14 #ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H
15 #define LLVM_CLANG_SERIALIZATION_ASTREADER_H
34 #include "llvm/ADT/MapVector.h"
35 #include "llvm/ADT/SmallPtrSet.h"
36 #include "llvm/ADT/SmallSet.h"
37 #include "llvm/ADT/SmallVector.h"
38 #include "llvm/ADT/StringMap.h"
39 #include "llvm/ADT/StringRef.h"
40 #include "llvm/ADT/TinyPtrVector.h"
41 #include "llvm/Support/DataTypes.h"
42 #include "llvm/Support/Timer.h"
50 class BitstreamCursor;
60 class HeaderSearchOptions;
65 class ASTIdentifierIterator;
70 class DefMacroDirective;
71 class DiagnosticOptions;
72 class NestedNameSpecifier;
73 class CXXBaseSpecifier;
74 class CXXConstructorDecl;
75 class CXXCtorInitializer;
76 class GlobalModuleIndex;
78 class MacroDefinition;
82 class OpaqueValueExpr;
84 class PreprocessorOptions;
87 class ASTDeserializationListener;
92 class ASTRecordReader;
94 struct HeaderFileInfo;
97 class LazyASTUnresolvedSet;
125 bool AllowCompatibleDifferences) {
134 bool AllowCompatibleDifferences) {
162 StringRef SpecificModuleCachePath,
177 std::string &SuggestedPredefines) {
202 bool isOverridden,
bool isExplicitModule) {
220 std::unique_ptr<ASTReaderListener> First;
221 std::unique_ptr<ASTReaderListener> Second;
226 std::unique_ptr<ASTReaderListener> Second)
227 : First(std::move(First)), Second(std::move(Second)) {}
229 std::unique_ptr<ASTReaderListener>
takeFirst() {
return std::move(First); }
230 std::unique_ptr<ASTReaderListener>
takeSecond() {
return std::move(Second); }
236 bool AllowCompatibleDifferences)
override;
238 bool AllowCompatibleDifferences)
override;
240 bool Complain)
override;
242 bool Complain)
override;
245 StringRef SpecificModuleCachePath,
246 bool Complain)
override;
249 std::string &SuggestedPredefines)
override;
257 bool isOverridden,
bool isExplicitModule)
override;
270 : PP(PP), Reader(Reader) {}
273 bool AllowCompatibleDifferences)
override;
275 bool AllowCompatibleDifferences)
override;
277 bool Complain)
override;
279 std::string &SuggestedPredefines)
override;
281 StringRef SpecificModuleCachePath,
282 bool Complain)
override;
286 void Error(
const char *Msg);
301 std::string &SuggestedPredefines)
override;
304 namespace serialization {
306 class ReadMethodPoolVisitor;
384 std::unique_ptr<ASTReaderListener> Listener;
388 bool OwnsDeserializationListener =
false;
397 Sema *SemaObj =
nullptr;
420 llvm::StringMap<std::shared_ptr<ModuleFileExtension>> ModuleFileExtensions;
423 std::unique_ptr<llvm::Timer> ReadTimer;
430 std::unique_ptr<GlobalModuleIndex> GlobalIndex;
449 std::vector<QualType> TypesLoaded;
463 std::vector<Decl *> DeclsLoaded;
472 typedef std::pair<ModuleFile *, uint64_t> FileOffset;
474 typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy>
475 DeclUpdateOffsetsMap;
479 DeclUpdateOffsetsMap DeclUpdateOffsets;
481 struct PendingUpdateRecord {
488 : D(D),
ID(ID), JustLoaded(JustLoaded) {}
498 llvm::DenseMap<void *, PendingFakeDefinitionKind> PendingFakeDefinitionData;
504 llvm::SmallMapVector<Decl *, FunctionDecl *, 4> PendingExceptionSpecUpdates;
508 llvm::DenseMap<std::pair<DeclContext*, IdentifierInfo*>, NamedDecl*>
509 ImportedTypedefNamesForLinkage;
513 llvm::DenseMap<DeclContext*, llvm::SmallVector<NamedDecl*, 2>>
514 AnonymousDeclarationsForMerging;
516 struct FileDeclsInfo {
518 ArrayRef<serialization::LocalDeclID> Decls;
520 FileDeclsInfo() : Mod(nullptr) {}
521 FileDeclsInfo(
ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls)
522 : Mod(Mod), Decls(Decls) {}
526 llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs;
530 typedef ArrayRef<llvm::support::unaligned_uint32_t> LexicalContents;
533 llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
537 std::vector<std::pair<ModuleFile*, LexicalContents>> TULexicalDecls;
540 llvm::DenseMap<
const DeclContext *,
541 serialization::reader::DeclContextLookupTable> Lookups;
547 struct PendingVisibleUpdate {
549 const unsigned char *Data;
551 typedef SmallVector<PendingVisibleUpdate, 1> DeclContextVisibleUpdates;
555 llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates>
556 PendingVisibleUpdates;
560 llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
562 typedef llvm::MapVector<
Decl *, uint64_t,
563 llvm::SmallDenseMap<Decl *, unsigned, 4>,
564 SmallVector<std::pair<Decl *, uint64_t>, 4> >
568 PendingBodiesMap PendingBodies;
572 llvm::SetVector<NamedDecl*> PendingMergedDefinitionsToDeduplicate;
575 bool ReadLexicalDeclContextStorage(
ModuleFile &M,
576 llvm::BitstreamCursor &
Cursor,
577 uint64_t
Offset, DeclContext *DC);
579 bool ReadVisibleDeclContextStorage(
ModuleFile &M,
580 llvm::BitstreamCursor &
Cursor,
589 std::vector<IdentifierInfo *> IdentifiersLoaded;
591 typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>
592 GlobalIdentifierMapType;
597 GlobalIdentifierMapType GlobalIdentifierMap;
605 std::vector<MacroInfo *> MacrosLoaded;
607 typedef std::pair<IdentifierInfo *, serialization::SubmoduleID>
615 typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>
621 GlobalMacroMapType GlobalMacroMap;
627 SmallVector<Module *, 2> SubmodulesLoaded;
629 typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>
630 GlobalSubmoduleMapType;
635 GlobalSubmoduleMapType GlobalSubmoduleMap;
638 typedef SmallVector<Decl*, 2> HiddenNames;
639 typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType;
643 HiddenNamesMapType HiddenNamesMap;
647 struct UnresolvedModuleRef {
655 enum { Import, Export, Conflict }
Kind;
661 unsigned IsWildcard : 1;
669 SmallVector<UnresolvedModuleRef, 2> UnresolvedModuleRefs;
676 SmallVector<Selector, 16> SelectorsLoaded;
678 typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>
679 GlobalSelectorMapType;
684 GlobalSelectorMapType GlobalSelectorMap;
688 llvm::DenseMap<Selector, unsigned> SelectorGeneration;
692 llvm::DenseMap<Selector, bool> SelectorOutOfDate;
694 struct PendingMacroInfo {
696 uint64_t MacroDirectivesOffset;
698 PendingMacroInfo(
ModuleFile *M, uint64_t MacroDirectivesOffset)
699 : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
702 typedef llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2> >
707 PendingMacroIDsMap PendingMacroIDs;
709 typedef ContinuousRangeMap<unsigned, ModuleFile *, 4>
710 GlobalPreprocessedEntityMapType;
715 GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap;
727 SmallVector<uint64_t, 16> EagerlyDeserializedDecls;
734 SmallVector<uint64_t, 16> TentativeDefinitions;
741 SmallVector<uint64_t, 64> VTableUses;
749 SmallVector<uint64_t, 64> PendingInstantiations;
759 SmallVector<uint64_t, 16> UnusedFileScopedDecls;
763 SmallVector<uint64_t, 4> DelegatingCtorDecls;
767 SmallVector<uint64_t, 64> ReferencedSelectorsData;
771 SmallVector<uint64_t, 64> WeakUndeclaredIdentifiers;
776 SmallVector<uint64_t, 4> ExtVectorDecls;
787 SmallVector<uint64_t, 16> UnusedLocalTypedefNameCandidates;
791 unsigned ForceCUDAHostDeviceDepth = 0;
796 SmallVector<uint64_t, 4> SemaDeclRefs;
801 SmallVector<uint64_t, 16> SpecialTypes;
807 SmallVector<uint64_t, 2> CUDASpecialDeclRefs;
810 SmallVector<uint64_t, 1> FPPragmaOptions;
813 SourceLocation OptimizeOffPragmaLocation;
816 int PragmaMSStructState = -1;
819 int PragmaMSPointersToMembersState = -1;
820 SourceLocation PointersToMembersPragmaLocation;
823 Optional<unsigned> PragmaPackCurrentValue;
824 SourceLocation PragmaPackCurrentLocation;
825 struct PragmaPackStackEntry {
827 SourceLocation Location;
834 OpenCLOptions OpenCLExtensions;
837 llvm::DenseMap<const Type *, std::set<std::string>> OpenCLTypeExtMap;
840 llvm::DenseMap<const Decl *, std::set<std::string>> OpenCLDeclExtMap;
843 SmallVector<uint64_t, 4> KnownNamespaces;
847 SmallVector<uint64_t, 8> UndefinedButUsed;
850 SmallVector<uint64_t, 8> DelayedDeleteExprs;
853 SmallVector<uint64_t, 1> LateParsedTemplates;
861 : ID(ID), ImportLoc(ImportLoc) {}
871 std::string CurrentDir;
875 std::string isysroot;
879 bool DisableValidation;
882 bool AllowASTWithCompilerErrors;
886 bool AllowConfigurationMismatch;
889 bool ValidateSystemInputs;
895 bool TriedLoadingGlobalIndex =
false;
898 bool ProcessingUpdateRecords =
false;
900 typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy;
905 SwitchCaseMapTy SwitchCaseStmts;
907 SwitchCaseMapTy *CurrSwitchCaseStmts;
911 unsigned NumSLocEntriesRead = 0;
914 unsigned TotalNumSLocEntries = 0;
918 unsigned NumStatementsRead = 0;
922 unsigned TotalNumStatements = 0;
925 unsigned NumMacrosRead = 0;
928 unsigned TotalNumMacros = 0;
931 unsigned NumIdentifierLookups = 0;
934 unsigned NumIdentifierLookupHits = 0;
937 unsigned NumSelectorsRead = 0;
940 unsigned NumMethodPoolEntriesRead = 0;
944 unsigned NumMethodPoolLookups = 0;
948 unsigned NumMethodPoolHits = 0;
952 unsigned NumMethodPoolTableLookups = 0;
956 unsigned NumMethodPoolTableHits = 0;
959 unsigned TotalNumMethodPoolEntries = 0;
962 unsigned NumLexicalDeclContextsRead = 0, TotalLexicalDeclContexts = 0;
965 unsigned NumVisibleDeclContextsRead = 0, TotalVisibleDeclContexts = 0;
968 uint64_t TotalModulesSizeInBits = 0;
971 unsigned NumCurrentElementsDeserializing = 0;
977 bool PassingDeclsToConsumer =
false;
984 llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4> >
985 PendingIdentifierInfos;
989 llvm::SmallMapVector<IdentifierInfo *, SmallVector<NamedDecl*, 2>, 16>
990 PendingFakeLookupResults;
994 llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration;
996 class InterestingDecl {
998 bool DeclHasPendingBody;
1001 InterestingDecl(
Decl *D,
bool HasBody)
1002 : D(D), DeclHasPendingBody(HasBody) {}
1003 Decl *getDecl() {
return D; }
1005 bool hasPendingBody() {
return DeclHasPendingBody; }
1014 std::deque<InterestingDecl> PotentiallyInterestingDecls;
1019 SmallVector<std::pair<Decl *, uint64_t>, 16> PendingDeclChains;
1023 SmallVector<Decl *, 16> PendingIncompleteDeclChains;
1027 struct PendingDeclContextInfo {
1038 std::deque<PendingDeclContextInfo> PendingDeclContextInfos;
1049 llvm::SmallDenseMap<CXXRecordDecl *, llvm::TinyPtrVector<CXXRecordDecl *>, 2>
1050 PendingOdrMergeFailures;
1053 llvm::SmallPtrSet<DeclContext*, 2> DiagnosedOdrMergeFailures;
1057 llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized;
1062 SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded;
1064 typedef llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2> >
1072 KeyDeclsMap KeyDecls;
1077 llvm::DenseMap<DeclContext *, DeclContext *> MergedDeclContexts;
1081 llvm::DenseMap<EnumDecl *, EnumDecl *> EnumDefinitions;
1084 SmallVector<Stmt *, 16> StmtStack;
1088 Read_None, Read_Decl, Read_Type, Read_Stmt
1092 ReadingKind ReadingKind = Read_None;
1095 class ReadingKindTracker {
1097 enum ReadingKind PrevKind;
1099 ReadingKindTracker(
const ReadingKindTracker &) =
delete;
1100 void operator=(
const ReadingKindTracker &) =
delete;
1103 ReadingKindTracker(
enum ReadingKind newKind, ASTReader &reader)
1104 : Reader(reader), PrevKind(Reader.ReadingKind) {
1105 Reader.ReadingKind = newKind;
1108 ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
1112 class ProcessingUpdatesRAIIObj {
1116 ProcessingUpdatesRAIIObj(
const ProcessingUpdatesRAIIObj &) =
delete;
1117 void operator=(
const ProcessingUpdatesRAIIObj &) =
delete;
1120 ProcessingUpdatesRAIIObj(ASTReader &reader)
1121 : Reader(reader), PrevState(Reader.ProcessingUpdateRecords) {
1122 Reader.ProcessingUpdateRecords =
true;
1125 ~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; }
1136 std::string SuggestedPredefines;
1138 llvm::DenseMap<const Decl *, bool> BodySource;
1143 struct InputFileInfo {
1149 bool TopLevelModuleMap;
1153 InputFileInfo readInputFileInfo(
ModuleFile &F,
unsigned ID);
1157 serialization::InputFile getInputFile(
ModuleFile &F,
unsigned ID,
1158 bool Complain =
true);
1172 auto I = KeyDecls.find(D);
1173 if (
I == KeyDecls.end() ||
I->second.empty())
1182 template <
typename Fn>
1188 auto It = KeyDecls.find(const_cast<Decl*>(D));
1189 if (It != KeyDecls.end())
1190 for (
auto ID : It->second)
1199 struct ImportedModule {
1207 : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) { }
1211 SourceLocation ImportLoc,
ModuleFile *ImportedBy,
1212 SmallVectorImpl<ImportedModule> &Loaded,
1213 off_t ExpectedSize, time_t ExpectedModTime,
1214 ASTFileSignature ExpectedSignature,
1215 unsigned ClientLoadCapabilities);
1217 SmallVectorImpl<ImportedModule> &Loaded,
1219 unsigned ClientLoadCapabilities);
1221 llvm::BitstreamCursor &Stream,
unsigned ClientLoadCapabilities,
1222 bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
1223 std::string &SuggestedPredefines);
1230 unsigned ClientLoadCapabilities);
1233 readUnhashedControlBlockImpl(
ModuleFile *F, llvm::StringRef StreamData,
1234 unsigned ClientLoadCapabilities,
1235 bool AllowCompatibleConfigurationMismatch,
1236 ASTReaderListener *Listener,
1237 bool ValidateDiagnosticOptions);
1241 void ReadModuleOffsetMap(
ModuleFile &F)
const;
1244 llvm::BitstreamCursor &SLocCursorForID(
int ID);
1245 SourceLocation getImportLocation(
ModuleFile *F);
1248 unsigned ClientLoadCapabilities);
1250 unsigned ClientLoadCapabilities);
1251 static bool ParseLanguageOptions(
const RecordData &Record,
bool Complain,
1252 ASTReaderListener &Listener,
1253 bool AllowCompatibleDifferences);
1254 static bool ParseTargetOptions(
const RecordData &Record,
bool Complain,
1255 ASTReaderListener &Listener,
1256 bool AllowCompatibleDifferences);
1257 static bool ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
1258 ASTReaderListener &Listener);
1259 static bool ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
1260 ASTReaderListener &Listener);
1261 static bool ParseHeaderSearchOptions(
const RecordData &Record,
bool Complain,
1262 ASTReaderListener &Listener);
1263 static bool ParsePreprocessorOptions(
const RecordData &Record,
bool Complain,
1264 ASTReaderListener &Listener,
1265 std::string &SuggestedPredefines);
1267 struct RecordLocation {
1274 QualType readTypeRecord(
unsigned Index);
1276 SmallVectorImpl<QualType> &ExceptionStorage,
1277 FunctionProtoType::ExceptionSpecInfo &ESI,
1279 RecordLocation TypeCursorForIndex(
unsigned Index);
1280 void LoadedDecl(
unsigned Index, Decl *D);
1282 void markIncompleteDeclChain(Decl *Canon);
1287 Decl *getMostRecentExistingDecl(Decl *D);
1290 SourceLocation &Location);
1291 void loadDeclUpdateRecords(PendingUpdateRecord &Record);
1292 void loadPendingDeclChain(Decl *D, uint64_t LocalOffset);
1294 unsigned PreviousGeneration = 0);
1296 RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
1297 uint64_t getGlobalBitOffset(
ModuleFile &M, uint32_t LocalOffset);
1302 findPreprocessedEntity(SourceLocation Loc,
bool EndsAfter)
const;
1311 findNextPreprocessedEntity(
1316 std::pair<ModuleFile *, unsigned>
1317 getModulePreprocessedEntity(
unsigned GlobalIndex);
1321 llvm::iterator_range<PreprocessingRecord::iterator>
1322 getModulePreprocessedEntities(
ModuleFile &Mod)
const;
1326 :
public llvm::iterator_adaptor_base<
1327 ModuleDeclIterator, const serialization::LocalDeclID *,
1328 std::random_access_iterator_tag, const Decl *, ptrdiff_t,
1329 const Decl *, const Decl *> {
1335 : iterator_adaptor_base(nullptr), Reader(nullptr), Mod(nullptr) {}
1339 : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
1347 assert(Reader == RHS.Reader && Mod == RHS.Mod);
1352 llvm::iterator_range<ModuleDeclIterator>
1356 void PassInterestingDeclsToConsumer();
1357 void PassInterestingDeclToConsumer(
Decl *D);
1359 void finishPendingActions();
1360 void diagnoseOdrViolations();
1364 void addPendingDeclContextInfo(
Decl *D,
1368 PendingDeclContextInfo Info = { D, SemaDC, LexicalDC };
1369 PendingDeclContextInfos.push_back(Info);
1376 void Error(StringRef Msg)
const;
1377 void Error(
unsigned DiagID, StringRef Arg1 = StringRef(),
1378 StringRef Arg2 = StringRef())
const;
1380 ASTReader(
const ASTReader &) =
delete;
1381 void operator=(
const ASTReader &) =
delete;
1422 ASTReader(Preprocessor &PP, ASTContext *
Context,
1423 const PCHContainerReader &PCHContainerRdr,
1424 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
1425 StringRef isysroot =
"",
bool DisableValidation =
false,
1426 bool AllowASTWithCompilerErrors =
false,
1427 bool AllowConfigurationMismatch =
false,
1428 bool ValidateSystemInputs =
false,
bool UseGlobalIndex =
true,
1429 std::unique_ptr<llvm::Timer> ReadTimer = {});
1478 unsigned ClientLoadCapabilities,
1503 return std::move(Listener);
1508 this->Listener = std::move(Listener);
1516 L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
1517 std::move(Listener));
1518 Listener = std::move(L);
1528 : Reader(Reader), Chained(
false) {
1532 L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
1540 Reader.
setListener(static_cast<ChainedASTReaderListener *>(New.get())
1547 bool TakeOwnership =
false);
1575 std::unique_ptr<llvm::MemoryBuffer>
Buffer) {
1611 bool FindModuleFileExtensions,
1613 bool ValidateDiagnosticOptions);
1622 StringRef ExistingModuleCachePath);
1637 std::pair<unsigned, unsigned>
1652 return TotalNumSLocEntries;
1657 return static_cast<unsigned>(IdentifiersLoaded.size());
1662 return static_cast<unsigned>(MacrosLoaded.size());
1667 return static_cast<unsigned>(TypesLoaded.size());
1672 return static_cast<unsigned>(DeclsLoaded.size());
1677 return static_cast<unsigned>(SubmodulesLoaded.size());
1682 return static_cast<unsigned>(SelectorsLoaded.size());
1689 for (
const auto &M : ModuleMgr)
1690 Result += M.NumPreprocessedEntities;
1726 if (Idx >= Record.size())
1768 template<
typename T>
1800 template<
typename T>
1845 llvm::function_ref<
bool(
Decl::Kind)> IsKindWeWant,
1914 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined)
override;
1935 SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels)
override;
1938 SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI)
override;
1947 llvm::MapVector<
const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
2041 unsigned LocalID)
const;
2070 bool Canonicalize =
false);
2080 unsigned &Idx,
bool Canonicalize =
false);
2115 ReadModuleOffsetMap(ModuleFile);
2118 "Cannot find offset to remap.");
2119 int Remap = ModuleFile.
SLocRemap.
find(Loc.getOffset())->second;
2142 const llvm::fltSemantics &Sem,
unsigned &Idx);
2167 assert(ReadingKind == Read_Stmt &&
2168 "Should be called only during statement reading!");
2171 assert(!StmtStack.empty() &&
"Read too many sub-statements!");
2172 return StmtStack.pop_back_val();
2196 uint64_t MacroDirectivesOffset);
2212 assert(ContextObj &&
"requested AST context when not loading AST");
2252 bool IncludeSystem,
bool Complain,
2280 : Reader(&Reader), F(&F) {}
2295 size_t size()
const {
return Record.size(); }
2300 const uint64_t &
back()
const {
return Record.back(); }
2304 const uint64_t &
readInt() {
return Record[Idx++]; }
2324 return Reader->ReadLexicalDeclContextStorage(*F, F->
DeclsCursor, Offset,
2331 return Reader->ReadVisibleDeclContextStorage(*F, F->
DeclsCursor, Offset,
2337 return Reader->readExceptionSpec(*F, ExceptionStorage, ESI, Record, Idx);
2342 return Reader->getGlobalBitOffset(*F, LocalOffset);
2360 template<
typename T>
2362 return cast_or_null<T>(Reader->
GetLocalDecl(*F, LocalID));
2395 return Reader->
readType(*F, Record, Idx);
2408 return Reader->
ReadDecl(*F, Record, Idx);
2416 template<
typename T>
2418 return Reader->
ReadDeclAs<T>(*F, Record, Idx);
2470 bool Canonicalize =
false) {
2526 return Reader->
ReadPath(*F, Record, Idx);
2541 return Reader->
ReadToken(*F, Record, Idx);
2558 : Cursor(Cursor),
Offset(Cursor.GetCurrentBitNo()) { }
2565 llvm::BitstreamCursor &
Cursor;
2569 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.
const uint64_t & readInt()
Returns the current value in this record, and advances to the next value.
SmallVector< std::pair< llvm::BitstreamCursor, serialization::ModuleFile * >, 8 > CommentsCursors
Cursors for comments blocks.
static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts, const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts, StringRef ExistingModuleCachePath)
Determine whether the given AST file is acceptable to load into a translation unit with the given lan...
void updateOutOfDateSelector(Selector Sel) override
Load the contents of the global method pool for a given selector if necessary.
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...
SourceLocation readSourceLocation()
Read a source location, advancing Idx.
The client can handle an AST file that cannot load because it was built with a different version of C...
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
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.
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.
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...
ASTRecordReader(ASTReader &Reader, ModuleFile &F)
Construct an ASTRecordReader that uses the default encoding scheme.
Stmt - This represents one statement.
Optional< bool > isPreprocessedEntityInFileID(unsigned Index, FileID FID) override
Optionally returns true or false if the preallocated preprocessed entity with index Index came from f...
void ReadComments() override
Loads comments ranges.
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.
value_type operator->() const
llvm::APFloat readAPFloat(const llvm::fltSemantics &Sem)
Read a floating-point value, advancing Idx.
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
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...
void readQualifierInfo(QualifierInfo &Info)
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
size_t size() const
The length of this record.
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...
ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod, const serialization::LocalDeclID *Pos)
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.
Manage memory buffers across multiple users.
void CompleteRedeclChain(const Decl *D) override
If any redeclarations of D have been imported since it was last checked, this digs out those redeclar...
ModuleManager::ModuleReverseIterator ModuleReverseIterator
void recordSwitchCaseID(SwitchCase *SC, unsigned ID)
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
QualType readType()
Read a type from the current position in the record.
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)
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
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.
void ReadUndefinedButUsed(llvm::MapVector< 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.
StringRef ModuleOffsetMap
The module offset map data for this file.
NestedNameSpecifierLoc readNestedNameSpecifierLoc()
One of these records is kept for each identifier that is lexed.
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
T * readDeclAs()
Reads a declaration from the given position in the record, advancing Idx.
bool hasGlobalIndex() const
Determine whether this AST reader has a global index.
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...
const uint64_t & back() const
The last element in this record.
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
Expr * readExpr()
Reads an expression.
Helper class that saves the current stream position and then restores it when destroyed.
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.
TemplateArgument readTemplateArgument(bool Canonicalize=false)
Read a template argument, advancing Idx.
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...
TypeSourceInfo * getTypeSourceInfo()
Reads a declarator info from the given record, advancing Idx.
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.
ASTReadResult ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, unsigned ClientLoadCapabilities, SmallVectorImpl< ImportedSubmodule > *Imported=nullptr)
Load the AST file designated by the given file name.
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.
ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc)
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.
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
llvm::iterator_range< ModuleDeclIterator > getModuleFileLevelDecls(ModuleFile &Mod)
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)
ExtKind hasExternalDefinitions(const Decl *D) override
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.
Defines the Diagnostic-related interfaces.
SourceRange readSourceRange()
Read a source range, advancing Idx.
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.
TemplateArgumentLocInfo getTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind, advancing Idx...
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.
const ASTTemplateArgumentListInfo * readASTTemplateArgumentListInfo()
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
CXXBaseSpecifier readCXXBaseSpecifier()
Read a C++ base specifier, advancing Idx.
The AST file itself appears corrupted.
unsigned getTotalNumDecls() const
Returns the number of declarations found in the chain.
detail::InMemoryDirectory::const_iterator I
void dump()
Dump information about the AST reader to standard error.
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.
const uint64_t & peekInt()
Returns the current value in this record, without advancing.
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.
serialization::TypeID getGlobalTypeID(unsigned LocalID) const
Map a local type ID within a given AST file to a global type ID.
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.
TemplateParameterList * readTemplateParameterList()
Read a template parameter list, advancing Idx.
ModuleKind
Specifies the kind of module that has been loaded.
Provides lookups to, and iteration over, IdentiferInfo objects.
SourceLocation ReadUntranslatedSourceLocation(uint32_t Raw) const
Read a source location from raw form and return it in its originating module file's source location s...
void SetGloballyVisibleDecls(IdentifierInfo *II, const SmallVectorImpl< uint32_t > &DeclIDs, SmallVectorImpl< Decl * > *Decls=nullptr)
Set the globally-visible declarations associated with the given identifier.
void readTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, bool Canonicalize=false)
Read a template argument array, advancing Idx.
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.
void visitInputFiles(serialization::ModuleFile &MF, bool IncludeSystem, bool Complain, llvm::function_ref< void(const serialization::InputFile &IF, bool isSystem)> Visitor)
Visit all the input files of the given module file.
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo)
std::string readPath()
Read a path, advancing Idx.
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.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::iterator > ModuleIterator
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...
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.
Stmt * readStmt()
Reads a statement.
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. ...
SimpleASTReaderListener(Preprocessor &PP)
ASTReaderListenter implementation to set SuggestedPredefines of ASTReader which is required to use a ...
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.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Decl * readDecl()
Reads a declaration from the given position in a record in the given module, advancing Idx...
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.
IdentifierInfo * getIdentifierInfo()
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 ...
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::const_iterator > ModuleConstIterator
The result type of a method or function.
std::string readString()
Read a string, advancing Idx.
SmallVector< uint64_t, 16 > PreloadedDeclIDs
void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, const RecordData &Record, unsigned &Idx)
void skipInts(unsigned N)
Skips the specified number of values.
The client can't handle any AST loading failures.
const uint64_t & operator[](size_t N)
An arbitrary index in this record.
bool operator==(const ModuleDeclIterator &RHS) const
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 mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef)
Note that MergedDef is a redefinition of the canonical definition Def, so Def should be visible whene...
unsigned readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID)
Reads a record with id AbbrevID from Cursor, resetting the internal state.
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...
SourceLocation TranslateSourceLocation(ModuleFile &ModuleFile, SourceLocation Loc) const
Translate a source location from another module file's source location space into ours...
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.
CXXTemporary * readCXXTemporary()
Encodes a location in the source.
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
Stmt * readSubStmt()
Reads a sub-statement operand during statement reading.
Represents a C++ temporary.
void InitializeContext()
Initializes the ASTContext.
CXXCtorInitializer ** readCXXCtorInitializers()
Read a CXXCtorInitializer array, advancing Idx.
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...
bool readLexicalDeclContextStorage(uint64_t Offset, DeclContext *DC)
Read the record that describes the lexical contents of a DC.
Cached information about one file (either on disk or in the virtual file system). ...
bool isProcessingUpdateRecords()
void readDeclarationNameInfo(DeclarationNameInfo &NameInfo)
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.
Expr * readSubExpr()
Reads a sub-expression operand during statement reading.
T * GetLocalDeclAs(uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
unsigned getIdx() const
The current position in this record.
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.
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
void readDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name)
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.
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
void setListener(std::unique_ptr< ASTReaderListener > Listener)
Set the AST callbacks listener.
void readExceptionSpec(SmallVectorImpl< QualType > &ExceptionStorage, FunctionProtoType::ExceptionSpecInfo &ESI)
serialization::SubmoduleID getGlobalSubmoduleID(unsigned LocalID)
Retrieve the global submodule ID its local ID number.
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...
serialization::SubmoduleID ID
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.
serialization::DeclID readDeclID()
Reads a declaration ID from the given position in this record.
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.
void readAttributes(AttrVec &Attrs)
Reads attributes from the current stream position, advancing Idx.
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.
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.
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...
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::reverse_iterator > ModuleReverseIterator
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.
Selector readSelector()
Read a selector from the Record, advancing Idx.
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...
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
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
unsigned getTotalNumMacros() const
Returns the number of macros found in the chain.
TemplateArgumentLoc readTemplateArgumentLoc()
Reads a TemplateArgumentLoc, advancing Idx.
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()
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, uint32_t Raw) const
Read a source location from raw form.
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate >> &LPTMap) override
Read the set of late parsed template functions for this source.
VersionTuple readVersionTuple()
Read a version tuple, advancing Idx.
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.
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope...
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.
uint64_t getGlobalBitOffset(uint32_t LocalOffset)
Get the global offset corresponding to a local offset.
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.
llvm::APSInt readAPSInt()
Read a signed integral value, advancing Idx.
void visitTopLevelModuleMaps(serialization::ModuleFile &MF, llvm::function_ref< void(const FileEntry *)> Visitor)
Visit all the top-level module maps loaded when building the given module file.
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.
TemplateName readTemplateName()
Read a template name, advancing Idx.
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.
DeclarationName readDeclarationName()
Read a declaration name, advancing Idx.
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)
value_type operator*() const
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
llvm::APInt readAPInt()
Read an integral value, advancing Idx.
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.
An object for streaming information from a record.
bool readVisibleDeclContextStorage(uint64_t Offset, serialization::DeclID ID)
Read the record that describes the visible contents of a DC.
Kind
Lists the kind of concrete classes of Decl.
SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID)
Returns the source location for the decl ID.
The AST file was written by a different version of Clang.
void ReadAttributes(ASTRecordReader &Record, AttrVec &Attrs)
Reads attributes from the current stream position.
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions, ASTReaderListener &Listener, bool ValidateDiagnosticOptions)
Read the control block for the named AST file.
NestedNameSpecifier * readNestedNameSpecifier()
Token readToken()
Reads a token out of a record, advancing Idx.
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...
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
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...
uint32_t TypeID
An ID number that refers to a type in an AST file.
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
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. ...
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
void FinishedDeserializing() override
Notify ASTReader that we finished the deserialization of a decl or type.
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
std::unique_ptr< ASTReaderListener > takeFirst()
void ReadModuleName(StringRef ModuleName) override
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
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)
void readUnresolvedSet(LazyASTUnresolvedSet &Set)
Read a UnresolvedSet structure, advancing Idx.