Go to the documentation of this file.
13 #ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H
14 #define LLVM_CLANG_SERIALIZATION_ASTREADER_H
36 #include "llvm/ADT/ArrayRef.h"
37 #include "llvm/ADT/DenseMap.h"
38 #include "llvm/ADT/DenseSet.h"
39 #include "llvm/ADT/IntrusiveRefCntPtr.h"
40 #include "llvm/ADT/MapVector.h"
41 #include "llvm/ADT/Optional.h"
42 #include "llvm/ADT/STLExtras.h"
43 #include "llvm/ADT/SetVector.h"
44 #include "llvm/ADT/SmallPtrSet.h"
45 #include "llvm/ADT/SmallVector.h"
46 #include "llvm/ADT/StringMap.h"
47 #include "llvm/ADT/StringRef.h"
48 #include "llvm/ADT/iterator.h"
49 #include "llvm/ADT/iterator_range.h"
50 #include "llvm/Bitstream/BitstreamReader.h"
51 #include "llvm/Support/MemoryBuffer.h"
52 #include "llvm/Support/Timer.h"
53 #include "llvm/Support/VersionTuple.h"
69 class ASTDeserializationListener;
71 class ASTRecordReader;
74 class DeclarationName;
82 class FileSystemOptions;
84 class GlobalModuleIndex;
85 struct HeaderFileInfo;
86 class HeaderSearchOptions;
89 class InMemoryModuleCache;
92 class ObjCCategoryDecl;
93 class ObjCInterfaceDecl;
94 class PCHContainerReader;
96 class PreprocessorOptions;
103 class TypedefNameDecl;
133 bool AllowCompatibleDifferences) {
142 bool AllowCompatibleDifferences) {
170 StringRef SpecificModuleCachePath,
212 bool isOverridden,
bool isExplicitModule) {
231 std::unique_ptr<ASTReaderListener> First;
232 std::unique_ptr<ASTReaderListener> Second;
237 std::unique_ptr<ASTReaderListener> Second)
241 std::unique_ptr<ASTReaderListener>
takeSecond() {
return std::move(Second); }
247 bool AllowCompatibleDifferences)
override;
249 bool AllowCompatibleDifferences)
override;
251 bool Complain)
override;
253 bool Complain)
override;
256 StringRef SpecificModuleCachePath,
257 bool Complain)
override;
268 bool isOverridden,
bool isExplicitModule)
override;
281 : PP(PP), Reader(Reader) {}
284 bool AllowCompatibleDifferences)
override;
286 bool AllowCompatibleDifferences)
override;
288 bool Complain)
override;
292 StringRef SpecificModuleCachePath,
293 bool Complain)
override;
297 void Error(
const char *Msg);
314 namespace serialization {
316 class ReadMethodPoolVisitor;
403 std::unique_ptr<ASTReaderListener> Listener;
408 bool OwnsDeserializationListener =
false;
417 Sema *SemaObj =
nullptr;
437 llvm::StringMap<std::shared_ptr<ModuleFileExtension>> ModuleFileExtensions;
440 std::unique_ptr<llvm::Timer> ReadTimer;
450 std::unique_ptr<GlobalModuleIndex> GlobalIndex;
470 std::vector<QualType> TypesLoaded;
484 std::vector<Decl *> DeclsLoaded;
493 using FileOffset = std::pair<ModuleFile *, uint64_t>;
495 using DeclUpdateOffsetsMap =
496 llvm::DenseMap<serialization::DeclID, FileOffsetsTy>;
500 DeclUpdateOffsetsMap DeclUpdateOffsets;
502 struct PendingUpdateRecord {
511 : D(D), ID(ID), JustLoaded(JustLoaded) {}
518 enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded };
522 llvm::DenseMap<void *, PendingFakeDefinitionKind> PendingFakeDefinitionData;
528 llvm::SmallMapVector<Decl *, FunctionDecl *, 4> PendingExceptionSpecUpdates;
533 llvm::SmallMapVector<FunctionDecl *, QualType, 4> PendingDeducedTypeUpdates;
537 llvm::DenseMap<std::pair<DeclContext *, IdentifierInfo *>, NamedDecl *>
538 ImportedTypedefNamesForLinkage;
542 llvm::DenseMap<Decl*, llvm::SmallVector<NamedDecl*, 2>>
543 AnonymousDeclarationsForMerging;
547 using LETemporaryKey = std::pair<Decl *, unsigned>;
550 llvm::DenseMap<LETemporaryKey, LifetimeExtendedTemporaryDecl *>
551 LETemporaryForMerging;
553 struct FileDeclsInfo {
555 ArrayRef<serialization::LocalDeclID> Decls;
557 FileDeclsInfo() =
default;
558 FileDeclsInfo(
ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls)
559 : Mod(Mod), Decls(Decls) {}
563 llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs;
567 using LexicalContents = ArrayRef<llvm::support::unaligned_uint32_t>;
570 llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
574 std::vector<std::pair<ModuleFile*, LexicalContents>> TULexicalDecls;
577 llvm::DenseMap<
const DeclContext *,
578 serialization::reader::DeclContextLookupTable> Lookups;
584 struct PendingVisibleUpdate {
586 const unsigned char *Data;
588 using DeclContextVisibleUpdates = SmallVector<PendingVisibleUpdate, 1>;
592 llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates>
593 PendingVisibleUpdates;
599 using PendingBodiesMap =
601 llvm::SmallDenseMap<Decl *, unsigned, 4>,
602 SmallVector<std::pair<Decl *, uint64_t>, 4>>;
605 PendingBodiesMap PendingBodies;
609 llvm::SetVector<NamedDecl *> PendingMergedDefinitionsToDeduplicate;
612 bool ReadLexicalDeclContextStorage(
ModuleFile &M,
613 llvm::BitstreamCursor &
Cursor,
617 bool ReadVisibleDeclContextStorage(
ModuleFile &M,
618 llvm::BitstreamCursor &
Cursor,
627 std::vector<IdentifierInfo *> IdentifiersLoaded;
629 using GlobalIdentifierMapType =
630 ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>;
635 GlobalIdentifierMapType GlobalIdentifierMap;
643 std::vector<MacroInfo *> MacrosLoaded;
645 using LoadedMacroInfo =
646 std::pair<IdentifierInfo *, serialization::SubmoduleID>;
653 using GlobalMacroMapType =
654 ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>;
659 GlobalMacroMapType GlobalMacroMap;
665 SmallVector<Module *, 2> SubmodulesLoaded;
667 using GlobalSubmoduleMapType =
668 ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>;
673 GlobalSubmoduleMapType GlobalSubmoduleMap;
676 using HiddenNames = SmallVector<Decl *, 2>;
677 using HiddenNamesMapType = llvm::DenseMap<Module *, HiddenNames>;
681 HiddenNamesMapType HiddenNamesMap;
684 struct UnresolvedModuleRef {
692 enum { Import, Export, Conflict }
Kind;
698 unsigned IsWildcard : 1;
706 SmallVector<UnresolvedModuleRef, 2> UnresolvedModuleRefs;
713 SmallVector<Selector, 16> SelectorsLoaded;
715 using GlobalSelectorMapType =
716 ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>;
720 GlobalSelectorMapType GlobalSelectorMap;
724 llvm::DenseMap<Selector, unsigned> SelectorGeneration;
728 llvm::DenseMap<Selector, bool> SelectorOutOfDate;
730 struct PendingMacroInfo {
733 uint32_t MacroDirectivesOffset;
735 PendingMacroInfo(
ModuleFile *M, uint32_t MacroDirectivesOffset)
736 : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
739 using PendingMacroIDsMap =
740 llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2>>;
744 PendingMacroIDsMap PendingMacroIDs;
746 using GlobalPreprocessedEntityMapType =
747 ContinuousRangeMap<unsigned, ModuleFile *, 4>;
752 GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap;
754 using GlobalSkippedRangeMapType =
755 ContinuousRangeMap<unsigned, ModuleFile *, 4>;
759 GlobalSkippedRangeMapType GlobalSkippedRangeMap;
771 SmallVector<serialization::DeclID, 16> EagerlyDeserializedDecls;
778 SmallVector<serialization::DeclID, 16> TentativeDefinitions;
785 SmallVector<serialization::DeclID, 64> VTableUses;
793 SmallVector<serialization::DeclID, 64> PendingInstantiations;
803 SmallVector<serialization::DeclID, 16> UnusedFileScopedDecls;
807 SmallVector<serialization::DeclID, 4> DelegatingCtorDecls;
811 SmallVector<serialization::SelectorID, 64> ReferencedSelectorsData;
815 SmallVector<serialization::IdentifierID, 64> WeakUndeclaredIdentifiers;
820 SmallVector<serialization::DeclID, 4> ExtVectorDecls;
831 SmallVector<serialization::DeclID, 16> UnusedLocalTypedefNameCandidates;
835 unsigned ForceCUDAHostDeviceDepth = 0;
840 SmallVector<serialization::DeclID, 4> SemaDeclRefs;
845 SmallVector<serialization::TypeID, 16> SpecialTypes;
851 SmallVector<serialization::DeclID, 2> CUDASpecialDeclRefs;
854 SmallVector<uint64_t, 1> FPPragmaOptions;
857 SourceLocation OptimizeOffPragmaLocation;
860 int PragmaMSStructState = -1;
863 int PragmaMSPointersToMembersState = -1;
864 SourceLocation PointersToMembersPragmaLocation;
868 SourceLocation FpPragmaCurrentLocation;
869 struct FpPragmaStackEntry {
870 FPOptionsOverride
Value;
871 SourceLocation Location;
872 SourceLocation PushLocation;
880 SourceLocation PragmaAlignPackCurrentLocation;
881 struct PragmaAlignPackStackEntry {
882 Sema::AlignPackInfo
Value;
883 SourceLocation Location;
884 SourceLocation PushLocation;
891 OpenCLOptions OpenCLExtensions;
894 llvm::DenseMap<const Type *, std::set<std::string>> OpenCLTypeExtMap;
897 llvm::DenseMap<const Decl *, std::set<std::string>> OpenCLDeclExtMap;
900 SmallVector<serialization::DeclID, 4> KnownNamespaces;
904 SmallVector<serialization::DeclID, 8> UndefinedButUsed;
907 SmallVector<uint64_t, 8> DelayedDeleteExprs;
910 SmallVector<std::pair<ModuleFile *, SmallVector<uint64_t, 1>>, 4>
942 bool AllowASTWithCompilerErrors;
946 bool AllowConfigurationMismatch;
949 bool ValidateSystemInputs;
952 bool ValidateASTInputFilesContent;
958 bool TriedLoadingGlobalIndex =
false;
961 bool ProcessingUpdateRecords =
false;
963 using SwitchCaseMapTy = llvm::DenseMap<unsigned, SwitchCase *>;
969 SwitchCaseMapTy SwitchCaseStmts;
971 SwitchCaseMapTy *CurrSwitchCaseStmts;
975 unsigned NumSLocEntriesRead = 0;
978 unsigned TotalNumSLocEntries = 0;
982 unsigned NumStatementsRead = 0;
986 unsigned TotalNumStatements = 0;
989 unsigned NumMacrosRead = 0;
992 unsigned TotalNumMacros = 0;
995 unsigned NumIdentifierLookups = 0;
998 unsigned NumIdentifierLookupHits = 0;
1001 unsigned NumSelectorsRead = 0;
1004 unsigned NumMethodPoolEntriesRead = 0;
1008 unsigned NumMethodPoolLookups = 0;
1012 unsigned NumMethodPoolHits = 0;
1016 unsigned NumMethodPoolTableLookups = 0;
1020 unsigned NumMethodPoolTableHits = 0;
1023 unsigned TotalNumMethodPoolEntries = 0;
1026 unsigned NumLexicalDeclContextsRead = 0, TotalLexicalDeclContexts = 0;
1029 unsigned NumVisibleDeclContextsRead = 0, TotalVisibleDeclContexts = 0;
1032 uint64_t TotalModulesSizeInBits = 0;
1035 unsigned NumCurrentElementsDeserializing = 0;
1041 bool PassingDeclsToConsumer =
false;
1048 llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4>>
1049 PendingIdentifierInfos;
1053 llvm::SmallMapVector<IdentifierInfo *, SmallVector<NamedDecl*, 2>, 16>
1054 PendingFakeLookupResults;
1058 llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration;
1060 class InterestingDecl {
1062 bool DeclHasPendingBody;
1065 InterestingDecl(
Decl *D,
bool HasBody)
1066 : D(D), DeclHasPendingBody(HasBody) {}
1068 Decl *getDecl() {
return D; }
1071 bool hasPendingBody() {
return DeclHasPendingBody; }
1080 std::deque<InterestingDecl> PotentiallyInterestingDecls;
1085 SmallVector<std::pair<FunctionDecl *, serialization::TypeID>, 16>
1086 PendingFunctionTypes;
1091 SmallVector<std::pair<Decl *, uint64_t>, 16> PendingDeclChains;
1095 SmallVector<Decl *, 16> PendingIncompleteDeclChains;
1099 struct PendingDeclContextInfo {
1110 std::deque<PendingDeclContextInfo> PendingDeclContextInfos;
1112 template <
typename DeclTy>
1113 using DuplicateObjCDecls = std::pair<DeclTy *, DeclTy *>;
1119 llvm::SmallMapVector<DuplicateObjCDecls<ObjCCategoryDecl>,
1122 PendingObjCExtensionIvarRedeclarations;
1132 using DataPointers =
1133 std::pair<CXXRecordDecl *, struct CXXRecordDecl::DefinitionData *>;
1136 llvm::SmallDenseMap<CXXRecordDecl *, llvm::SmallVector<DataPointers, 2>, 2>
1137 PendingOdrMergeFailures;
1140 llvm::SmallDenseMap<FunctionDecl *, llvm::SmallVector<FunctionDecl *, 2>, 2>
1141 PendingFunctionOdrMergeFailures;
1144 llvm::SmallDenseMap<EnumDecl *, llvm::SmallVector<EnumDecl *, 2>, 2>
1145 PendingEnumOdrMergeFailures;
1157 SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded;
1160 llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2>>;
1167 KeyDeclsMap KeyDecls;
1172 llvm::DenseMap<DeclContext *, DeclContext *> MergedDeclContexts;
1176 llvm::DenseMap<EnumDecl *, EnumDecl *> EnumDefinitions;
1180 llvm::DenseMap<RecordDecl *, RecordDecl *> RecordDefinitions;
1183 SmallVector<Stmt *, 16> StmtStack;
1187 Read_None, Read_Decl, Read_Type, Read_Stmt
1191 ReadingKind ReadingKind = Read_None;
1194 class ReadingKindTracker {
1196 enum ReadingKind PrevKind;
1199 ReadingKindTracker(
enum ReadingKind newKind,
ASTReader &reader)
1200 : Reader(reader), PrevKind(Reader.ReadingKind) {
1201 Reader.ReadingKind = newKind;
1204 ReadingKindTracker(
const ReadingKindTracker &) =
delete;
1205 ReadingKindTracker &
operator=(
const ReadingKindTracker &) =
delete;
1206 ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
1210 class ProcessingUpdatesRAIIObj {
1215 ProcessingUpdatesRAIIObj(
ASTReader &reader)
1216 : Reader(reader), PrevState(Reader.ProcessingUpdateRecords) {
1217 Reader.ProcessingUpdateRecords =
true;
1220 ProcessingUpdatesRAIIObj(
const ProcessingUpdatesRAIIObj &) =
delete;
1221 ProcessingUpdatesRAIIObj &
1222 operator=(
const ProcessingUpdatesRAIIObj &) =
delete;
1223 ~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; }
1236 llvm::DenseMap<const Decl *, bool> DefinitionSource;
1238 bool shouldDisableValidationForFile(
const serialization::ModuleFile &M)
const;
1243 struct InputFileInfo {
1250 bool TopLevelModuleMap;
1254 InputFileInfo readInputFileInfo(
ModuleFile &F,
unsigned ID);
1258 serialization::InputFile getInputFile(
ModuleFile &F,
unsigned ID,
1259 bool Complain =
true);
1273 auto I = KeyDecls.find(D);
1274 if (I == KeyDecls.end() || I->second.empty())
1283 template <
typename Fn>
1289 auto It = KeyDecls.find(
const_cast<Decl*
>(D));
1290 if (It != KeyDecls.end())
1291 for (
auto ID : It->second)
1300 struct ImportedModule {
1308 : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) {}
1312 SourceLocation ImportLoc,
ModuleFile *ImportedBy,
1313 SmallVectorImpl<ImportedModule> &Loaded,
1314 off_t ExpectedSize, time_t ExpectedModTime,
1315 ASTFileSignature ExpectedSignature,
1316 unsigned ClientLoadCapabilities);
1318 SmallVectorImpl<ImportedModule> &Loaded,
1320 unsigned ClientLoadCapabilities);
1322 llvm::BitstreamCursor &Stream,
unsigned ClientLoadCapabilities,
1323 bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
1331 unsigned ClientLoadCapabilities);
1334 readUnhashedControlBlockImpl(
ModuleFile *F, llvm::StringRef StreamData,
1335 unsigned ClientLoadCapabilities,
1336 bool AllowCompatibleConfigurationMismatch,
1337 ASTReaderListener *Listener,
1338 bool ValidateDiagnosticOptions);
1340 llvm::Error ReadASTBlock(
ModuleFile &F,
unsigned ClientLoadCapabilities);
1341 llvm::Error ReadExtensionBlock(
ModuleFile &F);
1342 void ReadModuleOffsetMap(
ModuleFile &F)
const;
1344 llvm::Error ReadSourceManagerBlock(
ModuleFile &F);
1345 llvm::BitstreamCursor &SLocCursorForID(
int ID);
1346 SourceLocation getImportLocation(
ModuleFile *F);
1347 void readIncludedFiles(
ModuleFile &F, StringRef Blob, Preprocessor &PP);
1350 unsigned ClientLoadCapabilities);
1351 llvm::Error ReadSubmoduleBlock(
ModuleFile &F,
1352 unsigned ClientLoadCapabilities);
1353 static bool ParseLanguageOptions(
const RecordData &Record,
bool Complain,
1354 ASTReaderListener &Listener,
1355 bool AllowCompatibleDifferences);
1356 static bool ParseTargetOptions(
const RecordData &Record,
bool Complain,
1357 ASTReaderListener &Listener,
1358 bool AllowCompatibleDifferences);
1359 static bool ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
1360 ASTReaderListener &Listener);
1361 static bool ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
1362 ASTReaderListener &Listener);
1363 static bool ParseHeaderSearchOptions(
const RecordData &Record,
bool Complain,
1364 ASTReaderListener &Listener);
1365 static bool ParsePreprocessorOptions(
const RecordData &Record,
bool Complain,
1366 ASTReaderListener &Listener,
1369 struct RecordLocation {
1376 QualType readTypeRecord(
unsigned Index);
1377 RecordLocation TypeCursorForIndex(
unsigned Index);
1378 void LoadedDecl(
unsigned Index, Decl *D);
1380 void markIncompleteDeclChain(Decl *Canon);
1385 Decl *getMostRecentExistingDecl(Decl *D);
1388 SourceLocation &Location);
1389 void loadDeclUpdateRecords(PendingUpdateRecord &Record);
1390 void loadPendingDeclChain(Decl *D,
uint64_t LocalOffset);
1392 unsigned PreviousGeneration = 0);
1394 RecordLocation getLocalBitOffset(
uint64_t GlobalOffset);
1400 findPreprocessedEntity(SourceLocation Loc,
bool EndsAfter)
const;
1409 findNextPreprocessedEntity(
1414 std::pair<ModuleFile *, unsigned>
1415 getModulePreprocessedEntity(
unsigned GlobalIndex);
1419 llvm::iterator_range<PreprocessingRecord::iterator>
1420 getModulePreprocessedEntities(
ModuleFile &Mod)
const;
1422 bool canRecoverFromOutOfDate(StringRef ModuleFileName,
1423 unsigned ClientLoadCapabilities);
1427 :
public llvm::iterator_adaptor_base<
1428 ModuleDeclIterator, const serialization::LocalDeclID *,
1429 std::random_access_iterator_tag, const Decl *, ptrdiff_t,
1430 const Decl *, const Decl *> {
1439 : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
1448 assert(Reader == RHS.Reader && Mod == RHS.Mod);
1453 llvm::iterator_range<ModuleDeclIterator>
1457 void PassInterestingDeclsToConsumer();
1458 void PassInterestingDeclToConsumer(
Decl *D);
1460 void finishPendingActions();
1461 void diagnoseOdrViolations();
1465 void addPendingDeclContextInfo(
Decl *D,
1469 PendingDeclContextInfo Info = { D, SemaDC, LexicalDC };
1470 PendingDeclContextInfos.push_back(Info);
1477 void Error(StringRef Msg)
const;
1478 void Error(
unsigned DiagID, StringRef Arg1 = StringRef(),
1479 StringRef Arg2 = StringRef(), StringRef Arg3 = StringRef())
const;
1480 void Error(llvm::Error &&Err)
const;
1522 ASTReader(Preprocessor &PP, InMemoryModuleCache &ModuleCache,
1523 ASTContext *Context,
const PCHContainerReader &PCHContainerRdr,
1524 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
1525 StringRef isysroot =
"",
1528 bool AllowASTWithCompilerErrors =
false,
1529 bool AllowConfigurationMismatch =
false,
1530 bool ValidateSystemInputs =
false,
1531 bool ValidateASTInputFilesContent =
false,
1532 bool UseGlobalIndex =
true,
1533 std::unique_ptr<llvm::Timer> ReadTimer = {});
1591 unsigned ClientLoadCapabilities,
1616 return std::move(Listener);
1621 this->Listener = std::move(Listener);
1629 L = std::make_unique<ChainedASTReaderListener>(std::move(L),
1630 std::move(Listener));
1631 Listener = std::move(L);
1637 bool Chained =
false;
1645 L = std::make_unique<ChainedASTReaderListener>(std::move(L),
1661 bool TakeOwnership =
false);
1665 return DeserializationListener;
1694 std::unique_ptr<llvm::MemoryBuffer> Buffer) {
1730 bool FindModuleFileExtensions,
1732 bool ValidateDiagnosticOptions);
1741 StringRef ExistingModuleCachePath);
1756 std::pair<unsigned, unsigned>
1774 return TotalNumSLocEntries;
1779 return static_cast<unsigned>(IdentifiersLoaded.size());
1784 return static_cast<unsigned>(MacrosLoaded.size());
1789 return static_cast<unsigned>(TypesLoaded.size());
1794 return static_cast<unsigned>(DeclsLoaded.size());
1799 return static_cast<unsigned>(SubmodulesLoaded.size());
1804 return static_cast<unsigned>(SelectorsLoaded.size());
1810 unsigned Result = 0;
1811 for (
const auto &M : ModuleMgr)
1812 Result += M.NumPreprocessedEntities;
1829 if (Idx >= Record.size())
1871 template<
typename T>
1903 template<
typename T>
1927 uint64_t *StartOfBlockOffset =
nullptr);
1950 llvm::function_ref<
bool(
Decl::Kind)> IsKindWeWant,
2019 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined)
override;
2055 llvm::MapVector<
const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
2149 unsigned LocalID)
const;
2162 LocSeq *Seq =
nullptr)
const {
2169 LocSeq *Seq =
nullptr)
const {
2182 "Cannot find offset to remap.");
2197 unsigned &Idx, LocSeq *Seq =
nullptr);
2204 Idx += Record[Idx] + 1;
2233 assert(ReadingKind == Read_Stmt &&
2234 "Should be called only during statement reading!");
2237 assert(!StmtStack.empty() &&
"Read too many sub-statements!");
2238 return StmtStack.pop_back_val();
2262 uint32_t MacroDirectivesOffset);
2278 assert(ContextObj &&
"requested AST context when not loading AST");
2318 bool IncludeSystem,
bool Complain,
2333 #endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H
unsigned getTotalNumIdentifiers() const
Returns the number of identifiers found in the chain.
FileManager & getFileManager() const
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
IdentifierInfo * DecodeIdentifierInfo(serialization::IdentifierID ID)
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, const RecordDataImpl &Record, unsigned &Idx, LocSeq *Seq=nullptr)
Read a source location.
Utility class for loading a ASTContext from an AST file.
void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata) override
Indicates that a particular module file extension has been read.
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
A global index for a set of module files, providing information about the identifiers within those mo...
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
void resetForReload()
Reset reader for a reload try.
Abstract interface for external sources of preprocessor information.
An abstract class that should be subclassed by any external source of preprocessing record entries.
A little helper class used to produce diagnostics.
void ClearSwitchCaseIDs()
Manages the set of modules loaded by an AST reader.
bool operator==(const ModuleDeclIterator &RHS) const
ASTReader & operator=(const ASTReader &)=delete
@ HadErrors
The AST file has errors.
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
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...
A trivial tuple used to represent a source range.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
void UpdateSema()
Update the state of Sema after loading some additional modules.
unsigned getTotalNumDecls() const
Returns the number of declarations found in the chain.
unsigned getTotalNumMacros() const
Returns the number of macros found in the chain.
void addInMemoryBuffer(StringRef FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add an in-memory buffer the list of known buffers.
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines)
Receives the preprocessor options.
void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation >> &Pending) override
@ Failure
The AST file itself appears corrupted.
Class that performs lookup for an identifier stored in an AST file.
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override
Finds all the visible declarations with a given name.
Stmt * ReadSubStmt()
Reads a sub-statement operand during statement reading.
void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &Exprs) override
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
T * GetLocalDeclAs(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
An object for streaming information from a record.
SmallVector< uint64_t, 64 > RecordData
This represents a decl that may have a name.
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain) override
Receives the file system options.
Sema * getSema()
Retrieve the semantic analysis object used to analyze the translation unit in which the precompiled h...
Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx)
IdentifierInfo * get(StringRef Name) override
Retrieve the IdentifierInfo for the named identifier.
A (possibly-)qualified type.
virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the target options.
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.
ASTReadResult ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, unsigned ClientLoadCapabilities, SmallVectorImpl< ImportedSubmodule > *Imported=nullptr)
Load the AST file designated by the given file name.
IdentifierIterator * getIdentifiers() override
Retrieve an iterator into the set of all identifiers in all loaded AST files.
Decl * GetExistingDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration.
Represents a member of a struct/union/class.
void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl * > &Decls) override
Read the set of ext_vector type declarations known to the external Sema source.
Concrete class used by the front-end to report problems and issues.
llvm::Optional< ASTSourceDescriptor > getSourceDescriptor(unsigned ID) override
Return a descriptor for the corresponding module.
@ ARR_ConfigurationMismatch
The client can handle an AST file that cannot load because it's compiled configuration doesn't match ...
IdentifierInfo * readIdentifier(ModuleFile &M, const RecordData &Record, unsigned &Idx)
ModuleManager::ModuleReverseIterator ModuleReverseIterator
NameVisibilityKind
Describes the visibility of the various names within a particular module.
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
ASTReader(Preprocessor &PP, InMemoryModuleCache &ModuleCache, ASTContext *Context, const PCHContainerReader &PCHContainerRdr, ArrayRef< std::shared_ptr< ModuleFileExtension >> Extensions, StringRef isysroot="", DisableValidationForModuleKind DisableValidationKind=DisableValidationForModuleKind::None, bool AllowASTWithCompilerErrors=false, bool AllowConfigurationMismatch=false, bool ValidateSystemInputs=false, bool ValidateASTInputFilesContent=false, bool UseGlobalIndex=true, std::unique_ptr< llvm::Timer > ReadTimer={})
Load the AST file and validate its contents against the given Preprocessor.
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
MacroInfo * getMacro(serialization::MacroID ID)
Retrieve the macro with the given ID.
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
PreprocessedEntity * ReadPreprocessedEntity(unsigned Index) override
Read a preallocated preprocessed entity from the external source.
SourceLocation TranslateSourceLocation(ModuleFile &ModuleFile, SourceLocation Loc) const
Translate a source location from another module file's source location space into ours.
Encapsulates the data about a macro definition (e.g.
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
PCHValidator(Preprocessor &PP, ASTReader &Reader)
const Decl * getKeyDeclaration(const Decl *D)
serialization::DeclID getGlobalDeclID(ModuleFile &F, serialization::LocalDeclID LocalID) const
Map from a local declaration ID within a given module to a global declaration ID.
bool ReadSLocEntry(int ID) override
Read the source location entry with index ID.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::reverse_iterator > ModuleReverseIterator
Token - This structure provides full information about a lexed token.
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
The name of a declaration.
virtual ~ASTReaderListener()
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
@ None
Perform validation, don't disable it.
This class handles loading and caching of source files into memory.
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 FinishedDeserializing() override
Notify ASTReader that we finished the deserialization of a decl or type.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
void ReadDefinedMacros() override
Read the set of macros defined by this external macro source.
void makeNamesVisible(const HiddenNames &Names, Module *Owner)
Make the names within this set of hidden names visible.
The base class of the type hierarchy.
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Keeps track of options that affect how file operations are performed.
void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl * > &Decls) override
Read the set of delegating constructors known to the external Sema source.
@ ARR_VersionMismatch
The client can handle an AST file that cannot load because it was built with a different version of C...
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
void ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo >> &WI) override
void StartTranslationUnit(ASTConsumer *Consumer) override
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
void ReadUndefinedButUsed(llvm::MapVector< NamedDecl *, SourceLocation > &Undefined) override
Load the set of used but not defined functions or variables with internal linkage,...
Decl * GetExternalDecl(uint32_t ID) override
Resolve a declaration ID into a declaration, potentially building a new declaration.
void addListener(std::unique_ptr< ASTReaderListener > L)
Add an AST callback listener.
void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind) override
This is called for each AST file loaded.
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...
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Decl * GetLocalDecl(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
serialization::ModuleFile ModuleFile
Kind
Lists the kind of concrete classes of Decl.
@ Success
The control block was read successfully.
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
Describes a module or submodule.
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
ASTReaderListener implementation to validate the information of the PCH file against an initialized P...
virtual void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata)
Indicates that a particular module file extension has been read.
void ReadComments() override
Loads comments ranges.
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
IdentifierInfo * GetIdentifier(serialization::IdentifierID ID) override
serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const
Map a local type ID within a given AST file into a global type ID.
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, SourceLocation::UIntTy Raw, LocSeq *Seq=nullptr) const
Read a source location from raw form.
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...
ModuleManager & getModuleManager()
Retrieve the module manager.
void ReadUsedVTables(SmallVectorImpl< ExternalVTableUse > &VTables) override
Read the set of used vtables known to the external Sema source.
SourceRange ReadSkippedRange(unsigned Index) override
Read a preallocated skipped range from the external source.
void updateOutOfDateIdentifier(IdentifierInfo &II) override
Update an out-of-date identifier.
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
@ ARR_None
The client can't handle any AST loading failures.
Decl * getKeyDeclaration(Decl *D)
Returns the first key declaration for the given declaration.
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID)
Retrieve the global submodule ID given a module and its local ID number.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
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.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::iterator > ModuleIterator
virtual bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain)
Receives the diagnostic options.
An identifier-lookup iterator that enumerates all of the identifiers stored within a set of AST files...
ExtKind hasExternalDefinitions(const Decl *D) override
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
An abstract interface that should be implemented by external AST sources that also provide informatio...
serialization::SubmoduleID ID
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
DisableValidationForModuleKind
Whether to disable the normal validation performed on precompiled headers and module files when they ...
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...
@ ARR_OutOfDate
The client can handle an AST file that cannot load because it is out-of-date relative to its input fi...
ContinuousRangeMap< SourceLocation::UIntTy, SourceLocation::IntTy, 2 > SLocRemap
Remapping table for source locations in this module.
std::pair< SourceLocation, StringRef > getModuleImportLoc(int ID) override
Retrieve the module import location and module name for the given source manager entry ID.
BlockID
The various types of blocks that can occur within a API notes file.
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
void updateOutOfDateSelector(Selector Sel) override
Load the contents of the global method pool for a given selector if necessary.
@ ARR_Missing
The client can handle an AST file that cannot load because it is missing.
An iterator that walks over all of the known identifiers in the lookup table.
virtual void ReadModuleName(StringRef ModuleName)
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
uint32_t IdentifierID
An ID number that refers to an identifier in an AST file.
uint32_t TypeID
An ID number that refers to a type in an AST file.
DiagnosticsEngine & getDiags() const
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
bool loadGlobalIndex()
Attempts to load the global index.
llvm::iterator_range< ModuleDeclIterator > getModuleFileLevelDecls(ModuleFile &Mod)
void dump()
Dump information about the AST reader to standard error.
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.
Represents a C++ temporary.
@ ARR_TreatModuleWithErrorsAsOutOfDate
If a module file is marked with errors treat it as out-of-date so the caller can rebuild it.
void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl * > &Decls) override
Read the set of unused file-scope declarations known to the external Sema source.
unsigned getTotalNumPreprocessedEntities() const
Returns the number of preprocessed entities known to the AST reader.
Writes an AST file containing the contents of a translation unit.
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 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.
RAII object to temporarily add an AST callback listener.
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate >> &LPTMap) override
Read the set of late parsed template functions for this source.
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.
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
SourceManager & getSourceManager() const
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
static std::string ReadString(const RecordData &Record, unsigned &Idx)
void addPendingMacro(IdentifierInfo *II, ModuleFile *M, uint32_t MacroDirectivesOffset)
Add a macro to deserialize its macro directive history.
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
void setListener(std::unique_ptr< ASTReaderListener > Listener)
Set the AST callbacks listener.
value_type operator*() const
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.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
SmallVectorImpl< uint64_t > RecordDataImpl
QualType getLocalType(ModuleFile &F, unsigned LocalID)
Resolve a local type ID within a given AST file into a type.
void markIdentifierUpToDate(IdentifierInfo *II)
Note that this identifier is up-to-date.
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
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.
StringRef ModuleOffsetMap
The module offset map data for this file.
serialization::ModuleKind ModuleKind
QualType GetType(serialization::TypeID ID)
Resolve a type ID into a type, potentially building a new type.
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,...
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx, LocSeq *Seq=nullptr)
Read a source range.
static SourceLocation decode(uint64_t, SourceLocationSequence *=nullptr)
void ReadModuleMapFile(StringRef ModuleMapPath) override
ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod, const serialization::LocalDeclID *Pos)
LoadFailureCapabilities
Flags that indicate what kind of AST loading failures the client of the AST reader can directly handl...
SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID)
Returns the source location for the decl ID.
serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID)
Retrieve the global macro ID corresponding to the given local ID within the given module file.
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
ModuleFile * getLocalModuleFile(ModuleFile &M, unsigned ID)
Retrieve the module file with a given local ID within the specified ModuleFile.
GlobalModuleIndex * getGlobalIndex()
Return global module index.
static void SkipString(const RecordData &Record, unsigned &Idx)
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
unsigned getTotalNumTypes() const
Returns the number of types found in the chain.
virtual void visitImport(StringRef ModuleName, StringRef Filename)
If needsImportVisitation returns true, this is called for each AST file imported by this AST file.
Serialized encoding of a sequence of SourceLocations.
ModuleManager::ModuleIterator ModuleIterator
@ OutOfDate
The AST file is out-of-date relative to its input files, and needs to be regenerated.
ChainedASTReaderListener(std::unique_ptr< ASTReaderListener > First, std::unique_ptr< ASTReaderListener > Second)
Takes ownership of First and Second.
Decl - This represents one declaration (or definition), e.g.
std::unique_ptr< ASTReaderListener > takeFirst()
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID)
Record that the given ID maps to the given switch-case statement.
const std::string & getSuggestedPredefines()
Returns the suggested contents of the predefines buffer, which contains a (typically-empty) subset of...
bool needsInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, unsigned LocalID)
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.
std::unique_ptr< ASTReaderListener > takeListener()
Take the AST callbacks listener.
@ ConfigurationMismatch
The AST file was writtten with a different language/target configuration.
IdentifierInfo * getLocalIdentifier(ModuleFile &M, unsigned LocalID)
Sema - This implements semantic analysis and AST building for C.
virtual void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind)
This is called for each AST file loaded.
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls) override
Read the set of potentially unused typedefs known to the source.
static llvm::Error ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID, uint64_t *StartOfBlockOffset=nullptr)
ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the specified cursor.
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...
void ReadTentativeDefinitions(SmallVectorImpl< VarDecl * > &TentativeDefs) override
Read the set of tentative definitions known to the external Sema source.
uint32_t GetNumExternalSelectors() override
Returns the number of selectors known to the external AST source.
void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation >> &Sels) override
void ReadMethodPool(Selector Sel) override
Load the contents of the global method pool for a given selector.
ModuleFile & getPrimaryModule()
Returns the primary module associated with the manager, that is, the first module loaded.
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...
MacroInfo * ReadMacroRecord(ModuleFile &F, uint64_t Offset)
Reads the macro record located at the given offset.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::const_iterator > ModuleConstIterator
One of these records is kept for each identifier that is lexed.
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo)
void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef)
Note that MergedDef is a redefinition of the canonical definition Def, so Def should be visible whene...
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain)
Receives the header search options.
static void SkipPath(const RecordData &Record, unsigned &Idx)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Sema::AlignPackInfo ReadAlignPackInfo(uint32_t Raw) const
Read a AlignPackInfo from raw form.
void PrintStats() override
Print some statistics about AST usage.
Reads an AST files chain containing the contents of a translation unit.
SmallVector< std::pair< llvm::BitstreamCursor, serialization::ModuleFile * >, 8 > CommentsCursors
Cursors for comments blocks.
void ReadModuleName(StringRef ModuleName) override
SimpleASTReaderListener(Preprocessor &PP)
void SetIdentifierInfo(unsigned ID, IdentifierInfo *II)
Optional< bool > isPreprocessedEntityInFileID(unsigned Index, FileID FID) override
Optionally returns true or false if the preallocated preprocessed entity with index Index came from f...
ListenerScope(ASTReader &Reader, std::unique_ptr< ASTReaderListener > L)
unsigned getTotalNumSLocs() const
Returns the number of source locations found in the chain.
Implements support for file system lookup, file system caching, and directory search management.
void addInMemoryBuffer(StringRef &FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add in-memory (virtual file) buffer.
Smart pointer class that efficiently represents Objective-C method names.
Stmt - This represents one statement.
value_type operator->() const
void StartedDeserializing() override
Notify ASTReader that we started deserialization of a decl or type so until FinishedDeserializing is ...
A map from continuous integer ranges to some value, with a very specialized interface.
typename Representation::const_iterator const_iterator
Abstract interface for callback invocations by the ASTReader.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
@ VersionMismatch
The AST file was written by a different version of Clang.
Stmt * ReadStmt(ModuleFile &F)
Reads a statement.
Represents a base class of a C++ class.
Implements an efficient mapping from strings to IdentifierInfo nodes.
virtual bool needsImportVisitation() const
Returns true if this ASTReaderListener wants to receive the imports of the AST file via visitImport,...
void setDeserializationListener(ASTDeserializationListener *Listener, bool TakeOwnership=false)
Set the AST deserialization listener.
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
Provides lookups to, and iteration over, IdentiferInfo objects.
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
T * ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Selector getLocalSelector(ModuleFile &M, unsigned LocalID)
Retrieve a selector from the given module with its local ID number.
Expr * ReadExpr(ModuleFile &F)
Reads an expression.
SmallVector< uint64_t, 16 > PreloadedDeclIDs
std::unique_ptr< ASTReaderListener > takeSecond()
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
void ReadDeclsToCheckForDeferredDiags(llvm::SmallSetVector< Decl *, 4 > &Decls) override
Read the set of decls to be checked for deferred diags.
void ForgetSema() override
Inform the semantic consumer that Sema is no longer available.
ModuleManager::ModuleConstIterator ModuleConstIterator
std::string OriginalSourceFileName
The original source file name that was used to build the primary AST file, which may have been modifi...
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
ModuleKind
Specifies the kind of module that has been loaded.
bool hasGlobalIndex() const
Determine whether this AST reader has a global index.
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 forEachImportedKeyDecl(const Decl *D, Fn Visit)
Run a callback on each imported key declaration of D.
Options for controlling the target.
Selector DecodeSelector(serialization::SelectorID Idx)
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
This represents one expression.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
bool isProcessingUpdateRecords()
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Represents a C++ base or member initializer.
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope.
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.
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...
External source of source location entries.
ASTReaderListenter implementation to set SuggestedPredefines of ASTReader which is required to use a ...
std::pair< unsigned, unsigned > findPreprocessedEntitiesInRange(SourceRange Range) override
Returns a pair of [Begin, End) indices of preallocated preprocessed entities that Range encompasses.
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
bool ReadFullVersionInformation(StringRef FullVersion) override
Receives the full Clang version information.
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.
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override
Read the header file information for the given file entry.
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
ASTDeserializationListener * getDeserializationListener()
Get the AST deserialization listener.
Decl * ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
Represents a function declaration or definition.
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...
ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc)
Simple wrapper class for chaining listeners.
Information about a module that has been loaded by the ASTReader.
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.
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons.
void SetGloballyVisibleDecls(IdentifierInfo *II, const SmallVectorImpl< uint32_t > &DeclIDs, SmallVectorImpl< Decl * > *Decls=nullptr)
Set the globally-visible declarations associated with the given identifier.
void InitializeContext()
Initializes the ASTContext.
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
SourceLocation ReadUntranslatedSourceLocation(SourceLocation::UIntTy Raw, LocSeq *Seq=nullptr) const
Read a source location from raw form and return it in its originating module file's source location s...
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
void completeVisibleDeclsMap(const DeclContext *DC) override
Load all external visible decls in the given DeclContext.
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
@ Missing
The AST file was missing.