14 #ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H
15 #define LLVM_CLANG_SERIALIZATION_ASTREADER_H
36 #include "llvm/ADT/APFloat.h"
37 #include "llvm/ADT/APInt.h"
38 #include "llvm/ADT/APSInt.h"
39 #include "llvm/ADT/MapVector.h"
40 #include "llvm/ADT/SmallPtrSet.h"
41 #include "llvm/ADT/SmallSet.h"
42 #include "llvm/ADT/SmallVector.h"
43 #include "llvm/ADT/StringMap.h"
44 #include "llvm/ADT/StringRef.h"
45 #include "llvm/ADT/TinyPtrVector.h"
46 #include "llvm/Bitcode/BitstreamReader.h"
47 #include "llvm/Support/DataTypes.h"
48 #include "llvm/Support/Timer.h"
65 class ASTIdentifierIterator;
70 class DefMacroDirective;
71 class DiagnosticOptions;
72 class NestedNameSpecifier;
73 class CXXBaseSpecifier;
74 class CXXConstructorDecl;
75 class CXXCtorInitializer;
76 class GlobalModuleIndex;
78 class MacroDefinition;
82 class OpaqueValueExpr;
84 class PreprocessorOptions;
87 class ASTDeserializationListener;
93 struct HeaderFileInfo;
96 class LazyASTUnresolvedSet;
124 bool AllowCompatibleDifferences) {
133 bool AllowCompatibleDifferences) {
161 StringRef SpecificModuleCachePath,
176 std::string &SuggestedPredefines) {
201 bool isOverridden,
bool isExplicitModule) {
219 std::unique_ptr<ASTReaderListener> First;
220 std::unique_ptr<ASTReaderListener> Second;
225 std::unique_ptr<ASTReaderListener> Second)
226 : First(std::move(First)), Second(std::move(Second)) {}
228 std::unique_ptr<ASTReaderListener>
takeFirst() {
return std::move(First); }
229 std::unique_ptr<ASTReaderListener>
takeSecond() {
return std::move(Second); }
235 bool AllowCompatibleDifferences)
override;
237 bool AllowCompatibleDifferences)
override;
239 bool Complain)
override;
241 bool Complain)
override;
244 StringRef SpecificModuleCachePath,
245 bool Complain)
override;
248 std::string &SuggestedPredefines)
override;
256 bool isOverridden,
bool isExplicitModule)
override;
269 : PP(PP), Reader(Reader) {}
272 bool AllowCompatibleDifferences)
override;
274 bool AllowCompatibleDifferences)
override;
276 bool Complain)
override;
278 std::string &SuggestedPredefines)
override;
280 StringRef SpecificModuleCachePath,
281 bool Complain)
override;
285 void Error(
const char *Msg);
288 namespace serialization {
290 class ReadMethodPoolVisitor;
367 std::unique_ptr<ASTReaderListener> Listener;
371 bool OwnsDeserializationListener;
400 llvm::StringMap<IntrusiveRefCntPtr<ModuleFileExtension>> ModuleFileExtensions;
403 std::unique_ptr<llvm::Timer> ReadTimer;
410 std::unique_ptr<GlobalModuleIndex> GlobalIndex;
429 std::vector<QualType> TypesLoaded;
443 std::vector<Decl *> DeclsLoaded;
452 typedef std::pair<ModuleFile *, uint64_t> FileOffset;
454 typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy>
455 DeclUpdateOffsetsMap;
459 DeclUpdateOffsetsMap DeclUpdateOffsets;
464 PendingUpdateRecords;
470 llvm::DenseMap<void *, PendingFakeDefinitionKind> PendingFakeDefinitionData;
476 llvm::SmallMapVector<Decl *, FunctionDecl *, 4> PendingExceptionSpecUpdates;
480 llvm::DenseMap<std::pair<DeclContext*, IdentifierInfo*>,
NamedDecl*>
481 ImportedTypedefNamesForLinkage;
485 llvm::DenseMap<DeclContext*, llvm::SmallVector<NamedDecl*, 2>>
486 AnonymousDeclarationsForMerging;
488 struct FileDeclsInfo {
492 FileDeclsInfo() : Mod(nullptr) {}
493 FileDeclsInfo(
ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls)
494 : Mod(Mod), Decls(Decls) {}
498 llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs;
502 typedef ArrayRef<llvm::support::unaligned_uint32_t> LexicalContents;
505 llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
509 std::vector<std::pair<ModuleFile*, LexicalContents>> TULexicalDecls;
512 llvm::DenseMap<
const DeclContext *,
513 serialization::reader::DeclContextLookupTable> Lookups;
519 struct PendingVisibleUpdate {
521 const unsigned char *Data;
523 typedef SmallVector<PendingVisibleUpdate, 1> DeclContextVisibleUpdates;
527 llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates>
528 PendingVisibleUpdates;
532 llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
534 typedef llvm::MapVector<
Decl *, uint64_t,
535 llvm::SmallDenseMap<Decl *, unsigned, 4>,
536 SmallVector<std::pair<Decl *, uint64_t>, 4> >
540 PendingBodiesMap PendingBodies;
544 llvm::SetVector<NamedDecl*> PendingMergedDefinitionsToDeduplicate;
547 bool ReadLexicalDeclContextStorage(
ModuleFile &M,
548 llvm::BitstreamCursor &
Cursor,
549 uint64_t
Offset, DeclContext *DC);
551 bool ReadVisibleDeclContextStorage(
ModuleFile &M,
552 llvm::BitstreamCursor &
Cursor,
561 std::vector<IdentifierInfo *> IdentifiersLoaded;
563 typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>
564 GlobalIdentifierMapType;
569 GlobalIdentifierMapType GlobalIdentifierMap;
577 std::vector<MacroInfo *> MacrosLoaded;
579 typedef std::pair<IdentifierInfo *, serialization::SubmoduleID>
587 typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>
593 GlobalMacroMapType GlobalMacroMap;
599 SmallVector<Module *, 2> SubmodulesLoaded;
601 typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>
602 GlobalSubmoduleMapType;
607 GlobalSubmoduleMapType GlobalSubmoduleMap;
610 typedef SmallVector<Decl*, 2> HiddenNames;
611 typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType;
615 HiddenNamesMapType HiddenNamesMap;
619 struct UnresolvedModuleRef {
627 enum { Import, Export, Conflict }
Kind;
633 unsigned IsWildcard : 1;
641 SmallVector<UnresolvedModuleRef, 2> UnresolvedModuleRefs;
648 SmallVector<Selector, 16> SelectorsLoaded;
650 typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>
651 GlobalSelectorMapType;
656 GlobalSelectorMapType GlobalSelectorMap;
660 llvm::DenseMap<Selector, unsigned> SelectorGeneration;
664 llvm::DenseMap<Selector, bool> SelectorOutOfDate;
666 struct PendingMacroInfo {
668 uint64_t MacroDirectivesOffset;
670 PendingMacroInfo(
ModuleFile *M, uint64_t MacroDirectivesOffset)
671 : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
674 typedef llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2> >
679 PendingMacroIDsMap PendingMacroIDs;
681 typedef ContinuousRangeMap<unsigned, ModuleFile *, 4>
682 GlobalPreprocessedEntityMapType;
687 GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap;
699 SmallVector<uint64_t, 16> EagerlyDeserializedDecls;
706 SmallVector<uint64_t, 16> TentativeDefinitions;
713 SmallVector<uint64_t, 64> VTableUses;
721 SmallVector<uint64_t, 64> PendingInstantiations;
731 SmallVector<uint64_t, 16> UnusedFileScopedDecls;
735 SmallVector<uint64_t, 4> DelegatingCtorDecls;
739 SmallVector<uint64_t, 64> ReferencedSelectorsData;
743 SmallVector<uint64_t, 64> WeakUndeclaredIdentifiers;
748 SmallVector<uint64_t, 4> ExtVectorDecls;
759 SmallVector<uint64_t, 16> UnusedLocalTypedefNameCandidates;
764 SmallVector<uint64_t, 4> SemaDeclRefs;
769 SmallVector<uint64_t, 16> SpecialTypes;
775 SmallVector<uint64_t, 2> CUDASpecialDeclRefs;
778 SmallVector<uint64_t, 1> FPPragmaOptions;
781 SourceLocation OptimizeOffPragmaLocation;
784 int PragmaMSStructState;
787 int PragmaMSPointersToMembersState;
788 SourceLocation PointersToMembersPragmaLocation;
791 SmallVector<uint64_t, 1> OpenCLExtensions;
794 SmallVector<uint64_t, 4> KnownNamespaces;
798 SmallVector<uint64_t, 8> UndefinedButUsed;
801 SmallVector<uint64_t, 8> DelayedDeleteExprs;
804 SmallVector<uint64_t, 1> LateParsedTemplates;
806 struct ImportedSubmodule {
808 SourceLocation ImportLoc;
811 : ID(ID), ImportLoc(ImportLoc) {}
816 SmallVector<ImportedSubmodule, 2> ImportedModules;
820 std::string CurrentDir;
824 std::string isysroot;
828 bool DisableValidation;
831 bool AllowASTWithCompilerErrors;
835 bool AllowConfigurationMismatch;
838 bool ValidateSystemInputs;
844 bool TriedLoadingGlobalIndex;
847 bool ProcessingUpdateRecords;
849 typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy;
854 SwitchCaseMapTy SwitchCaseStmts;
856 SwitchCaseMapTy *CurrSwitchCaseStmts;
860 unsigned NumSLocEntriesRead;
863 unsigned TotalNumSLocEntries;
867 unsigned NumStatementsRead;
871 unsigned TotalNumStatements;
874 unsigned NumMacrosRead;
877 unsigned TotalNumMacros;
880 unsigned NumIdentifierLookups;
883 unsigned NumIdentifierLookupHits;
886 unsigned NumSelectorsRead;
889 unsigned NumMethodPoolEntriesRead;
893 unsigned NumMethodPoolLookups;
897 unsigned NumMethodPoolHits;
901 unsigned NumMethodPoolTableLookups;
905 unsigned NumMethodPoolTableHits;
908 unsigned TotalNumMethodPoolEntries;
911 unsigned NumLexicalDeclContextsRead, TotalLexicalDeclContexts;
914 unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts;
917 uint64_t TotalModulesSizeInBits;
920 unsigned NumCurrentElementsDeserializing;
926 bool PassingDeclsToConsumer;
933 llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4> >
934 PendingIdentifierInfos;
938 llvm::SmallMapVector<IdentifierInfo *, SmallVector<NamedDecl*, 2>, 16>
939 PendingFakeLookupResults;
943 llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration;
951 std::deque<Decl *> InterestingDecls;
956 SmallVector<std::pair<Decl *, uint64_t>, 16> PendingDeclChains;
960 SmallVector<Decl *, 16> PendingIncompleteDeclChains;
964 struct PendingDeclContextInfo {
975 std::deque<PendingDeclContextInfo> PendingDeclContextInfos;
986 llvm::SmallDenseMap<CXXRecordDecl *, llvm::TinyPtrVector<CXXRecordDecl *>, 2>
987 PendingOdrMergeFailures;
990 llvm::SmallPtrSet<DeclContext*, 2> DiagnosedOdrMergeFailures;
994 llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized;
999 SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded;
1001 typedef llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2> >
1009 KeyDeclsMap KeyDecls;
1014 llvm::DenseMap<DeclContext *, DeclContext *> MergedDeclContexts;
1018 llvm::DenseMap<EnumDecl *, EnumDecl *> EnumDefinitions;
1021 SmallVector<Stmt *, 16> StmtStack;
1025 Read_None, Read_Decl, Read_Type, Read_Stmt
1029 ReadingKind ReadingKind;
1032 class ReadingKindTracker {
1034 enum ReadingKind PrevKind;
1036 ReadingKindTracker(
const ReadingKindTracker &) =
delete;
1037 void operator=(
const ReadingKindTracker &) =
delete;
1040 ReadingKindTracker(
enum ReadingKind newKind, ASTReader &reader)
1041 : Reader(reader), PrevKind(Reader.ReadingKind) {
1042 Reader.ReadingKind = newKind;
1045 ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
1049 class ProcessingUpdatesRAIIObj {
1053 ProcessingUpdatesRAIIObj(
const ProcessingUpdatesRAIIObj &) =
delete;
1054 void operator=(
const ProcessingUpdatesRAIIObj &) =
delete;
1057 ProcessingUpdatesRAIIObj(ASTReader &reader)
1058 : Reader(reader), PrevState(Reader.ProcessingUpdateRecords) {
1059 Reader.ProcessingUpdateRecords =
true;
1062 ~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; }
1073 std::string SuggestedPredefines;
1078 struct InputFileInfo {
1087 InputFileInfo readInputFileInfo(
ModuleFile &F,
unsigned ID);
1091 serialization::InputFile getInputFile(
ModuleFile &F,
unsigned ID,
1092 bool Complain =
true);
1102 D = D->getCanonicalDecl();
1103 if (D->isFromASTFile())
1106 auto I = KeyDecls.find(D);
1107 if (
I == KeyDecls.end() ||
I->second.empty())
1116 template <
typename Fn>
1118 D = D->getCanonicalDecl();
1119 if (D->isFromASTFile())
1122 auto It = KeyDecls.find(const_cast<Decl*>(D));
1123 if (It != KeyDecls.end())
1124 for (
auto ID : It->second)
1133 struct ImportedModule {
1141 : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) { }
1145 SourceLocation ImportLoc,
ModuleFile *ImportedBy,
1146 SmallVectorImpl<ImportedModule> &Loaded,
1147 off_t ExpectedSize, time_t ExpectedModTime,
1149 unsigned ClientLoadCapabilities);
1151 SmallVectorImpl<ImportedModule> &Loaded,
1153 unsigned ClientLoadCapabilities);
1155 llvm::BitstreamCursor &Stream,
unsigned ClientLoadCapabilities,
1156 bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
1157 std::string &SuggestedPredefines);
1162 llvm::BitstreamCursor &SLocCursorForID(
int ID);
1163 SourceLocation getImportLocation(
ModuleFile *F);
1166 unsigned ClientLoadCapabilities);
1168 unsigned ClientLoadCapabilities);
1169 static bool ParseLanguageOptions(
const RecordData &Record,
bool Complain,
1170 ASTReaderListener &Listener,
1171 bool AllowCompatibleDifferences);
1172 static bool ParseTargetOptions(
const RecordData &Record,
bool Complain,
1173 ASTReaderListener &Listener,
1174 bool AllowCompatibleDifferences);
1175 static bool ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
1176 ASTReaderListener &Listener);
1177 static bool ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
1178 ASTReaderListener &Listener);
1179 static bool ParseHeaderSearchOptions(
const RecordData &Record,
bool Complain,
1180 ASTReaderListener &Listener);
1181 static bool ParsePreprocessorOptions(
const RecordData &Record,
bool Complain,
1182 ASTReaderListener &Listener,
1183 std::string &SuggestedPredefines);
1185 struct RecordLocation {
1192 QualType readTypeRecord(
unsigned Index);
1194 SmallVectorImpl<QualType> &ExceptionStorage,
1195 FunctionProtoType::ExceptionSpecInfo &ESI,
1197 RecordLocation TypeCursorForIndex(
unsigned Index);
1198 void LoadedDecl(
unsigned Index,
Decl *D);
1200 void markIncompleteDeclChain(
Decl *Canon);
1205 Decl *getMostRecentExistingDecl(
Decl *D);
1208 SourceLocation &Location);
1210 void loadPendingDeclChain(
Decl *D, uint64_t LocalOffset);
1212 unsigned PreviousGeneration = 0);
1214 RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
1215 uint64_t getGlobalBitOffset(
ModuleFile &M, uint32_t LocalOffset);
1220 findPreprocessedEntity(SourceLocation Loc,
bool EndsAfter)
const;
1229 findNextPreprocessedEntity(
1234 std::pair<ModuleFile *, unsigned>
1235 getModulePreprocessedEntity(
unsigned GlobalIndex);
1239 llvm::iterator_range<PreprocessingRecord::iterator>
1240 getModulePreprocessedEntities(
ModuleFile &Mod)
const;
1242 class ModuleDeclIterator
1243 :
public llvm::iterator_adaptor_base<
1244 ModuleDeclIterator, const serialization::LocalDeclID *,
1245 std::random_access_iterator_tag, const Decl *, ptrdiff_t,
1246 const Decl *, const Decl *> {
1251 ModuleDeclIterator()
1252 : iterator_adaptor_base(nullptr), Reader(nullptr), Mod(nullptr) {}
1254 ModuleDeclIterator(ASTReader *Reader,
ModuleFile *Mod,
1256 : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
1259 return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *
I));
1261 value_type operator->()
const {
return **
this; }
1263 bool operator==(
const ModuleDeclIterator &RHS)
const {
1264 assert(Reader == RHS.Reader && Mod == RHS.Mod);
1269 llvm::iterator_range<ModuleDeclIterator>
1272 void PassInterestingDeclsToConsumer();
1273 void PassInterestingDeclToConsumer(
Decl *D);
1275 void finishPendingActions();
1276 void diagnoseOdrViolations();
1278 void pushExternalDeclIntoScope(NamedDecl *D, DeclarationName
Name);
1280 void addPendingDeclContextInfo(
Decl *D,
1284 PendingDeclContextInfo Info = { D, SemaDC, LexicalDC };
1285 PendingDeclContextInfos.push_back(Info);
1292 void Error(StringRef Msg);
1293 void Error(
unsigned DiagID, StringRef Arg1 = StringRef(),
1294 StringRef Arg2 = StringRef());
1296 ASTReader(
const ASTReader &) =
delete;
1297 void operator=(
const ASTReader &) =
delete;
1338 ASTReader(Preprocessor &PP,
ASTContext &Context,
1339 const PCHContainerReader &PCHContainerRdr,
1340 ArrayRef<IntrusiveRefCntPtr<ModuleFileExtension>> Extensions,
1341 StringRef isysroot =
"",
bool DisableValidation =
false,
1342 bool AllowASTWithCompilerErrors =
false,
1343 bool AllowConfigurationMismatch =
false,
1344 bool ValidateSystemInputs =
false,
bool UseGlobalIndex =
true,
1345 std::unique_ptr<llvm::Timer> ReadTimer = {});
1391 unsigned ClientLoadCapabilities);
1411 return std::move(Listener);
1416 this->Listener = std::move(Listener);
1424 L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
1425 std::move(Listener));
1426 Listener = std::move(L);
1436 : Reader(Reader), Chained(
false) {
1440 L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
1448 Reader.
setListener(static_cast<ChainedASTReaderListener *>(New.get())
1455 bool TakeOwnership =
false);
1483 std::unique_ptr<llvm::MemoryBuffer>
Buffer) {
1519 bool FindModuleFileExtensions,
1529 std::string ExistingModuleCachePath);
1544 std::pair<unsigned, unsigned>
1559 return TotalNumSLocEntries;
1564 return static_cast<unsigned>(IdentifiersLoaded.size());
1569 return static_cast<unsigned>(MacrosLoaded.size());
1574 return static_cast<unsigned>(TypesLoaded.size());
1579 return static_cast<unsigned>(DeclsLoaded.size());
1584 return static_cast<unsigned>(SubmodulesLoaded.size());
1589 return static_cast<unsigned>(SelectorsLoaded.size());
1597 E = ModuleMgr.
end();
I !=
E; ++
I) {
1598 Result += (*I)->NumPreprocessedEntities;
1636 if (Idx >= Record.size())
1678 template<
typename T>
1710 template<
typename T>
1755 llvm::function_ref<
bool(
Decl::Kind)> IsKindWeWant,
1824 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined)
override;
1845 SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels)
override;
1848 SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI)
override;
1857 llvm::MapVector<const FunctionDecl *, LateParsedTemplate *> &LPTMap)
1949 unsigned LocalID)
const;
1978 bool Canonicalize =
false);
1988 unsigned &Idx,
bool Canonicalize =
false);
2024 "Cannot find offset to remap.");
2025 int Remap = ModuleFile.
SLocRemap.
find(Loc.getOffset())->second;
2048 const llvm::fltSemantics &Sem,
unsigned &Idx);
2074 assert(ReadingKind == Read_Stmt &&
2075 "Should be called only during statement reading!");
2078 assert(!StmtStack.empty() &&
"Read too many sub-statements!");
2079 return StmtStack.pop_back_val();
2103 uint64_t MacroDirectivesOffset);
2161 : Cursor(Cursor),
Offset(Cursor.GetCurrentBitNo()) { }
2168 llvm::BitstreamCursor &
Cursor;
2172 inline void PCHValidator::Error(
const char *Msg) {
llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx)
Read an integral value.
Decl * GetExistingDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration.
SmallVector< std::pair< llvm::BitstreamCursor, serialization::ModuleFile * >, 8 > CommentsCursors
Cursors for comments blocks.
void updateOutOfDateSelector(Selector Sel) override
Load the contents of the global method pool for a given selector if necessary.
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override
Finds all the visible declarations with a given name.
Decl * GetLocalDecl(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons...
The client can handle an AST file that cannot load because it was built with a different version of C...
IdentifierIterator * getIdentifiers() override
Retrieve an iterator into the set of all identifiers in all loaded AST files.
unsigned getTotalNumTypes() const
Returns the number of types found in the chain.
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines)
Receives the preprocessor options.
Represents a version number in the form major[.minor[.subminor[.build]]].
void SetIdentifierInfo(unsigned ID, IdentifierInfo *II)
virtual bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule)
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Implements support for file system lookup, file system caching, and directory search management...
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
virtual void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind)
This is called for each AST file loaded.
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
bool operator==(CanQual< T > x, CanQual< U > y)
Defines the clang::FileManager interface and associated types.
CXXBaseSpecifier * GetExternalCXXBaseSpecifiers(uint64_t Offset) override
Resolve the offset of a set of C++ base specifiers in the decl stream into an array of specifiers...
Optional< bool > isPreprocessedEntityInFileID(unsigned Index, FileID FID) override
Optionally returns true or false if the preallocated preprocessed entity with index Index came from f...
void ReadComments() override
Loads comments ranges.
Defines the SourceManager interface.
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
GlobalModuleIndex * getGlobalIndex()
Return global module index.
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
ModuleManager::ModuleConstIterator ModuleConstIterator
SmallVector< uint64_t, 64 > RecordData
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
The base class of the type hierarchy.
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
IdentifierInfo * getLocalIdentifier(ModuleFile &M, unsigned LocalID)
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
std::unique_ptr< llvm::MemoryBuffer > Buffer
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
A container of type source information.
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
void makeModuleVisible(Module *Mod, Module::NameVisibilityKind NameVisibility, SourceLocation ImportLoc)
Make the entities in the given module and any of its (non-explicit) submodules visible to name lookup...
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
void addPendingMacro(IdentifierInfo *II, ModuleFile *M, uint64_t MacroDirectivesOffset)
Add a macro to deserialize its macro directive history.
CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a C++ base specifier.
The client can handle an AST file that cannot load because it is out-of-date relative to its input fi...
uint32_t IdentifierID
An ID number that refers to an identifier in an AST file.
Manages the set of modules loaded by an AST reader.
void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation > > &Sels) override
Read the set of referenced selectors known to the external Sema source.
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
Options for controlling the target.
serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const
Map a local type ID within a given AST file into a global type ID.
void CompleteRedeclChain(const Decl *D) override
If any redeclarations of D have been imported since it was last checked, this digs out those redeclar...
ModuleManager::ModuleReverseIterator ModuleReverseIterator
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Stores a list of template parameters for a TemplateDecl and its derived classes.
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
T * ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx)
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
void ReadTentativeDefinitions(SmallVectorImpl< VarDecl * > &TentativeDefs) override
Read the set of tentative definitions known to the external Sema source.
An UnresolvedSet-like class that might not have been loaded from the external AST source yet...
The client can handle an AST file that cannot load because it is missing.
void ReadUndefinedButUsed(llvm::MapVector< NamedDecl *, SourceLocation > &Undefined) override
Load the set of used but not defined functions or variables with internal linkage, or used but not defined internal functions.
One of these records is kept for each identifier that is lexed.
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
SmallVectorImpl< ModuleFile * >::const_iterator ModuleConstIterator
bool hasGlobalIndex() const
Determine whether this AST reader has a global index.
ModuleIterator begin()
Forward iterator to traverse all loaded modules.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
T * GetLocalDeclAs(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
Utility class for loading a ASTContext from an AST file.
serialization::SelectorID getGlobalSelectorID(ModuleFile &F, unsigned LocalID) const
Retrieve the global selector ID that corresponds to this the local selector ID in a given module...
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions, ASTReaderListener &Listener)
Read the control block for the named AST file.
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
serialization::ModuleManager ModuleManager
void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, LateParsedTemplate * > &LPTMap) override
Read the set of late parsed template functions for this source.
unsigned ASTFileSignature
Helper class that saves the current stream position and then restores it when destroyed.
TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template name.
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
Token - This structure provides full information about a lexed token.
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Sema * getSema()
Retrieve the semantic analysis object used to analyze the translation unit in which the precompiled h...
Stmt * ReadSubStmt()
Reads a sub-statement operand during statement reading.
void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl * > &Decls) override
Read the set of ext_vector type declarations known to the external Sema source.
The client can handle an AST file that cannot load because it's compiled configuration doesn't match ...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Decl * getKeyDeclaration(Decl *D)
Returns the first key declaration for the given declaration.
void ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo > > &WI) override
Read the set of weak, undeclared identifiers known to the external Sema source.
Describes a module or submodule.
void completeVisibleDeclsMap(const DeclContext *DC) override
Load all external visible decls in the given DeclContext.
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
llvm::Optional< ASTSourceDescriptor > getSourceDescriptor(unsigned ID) override
Return a descriptor for the corresponding module.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
PreprocessedEntity * ReadPreprocessedEntity(unsigned Index) override
Read a preallocated preprocessed entity from the external source.
serialization::ModuleKind ModuleKind
TypeSourceInfo * GetTypeSourceInfo(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declarator info from the given record.
ModuleManager & getModuleManager()
Retrieve the module manager.
void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, const RecordData &Record, unsigned &Idx)
CXXCtorInitializer ** ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a CXXCtorInitializer array.
llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx)
Read a signed integral value.
DiagnosticsEngine & getDiags() const
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, const RecordDataImpl &Record, unsigned &Idx)
Read a source location.
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
ModuleIterator end()
Forward iterator end-point to traverse all loaded modules.
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
std::string getOwningModuleNameForDiagnostic(const Decl *D)
Get the best name we know for the module that owns the given declaration, or an empty string if the d...
Concrete class used by the front-end to report problems and issues.
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID)
Retrieve the global submodule ID given a module and its local ID number.
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
TemplateArgument ReadTemplateArgument(ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument.
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
const Decl * getKeyDeclaration(const Decl *D)
std::string OriginalSourceFileName
The original source file name that was used to build the primary AST file, which may have been modifi...
void resetForReload()
Reset reader for a reload try.
ModuleManager::ModuleIterator ModuleIterator
void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation > > &Pending) override
Read the set of pending instantiations known to the external Sema source.
ContinuousRangeMap< uint32_t, int, 2 > SLocRemap
Remapping table for source locations in this module.
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
The AST file itself appears corrupted.
unsigned getTotalNumDecls() const
Returns the number of declarations found in the chain.
detail::InMemoryDirectory::const_iterator I
void dump()
Dump information about the AST reader to standard error.
void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &Exprs) override
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl * > &Decls) override
Read the set of delegating constructors known to the external Sema source.
static std::string ReadString(const RecordData &Record, unsigned &Idx)
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
IdentifierInfo * GetIdentifierInfo(ModuleFile &M, const RecordData &Record, unsigned &Idx)
void ForgetSema() override
Inform the semantic consumer that Sema is no longer available.
Sema - This implements semantic analysis and AST building for C.
A little helper class used to produce diagnostics.
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
ModuleKind
Specifies the kind of module that has been loaded.
Provides lookups to, and iteration over, IdentiferInfo objects.
SourceLocation ReadUntranslatedSourceLocation(uint32_t Raw) const
Read a source location from raw form and return it in its originating module file's source location s...
void SetGloballyVisibleDecls(IdentifierInfo *II, const SmallVectorImpl< uint32_t > &DeclIDs, SmallVectorImpl< Decl * > *Decls=nullptr)
Set the globally-visible declarations associated with the given identifier.
void ReadModuleMapFile(StringRef ModuleMapPath) override
Decl * ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts, const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts, std::string ExistingModuleCachePath)
Determine whether the given AST file is acceptable to load into a translation unit with the given lan...
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo)
SmallVectorImpl< ModuleFile * >::reverse_iterator ModuleReverseIterator
serialization::PreprocessedEntityID getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const
Determine the global preprocessed entity ID that corresponds to the given local ID within the given m...
ASTReaderListener implementation to validate the information of the PCH file against an initialized P...
Abstract interface for external sources of preprocessor information.
HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override
Read the header file information for the given file entry.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID)
Retrieve the global macro ID corresponding to the given local ID within the given module file...
DiagnosticBuilder Diag(unsigned DiagID)
Report a diagnostic.
QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a type from the current position in the given record, which was read from the given AST file...
RAII object to temporarily add an AST callback listener.
Stmt * ReadStmt(ModuleFile &F)
Reads a statement.
void ReadUsedVTables(SmallVectorImpl< ExternalVTableUse > &VTables) override
Read the set of used vtables known to the external Sema source.
Implements an efficient mapping from strings to IdentifierInfo nodes.
virtual void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata)
Indicates that a particular module file extension has been read.
Defines version macros and version-related utility functions for Clang.
ArgKind
The kind of template argument we're storing.
serialization::DeclID getGlobalDeclID(ModuleFile &F, serialization::LocalDeclID LocalID) const
Map from a local declaration ID within a given module to a global declaration ID. ...
std::pair< SourceLocation, StringRef > getModuleImportLoc(int ID) override
Retrieve the module import location and module name for the given source manager entry ID...
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a source range.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Represents a C++ template name within the type system.
QualType getLocalType(ModuleFile &F, unsigned LocalID)
Resolve a local type ID within a given AST file into a type.
Information about a module that has been loaded by the ASTReader.
virtual ~ASTReaderListener()
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
An iterator that walks over all of the known identifiers in the lookup table.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
SavedStreamPosition(llvm::BitstreamCursor &Cursor)
void StartedDeserializing() override
Notify ASTReader that we started deserialization of a decl or type so until FinishedDeserializing is ...
The result type of a method or function.
SmallVector< uint64_t, 16 > PreloadedDeclIDs
void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, const RecordData &Record, unsigned &Idx)
The client can't handle any AST loading failures.
The AST file was missing.
An abstract interface that should be implemented by external AST sources that also provide informatio...
NestedNameSpecifier * ReadNestedNameSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
void addInMemoryBuffer(StringRef FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add an in-memory buffer the list of known buffers.
Representation::const_iterator const_iterator
void makeNamesVisible(const HiddenNames &Names, Module *Owner)
Make the names within this set of hidden names visible.
QualifierInfo - A struct with extended info about a syntactic name qualifier, to be used for the case...
The control block was read successfully.
bool ReadFullVersionInformation(StringRef FullVersion) override
Receives the full Clang version information.
void addListener(std::unique_ptr< ASTReaderListener > L)
Add an AST callback listener.
bool isGlobalIndexUnavailable() const
Determine whether we tried to load the global index, but failed, e.g., because it is out-of-date or d...
SourceLocation TranslateSourceLocation(ModuleFile &ModuleFile, SourceLocation Loc) const
Translate a source location from another module file's source location space into ours...
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
MacroInfo * ReadMacroRecord(ModuleFile &F, uint64_t Offset)
Reads the macro record located at the given offset.
Encodes a location in the source.
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
Represents a C++ temporary.
void InitializeContext()
Initializes the ASTContext.
An identifier-lookup iterator that enumerates all of the identifiers stored within a set of AST files...
std::unique_ptr< ASTReaderListener > takeListener()
Take the AST callbacks listener.
void ReadKnownNamespaces(SmallVectorImpl< NamespaceDecl * > &Namespaces) override
Load the set of namespaces that are known to the external source, which will be used during typo corr...
Cached information about one file (either on disk or in the virtual file system). ...
bool isProcessingUpdateRecords()
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
MacroInfo * getMacro(serialization::MacroID ID)
Retrieve the macro with the given ID.
TemplateParameterList * ReadTemplateParameterList(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template parameter list.
An abstract class that should be subclassed by any external source of preprocessing record entries...
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
void ReadMethodPool(Selector Sel) override
Load the contents of the global method pool for a given selector.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
void addInMemoryBuffer(StringRef &FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add in-memory (virtual file) buffer.
PCHValidator(Preprocessor &PP, ASTReader &Reader)
uint32_t MacroID
An ID number that refers to a macro in an AST file.
void setListener(std::unique_ptr< ASTReaderListener > Listener)
Set the AST callbacks listener.
External source of source location entries.
virtual void visitImport(StringRef Filename)
If needsImportVisitation returns true, this is called for each AST file imported by this AST file...
A global index for a set of module files, providing information about the identifiers within those mo...
DeclarationName ReadDeclarationName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a declaration name.
ASTReadResult ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, unsigned ClientLoadCapabilities)
Load the AST file designated by the given file name.
The AST file was writtten with a different language/target configuration.
void markIdentifierUpToDate(IdentifierInfo *II)
Note that this identifier is up-to-date.
llvm::APFloat ReadAPFloat(const RecordData &Record, const llvm::fltSemantics &Sem, unsigned &Idx)
Read a floating-point value.
unsigned getTotalNumSLocs() const
Returns the number of source locations found in the chain.
ModuleFile * getLocalModuleFile(ModuleFile &M, unsigned ID)
Retrieve the module file with a given local ID within the specified ModuleFile.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
ChainedASTReaderListener(std::unique_ptr< ASTReaderListener > First, std::unique_ptr< ASTReaderListener > Second)
Takes ownership of First and Second.
SmallVectorImpl< uint64_t > RecordDataImpl
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a template argument.
Selector getLocalSelector(ModuleFile &M, unsigned LocalID)
Retrieve a selector from the given module with its local ID number.
const ASTTemplateArgumentListInfo * ReadASTTemplateArgumentListInfo(ModuleFile &F, const RecordData &Record, unsigned &Index)
bool ReadSLocEntry(int ID) override
Read the source location entry with index ID.
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
void ResolveImportedPath(ModuleFile &M, std::string &Filename)
If we are loading a relocatable PCH or module file, and the filename is not an absolute path...
void setDeserializationListener(ASTDeserializationListener *Listener, bool TakeOwnership=false)
Set the AST deserialization listener.
unsigned getTotalNumIdentifiers() const
Returns the number of identifiers found in the chain.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
void updateOutOfDateIdentifier(IdentifierInfo &II) override
Update an out-of-date identifier.
void ReadDefinedMacros() override
Read the set of macros defined by this external macro source.
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain) override
Receives the file system options.
Reads an AST files chain containing the contents of a translation unit.
Expr * ReadExpr(ModuleFile &F)
Reads an expression.
ListenerScope(ASTReader &Reader, std::unique_ptr< ASTReaderListener > L)
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
ModuleFile & getPrimaryModule()
Returns the primary module associated with the manager, that is, the first module loaded...
bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule) override
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
LoadFailureCapabilities
Flags that indicate what kind of AST loading failures the client of the AST reader can directly handl...
DeclarationName - The name of a declaration.
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
bool needsInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
void FindExternalLexicalDecls(const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl * > &Decls) override
Read all of the declarations lexically stored in a declaration context.
SourceManager & getSourceManager() const
detail::InMemoryDirectory::const_iterator E
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
unsigned getTotalNumMacros() const
Returns the number of macros found in the chain.
A map from continuous integer ranges to some value, with a very specialized interface.
Class that performs lookup for an identifier stored in an AST file.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void ReadDeclarationNameLoc(ModuleFile &F, DeclarationNameLoc &DNLoc, DeclarationName Name, const RecordData &Record, unsigned &Idx)
void ClearSwitchCaseIDs()
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, uint32_t Raw) const
Read a source location from raw form.
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
Defines the Diagnostic-related interfaces.
Encapsulates the data about a macro definition (e.g.
Decl * GetExternalDecl(uint32_t ID) override
Resolve a declaration ID into a declaration, potentially building a new declaration.
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope...
void ReadUnresolvedSet(ModuleFile &F, LazyASTUnresolvedSet &Set, const RecordData &Record, unsigned &Idx)
Read a UnresolvedSet structure.
Abstract interface for callback invocations by the ASTReader.
Location wrapper for a TemplateArgument.
NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
std::pair< unsigned, unsigned > findPreprocessedEntitiesInRange(SourceRange Range) override
Returns a pair of [Begin, End) indices of preallocated preprocessed entities that Range encompasses...
Defines the clang::FileSystemOptions interface.
Represents a C++ base or member initializer.
virtual bool needsImportVisitation() const
Returns true if this ASTReaderListener wants to receive the imports of the AST file via visitImport...
void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata) override
Indicates that a particular module file extension has been read.
void ReadTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument array.
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
void forEachImportedKeyDecl(const Decl *D, Fn Visit)
Run a callback on each imported key declaration of D.
Selector DecodeSelector(serialization::SelectorID Idx)
Represents a base class of a C++ class.
uint32_t GetNumExternalSelectors() override
Returns the number of selectors known to the external AST source.
void PrintStats() override
Print some statistics about AST usage.
Keeps track of options that affect how file operations are performed.
static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID)
ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the specified cursor.
QualType GetType(serialization::TypeID ID)
Resolve a type ID into a type, potentially building a new type.
IdentifierInfo * DecodeIdentifierInfo(serialization::IdentifierID ID)
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain)
Receives the header search options.
serialization::ModuleFile ModuleFile
unsigned getTotalNumPreprocessedEntities() const
Returns the number of preprocessed entities known to the AST reader.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length, SmallVectorImpl< Decl * > &Decls) override
Get the decls that are contained in a file in the Offset/Length range.
FileManager & getFileManager() const
TemplateArgumentLoc ReadTemplateArgumentLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLoc.
TemplateArgumentLocInfo GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind.
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declaration ID from the given position in a record in the given module.
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
Expr * ReadSubExpr()
Reads a sub-expression operand during statement reading.
Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx)
Reads a token out of a record.
IdentifierInfo * GetIdentifier(serialization::IdentifierID ID) override
Location information for a TemplateArgument.
virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the target options.
Writes an AST file containing the contents of a translation unit.
virtual void ReadModuleName(StringRef ModuleName)
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
The AST file is out-of-date relative to its input files, and needs to be regenerated.
NameVisibilityKind
Describes the visibility of the various names within a particular module.
Simple wrapper class for chaining listeners.
void ReadAttributes(ModuleFile &F, AttrVec &Attrs, const RecordData &Record, unsigned &Idx)
Reads attributes from the current stream position.
SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID)
Returns the source location for the decl ID.
The AST file was written by a different version of Clang.
std::unique_ptr< ASTReaderListener > takeSecond()
ModuleFile * getOwningModuleFile(const Decl *D)
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
void StartTranslationUnit(ASTConsumer *Consumer) override
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
const std::string & getSuggestedPredefines()
Returns the suggested contents of the predefines buffer, which contains a (typically-empty) subset of...
SmallVectorImpl< ModuleFile * >::iterator ModuleIterator
uint32_t TypeID
An ID number that refers to a type in an AST file.
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
void UpdateSema()
Update the state of Sema after loading some additional modules.
serialization::DeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M, serialization::DeclID GlobalID)
Map a global declaration ID into the declaration ID used to refer to this declaration within the give...
void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl * > &Decls) override
Read the set of unused file-scope declarations known to the external Sema source. ...
void FinishedDeserializing() override
Notify ASTReader that we finished the deserialization of a decl or type.
std::unique_ptr< ASTReaderListener > takeFirst()
void ReadModuleName(StringRef ModuleName) override
This class handles loading and caching of source files into memory.
void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind) override
This is called for each AST file loaded.
bool loadGlobalIndex()
Attempts to load the global index.
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls) override
Read the set of potentially unused typedefs known to the source.
virtual bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain)
Receives the diagnostic options.
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID)
Record that the given ID maps to the given switch-case statement.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, unsigned LocalID)