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"
120 llvm::BitstreamWriter &Stream;
137 Module *WritingModule =
nullptr;
140 std::pair<uint64_t, uint64_t> UnhashedControlBlockRange;
142 uint64_t ASTBlockHashOffset = 0;
144 uint64_t SignatureOffset = 0;
147 uint64_t ASTBlockStartOffset = 0;
150 std::pair<uint64_t, uint64_t> ASTBlockRange;
153 std::string BaseDirectory;
159 bool IncludeTimestamps;
164 bool BuildingImplicitModule =
false;
168 bool WritingAST =
false;
172 bool DoneWritingDeclsAndTypes =
false;
175 bool ASTHasCompilerErrors =
false;
179 bool GeneratingReducedBMI =
false;
183 llvm::DenseMap<const FileEntry *, uint32_t> InputFileIDs;
188 DeclOrType(
Decl *D) : Stored(D), IsType(
false) {}
189 DeclOrType(
QualType T) : Stored(T.getAsOpaquePtr()), IsType(
true) {}
191 bool isType()
const {
return IsType; }
192 bool isDecl()
const {
return !IsType; }
195 assert(isType() &&
"Not a type!");
199 Decl *getDecl()
const {
200 assert(isDecl() &&
"Not a decl!");
201 return static_cast<Decl *
>(Stored);
210 std::queue<DeclOrType> DeclTypesToEmit;
234 llvm::DenseMap<const Decl *, LocalDeclID> DeclIDs;
246 llvm::DenseMap<LocalDeclID, SmallVector<LocalDeclID, 4>> RelatedDeclsMap;
250 std::vector<serialization::DeclOffset> DeclOffsets;
254 uint64_t DeclTypesBlockStartOffset = 0;
258 struct DeclIDInFileInfo {
259 LocDeclIDsTy DeclIDs;
263 unsigned FirstDeclIndex;
265 using FileDeclIDsTy =
266 llvm::DenseMap<FileID, std::unique_ptr<DeclIDInFileInfo>>;
270 FileDeclIDsTy FileDeclIDs;
272 void associateDeclWithFile(
const Decl *D, LocalDeclID);
293 std::vector<serialization::UnalignedUInt64> TypeOffsets;
307 llvm::MapVector<const IdentifierInfo *, serialization::IdentifierID> IdentifierIDs;
316 llvm::DenseMap<MacroInfo *, serialization::MacroID> MacroIDs;
318 struct MacroInfoToEmitData {
319 const IdentifierInfo *Name;
325 std::vector<MacroInfoToEmitData> MacroInfosToEmit;
327 llvm::DenseMap<const IdentifierInfo *, uint32_t>
328 IdentMacroDirectivesOffsetMap;
334 llvm::DenseSet<Stmt *> ParentStmts;
338 llvm::DenseMap<Stmt *, uint64_t> SubStmtEntries;
344 std::vector<uint32_t> IdentifierOffsets;
361 llvm::MapVector<Selector, serialization::SelectorID> SelectorIDs;
365 std::vector<uint32_t> SelectorOffsets;
369 llvm::DenseMap<
const MacroDefinitionRecord *,
374 llvm::DenseMap<const Decl *, unsigned> AnonymousDeclarationNumbers;
381 llvm::SetVector<Module *> TouchedTopLevelModules;
382 llvm::SetVector<serialization::ModuleFile *> TouchedModuleFiles;
393 const Attr *Attribute;
399 : Kind(Kind), Dcl(Dcl) {}
401 : Kind(Kind), Type(Type.getAsOpaquePtr()) {}
403 : Kind(Kind), Loc(Loc.getRawEncoding()) {}
405 : Kind(Kind), Val(Val) {}
407 : Kind(Kind), Mod(M) {}
409 : Kind(Kind), Attribute(Attribute) {}
412 const Decl *getDecl()
const {
return Dcl; }
415 SourceLocation getLoc()
const {
419 unsigned getNumber()
const {
return Val; }
420 Module *getModule()
const {
return Mod; }
421 const Attr *getAttr()
const {
return Attribute; }
424 using UpdateRecord = SmallVector<DeclUpdate, 1>;
425 using DeclUpdateMap = llvm::MapVector<const Decl *, UpdateRecord>;
429 DeclUpdateMap DeclUpdates;
434 DeclUpdateMap DeclUpdatesLazy;
437 void prepareLazyUpdates();
439 void getLazyUpdates(
const Decl *D);
443 using SpecializationUpdateMap =
444 llvm::MapVector<const NamedDecl *, SmallVector<const Decl *>>;
445 SpecializationUpdateMap SpecializationsUpdates;
446 SpecializationUpdateMap PartialSpecializationsUpdates;
448 using FirstLatestDeclMap = llvm::DenseMap<Decl *, Decl *>;
452 FirstLatestDeclMap FirstLatestDecls;
475 llvm::SmallSetVector<const DeclContext *, 16> UpdatedDeclContexts;
480 llvm::SmallSetVector<const DeclContext *, 16> UpdatedDeclContextsLazy;
485 SmallVector<const Decl *, 16> DeclsToEmitEvenIfUnreferenced;
489 llvm::SetVector<ObjCInterfaceDecl *> ObjCClassesWithCategories;
493 llvm::SmallVector<const Decl *, 16> Redeclarations;
497 llvm::DenseMap<const Decl *, const Decl *> FirstLocalDeclCache;
500 llvm::DenseMap<SwitchCase *, unsigned> SwitchCaseIDs;
503 unsigned NumStatements = 0;
506 unsigned NumMacros = 0;
510 unsigned NumLexicalDeclContexts = 0;
514 unsigned NumVisibleDeclContexts = 0;
518 unsigned NumModuleLocalDeclContexts = 0;
521 unsigned NumTULocalDeclContexts = 0;
525 llvm::DenseMap<const Module *, unsigned> SubmoduleIDs;
528 std::vector<std::unique_ptr<ModuleFileExtensionWriter>>
529 ModuleFileExtensionWriters;
532 llvm::BitVector IsSLocAffecting;
535 llvm::BitVector IsSLocFileEntryAffecting;
538 std::vector<FileID> NonAffectingFileIDs;
539 std::vector<unsigned> NonAffectingFileIDAdjustments;
542 std::vector<SourceRange> NonAffectingRanges;
543 std::vector<SourceLocation::UIntTy> NonAffectingOffsetAdjustments;
547 llvm::SmallVector<CXXRecordDecl *> PendingEmittingVTables;
552 void computeNonAffectingInputFiles();
556 SourceLocation getAffectingIncludeLoc(
const SourceManager &SourceMgr,
557 const SrcMgr::FileInfo &
File);
561 FileID getAdjustedFileID(FileID FID)
const;
564 unsigned getAdjustedNumCreatedFIDs(FileID FID)
const;
567 SourceLocation getAdjustedLocation(SourceLocation Loc)
const;
570 SourceRange getAdjustedRange(SourceRange Range)
const;
579 unsigned getSubmoduleID(
Module *Mod);
582 void WriteSubStmt(ASTContext &Context, Stmt *S);
584 void WriteBlockInfoBlock();
585 void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
588 void writeUnhashedControlBlock(Preprocessor &PP);
589 ASTFileSignature backpatchSignature();
592 std::pair<ASTFileSignature, ASTFileSignature> createSignature()
const;
593 ASTFileSignature createSignatureForNamedModule()
const;
595 void WriteInputFiles(SourceManager &SourceMgr);
596 void WriteSourceManagerBlock(SourceManager &SourceMgr);
597 void WritePreprocessor(
const Preprocessor &PP,
bool IsModule);
598 void WriteHeaderSearch(
const HeaderSearch &HS);
599 void WritePreprocessorDetail(PreprocessingRecord &PPRec,
600 uint64_t MacroOffsetsBase);
601 void WriteSubmodules(
Module *WritingModule, ASTContext *Context);
603 void WritePragmaDiagnosticMappings(
const DiagnosticsEngine &
Diag,
606 unsigned TypeExtQualAbbrev = 0;
607 void WriteTypeAbbrevs();
608 void WriteType(ASTContext &Context, QualType T);
610 void GenerateSpecializationInfoLookupTable(
611 const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
612 llvm::SmallVectorImpl<char> &LookupTable,
bool IsPartial);
613 uint64_t WriteSpecializationInfoLookupTable(
614 const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
617 GenerateNameLookupTable(ASTContext &Context,
const DeclContext *DC,
618 llvm::SmallVectorImpl<char> &LookupTable,
619 llvm::SmallVectorImpl<char> &ModuleLocalLookupTable,
620 llvm::SmallVectorImpl<char> &TULocalLookupTable);
621 uint64_t WriteDeclContextLexicalBlock(ASTContext &Context,
622 const DeclContext *DC);
623 void WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC,
624 VisibleLookupBlockOffsets &Offsets);
625 void WriteTypeDeclOffsets();
626 void WriteFileDeclIDsMap();
627 void WriteComments(ASTContext &Context);
628 void WriteSelectors(Sema &SemaRef);
629 void WriteReferencedSelectorsPool(Sema &SemaRef);
630 void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver *IdResolver,
632 void WriteDeclAndTypes(ASTContext &Context);
633 void PrepareWritingSpecialDecls(Sema &SemaRef);
634 void WriteSpecialDeclRecords(Sema &SemaRef);
635 void WriteSpecializationsUpdates(
bool IsPartial);
636 void WriteDeclUpdatesBlocks(ASTContext &Context,
638 void WriteDeclContextVisibleUpdate(ASTContext &Context,
639 const DeclContext *DC);
640 void WriteFPPragmaOptions(
const FPOptionsOverride &Opts);
641 void WriteOpenCLExtensions(Sema &SemaRef);
642 void WriteCUDAPragmas(Sema &SemaRef);
643 void WriteObjCCategories();
644 void WriteLateParsedTemplates(Sema &SemaRef);
645 void WriteOptimizePragmaOptions(Sema &SemaRef);
646 void WriteMSStructPragmaOptions(Sema &SemaRef);
647 void WriteMSPointersToMembersPragmaOptions(Sema &SemaRef);
648 void WritePackPragmaOptions(Sema &SemaRef);
649 void WriteFloatControlPragmaOptions(Sema &SemaRef);
650 void WriteDeclsWithEffectsToVerify(Sema &SemaRef);
651 void WriteModuleFileExtension(Sema &SemaRef,
652 ModuleFileExtensionWriter &Writer);
653 void WriteRISCVIntrinsicPragmas(Sema &SemaRef);
655 unsigned DeclParmVarAbbrev = 0;
656 unsigned DeclContextLexicalAbbrev = 0;
657 unsigned DeclContextVisibleLookupAbbrev = 0;
658 unsigned DeclModuleLocalVisibleLookupAbbrev = 0;
659 unsigned DeclTULocalLookupAbbrev = 0;
660 unsigned UpdateVisibleAbbrev = 0;
661 unsigned ModuleLocalUpdateVisibleAbbrev = 0;
662 unsigned TULocalUpdateVisibleAbbrev = 0;
663 unsigned DeclRecordAbbrev = 0;
664 unsigned DeclTypedefAbbrev = 0;
665 unsigned DeclVarAbbrev = 0;
666 unsigned DeclFieldAbbrev = 0;
667 unsigned DeclEnumAbbrev = 0;
668 unsigned DeclObjCIvarAbbrev = 0;
669 unsigned DeclCXXMethodAbbrev = 0;
670 unsigned DeclSpecializationsAbbrev = 0;
671 unsigned DeclPartialSpecializationsAbbrev = 0;
673 unsigned DeclDependentNonTemplateCXXMethodAbbrev = 0;
674 unsigned DeclTemplateCXXMethodAbbrev = 0;
675 unsigned DeclMemberSpecializedCXXMethodAbbrev = 0;
676 unsigned DeclTemplateSpecializedCXXMethodAbbrev = 0;
677 unsigned DeclDependentSpecializationCXXMethodAbbrev = 0;
678 unsigned DeclTemplateTypeParmAbbrev = 0;
679 unsigned DeclUsingShadowAbbrev = 0;
681 unsigned DeclRefExprAbbrev = 0;
682 unsigned CharacterLiteralAbbrev = 0;
683 unsigned IntegerLiteralAbbrev = 0;
684 unsigned ExprImplicitCastAbbrev = 0;
685 unsigned BinaryOperatorAbbrev = 0;
686 unsigned CompoundAssignOperatorAbbrev = 0;
687 unsigned CallExprAbbrev = 0;
688 unsigned CXXOperatorCallExprAbbrev = 0;
689 unsigned CXXMemberCallExprAbbrev = 0;
691 unsigned CompoundStmtAbbrev = 0;
693 void WriteDeclAbbrevs();
694 void WriteDecl(ASTContext &Context, Decl *D);
696 ASTFileSignature WriteASTCore(Sema *SemaPtr, StringRef isysroot,
702 ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl<char> &Buffer,
703 ModuleCache &ModCache,
const CodeGenOptions &CodeGenOpts,
704 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
705 bool IncludeTimestamps =
true,
bool BuildingImplicitModule =
false,
706 bool GeneratingReducedBMI =
false);
735 StringRef OutputFile,
Module *WritingModule,
737 bool ShouldCacheASTInMemory =
false);
789 auto I = DeclIDs.find(D);
795 llvm::MapVector<serialization::ModuleFile *, const Decl *>
872 return TypeExtQualAbbrev;
885 return DeclCXXMethodAbbrev;
887 return DeclTemplateCXXMethodAbbrev;
889 return DeclMemberSpecializedCXXMethodAbbrev;
891 return DeclTemplateSpecializedCXXMethodAbbrev;
893 return DeclDependentNonTemplateCXXMethodAbbrev;
895 return DeclDependentSpecializationCXXMethodAbbrev;
897 llvm_unreachable(
"Unknwon Template Kind!");
900 return DeclTemplateTypeParmAbbrev;
910 return CompoundAssignOperatorAbbrev;
924 return WritingModule && WritingModule->isNamedModule();
928 return WritingModule && WritingModule->isHeaderUnit();
936 return PredefinedDecls.count(D);
945 void ReaderInitialized(
ASTReader *Reader)
override;
956 void CompletedTagDefinition(
const TagDecl *D)
override;
959 void AddedCXXTemplateSpecialization(
962 void AddedCXXTemplateSpecialization(
967 void ResolvedExceptionSpec(
const FunctionDecl *FD)
override;
971 Expr *ThisArg)
override;
978 void CompletedImplicitDefinition(
const FunctionDecl *D)
override;
979 void InstantiationRequested(
const ValueDecl *D)
override;
980 void VariableDefinitionInstantiated(
const VarDecl *D)
override;
981 void FunctionDefinitionInstantiated(
const FunctionDecl *D)
override;
982 void DefaultArgumentInstantiated(
const ParmVarDecl *D)
override;
983 void DefaultMemberInitializerInstantiated(
const FieldDecl *D)
override;
986 void DeclarationMarkedUsed(
const Decl *D)
override;
987 void DeclarationMarkedOpenMPThreadPrivate(
const Decl *D)
override;
988 void DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
990 void DeclarationMarkedOpenMPAllocate(
const Decl *D,
const Attr *A)
override;
991 void DeclarationMarkedOpenMPIndirectCall(
const Decl *D)
override;
992 void RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M)
override;
993 void AddedAttributeToRecord(
const Attr *
Attr,
995 void AddedManglingNumber(
const Decl *D,
unsigned)
override;
996 void AddedStaticLocalNumbers(
const Decl *D,
unsigned)
override;
1004 void anchor()
override;
1007 llvm::PointerUnion<Sema *, Preprocessor *> Subject;
1008 std::string OutputFile;
1009 std::string isysroot;
1010 std::shared_ptr<PCHBuffer> Buffer;
1011 llvm::BitstreamWriter Stream;
1013 bool AllowASTWithErrors;
1014 bool ShouldCacheASTInMemory;
1031 StringRef isysroot, std::shared_ptr<PCHBuffer> Buffer,
1033 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
1034 bool AllowASTWithErrors =
false,
bool IncludeTimestamps =
true,
1035 bool BuildingImplicitModule =
false,
1036 bool ShouldCacheASTInMemory =
false,
1037 bool GeneratingReducedBMI =
false);
1049 void anchor()
override;
1056 bool GeneratingReducedBMI,
bool AllowASTWithErrors);
1061 bool AllowASTWithErrors =
false)
1064 AllowASTWithErrors) {}
1070 void anchor()
override;
1075 bool AllowASTWithErrors =
false)
1078 AllowASTWithErrors) {}
1090 constexpr static uint32_t BitIndexUpbound = 32u;
1101 return CurrentBitIndex + BitsWidth < BitIndexUpbound;
1105 UnderlyingValue =
Value;
1106 CurrentBitIndex = 0;
1111 assert(BitsWidth < BitIndexUpbound);
1112 assert((
Value < (1u << BitsWidth)) &&
"Passing narrower bit width!");
1114 "Inserting too much bits into a value!");
1116 UnderlyingValue |=
Value << CurrentBitIndex;
1117 CurrentBitIndex += BitsWidth;
1120 operator uint32_t() {
return UnderlyingValue; }
1123 uint32_t UnderlyingValue = 0;
1124 uint32_t CurrentBitIndex = 0;
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.
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.
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()
ASTFileSignature WriteAST(llvm::PointerUnion< Sema *, Preprocessor * > Subject, StringRef OutputFile, Module *WritingModule, StringRef isysroot, bool ShouldCacheASTInMemory=false)
Write a precompiled header or a module with the AST produced by the Sema object, or a dependency scan...
ASTReader * getChain() const
unsigned getCompoundAssignOperatorAbbrev() const
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
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 ShouldCacheASTInMemory=false, bool GeneratingReducedBMI=false)
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...
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.
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...
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.
The JSON file list parser is used to communicate input to InstallAPI.
@ 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.
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.