14 #ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H
15 #define LLVM_CLANG_SERIALIZATION_ASTREADER_H
35 #include "llvm/ADT/APFloat.h"
36 #include "llvm/ADT/APInt.h"
37 #include "llvm/ADT/APSInt.h"
38 #include "llvm/ADT/MapVector.h"
39 #include "llvm/ADT/SmallPtrSet.h"
40 #include "llvm/ADT/SmallSet.h"
41 #include "llvm/ADT/SmallVector.h"
42 #include "llvm/ADT/StringMap.h"
43 #include "llvm/ADT/StringRef.h"
44 #include "llvm/ADT/TinyPtrVector.h"
45 #include "llvm/Bitcode/BitstreamReader.h"
46 #include "llvm/Support/DataTypes.h"
47 #include "llvm/Support/Timer.h"
64 class ASTIdentifierIterator;
69 class DefMacroDirective;
70 class DiagnosticOptions;
71 class NestedNameSpecifier;
72 class CXXBaseSpecifier;
73 class CXXConstructorDecl;
74 class CXXCtorInitializer;
75 class GlobalModuleIndex;
77 class MacroDefinition;
81 class OpaqueValueExpr;
83 class PreprocessorOptions;
86 class ASTDeserializationListener;
92 struct HeaderFileInfo;
95 class LazyASTUnresolvedSet;
123 bool AllowCompatibleDifferences) {
132 bool AllowCompatibleDifferences) {
160 StringRef SpecificModuleCachePath,
175 std::string &SuggestedPredefines) {
200 bool isOverridden,
bool isExplicitModule) {
218 std::unique_ptr<ASTReaderListener> First;
219 std::unique_ptr<ASTReaderListener> Second;
224 std::unique_ptr<ASTReaderListener> Second)
225 : First(std::move(First)), Second(std::move(Second)) {}
227 std::unique_ptr<ASTReaderListener>
takeFirst() {
return std::move(First); }
228 std::unique_ptr<ASTReaderListener>
takeSecond() {
return std::move(Second); }
234 bool AllowCompatibleDifferences)
override;
236 bool AllowCompatibleDifferences)
override;
238 bool Complain)
override;
240 bool Complain)
override;
243 StringRef SpecificModuleCachePath,
244 bool Complain)
override;
247 std::string &SuggestedPredefines)
override;
255 bool isOverridden,
bool isExplicitModule)
override;
268 : PP(PP), Reader(Reader) {}
271 bool AllowCompatibleDifferences)
override;
273 bool AllowCompatibleDifferences)
override;
275 bool Complain)
override;
277 std::string &SuggestedPredefines)
override;
279 StringRef SpecificModuleCachePath,
280 bool Complain)
override;
284 void Error(
const char *Msg);
287 namespace serialization {
289 class ReadMethodPoolVisitor;
366 std::unique_ptr<ASTReaderListener> Listener;
370 bool OwnsDeserializationListener;
394 llvm::StringMap<IntrusiveRefCntPtr<ModuleFileExtension>> ModuleFileExtensions;
397 std::unique_ptr<llvm::Timer> ReadTimer;
404 std::unique_ptr<GlobalModuleIndex> GlobalIndex;
423 std::vector<QualType> TypesLoaded;
437 std::vector<Decl *> DeclsLoaded;
446 typedef std::pair<ModuleFile *, uint64_t> FileOffset;
448 typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy>
449 DeclUpdateOffsetsMap;
453 DeclUpdateOffsetsMap DeclUpdateOffsets;
458 PendingUpdateRecords;
464 llvm::DenseMap<void *, PendingFakeDefinitionKind> PendingFakeDefinitionData;
470 llvm::SmallMapVector<Decl *, FunctionDecl *, 4> PendingExceptionSpecUpdates;
472 struct ReplacedDeclInfo {
477 ReplacedDeclInfo() : Mod(nullptr),
Offset(0), RawLoc(0) {}
479 : Mod(Mod), Offset(Offset), RawLoc(RawLoc) {}
482 typedef llvm::DenseMap<serialization::DeclID, ReplacedDeclInfo>
485 DeclReplacementMap ReplacedDecls;
489 llvm::DenseMap<std::pair<DeclContext*, IdentifierInfo*>, NamedDecl*>
490 ImportedTypedefNamesForLinkage;
494 llvm::DenseMap<DeclContext*, llvm::SmallVector<NamedDecl*, 2>>
495 AnonymousDeclarationsForMerging;
497 struct FileDeclsInfo {
499 ArrayRef<serialization::LocalDeclID> Decls;
501 FileDeclsInfo() : Mod(nullptr) {}
502 FileDeclsInfo(
ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls)
503 : Mod(Mod), Decls(Decls) {}
507 llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs;
511 typedef ArrayRef<llvm::support::unaligned_uint32_t> LexicalContents;
514 llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
518 std::vector<std::pair<ModuleFile*, LexicalContents>> TULexicalDecls;
521 llvm::DenseMap<
const DeclContext *,
522 serialization::reader::DeclContextLookupTable> Lookups;
528 struct PendingVisibleUpdate {
530 const unsigned char *Data;
532 typedef SmallVector<PendingVisibleUpdate, 1> DeclContextVisibleUpdates;
536 llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates>
537 PendingVisibleUpdates;
541 llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
543 typedef llvm::MapVector<
Decl *, uint64_t,
544 llvm::SmallDenseMap<Decl *, unsigned, 4>,
545 SmallVector<std::pair<Decl *, uint64_t>, 4> >
549 PendingBodiesMap PendingBodies;
553 llvm::SetVector<NamedDecl*> PendingMergedDefinitionsToDeduplicate;
556 bool ReadLexicalDeclContextStorage(
ModuleFile &M,
557 llvm::BitstreamCursor &
Cursor,
558 uint64_t
Offset, DeclContext *DC);
560 bool ReadVisibleDeclContextStorage(
ModuleFile &M,
561 llvm::BitstreamCursor &
Cursor,
570 std::vector<IdentifierInfo *> IdentifiersLoaded;
572 typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>
573 GlobalIdentifierMapType;
578 GlobalIdentifierMapType GlobalIdentifierMap;
586 std::vector<MacroInfo *> MacrosLoaded;
588 typedef std::pair<IdentifierInfo *, serialization::SubmoduleID>
596 typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>
602 GlobalMacroMapType GlobalMacroMap;
608 SmallVector<Module *, 2> SubmodulesLoaded;
610 typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>
611 GlobalSubmoduleMapType;
616 GlobalSubmoduleMapType GlobalSubmoduleMap;
619 typedef SmallVector<Decl*, 2> HiddenNames;
620 typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType;
624 HiddenNamesMapType HiddenNamesMap;
628 struct UnresolvedModuleRef {
636 enum { Import, Export, Conflict }
Kind;
642 unsigned IsWildcard : 1;
650 SmallVector<UnresolvedModuleRef, 2> UnresolvedModuleRefs;
657 SmallVector<Selector, 16> SelectorsLoaded;
659 typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>
660 GlobalSelectorMapType;
665 GlobalSelectorMapType GlobalSelectorMap;
669 llvm::DenseMap<Selector, unsigned> SelectorGeneration;
671 struct PendingMacroInfo {
673 uint64_t MacroDirectivesOffset;
675 PendingMacroInfo(
ModuleFile *M, uint64_t MacroDirectivesOffset)
676 : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
679 typedef llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2> >
684 PendingMacroIDsMap PendingMacroIDs;
686 typedef ContinuousRangeMap<unsigned, ModuleFile *, 4>
687 GlobalPreprocessedEntityMapType;
692 GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap;
704 SmallVector<uint64_t, 16> EagerlyDeserializedDecls;
711 SmallVector<uint64_t, 16> TentativeDefinitions;
718 SmallVector<uint64_t, 64> VTableUses;
726 SmallVector<uint64_t, 64> PendingInstantiations;
736 SmallVector<uint64_t, 16> UnusedFileScopedDecls;
740 SmallVector<uint64_t, 4> DelegatingCtorDecls;
744 SmallVector<uint64_t, 64> ReferencedSelectorsData;
748 SmallVector<uint64_t, 64> WeakUndeclaredIdentifiers;
753 SmallVector<uint64_t, 4> ExtVectorDecls;
764 SmallVector<uint64_t, 16> UnusedLocalTypedefNameCandidates;
769 SmallVector<uint64_t, 4> SemaDeclRefs;
774 SmallVector<uint64_t, 16> SpecialTypes;
780 SmallVector<uint64_t, 2> CUDASpecialDeclRefs;
783 SmallVector<uint64_t, 1> FPPragmaOptions;
786 SourceLocation OptimizeOffPragmaLocation;
789 SmallVector<uint64_t, 1> OpenCLExtensions;
792 SmallVector<uint64_t, 4> KnownNamespaces;
796 SmallVector<uint64_t, 8> UndefinedButUsed;
799 SmallVector<uint64_t, 8> DelayedDeleteExprs;
802 SmallVector<uint64_t, 1> LateParsedTemplates;
804 struct ImportedSubmodule {
806 SourceLocation ImportLoc;
809 : ID(ID), ImportLoc(ImportLoc) {}
814 SmallVector<ImportedSubmodule, 2> ImportedModules;
818 std::string CurrentDir;
822 std::string isysroot;
826 bool DisableValidation;
829 bool AllowASTWithCompilerErrors;
833 bool AllowConfigurationMismatch;
836 bool ValidateSystemInputs;
842 bool TriedLoadingGlobalIndex;
844 typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy;
849 SwitchCaseMapTy SwitchCaseStmts;
851 SwitchCaseMapTy *CurrSwitchCaseStmts;
855 unsigned NumSLocEntriesRead;
858 unsigned TotalNumSLocEntries;
862 unsigned NumStatementsRead;
866 unsigned TotalNumStatements;
869 unsigned NumMacrosRead;
872 unsigned TotalNumMacros;
875 unsigned NumIdentifierLookups;
878 unsigned NumIdentifierLookupHits;
881 unsigned NumSelectorsRead;
884 unsigned NumMethodPoolEntriesRead;
888 unsigned NumMethodPoolLookups;
892 unsigned NumMethodPoolHits;
896 unsigned NumMethodPoolTableLookups;
900 unsigned NumMethodPoolTableHits;
903 unsigned TotalNumMethodPoolEntries;
906 unsigned NumLexicalDeclContextsRead, TotalLexicalDeclContexts;
909 unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts;
912 uint64_t TotalModulesSizeInBits;
915 unsigned NumCurrentElementsDeserializing;
921 bool PassingDeclsToConsumer;
928 llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4> >
929 PendingIdentifierInfos;
933 llvm::SmallMapVector<IdentifierInfo *, SmallVector<NamedDecl*, 2>, 16>
934 PendingFakeLookupResults;
938 llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration;
946 std::deque<Decl *> InterestingDecls;
951 SmallVector<std::pair<Decl *, uint64_t>, 16> PendingDeclChains;
955 SmallVector<Decl *, 16> PendingIncompleteDeclChains;
959 struct PendingDeclContextInfo {
970 std::deque<PendingDeclContextInfo> PendingDeclContextInfos;
981 llvm::SmallDenseMap<CXXRecordDecl *, llvm::TinyPtrVector<CXXRecordDecl *>, 2>
982 PendingOdrMergeFailures;
985 llvm::SmallPtrSet<DeclContext*, 2> DiagnosedOdrMergeFailures;
989 llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized;
994 SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded;
996 typedef llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2> >
1004 KeyDeclsMap KeyDecls;
1009 llvm::DenseMap<DeclContext *, DeclContext *> MergedDeclContexts;
1013 llvm::DenseMap<EnumDecl *, EnumDecl *> EnumDefinitions;
1016 SmallVector<Stmt *, 16> StmtStack;
1020 Read_None, Read_Decl, Read_Type, Read_Stmt
1024 ReadingKind ReadingKind;
1027 class ReadingKindTracker {
1029 enum ReadingKind PrevKind;
1031 ReadingKindTracker(
const ReadingKindTracker &) =
delete;
1032 void operator=(
const ReadingKindTracker &) =
delete;
1035 ReadingKindTracker(
enum ReadingKind newKind, ASTReader &reader)
1036 : Reader(reader), PrevKind(Reader.ReadingKind) {
1037 Reader.ReadingKind = newKind;
1040 ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
1051 std::string SuggestedPredefines;
1056 struct InputFileInfo {
1065 InputFileInfo readInputFileInfo(
ModuleFile &F,
unsigned ID);
1069 serialization::InputFile getInputFile(
ModuleFile &F,
unsigned ID,
1070 bool Complain =
true);
1084 auto I = KeyDecls.find(D);
1085 if (
I == KeyDecls.end() ||
I->second.empty())
1094 template <
typename Fn>
1100 auto It = KeyDecls.find(const_cast<Decl*>(D));
1101 if (It != KeyDecls.end())
1102 for (
auto ID : It->second)
1111 struct ImportedModule {
1119 : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) { }
1123 SourceLocation ImportLoc,
ModuleFile *ImportedBy,
1124 SmallVectorImpl<ImportedModule> &Loaded,
1125 off_t ExpectedSize, time_t ExpectedModTime,
1127 unsigned ClientLoadCapabilities);
1129 SmallVectorImpl<ImportedModule> &Loaded,
1131 unsigned ClientLoadCapabilities);
1133 llvm::BitstreamCursor &Stream,
unsigned ClientLoadCapabilities,
1134 bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
1135 std::string &SuggestedPredefines);
1140 llvm::BitstreamCursor &SLocCursorForID(
int ID);
1141 SourceLocation getImportLocation(
ModuleFile *F);
1144 unsigned ClientLoadCapabilities);
1146 unsigned ClientLoadCapabilities);
1147 static bool ParseLanguageOptions(
const RecordData &Record,
bool Complain,
1148 ASTReaderListener &Listener,
1149 bool AllowCompatibleDifferences);
1150 static bool ParseTargetOptions(
const RecordData &Record,
bool Complain,
1151 ASTReaderListener &Listener,
1152 bool AllowCompatibleDifferences);
1153 static bool ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
1154 ASTReaderListener &Listener);
1155 static bool ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
1156 ASTReaderListener &Listener);
1157 static bool ParseHeaderSearchOptions(
const RecordData &Record,
bool Complain,
1158 ASTReaderListener &Listener);
1159 static bool ParsePreprocessorOptions(
const RecordData &Record,
bool Complain,
1160 ASTReaderListener &Listener,
1161 std::string &SuggestedPredefines);
1163 struct RecordLocation {
1170 QualType readTypeRecord(
unsigned Index);
1172 SmallVectorImpl<QualType> &ExceptionStorage,
1173 FunctionProtoType::ExceptionSpecInfo &ESI,
1175 RecordLocation TypeCursorForIndex(
unsigned Index);
1176 void LoadedDecl(
unsigned Index, Decl *D);
1178 void markIncompleteDeclChain(Decl *Canon);
1183 Decl *getMostRecentExistingDecl(Decl *D);
1186 unsigned &RawLocation);
1188 void loadPendingDeclChain(Decl *D, uint64_t LocalOffset);
1190 unsigned PreviousGeneration = 0);
1192 RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
1193 uint64_t getGlobalBitOffset(
ModuleFile &M, uint32_t LocalOffset);
1198 findPreprocessedEntity(SourceLocation Loc,
bool EndsAfter)
const;
1207 findNextPreprocessedEntity(
1212 std::pair<ModuleFile *, unsigned>
1213 getModulePreprocessedEntity(
unsigned GlobalIndex);
1217 llvm::iterator_range<PreprocessingRecord::iterator>
1218 getModulePreprocessedEntities(
ModuleFile &Mod)
const;
1220 class ModuleDeclIterator
1221 :
public llvm::iterator_adaptor_base<
1222 ModuleDeclIterator, const serialization::LocalDeclID *,
1223 std::random_access_iterator_tag, const Decl *, ptrdiff_t,
1224 const Decl *, const Decl *> {
1229 ModuleDeclIterator()
1230 : iterator_adaptor_base(nullptr), Reader(nullptr), Mod(nullptr) {}
1232 ModuleDeclIterator(ASTReader *Reader,
ModuleFile *Mod,
1234 : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
1237 return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *
I));
1239 value_type operator->()
const {
return **
this; }
1241 bool operator==(
const ModuleDeclIterator &RHS)
const {
1242 assert(Reader == RHS.Reader && Mod == RHS.Mod);
1247 llvm::iterator_range<ModuleDeclIterator>
1250 void PassInterestingDeclsToConsumer();
1251 void PassInterestingDeclToConsumer(Decl *D);
1253 void finishPendingActions();
1254 void diagnoseOdrViolations();
1256 void pushExternalDeclIntoScope(NamedDecl *D, DeclarationName
Name);
1258 void addPendingDeclContextInfo(Decl *D,
1262 PendingDeclContextInfo Info = { D, SemaDC, LexicalDC };
1263 PendingDeclContextInfos.push_back(Info);
1270 void Error(StringRef Msg);
1271 void Error(
unsigned DiagID, StringRef Arg1 = StringRef(),
1272 StringRef Arg2 = StringRef());
1274 ASTReader(
const ASTReader &) =
delete;
1275 void operator=(
const ASTReader &) =
delete;
1316 ASTReader(Preprocessor &PP,
ASTContext &Context,
1317 const PCHContainerReader &PCHContainerRdr,
1318 ArrayRef<IntrusiveRefCntPtr<ModuleFileExtension>> Extensions,
1319 StringRef isysroot =
"",
bool DisableValidation =
false,
1320 bool AllowASTWithCompilerErrors =
false,
1321 bool AllowConfigurationMismatch =
false,
1322 bool ValidateSystemInputs =
false,
bool UseGlobalIndex =
true,
1323 std::unique_ptr<llvm::Timer> ReadTimer = {});
1369 unsigned ClientLoadCapabilities);
1389 return std::move(Listener);
1394 this->Listener = std::move(Listener);
1402 L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
1403 std::move(Listener));
1404 Listener = std::move(L);
1414 : Reader(Reader), Chained(
false) {
1418 L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
1426 Reader.
setListener(static_cast<ChainedASTReaderListener *>(New.get())
1433 bool TakeOwnership =
false);
1461 std::unique_ptr<llvm::MemoryBuffer>
Buffer) {
1497 bool FindModuleFileExtensions,
1507 std::string ExistingModuleCachePath);
1522 std::pair<unsigned, unsigned>
1537 return TotalNumSLocEntries;
1542 return static_cast<unsigned>(IdentifiersLoaded.size());
1547 return static_cast<unsigned>(MacrosLoaded.size());
1552 return static_cast<unsigned>(TypesLoaded.size());
1557 return static_cast<unsigned>(DeclsLoaded.size());
1562 return static_cast<unsigned>(SubmodulesLoaded.size());
1567 return static_cast<unsigned>(SelectorsLoaded.size());
1575 E = ModuleMgr.
end();
I !=
E; ++
I) {
1576 Result += (*I)->NumPreprocessedEntities;
1614 if (Idx >= Record.size())
1656 template<
typename T>
1688 template<
typename T>
1738 llvm::function_ref<
bool(
Decl::Kind)> IsKindWeWant,
1803 llvm::DenseMap<NamedDecl *, SourceLocation> &Undefined)
override;
1824 SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels)
override;
1827 SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI)
override;
1836 llvm::MapVector<const FunctionDecl *, LateParsedTemplate *> &LPTMap)
1928 unsigned LocalID)
const;
1957 bool Canonicalize =
false);
1967 unsigned &Idx,
bool Canonicalize =
false);
1994 "Cannot find offset to remap.");
1995 int Remap = ModuleFile.
SLocRemap.
find(Loc.getOffset())->second;
2018 const llvm::fltSemantics &Sem,
unsigned &Idx);
2044 assert(ReadingKind == Read_Stmt &&
2045 "Should be called only during statement reading!");
2048 assert(!StmtStack.empty() &&
"Read too many sub-statements!");
2049 return StmtStack.pop_back_val();
2073 uint64_t MacroDirectivesOffset);
2124 : Cursor(Cursor),
Offset(Cursor.GetCurrentBitNo()) { }
2131 llvm::BitstreamCursor &
Cursor;
2135 inline void PCHValidator::Error(
const char *Msg) {
llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx)
Read an integral value.
Decl * GetExistingDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration.
SmallVector< std::pair< llvm::BitstreamCursor, serialization::ModuleFile * >, 8 > CommentsCursors
Cursors for comments blocks.
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override
Finds all the visible declarations with a given name.
Decl * GetLocalDecl(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons...
The client can handle an AST file that cannot load because it was built with a different version of C...
IdentifierIterator * getIdentifiers() override
Retrieve an iterator into the set of all identifiers in all loaded AST files.
unsigned getTotalNumTypes() const
Returns the number of types found in the chain.
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Smart pointer class that efficiently represents Objective-C method names.
ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type, SourceLocation ImportLoc, unsigned ClientLoadCapabilities)
Load the AST file designated by the given file name.
A (possibly-)qualified type.
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines)
Receives the preprocessor options.
Represents a version number in the form major[.minor[.subminor[.build]]].
void SetIdentifierInfo(unsigned ID, IdentifierInfo *II)
virtual bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule)
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Implements support for file system lookup, file system caching, and directory search management...
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
virtual void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind)
This is called for each AST file loaded.
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
bool operator==(CanQual< T > x, CanQual< U > y)
Defines the clang::FileManager interface and associated types.
CXXBaseSpecifier * GetExternalCXXBaseSpecifiers(uint64_t Offset) override
Resolve the offset of a set of C++ base specifiers in the decl stream into an array of specifiers...
Optional< bool > isPreprocessedEntityInFileID(unsigned Index, FileID FID) override
Optionally returns true or false if the preallocated preprocessed entity with index Index came from f...
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, unsigned Raw) const
Read a source location from raw form.
void ReadComments() override
Loads comments ranges.
Defines the SourceManager interface.
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
GlobalModuleIndex * getGlobalIndex()
Return global module index.
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
Decl - This represents one declaration (or definition), e.g.
ModuleManager::ModuleConstIterator ModuleConstIterator
SmallVector< uint64_t, 64 > RecordData
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
The base class of the type hierarchy.
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
IdentifierInfo * getLocalIdentifier(ModuleFile &M, unsigned LocalID)
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
std::unique_ptr< llvm::MemoryBuffer > Buffer
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
A container of type source information.
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
void makeModuleVisible(Module *Mod, Module::NameVisibilityKind NameVisibility, SourceLocation ImportLoc)
Make the entities in the given module and any of its (non-explicit) submodules visible to name lookup...
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
void addPendingMacro(IdentifierInfo *II, ModuleFile *M, uint64_t MacroDirectivesOffset)
Add a macro to deserialize its macro directive history.
CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a C++ base specifier.
The client can handle an AST file that cannot load because it is out-of-date relative to its input fi...
uint32_t IdentifierID
An ID number that refers to an identifier in an AST file.
Manages the set of modules loaded by an AST reader.
void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation > > &Sels) override
Read the set of referenced selectors known to the external Sema source.
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
Options for controlling the target.
serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const
Map a local type ID within a given AST file into a global type ID.
void CompleteRedeclChain(const Decl *D) override
If any redeclarations of D have been imported since it was last checked, this digs out those redeclar...
void dump()
Dump information about the AST reader to standard error.
ModuleManager::ModuleReverseIterator ModuleReverseIterator
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Stores a list of template parameters for a TemplateDecl and its derived classes.
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
T * ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx)
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
void ReadTentativeDefinitions(SmallVectorImpl< VarDecl * > &TentativeDefs) override
Read the set of tentative definitions known to the external Sema source.
An UnresolvedSet-like class that might not have been loaded from the external AST source yet...
The client can handle an AST file that cannot load because it is missing.
One of these records is kept for each identifier that is lexed.
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
SmallVectorImpl< ModuleFile * >::const_iterator ModuleConstIterator
bool hasGlobalIndex() const
Determine whether this AST reader has a global index.
ModuleIterator begin()
Forward iterator to traverse all loaded modules.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
T * GetLocalDeclAs(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
Utility class for loading a ASTContext from an AST file.
serialization::SelectorID getGlobalSelectorID(ModuleFile &F, unsigned LocalID) const
Retrieve the global selector ID that corresponds to this the local selector ID in a given module...
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions, ASTReaderListener &Listener)
Read the control block for the named AST file.
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
serialization::ModuleManager ModuleManager
void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, LateParsedTemplate * > &LPTMap) override
Read the set of late parsed template functions for this source.
unsigned ASTFileSignature
Helper class that saves the current stream position and then restores it when destroyed.
void ReadUndefinedButUsed(llvm::DenseMap< NamedDecl *, SourceLocation > &Undefined) override
Load the set of used but not defined functions or variables with internal linkage, or used but not defined internal functions.
TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template name.
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
Token - This structure provides full information about a lexed token.
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Sema * getSema()
Retrieve the semantic analysis object used to analyze the translation unit in which the precompiled h...
Stmt * ReadSubStmt()
Reads a sub-statement operand during statement reading.
void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl * > &Decls) override
Read the set of ext_vector type declarations known to the external Sema source.
The client can handle an AST file that cannot load because it's compiled configuration doesn't match ...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Decl * getKeyDeclaration(Decl *D)
Returns the first key declaration for the given declaration.
void ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo > > &WI) override
Read the set of weak, undeclared identifiers known to the external Sema source.
Describes a module or submodule.
void completeVisibleDeclsMap(const DeclContext *DC) override
Load all external visible decls in the given DeclContext.
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
llvm::Optional< ASTSourceDescriptor > getSourceDescriptor(unsigned ID) override
Return a descriptor for the corresponding module.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
PreprocessedEntity * ReadPreprocessedEntity(unsigned Index) override
Read a preallocated preprocessed entity from the external source.
serialization::ModuleKind ModuleKind
TypeSourceInfo * GetTypeSourceInfo(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declarator info from the given record.
ModuleManager & getModuleManager()
Retrieve the module manager.
void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, const RecordData &Record, unsigned &Idx)
CXXCtorInitializer ** ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a CXXCtorInitializer array.
llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx)
Read a signed integral value.
DiagnosticsEngine & getDiags() const
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, const RecordDataImpl &Record, unsigned &Idx)
Read a source location.
uint64_t readCXXBaseSpecifiers(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Read a CXXBaseSpecifiers ID form the given record and return its global bit offset.
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
ModuleIterator end()
Forward iterator end-point to traverse all loaded modules.
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
std::string getOwningModuleNameForDiagnostic(const Decl *D)
Get the best name we know for the module that owns the given declaration, or an empty string if the d...
Concrete class used by the front-end to report problems and issues.
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID)
Retrieve the global submodule ID given a module and its local ID number.
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
TemplateArgument ReadTemplateArgument(ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument.
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
const Decl * getKeyDeclaration(const Decl *D)
std::string OriginalSourceFileName
The original source file name that was used to build the primary AST file, which may have been modifi...
void resetForReload()
Reset reader for a reload try.
ModuleManager::ModuleIterator ModuleIterator
void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation > > &Pending) override
Read the set of pending instantiations known to the external Sema source.
ContinuousRangeMap< uint32_t, int, 2 > SLocRemap
Remapping table for source locations in this module.
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
The AST file itself appears corrupted.
unsigned getTotalNumDecls() const
Returns the number of declarations found in the chain.
detail::InMemoryDirectory::const_iterator I
void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &Exprs) override
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl * > &Decls) override
Read the set of delegating constructors known to the external Sema source.
static std::string ReadString(const RecordData &Record, unsigned &Idx)
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
IdentifierInfo * GetIdentifierInfo(ModuleFile &M, const RecordData &Record, unsigned &Idx)
void ForgetSema() override
Inform the semantic consumer that Sema is no longer available.
Sema - This implements semantic analysis and AST building for C.
A little helper class used to produce diagnostics.
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
ModuleKind
Specifies the kind of module that has been loaded.
Provides lookups to, and iteration over, IdentiferInfo objects.
void SetGloballyVisibleDecls(IdentifierInfo *II, const SmallVectorImpl< uint32_t > &DeclIDs, SmallVectorImpl< Decl * > *Decls=nullptr)
Set the globally-visible declarations associated with the given identifier.
void ReadModuleMapFile(StringRef ModuleMapPath) override
Decl * ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts, const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts, std::string ExistingModuleCachePath)
Determine whether the given AST file is acceptable to load into a translation unit with the given lan...
ID
Defines the set of possible language-specific address spaces.
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo)
SmallVectorImpl< ModuleFile * >::reverse_iterator ModuleReverseIterator
serialization::PreprocessedEntityID getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const
Determine the global preprocessed entity ID that corresponds to the given local ID within the given m...
ASTReaderListener implementation to validate the information of the PCH file against an initialized P...
Abstract interface for external sources of preprocessor information.
HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override
Read the header file information for the given file entry.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID)
Retrieve the global macro ID corresponding to the given local ID within the given module file...
DiagnosticBuilder Diag(unsigned DiagID)
Report a diagnostic.
QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a type from the current position in the given record, which was read from the given AST file...
RAII object to temporarily add an AST callback listener.
Stmt * ReadStmt(ModuleFile &F)
Reads a statement.
void ReadUsedVTables(SmallVectorImpl< ExternalVTableUse > &VTables) override
Read the set of used vtables known to the external Sema source.
Implements an efficient mapping from strings to IdentifierInfo nodes.
virtual void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata)
Indicates that a particular module file extension has been read.
Defines version macros and version-related utility functions for Clang.
ArgKind
The kind of template argument we're storing.
serialization::DeclID getGlobalDeclID(ModuleFile &F, serialization::LocalDeclID LocalID) const
Map from a local declaration ID within a given module to a global declaration ID. ...
std::pair< SourceLocation, StringRef > getModuleImportLoc(int ID) override
Retrieve the module import location and module name for the given source manager entry ID...
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a source range.
Represents a C++ template name within the type system.
QualType getLocalType(ModuleFile &F, unsigned LocalID)
Resolve a local type ID within a given AST file into a type.
Information about a module that has been loaded by the ASTReader.
virtual ~ASTReaderListener()
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
An iterator that walks over all of the known identifiers in the lookup table.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
SavedStreamPosition(llvm::BitstreamCursor &Cursor)
void StartedDeserializing() override
Notify ASTReader that we started deserialization of a decl or type so until FinishedDeserializing is ...
The result type of a method or function.
SmallVector< uint64_t, 16 > PreloadedDeclIDs
void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, const RecordData &Record, unsigned &Idx)
The client can't handle any AST loading failures.
The AST file was missing.
An abstract interface that should be implemented by external AST sources that also provide informatio...
NestedNameSpecifier * ReadNestedNameSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
void addInMemoryBuffer(StringRef FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add an in-memory buffer the list of known buffers.
Representation::const_iterator const_iterator
void makeNamesVisible(const HiddenNames &Names, Module *Owner)
Make the names within this set of hidden names visible.
QualifierInfo - A struct with extended info about a syntactic name qualifier, to be used for the case...
The control block was read successfully.
bool ReadFullVersionInformation(StringRef FullVersion) override
Receives the full Clang version information.
void addListener(std::unique_ptr< ASTReaderListener > L)
Add an AST callback listener.
bool isGlobalIndexUnavailable() const
Determine whether we tried to load the global index, but failed, e.g., because it is out-of-date or d...
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
MacroInfo * ReadMacroRecord(ModuleFile &F, uint64_t Offset)
Reads the macro record located at the given offset.
Encodes a location in the source.
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
Represents a C++ temporary.
void InitializeContext()
Initializes the ASTContext.
An identifier-lookup iterator that enumerates all of the identifiers stored within a set of AST files...
std::unique_ptr< ASTReaderListener > takeListener()
Take the AST callbacks listener.
void ReadKnownNamespaces(SmallVectorImpl< NamespaceDecl * > &Namespaces) override
Load the set of namespaces that are known to the external source, which will be used during typo corr...
Cached information about one file (either on disk or in the virtual file system). ...
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
MacroInfo * getMacro(serialization::MacroID ID)
Retrieve the macro with the given ID.
TemplateParameterList * ReadTemplateParameterList(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template parameter list.
An abstract class that should be subclassed by any external source of preprocessing record entries...
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
void ReadMethodPool(Selector Sel) override
Load the contents of the global method pool for a given selector.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
void addInMemoryBuffer(StringRef &FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add in-memory (virtual file) buffer.
PCHValidator(Preprocessor &PP, ASTReader &Reader)
uint32_t MacroID
An ID number that refers to a macro in an AST file.
void setListener(std::unique_ptr< ASTReaderListener > Listener)
Set the AST callbacks listener.
External source of source location entries.
virtual void visitImport(StringRef Filename)
If needsImportVisitation returns true, this is called for each AST file imported by this AST file...
A global index for a set of module files, providing information about the identifiers within those mo...
DeclarationName ReadDeclarationName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a declaration name.
The AST file was writtten with a different language/target configuration.
void markIdentifierUpToDate(IdentifierInfo *II)
Note that this identifier is up-to-date.
llvm::APFloat ReadAPFloat(const RecordData &Record, const llvm::fltSemantics &Sem, unsigned &Idx)
Read a floating-point value.
unsigned getTotalNumSLocs() const
Returns the number of source locations found in the chain.
ModuleFile * getLocalModuleFile(ModuleFile &M, unsigned ID)
Retrieve the module file with a given local ID within the specified ModuleFile.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
ChainedASTReaderListener(std::unique_ptr< ASTReaderListener > First, std::unique_ptr< ASTReaderListener > Second)
Takes ownership of First and Second.
SmallVectorImpl< uint64_t > RecordDataImpl
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a template argument.
Selector getLocalSelector(ModuleFile &M, unsigned LocalID)
Retrieve a selector from the given module with its local ID number.
const ASTTemplateArgumentListInfo * ReadASTTemplateArgumentListInfo(ModuleFile &F, const RecordData &Record, unsigned &Index)
bool ReadSLocEntry(int ID) override
Read the source location entry with index ID.
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
void ResolveImportedPath(ModuleFile &M, std::string &Filename)
If we are loading a relocatable PCH or module file, and the filename is not an absolute path...
void setDeserializationListener(ASTDeserializationListener *Listener, bool TakeOwnership=false)
Set the AST deserialization listener.
unsigned getTotalNumIdentifiers() const
Returns the number of identifiers found in the chain.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
void updateOutOfDateIdentifier(IdentifierInfo &II) override
Update an out-of-date identifier.
void ReadDefinedMacros() override
Read the set of macros defined by this external macro source.
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain) override
Receives the file system options.
Reads an AST files chain containing the contents of a translation unit.
Expr * ReadExpr(ModuleFile &F)
Reads an expression.
ListenerScope(ASTReader &Reader, std::unique_ptr< ASTReaderListener > L)
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
ModuleFile & getPrimaryModule()
Returns the primary module associated with the manager, that is, the first module loaded...
bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule) override
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
uint64_t ReadCXXCtorInitializersRef(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Read a CXXCtorInitializers ID from the given record and return its global bit offset.
LoadFailureCapabilities
Flags that indicate what kind of AST loading failures the client of the AST reader can directly handl...
DeclarationName - The name of a declaration.
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
bool needsInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
void FindExternalLexicalDecls(const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl * > &Decls) override
Read all of the declarations lexically stored in a declaration context.
SourceManager & getSourceManager() const
detail::InMemoryDirectory::const_iterator E
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
unsigned getTotalNumMacros() const
Returns the number of macros found in the chain.
A map from continuous integer ranges to some value, with a very specialized interface.
Class that performs lookup for an identifier stored in an AST file.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void ReadDeclarationNameLoc(ModuleFile &F, DeclarationNameLoc &DNLoc, DeclarationName Name, const RecordData &Record, unsigned &Idx)
void ClearSwitchCaseIDs()
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
Defines the Diagnostic-related interfaces.
Encapsulates the data about a macro definition (e.g.
Decl * GetExternalDecl(uint32_t ID) override
Resolve a declaration ID into a declaration, potentially building a new declaration.
void ReadUnresolvedSet(ModuleFile &F, LazyASTUnresolvedSet &Set, const RecordData &Record, unsigned &Idx)
Read a UnresolvedSet structure.
Abstract interface for callback invocations by the ASTReader.
Location wrapper for a TemplateArgument.
NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
std::pair< unsigned, unsigned > findPreprocessedEntitiesInRange(SourceRange Range) override
Returns a pair of [Begin, End) indices of preallocated preprocessed entities that Range encompasses...
Defines the clang::FileSystemOptions interface.
Represents a C++ base or member initializer.
virtual bool needsImportVisitation() const
Returns true if this ASTReaderListener wants to receive the imports of the AST file via visitImport...
void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata) override
Indicates that a particular module file extension has been read.
void ReadTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument array.
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
void forEachImportedKeyDecl(const Decl *D, Fn Visit)
Run a callback on each imported key declaration of D.
Selector DecodeSelector(serialization::SelectorID Idx)
Represents a base class of a C++ class.
uint32_t GetNumExternalSelectors() override
Returns the number of selectors known to the external AST source.
void PrintStats() override
Print some statistics about AST usage.
Keeps track of options that affect how file operations are performed.
static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID)
ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the specified cursor.
QualType GetType(serialization::TypeID ID)
Resolve a type ID into a type, potentially building a new type.
IdentifierInfo * DecodeIdentifierInfo(serialization::IdentifierID ID)
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain)
Receives the header search options.
serialization::ModuleFile ModuleFile
unsigned getTotalNumPreprocessedEntities() const
Returns the number of preprocessed entities known to the AST reader.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length, SmallVectorImpl< Decl * > &Decls) override
Get the decls that are contained in a file in the Offset/Length range.
FileManager & getFileManager() const
TemplateArgumentLoc ReadTemplateArgumentLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLoc.
TemplateArgumentLocInfo GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind.
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declaration ID from the given position in a record in the given module.
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
Expr * ReadSubExpr()
Reads a sub-expression operand during statement reading.
Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx)
Reads a token out of a record.
IdentifierInfo * GetIdentifier(serialization::IdentifierID ID) override
Location information for a TemplateArgument.
virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the target options.
Writes an AST file containing the contents of a translation unit.
virtual void ReadModuleName(StringRef ModuleName)
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
The AST file is out-of-date relative to its input files, and needs to be regenerated.
NameVisibilityKind
Describes the visibility of the various names within a particular module.
Simple wrapper class for chaining listeners.
Kind
Lists the kind of concrete classes of Decl.
void ReadAttributes(ModuleFile &F, AttrVec &Attrs, const RecordData &Record, unsigned &Idx)
Reads attributes from the current stream position.
SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID)
Returns the source location for the decl ID.
The AST file was written by a different version of Clang.
std::unique_ptr< ASTReaderListener > takeSecond()
ModuleFile * getOwningModuleFile(const Decl *D)
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
void StartTranslationUnit(ASTConsumer *Consumer) override
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
const std::string & getSuggestedPredefines()
Returns the suggested contents of the predefines buffer, which contains a (typically-empty) subset of...
SmallVectorImpl< ModuleFile * >::iterator ModuleIterator
uint32_t TypeID
An ID number that refers to a type in an AST file.
A trivial tuple used to represent a source range.
void UpdateSema()
Update the state of Sema after loading some additional modules.
serialization::DeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M, serialization::DeclID GlobalID)
Map a global declaration ID into the declaration ID used to refer to this declaration within the give...
void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl * > &Decls) override
Read the set of unused file-scope declarations known to the external Sema source. ...
void FinishedDeserializing() override
Notify ASTReader that we finished the deserialization of a decl or type.
std::unique_ptr< ASTReaderListener > takeFirst()
void ReadModuleName(StringRef ModuleName) override
This class handles loading and caching of source files into memory.
void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind) override
This is called for each AST file loaded.
bool loadGlobalIndex()
Attempts to load the global index.
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls) override
Read the set of potentially unused typedefs known to the source.
virtual bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain)
Receives the diagnostic options.
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID)
Record that the given ID maps to the given switch-case statement.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, unsigned LocalID)