14#ifndef LLVM_CLANG_SERIALIZATION_ASTWRITER_H
15#define LLVM_CLANG_SERIALIZATION_ASTWRITER_H
28#include "llvm/ADT/ArrayRef.h"
29#include "llvm/ADT/DenseMap.h"
30#include "llvm/ADT/DenseSet.h"
31#include "llvm/ADT/MapVector.h"
32#include "llvm/ADT/STLExtras.h"
33#include "llvm/ADT/SetVector.h"
34#include "llvm/ADT/SmallVector.h"
35#include "llvm/ADT/StringRef.h"
36#include "llvm/Bitstream/BitstreamWriter.h"
121 llvm::BitstreamWriter &Stream;
138 Module *WritingModule =
nullptr;
141 std::pair<uint64_t, uint64_t> UnhashedControlBlockRange;
143 uint64_t ASTBlockHashOffset = 0;
145 uint64_t SignatureOffset = 0;
148 uint64_t ASTBlockStartOffset = 0;
151 std::pair<uint64_t, uint64_t> ASTBlockRange;
154 std::string BaseDirectory;
160 bool IncludeTimestamps;
165 bool BuildingImplicitModule =
false;
169 bool WritingAST =
false;
173 bool DoneWritingDeclsAndTypes =
false;
176 bool ASTHasCompilerErrors =
false;
180 bool GeneratingReducedBMI =
false;
184 llvm::DenseMap<const FileEntry *, uint32_t> InputFileIDs;
189 DeclOrType(
Decl *D) : Stored(D), IsType(
false) {}
190 DeclOrType(
QualType T) : Stored(
T.getAsOpaquePtr()), IsType(
true) {}
192 bool isType()
const {
return IsType; }
193 bool isDecl()
const {
return !IsType; }
196 assert(isType() &&
"Not a type!");
200 Decl *getDecl()
const {
201 assert(isDecl() &&
"Not a decl!");
202 return static_cast<Decl *
>(Stored);
211 std::queue<DeclOrType> DeclTypesToEmit;
235 llvm::DenseMap<const Decl *, LocalDeclID> DeclIDs;
247 llvm::DenseMap<LocalDeclID, SmallVector<LocalDeclID, 4>> RelatedDeclsMap;
251 std::vector<serialization::DeclOffset> DeclOffsets;
255 uint64_t DeclTypesBlockStartOffset = 0;
259 struct DeclIDInFileInfo {
260 LocDeclIDsTy DeclIDs;
264 unsigned FirstDeclIndex;
266 using FileDeclIDsTy =
267 llvm::DenseMap<FileID, std::unique_ptr<DeclIDInFileInfo>>;
271 FileDeclIDsTy FileDeclIDs;
273 void associateDeclWithFile(
const Decl *D, LocalDeclID);
294 std::vector<serialization::UnalignedUInt64> TypeOffsets;
308 llvm::MapVector<const IdentifierInfo *, serialization::IdentifierID> IdentifierIDs;
317 llvm::DenseMap<MacroInfo *, serialization::MacroID> MacroIDs;
319 struct MacroInfoToEmitData {
320 const IdentifierInfo *Name;
326 std::vector<MacroInfoToEmitData> MacroInfosToEmit;
328 llvm::DenseMap<const IdentifierInfo *, uint32_t>
329 IdentMacroDirectivesOffsetMap;
335 llvm::DenseSet<Stmt *> ParentStmts;
339 llvm::DenseMap<Stmt *, uint64_t> SubStmtEntries;
345 std::vector<uint32_t> IdentifierOffsets;
362 llvm::MapVector<Selector, serialization::SelectorID> SelectorIDs;
366 std::vector<uint32_t> SelectorOffsets;
370 llvm::DenseMap<
const MacroDefinitionRecord *,
375 llvm::DenseMap<const Decl *, unsigned> AnonymousDeclarationNumbers;
382 llvm::SetVector<Module *> TouchedTopLevelModules;
383 llvm::SetVector<serialization::ModuleFile *> TouchedModuleFiles;
394 const Attr *Attribute;
400 : Kind(Kind), Dcl(Dcl) {}
402 : Kind(Kind), Type(Type.getAsOpaquePtr()) {}
404 : Kind(Kind), Loc(Loc.getRawEncoding()) {}
406 : Kind(Kind), Val(Val) {}
408 : Kind(Kind), Mod(M) {}
410 : Kind(Kind), Attribute(Attribute) {}
413 const Decl *getDecl()
const {
return Dcl; }
416 SourceLocation getLoc()
const {
420 unsigned getNumber()
const {
return Val; }
421 Module *getModule()
const {
return Mod; }
422 const Attr *getAttr()
const {
return Attribute; }
425 using UpdateRecord = SmallVector<DeclUpdate, 1>;
426 using DeclUpdateMap = llvm::MapVector<const Decl *, UpdateRecord>;
430 DeclUpdateMap DeclUpdates;
435 DeclUpdateMap DeclUpdatesLazy;
438 void prepareLazyUpdates();
440 void getLazyUpdates(
const Decl *D);
444 using SpecializationUpdateMap =
445 llvm::MapVector<const NamedDecl *, SmallVector<const Decl *>>;
446 SpecializationUpdateMap SpecializationsUpdates;
447 SpecializationUpdateMap PartialSpecializationsUpdates;
449 using FirstLatestDeclMap = llvm::DenseMap<Decl *, Decl *>;
453 FirstLatestDeclMap FirstLatestDecls;
476 llvm::SmallSetVector<const DeclContext *, 16> UpdatedDeclContexts;
481 llvm::SmallSetVector<const DeclContext *, 16> UpdatedDeclContextsLazy;
486 SmallVector<const Decl *, 16> DeclsToEmitEvenIfUnreferenced;
490 llvm::SetVector<ObjCInterfaceDecl *> ObjCClassesWithCategories;
494 llvm::SmallVector<const Decl *, 16> Redeclarations;
498 llvm::DenseMap<const Decl *, const Decl *> FirstLocalDeclCache;
501 llvm::DenseMap<SwitchCase *, unsigned> SwitchCaseIDs;
504 unsigned NumStatements = 0;
507 unsigned NumMacros = 0;
511 unsigned NumLexicalDeclContexts = 0;
515 unsigned NumVisibleDeclContexts = 0;
519 unsigned NumModuleLocalDeclContexts = 0;
522 unsigned NumTULocalDeclContexts = 0;
526 llvm::DenseMap<const Module *, unsigned> SubmoduleIDs;
529 std::vector<std::unique_ptr<ModuleFileExtensionWriter>>
530 ModuleFileExtensionWriters;
533 llvm::BitVector IsSLocAffecting;
536 llvm::BitVector IsSLocFileEntryAffecting;
539 std::vector<FileID> NonAffectingFileIDs;
540 std::vector<unsigned> NonAffectingFileIDAdjustments;
543 std::vector<SourceRange> NonAffectingRanges;
544 std::vector<SourceLocation::UIntTy> NonAffectingOffsetAdjustments;
548 llvm::SmallVector<CXXRecordDecl *> PendingEmittingVTables;
553 void computeNonAffectingInputFiles();
557 SourceLocation getAffectingIncludeLoc(
const SourceManager &SourceMgr,
558 const SrcMgr::FileInfo &
File);
562 FileID getAdjustedFileID(FileID FID)
const;
565 unsigned getAdjustedNumCreatedFIDs(FileID FID)
const;
568 SourceLocation getAdjustedLocation(SourceLocation Loc)
const;
571 SourceRange getAdjustedRange(SourceRange Range)
const;
580 unsigned getSubmoduleID(
Module *Mod);
583 void WriteSubStmt(ASTContext &Context, Stmt *S);
585 void WriteBlockInfoBlock();
586 void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
589 void writeUnhashedControlBlock(Preprocessor &PP);
590 ASTFileSignature backpatchSignature();
593 std::pair<ASTFileSignature, ASTFileSignature> createSignature()
const;
594 ASTFileSignature createSignatureForNamedModule()
const;
596 void WriteInputFiles(SourceManager &SourceMgr);
597 void WriteSourceManagerBlock(SourceManager &SourceMgr);
598 void WritePreprocessor(
const Preprocessor &PP,
bool IsModule);
599 void WriteHeaderSearch(
const HeaderSearch &HS);
600 void WritePreprocessorDetail(PreprocessingRecord &PPRec,
601 uint64_t MacroOffsetsBase);
602 void WriteSubmodules(
Module *WritingModule, ASTContext *Context);
604 void WritePragmaDiagnosticMappings(
const DiagnosticsEngine &
Diag,
607 unsigned TypeExtQualAbbrev = 0;
608 void WriteTypeAbbrevs();
609 void WriteType(ASTContext &Context, QualType
T);
611 void GenerateSpecializationInfoLookupTable(
612 const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
613 llvm::SmallVectorImpl<char> &LookupTable,
bool IsPartial);
614 uint64_t WriteSpecializationInfoLookupTable(
615 const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
618 GenerateNameLookupTable(ASTContext &Context,
const DeclContext *DC,
619 llvm::SmallVectorImpl<char> &LookupTable,
620 llvm::SmallVectorImpl<char> &ModuleLocalLookupTable,
621 llvm::SmallVectorImpl<char> &TULocalLookupTable);
622 uint64_t WriteDeclContextLexicalBlock(ASTContext &Context,
623 const DeclContext *DC);
624 void WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC,
625 VisibleLookupBlockOffsets &Offsets);
626 void WriteTypeDeclOffsets();
627 void WriteFileDeclIDsMap();
628 void WriteComments(ASTContext &Context);
629 void WriteSelectors(Sema &SemaRef);
630 void WriteReferencedSelectorsPool(Sema &SemaRef);
631 void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver *IdResolver,
633 void WriteDeclAndTypes(ASTContext &Context);
634 void PrepareWritingSpecialDecls(Sema &SemaRef);
635 void WriteSpecialDeclRecords(Sema &SemaRef);
636 void WriteSpecializationsUpdates(
bool IsPartial);
637 void WriteDeclUpdatesBlocks(ASTContext &Context,
639 void WriteDeclContextVisibleUpdate(ASTContext &Context,
640 const DeclContext *DC);
641 void WriteFPPragmaOptions(
const FPOptionsOverride &Opts);
642 void WriteOpenCLExtensions(Sema &SemaRef);
643 void WriteCUDAPragmas(Sema &SemaRef);
644 void WriteObjCCategories();
645 void WriteLateParsedTemplates(Sema &SemaRef);
646 void WriteOptimizePragmaOptions(Sema &SemaRef);
647 void WriteMSStructPragmaOptions(Sema &SemaRef);
648 void WriteMSPointersToMembersPragmaOptions(Sema &SemaRef);
649 void WritePackPragmaOptions(Sema &SemaRef);
650 void WriteFloatControlPragmaOptions(Sema &SemaRef);
651 void WriteDeclsWithEffectsToVerify(Sema &SemaRef);
652 void WriteOpenMPRequiresDecls(Sema &SemaRef);
653 void WriteModuleFileExtension(Sema &SemaRef,
654 ModuleFileExtensionWriter &Writer);
655 void WriteRISCVIntrinsicPragmas(Sema &SemaRef);
657 unsigned DeclParmVarAbbrev = 0;
658 unsigned DeclContextLexicalAbbrev = 0;
659 unsigned DeclContextVisibleLookupAbbrev = 0;
660 unsigned DeclModuleLocalVisibleLookupAbbrev = 0;
661 unsigned DeclTULocalLookupAbbrev = 0;
662 unsigned UpdateVisibleAbbrev = 0;
663 unsigned ModuleLocalUpdateVisibleAbbrev = 0;
664 unsigned TULocalUpdateVisibleAbbrev = 0;
665 unsigned DeclRecordAbbrev = 0;
666 unsigned DeclTypedefAbbrev = 0;
667 unsigned DeclVarAbbrev = 0;
668 unsigned DeclFieldAbbrev = 0;
669 unsigned DeclEnumAbbrev = 0;
670 unsigned DeclObjCIvarAbbrev = 0;
671 unsigned DeclCXXMethodAbbrev = 0;
672 unsigned DeclSpecializationsAbbrev = 0;
673 unsigned DeclPartialSpecializationsAbbrev = 0;
675 unsigned DeclDependentNonTemplateCXXMethodAbbrev = 0;
676 unsigned DeclTemplateCXXMethodAbbrev = 0;
677 unsigned DeclMemberSpecializedCXXMethodAbbrev = 0;
678 unsigned DeclTemplateSpecializedCXXMethodAbbrev = 0;
679 unsigned DeclDependentSpecializationCXXMethodAbbrev = 0;
680 unsigned DeclTemplateTypeParmAbbrev = 0;
681 unsigned DeclUsingShadowAbbrev = 0;
683 unsigned DeclRefExprAbbrev = 0;
684 unsigned CharacterLiteralAbbrev = 0;
685 unsigned IntegerLiteralAbbrev = 0;
686 unsigned ExprImplicitCastAbbrev = 0;
687 unsigned BinaryOperatorAbbrev = 0;
688 unsigned CompoundAssignOperatorAbbrev = 0;
689 unsigned CallExprAbbrev = 0;
690 unsigned CXXOperatorCallExprAbbrev = 0;
691 unsigned CXXMemberCallExprAbbrev = 0;
693 unsigned CompoundStmtAbbrev = 0;
695 void WriteDeclAbbrevs();
696 void WriteDecl(ASTContext &Context, Decl *D);
698 ASTFileSignature WriteASTCore(Sema *SemaPtr, StringRef isysroot,
704 ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl<char> &Buffer,
705 ModuleCache &ModCache,
const CodeGenOptions &CodeGenOpts,
706 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
707 bool IncludeTimestamps =
true,
bool BuildingImplicitModule =
false,
708 bool GeneratingReducedBMI =
false);
737 StringRef OutputFile,
Module *WritingModule,
810 auto I = DeclIDs.find(D);
816 llvm::MapVector<serialization::ModuleFile *, const Decl *>
893 return TypeExtQualAbbrev;
906 return DeclCXXMethodAbbrev;
908 return DeclTemplateCXXMethodAbbrev;
910 return DeclMemberSpecializedCXXMethodAbbrev;
912 return DeclTemplateSpecializedCXXMethodAbbrev;
914 return DeclDependentNonTemplateCXXMethodAbbrev;
916 return DeclDependentSpecializationCXXMethodAbbrev;
918 llvm_unreachable(
"Unknwon Template Kind!");
921 return DeclTemplateTypeParmAbbrev;
931 return CompoundAssignOperatorAbbrev;
945 return WritingModule && WritingModule->isNamedModule();
949 return WritingModule && WritingModule->isHeaderUnit();
957 return PredefinedDecls.count(D);
966 void ReaderInitialized(
ASTReader *Reader)
override;
977 void CompletedTagDefinition(
const TagDecl *D)
override;
980 void AddedCXXTemplateSpecialization(
983 void AddedCXXTemplateSpecialization(
988 void ResolvedExceptionSpec(
const FunctionDecl *FD)
override;
992 Expr *ThisArg)
override;
999 void CompletedImplicitDefinition(
const FunctionDecl *D)
override;
1000 void InstantiationRequested(
const ValueDecl *D)
override;
1001 void VariableDefinitionInstantiated(
const VarDecl *D)
override;
1002 void FunctionDefinitionInstantiated(
const FunctionDecl *D)
override;
1003 void DefaultArgumentInstantiated(
const ParmVarDecl *D)
override;
1004 void DefaultMemberInitializerInstantiated(
const FieldDecl *D)
override;
1007 void DeclarationMarkedUsed(
const Decl *D)
override;
1008 void DeclarationMarkedOpenMPThreadPrivate(
const Decl *D)
override;
1009 void DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
1011 void DeclarationMarkedOpenMPAllocate(
const Decl *D,
const Attr *A)
override;
1012 void DeclarationMarkedOpenMPIndirectCall(
const Decl *D)
override;
1013 void RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M)
override;
1014 void AddedAttributeToRecord(
const Attr *
Attr,
1016 void AddedManglingNumber(
const Decl *D,
unsigned)
override;
1017 void AddedStaticLocalNumbers(
const Decl *D,
unsigned)
override;
1025 void anchor()
override;
1028 llvm::PointerUnion<Sema *, Preprocessor *> Subject;
1029 std::string OutputFile;
1030 std::string isysroot;
1031 std::shared_ptr<PCHBuffer> Buffer;
1032 llvm::BitstreamWriter Stream;
1034 bool AllowASTWithErrors;
1051 StringRef isysroot, std::shared_ptr<PCHBuffer> Buffer,
1053 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
1054 bool AllowASTWithErrors =
false,
bool IncludeTimestamps =
true,
1055 bool BuildingImplicitModule =
false,
1056 bool GeneratingReducedBMI =
false);
1068 void anchor()
override;
1075 bool GeneratingReducedBMI,
bool AllowASTWithErrors);
1080 bool AllowASTWithErrors =
false)
1083 AllowASTWithErrors) {}
1089 void anchor()
override;
1094 bool AllowASTWithErrors =
false)
1097 AllowASTWithErrors) {}
1109 constexpr static uint32_t BitIndexUpbound = 32u;
1120 return CurrentBitIndex + BitsWidth < BitIndexUpbound;
1124 UnderlyingValue =
Value;
1125 CurrentBitIndex = 0;
1130 assert(BitsWidth < BitIndexUpbound);
1131 assert((
Value < (1u << BitsWidth)) &&
"Passing narrower bit width!");
1133 "Inserting too much bits into a value!");
1135 UnderlyingValue |=
Value << CurrentBitIndex;
1136 CurrentBitIndex += BitsWidth;
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Record Record
Defines the clang::SourceLocation class and associated facilities.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Reads an AST files chain containing the contents of a translation unit.
Writes an AST file containing the contents of a translation unit.
static SourceLocationEncoding::Chain EmitSourceLocationOffset(SourceLocation::UIntTy Offset, SourceLocation::UIntTy InitialDelta, RecordDataImpl &Record)
Emit Offset as the next record field and return a chain anchored at Offset + InitialDelta,...
SourceLocation::UIntTy getEntryOffset(const SrcMgr::SLocEntry &SLoc) const
The starting offset of SLoc's entry within this module, with the dummy entry skipped.
unsigned getDeclParmVarAbbrev() const
void AddEmittedDeclRef(const Decl *D, RecordDataImpl &Record)
friend class ASTRecordWriter
unsigned getBinaryOperatorAbbrev() const
unsigned getDeclTemplateTypeParmAbbrev() const
bool isWritingStdCXXNamedModules() const
ArrayRef< uint64_t > RecordDataRef
void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record, StringRef Path)
Emit the current record with the given path as a blob.
void AddFileID(FileID FID, RecordDataImpl &Record)
Emit a FileID.
unsigned getDeclObjCIvarAbbrev() const
unsigned getExprImplicitCastAbbrev() const
bool isDeclPredefined(const Decl *D) const
unsigned getDeclTypedefAbbrev() const
bool IsLocalDecl(const Decl *D) const
Is this a local declaration (that is, one that will be written to our AST file)?
unsigned getSwitchCaseID(SwitchCase *S)
Retrieve the ID for the given switch-case statement.
void AddPath(StringRef Path, RecordDataImpl &Record)
Add a path to the given record.
SmallVectorImpl< uint64_t > RecordDataImpl
unsigned getDeclUsingShadowAbbrev() const
unsigned getTypeExtQualAbbrev() const
void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record)
Add a version tuple to the given record.
bool isGeneratingReducedBMI() const
uint32_t getMacroDirectivesOffset(const IdentifierInfo *Name)
unsigned getDeclVarAbbrev() const
unsigned getDeclEnumAbbrev() const
void AddAlignPackInfo(const Sema::AlignPackInfo &Info, RecordDataImpl &Record)
Emit a AlignPackInfo.
void AddPathBlob(StringRef Str, RecordDataImpl &Record, SmallVectorImpl< char > &Blob)
unsigned getDeclRefExprAbbrev() const
llvm::MapVector< serialization::ModuleFile *, const Decl * > CollectFirstDeclFromEachModule(const Decl *D, bool IncludeLocal)
Collect the first declaration from each module file that provides a declaration of D.
void AddTypeRef(ASTContext &Context, QualType T, RecordDataImpl &Record)
Emit a reference to a type.
unsigned getCXXOperatorCallExprAbbrev()
bool wasDeclEmitted(const Decl *D) const
Whether or not the declaration got emitted.
void AddString(StringRef Str, RecordDataImpl &Record)
Add a string to the given record.
void ClearSwitchCaseIDs()
bool isWritingModule() const
LocalDeclID GetDeclRef(const Decl *D)
Force a declaration to be emitted and get its local ID to the module file been writing.
void AddSourceRange(SourceRange Range, RecordDataImpl &Record)
Emit a source range.
LocalDeclID getDeclID(const Decl *D)
Determine the local declaration ID of an already-emitted declaration.
void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record)
Emit a source location.
ASTFileSignature WriteAST(llvm::PointerUnion< Sema *, Preprocessor * > Subject, StringRef OutputFile, Module *WritingModule, StringRef isysroot)
Write a precompiled header or a module with the AST produced by the Sema object, or a dependency scan...
void addTouchedModuleFile(serialization::ModuleFile *)
void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record)
Emit a reference to an identifier.
const CodeGenOptions & getCodeGenOpts() const
serialization::MacroID getMacroRef(MacroInfo *MI, const IdentifierInfo *Name)
Get the unique number used to refer to the given macro.
SourceLocationEncoding::RawLocEncoding getRawSourceLocationEncoding(SourceLocation Loc)
Return the raw encodings for source locations.
unsigned getCXXMemberCallExprAbbrev()
ASTReader * getChain() const
unsigned getCompoundAssignOperatorAbbrev() const
SourceLocationEncoding::Chain EmitEntryOffset(const SrcMgr::SLocEntry &SLoc, RecordDataImpl &Record)
Emit SLoc's entry offset as the record's first field and return a chain anchored at that entry,...
bool getDoneWritingDeclsAndTypes() const
friend class ASTDeclWriter
serialization::IdentifierID getIdentifierRef(const IdentifierInfo *II)
Get the unique number used to refer to the given identifier.
unsigned RecordSwitchCaseID(SwitchCase *S)
Record an ID for the given switch-case statement.
ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl< char > &Buffer, ModuleCache &ModCache, const CodeGenOptions &CodeGenOpts, ArrayRef< std::shared_ptr< ModuleFileExtension > > Extensions, bool IncludeTimestamps=true, bool BuildingImplicitModule=false, bool GeneratingReducedBMI=false)
Create a new precompiled header writer that outputs to the given bitstream.
unsigned getCharacterLiteralAbbrev() const
time_t getTimestampForOutput(time_t ModTime) const
Get a timestamp for output into the AST file.
unsigned getDeclCXXMethodAbbrev(FunctionDecl::TemplatedKind Kind) const
void handleVTable(CXXRecordDecl *RD)
bool isWritingStdCXXHeaderUnit() const
unsigned getCompoundStmtAbbrev() const
unsigned getLocalOrImportedSubmoduleID(const Module *Mod)
Retrieve or create a submodule ID for this module, or return 0 if the submodule is neither local (a s...
const Decl * getFirstLocalDecl(const Decl *D)
Find the first local declaration of a given local redeclarable decl.
void AddToken(const Token &Tok, RecordDataImpl &Record)
Emit a token.
void AddLookupOffsets(const LookupBlockOffsets &Offsets, RecordDataImpl &Record)
serialization::SelectorID getSelectorRef(Selector Sel)
Get the unique number used to refer to the given selector.
SmallVector< uint64_t, 64 > RecordData
serialization::TypeID GetOrCreateTypeID(ASTContext &Context, QualType T)
Force a type to be emitted and get its ID.
unsigned getAnonymousDeclarationNumber(const NamedDecl *D)
unsigned getDeclFieldAbbrev() const
void AddMacroRef(MacroInfo *MI, const IdentifierInfo *Name, RecordDataImpl &Record)
Emit a reference to a macro.
const LangOptions & getLangOpts() const
void SetSelectorOffset(Selector Sel, uint32_t Offset)
Note that the selector Sel occurs at the given offset within the method pool/selector table.
bool PreparePathForOutput(SmallVectorImpl< char > &Path)
Convert a path from this build process into one that is appropriate for emission in the module file.
unsigned getCallExprAbbrev() const
void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset)
Note that the identifier II occurs at the given offset within the identifier table.
unsigned getDeclRecordAbbrev() const
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
void AddStringBlob(StringRef Str, RecordDataImpl &Record, SmallVectorImpl< char > &Blob)
unsigned getIntegerLiteralAbbrev() const
Attr - This represents one attribute.
bool canWriteNextNBits(uint32_t BitsWidth) const
BitsPacker operator=(BitsPacker &&)=delete
BitsPacker(BitsPacker &&)=delete
void addBits(uint32_t Value, uint32_t BitsWidth)
void reset(uint32_t Value)
BitsPacker(const BitsPacker &)=delete
BitsPacker operator=(const BitsPacker &)=delete
CXX20ModulesGenerator(Preprocessor &PP, ModuleCache &ModCache, StringRef OutputFile, const CodeGenOptions &CodeGenOpts, bool GeneratingReducedBMI, bool AllowASTWithErrors)
void HandleTranslationUnit(ASTContext &Ctx) override
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
virtual Module * getEmittingModule(ASTContext &Ctx) override
CXX20ModulesGenerator(Preprocessor &PP, ModuleCache &ModCache, StringRef OutputFile, const CodeGenOptions &CodeGenOpts, bool AllowASTWithErrors=false)
Represents a C++ destructor within a class.
Represents a C++ struct/union/class.
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Decl - This represents one declaration (or definition), e.g.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Concrete class used by the front-end to report problems and issues.
This represents one expression.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
Cached information about one file (either on disk or in the virtual file system).
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a function declaration or definition.
TemplatedKind
The kind of templated function a FunctionDecl can be.
@ TK_MemberSpecialization
@ TK_DependentNonTemplate
@ TK_FunctionTemplateSpecialization
@ TK_DependentFunctionTemplateSpecialization
Declaration of a template function.
One of these records is kept for each identifier that is lexed.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Record the location of a macro definition.
Encapsulates the data about a macro definition (e.g.
The module cache used for compiling modules implicitly.
Abstract base class that writes a module file extension block into a module file.
An abstract superclass that describes a custom extension to the module/precompiled header file format...
Describes a module or submodule.
This represents a decl that may have a name.
Represent a C++ namespace.
ObjCCategoryDecl - Represents a category declaration.
Represents an ObjC class declaration.
ASTMutationListener * GetASTMutationListener() override
If the consumer is interested in entities getting modified after their initial creation,...
void InitializeSema(Sema &S) override
Initialize the semantic consumer with the Sema instance being used to perform semantic analysis on th...
PCHBuffer * getBufferPtr()
Preprocessor & getPreprocessor()
virtual Module * getEmittingModule(ASTContext &Ctx)
SmallVectorImpl< char > & getPCH() const
StringRef getOutputFile() const
void HandleVTable(CXXRecordDecl *RD) override
Callback involved at the end of a translation unit to notify the consumer that a vtable for the given...
ASTDeserializationListener * GetASTDeserializationListener() override
If the consumer is interested in entities being deserialized from AST files, it should return a point...
PCHGenerator(Preprocessor &PP, ModuleCache &ModCache, StringRef OutputFile, StringRef isysroot, std::shared_ptr< PCHBuffer > Buffer, const CodeGenOptions &CodeGenOpts, ArrayRef< std::shared_ptr< ModuleFileExtension > > Extensions, bool AllowASTWithErrors=false, bool IncludeTimestamps=true, bool BuildingImplicitModule=false, bool GeneratingReducedBMI=false)
const ASTWriter & getWriter() const
void HandleTranslationUnit(ASTContext &Ctx) override
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
bool hasEmittedPCH() const
DiagnosticsEngine & getDiagnostics() const
Represents a parameter to a function.
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
A (possibly-)qualified type.
static QualType getFromOpaquePtr(const void *Ptr)
Represents a struct/union/class.
ReducedBMIGenerator(Preprocessor &PP, ModuleCache &ModCache, StringRef OutputFile, const CodeGenOptions &CodeGenOpts, bool AllowASTWithErrors=false)
Smart pointer class that efficiently represents Objective-C method names.
Sema - This implements semantic analysis and AST building for C.
A delta encoder for a run of source locations.
Encodes a location in the source.
static SourceLocation getFromRawEncoding(UIntTy Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
Information about a FileID, basically just the logical file that it represents and include stack info...
This is a discriminated union of FileInfo and ExpansionInfo.
Stmt - This represents one statement.
An array of decls optimized for the common case of only containing one entry.
Represents the declaration of a struct/union/class/enum.
Token - This structure provides full information about a lexed token.
The top declaration context.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
Declaration of a variable template.
Represents a variable template specialization, which refers to a variable template with a given set o...
Information about a module that has been loaded by the ASTReader.
A type index; the type ID with the qualifier bits removed.
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
Public enums and private classes that are part of the SourceManager implementation.
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
uint64_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
uint64_t MacroID
An ID number that refers to a macro in an AST file.
uint64_t TypeID
An ID number that refers to a type in an AST file.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
uint64_t IdentifierID
An ID number that refers to an identifier in an AST file.
Top level wrappers for InstallAPI frontend operations.
@ Delete
'delete' clause, allowed on the 'exit data' construct.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
PredefinedDeclIDs
Predefined declaration IDs.
@ NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
const FunctionProtoType * T
bool CanElideDeclDef(const Decl *D)
If we can elide the definition of.
The signature of a module, which is a hash of the AST content.
A structure for putting "fast"-unqualified QualTypes into a DenseMap.