13 #ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H 14 #define LLVM_CLANG_SERIALIZATION_ASTREADER_H 42 #include "llvm/ADT/APFloat.h" 43 #include "llvm/ADT/APInt.h" 44 #include "llvm/ADT/APSInt.h" 45 #include "llvm/ADT/ArrayRef.h" 46 #include "llvm/ADT/DenseMap.h" 47 #include "llvm/ADT/DenseSet.h" 48 #include "llvm/ADT/IntrusiveRefCntPtr.h" 49 #include "llvm/ADT/MapVector.h" 50 #include "llvm/ADT/Optional.h" 51 #include "llvm/ADT/STLExtras.h" 52 #include "llvm/ADT/SetVector.h" 53 #include "llvm/ADT/SmallPtrSet.h" 54 #include "llvm/ADT/SmallVector.h" 55 #include "llvm/ADT/StringMap.h" 56 #include "llvm/ADT/StringRef.h" 57 #include "llvm/ADT/iterator.h" 58 #include "llvm/ADT/iterator_range.h" 59 #include "llvm/Bitstream/BitstreamReader.h" 60 #include "llvm/Support/Casting.h" 61 #include "llvm/Support/Endian.h" 62 #include "llvm/Support/MemoryBuffer.h" 63 #include "llvm/Support/Timer.h" 64 #include "llvm/Support/VersionTuple.h" 80 class ASTDeserializationListener;
82 class ASTRecordReader;
92 class FileSystemOptions;
94 class GlobalModuleIndex;
95 struct HeaderFileInfo;
96 class HeaderSearchOptions;
98 class LazyASTUnresolvedSet;
100 class InMemoryModuleCache;
103 class ObjCCategoryDecl;
104 class ObjCInterfaceDecl;
105 class PCHContainerReader;
107 class PreprocessorOptions;
108 struct QualifierInfo;
114 class TemplateParameterList;
115 class TypedefNameDecl;
116 class TypeSourceInfo;
146 bool AllowCompatibleDifferences) {
155 bool AllowCompatibleDifferences) {
183 StringRef SpecificModuleCachePath,
198 std::string &SuggestedPredefines) {
225 bool isOverridden,
bool isExplicitModule) {
244 std::unique_ptr<ASTReaderListener>
First;
245 std::unique_ptr<ASTReaderListener> Second;
250 std::unique_ptr<ASTReaderListener> Second)
251 : First(
std::move(First)), Second(
std::move(Second)) {}
253 std::unique_ptr<ASTReaderListener>
takeFirst() {
return std::move(First); }
254 std::unique_ptr<ASTReaderListener>
takeSecond() {
return std::move(Second); }
260 bool AllowCompatibleDifferences)
override;
262 bool AllowCompatibleDifferences)
override;
264 bool Complain)
override;
266 bool Complain)
override;
269 StringRef SpecificModuleCachePath,
270 bool Complain)
override;
273 std::string &SuggestedPredefines)
override;
281 bool isOverridden,
bool isExplicitModule)
override;
294 : PP(PP), Reader(Reader) {}
297 bool AllowCompatibleDifferences)
override;
299 bool AllowCompatibleDifferences)
override;
301 bool Complain)
override;
303 std::string &SuggestedPredefines)
override;
305 StringRef SpecificModuleCachePath,
306 bool Complain)
override;
310 void Error(
const char *Msg);
324 std::string &SuggestedPredefines)
override;
327 namespace serialization {
329 class ReadMethodPoolVisitor;
415 std::unique_ptr<ASTReaderListener> Listener;
420 bool OwnsDeserializationListener =
false;
429 Sema *SemaObj =
nullptr;
449 llvm::StringMap<std::shared_ptr<ModuleFileExtension>> ModuleFileExtensions;
452 std::unique_ptr<llvm::Timer> ReadTimer;
459 std::unique_ptr<GlobalModuleIndex> GlobalIndex;
479 std::vector<QualType> TypesLoaded;
493 std::vector<Decl *> DeclsLoaded;
502 using FileOffset = std::pair<ModuleFile *, uint64_t>;
504 using DeclUpdateOffsetsMap =
505 llvm::DenseMap<serialization::DeclID, FileOffsetsTy>;
509 DeclUpdateOffsetsMap DeclUpdateOffsets;
511 struct PendingUpdateRecord {
520 : D(D),
ID(ID), JustLoaded(JustLoaded) {}
527 enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded };
531 llvm::DenseMap<void *, PendingFakeDefinitionKind> PendingFakeDefinitionData;
537 llvm::SmallMapVector<Decl *, FunctionDecl *, 4> PendingExceptionSpecUpdates;
542 llvm::SmallMapVector<FunctionDecl *, QualType, 4> PendingDeducedTypeUpdates;
546 llvm::DenseMap<std::pair<DeclContext *, IdentifierInfo *>,
NamedDecl *>
547 ImportedTypedefNamesForLinkage;
551 llvm::DenseMap<Decl*, llvm::SmallVector<NamedDecl*, 2>>
552 AnonymousDeclarationsForMerging;
554 struct FileDeclsInfo {
558 FileDeclsInfo() =
default;
560 : Mod(Mod), Decls(Decls) {}
564 llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs;
571 llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
575 std::vector<std::pair<ModuleFile*, LexicalContents>> TULexicalDecls;
585 struct PendingVisibleUpdate {
587 const unsigned char *Data;
593 llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates>
594 PendingVisibleUpdates;
598 llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
600 using PendingBodiesMap =
601 llvm::MapVector<
Decl *, uint64_t,
602 llvm::SmallDenseMap<Decl *, unsigned, 4>,
606 PendingBodiesMap PendingBodies;
610 llvm::SetVector<NamedDecl *> PendingMergedDefinitionsToDeduplicate;
613 bool ReadLexicalDeclContextStorage(
ModuleFile &M,
614 llvm::BitstreamCursor &
Cursor,
615 uint64_t
Offset, DeclContext *DC);
618 bool ReadVisibleDeclContextStorage(
ModuleFile &M,
619 llvm::BitstreamCursor &Cursor,
628 std::vector<IdentifierInfo *> IdentifiersLoaded;
644 std::vector<MacroInfo *> MacrosLoaded;
646 using LoadedMacroInfo =
647 std::pair<IdentifierInfo *, serialization::SubmoduleID>;
678 using HiddenNamesMapType = llvm::DenseMap<Module *, HiddenNames>;
682 HiddenNamesMapType HiddenNamesMap;
685 struct UnresolvedModuleRef {
693 enum { Import, Export, Conflict }
Kind;
699 unsigned IsWildcard : 1;
725 llvm::DenseMap<Selector, unsigned> SelectorGeneration;
729 llvm::DenseMap<Selector, bool> SelectorOutOfDate;
731 struct PendingMacroInfo {
733 uint64_t MacroDirectivesOffset;
735 PendingMacroInfo(
ModuleFile *M, uint64_t MacroDirectivesOffset)
736 : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
739 using PendingMacroIDsMap =
740 llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2>>;
744 PendingMacroIDsMap PendingMacroIDs;
835 unsigned ForceCUDAHostDeviceDepth = 0;
860 int PragmaMSStructState = -1;
863 int PragmaMSPointersToMembersState = -1;
869 struct PragmaPackStackEntry {
882 llvm::DenseMap<const Type *, std::set<std::string>> OpenCLTypeExtMap;
885 llvm::DenseMap<const Decl *, std::set<std::string>> OpenCLDeclExtMap;
906 : ID(ID), ImportLoc(ImportLoc) {}
917 std::string isysroot;
921 bool DisableValidation;
924 bool AllowASTWithCompilerErrors;
928 bool AllowConfigurationMismatch;
931 bool ValidateSystemInputs;
937 bool TriedLoadingGlobalIndex =
false;
940 bool ProcessingUpdateRecords =
false;
942 using SwitchCaseMapTy = llvm::DenseMap<unsigned, SwitchCase *>;
948 SwitchCaseMapTy SwitchCaseStmts;
950 SwitchCaseMapTy *CurrSwitchCaseStmts;
954 unsigned NumSLocEntriesRead = 0;
957 unsigned TotalNumSLocEntries = 0;
961 unsigned NumStatementsRead = 0;
965 unsigned TotalNumStatements = 0;
968 unsigned NumMacrosRead = 0;
971 unsigned TotalNumMacros = 0;
974 unsigned NumIdentifierLookups = 0;
977 unsigned NumIdentifierLookupHits = 0;
980 unsigned NumSelectorsRead = 0;
983 unsigned NumMethodPoolEntriesRead = 0;
987 unsigned NumMethodPoolLookups = 0;
991 unsigned NumMethodPoolHits = 0;
995 unsigned NumMethodPoolTableLookups = 0;
999 unsigned NumMethodPoolTableHits = 0;
1002 unsigned TotalNumMethodPoolEntries = 0;
1005 unsigned NumLexicalDeclContextsRead = 0, TotalLexicalDeclContexts = 0;
1008 unsigned NumVisibleDeclContextsRead = 0, TotalVisibleDeclContexts = 0;
1011 uint64_t TotalModulesSizeInBits = 0;
1014 unsigned NumCurrentElementsDeserializing = 0;
1020 bool PassingDeclsToConsumer =
false;
1027 llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4>>
1028 PendingIdentifierInfos;
1032 llvm::SmallMapVector<IdentifierInfo *, SmallVector<NamedDecl*, 2>, 16>
1033 PendingFakeLookupResults;
1037 llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration;
1039 class InterestingDecl {
1041 bool DeclHasPendingBody;
1044 InterestingDecl(Decl *D,
bool HasBody)
1045 : D(D), DeclHasPendingBody(HasBody) {}
1047 Decl *getDecl() {
return D; }
1050 bool hasPendingBody() {
return DeclHasPendingBody; }
1059 std::deque<InterestingDecl> PotentiallyInterestingDecls;
1065 PendingFunctionTypes;
1070 SmallVector<std::pair<Decl *, uint64_t>, 16> PendingDeclChains;
1078 struct PendingDeclContextInfo {
1089 std::deque<PendingDeclContextInfo> PendingDeclContextInfos;
1099 using DataPointers =
1100 std::pair<CXXRecordDecl *, struct CXXRecordDecl::DefinitionData *>;
1103 llvm::SmallDenseMap<CXXRecordDecl *, llvm::SmallVector<DataPointers, 2>, 2>
1104 PendingOdrMergeFailures;
1107 llvm::SmallDenseMap<FunctionDecl *, llvm::SmallVector<FunctionDecl *, 2>, 2>
1108 PendingFunctionOdrMergeFailures;
1111 llvm::SmallDenseMap<EnumDecl *, llvm::SmallVector<EnumDecl *, 2>, 2>
1112 PendingEnumOdrMergeFailures;
1115 llvm::SmallPtrSet<DeclContext*, 2> DiagnosedOdrMergeFailures;
1119 llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized;
1127 llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2>>;
1134 KeyDeclsMap KeyDecls;
1139 llvm::DenseMap<DeclContext *, DeclContext *> MergedDeclContexts;
1143 llvm::DenseMap<EnumDecl *, EnumDecl *> EnumDefinitions;
1150 Read_None, Read_Decl, Read_Type, Read_Stmt
1154 ReadingKind ReadingKind = Read_None;
1157 class ReadingKindTracker {
1159 enum ReadingKind PrevKind;
1162 ReadingKindTracker(
enum ReadingKind newKind,
ASTReader &reader)
1163 : Reader(reader), PrevKind(Reader.ReadingKind) {
1164 Reader.ReadingKind = newKind;
1167 ReadingKindTracker(
const ReadingKindTracker &) =
delete;
1168 ReadingKindTracker &operator=(
const ReadingKindTracker &) =
delete;
1169 ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
1173 class ProcessingUpdatesRAIIObj {
1178 ProcessingUpdatesRAIIObj(
ASTReader &reader)
1179 : Reader(reader), PrevState(Reader.ProcessingUpdateRecords) {
1180 Reader.ProcessingUpdateRecords =
true;
1183 ProcessingUpdatesRAIIObj(
const ProcessingUpdatesRAIIObj &) =
delete;
1184 ProcessingUpdatesRAIIObj &
1185 operator=(
const ProcessingUpdatesRAIIObj &) =
delete;
1186 ~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; }
1197 std::string SuggestedPredefines;
1199 llvm::DenseMap<const Decl *, bool> DefinitionSource;
1204 struct InputFileInfo {
1210 bool TopLevelModuleMap;
1214 InputFileInfo readInputFileInfo(
ModuleFile &F,
unsigned ID);
1219 bool Complain =
true);
1223 static void ResolveImportedPath(std::string &Filename, StringRef Prefix);
1233 auto I = KeyDecls.find(D);
1234 if (I == KeyDecls.end() || I->second.empty())
1236 return GetExistingDecl(I->second[0]);
1239 return getKeyDeclaration(const_cast<Decl*>(D));
1243 template <
typename Fn>
1249 auto It = KeyDecls.find(const_cast<Decl*>(D));
1250 if (It != KeyDecls.end())
1251 for (
auto ID : It->second)
1252 Visit(GetExistingDecl(ID));
1257 getLoadedLookupTables(DeclContext *Primary)
const;
1260 struct ImportedModule {
1268 : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) {}
1274 off_t ExpectedSize, time_t ExpectedModTime,
1276 unsigned ClientLoadCapabilities);
1280 unsigned ClientLoadCapabilities);
1282 llvm::BitstreamCursor &Stream,
unsigned ClientLoadCapabilities,
1284 std::string &SuggestedPredefines);
1291 unsigned ClientLoadCapabilities);
1294 readUnhashedControlBlockImpl(
ModuleFile *F, llvm::StringRef StreamData,
1295 unsigned ClientLoadCapabilities,
1296 bool AllowCompatibleConfigurationMismatch,
1298 bool ValidateDiagnosticOptions);
1302 void ReadModuleOffsetMap(
ModuleFile &F)
const;
1305 llvm::BitstreamCursor &SLocCursorForID(
int ID);
1309 unsigned ClientLoadCapabilities);
1311 unsigned ClientLoadCapabilities);
1312 static bool ParseLanguageOptions(
const RecordData &Record,
bool Complain,
1314 bool AllowCompatibleDifferences);
1315 static bool ParseTargetOptions(
const RecordData &Record,
bool Complain,
1317 bool AllowCompatibleDifferences);
1318 static bool ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
1320 static bool ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
1322 static bool ParseHeaderSearchOptions(
const RecordData &Record,
bool Complain,
1324 static bool ParsePreprocessorOptions(
const RecordData &Record,
bool Complain,
1326 std::string &SuggestedPredefines);
1328 struct RecordLocation {
1335 QualType readTypeRecord(
unsigned Index);
1340 RecordLocation TypeCursorForIndex(
unsigned Index);
1341 void LoadedDecl(
unsigned Index, Decl *D);
1343 void markIncompleteDeclChain(Decl *Canon);
1348 Decl *getMostRecentExistingDecl(Decl *D);
1352 void loadDeclUpdateRecords(PendingUpdateRecord &Record);
1353 void loadPendingDeclChain(Decl *D, uint64_t LocalOffset);
1355 unsigned PreviousGeneration = 0);
1357 RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
1358 uint64_t getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset);
1363 findPreprocessedEntity(
SourceLocation Loc,
bool EndsAfter)
const;
1372 findNextPreprocessedEntity(
1373 GlobalSLocOffsetMapType::const_iterator SLocMapI)
const;
1377 std::pair<ModuleFile *, unsigned>
1378 getModulePreprocessedEntity(
unsigned GlobalIndex);
1382 llvm::iterator_range<PreprocessingRecord::iterator>
1383 getModulePreprocessedEntities(ModuleFile &Mod)
const;
1387 :
public llvm::iterator_adaptor_base<
1388 ModuleDeclIterator, const serialization::LocalDeclID *,
1389 std::random_access_iterator_tag, const Decl *, ptrdiff_t,
1390 const Decl *, const Decl *> {
1392 ModuleFile *Mod =
nullptr;
1399 : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
1408 assert(Reader == RHS.Reader && Mod == RHS.Mod);
1413 llvm::iterator_range<ModuleDeclIterator>
1414 getModuleFileLevelDecls(ModuleFile &Mod);
1417 void PassInterestingDeclsToConsumer();
1418 void PassInterestingDeclToConsumer(Decl *D);
1420 void finishPendingActions();
1421 void diagnoseOdrViolations();
1425 void addPendingDeclContextInfo(Decl *D,
1429 PendingDeclContextInfo Info = { D, SemaDC, LexicalDC };
1430 PendingDeclContextInfos.push_back(Info);
1437 void Error(StringRef Msg)
const;
1438 void Error(
unsigned DiagID, StringRef Arg1 = StringRef(),
1439 StringRef Arg2 = StringRef())
const;
1484 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
1485 StringRef isysroot =
"",
bool DisableValidation =
false,
1486 bool AllowASTWithCompilerErrors =
false,
1487 bool AllowConfigurationMismatch =
false,
1488 bool ValidateSystemInputs =
false,
bool UseGlobalIndex =
true,
1489 std::unique_ptr<llvm::Timer> ReadTimer = {});
1513 ARR_OutOfDate = 0x2,
1517 ARR_VersionMismatch = 0x4,
1522 ARR_ConfigurationMismatch = 0x8
1543 unsigned ClientLoadCapabilities,
1555 void makeModuleVisible(
Module *Mod,
1568 return std::move(Listener);
1573 this->Listener = std::move(Listener);
1581 L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
1582 std::move(Listener));
1583 Listener = std::move(L);
1589 bool Chained =
false;
1597 L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
1606 Reader.
setListener(static_cast<ChainedASTReaderListener *>(New.get())
1613 bool TakeOwnership =
false);
1617 return DeserializationListener;
1632 bool loadGlobalIndex();
1636 bool isGlobalIndexUnavailable()
const;
1639 void InitializeContext();
1646 std::unique_ptr<llvm::MemoryBuffer> Buffer) {
1655 void finalizeForWriting();
1672 getOriginalSourceFile(
const std::string &ASTFileName,
FileManager &FileMgr,
1680 readASTFileControlBlock(StringRef Filename,
FileManager &FileMgr,
1682 bool FindModuleFileExtensions,
1684 bool ValidateDiagnosticOptions);
1688 static bool isAcceptableASTFile(StringRef Filename,
FileManager &FileMgr,
1693 StringRef ExistingModuleCachePath);
1708 std::pair<unsigned, unsigned>
1709 findPreprocessedEntitiesInRange(
SourceRange Range)
override;
1717 SourceRange ReadSkippedRange(
unsigned Index)
override;
1726 return TotalNumSLocEntries;
1731 return static_cast<unsigned>(IdentifiersLoaded.size());
1736 return static_cast<unsigned>(MacrosLoaded.size());
1741 return static_cast<unsigned>(TypesLoaded.size());
1746 return static_cast<unsigned>(DeclsLoaded.size());
1751 return static_cast<unsigned>(SubmodulesLoaded.size());
1756 return static_cast<unsigned>(SelectorsLoaded.size());
1763 for (
const auto &M : ModuleMgr)
1776 ReadTemplateArgumentLoc(ModuleFile &F,
1780 ReadASTTemplateArgumentListInfo(ModuleFile &F,
1788 void ReadTypeLoc(ModuleFile &F,
const RecordData &Record,
unsigned &Idx,
1796 QualType getLocalType(ModuleFile &F,
unsigned LocalID);
1804 if (Idx >= Record.size())
1807 return getLocalType(F, Record[Idx++]);
1820 ModuleFile *getOwningModuleFile(
const Decl *D);
1824 std::string getOwningModuleNameForDiagnostic(
const Decl *D);
1832 Decl *GetExternalDecl(uint32_t ID)
override;
1840 return GetDecl(getGlobalDeclID(F, LocalID));
1846 template<
typename T>
1848 return cast_or_null<T>(GetLocalDecl(F, LocalID));
1857 mapGlobalIDToModuleFileGlobalID(ModuleFile &M,
1870 return GetDecl(ReadDeclID(F, R, I));
1878 template<
typename T>
1880 return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I)));
1886 void CompleteRedeclChain(
const Decl *D)
override;
1895 Stmt *GetExternalDeclStmt(uint64_t Offset)
override;
1900 static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor,
unsigned BlockID);
1905 bool FindExternalVisibleDeclsByName(
const DeclContext *DC,
1922 FindExternalLexicalDecls(
const DeclContext *DC,
1923 llvm::function_ref<
bool(
Decl::Kind)> IsKindWeWant,
1929 void FindFileRegionDecls(
FileID File,
unsigned Offset,
unsigned Length,
1935 void StartedDeserializing()
override;
1939 void FinishedDeserializing()
override;
1946 void StartTranslationUnit(
ASTConsumer *Consumer)
override;
1949 void PrintStats()
override;
1961 void InitializeSema(
Sema &S)
override;
1980 void ReadMethodPool(
Selector Sel)
override;
1984 void updateOutOfDateSelector(
Selector Sel)
override;
1988 void ReadKnownNamespaces(
1991 void ReadUndefinedButUsed(
1992 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined)
override;
1994 void ReadMismatchingDeleteExpressions(llvm::MapVector<
1998 void ReadTentativeDefinitions(
2001 void ReadUnusedFileScopedDecls(
2004 void ReadDelegatingConstructors(
2009 void ReadUnusedLocalTypedefNameCandidates(
2012 void ReadReferencedSelectors(
2015 void ReadWeakUndeclaredIdentifiers(
2020 void ReadPendingInstantiations(
2024 void ReadLateParsedTemplates(
2025 llvm::MapVector<
const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
2046 return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++]));
2053 return DecodeIdentifierInfo(ID);
2056 IdentifierInfo *getLocalIdentifier(ModuleFile &M,
unsigned LocalID);
2061 void resolvePendingMacro(
IdentifierInfo *II,
const PendingMacroInfo &PMInfo);
2071 bool ReadSLocEntry(
int ID)
override;
2075 std::pair<SourceLocation, StringRef> getModuleImportLoc(
int ID)
override;
2080 getGlobalSubmoduleID(ModuleFile &M,
unsigned LocalID);
2089 Module *getModule(
unsigned ID)
override;
2091 bool DeclIsFromPCHWithObjectFile(
const Decl *D)
override;
2095 ModuleFile *getLocalModuleFile(ModuleFile &M,
unsigned ID);
2098 unsigned getModuleFileID(ModuleFile *M);
2103 ExtKind hasExternalDefinitions(
const Decl *D)
override;
2107 Selector getLocalSelector(ModuleFile &M,
unsigned LocalID);
2112 uint32_t GetNumExternalSelectors()
override;
2115 return getLocalSelector(M, Record[Idx++]);
2121 unsigned LocalID)
const;
2126 void ReadDeclarationNameLoc(ModuleFile &F,
2150 bool Canonicalize =
false);
2160 unsigned &Idx,
bool Canonicalize =
false);
2172 ReadCXXCtorInitializers(ModuleFile &F,
const RecordData &Record,
2187 return TranslateSourceLocation(ModuleFile, Loc);
2195 ReadModuleOffsetMap(ModuleFile);
2198 "Cannot find offset to remap.");
2199 int Remap = ModuleFile.
SLocRemap.
find(Loc.getOffset())->second;
2207 return ReadSourceLocation(ModuleFile, Record[Idx++]);
2215 llvm::APInt ReadAPInt(
const RecordData &Record,
unsigned &Idx);
2218 llvm::APSInt ReadAPSInt(
const RecordData &Record,
unsigned &Idx);
2221 llvm::APFloat ReadAPFloat(
const RecordData &Record,
2222 const llvm::fltSemantics &Sem,
unsigned &Idx);
2228 static std::string ReadString(
const RecordData &Record,
unsigned &Idx);
2232 Idx += Record[Idx] + 1;
2236 std::string ReadPath(ModuleFile &F,
const RecordData &Record,
unsigned &Idx);
2239 std::string ReadPath(StringRef BaseDirectory,
const RecordData &Record,
2244 SkipString(Record, Idx);
2248 static VersionTuple ReadVersionTuple(
const RecordData &Record,
unsigned &Idx);
2254 Attr *ReadAttr(ModuleFile &M,
const RecordData &Record,
unsigned &Idx);
2260 Stmt *ReadStmt(ModuleFile &F);
2263 Expr *ReadExpr(ModuleFile &F);
2267 assert(ReadingKind == Read_Stmt &&
2268 "Should be called only during statement reading!");
2271 assert(!StmtStack.empty() &&
"Read too many sub-statements!");
2272 return StmtStack.pop_back_val();
2276 Expr *ReadSubExpr();
2282 MacroInfo *ReadMacroRecord(ModuleFile &F, uint64_t Offset);
2287 getGlobalPreprocessedEntityID(ModuleFile &M,
unsigned LocalID)
const;
2296 uint64_t MacroDirectivesOffset);
2299 void ReadDefinedMacros()
override;
2308 void completeVisibleDeclsMap(
const DeclContext *DC)
override;
2312 assert(ContextObj &&
"requested AST context when not loading AST");
2336 void RecordSwitchCaseID(
SwitchCase *SC,
unsigned ID);
2339 SwitchCase *getSwitchCaseWithID(
unsigned ID);
2341 void ClearSwitchCaseIDs();
2348 void ReadComments()
override;
2352 bool IncludeSystem,
bool Complain,
2396 size_t size()
const {
return Record.size(); }
2402 const uint64_t &
back()
const {
return Record.back(); }
2406 const uint64_t &
readInt() {
return Record[Idx++]; }
2427 return Reader->ReadLexicalDeclContextStorage(*F, F->
DeclsCursor, Offset,
2434 return Reader->ReadVisibleDeclContextStorage(*F, F->
DeclsCursor, Offset,
2439 uint64_t Kind = readInt();
2440 bool HasExpr = Kind & 0x1;
2443 static_cast<ExplicitSpecKind>(Kind));
2448 return Reader->readExceptionSpec(*F, ExceptionStorage, ESI, Record, Idx);
2453 return Reader->getGlobalBitOffset(*F, LocalOffset);
2471 template<
typename T>
2473 return cast_or_null<T>(Reader->
GetLocalDecl(*F, LocalID));
2511 return Reader->
readType(*F, Record, Idx);
2524 return Reader->
ReadDecl(*F, Record, Idx);
2532 template<
typename T>
2534 return Reader->
ReadDeclAs<T>(*F, Record, Idx);
2586 bool Canonicalize =
false) {
2644 return Reader->
ReadPath(*F, Record, Idx);
2654 return Reader->
ReadAttr(*F, Record, Idx);
2664 return Reader->
ReadToken(*F, Record, Idx);
2681 : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) {}
2685 llvm::report_fatal_error(
2686 "Cursor should always be able to go back, failed: " +
2691 llvm::BitstreamCursor &
Cursor;
2695 inline void PCHValidator::Error(
const char *Msg) {
2705 : Record(Record), Context(Record.getContext()) {}
2707 #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C); 2708 #include "clang/Basic/OpenMPKinds.def" 2711 void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *
C);
2716 #endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx)
Read an integral value.
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.
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.
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.
ASTRecordReader(ASTReader &Reader, ModuleFile &F)
Construct an ASTRecordReader that uses the default encoding scheme.
Stmt - This represents one statement.
ModuleManager::ModuleReverseIterator ModuleReverseIterator
C Language Family Type Representation.
GlobalModuleIndex * getGlobalIndex()
Return global module index.
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, uint32_t Raw) const
Read a source location from raw form.
Defines the clang::Module class, which describes a module in the source code.
Decl - This represents one declaration (or definition), e.g.
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
llvm::APFloat readAPFloat(const llvm::fltSemantics &Sem)
Read a floating-point value, advancing Idx.
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 ...
A container of type source information.
Store information needed for an explicit specifier.
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
void readQualifierInfo(QualifierInfo &Info)
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
void readTypeLoc(TypeLoc TL)
Reads the location information for a type.
CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a C++ base specifier.
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.
void recordSwitchCaseID(SwitchCase *SC, unsigned ID)
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.
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.
An UnresolvedSet-like class that might not have been loaded from the external AST source yet...
Base wrapper for a particular "section" of type source info.
serialization::TypeID getGlobalTypeID(unsigned LocalID) const
Map a local type ID within a given AST file to a global type ID.
StringRef ModuleOffsetMap
The module offset map data for this file.
NestedNameSpecifierLoc readNestedNameSpecifierLoc()
One of these records is kept for each identifier that is lexed.
T * readDeclAs()
Reads a declaration from the given position in the record, advancing Idx.
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 ...
A C++ nested-name-specifier augmented with source location information.
Utility class for loading a ASTContext from an AST file.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
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.
Expr * readExpr()
Reads an expression.
value_type operator->() const
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.
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)
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.
Describes a module or submodule.
size_t size() const
The length of this record.
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc)
FileManager & getFileManager() const
TypeSourceInfo * GetTypeSourceInfo(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declarator info from the given record.
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
ModuleManager & getModuleManager()
Retrieve the module manager.
void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, const RecordData &Record, unsigned &Idx)
APValue ReadAPValue(const RecordData &Record, unsigned &Idx)
Read an APValue.
serialization::DeclID getGlobalDeclID(ModuleFile &F, serialization::LocalDeclID LocalID) const
Map from a local declaration ID within a given module to a global declaration ID. ...
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.
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, const RecordDataImpl &Record, unsigned &Idx)
Read a source location.
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Concrete class used by the front-end to report problems and issues.
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID)
Retrieve the global submodule ID given a module and its local ID number.
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
TemplateArgument ReadTemplateArgument(ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument.
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
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...
ContinuousRangeMap< uint32_t, int, 2 > SLocRemap
Remapping table for source locations in this module.
const ASTTemplateArgumentListInfo * readASTTemplateArgumentListInfo()
Represents an ObjC class declaration.
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.
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...
static std::string ReadString(const RecordData &Record, unsigned &Idx)
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
IdentifierInfo * GetIdentifierInfo(ModuleFile &M, const RecordData &Record, unsigned &Idx)
void ForgetSema() override
Inform the semantic consumer that Sema is no longer available.
Sema - This implements semantic analysis and AST building for C.
A little helper class used to produce diagnostics.
TemplateParameterList * readTemplateParameterList()
Read a template parameter list, advancing Idx.
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.
void readTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, bool Canonicalize=false)
Read a template argument array, advancing Idx.
Decl * ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
std::string readPath()
Read a path, advancing Idx.
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...
serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const
Map a local type ID within a given AST file into a global type ID.
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.
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
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.
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.
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
ArgKind
The kind of template argument we're storing.
SimpleASTReaderListener(Preprocessor &PP)
ASTReaderListenter implementation to set SuggestedPredefines of ASTReader which is required to use a ...
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.
Information about a module that has been loaded by the ASTReader.
virtual ~ASTReaderListener()
OMPClauseReader(ASTRecordReader &Record)
const uint64_t & back() const
The last element in this record.
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.
IdentifierInfo * getIdentifierInfo()
SavedStreamPosition(llvm::BitstreamCursor &Cursor)
The result type of a method or function.
std::string readString()
Read a string, advancing Idx.
DiagnosticsEngine & getDiags() const
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.
This file defines OpenMP AST classes for clauses.
const uint64_t & operator[](size_t N)
An arbitrary index in this record.
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
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)
Attr * ReadAttr(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Reads one attribute from the current stream position.
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.
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
The control block was read successfully.
void addListener(std::unique_ptr< ASTReaderListener > L)
Add an AST callback listener.
CXXTemporary * readCXXTemporary()
Encodes a location in the source.
unsigned getTotalNumMacros() const
Returns the number of macros found in the chain.
Stmt * readSubStmt()
Reads a sub-statement operand during statement reading.
Represents a C++ temporary.
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.
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 isModule() const
Is this a module file for a module (rather than a PCH or similar).
bool isProcessingUpdateRecords()
void readDeclarationNameInfo(DeclarationNameInfo &NameInfo)
ASTDeserializationListener * getDeserializationListener()
Get the AST deserialization listener.
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...
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.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
void 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)
unsigned getIdx() const
The current position in this record.
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
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.
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.
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.
DeclarationName ReadDeclarationName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a declaration name.
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
The AST file was writtten with a different language/target configuration.
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.
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.
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...
Represents a template argument.
const ASTTemplateArgumentListInfo * ReadASTTemplateArgumentListInfo(ModuleFile &F, const RecordData &Record, unsigned &Index)
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Dataflow Directional Tag Classes.
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.
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.
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)
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)
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)
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
VersionTuple readVersionTuple()
Read a version tuple, advancing Idx.
Encapsulates the data about a macro definition (e.g.
SmallVector< uint64_t, 64 > RecordData
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)
Represents a C++ base or member initializer.
uint64_t getGlobalBitOffset(uint32_t LocalOffset)
Get the global offset corresponding to a local offset.
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 forEachImportedKeyDecl(const Decl *D, Fn Visit)
Run a callback on each imported key declaration of D.
void ReadTypeLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx, TypeLoc TL)
Raad the type locations for the given TInfo.
Holds information about the various types of exception specification.
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Represents a base class of a C++ class.
Attr * readAttr()
Reads one attribute from the current stream position, advancing Idx.
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 C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
TemplateName readTemplateName()
Read a template name, advancing Idx.
SmallVectorImpl< uint64_t > RecordDataImpl
Defines the clang::SourceLocation class and associated facilities.
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.
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...
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
unsigned getTotalNumSLocs() const
Returns the number of source locations found in the chain.
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)
unsigned getTotalNumIdentifiers() const
Returns the number of identifiers found in the chain.
value_type operator*() const
ExplicitSpecifier readExplicitSpec()
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.
The AST file was written by a different version of Clang.
void ReadAttributes(ASTRecordReader &Record, AttrVec &Attrs)
Reads attributes from the current stream position.
NestedNameSpecifier * readNestedNameSpecifier()
Token readToken()
Reads a token out of a record, advancing Idx.
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.
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
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.
Attr - This represents one attribute.
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.
void readUnresolvedSet(LazyASTUnresolvedSet &Set)
Read a UnresolvedSet structure, advancing Idx.