13 #ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H 14 #define LLVM_CLANG_SERIALIZATION_ASTREADER_H 33 #include "llvm/ADT/ArrayRef.h" 34 #include "llvm/ADT/DenseMap.h" 35 #include "llvm/ADT/DenseSet.h" 36 #include "llvm/ADT/IntrusiveRefCntPtr.h" 37 #include "llvm/ADT/MapVector.h" 38 #include "llvm/ADT/Optional.h" 39 #include "llvm/ADT/STLExtras.h" 40 #include "llvm/ADT/SetVector.h" 41 #include "llvm/ADT/SmallPtrSet.h" 42 #include "llvm/ADT/SmallVector.h" 43 #include "llvm/ADT/StringMap.h" 44 #include "llvm/ADT/StringRef.h" 45 #include "llvm/ADT/iterator.h" 46 #include "llvm/ADT/iterator_range.h" 47 #include "llvm/Bitstream/BitstreamReader.h" 48 #include "llvm/Support/MemoryBuffer.h" 49 #include "llvm/Support/Timer.h" 50 #include "llvm/Support/VersionTuple.h" 66 class ASTDeserializationListener;
68 class ASTRecordReader;
71 class DeclarationName;
79 class FileSystemOptions;
81 class GlobalModuleIndex;
82 struct HeaderFileInfo;
83 class HeaderSearchOptions;
85 class LazyASTUnresolvedSet;
87 class InMemoryModuleCache;
90 class ObjCCategoryDecl;
91 class ObjCInterfaceDecl;
92 class PCHContainerReader;
94 class PreprocessorOptions;
102 class TypedefNameDecl;
132 bool AllowCompatibleDifferences) {
141 bool AllowCompatibleDifferences) {
169 StringRef SpecificModuleCachePath,
184 std::string &SuggestedPredefines) {
211 bool isOverridden,
bool isExplicitModule) {
230 std::unique_ptr<ASTReaderListener>
First;
231 std::unique_ptr<ASTReaderListener> Second;
236 std::unique_ptr<ASTReaderListener> Second)
237 : First(
std::move(First)), Second(
std::move(Second)) {}
239 std::unique_ptr<ASTReaderListener>
takeFirst() {
return std::move(First); }
240 std::unique_ptr<ASTReaderListener>
takeSecond() {
return std::move(Second); }
246 bool AllowCompatibleDifferences)
override;
248 bool AllowCompatibleDifferences)
override;
250 bool Complain)
override;
252 bool Complain)
override;
255 StringRef SpecificModuleCachePath,
256 bool Complain)
override;
259 std::string &SuggestedPredefines)
override;
267 bool isOverridden,
bool isExplicitModule)
override;
280 : PP(PP), Reader(Reader) {}
283 bool AllowCompatibleDifferences)
override;
285 bool AllowCompatibleDifferences)
override;
287 bool Complain)
override;
289 std::string &SuggestedPredefines)
override;
291 StringRef SpecificModuleCachePath,
292 bool Complain)
override;
296 void Error(
const char *Msg);
310 std::string &SuggestedPredefines)
override;
313 namespace serialization {
315 class ReadMethodPoolVisitor;
400 std::unique_ptr<ASTReaderListener> Listener;
405 bool OwnsDeserializationListener =
false;
414 Sema *SemaObj =
nullptr;
434 llvm::StringMap<std::shared_ptr<ModuleFileExtension>> ModuleFileExtensions;
437 std::unique_ptr<llvm::Timer> ReadTimer;
444 std::unique_ptr<GlobalModuleIndex> GlobalIndex;
464 std::vector<QualType> TypesLoaded;
478 std::vector<Decl *> DeclsLoaded;
487 using FileOffset = std::pair<ModuleFile *, uint64_t>;
489 using DeclUpdateOffsetsMap =
490 llvm::DenseMap<serialization::DeclID, FileOffsetsTy>;
494 DeclUpdateOffsetsMap DeclUpdateOffsets;
496 struct PendingUpdateRecord {
505 : D(D),
ID(ID), JustLoaded(JustLoaded) {}
512 enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded };
516 llvm::DenseMap<void *, PendingFakeDefinitionKind> PendingFakeDefinitionData;
522 llvm::SmallMapVector<Decl *, FunctionDecl *, 4> PendingExceptionSpecUpdates;
527 llvm::SmallMapVector<FunctionDecl *, QualType, 4> PendingDeducedTypeUpdates;
531 llvm::DenseMap<std::pair<DeclContext *, IdentifierInfo *>,
NamedDecl *>
532 ImportedTypedefNamesForLinkage;
536 llvm::DenseMap<Decl*, llvm::SmallVector<NamedDecl*, 2>>
537 AnonymousDeclarationsForMerging;
541 using LETemporaryKey = std::pair<Decl *, unsigned>;
544 llvm::DenseMap<LETemporaryKey, LifetimeExtendedTemporaryDecl *>
545 LETemporaryForMerging;
547 struct FileDeclsInfo {
551 FileDeclsInfo() =
default;
553 : Mod(Mod), Decls(Decls) {}
557 llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs;
564 llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
568 std::vector<std::pair<ModuleFile*, LexicalContents>> TULexicalDecls;
578 struct PendingVisibleUpdate {
580 const unsigned char *Data;
586 llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates>
587 PendingVisibleUpdates;
591 llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
593 using PendingBodiesMap =
594 llvm::MapVector<
Decl *, uint64_t,
595 llvm::SmallDenseMap<Decl *, unsigned, 4>,
599 PendingBodiesMap PendingBodies;
603 llvm::SetVector<NamedDecl *> PendingMergedDefinitionsToDeduplicate;
606 bool ReadLexicalDeclContextStorage(
ModuleFile &M,
607 llvm::BitstreamCursor &
Cursor,
608 uint64_t
Offset, DeclContext *DC);
611 bool ReadVisibleDeclContextStorage(
ModuleFile &M,
612 llvm::BitstreamCursor &Cursor,
621 std::vector<IdentifierInfo *> IdentifiersLoaded;
637 std::vector<MacroInfo *> MacrosLoaded;
639 using LoadedMacroInfo =
640 std::pair<IdentifierInfo *, serialization::SubmoduleID>;
671 using HiddenNamesMapType = llvm::DenseMap<Module *, HiddenNames>;
675 HiddenNamesMapType HiddenNamesMap;
678 struct UnresolvedModuleRef {
686 enum { Import, Export, Conflict }
Kind;
692 unsigned IsWildcard : 1;
718 llvm::DenseMap<Selector, unsigned> SelectorGeneration;
722 llvm::DenseMap<Selector, bool> SelectorOutOfDate;
724 struct PendingMacroInfo {
726 uint64_t MacroDirectivesOffset;
728 PendingMacroInfo(
ModuleFile *M, uint64_t MacroDirectivesOffset)
729 : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
732 using PendingMacroIDsMap =
733 llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2>>;
737 PendingMacroIDsMap PendingMacroIDs;
828 unsigned ForceCUDAHostDeviceDepth = 0;
853 int PragmaMSStructState = -1;
856 int PragmaMSPointersToMembersState = -1;
862 struct PragmaPackStackEntry {
875 llvm::DenseMap<const Type *, std::set<std::string>> OpenCLTypeExtMap;
878 llvm::DenseMap<const Decl *, std::set<std::string>> OpenCLDeclExtMap;
899 : ID(ID), ImportLoc(ImportLoc) {}
910 std::string isysroot;
914 bool DisableValidation;
917 bool AllowASTWithCompilerErrors;
921 bool AllowConfigurationMismatch;
924 bool ValidateSystemInputs;
927 bool ValidateASTInputFilesContent;
933 bool TriedLoadingGlobalIndex =
false;
936 bool ProcessingUpdateRecords =
false;
938 using SwitchCaseMapTy = llvm::DenseMap<unsigned, SwitchCase *>;
944 SwitchCaseMapTy SwitchCaseStmts;
946 SwitchCaseMapTy *CurrSwitchCaseStmts;
950 unsigned NumSLocEntriesRead = 0;
953 unsigned TotalNumSLocEntries = 0;
957 unsigned NumStatementsRead = 0;
961 unsigned TotalNumStatements = 0;
964 unsigned NumMacrosRead = 0;
967 unsigned TotalNumMacros = 0;
970 unsigned NumIdentifierLookups = 0;
973 unsigned NumIdentifierLookupHits = 0;
976 unsigned NumSelectorsRead = 0;
979 unsigned NumMethodPoolEntriesRead = 0;
983 unsigned NumMethodPoolLookups = 0;
987 unsigned NumMethodPoolHits = 0;
991 unsigned NumMethodPoolTableLookups = 0;
995 unsigned NumMethodPoolTableHits = 0;
998 unsigned TotalNumMethodPoolEntries = 0;
1001 unsigned NumLexicalDeclContextsRead = 0, TotalLexicalDeclContexts = 0;
1004 unsigned NumVisibleDeclContextsRead = 0, TotalVisibleDeclContexts = 0;
1007 uint64_t TotalModulesSizeInBits = 0;
1010 unsigned NumCurrentElementsDeserializing = 0;
1016 bool PassingDeclsToConsumer =
false;
1023 llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4>>
1024 PendingIdentifierInfos;
1028 llvm::SmallMapVector<IdentifierInfo *, SmallVector<NamedDecl*, 2>, 16>
1029 PendingFakeLookupResults;
1033 llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration;
1035 class InterestingDecl {
1037 bool DeclHasPendingBody;
1040 InterestingDecl(Decl *D,
bool HasBody)
1041 : D(D), DeclHasPendingBody(HasBody) {}
1043 Decl *getDecl() {
return D; }
1046 bool hasPendingBody() {
return DeclHasPendingBody; }
1055 std::deque<InterestingDecl> PotentiallyInterestingDecls;
1061 PendingFunctionTypes;
1066 SmallVector<std::pair<Decl *, uint64_t>, 16> PendingDeclChains;
1074 struct PendingDeclContextInfo {
1085 std::deque<PendingDeclContextInfo> PendingDeclContextInfos;
1095 using DataPointers =
1096 std::pair<CXXRecordDecl *, struct CXXRecordDecl::DefinitionData *>;
1099 llvm::SmallDenseMap<CXXRecordDecl *, llvm::SmallVector<DataPointers, 2>, 2>
1100 PendingOdrMergeFailures;
1103 llvm::SmallDenseMap<FunctionDecl *, llvm::SmallVector<FunctionDecl *, 2>, 2>
1104 PendingFunctionOdrMergeFailures;
1107 llvm::SmallDenseMap<EnumDecl *, llvm::SmallVector<EnumDecl *, 2>, 2>
1108 PendingEnumOdrMergeFailures;
1111 llvm::SmallPtrSet<DeclContext*, 2> DiagnosedOdrMergeFailures;
1115 llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized;
1123 llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2>>;
1130 KeyDeclsMap KeyDecls;
1135 llvm::DenseMap<DeclContext *, DeclContext *> MergedDeclContexts;
1139 llvm::DenseMap<EnumDecl *, EnumDecl *> EnumDefinitions;
1146 Read_None, Read_Decl, Read_Type, Read_Stmt
1150 ReadingKind ReadingKind = Read_None;
1153 class ReadingKindTracker {
1155 enum ReadingKind PrevKind;
1158 ReadingKindTracker(
enum ReadingKind newKind,
ASTReader &reader)
1159 : Reader(reader), PrevKind(Reader.ReadingKind) {
1160 Reader.ReadingKind = newKind;
1163 ReadingKindTracker(
const ReadingKindTracker &) =
delete;
1164 ReadingKindTracker &operator=(
const ReadingKindTracker &) =
delete;
1165 ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
1169 class ProcessingUpdatesRAIIObj {
1174 ProcessingUpdatesRAIIObj(
ASTReader &reader)
1175 : Reader(reader), PrevState(Reader.ProcessingUpdateRecords) {
1176 Reader.ProcessingUpdateRecords =
true;
1179 ProcessingUpdatesRAIIObj(
const ProcessingUpdatesRAIIObj &) =
delete;
1180 ProcessingUpdatesRAIIObj &
1181 operator=(
const ProcessingUpdatesRAIIObj &) =
delete;
1182 ~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; }
1193 std::string SuggestedPredefines;
1195 llvm::DenseMap<const Decl *, bool> DefinitionSource;
1200 struct InputFileInfo {
1202 uint64_t ContentHash;
1207 bool TopLevelModuleMap;
1211 InputFileInfo readInputFileInfo(
ModuleFile &F,
unsigned ID);
1216 bool Complain =
true);
1220 static void ResolveImportedPath(std::string &Filename, StringRef Prefix);
1230 auto I = KeyDecls.find(D);
1231 if (I == KeyDecls.end() || I->second.empty())
1233 return GetExistingDecl(I->second[0]);
1236 return getKeyDeclaration(const_cast<Decl*>(D));
1240 template <
typename Fn>
1246 auto It = KeyDecls.find(const_cast<Decl*>(D));
1247 if (It != KeyDecls.end())
1248 for (
auto ID : It->second)
1249 Visit(GetExistingDecl(ID));
1254 getLoadedLookupTables(DeclContext *Primary)
const;
1257 struct ImportedModule {
1265 : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) {}
1271 off_t ExpectedSize, time_t ExpectedModTime,
1273 unsigned ClientLoadCapabilities);
1277 unsigned ClientLoadCapabilities);
1279 llvm::BitstreamCursor &Stream,
unsigned ClientLoadCapabilities,
1281 std::string &SuggestedPredefines);
1288 unsigned ClientLoadCapabilities);
1291 readUnhashedControlBlockImpl(
ModuleFile *F, llvm::StringRef StreamData,
1292 unsigned ClientLoadCapabilities,
1293 bool AllowCompatibleConfigurationMismatch,
1295 bool ValidateDiagnosticOptions);
1299 void ReadModuleOffsetMap(
ModuleFile &F)
const;
1302 llvm::BitstreamCursor &SLocCursorForID(
int ID);
1306 unsigned ClientLoadCapabilities);
1308 unsigned ClientLoadCapabilities);
1309 static bool ParseLanguageOptions(
const RecordData &Record,
bool Complain,
1311 bool AllowCompatibleDifferences);
1312 static bool ParseTargetOptions(
const RecordData &Record,
bool Complain,
1314 bool AllowCompatibleDifferences);
1315 static bool ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
1317 static bool ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
1319 static bool ParseHeaderSearchOptions(
const RecordData &Record,
bool Complain,
1321 static bool ParsePreprocessorOptions(
const RecordData &Record,
bool Complain,
1323 std::string &SuggestedPredefines);
1325 struct RecordLocation {
1332 QualType readTypeRecord(
unsigned Index);
1333 RecordLocation TypeCursorForIndex(
unsigned Index);
1334 void LoadedDecl(
unsigned Index, Decl *D);
1336 void markIncompleteDeclChain(Decl *Canon);
1341 Decl *getMostRecentExistingDecl(Decl *D);
1345 void loadDeclUpdateRecords(PendingUpdateRecord &Record);
1346 void loadPendingDeclChain(Decl *D, uint64_t LocalOffset);
1348 unsigned PreviousGeneration = 0);
1350 RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
1351 uint64_t getGlobalBitOffset(
ModuleFile &M, uint32_t LocalOffset);
1356 findPreprocessedEntity(
SourceLocation Loc,
bool EndsAfter)
const;
1365 findNextPreprocessedEntity(
1366 GlobalSLocOffsetMapType::const_iterator SLocMapI)
const;
1370 std::pair<ModuleFile *, unsigned>
1371 getModulePreprocessedEntity(
unsigned GlobalIndex);
1375 llvm::iterator_range<PreprocessingRecord::iterator>
1376 getModulePreprocessedEntities(
ModuleFile &Mod)
const;
1380 :
public llvm::iterator_adaptor_base<
1381 ModuleDeclIterator, const serialization::LocalDeclID *,
1382 std::random_access_iterator_tag, const Decl *, ptrdiff_t,
1383 const Decl *, const Decl *> {
1392 : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
1401 assert(Reader == RHS.Reader && Mod == RHS.Mod);
1406 llvm::iterator_range<ModuleDeclIterator>
1410 void PassInterestingDeclsToConsumer();
1411 void PassInterestingDeclToConsumer(Decl *D);
1413 void finishPendingActions();
1414 void diagnoseOdrViolations();
1418 void addPendingDeclContextInfo(Decl *D,
1422 PendingDeclContextInfo Info = { D, SemaDC, LexicalDC };
1423 PendingDeclContextInfos.push_back(Info);
1430 void Error(StringRef Msg)
const;
1431 void Error(
unsigned DiagID, StringRef Arg1 = StringRef(),
1432 StringRef Arg2 = StringRef(), StringRef Arg3 = StringRef())
const;
1433 void Error(
unsigned DiagID, StringRef Arg1, StringRef Arg2,
1434 unsigned Select)
const;
1479 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
1480 StringRef isysroot =
"",
bool DisableValidation =
false,
1481 bool AllowASTWithCompilerErrors =
false,
1482 bool AllowConfigurationMismatch =
false,
1483 bool ValidateSystemInputs =
false,
1484 bool ValidateASTInputFilesContent =
false,
1485 bool UseGlobalIndex =
true,
1486 std::unique_ptr<llvm::Timer> ReadTimer = {});
1510 ARR_OutOfDate = 0x2,
1514 ARR_VersionMismatch = 0x4,
1519 ARR_ConfigurationMismatch = 0x8
1540 unsigned ClientLoadCapabilities,
1552 void makeModuleVisible(
Module *Mod,
1565 return std::move(Listener);
1570 this->Listener = std::move(Listener);
1578 L = std::make_unique<ChainedASTReaderListener>(std::move(L),
1579 std::move(Listener));
1580 Listener = std::move(L);
1586 bool Chained =
false;
1594 L = std::make_unique<ChainedASTReaderListener>(std::move(L),
1603 Reader.
setListener(static_cast<ChainedASTReaderListener *>(New.get())
1610 bool TakeOwnership =
false);
1614 return DeserializationListener;
1629 bool loadGlobalIndex();
1633 bool isGlobalIndexUnavailable()
const;
1636 void InitializeContext();
1643 std::unique_ptr<llvm::MemoryBuffer> Buffer) {
1652 void finalizeForWriting();
1669 getOriginalSourceFile(
const std::string &ASTFileName,
FileManager &FileMgr,
1677 readASTFileControlBlock(StringRef Filename,
FileManager &FileMgr,
1679 bool FindModuleFileExtensions,
1681 bool ValidateDiagnosticOptions);
1685 static bool isAcceptableASTFile(StringRef Filename,
FileManager &FileMgr,
1690 StringRef ExistingModuleCachePath);
1705 std::pair<unsigned, unsigned>
1706 findPreprocessedEntitiesInRange(
SourceRange Range)
override;
1714 SourceRange ReadSkippedRange(
unsigned Index)
override;
1723 return TotalNumSLocEntries;
1728 return static_cast<unsigned>(IdentifiersLoaded.size());
1733 return static_cast<unsigned>(MacrosLoaded.size());
1738 return static_cast<unsigned>(TypesLoaded.size());
1743 return static_cast<unsigned>(DeclsLoaded.size());
1748 return static_cast<unsigned>(SubmodulesLoaded.size());
1753 return static_cast<unsigned>(SelectorsLoaded.size());
1760 for (
const auto &M : ModuleMgr)
1778 if (Idx >= Record.size())
1781 return getLocalType(F, Record[Idx++]);
1794 ModuleFile *getOwningModuleFile(
const Decl *D);
1798 std::string getOwningModuleNameForDiagnostic(
const Decl *D);
1806 Decl *GetExternalDecl(uint32_t ID)
override;
1814 return GetDecl(getGlobalDeclID(F, LocalID));
1820 template<
typename T>
1822 return cast_or_null<T>(GetLocalDecl(F, LocalID));
1831 mapGlobalIDToModuleFileGlobalID(
ModuleFile &M,
1844 return GetDecl(ReadDeclID(F, R, I));
1852 template<
typename T>
1854 return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I)));
1860 void CompleteRedeclChain(
const Decl *D)
override;
1869 Stmt *GetExternalDeclStmt(uint64_t Offset)
override;
1874 static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor,
unsigned BlockID);
1879 bool FindExternalVisibleDeclsByName(
const DeclContext *DC,
1896 FindExternalLexicalDecls(
const DeclContext *DC,
1897 llvm::function_ref<
bool(
Decl::Kind)> IsKindWeWant,
1903 void FindFileRegionDecls(
FileID File,
unsigned Offset,
unsigned Length,
1909 void StartedDeserializing()
override;
1913 void FinishedDeserializing()
override;
1920 void StartTranslationUnit(
ASTConsumer *Consumer)
override;
1923 void PrintStats()
override;
1935 void InitializeSema(
Sema &S)
override;
1954 void ReadMethodPool(
Selector Sel)
override;
1958 void updateOutOfDateSelector(
Selector Sel)
override;
1962 void ReadKnownNamespaces(
1965 void ReadUndefinedButUsed(
1966 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined)
override;
1968 void ReadMismatchingDeleteExpressions(llvm::MapVector<
1972 void ReadTentativeDefinitions(
1975 void ReadUnusedFileScopedDecls(
1978 void ReadDelegatingConstructors(
1983 void ReadUnusedLocalTypedefNameCandidates(
1986 void ReadReferencedSelectors(
1989 void ReadWeakUndeclaredIdentifiers(
1994 void ReadPendingInstantiations(
1998 void ReadLateParsedTemplates(
1999 llvm::MapVector<
const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
2020 return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++]));
2027 return DecodeIdentifierInfo(ID);
2035 void resolvePendingMacro(
IdentifierInfo *II,
const PendingMacroInfo &PMInfo);
2045 bool ReadSLocEntry(
int ID)
override;
2049 std::pair<SourceLocation, StringRef> getModuleImportLoc(
int ID)
override;
2054 getGlobalSubmoduleID(
ModuleFile &M,
unsigned LocalID);
2063 Module *getModule(
unsigned ID)
override;
2065 bool DeclIsFromPCHWithObjectFile(
const Decl *D)
override;
2077 ExtKind hasExternalDefinitions(
const Decl *D)
override;
2086 uint32_t GetNumExternalSelectors()
override;
2089 return getLocalSelector(M, Record[Idx++]);
2095 unsigned LocalID)
const;
2109 return TranslateSourceLocation(ModuleFile, Loc);
2117 ReadModuleOffsetMap(ModuleFile);
2120 "Cannot find offset to remap.");
2121 int Remap = ModuleFile.
SLocRemap.
find(Loc.getOffset())->second;
2129 return ReadSourceLocation(ModuleFile, Record[Idx++]);
2137 static std::string ReadString(
const RecordData &Record,
unsigned &Idx);
2141 Idx += Record[Idx] + 1;
2148 std::string ReadPath(StringRef BaseDirectory,
const RecordData &Record,
2153 SkipString(Record, Idx);
2157 static VersionTuple ReadVersionTuple(
const RecordData &Record,
unsigned &Idx);
2170 assert(ReadingKind == Read_Stmt &&
2171 "Should be called only during statement reading!");
2174 assert(!StmtStack.empty() &&
"Read too many sub-statements!");
2175 return StmtStack.pop_back_val();
2179 Expr *ReadSubExpr();
2190 getGlobalPreprocessedEntityID(
ModuleFile &M,
unsigned LocalID)
const;
2199 uint64_t MacroDirectivesOffset);
2202 void ReadDefinedMacros()
override;
2211 void completeVisibleDeclsMap(
const DeclContext *DC)
override;
2215 assert(ContextObj &&
"requested AST context when not loading AST");
2239 void RecordSwitchCaseID(
SwitchCase *SC,
unsigned ID);
2242 SwitchCase *getSwitchCaseWithID(
unsigned ID);
2244 void ClearSwitchCaseIDs();
2251 void ReadComments()
override;
2255 bool IncludeSystem,
bool Complain,
2270 #endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H
SmallVector< std::pair< llvm::BitstreamCursor, serialization::ModuleFile * >, 8 > CommentsCursors
Cursors for comments blocks.
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...
Represents a function declaration or definition.
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...
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
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.
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.
SourceManager & getSourceManager() const
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
OpenCL supported extensions and optional core features.
Stmt - This represents one statement.
ModuleManager::ModuleReverseIterator ModuleReverseIterator
C Language Family Type Representation.
GlobalModuleIndex * getGlobalIndex()
Return global module index.
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, uint32_t Raw) const
Read a source location from raw form.
Decl - This represents one declaration (or definition), e.g.
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
The base class of the type hierarchy.
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
ModuleManager::ModuleConstIterator ModuleConstIterator
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
unsigned NumPreprocessedEntities
ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod, const serialization::LocalDeclID *Pos)
Manages the set of modules loaded by an AST reader.
Options for controlling the target.
unsigned getTotalNumPreprocessedEntities() const
Returns the number of preprocessed entities known to the AST reader.
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)
StringRef ModuleOffsetMap
The module offset map data for this file.
One of these records is kept for each identifier that is lexed.
T * GetLocalDeclAs(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Utility class for loading a ASTContext from an AST file.
unsigned getTotalNumDecls() const
Returns the number of declarations found in the chain.
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
Represents a member of a struct/union/class.
value_type operator->() const
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
Token - This structure provides full information about a lexed token.
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.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
The signature of a module, which is a hash of the AST content.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static void SkipString(const RecordData &Record, unsigned &Idx)
Decl * getKeyDeclaration(Decl *D)
Returns the first key declaration for the given declaration.
Describes a module or submodule.
ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc)
FileManager & getFileManager() const
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
ModuleManager & getModuleManager()
Retrieve the module manager.
serialization::DeclID getGlobalDeclID(ModuleFile &F, serialization::LocalDeclID LocalID) const
Map from a local declaration ID within a given module to a global declaration ID. ...
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, const RecordDataImpl &Record, unsigned &Idx)
Read a source location.
Concrete class used by the front-end to report problems and issues.
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
Defines the Diagnostic-related interfaces.
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.
ContinuousRangeMap< uint32_t, int, 2 > SLocRemap
Remapping table for source locations in this module.
Represents an ObjC class declaration.
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
The AST file itself appears corrupted.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
void ForgetSema() override
Inform the semantic consumer that Sema is no longer available.
Sema - This implements semantic analysis and AST building for C.
A little helper class used to produce diagnostics.
virtual bool needsImportVisitation() const
Returns true if this ASTReaderListener wants to receive the imports of the AST file via visitImport...
bool operator==(const ModuleDeclIterator &RHS) const
ModuleKind
Specifies the kind of module that has been loaded.
Provides lookups to, and iteration over, IdentiferInfo objects.
Decl * ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::reverse_iterator > ModuleReverseIterator
ASTReaderListener implementation to validate the information of the PCH file against an initialized P...
Abstract interface for external sources of preprocessor information.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
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.
Implements an efficient mapping from strings to IdentifierInfo nodes.
virtual void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata)
Indicates that a particular module file extension has been read.
Defines version macros and version-related utility functions for Clang.
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
SimpleASTReaderListener(Preprocessor &PP)
ASTReaderListenter implementation to set SuggestedPredefines of ASTReader which is required to use a ...
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Information about a module that has been loaded by the ASTReader.
virtual ~ASTReaderListener()
uint32_t IdentifierID
An ID number that refers to an identifier in an AST file.
An iterator that walks over all of the known identifiers in the lookup table.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::const_iterator > ModuleConstIterator
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
The result type of a method or function.
DiagnosticsEngine & getDiags() const
SmallVector< uint64_t, 16 > PreloadedDeclIDs
The AST file was missing.
An abstract interface that should be implemented by external AST sources that also provide informatio...
In-memory cache for modules.
void addInMemoryBuffer(StringRef FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add an in-memory buffer the list of known buffers.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
static void SkipPath(const RecordData &Record, unsigned &Idx)
Defines the clang::OpenCLOptions class.
The control block was read successfully.
void addListener(std::unique_ptr< ASTReaderListener > L)
Add an AST callback listener.
Encodes a location in the source.
unsigned getTotalNumMacros() const
Returns the number of macros found in the chain.
Represents a C++ temporary.
IdentifierInfo * readIdentifier(ModuleFile &M, const RecordData &Record, unsigned &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.
Cached information about one file (either on disk or in the virtual file system). ...
bool isProcessingUpdateRecords()
ASTDeserializationListener * getDeserializationListener()
Get the AST deserialization listener.
An abstract class that should be subclassed by any external source of preprocessing record entries...
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
void addInMemoryBuffer(StringRef &FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add in-memory (virtual file) buffer.
PCHValidator(Preprocessor &PP, ASTReader &Reader)
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
uint32_t TypeID
An ID number that refers to a type in an AST file.
void setListener(std::unique_ptr< ASTReaderListener > Listener)
Set the AST callbacks listener.
External source of source location entries.
serialization::SubmoduleID ID
virtual void visitImport(StringRef ModuleName, StringRef Filename)
If needsImportVisitation returns true, this is called for each AST file imported by this AST file...
A global index for a set of module files, providing information about the identifiers within those mo...
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
The AST file was writtten with a different language/target configuration.
ChainedASTReaderListener(std::unique_ptr< ASTReaderListener > First, std::unique_ptr< ASTReaderListener > Second)
Takes ownership of First and Second.
unsigned getTotalNumTypes() const
Returns the number of types found in the chain.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Dataflow Directional Tag Classes.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
SourceLocation TranslateSourceLocation(ModuleFile &ModuleFile, SourceLocation Loc) const
Translate a source location from another module file's source location space into ours...
Reads an AST files chain containing the contents of a translation unit.
ListenerScope(ASTReader &Reader, std::unique_ptr< ASTReaderListener > L)
ModuleFile & getPrimaryModule()
Returns the primary module associated with the manager, that is, the first module loaded...
ModuleManager::ModuleIterator ModuleIterator
bool hasGlobalIndex() const
Determine whether this AST reader has a global index.
LoadFailureCapabilities
Flags that indicate what kind of AST loading failures the client of the AST reader can directly handl...
The name of a declaration.
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
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.
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Encapsulates the data about a macro definition (e.g.
Abstract interface for callback invocations by the ASTReader.
Represents a C++ base or member initializer.
void forEachImportedKeyDecl(const Decl *D, Fn Visit)
Run a callback on each imported key declaration of D.
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
Represents a base class of a C++ class.
Keeps track of options that affect how file operations are performed.
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain)
Receives the header search options.
Defines the clang::SourceLocation class and associated facilities.
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
unsigned getTotalNumSLocs() const
Returns the number of source locations found in the chain.
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)
unsigned getTotalNumIdentifiers() const
Returns the number of identifiers found in the chain.
value_type operator*() const
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.
Kind
Lists the kind of concrete classes of Decl.
The AST file was written by a different version of Clang.
std::unique_ptr< ASTReaderListener > takeSecond()
const std::string & getSuggestedPredefines()
Returns the suggested contents of the predefines buffer, which contains a (typically-empty) subset of...
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::iterator > ModuleIterator
std::unique_ptr< ASTReaderListener > takeFirst()
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.
virtual bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain)
Receives the diagnostic options.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.