48 #include "llvm/ADT/Hashing.h"
49 #include "llvm/ADT/StringExtras.h"
50 #include "llvm/Bitcode/BitstreamReader.h"
51 #include "llvm/Support/Compression.h"
52 #include "llvm/Support/ErrorHandling.h"
53 #include "llvm/Support/FileSystem.h"
54 #include "llvm/Support/MemoryBuffer.h"
55 #include "llvm/Support/Path.h"
56 #include "llvm/Support/SaveAndRestore.h"
57 #include "llvm/Support/raw_ostream.h"
61 #include <system_error>
63 using namespace clang;
64 using namespace clang::serialization;
65 using namespace clang::serialization::reader;
66 using llvm::BitstreamCursor;
75 return First->ReadFullVersionInformation(FullVersion) ||
76 Second->ReadFullVersionInformation(FullVersion);
79 First->ReadModuleName(ModuleName);
80 Second->ReadModuleName(ModuleName);
83 First->ReadModuleMapFile(ModuleMapPath);
84 Second->ReadModuleMapFile(ModuleMapPath);
89 bool AllowCompatibleDifferences) {
90 return First->ReadLanguageOptions(LangOpts, Complain,
91 AllowCompatibleDifferences) ||
92 Second->ReadLanguageOptions(LangOpts, Complain,
93 AllowCompatibleDifferences);
97 bool AllowCompatibleDifferences) {
98 return First->ReadTargetOptions(TargetOpts, Complain,
99 AllowCompatibleDifferences) ||
100 Second->ReadTargetOptions(TargetOpts, Complain,
101 AllowCompatibleDifferences);
105 return First->ReadDiagnosticOptions(DiagOpts, Complain) ||
106 Second->ReadDiagnosticOptions(DiagOpts, Complain);
111 return First->ReadFileSystemOptions(FSOpts, Complain) ||
112 Second->ReadFileSystemOptions(FSOpts, Complain);
118 return First->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
120 Second->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
125 std::string &SuggestedPredefines) {
126 return First->ReadPreprocessorOptions(PPOpts, Complain,
127 SuggestedPredefines) ||
128 Second->ReadPreprocessorOptions(PPOpts, Complain, SuggestedPredefines);
132 First->ReadCounter(M, Value);
133 Second->ReadCounter(M, Value);
136 return First->needsInputFileVisitation() ||
137 Second->needsInputFileVisitation();
140 return First->needsSystemInputFileVisitation() ||
141 Second->needsSystemInputFileVisitation();
145 First->visitModuleFile(Filename, Kind);
146 Second->visitModuleFile(Filename, Kind);
151 bool isExplicitModule) {
152 bool Continue =
false;
153 if (First->needsInputFileVisitation() &&
154 (!isSystem || First->needsSystemInputFileVisitation()))
155 Continue |= First->visitInputFile(Filename, isSystem, isOverridden,
157 if (Second->needsInputFileVisitation() &&
158 (!isSystem || Second->needsSystemInputFileVisitation()))
159 Continue |= Second->visitInputFile(Filename, isSystem, isOverridden,
166 First->readModuleFileExtension(Metadata);
167 Second->readModuleFileExtension(Metadata);
187 bool AllowCompatibleDifferences =
true) {
188 #define LANGOPT(Name, Bits, Default, Description) \
189 if (ExistingLangOpts.Name != LangOpts.Name) { \
191 Diags->Report(diag::err_pch_langopt_mismatch) \
192 << Description << LangOpts.Name << ExistingLangOpts.Name; \
196 #define VALUE_LANGOPT(Name, Bits, Default, Description) \
197 if (ExistingLangOpts.Name != LangOpts.Name) { \
199 Diags->Report(diag::err_pch_langopt_value_mismatch) \
204 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
205 if (ExistingLangOpts.get##Name() != LangOpts.get##Name()) { \
207 Diags->Report(diag::err_pch_langopt_value_mismatch) \
212 #define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
213 if (!AllowCompatibleDifferences) \
214 LANGOPT(Name, Bits, Default, Description)
216 #define COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) \
217 if (!AllowCompatibleDifferences) \
218 ENUM_LANGOPT(Name, Bits, Default, Description)
220 #define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \
221 if (!AllowCompatibleDifferences) \
222 VALUE_LANGOPT(Name, Bits, Default, Description)
224 #define BENIGN_LANGOPT(Name, Bits, Default, Description)
225 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
226 #define BENIGN_VALUE_LANGOPT(Name, Type, Bits, Default, Description)
227 #include "clang/Basic/LangOptions.def"
231 Diags->
Report(diag::err_pch_langopt_value_mismatch) <<
"module features";
237 Diags->
Report(diag::err_pch_langopt_value_mismatch)
238 <<
"target Objective-C runtime";
245 Diags->
Report(diag::err_pch_langopt_value_mismatch)
246 <<
"block command names";
262 bool AllowCompatibleDifferences =
true) {
263 #define CHECK_TARGET_OPT(Field, Name) \
264 if (TargetOpts.Field != ExistingTargetOpts.Field) { \
266 Diags->Report(diag::err_pch_targetopt_mismatch) \
267 << Name << TargetOpts.Field << ExistingTargetOpts.Field; \
278 if (!AllowCompatibleDifferences)
281 #undef CHECK_TARGET_OPT
289 std::sort(ExistingFeatures.begin(), ExistingFeatures.end());
290 std::sort(ReadFeatures.begin(), ReadFeatures.end());
296 ExistingFeatures.begin(), ExistingFeatures.end(), ReadFeatures.begin(),
297 ReadFeatures.end(), std::back_inserter(UnmatchedExistingFeatures));
298 std::set_difference(ReadFeatures.begin(), ReadFeatures.end(),
299 ExistingFeatures.begin(), ExistingFeatures.end(),
300 std::back_inserter(UnmatchedReadFeatures));
304 if (AllowCompatibleDifferences && UnmatchedReadFeatures.empty())
308 for (StringRef Feature : UnmatchedReadFeatures)
309 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
311 for (StringRef Feature : UnmatchedExistingFeatures)
312 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
316 return !UnmatchedReadFeatures.empty() || !UnmatchedExistingFeatures.empty();
322 bool AllowCompatibleDifferences) {
323 const LangOptions &ExistingLangOpts = PP.getLangOpts();
325 Complain ? &Reader.Diags :
nullptr,
326 AllowCompatibleDifferences);
331 bool AllowCompatibleDifferences) {
332 const TargetOptions &ExistingTargetOpts = PP.getTargetInfo().getTargetOpts();
334 Complain ? &Reader.Diags :
nullptr,
335 AllowCompatibleDifferences);
339 typedef llvm::StringMap<std::pair<StringRef,
bool > >
341 typedef llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8> >
356 for (
auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) {
365 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror=" +
384 bool IsSystem,
bool Complain) {
392 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Wsystem-headers";
399 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror";
406 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Weverything -Werror";
413 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-pedantic-errors";
431 assert(ModuleMgr.
size() >= 1 &&
"what ASTFile is this then");
440 ModuleFile *TopImport = *ModuleMgr.
rbegin();
441 while (!TopImport->ImportedBy.empty())
442 TopImport = TopImport->ImportedBy[0];
446 StringRef ModuleName = TopImport->ModuleName;
447 assert(!ModuleName.empty() &&
"diagnostic options read before module name");
449 Module *M = PP.getHeaderSearchInfo().lookupModule(ModuleName);
450 assert(M &&
"missing module");
461 MacroDefinitionsMap &Macros,
463 for (
unsigned I = 0, N = PPOpts.
Macros.size();
I != N; ++
I) {
464 StringRef Macro = PPOpts.
Macros[
I].first;
465 bool IsUndef = PPOpts.
Macros[
I].second;
467 std::pair<StringRef, StringRef> MacroPair = Macro.split(
'=');
468 StringRef MacroName = MacroPair.first;
469 StringRef MacroBody = MacroPair.second;
473 if (MacroNames && !Macros.count(MacroName))
474 MacroNames->push_back(MacroName);
476 Macros[MacroName] = std::make_pair(
"",
true);
481 if (MacroName.size() == Macro.size())
485 StringRef::size_type
End = MacroBody.find_first_of(
"\n\r");
486 MacroBody = MacroBody.substr(0, End);
489 if (MacroNames && !Macros.count(MacroName))
490 MacroNames->push_back(MacroName);
491 Macros[MacroName] = std::make_pair(MacroBody,
false);
503 std::string &SuggestedPredefines,
506 MacroDefinitionsMap ASTFileMacros;
508 MacroDefinitionsMap ExistingMacros;
512 for (
unsigned I = 0, N = ExistingMacroNames.size();
I != N; ++
I) {
514 StringRef MacroName = ExistingMacroNames[
I];
515 std::pair<StringRef, bool> Existing = ExistingMacros[MacroName];
518 llvm::StringMap<std::pair<StringRef,
bool > >
::iterator Known
519 = ASTFileMacros.find(MacroName);
520 if (Known == ASTFileMacros.end()) {
525 if (Existing.second) {
526 SuggestedPredefines +=
"#undef ";
527 SuggestedPredefines += MacroName.str();
528 SuggestedPredefines +=
'\n';
530 SuggestedPredefines +=
"#define ";
531 SuggestedPredefines += MacroName.str();
532 SuggestedPredefines +=
' ';
533 SuggestedPredefines += Existing.first.str();
534 SuggestedPredefines +=
'\n';
541 if (Existing.second != Known->second.second) {
543 Diags->
Report(diag::err_pch_macro_def_undef)
544 << MacroName << Known->second.second;
551 if (Existing.second || Existing.first == Known->second.first)
556 Diags->
Report(diag::err_pch_macro_def_conflict)
557 << MacroName << Known->second.first << Existing.first;
571 if (LangOpts.Modules &&
580 for (
unsigned I = 0, N = ExistingPPOpts.
Includes.size();
I != N; ++
I) {
581 StringRef File = ExistingPPOpts.
Includes[
I];
589 SuggestedPredefines +=
"#include \"";
590 SuggestedPredefines += File;
591 SuggestedPredefines +=
"\"\n";
594 for (
unsigned I = 0, N = ExistingPPOpts.
MacroIncludes.size();
I != N; ++
I) {
601 SuggestedPredefines +=
"#__include_macros \"";
602 SuggestedPredefines += File;
603 SuggestedPredefines +=
"\"\n##\n";
611 std::string &SuggestedPredefines) {
615 Complain? &Reader.Diags :
nullptr,
626 StringRef SpecificModuleCachePath,
627 StringRef ExistingModuleCachePath,
630 if (LangOpts.Modules) {
631 if (SpecificModuleCachePath != ExistingModuleCachePath) {
633 Diags->
Report(diag::err_pch_modulecache_mismatch)
634 << SpecificModuleCachePath << ExistingModuleCachePath;
643 StringRef SpecificModuleCachePath,
646 PP.getHeaderSearchInfo().getModuleCachePath(),
647 Complain ? &Reader.Diags :
nullptr,
652 PP.setCounterValue(Value);
660 bool TakeOwnership) {
661 DeserializationListener = Listener;
662 OwnsDeserializationListener = TakeOwnership;
672 std::pair<unsigned, unsigned>
674 using namespace llvm::support;
675 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
676 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
677 return std::make_pair(KeyLen, DataLen);
682 using namespace llvm::support;
684 unsigned N = endian::readNext<uint16_t, little, unaligned>(d);
686 F, endian::readNext<uint32_t, little, unaligned>(d));
688 return SelTable.getNullarySelector(FirstII);
690 return SelTable.getUnarySelector(FirstII);
693 Args.push_back(FirstII);
694 for (
unsigned I = 1;
I != N; ++
I)
695 Args.push_back(Reader.getLocalIdentifier(
696 F, endian::readNext<uint32_t, little, unaligned>(d)));
698 return SelTable.getSelector(N, Args.data());
704 using namespace llvm::support;
708 Result.ID = Reader.getGlobalSelectorID(
709 F, endian::readNext<uint32_t, little, unaligned>(d));
710 unsigned FullInstanceBits = endian::readNext<uint16_t, little, unaligned>(d);
711 unsigned FullFactoryBits = endian::readNext<uint16_t, little, unaligned>(d);
712 Result.InstanceBits = FullInstanceBits & 0x3;
713 Result.InstanceHasMoreThanOneDecl = (FullInstanceBits >> 2) & 0x1;
714 Result.FactoryBits = FullFactoryBits & 0x3;
715 Result.FactoryHasMoreThanOneDecl = (FullFactoryBits >> 2) & 0x1;
716 unsigned NumInstanceMethods = FullInstanceBits >> 3;
717 unsigned NumFactoryMethods = FullFactoryBits >> 3;
720 for (
unsigned I = 0;
I != NumInstanceMethods; ++
I) {
722 F, endian::readNext<uint32_t, little, unaligned>(d)))
723 Result.Instance.push_back(Method);
727 for (
unsigned I = 0;
I != NumFactoryMethods; ++
I) {
729 F, endian::readNext<uint32_t, little, unaligned>(d)))
730 Result.Factory.push_back(Method);
737 return llvm::HashString(a);
740 std::pair<unsigned, unsigned>
742 using namespace llvm::support;
743 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
744 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
745 return std::make_pair(KeyLen, DataLen);
750 assert(n >= 2 && d[n-1] ==
'\0');
751 return StringRef((
const char*) d, n-1);
766 bool Value = Bits & 0x1;
772 using namespace llvm::support;
773 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
774 return Reader.getGlobalIdentifierID(F, RawID >> 1);
787 const unsigned char* d,
789 using namespace llvm::support;
790 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
791 bool IsInteresting = RawID & 0x01;
799 II = &Reader.getIdentifierTable().getOwn(k);
803 Reader.markIdentifierUpToDate(II);
805 IdentID ID = Reader.getGlobalIdentifierID(F, RawID);
806 if (!IsInteresting) {
809 Reader.SetIdentifierInfo(
ID, II);
813 unsigned ObjCOrBuiltinID = endian::readNext<uint16_t, little, unaligned>(d);
814 unsigned Bits = endian::readNext<uint16_t, little, unaligned>(d);
815 bool CPlusPlusOperatorKeyword =
readBit(Bits);
816 bool HasRevertedTokenIDToIdentifier =
readBit(Bits);
817 bool HasRevertedBuiltin =
readBit(Bits);
819 bool ExtensionToken =
readBit(Bits);
820 bool HadMacroDefinition =
readBit(Bits);
822 assert(Bits == 0 &&
"Extra bits in the identifier?");
827 if (HasRevertedTokenIDToIdentifier && II->getTokenID() != tok::identifier)
828 II->revertTokenIDToIdentifier();
830 II->setObjCOrBuiltinID(ObjCOrBuiltinID);
831 else if (HasRevertedBuiltin && II->getBuiltinID()) {
833 assert((II->hasRevertedBuiltin() ||
834 II->getObjCOrBuiltinID() == ObjCOrBuiltinID) &&
835 "Incorrect ObjC keyword or builtin ID");
837 assert(II->isExtensionToken() == ExtensionToken &&
838 "Incorrect extension token flag");
839 (void)ExtensionToken;
841 II->setIsPoisoned(
true);
842 assert(II->isCPlusPlusOperatorKeyword() == CPlusPlusOperatorKeyword &&
843 "Incorrect C++ operator keyword flag");
844 (void)CPlusPlusOperatorKeyword;
848 if (HadMacroDefinition) {
849 uint32_t MacroDirectivesOffset =
850 endian::readNext<uint32_t, little, unaligned>(d);
853 Reader.addPendingMacro(II, &F, MacroDirectivesOffset);
856 Reader.SetIdentifierInfo(
ID, II);
862 for (; DataLen > 0; DataLen -= 4)
863 DeclIDs.push_back(Reader.getGlobalDeclID(
864 F, endian::readNext<uint32_t, little, unaligned>(d)));
865 Reader.SetGloballyVisibleDecls(II, DeclIDs);
872 :
Kind(Name.getNameKind()) {
898 llvm::FoldingSetNodeID
ID;
921 return ID.ComputeHash();
925 ASTDeclContextNameLookupTrait::ReadFileRef(
const unsigned char *&d) {
926 using namespace llvm::support;
927 uint32_t ModuleFileID = endian::readNext<uint32_t, little, unaligned>(d);
928 return Reader.getLocalModuleFile(F, ModuleFileID);
931 std::pair<unsigned, unsigned>
932 ASTDeclContextNameLookupTrait::ReadKeyDataLength(
const unsigned char *&d) {
933 using namespace llvm::support;
934 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
935 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
936 return std::make_pair(KeyLen, DataLen);
940 ASTDeclContextNameLookupTrait::ReadKey(
const unsigned char *d,
unsigned) {
941 using namespace llvm::support;
947 Data = (uint64_t)Reader.getLocalIdentifier(
948 F, endian::readNext<uint32_t, little, unaligned>(d));
954 (uint64_t)Reader.getLocalSelector(
955 F, endian::readNext<uint32_t, little, unaligned>(
956 d)).getAsOpaquePtr();
962 Data = (uint64_t)Reader.getLocalIdentifier(
963 F, endian::readNext<uint32_t, little, unaligned>(d));
977 const unsigned char *d,
980 using namespace llvm::support;
981 for (
unsigned NumDecls = DataLen / 4; NumDecls; --NumDecls) {
982 uint32_t LocalID = endian::readNext<uint32_t, little, unaligned>(d);
983 Val.
insert(Reader.getGlobalDeclID(F, LocalID));
987 bool ASTReader::ReadLexicalDeclContextStorage(
ModuleFile &M,
994 Cursor.JumpToBit(Offset);
998 unsigned Code = Cursor.ReadCode();
999 unsigned RecCode = Cursor.readRecord(Code, Record, &Blob);
1001 Error(
"Expected lexical block");
1005 assert(!isa<TranslationUnitDecl>(DC) &&
1006 "expected a TU_UPDATE_LEXICAL record for TU");
1011 auto &Lex = LexicalDecls[DC];
1013 Lex = std::make_pair(
1014 &M, llvm::makeArrayRef(
1015 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
1023 bool ASTReader::ReadVisibleDeclContextStorage(
ModuleFile &M,
1024 BitstreamCursor &Cursor,
1027 assert(Offset != 0);
1030 Cursor.JumpToBit(Offset);
1034 unsigned Code = Cursor.ReadCode();
1035 unsigned RecCode = Cursor.readRecord(Code, Record, &Blob);
1037 Error(
"Expected visible lookup table block");
1043 auto *Data = (
const unsigned char*)Blob.data();
1044 PendingVisibleUpdates[
ID].push_back(PendingVisibleUpdate{&M, Data});
1048 void ASTReader::Error(StringRef Msg) {
1049 Error(diag::err_fe_pch_malformed, Msg);
1051 !PP.getHeaderSearchInfo().getModuleCachePath().empty()) {
1052 Diag(diag::note_module_cache_path)
1053 << PP.getHeaderSearchInfo().getModuleCachePath();
1057 void ASTReader::Error(
unsigned DiagID,
1058 StringRef Arg1, StringRef Arg2) {
1059 if (Diags.isDiagnosticInFlight())
1060 Diags.SetDelayedDiagnostic(DiagID, Arg1, Arg2);
1062 Diag(DiagID) << Arg1 << Arg2;
1071 bool ASTReader::ParseLineTable(
ModuleFile &F,
1072 const RecordData &Record) {
1077 std::map<int, int> FileIDs;
1078 for (
unsigned I = 0; Record[Idx]; ++
I) {
1080 auto Filename = ReadPath(F, Record, Idx);
1086 std::vector<LineEntry> Entries;
1087 while (Idx < Record.size()) {
1088 int FID = Record[Idx++];
1089 assert(FID >= 0 &&
"Serialized line entries for non-local file.");
1094 unsigned NumEntries = Record[Idx++];
1095 assert(NumEntries &&
"no line entries for file ID");
1097 Entries.reserve(NumEntries);
1098 for (
unsigned I = 0;
I != NumEntries; ++
I) {
1099 unsigned FileOffset = Record[Idx++];
1100 unsigned LineNo = Record[Idx++];
1101 int FilenameID = FileIDs[Record[Idx++]];
1104 unsigned IncludeOffset = Record[Idx++];
1106 FileKind, IncludeOffset));
1108 LineTable.
AddEntry(FileID::get(FID), Entries);
1115 bool ASTReader::ReadSourceManagerBlock(
ModuleFile &F) {
1116 using namespace SrcMgr;
1124 SLocEntryCursor = F.
Stream;
1127 if (F.
Stream.SkipBlock()) {
1128 Error(
"malformed block record in AST file");
1134 Error(
"malformed source manager block record in AST file");
1140 llvm::BitstreamEntry
E = SLocEntryCursor.advanceSkippingSubblocks();
1143 case llvm::BitstreamEntry::SubBlock:
1145 Error(
"malformed block record in AST file");
1147 case llvm::BitstreamEntry::EndBlock:
1149 case llvm::BitstreamEntry::Record:
1157 switch (SLocEntryCursor.readRecord(E.ID, Record, &Blob)) {
1176 const std::string &OriginalDir,
1177 const std::string &CurrDir) {
1178 assert(OriginalDir != CurrDir &&
1179 "No point trying to resolve the file if the PCH dir didn't change");
1180 using namespace llvm::sys;
1182 fs::make_absolute(filePath);
1183 assert(path::is_absolute(OriginalDir));
1186 path::const_iterator fileDirI =
path::begin(path::parent_path(filePath)),
1187 fileDirE =
path::end(path::parent_path(filePath));
1188 path::const_iterator origDirI =
path::begin(OriginalDir),
1191 while (fileDirI != fileDirE && origDirI != origDirE &&
1192 *fileDirI == *origDirI) {
1196 for (; origDirI != origDirE; ++origDirI)
1197 path::append(currPCHPath,
"..");
1198 path::append(currPCHPath, fileDirI, fileDirE);
1199 path::append(currPCHPath, path::filename(Filename));
1200 return currPCHPath.str();
1207 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1208 Error(
"source location entry ID out-of-range for AST file");
1214 auto ReadBuffer = [
this](
1215 BitstreamCursor &SLocEntryCursor,
1216 StringRef
Name) -> std::unique_ptr<llvm::MemoryBuffer> {
1219 unsigned Code = SLocEntryCursor.ReadCode();
1220 unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, &Blob);
1224 if (llvm::zlib::uncompress(Blob, Uncompressed, Record[0]) !=
1225 llvm::zlib::StatusOK) {
1226 Error(
"could not decompress embedded file contents");
1229 return llvm::MemoryBuffer::getMemBufferCopy(Uncompressed,
Name);
1231 return llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1),
Name,
true);
1233 Error(
"AST record has invalid code");
1238 ModuleFile *F = GlobalSLocEntryMap.find(-ID)->second;
1243 ++NumSLocEntriesRead;
1244 llvm::BitstreamEntry Entry = SLocEntryCursor.advance();
1245 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1246 Error(
"incorrectly-formatted source location entry in AST file");
1252 switch (SLocEntryCursor.readRecord(Entry.ID, Record, &Blob)) {
1254 Error(
"incorrectly-formatted source location entry in AST file");
1260 unsigned InputID = Record[4];
1261 InputFile IF = getInputFile(*F, InputID);
1274 IncludeLoc = getImportLocation(F);
1278 FileID FID = SourceMgr.createFileID(File, IncludeLoc, FileCharacter,
1279 ID, BaseOffset + Record[0]);
1282 FileInfo.NumCreatedFIDs = Record[5];
1287 unsigned NumFileDecls = Record[7];
1289 assert(F->
FileSortedDecls &&
"FILE_SORTED_DECLS not encountered yet ?");
1290 FileDeclIDs[FID] = FileDeclsInfo(F, llvm::makeArrayRef(FirstDecl,
1294 const SrcMgr::ContentCache *ContentCache
1295 = SourceMgr.getOrCreateContentCache(File,
1297 if (OverriddenBuffer && !ContentCache->BufferOverridden &&
1298 ContentCache->ContentsEntry == ContentCache->OrigEntry &&
1299 !ContentCache->getRawBuffer()) {
1303 SourceMgr.overrideFileContents(File, std::move(
Buffer));
1310 const char *
Name = Blob.data();
1311 unsigned Offset = Record[0];
1317 IncludeLoc = getImportLocation(F);
1320 auto Buffer = ReadBuffer(SLocEntryCursor, Name);
1323 SourceMgr.createFileID(std::move(
Buffer), FileCharacter, ID,
1324 BaseOffset + Offset, IncludeLoc);
1330 SourceMgr.createExpansionLoc(SpellingLoc,
1331 ReadSourceLocation(*F, Record[2]),
1332 ReadSourceLocation(*F, Record[3]),
1335 BaseOffset + Record[0]);
1347 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1348 Error(
"source location entry ID out-of-range for AST file");
1353 ModuleFile *M = GlobalSLocEntryMap.find(-ID)->second;
1364 if (F->ImportLoc.isValid())
1365 return F->ImportLoc;
1369 if (F->ImportedBy.empty() || !F->ImportedBy[0]) {
1371 assert(SourceMgr.getMainFileID().isValid() &&
"missing main file");
1372 return SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
1374 return F->ImportedBy[0]->FirstLoc;
1381 if (Cursor.EnterSubBlock(BlockID))
1385 uint64_t Offset = Cursor.GetCurrentBitNo();
1386 unsigned Code = Cursor.ReadCode();
1389 if (Code != llvm::bitc::DEFINE_ABBREV) {
1390 Cursor.JumpToBit(Offset);
1393 Cursor.ReadAbbrevRecord();
1401 Tok.
setLocation(ReadSourceLocation(F, Record, Idx));
1417 Stream.JumpToBit(Offset);
1426 unsigned Flags = BitstreamCursor::AF_DontPopBlockAtEnd;
1427 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks(Flags);
1429 switch (Entry.Kind) {
1430 case llvm::BitstreamEntry::SubBlock:
1432 Error(
"malformed block record in AST file");
1434 case llvm::BitstreamEntry::EndBlock:
1436 case llvm::BitstreamEntry::Record:
1459 SubmoduleID SubModID = getGlobalSubmoduleID(F, Record[NextIndex++]);
1461 MacroInfo *MI = PP.AllocateDeserializedMacroInfo(Loc, SubModID);
1468 bool isC99VarArgs = Record[NextIndex++];
1469 bool isGNUVarArgs = Record[NextIndex++];
1470 bool hasCommaPasting = Record[NextIndex++];
1472 unsigned NumArgs = Record[NextIndex++];
1473 for (
unsigned i = 0; i !=
NumArgs; ++i)
1474 MacroArgs.push_back(getLocalIdentifier(F, Record[NextIndex++]));
1488 if (NextIndex + 1 == Record.size() && PP.getPreprocessingRecord() &&
1492 GlobalID = getGlobalPreprocessedEntityID(F, Record[NextIndex]);
1494 PreprocessingRecord::PPEntityID PPID =
1495 PPRec.getPPEntityID(GlobalID - 1,
true);
1497 PPRec.getPreprocessedEntity(PPID));
1499 PPRec.RegisterMacroDefinition(Macro, PPDef);
1512 Token Tok = ReadToken(F, Record, Idx);
1525 &&
"Invalid index into preprocessed entity index remap");
1527 return LocalID + I->second;
1531 return llvm::hash_combine(ikey.
Size, ikey.
ModTime);
1546 if (llvm::sys::path::is_absolute(a.
Filename) &&
1554 return FileMgr.
getFile(Key.Filename);
1556 std::string Resolved = Key.Filename;
1557 Reader.ResolveImportedPath(M, Resolved);
1558 return FileMgr.
getFile(Resolved);
1563 return FEA && FEA == FEB;
1566 std::pair<unsigned, unsigned>
1567 HeaderFileInfoTrait::ReadKeyDataLength(
const unsigned char*& d) {
1568 using namespace llvm::support;
1569 unsigned KeyLen = (
unsigned) endian::readNext<uint16_t, little, unaligned>(d);
1570 unsigned DataLen = (
unsigned) *d++;
1571 return std::make_pair(KeyLen, DataLen);
1575 HeaderFileInfoTrait::ReadKey(
const unsigned char *d,
unsigned) {
1576 using namespace llvm::support;
1578 ikey.
Size = off_t(endian::readNext<uint64_t, little, unaligned>(d));
1579 ikey.ModTime = time_t(endian::readNext<uint64_t, little, unaligned>(d));
1580 ikey.Filename = (
const char *)d;
1581 ikey.Imported =
true;
1588 const unsigned char *
End = d + DataLen;
1589 using namespace llvm::support;
1591 unsigned Flags = *d++;
1593 HFI.
isImport |= (Flags >> 4) & 0x01;
1594 HFI.isPragmaOnce |= (Flags >> 3) & 0x01;
1595 HFI.DirInfo = (Flags >> 1) & 0x03;
1596 HFI.IndexHeaderMapHeader = Flags & 0x01;
1599 HFI.NumIncludes =
std::max(endian::readNext<uint16_t, little, unaligned>(d),
1601 HFI.ControllingMacroID = Reader.getGlobalIdentifierID(
1602 M, endian::readNext<uint32_t, little, unaligned>(d));
1603 if (
unsigned FrameworkOffset =
1604 endian::readNext<uint32_t, little, unaligned>(d)) {
1607 StringRef FrameworkName(FrameworkStrings + FrameworkOffset - 1);
1608 HFI.Framework = HS->getUniqueFrameworkName(FrameworkName);
1611 assert((End - d) % 4 == 0 &&
1612 "Wrong data length in HeaderFileInfo deserialization");
1614 uint32_t LocalSMID = endian::readNext<uint32_t, little, unaligned>(d);
1620 SubmoduleID GlobalSMID = Reader.getGlobalSubmoduleID(M, LocalSMID);
1621 Module *Mod = Reader.getSubmodule(GlobalSMID);
1624 Reader.getPreprocessor().getHeaderSearchInfo().getModuleMap();
1628 Reader.ResolveImportedPath(M, Filename);
1633 ModMap.
addHeader(Mod, H, HeaderRole,
true);
1638 HFI.External =
true;
1645 uint64_t MacroDirectivesOffset) {
1646 assert(NumCurrentElementsDeserializing > 0 &&
"Missing deserialization guard");
1647 PendingMacroIDs[II].push_back(PendingMacroInfo(M, MacroDirectivesOffset));
1654 for (
auto &
I : llvm::reverse(ModuleMgr)) {
1655 BitstreamCursor &MacroCursor =
I->MacroCursor;
1658 if (!MacroCursor.getBitStreamReader())
1661 BitstreamCursor Cursor = MacroCursor;
1662 Cursor.JumpToBit(
I->MacroStartOffset);
1666 llvm::BitstreamEntry E = Cursor.advanceSkippingSubblocks();
1669 case llvm::BitstreamEntry::SubBlock:
1671 Error(
"malformed block record in AST file");
1673 case llvm::BitstreamEntry::EndBlock:
1676 case llvm::BitstreamEntry::Record:
1678 switch (Cursor.readRecord(E.ID, Record)) {
1686 updateOutOfDateIdentifier(*II);
1703 class IdentifierLookupVisitor {
1706 unsigned PriorGeneration;
1707 unsigned &NumIdentifierLookups;
1708 unsigned &NumIdentifierLookupHits;
1712 IdentifierLookupVisitor(StringRef
Name,
unsigned PriorGeneration,
1713 unsigned &NumIdentifierLookups,
1714 unsigned &NumIdentifierLookupHits)
1716 PriorGeneration(PriorGeneration),
1717 NumIdentifierLookups(NumIdentifierLookups),
1718 NumIdentifierLookupHits(NumIdentifierLookupHits),
1735 ++NumIdentifierLookups;
1737 IdTable->find_hashed(
Name, NameHash, &Trait);
1738 if (Pos == IdTable->end())
1744 ++NumIdentifierLookupHits;
1759 unsigned PriorGeneration = 0;
1760 if (getContext().getLangOpts().Modules)
1761 PriorGeneration = IdentifierGeneration[&II];
1767 if (!loadGlobalIndex()) {
1768 if (GlobalIndex->lookupIdentifier(II.
getName(), Hits)) {
1773 IdentifierLookupVisitor Visitor(II.
getName(), PriorGeneration,
1774 NumIdentifierLookups,
1775 NumIdentifierLookupHits);
1776 ModuleMgr.visit(Visitor, HitsPtr);
1777 markIdentifierUpToDate(&II);
1787 if (getContext().getLangOpts().Modules)
1788 IdentifierGeneration[II] = getGeneration();
1792 const PendingMacroInfo &PMInfo) {
1797 Cursor.JumpToBit(PMInfo.MacroDirectivesOffset);
1799 struct ModuleMacroRecord {
1811 llvm::BitstreamEntry Entry =
1812 Cursor.advance(BitstreamCursor::AF_DontPopBlockAtEnd);
1813 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1814 Error(
"malformed block record in AST file");
1824 ModuleMacros.push_back(ModuleMacroRecord());
1825 auto &Info = ModuleMacros.back();
1826 Info.SubModID = getGlobalSubmoduleID(M, Record[0]);
1827 Info.MI = getMacro(getGlobalMacroID(M, Record[1]));
1828 for (
int I = 2, N = Record.size();
I != N; ++
I)
1829 Info.Overrides.push_back(getGlobalSubmoduleID(M, Record[
I]));
1834 Error(
"malformed block record in AST file");
1845 std::reverse(ModuleMacros.begin(), ModuleMacros.end());
1847 for (
auto &MMR : ModuleMacros) {
1849 for (
unsigned ModID : MMR.Overrides) {
1850 Module *Mod = getSubmodule(ModID);
1851 auto *Macro = PP.getModuleMacro(Mod, II);
1852 assert(Macro &&
"missing definition for overridden macro");
1853 Overrides.push_back(Macro);
1856 bool Inserted =
false;
1857 Module *Owner = getSubmodule(MMR.SubModID);
1858 PP.addModuleMacro(Owner, II, MMR.MI, Overrides, Inserted);
1869 unsigned Idx = 0, N = Record.size();
1876 MacroInfo *MI = getMacro(getGlobalMacroID(M, Record[Idx++]));
1877 MD = PP.AllocateDefMacroDirective(MI, Loc);
1881 MD = PP.AllocateUndefMacroDirective(Loc);
1885 bool isPublic = Record[Idx++];
1886 MD = PP.AllocateVisibilityMacroDirective(Loc, isPublic);
1898 PP.setLoadedMacroDirective(II, Latest);
1901 ASTReader::InputFileInfo
1902 ASTReader::readInputFileInfo(ModuleFile &F,
unsigned ID) {
1904 BitstreamCursor &Cursor = F.InputFilesCursor;
1906 Cursor.JumpToBit(F.InputFileOffsets[ID-1]);
1908 unsigned Code = Cursor.ReadCode();
1912 unsigned Result = Cursor.readRecord(Code, Record, &Blob);
1913 assert(static_cast<InputFileRecordTypes>(Result) ==
INPUT_FILE &&
1914 "invalid record type for input file");
1917 assert(Record[0] == ID &&
"Bogus stored ID or offset");
1919 R.StoredSize =
static_cast<off_t
>(Record[1]);
1920 R.StoredTime =
static_cast<time_t
>(Record[2]);
1921 R.Overridden =
static_cast<bool>(Record[3]);
1922 R.Transient =
static_cast<bool>(Record[4]);
1924 ResolveImportedPath(F, R.Filename);
1945 InputFileInfo FI = readInputFileInfo(F, ID);
1946 off_t StoredSize = FI.StoredSize;
1947 time_t StoredTime = FI.StoredTime;
1948 bool Overridden = FI.Overridden;
1949 bool Transient = FI.Transient;
1952 const FileEntry *File = FileMgr.getFile(Filename,
false);
1956 if (File ==
nullptr && !F.
OriginalDir.empty() && !CurrentDir.empty() &&
1961 if (!Resolved.empty())
1962 File = FileMgr.getFile(Resolved);
1967 if ((Overridden || Transient) && File ==
nullptr)
1968 File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime);
1970 if (File ==
nullptr) {
1972 std::string ErrorStr =
"could not find file '";
1974 ErrorStr +=
"' referenced by AST file '";
1977 Error(ErrorStr.c_str());
1992 Error(diag::err_fe_pch_file_overridden, Filename);
2004 FileMgr.modifyFileEntry(const_cast<FileEntry*>(File),
2005 StoredSize, StoredTime);
2008 bool IsOutOfDate =
false;
2012 (StoredSize != File->
getSize() ||
2019 while (ImportStack.back()->ImportedBy.size() > 0)
2020 ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
2023 StringRef TopLevelPCHName(ImportStack.back()->FileName);
2024 Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
2027 if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
2028 Diag(diag::note_pch_required_by)
2029 << Filename << ImportStack[0]->FileName;
2030 for (
unsigned I = 1;
I < ImportStack.size(); ++
I)
2031 Diag(diag::note_pch_required_by)
2032 << ImportStack[
I-1]->FileName << ImportStack[
I]->FileName;
2035 if (!Diags.isDiagnosticInFlight())
2036 Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
2061 if (Filename.empty() || llvm::sys::path::is_absolute(Filename))
2065 llvm::sys::path::append(Buffer, Prefix, Filename);
2066 Filename.assign(Buffer.begin(), Buffer.end());
2081 llvm_unreachable(
"unknown ASTReadResult");
2085 BitstreamCursor &Stream,
unsigned ClientLoadCapabilities,
2087 std::string &SuggestedPredefines) {
2093 ASTReadResult Result =
Success;
2095 llvm::BitstreamEntry Entry = Stream.advance();
2097 switch (Entry.Kind) {
2099 case llvm::BitstreamEntry::SubBlock:
2102 case llvm::BitstreamEntry::EndBlock:
2105 case llvm::BitstreamEntry::Record:
2114 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2115 if (ParseLanguageOptions(Record, Complain, Listener,
2116 AllowCompatibleConfigurationMismatch))
2117 Result = ConfigurationMismatch;
2122 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2123 if (ParseTargetOptions(Record, Complain, Listener,
2124 AllowCompatibleConfigurationMismatch))
2125 Result = ConfigurationMismatch;
2130 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
2131 if (!AllowCompatibleConfigurationMismatch &&
2132 ParseDiagnosticOptions(Record, Complain, Listener))
2138 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2139 if (!AllowCompatibleConfigurationMismatch &&
2140 ParseFileSystemOptions(Record, Complain, Listener))
2141 Result = ConfigurationMismatch;
2146 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2147 if (!AllowCompatibleConfigurationMismatch &&
2148 ParseHeaderSearchOptions(Record, Complain, Listener))
2149 Result = ConfigurationMismatch;
2154 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2155 if (!AllowCompatibleConfigurationMismatch &&
2156 ParsePreprocessorOptions(Record, Complain, Listener,
2157 SuggestedPredefines))
2158 Result = ConfigurationMismatch;
2168 unsigned ClientLoadCapabilities) {
2169 BitstreamCursor &Stream = F.
Stream;
2170 ASTReadResult Result =
Success;
2173 Error(
"malformed block record in AST file");
2179 unsigned NumInputs = 0;
2180 unsigned NumUserInputs = 0;
2182 llvm::BitstreamEntry Entry = Stream.advance();
2184 switch (Entry.Kind) {
2186 Error(
"malformed block record in AST file");
2188 case llvm::BitstreamEntry::EndBlock: {
2191 PP.getHeaderSearchInfo().getHeaderSearchOpts();
2197 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
2203 unsigned N = NumUserInputs;
2204 if (ValidateSystemInputs ||
2210 for (
unsigned I = 0;
I < N; ++
I) {
2211 InputFile IF = getInputFile(F,
I+1, Complain);
2223 for (
unsigned I = 0;
I < N; ++
I) {
2224 bool IsSystem =
I >= NumUserInputs;
2225 InputFileInfo FI = readInputFileInfo(F,
I+1);
2234 case llvm::BitstreamEntry::SubBlock:
2238 if (Stream.SkipBlock() ||
2241 Error(
"malformed block record in AST file");
2250 if (Listener && !ImportedBy) {
2256 bool AllowCompatibleConfigurationMismatch =
2259 Result = ReadOptionsBlock(Stream, ClientLoadCapabilities,
2260 AllowCompatibleConfigurationMismatch,
2261 *Listener, SuggestedPredefines);
2262 if (Result == Failure) {
2263 Error(
"malformed block record in AST file");
2267 if (DisableValidation ||
2268 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
2274 if (Result != Success)
2276 }
else if (Stream.SkipBlock()) {
2277 Error(
"malformed block record in AST file");
2283 if (Stream.SkipBlock()) {
2284 Error(
"malformed block record in AST file");
2290 case llvm::BitstreamEntry::Record:
2301 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2303 : diag::err_pch_version_too_new);
2307 bool hasErrors = Record[6];
2308 if (hasErrors && !DisableValidation && !AllowASTWithCompilerErrors) {
2309 Diag(diag::err_pch_with_compiler_errors);
2313 Diags.ErrorOccurred =
true;
2314 Diags.UncompilableErrorOccurred =
true;
2315 Diags.UnrecoverableErrorOccurred =
true;
2326 StringRef ASTBranch = Blob;
2327 if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
2328 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2329 Diag(diag::err_pch_different_branch) << ASTBranch << CurBranch;
2342 unsigned Idx = 0, N = Record.size();
2350 ReadUntranslatedSourceLocation(Record[Idx++]);
2351 off_t StoredSize = (off_t)Record[Idx++];
2352 time_t StoredModTime = (time_t)Record[Idx++];
2354 auto ImportedFile = ReadPath(F, Record, Idx);
2358 unsigned Capabilities = ClientLoadCapabilities;
2359 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2360 Capabilities &= ~ARR_Missing;
2363 auto Result = ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F,
2364 Loaded, StoredSize, StoredModTime,
2365 StoredSignature, Capabilities);
2369 Diag(diag::note_module_file_imported_by)
2373 case Failure:
return Failure;
2376 case OutOfDate:
return OutOfDate;
2378 case ConfigurationMismatch:
return ConfigurationMismatch;
2379 case HadErrors:
return HadErrors;
2409 "MODULE_DIRECTORY found before MODULE_NAME");
2413 if (M && M->Directory) {
2418 PP.getFileManager().getDirectory(Blob);
2419 if (!BuildDir || BuildDir != M->Directory) {
2420 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2421 Diag(diag::err_imported_module_relocated)
2422 << F.
ModuleName << Blob << M->Directory->getName();
2434 if (ASTReadResult Result =
2435 ReadModuleMapFileBlock(Record, F, ImportedBy, ClientLoadCapabilities))
2440 NumInputs = Record[0];
2441 NumUserInputs = Record[1];
2443 (
const llvm::support::unaligned_uint64_t *)Blob.data();
2451 ASTReader::ReadASTBlock(
ModuleFile &F,
unsigned ClientLoadCapabilities) {
2452 BitstreamCursor &Stream = F.
Stream;
2455 Error(
"malformed block record in AST file");
2462 llvm::BitstreamEntry Entry = Stream.advance();
2464 switch (Entry.Kind) {
2466 Error(
"error at end of module block in AST file");
2468 case llvm::BitstreamEntry::EndBlock: {
2476 !getContext().getLangOpts().CPlusPlus)
2481 case llvm::BitstreamEntry::SubBlock:
2489 if (Stream.SkipBlock() ||
2492 Error(
"malformed block record in AST file");
2499 if (!PP.getExternalSource())
2500 PP.setExternalSource(
this);
2502 if (Stream.SkipBlock() ||
2504 Error(
"malformed block record in AST file");
2512 if (Stream.SkipBlock() ||
2515 Error(
"malformed preprocessor detail record in AST file");
2521 if (!PP.getPreprocessingRecord())
2522 PP.createPreprocessingRecord();
2523 if (!PP.getPreprocessingRecord()->getExternalSource())
2524 PP.getPreprocessingRecord()->SetExternalSource(*
this);
2528 if (ReadSourceManagerBlock(F))
2533 if (ASTReadResult Result = ReadSubmoduleBlock(F, ClientLoadCapabilities))
2538 BitstreamCursor
C = Stream;
2539 if (Stream.SkipBlock() ||
2541 Error(
"malformed comments block in AST file");
2544 CommentsCursors.push_back(std::make_pair(C, &F));
2549 if (Stream.SkipBlock()) {
2550 Error(
"malformed block record in AST file");
2557 case llvm::BitstreamEntry::Record:
2565 switch ((
ASTRecordTypes)Stream.readRecord(Entry.ID, Record, &Blob)) {
2571 Error(
"duplicate TYPE_OFFSET record in AST file");
2576 unsigned LocalBaseTypeIndex = Record[1];
2581 GlobalTypeMap.insert(std::make_pair(getTotalNumTypes(), &F));
2585 std::make_pair(LocalBaseTypeIndex,
2595 Error(
"duplicate DECL_OFFSET record in AST file");
2600 unsigned LocalBaseDeclID = Record[1];
2606 GlobalDeclMap.insert(
2612 std::make_pair(LocalBaseDeclID, F.
BaseDeclID - LocalBaseDeclID));
2625 LexicalContents Contents(
2626 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
2628 static_cast<unsigned int>(Blob.size() / 4));
2629 TULexicalDecls.push_back(std::make_pair(&F, Contents));
2637 auto *Data = (
const unsigned char*)Blob.data();
2638 PendingVisibleUpdates[
ID].push_back(PendingVisibleUpdate{&F, Data});
2641 if (
Decl *D = GetExistingDecl(ID))
2642 PendingUpdateRecords.push_back(std::make_pair(ID, D));
2655 PP.getIdentifierTable().setExternalIdentifierLookup(
this);
2661 Error(
"duplicate IDENTIFIER_OFFSET record in AST file");
2666 unsigned LocalBaseIdentifierID = Record[1];
2672 GlobalIdentifierMap.insert(std::make_pair(getTotalNumIdentifiers() + 1,
2678 std::make_pair(LocalBaseIdentifierID,
2681 IdentifiersLoaded.resize(IdentifiersLoaded.size()
2694 for (
unsigned I = 0, N = Record.size();
I != N; ++
I)
2695 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[
I]));
2699 if (SpecialTypes.empty()) {
2700 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
2701 SpecialTypes.push_back(getGlobalTypeID(F, Record[I]));
2705 if (SpecialTypes.size() != Record.size()) {
2706 Error(
"invalid special-types record");
2710 for (
unsigned I = 0, N = Record.size(); I != N; ++
I) {
2712 if (!SpecialTypes[I])
2713 SpecialTypes[
I] =
ID;
2720 TotalNumStatements += Record[0];
2721 TotalNumMacros += Record[1];
2722 TotalLexicalDeclContexts += Record[2];
2723 TotalVisibleDeclContexts += Record[3];
2727 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
2728 UnusedFileScopedDecls.push_back(getGlobalDeclID(F, Record[I]));
2732 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
2733 DelegatingCtorDecls.push_back(getGlobalDeclID(F, Record[I]));
2737 if (Record.size() % 4 != 0) {
2738 Error(
"invalid weak identifiers record");
2744 WeakUndeclaredIdentifiers.clear();
2747 for (
unsigned I = 0, N = Record.size(); I < N; ) {
2748 WeakUndeclaredIdentifiers.push_back(
2749 getGlobalIdentifierID(F, Record[I++]));
2750 WeakUndeclaredIdentifiers.push_back(
2751 getGlobalIdentifierID(F, Record[I++]));
2752 WeakUndeclaredIdentifiers.push_back(
2753 ReadSourceLocation(F, Record, I).getRawEncoding());
2754 WeakUndeclaredIdentifiers.push_back(Record[I++]);
2761 unsigned LocalBaseSelectorID = Record[1];
2767 GlobalSelectorMap.insert(std::make_pair(getTotalNumSelectors()+1, &F));
2772 std::make_pair(LocalBaseSelectorID,
2788 TotalNumMethodPoolEntries += Record[1];
2792 if (!Record.empty()) {
2793 for (
unsigned Idx = 0, N = Record.size() - 1; Idx < N; ) {
2794 ReferencedSelectorsData.push_back(getGlobalSelectorID(F,
2796 ReferencedSelectorsData.push_back(ReadSourceLocation(F, Record, Idx).
2803 if (!Record.empty() && Listener)
2815 unsigned SLocSpaceSize = Record[1];
2820 Error(
"ran out of source locations");
2826 unsigned RangeStart =
2828 GlobalSLocEntryMap.insert(std::make_pair(RangeStart, &F));
2833 GlobalSLocOffsetMap.insert(
2835 - SLocSpaceSize,&F));
2850 const unsigned char *Data = (
const unsigned char*)Blob.data();
2851 const unsigned char *DataEnd = Data + Blob.size();
2871 while (Data < DataEnd) {
2872 using namespace llvm::support;
2873 uint16_t Len = endian::readNext<uint16_t, little, unaligned>(Data);
2874 StringRef
Name = StringRef((
const char*)Data, Len);
2878 Error(
"SourceLocation remap refers to unknown module");
2882 uint32_t SLocOffset =
2883 endian::readNext<uint32_t, little, unaligned>(Data);
2884 uint32_t IdentifierIDOffset =
2885 endian::readNext<uint32_t, little, unaligned>(Data);
2886 uint32_t MacroIDOffset =
2887 endian::readNext<uint32_t, little, unaligned>(Data);
2888 uint32_t PreprocessedEntityIDOffset =
2889 endian::readNext<uint32_t, little, unaligned>(Data);
2890 uint32_t SubmoduleIDOffset =
2891 endian::readNext<uint32_t, little, unaligned>(Data);
2892 uint32_t SelectorIDOffset =
2893 endian::readNext<uint32_t, little, unaligned>(Data);
2894 uint32_t DeclIDOffset =
2895 endian::readNext<uint32_t, little, unaligned>(Data);
2896 uint32_t TypeIndexOffset =
2897 endian::readNext<uint32_t, little, unaligned>(Data);
2901 auto mapOffset = [&](uint32_t
Offset, uint32_t BaseOffset,
2902 RemapBuilder &Remap) {
2904 Remap.insert(std::make_pair(Offset,
2905 static_cast<int>(BaseOffset - Offset)));
2907 mapOffset(SLocOffset, OM->SLocEntryBaseOffset,
SLocRemap);
2908 mapOffset(IdentifierIDOffset, OM->BaseIdentifierID, IdentifierRemap);
2909 mapOffset(MacroIDOffset, OM->BaseMacroID, MacroRemap);
2910 mapOffset(PreprocessedEntityIDOffset, OM->BasePreprocessedEntityID,
2911 PreprocessedEntityRemap);
2912 mapOffset(SubmoduleIDOffset, OM->BaseSubmoduleID, SubmoduleRemap);
2913 mapOffset(SelectorIDOffset, OM->BaseSelectorID, SelectorRemap);
2914 mapOffset(DeclIDOffset, OM->BaseDeclID, DeclRemap);
2915 mapOffset(TypeIndexOffset, OM->BaseTypeIndex, TypeRemap);
2924 if (ParseLineTable(F, Record))
2932 Error(
"Multiple SOURCE_LOCATION_PRELOADS records in AST file");
2941 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
2942 ExtVectorDecls.push_back(getGlobalDeclID(F, Record[I]));
2946 if (Record.size() % 3 != 0) {
2947 Error(
"Invalid VTABLE_USES record");
2956 for (
unsigned Idx = 0, N = Record.size(); Idx != N; ) {
2957 VTableUses.push_back(getGlobalDeclID(F, Record[Idx++]));
2958 VTableUses.push_back(
2959 ReadSourceLocation(F, Record, Idx).getRawEncoding());
2960 VTableUses.push_back(Record[Idx++]);
2965 if (PendingInstantiations.size() % 2 != 0) {
2966 Error(
"Invalid existing PendingInstantiations");
2970 if (Record.size() % 2 != 0) {
2971 Error(
"Invalid PENDING_IMPLICIT_INSTANTIATIONS block");
2975 for (
unsigned I = 0, N = Record.size(); I != N; ) {
2976 PendingInstantiations.push_back(getGlobalDeclID(F, Record[I++]));
2977 PendingInstantiations.push_back(
2978 ReadSourceLocation(F, Record, I).getRawEncoding());
2983 if (Record.size() != 2) {
2984 Error(
"Invalid SEMA_DECL_REFS block");
2987 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
2988 SemaDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
2996 unsigned LocalBasePreprocessedEntityID = Record[0];
2998 unsigned StartingID;
2999 if (!PP.getPreprocessingRecord())
3000 PP.createPreprocessingRecord();
3001 if (!PP.getPreprocessingRecord()->getExternalSource())
3002 PP.getPreprocessingRecord()->SetExternalSource(*
this);
3004 = PP.getPreprocessingRecord()
3011 GlobalPreprocessedEntityMap.insert(std::make_pair(StartingID, &F));
3016 std::make_pair(LocalBasePreprocessedEntityID,
3024 if (Record.size() % 2 != 0) {
3025 Error(
"invalid DECL_UPDATE_OFFSETS block in AST file");
3028 for (
unsigned I = 0, N = Record.size(); I != N; I += 2) {
3030 DeclUpdateOffsets[
ID].push_back(std::make_pair(&F, Record[I + 1]));
3034 if (
Decl *D = GetExistingDecl(ID))
3035 PendingUpdateRecords.push_back(std::make_pair(ID, D));
3042 Error(
"duplicate OBJC_CATEGORIES_MAP record in AST file");
3060 Record.begin(), Record.end());
3066 CUDASpecialDeclRefs.clear();
3067 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
3068 CUDASpecialDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
3080 &PP.getHeaderSearchInfo(),
3081 Blob.data() + Record[2]));
3083 PP.getHeaderSearchInfo().SetExternalSource(
this);
3084 if (!PP.getHeaderSearchInfo().getExternalLookup())
3085 PP.getHeaderSearchInfo().SetExternalLookup(
this);
3092 FPPragmaOptions.swap(Record);
3097 OpenCLExtensions.swap(Record);
3101 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
3102 TentativeDefinitions.push_back(getGlobalDeclID(F, Record[I]));
3106 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
3107 KnownNamespaces.push_back(getGlobalDeclID(F, Record[I]));
3111 if (UndefinedButUsed.size() % 2 != 0) {
3112 Error(
"Invalid existing UndefinedButUsed");
3116 if (Record.size() % 2 != 0) {
3117 Error(
"invalid undefined-but-used record");
3120 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3121 UndefinedButUsed.push_back(getGlobalDeclID(F, Record[I++]));
3122 UndefinedButUsed.push_back(
3123 ReadSourceLocation(F, Record, I).getRawEncoding());
3127 for (
unsigned I = 0, N = Record.size(); I != N;) {
3128 DelayedDeleteExprs.push_back(getGlobalDeclID(F, Record[I++]));
3129 const uint64_t
Count = Record[I++];
3130 DelayedDeleteExprs.push_back(Count);
3131 for (uint64_t C = 0; C <
Count; ++C) {
3132 DelayedDeleteExprs.push_back(ReadSourceLocation(F, Record, I).getRawEncoding());
3133 bool IsArrayForm = Record[I++] == 1;
3134 DelayedDeleteExprs.push_back(IsArrayForm);
3144 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3145 unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
3148 ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
3156 Error(
"duplicate MACRO_OFFSET record in AST file");
3161 unsigned LocalBaseMacroID = Record[1];
3166 GlobalMacroMap.insert(std::make_pair(getTotalNumMacros() + 1, &F));
3170 std::make_pair(LocalBaseMacroID,
3179 LateParsedTemplates.append(Record.begin(), Record.end());
3184 if (Record.size() != 1) {
3185 Error(
"invalid pragma optimize record");
3188 OptimizeOffPragmaLocation = ReadSourceLocation(F, Record[0]);
3192 if (Record.size() != 1) {
3193 Error(
"invalid pragma ms_struct record");
3196 PragmaMSStructState = Record[0];
3200 if (Record.size() != 2) {
3201 Error(
"invalid pragma ms_struct record");
3204 PragmaMSPointersToMembersState = Record[0];
3205 PointersToMembersPragmaLocation = ReadSourceLocation(F, Record[1]);
3209 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
3210 UnusedLocalTypedefNameCandidates.push_back(
3211 getGlobalDeclID(F, Record[I]));
3218 ASTReader::ReadModuleMapFileBlock(RecordData &Record,
ModuleFile &F,
3220 unsigned ClientLoadCapabilities) {
3235 "MODULE_NAME should come before MODULE_MAP_FILE");
3241 auto &
Map = PP.getHeaderSearchInfo().getModuleMap();
3242 const FileEntry *ModMap = M ?
Map.getModuleMapFileForUniquing(M) :
nullptr;
3244 assert(ImportedBy &&
"top-level import should be verified");
3245 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) {
3246 if (
auto *ASTFE = M ? M->
getASTFile() :
nullptr)
3249 << ASTFE->getName();
3252 Diag(diag::err_imported_module_not_found)
3259 assert(M->
Name == F.
ModuleName &&
"found module with different name");
3263 if (StoredModMap ==
nullptr || StoredModMap != ModMap) {
3264 assert(ModMap &&
"found module is missing module map file");
3265 assert(ImportedBy &&
"top-level import should be verified");
3266 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3267 Diag(diag::err_imported_module_modmap_changed)
3273 llvm::SmallPtrSet<const FileEntry *, 1> AdditionalStoredMaps;
3274 for (
unsigned I = 0, N = Record[Idx++]; I < N; ++
I) {
3276 std::string Filename = ReadPath(F, Record, Idx);
3278 FileMgr.getFile(Filename,
false,
false);
3280 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3281 Error(
"could not find file '" + Filename +
"' referenced by AST file");
3284 AdditionalStoredMaps.insert(F);
3289 if (
auto *AdditionalModuleMaps =
Map.getAdditionalModuleMapFiles(M)) {
3290 for (
const FileEntry *ModMap : *AdditionalModuleMaps) {
3293 if (!AdditionalStoredMaps.erase(ModMap)) {
3294 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3295 Diag(diag::err_module_different_modmap)
3296 << F.ModuleName << 0 << ModMap->
getName();
3304 for (
const FileEntry *ModMap : AdditionalStoredMaps) {
3305 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3306 Diag(diag::err_module_different_modmap)
3307 << F.ModuleName << 1 << ModMap->
getName();
3328 : Known->second.second;
3332 if (List->getMethod() == Method) {
3340 if (List->getNext())
3341 List->setMethod(List->getNext()->getMethod());
3343 List->setMethod(Method);
3349 for (
Decl *D : Names) {
3350 bool wasHidden = D->Hidden;
3353 if (wasHidden && SemaObj) {
3364 llvm::SmallPtrSet<Module *, 4> Visited;
3366 Stack.push_back(Mod);
3367 while (!Stack.empty()) {
3368 Mod = Stack.pop_back_val();
3370 if (NameVisibility <= Mod->NameVisibility) {
3387 if (Hidden != HiddenNamesMap.end()) {
3389 HiddenNamesMap.erase(Hidden);
3391 assert(HiddenNamesMap.find(Mod) == HiddenNamesMap.end() &&
3392 "making names visible added hidden names");
3399 I = Exports.begin(), E = Exports.end(); I !=
E; ++
I) {
3401 if (Visited.insert(Exported).second)
3402 Stack.push_back(Exported);
3411 if (TriedLoadingGlobalIndex || !UseGlobalIndex ||
3416 TriedLoadingGlobalIndex =
true;
3417 StringRef ModuleCachePath
3418 = getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
3419 std::pair<GlobalModuleIndex *, GlobalModuleIndex::ErrorCode> Result
3424 GlobalIndex.reset(Result.first);
3425 ModuleMgr.setGlobalIndex(GlobalIndex.get());
3431 !hasGlobalIndex() && TriedLoadingGlobalIndex;
3438 llvm::raw_fd_ostream OS(TimestampFilename, EC, llvm::sys::fs::F_Text);
3441 OS <<
"Timestamp file\n";
3449 llvm::BitstreamEntry Entry = Cursor.advance();
3450 switch (Entry.Kind) {
3452 case llvm::BitstreamEntry::EndBlock:
3455 case llvm::BitstreamEntry::Record:
3457 Cursor.skipRecord(Entry.ID);
3460 case llvm::BitstreamEntry::SubBlock:
3461 if (Entry.ID == BlockID) {
3462 if (Cursor.EnterSubBlock(BlockID))
3468 if (Cursor.SkipBlock())
3477 unsigned ClientLoadCapabilities) {
3479 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
3485 unsigned PreviousGeneration = incrementGeneration(
Context);
3487 unsigned NumModules = ModuleMgr.size();
3489 switch(
ASTReadResult ReadResult = ReadASTCore(FileName, Type, ImportLoc,
3492 ClientLoadCapabilities)) {
3496 case VersionMismatch:
3497 case ConfigurationMismatch:
3499 llvm::SmallPtrSet<ModuleFile *, 4> LoadedSet;
3500 for (
const ImportedModule &IM : Loaded)
3501 LoadedSet.insert(IM.Mod);
3503 ModuleMgr.removeModules(ModuleMgr.begin() + NumModules, ModuleMgr.end(),
3506 ? &PP.getHeaderSearchInfo().getModuleMap()
3511 GlobalIndex.reset();
3512 ModuleMgr.setGlobalIndex(
nullptr);
3523 MEnd = Loaded.end();
3528 if (
ASTReadResult Result = ReadASTBlock(F, ClientLoadCapabilities))
3550 SourceMgr.getLoadedSLocEntryByID(Index);
3556 const unsigned char *Data =
reinterpret_cast<const unsigned char *
>(
3561 auto Key = Trait.
ReadKey(Data, KeyDataLen.first);
3562 auto &II = PP.getIdentifierTable().getOwn(Key);
3563 II.setOutOfDate(
true);
3571 SetIdentifierInfo(ID, &II);
3578 MEnd = Loaded.end();
3582 ModuleMgr.moduleFileAccepted(&F);
3591 F.
ImportLoc = TranslateSourceLocation(*M->ImportedBy, M->ImportLoc);
3604 IdEnd = PP.getIdentifierTable().end();
3606 Id->second->setOutOfDate(
true);
3609 for (
auto Sel : SelectorGeneration)
3610 SelectorOutOfDate[Sel.first] =
true;
3613 for (
unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++
I) {
3614 UnresolvedModuleRef &Unresolved = UnresolvedModuleRefs[
I];
3615 SubmoduleID GlobalID = getGlobalSubmoduleID(*Unresolved.File,Unresolved.ID);
3616 Module *ResolvedMod = getSubmodule(GlobalID);
3618 switch (Unresolved.Kind) {
3619 case UnresolvedModuleRef::Conflict:
3622 Conflict.
Other = ResolvedMod;
3623 Conflict.
Message = Unresolved.String.str();
3624 Unresolved.Mod->Conflicts.push_back(Conflict);
3628 case UnresolvedModuleRef::Import:
3630 Unresolved.Mod->Imports.insert(ResolvedMod);
3633 case UnresolvedModuleRef::Export:
3634 if (ResolvedMod || Unresolved.IsWildcard)
3635 Unresolved.Mod->Exports.push_back(
3640 UnresolvedModuleRefs.clear();
3646 InitializeContext();
3651 if (DeserializationListener)
3652 DeserializationListener->ReaderInitialized(
this);
3654 ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule();
3672 for (
unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++
I) {
3673 loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
3674 ObjCClassesLoaded[I],
3675 PreviousGeneration);
3678 if (PP.getHeaderSearchInfo()
3679 .getHeaderSearchOpts()
3680 .ModulesValidateOncePerBuildSession) {
3685 for (
unsigned I = 0, N = Loaded.size(); I != N; ++
I) {
3686 ImportedModule &M = Loaded[
I];
3700 return Stream.Read(8) ==
'C' &&
3701 Stream.Read(8) ==
'P' &&
3702 Stream.Read(8) ==
'C' &&
3703 Stream.Read(8) ==
'H';
3717 llvm_unreachable(
"unknown module kind");
3721 ASTReader::ReadASTCore(StringRef
FileName,
3726 off_t ExpectedSize, time_t ExpectedModTime,
3728 unsigned ClientLoadCapabilities) {
3730 std::string ErrorStr;
3732 = ModuleMgr.addModule(FileName, Type, ImportLoc, ImportedBy,
3733 getGeneration(), ExpectedSize, ExpectedModTime,
3737 switch (AddResult) {
3748 if (ClientLoadCapabilities & ARR_Missing)
3753 << FileName << ErrorStr.empty()
3760 if (ClientLoadCapabilities & ARR_OutOfDate)
3765 << FileName << ErrorStr.empty()
3770 assert(M &&
"Missing module file");
3774 if (FileName !=
"-") {
3775 CurrentDir = llvm::sys::path::parent_path(FileName);
3776 if (CurrentDir.empty()) CurrentDir =
".";
3780 BitstreamCursor &Stream = F.
Stream;
3793 bool HaveReadControlBlock =
false;
3795 llvm::BitstreamEntry Entry = Stream.advance();
3797 switch (Entry.Kind) {
3799 case llvm::BitstreamEntry::Record:
3800 case llvm::BitstreamEntry::EndBlock:
3801 Error(
"invalid record at top-level of AST file");
3804 case llvm::BitstreamEntry::SubBlock:
3810 HaveReadControlBlock =
true;
3811 switch (ReadControlBlock(F, Loaded, ImportedBy, ClientLoadCapabilities)) {
3820 if (Result != OutOfDate ||
3821 (ClientLoadCapabilities & ARR_OutOfDate) == 0)
3827 case Failure:
return Failure;
3828 case Missing:
return Missing;
3829 case OutOfDate:
return OutOfDate;
3831 case ConfigurationMismatch:
return ConfigurationMismatch;
3832 case HadErrors:
return HadErrors;
3837 if (!HaveReadControlBlock) {
3838 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
3839 Diag(diag::err_pch_version_too_old);
3844 Loaded.push_back(ImportedModule(M, ImportedBy, ImportLoc));
3848 if (Stream.SkipBlock()) {
3849 Error(
"malformed block record in AST file");
3864 if (Record.size() < 4)
return true;
3869 unsigned BlockNameLen = Record[2];
3870 unsigned UserInfoLen = Record[3];
3872 if (BlockNameLen + UserInfoLen > Blob.size())
return true;
3874 Metadata.
BlockName = std::string(Blob.data(), Blob.data() + BlockNameLen);
3875 Metadata.
UserInfo = std::string(Blob.data() + BlockNameLen,
3876 Blob.data() + BlockNameLen + UserInfoLen);
3881 BitstreamCursor &Stream = F.
Stream;
3885 llvm::BitstreamEntry Entry = Stream.advance();
3886 switch (Entry.Kind) {
3887 case llvm::BitstreamEntry::SubBlock:
3888 if (Stream.SkipBlock())
3893 case llvm::BitstreamEntry::EndBlock:
3899 case llvm::BitstreamEntry::Record:
3905 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
3913 auto Known = ModuleFileExtensions.find(Metadata.
BlockName);
3914 if (Known == ModuleFileExtensions.end())
break;
3917 if (
auto Reader = Known->second->createExtensionReader(Metadata, *
this,
3932 if (DeserializationListener)
3942 if (!
Context.CFConstantStringTypeDecl)
3949 Error(
"FILE type is NULL");
3959 Error(
"Invalid FILE type in AST file");
3968 QualType Jmp_bufType = GetType(Jmp_buf);
3969 if (Jmp_bufType.
isNull()) {
3970 Error(
"jmp_buf type is NULL");
3980 Error(
"Invalid jmp_buf type in AST file");
3989 QualType Sigjmp_bufType = GetType(Sigjmp_buf);
3990 if (Sigjmp_bufType.
isNull()) {
3991 Error(
"sigjmp_buf type is NULL");
3995 if (!
Context.sigjmp_bufDecl) {
4000 assert(Tag &&
"Invalid sigjmp_buf type in AST file");
4006 if (
unsigned ObjCIdRedef
4009 Context.ObjCIdRedefinitionType = GetType(ObjCIdRedef);
4012 if (
unsigned ObjCClassRedef
4015 Context.ObjCClassRedefinitionType = GetType(ObjCClassRedef);
4018 if (
unsigned ObjCSelRedef
4021 Context.ObjCSelRedefinitionType = GetType(ObjCSelRedef);
4025 QualType Ucontext_tType = GetType(Ucontext_t);
4026 if (Ucontext_tType.
isNull()) {
4027 Error(
"ucontext_t type is NULL");
4031 if (!
Context.ucontext_tDecl) {
4036 assert(Tag &&
"Invalid ucontext_t type in AST file");
4046 if (!CUDASpecialDeclRefs.empty()) {
4047 assert(CUDASpecialDeclRefs.size() == 1 &&
"More decl refs than expected!");
4049 cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
4054 for (
auto &Import : ImportedModules) {
4055 if (
Module *Imported = getSubmodule(Import.ID)) {
4058 if (Import.ImportLoc.isValid())
4059 PP.makeModuleVisible(Imported, Import.ImportLoc);
4063 ImportedModules.clear();
4073 BitstreamCursor Stream(StreamFile);
4084 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
4085 if (Entry.Kind == llvm::BitstreamEntry::EndBlock ||
4086 Entry.Kind != llvm::BitstreamEntry::Record)
4091 if (
SIGNATURE == Stream.readRecord(Entry.ID, Record, &Blob))
4100 const std::string &ASTFileName,
FileManager &FileMgr,
4105 Diags.
Report(diag::err_fe_unable_to_read_pch_file)
4106 << ASTFileName <<
Buffer.getError().message();
4107 return std::string();
4111 llvm::BitstreamReader StreamFile;
4112 PCHContainerRdr.
ExtractPCH((*Buffer)->getMemBufferRef(), StreamFile);
4113 BitstreamCursor Stream(StreamFile);
4117 Diags.
Report(diag::err_fe_not_a_pch_file) << ASTFileName;
4118 return std::string();
4123 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
4124 return std::string();
4130 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
4131 if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
4132 return std::string();
4134 if (Entry.Kind != llvm::BitstreamEntry::Record) {
4135 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
4136 return std::string();
4141 if (Stream.readRecord(Entry.ID, Record, &Blob) ==
ORIGINAL_FILE)
4151 std::string ExistingModuleCachePath;
4155 SimplePCHValidator(
const LangOptions &ExistingLangOpts,
4158 StringRef ExistingModuleCachePath,
4160 : ExistingLangOpts(ExistingLangOpts),
4161 ExistingTargetOpts(ExistingTargetOpts),
4162 ExistingPPOpts(ExistingPPOpts),
4163 ExistingModuleCachePath(ExistingModuleCachePath),
4168 bool ReadLanguageOptions(
const LangOptions &LangOpts,
bool Complain,
4169 bool AllowCompatibleDifferences)
override {
4171 AllowCompatibleDifferences);
4173 bool ReadTargetOptions(
const TargetOptions &TargetOpts,
bool Complain,
4174 bool AllowCompatibleDifferences)
override {
4176 AllowCompatibleDifferences);
4179 StringRef SpecificModuleCachePath,
4180 bool Complain)
override {
4182 ExistingModuleCachePath,
4183 nullptr, ExistingLangOpts);
4187 std::string &SuggestedPredefines)
override {
4189 SuggestedPredefines, ExistingLangOpts);
4197 bool FindModuleFileExtensions,
4208 llvm::BitstreamReader StreamFile;
4209 PCHContainerRdr.
ExtractPCH((*Buffer)->getMemBufferRef(), StreamFile);
4210 BitstreamCursor Stream(StreamFile);
4223 BitstreamCursor InputFilesCursor;
4226 std::string ModuleDir;
4227 bool DoneWithControlBlock =
false;
4228 while (!DoneWithControlBlock) {
4229 llvm::BitstreamEntry Entry = Stream.advance();
4231 switch (Entry.Kind) {
4232 case llvm::BitstreamEntry::SubBlock: {
4235 std::string IgnoredSuggestedPredefines;
4236 if (ReadOptionsBlock(Stream, ARR_ConfigurationMismatch | ARR_OutOfDate,
4238 Listener, IgnoredSuggestedPredefines) != Success)
4244 InputFilesCursor = Stream;
4245 if (Stream.SkipBlock() ||
4252 if (Stream.SkipBlock())
4260 case llvm::BitstreamEntry::EndBlock:
4261 DoneWithControlBlock =
true;
4267 case llvm::BitstreamEntry::Record:
4271 if (DoneWithControlBlock)
break;
4275 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4294 auto Path = ReadString(Record, Idx);
4295 ResolveImportedPath(Path, ModuleDir);
4300 if (!NeedsInputFiles)
4303 unsigned NumInputFiles = Record[0];
4304 unsigned NumUserFiles = Record[1];
4305 const uint64_t *InputFileOffs = (
const uint64_t *)Blob.data();
4306 for (
unsigned I = 0; I != NumInputFiles; ++
I) {
4308 bool isSystemFile = I >= NumUserFiles;
4310 if (isSystemFile && !NeedsSystemInputFiles)
4313 BitstreamCursor &Cursor = InputFilesCursor;
4315 Cursor.JumpToBit(InputFileOffs[I]);
4317 unsigned Code = Cursor.ReadCode();
4320 bool shouldContinue =
false;
4323 bool Overridden =
static_cast<bool>(Record[3]);
4324 std::string Filename = Blob;
4325 ResolveImportedPath(Filename, ModuleDir);
4327 Filename, isSystemFile, Overridden,
false);
4330 if (!shouldContinue)
4340 unsigned Idx = 0, N = Record.size();
4344 std::string Filename = ReadString(Record, Idx);
4345 ResolveImportedPath(Filename, ModuleDir);
4358 if (FindModuleFileExtensions) {
4360 bool DoneWithExtensionBlock =
false;
4361 while (!DoneWithExtensionBlock) {
4362 llvm::BitstreamEntry Entry = Stream.advance();
4364 switch (Entry.Kind) {
4365 case llvm::BitstreamEntry::SubBlock:
4366 if (Stream.SkipBlock())
4371 case llvm::BitstreamEntry::EndBlock:
4372 DoneWithExtensionBlock =
true;
4378 case llvm::BitstreamEntry::Record:
4384 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4406 std::string ExistingModuleCachePath) {
4407 SimplePCHValidator validator(LangOpts, TargetOpts, PPOpts,
4408 ExistingModuleCachePath, FileMgr);
4409 return !readASTFileControlBlock(Filename, FileMgr, PCHContainerRdr,
4415 ASTReader::ReadSubmoduleBlock(ModuleFile &F,
unsigned ClientLoadCapabilities) {
4418 Error(
"malformed submodule block record in AST file");
4422 ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
4424 Module *CurrentModule =
nullptr;
4427 llvm::BitstreamEntry Entry = F.Stream.advanceSkippingSubblocks();
4429 switch (Entry.Kind) {
4430 case llvm::BitstreamEntry::SubBlock:
4432 Error(
"malformed block record in AST file");
4434 case llvm::BitstreamEntry::EndBlock:
4436 case llvm::BitstreamEntry::Record:
4444 auto Kind = F.Stream.readRecord(Entry.ID, Record, &Blob);
4447 Error(
"submodule metadata record should be at beginning of block");
4463 if (Record.size() < 8) {
4464 Error(
"malformed module definition");
4468 StringRef
Name = Blob;
4470 SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);
4471 SubmoduleID Parent = getGlobalSubmoduleID(F, Record[Idx++]);
4472 bool IsFramework = Record[Idx++];
4473 bool IsExplicit = Record[Idx++];
4474 bool IsSystem = Record[Idx++];
4475 bool IsExternC = Record[Idx++];
4476 bool InferSubmodules = Record[Idx++];
4477 bool InferExplicitSubmodules = Record[Idx++];
4478 bool InferExportWildcard = Record[Idx++];
4479 bool ConfigMacrosExhaustive = Record[Idx++];
4481 Module *ParentModule =
nullptr;
4483 ParentModule = getSubmodule(Parent);
4494 if (GlobalIndex >= SubmodulesLoaded.size() ||
4495 SubmodulesLoaded[GlobalIndex]) {
4496 Error(
"too many submodules");
4500 if (!ParentModule) {
4502 if (CurFile != F.File) {
4503 if (!Diags.isDiagnosticInFlight()) {
4504 Diag(diag::err_module_file_conflict)
4506 << CurFile->getName()
4507 << F.File->getName();
4524 if (DeserializationListener)
4525 DeserializationListener->ModuleRead(GlobalID, CurrentModule);
4527 SubmodulesLoaded[GlobalIndex] = CurrentModule;
4549 std::string Filename = Blob;
4550 ResolveImportedPath(F, Filename);
4551 if (
auto *Umbrella = PP.getFileManager().getFile(Filename)) {
4587 std::string Dirname = Blob;
4588 ResolveImportedPath(F, Dirname);
4589 if (
auto *Umbrella = PP.getFileManager().getDirectory(Dirname)) {
4593 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
4594 Error(
"mismatched umbrella directories in submodule");
4602 F.BaseSubmoduleID = getTotalNumSubmodules();
4603 F.LocalNumSubmodules = Record[0];
4604 unsigned LocalBaseSubmoduleID = Record[1];
4605 if (F.LocalNumSubmodules > 0) {
4608 GlobalSubmoduleMap.insert(std::make_pair(getTotalNumSubmodules()+1,&F));
4612 F.SubmoduleRemap.insertOrReplace(
4613 std::make_pair(LocalBaseSubmoduleID,
4614 F.BaseSubmoduleID - LocalBaseSubmoduleID));
4616 SubmodulesLoaded.resize(SubmodulesLoaded.size() + F.LocalNumSubmodules);
4622 for (
unsigned Idx = 0; Idx != Record.size(); ++Idx) {
4623 UnresolvedModuleRef Unresolved;
4624 Unresolved.File = &F;
4625 Unresolved.Mod = CurrentModule;
4626 Unresolved.ID = Record[Idx];
4627 Unresolved.Kind = UnresolvedModuleRef::Import;
4628 Unresolved.IsWildcard =
false;
4629 UnresolvedModuleRefs.push_back(Unresolved);
4635 for (
unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
4636 UnresolvedModuleRef Unresolved;
4637 Unresolved.File = &F;
4638 Unresolved.Mod = CurrentModule;
4639 Unresolved.ID = Record[Idx];
4640 Unresolved.Kind = UnresolvedModuleRef::Export;
4641 Unresolved.IsWildcard = Record[Idx + 1];
4642 UnresolvedModuleRefs.push_back(Unresolved);
4666 UnresolvedModuleRef Unresolved;
4667 Unresolved.File = &F;
4668 Unresolved.Mod = CurrentModule;
4669 Unresolved.ID = Record[0];
4670 Unresolved.Kind = UnresolvedModuleRef::Conflict;
4671 Unresolved.IsWildcard =
false;
4672 Unresolved.String = Blob;
4673 UnresolvedModuleRefs.push_back(Unresolved);
4687 bool ASTReader::ParseLanguageOptions(
const RecordData &Record,
4690 bool AllowCompatibleDifferences) {
4693 #define LANGOPT(Name, Bits, Default, Description) \
4694 LangOpts.Name = Record[Idx++];
4695 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
4696 LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++]));
4697 #include "clang/Basic/LangOptions.def"
4698 #define SANITIZER(NAME, ID) \
4699 LangOpts.Sanitize.set(SanitizerKind::ID, Record[Idx++]);
4700 #include "clang/Basic/Sanitizers.def"
4702 for (
unsigned N = Record[Idx++]; N; --N)
4706 VersionTuple runtimeVersion = ReadVersionTuple(Record, Idx);
4712 for (
unsigned N = Record[Idx++]; N; --N) {
4714 ReadString(Record, Idx));
4719 for (
unsigned N = Record[Idx++]; N; --N) {
4720 LangOpts.
OMPTargetTriples.push_back(llvm::Triple(ReadString(Record, Idx)));
4726 AllowCompatibleDifferences);
4729 bool ASTReader::ParseTargetOptions(
const RecordData &Record,
bool Complain,
4731 bool AllowCompatibleDifferences) {
4734 TargetOpts.
Triple = ReadString(Record, Idx);
4735 TargetOpts.
CPU = ReadString(Record, Idx);
4736 TargetOpts.
ABI = ReadString(Record, Idx);
4737 for (
unsigned N = Record[Idx++]; N; --N) {
4740 for (
unsigned N = Record[Idx++]; N; --N) {
4741 TargetOpts.
Features.push_back(ReadString(Record, Idx));
4745 AllowCompatibleDifferences);
4748 bool ASTReader::ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
4752 #define DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++];
4753 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
4754 DiagOpts->set##Name(static_cast<Type>(Record[Idx++]));
4755 #include "clang/Basic/DiagnosticOptions.def"
4757 for (
unsigned N = Record[Idx++]; N; --N)
4758 DiagOpts->Warnings.push_back(ReadString(Record, Idx));
4759 for (
unsigned N = Record[Idx++]; N; --N)
4760 DiagOpts->Remarks.push_back(ReadString(Record, Idx));
4765 bool ASTReader::ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
4773 bool ASTReader::ParseHeaderSearchOptions(
const RecordData &Record,
4778 HSOpts.
Sysroot = ReadString(Record, Idx);
4781 for (
unsigned N = Record[Idx++]; N; --N) {
4782 std::string Path = ReadString(Record, Idx);
4785 bool IsFramework = Record[Idx++];
4786 bool IgnoreSysRoot = Record[Idx++];
4787 HSOpts.
UserEntries.emplace_back(std::move(Path), Group, IsFramework,
4792 for (
unsigned N = Record[Idx++]; N; --N) {
4793 std::string Prefix = ReadString(Record, Idx);
4794 bool IsSystemHeader = Record[Idx++];
4806 std::string SpecificModuleCachePath = ReadString(Record, Idx);
4812 bool ASTReader::ParsePreprocessorOptions(
const RecordData &Record,
4815 std::string &SuggestedPredefines) {
4820 for (
unsigned N = Record[Idx++]; N; --N) {
4821 std::string
Macro = ReadString(Record, Idx);
4822 bool IsUndef = Record[Idx++];
4823 PPOpts.
Macros.push_back(std::make_pair(Macro, IsUndef));
4827 for (
unsigned N = Record[Idx++]; N; --N) {
4828 PPOpts.
Includes.push_back(ReadString(Record, Idx));
4832 for (
unsigned N = Record[Idx++]; N; --N) {
4842 SuggestedPredefines.clear();
4844 SuggestedPredefines);
4847 std::pair<ModuleFile *, unsigned>
4848 ASTReader::getModulePreprocessedEntity(
unsigned GlobalIndex) {
4850 I = GlobalPreprocessedEntityMap.find(GlobalIndex);
4851 assert(I != GlobalPreprocessedEntityMap.end() &&
4852 "Corrupted global preprocessed entity map");
4854 unsigned LocalIndex = GlobalIndex - M->BasePreprocessedEntityID;
4855 return std::make_pair(M, LocalIndex);
4858 llvm::iterator_range<PreprocessingRecord::iterator>
4859 ASTReader::getModulePreprocessedEntities(
ModuleFile &Mod)
const {
4868 llvm::iterator_range<ASTReader::ModuleDeclIterator>
4869 ASTReader::getModuleFileLevelDecls(
ModuleFile &Mod) {
4870 return llvm::make_range(
4872 ModuleDeclIterator(
this, &Mod,
4878 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
4880 unsigned LocalIndex = PPInfo.second;
4883 if (!PP.getPreprocessingRecord()) {
4884 Error(
"no preprocessing record");
4891 llvm::BitstreamEntry Entry =
4893 if (Entry.Kind != llvm::BitstreamEntry::Record)
4898 TranslateSourceLocation(M, PPOffs.
getEnd()));
4904 Entry.ID, Record, &Blob);
4907 bool isBuiltin = Record[0];
4911 Name = getLocalIdentifier(M, Record[1]);
4914 getGlobalPreprocessedEntityID(M, Record[1]);
4915 Def = cast<MacroDefinitionRecord>(
4916 PPRec.getLoadedPreprocessedEntity(GlobalID - 1));
4934 if (DeserializationListener)
4935 DeserializationListener->MacroDefinitionRead(PPID, MD);
4941 const char *FullFileNameStart = Blob.data() + Record[0];
4942 StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]);
4944 if (!FullFileName.empty())
4945 File = PP.getFileManager().getFile(FullFileName);
4952 StringRef(Blob.data(), Record[0]),
4953 Record[1], Record[3],
4960 llvm_unreachable(
"Invalid PreprocessorDetailRecordTypes");
4968 GlobalSLocOffsetMapType::const_iterator SLocMapI)
const {
4970 for (GlobalSLocOffsetMapType::const_iterator
4971 EndI = GlobalSLocOffsetMap.end(); SLocMapI != EndI; ++SLocMapI) {
4972 ModuleFile &M = *SLocMapI->second;
4973 if (M.NumPreprocessedEntities)
4977 return getTotalNumPreprocessedEntities();
4982 struct PPEntityComp {
4991 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
4996 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
5001 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
5005 return Reader.TranslateSourceLocation(M, PPE.
getBegin());
5012 bool EndsAfter)
const {
5013 if (SourceMgr.isLocalSourceLocation(Loc))
5014 return getTotalNumPreprocessedEntities();
5016 GlobalSLocOffsetMapType::const_iterator SLocMapI = GlobalSLocOffsetMap.find(
5017 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
5018 assert(SLocMapI != GlobalSLocOffsetMap.end() &&
5019 "Corrupted global sloc offset map");
5021 if (SLocMapI->second->NumPreprocessedEntities == 0)
5022 return findNextPreprocessedEntity(SLocMapI);
5031 pp_iterator First = pp_begin;
5035 PPI = std::upper_bound(pp_begin, pp_end, Loc,
5036 PPEntityComp(*
this, M));
5045 std::advance(PPI, Half);
5046 if (SourceMgr.isBeforeInTranslationUnit(
5047 TranslateSourceLocation(M, PPI->getEnd()), Loc)) {
5050 Count = Count - Half - 1;
5057 return findNextPreprocessedEntity(SLocMapI);
5064 std::pair<unsigned, unsigned>
5067 return std::make_pair(0,0);
5068 assert(!SourceMgr.isBeforeInTranslationUnit(Range.
getEnd(),Range.
getBegin()));
5071 findPreprocessedEntity(Range.
getBegin(),
false);
5073 return std::make_pair(BeginID, EndID);
5083 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
5085 unsigned LocalIndex = PPInfo.second;
5092 if (SourceMgr.isInFileID(SourceMgr.getFileLoc(Loc), FID))
5100 class HeaderFileInfoVisitor {
5106 explicit HeaderFileInfoVisitor(
const FileEntry *FE)
5117 if (Pos == Table->end())
5129 HeaderFileInfoVisitor Visitor(FE);
5130 ModuleMgr.visit(Visitor);
5140 for (
ModuleIterator I = ModuleMgr.begin(), E = ModuleMgr.end(); I !=
E; ++
I) {
5144 assert(!Diag.DiagStates.empty());
5145 DiagStates.push_back(&Diag.DiagStates.front());
5149 if (DiagStateID != 0) {
5150 Diag.DiagStatePoints.push_back(
5151 DiagnosticsEngine::DiagStatePoint(DiagStates[DiagStateID-1],
5156 assert(DiagStateID == 0);
5158 Diag.DiagStates.push_back(*Diag.GetCurDiagState());
5159 DiagnosticsEngine::DiagState *NewState = &Diag.DiagStates.back();
5160 DiagStates.push_back(NewState);
5161 Diag.DiagStatePoints.push_back(
5162 DiagnosticsEngine::DiagStatePoint(NewState,
5166 "Invalid data, didn't find '-1' marking end of diag/map pairs");
5172 if (DiagID == (
unsigned)-1) {
5177 Diag.GetCurDiagState()->setMapping(DiagID, Mapping);
5184 ASTReader::RecordLocation ASTReader::TypeCursorForIndex(
unsigned Index) {
5186 assert(I != GlobalTypeMap.end() &&
"Corrupted global type map");
5187 ModuleFile *M = I->second;
5188 return RecordLocation(M, M->TypeOffsets[Index - M->BaseTypeIndex]);
5197 QualType ASTReader::readTypeRecord(
unsigned Index) {
5198 RecordLocation Loc = TypeCursorForIndex(Index);
5199 BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
5205 ReadingKindTracker ReadingKind(Read_Type, *
this);
5208 Deserializing AType(
this);
5211 DeclsCursor.JumpToBit(Loc.Offset);
5213 unsigned Code = DeclsCursor.ReadCode();
5214 switch ((
TypeCode)DeclsCursor.readRecord(Code, Record)) {
5216 if (Record.size() != 2) {
5217 Error(
"Incorrect encoding of extended qualifier type");
5226 if (Record.size() != 1) {
5227 Error(
"Incorrect encoding of complex type");
5230 QualType ElemType = readType(*Loc.F, Record, Idx);
5235 if (Record.size() != 1) {
5236 Error(
"Incorrect encoding of pointer type");
5239 QualType PointeeType = readType(*Loc.F, Record, Idx);
5244 if (Record.size() != 1) {
5245 Error(
"Incorrect encoding of decayed type");
5248 QualType OriginalType = readType(*Loc.F, Record, Idx);
5250 if (!isa<DecayedType>(DT))
5251 Error(
"Decayed type does not decay");
5256 if (Record.size() != 2) {
5257 Error(
"Incorrect encoding of adjusted type");
5260 QualType OriginalTy = readType(*Loc.F, Record, Idx);
5261 QualType AdjustedTy = readType(*Loc.F, Record, Idx);
5266 if (Record.size() != 1) {
5267 Error(
"Incorrect encoding of block pointer type");
5270 QualType PointeeType = readType(*Loc.F, Record, Idx);
5275 if (Record.size() != 2) {
5276 Error(
"Incorrect encoding of lvalue reference type");
5279 QualType PointeeType = readType(*Loc.F, Record, Idx);
5284 if (Record.size() != 1) {
5285 Error(
"Incorrect encoding of rvalue reference type");
5288 QualType PointeeType = readType(*Loc.F, Record, Idx);
5293 if (Record.size() != 2) {
5294 Error(
"Incorrect encoding of member pointer type");
5297 QualType PointeeType = readType(*Loc.F, Record, Idx);
5298 QualType ClassType = readType(*Loc.F, Record, Idx);
5306 QualType ElementType = readType(*Loc.F, Record, Idx);
5308 unsigned IndexTypeQuals = Record[2];
5310 llvm::APInt Size = ReadAPInt(Record, Idx);
5312 ASM, IndexTypeQuals);
5316 QualType ElementType = readType(*Loc.F, Record, Idx);
5318 unsigned IndexTypeQuals = Record[2];
5323 QualType ElementType = readType(*Loc.F, Record, Idx);
5325 unsigned IndexTypeQuals = Record[2];
5329 ASM, IndexTypeQuals,
5334 if (Record.size() != 3) {
5335 Error(
"incorrect encoding of vector type in AST file");
5339 QualType ElementType = readType(*Loc.F, Record, Idx);
5340 unsigned NumElements = Record[1];
5341 unsigned VecKind = Record[2];
5347 if (Record.size() != 3) {
5348 Error(
"incorrect encoding of extended vector type in AST file");
5352 QualType ElementType = readType(*Loc.F, Record, Idx);
5353 unsigned NumElements = Record[1];
5358 if (Record.size() != 6) {
5359 Error(
"incorrect encoding of no-proto function type");
5362 QualType ResultType = readType(*Loc.F, Record, Idx);
5369 QualType ResultType = readType(*Loc.F, Record, Idx);
5375 static_cast<CallingConv>(Record[4]),
5385 readExceptionSpec(*Loc.F, ExceptionStorage, EPI.
ExceptionSpec, Record, Idx);
5387 unsigned NumParams = Record[Idx++];
5389 for (
unsigned I = 0; I != NumParams; ++
I)
5390 ParamTypes.push_back(readType(*Loc.F, Record, Idx));
5393 if (Idx != Record.size()) {
5394 for (
unsigned I = 0; I != NumParams; ++
I)
5395 ExtParameterInfos.push_back(
5397 ::getFromOpaqueValue(Record[Idx++]));
5401 assert(Idx == Record.size());
5409 ReadDeclAs<UnresolvedUsingTypenameDecl>(*Loc.F, Record, Idx));
5413 if (Record.size() != 2) {
5414 Error(
"incorrect encoding of typedef type");
5419 QualType Canonical = readType(*Loc.F, Record, Idx);
5420 if (!Canonical.isNull())
5429 if (Record.size() != 1) {
5430 Error(
"incorrect encoding of typeof(type) in AST file");
5433 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
5438 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
5443 QualType BaseType = readType(*Loc.F, Record, Idx);
5444 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
5450 QualType Deduced = readType(*Loc.F, Record, Idx);
5452 bool IsDependent = Deduced.
isNull() ? Record[Idx++] :
false;
5457 if (Record.size() != 2) {
5458 Error(
"incorrect encoding of record type");
5462 bool IsDependent = Record[Idx++];
5463 RecordDecl *RD = ReadDeclAs<RecordDecl>(*Loc.F, Record, Idx);
5464 RD = cast_or_null<RecordDecl>(RD->getCanonicalDecl());
5466 const_cast<Type*
>(T.getTypePtr())->setDependent(IsDependent);
5471 if (Record.size() != 2) {
5472 Error(
"incorrect encoding of enum type");
5476 bool IsDependent = Record[Idx++];
5479 const_cast<Type*
>(T.
getTypePtr())->setDependent(IsDependent);
5484 if (Record.size() != 3) {
5485 Error(
"incorrect encoding of attributed type");
5488 QualType modifiedType = readType(*Loc.F, Record, Idx);
5489 QualType equivalentType = readType(*Loc.F, Record, Idx);
5495 if (Record.size() != 1) {
5496 Error(
"incorrect encoding of paren type");
5499 QualType InnerType = readType(*Loc.F, Record, Idx);
5504 if (Record.size() != 2) {
5505 Error(
"incorrect encoding of pack expansion type");
5508 QualType Pattern = readType(*Loc.F, Record, Idx);
5513 NumExpansions = Record[1] - 1;
5521 QualType NamedType = readType(*Loc.F, Record, Idx);
5528 = ReadDeclAs<ObjCInterfaceDecl>(*Loc.F, Record, Idx);
5534 QualType Base = readType(*Loc.F, Record, Idx);
5535 unsigned NumTypeArgs = Record[Idx++];
5537 for (
unsigned I = 0; I != NumTypeArgs; ++
I)
5538 TypeArgs.push_back(readType(*Loc.F, Record, Idx));
5539 unsigned NumProtos = Record[Idx++];
5541 for (
unsigned I = 0; I != NumProtos; ++
I)
5542 Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
5543 bool IsKindOf = Record[Idx++];
5549 QualType Pointee = readType(*Loc.F, Record, Idx);
5555 QualType Parm = readType(*Loc.F, Record, Idx);
5558 cast<TemplateTypeParmType>(Parm),
5564 QualType Parm = readType(*Loc.F, Record, Idx);
5567 cast<TemplateTypeParmType>(Parm),
5572 CXXRecordDecl *D = ReadDeclAs<CXXRecordDecl>(*Loc.F, Record, Idx);
5573 QualType TST = readType(*Loc.F, Record, Idx);
5576 const Type *T =
nullptr;
5578 if (
const Type *Existing = DI->getTypeForDecl()) {
5586 DI->setTypeForDecl(T);
5593 unsigned Depth = Record[Idx++];
5594 unsigned Index = Record[Idx++];
5595 bool Pack = Record[Idx++];
5597 = ReadDeclAs<TemplateTypeParmDecl>(*Loc.F, Record, Idx);
5605 const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx);
5606 QualType Canon = readType(*Loc.F, Record, Idx);
5616 const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx);
5617 unsigned NumArgs = Record[Idx++];
5619 Args.reserve(NumArgs);
5621 Args.push_back(ReadTemplateArgument(*Loc.F, Record, Idx));
5630 QualType ElementType = readType(*Loc.F, Record, Idx);
5633 unsigned IndexTypeQuals = Record[Idx++];
5636 Expr *NumElts = ReadExpr(*Loc.F);
5637 SourceRange Brackets = ReadSourceRange(*Loc.F, Record, Idx);
5640 IndexTypeQuals, Brackets);
5645 bool IsDependent = Record[Idx++];
5646 TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx);
5648 ReadTemplateArgumentList(Args, *Loc.F, Record, Idx);
5649 QualType Underlying = readType(*Loc.F, Record, Idx);
5655 const_cast<Type*
>(T.
getTypePtr())->setDependent(IsDependent);
5660 if (Record.size() != 1) {
5661 Error(
"Incorrect encoding of atomic type");
5664 QualType ValueType = readType(*Loc.F, Record, Idx);
5669 if (Record.size() != 1) {
5670 Error(
"Incorrect encoding of pipe type");
5675 QualType ElementType = readType(*Loc.F, Record, Idx);
5679 llvm_unreachable(
"Invalid TypeCode!");
5685 const RecordData &Record,
unsigned &Idx) {
5690 for (
unsigned I = 0, N = Record[Idx++]; I != N; ++
I)
5691 Exceptions.push_back(readType(ModuleFile, Record, Idx));
5696 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
5697 ESI.
SourceTemplate = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
5699 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
5711 return Reader.ReadSourceLocation(F, R, I);
5714 template<
typename T>
5716 return Reader.ReadDeclAs<T>(F, Record, Idx);
5722 : Reader(Reader), F(F), Record(Record), Idx(Idx)
5728 #define ABSTRACT_TYPELOC(CLASS, PARENT)
5729 #define TYPELOC(CLASS, PARENT) \
5730 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
5731 #include "clang/AST/TypeLocNodes.def"
5750 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5753 TL.
setStarLoc(ReadSourceLocation(Record, Idx));
5765 TL.
setAmpLoc(ReadSourceLocation(Record, Idx));
5771 TL.
setStarLoc(ReadSourceLocation(Record, Idx));
5783 VisitArrayTypeLoc(TL);
5786 VisitArrayTypeLoc(TL);
5789 VisitArrayTypeLoc(TL);
5791 void TypeLocReader::VisitDependentSizedArrayTypeLoc(
5793 VisitArrayTypeLoc(TL);
5795 void TypeLocReader::VisitDependentSizedExtVectorTypeLoc(
5797 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5800 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5803 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5810 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i) {
5811 TL.
setParam(i, ReadDeclAs<ParmVarDecl>(Record, Idx));
5815 VisitFunctionTypeLoc(TL);
5818 VisitFunctionTypeLoc(TL);
5821 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5824 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5838 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5841 TL.
setKWLoc(ReadSourceLocation(Record, Idx));
5846 void TypeLocReader::VisitAutoTypeLoc(
AutoTypeLoc TL) {
5847 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5850 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5852 void TypeLocReader::VisitEnumTypeLoc(
EnumTypeLoc TL) {
5853 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5856 TL.setAttrNameLoc(ReadSourceLocation(Record, Idx));
5859 range.
setBegin(ReadSourceLocation(Record, Idx));
5860 range.
setEnd(ReadSourceLocation(Record, Idx));
5865 TL.setAttrExprOperand(Reader.ReadExpr(F));
5867 TL.setAttrExprOperand(
nullptr);
5872 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5874 void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
5876 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5878 void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
5880 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5882 void TypeLocReader::VisitTemplateSpecializationTypeLoc(
5888 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
5890 Reader.GetTemplateArgumentLocInfo(F,
5894 void TypeLocReader::VisitParenTypeLoc(
ParenTypeLoc TL) {
5900 TL.
setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(F, Record, Idx));
5903 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5907 TL.
setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(F, Record, Idx));
5908 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5910 void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc(
5913 TL.
setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(F, Record, Idx));
5920 Reader.GetTemplateArgumentLocInfo(F,
5928 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5942 TL.
setStarLoc(ReadSourceLocation(Record, Idx));
5945 TL.
setKWLoc(ReadSourceLocation(Record, Idx));
5949 void TypeLocReader::VisitPipeTypeLoc(
PipeTypeLoc TL) {
5950 TL.
setKWLoc(ReadSourceLocation(Record, Idx));
5956 QualType InfoTy = readType(F, Record, Idx);
5960 TypeSourceInfo *TInfo = getContext().CreateTypeSourceInfo(InfoTy);
6076 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
6077 case PREDEF_TYPE_##Id##_ID: \
6078 T = Context.SingletonId; \
6080 #include "clang/Basic/OpenCLImageTypes.def"
6120 assert(!T.
isNull() &&
"Unknown predefined type");
6125 assert(Index < TypesLoaded.size() &&
"Type index out-of-range");
6126 if (TypesLoaded[Index].isNull()) {
6127 TypesLoaded[Index] = readTypeRecord(Index);
6128 if (TypesLoaded[Index].isNull())
6131 TypesLoaded[Index]->setFromAST();
6132 if (DeserializationListener)
6134 TypesLoaded[Index]);
6137 return TypesLoaded[Index].withFastQualifiers(FastQuals);
6141 return GetType(getGlobalTypeID(F, LocalID));
6154 assert(I != F.
TypeRemap.
end() &&
"Invalid index into type index remap");
6156 unsigned GlobalIndex = LocalIndex + I->second;
6157 return (GlobalIndex << Qualifiers::FastWidth) | FastQuals;
6169 return GetTypeSourceInfo(F, Record, Index);
6173 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
6180 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
6181 SourceLocation EllipsisLoc = ReadSourceLocation(F, Record, Index);
6193 llvm_unreachable(
"unexpected template argument loc");
6202 if (Record[Index++])
6215 unsigned NumArgsAsWritten = Record[Index++];
6217 for (
unsigned i = 0; i != NumArgsAsWritten; ++i)
6218 TemplArgsInfo.
addArgument(ReadTemplateArgumentLoc(F, Record, Index));
6226 template<
typename TemplateSpecializationDecl>
6228 if (
auto *TSD = dyn_cast<TemplateSpecializationDecl>(D))
6229 TSD->getSpecializedTemplate()->LoadLazySpecializations();
6233 if (NumCurrentElementsDeserializing) {
6238 PendingIncompleteDeclChains.push_back(const_cast<Decl*>(D));
6242 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
6249 if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC) ||
6250 isa<CXXRecordDecl>(DC) || isa<EnumDecl>(DC)) {
6252 if (!getContext().getLangOpts().
CPlusPlus &&
6253 isa<TranslationUnitDecl>(DC)) {
6257 auto *II = Name.getAsIdentifierInfo();
6258 assert(II &&
"non-identifier name in C?");
6259 if (II->isOutOfDate())
6260 updateOutOfDateIdentifier(*II);
6265 for (
auto *DCDecl : cast<Decl>(D->getLexicalDeclContext())->redecls()) {
6266 auto *DC = cast<DeclContext>(DCDecl);
6268 FindExternalLexicalDecls(
6269 DC, [&](
Decl::Kind K) {
return K == D->getKind(); }, Decls);
6274 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D))
6275 CTSD->getSpecializedTemplate()->LoadLazySpecializations();
6276 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D))
6277 VTSD->getSpecializedTemplate()->LoadLazySpecializations();
6278 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
6279 if (
auto *Template = FD->getPrimaryTemplate())
6280 Template->LoadLazySpecializations();
6286 RecordLocation Loc = getLocalBitOffset(Offset);
6287 BitstreamCursor &Cursor = Loc.F->DeclsCursor;
6289 Cursor.JumpToBit(Loc.Offset);
6290 ReadingKindTracker ReadingKind(Read_Decl, *
this);
6293 unsigned Code = Cursor.ReadCode();
6294 unsigned RecCode = Cursor.readRecord(Code, Record);
6296 Error(
"malformed AST file: missing C++ ctor initializers");
6301 return ReadCXXCtorInitializers(*Loc.F, Record, Idx);
6305 RecordLocation Loc = getLocalBitOffset(Offset);
6306 BitstreamCursor &Cursor = Loc.F->DeclsCursor;
6308 Cursor.JumpToBit(Loc.Offset);
6309 ReadingKindTracker ReadingKind(Read_Decl, *
this);
6311 unsigned Code = Cursor.ReadCode();
6312 unsigned RecCode = Cursor.readRecord(Code, Record);
6314 Error(
"malformed AST file: missing C++ base specifiers");
6319 unsigned NumBases = Record[Idx++];
6322 for (
unsigned I = 0; I != NumBases; ++
I)
6323 Bases[I] = ReadCXXBaseSpecifier(*Loc.F, Record, Idx);
6334 assert(I != F.
DeclRemap.
end() &&
"Invalid index into decl index remap");
6336 return LocalID + I->second;
6340 ModuleFile &M)
const {
6350 if (!D->isFromASTFile())
6353 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
6363 if (Index > DeclsLoaded.size()) {
6364 Error(
"declaration ID out-of-range for AST file");
6368 if (Decl *D = DeclsLoaded[Index])
6369 return D->getLocation();
6372 DeclCursorForID(ID, Loc);
6429 llvm_unreachable(
"PredefinedDeclIDs unknown enum value");
6438 auto &Merged = KeyDecls[D->getCanonicalDecl()];
6440 Merged.push_back(ID);
6447 if (Index >= DeclsLoaded.size()) {
6448 assert(0 &&
"declaration ID out-of-range for AST file");
6449 Error(
"declaration ID out-of-range for AST file");
6453 return DeclsLoaded[Index];
6458 return GetExistingDecl(ID);
6462 if (Index >= DeclsLoaded.size()) {
6463 assert(0 &&
"declaration ID out-of-range for AST file");
6464 Error(
"declaration ID out-of-range for AST file");
6468 if (!DeclsLoaded[Index]) {
6470 if (DeserializationListener)
6471 DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);
6474 return DeclsLoaded[Index];
6483 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
6484 ModuleFile *Owner = I->second;
6491 return GlobalID - Owner->BaseDeclID + Pos->second;
6497 if (Idx >= Record.size()) {
6498 Error(
"Corrupted AST file");
6502 return getGlobalDeclID(F, Record[Idx++]);
6512 ClearSwitchCaseIDs();
6515 RecordLocation Loc = getLocalBitOffset(Offset);
6516 Loc.F->DeclsCursor.JumpToBit(Loc.Offset);
6517 return ReadStmtFromStream(*Loc.F);
6526 assert(LexicalDecls.size() % 2 == 0 &&
"expected an even number of entries");
6527 for (
int I = 0, N = LexicalDecls.size(); I != N; I += 2) {
6529 if (!IsKindWeWant(K))
6537 if (PredefsVisited[ID])
6540 PredefsVisited[
ID] =
true;
6543 if (Decl *D = GetLocalDecl(*M, ID)) {
6544 assert(D->getKind() == K &&
"wrong kind for lexical decl");
6551 if (isa<TranslationUnitDecl>(DC)) {
6552 for (
auto Lexical : TULexicalDecls)
6553 Visit(Lexical.first, Lexical.second);
6555 auto I = LexicalDecls.find(DC);
6556 if (I != LexicalDecls.end())
6557 Visit(I->second.first, I->second.second);
6560 ++NumLexicalDeclContextsRead;
6570 DeclIDComp(
ASTReader &Reader, ModuleFile &M) : Reader(Reader), Mod(M) {}
6575 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
6580 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
6585 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
6589 return Reader.getSourceManager().getFileLoc(
6590 Reader.getSourceLocationForDeclID(Reader.getGlobalDeclID(Mod, ID)));
6597 unsigned Offset,
unsigned Length,
6602 if (I == FileDeclIDs.end())
6605 FileDeclsInfo &DInfo = I->second;
6606 if (DInfo.Decls.empty())
6613 DeclIDComp DIDComp(*
this, *DInfo.Mod);
6615 BeginIt = std::lower_bound(DInfo.Decls.begin(), DInfo.Decls.end(),
6617 if (BeginIt != DInfo.Decls.begin())
6623 while (BeginIt != DInfo.Decls.begin() &&
6624 GetDecl(getGlobalDeclID(*DInfo.Mod, *BeginIt))
6625 ->isTopLevelDeclInObjCContainer())
6629 EndIt = std::upper_bound(DInfo.Decls.begin(), DInfo.Decls.end(),
6631 if (EndIt != DInfo.Decls.end())
6635 DIt = BeginIt; DIt != EndIt; ++DIt)
6636 Decls.push_back(GetDecl(getGlobalDeclID(*DInfo.Mod, *DIt)));
6643 "DeclContext has no visible decls in storage");
6647 auto It = Lookups.find(DC);
6648 if (It == Lookups.end())
6655 for (
DeclID ID : It->second.Table.find(Name)) {
6656 NamedDecl *ND = cast<NamedDecl>(GetDecl(ID));
6658 Decls.push_back(ND);
6661 ++NumVisibleDeclContextsRead;
6662 SetExternalVisibleDeclsForName(DC, Name, Decls);
6663 return !Decls.empty();
6670 auto It = Lookups.find(DC);
6671 assert(It != Lookups.end() &&
6672 "have external visible storage but no lookup tables");
6676 for (
DeclID ID : It->second.Table.findAll()) {
6677 NamedDecl *ND = cast<NamedDecl>(GetDecl(ID));
6681 ++NumVisibleDeclContextsRead;
6684 SetExternalVisibleDeclsForName(DC, I->first, I->second);
6686 const_cast<DeclContext *
>(DC)->setHasExternalVisibleStorage(
false);
6691 auto I = Lookups.find(Primary);
6692 return I == Lookups.end() ?
nullptr : &I->second;
6701 assert(ImplD && Consumer);
6703 for (
auto *I : ImplD->
methods())
6709 void ASTReader::PassInterestingDeclsToConsumer() {
6712 if (PassingDeclsToConsumer)
6722 for (
auto ID : EagerlyDeserializedDecls)
6724 EagerlyDeserializedDecls.clear();
6726 while (!InterestingDecls.empty()) {
6727 Decl *D = InterestingDecls.front();
6728 InterestingDecls.pop_front();
6730 PassInterestingDeclToConsumer(D);
6734 void ASTReader::PassInterestingDeclToConsumer(Decl *D) {
6742 this->Consumer = Consumer;
6745 PassInterestingDeclsToConsumer();
6747 if (DeserializationListener)
6748 DeserializationListener->ReaderInitialized(
this);
6752 std::fprintf(stderr,
"*** AST File Statistics:\n");
6754 unsigned NumTypesLoaded
6755 = TypesLoaded.size() - std::count(TypesLoaded.begin(), TypesLoaded.end(),
6757 unsigned NumDeclsLoaded
6758 = DeclsLoaded.size() - std::count(DeclsLoaded.begin(), DeclsLoaded.end(),
6760 unsigned NumIdentifiersLoaded
6761 = IdentifiersLoaded.size() - std::count(IdentifiersLoaded.begin(),
6762 IdentifiersLoaded.end(),
6764 unsigned NumMacrosLoaded
6765 = MacrosLoaded.size() - std::count(MacrosLoaded.begin(),
6768 unsigned NumSelectorsLoaded
6769 = SelectorsLoaded.size() - std::count(SelectorsLoaded.begin(),
6770 SelectorsLoaded.end(),
6773 if (
unsigned TotalNumSLocEntries = getTotalNumSLocs())
6774 std::fprintf(stderr,
" %u/%u source location entries read (%f%%)\n",
6775 NumSLocEntriesRead, TotalNumSLocEntries,
6776 ((
float)NumSLocEntriesRead/TotalNumSLocEntries * 100));
6777 if (!TypesLoaded.empty())
6778 std::fprintf(stderr,
" %u/%u types read (%f%%)\n",
6779 NumTypesLoaded, (
unsigned)TypesLoaded.size(),
6780 ((float)NumTypesLoaded/TypesLoaded.size() * 100));
6781 if (!DeclsLoaded.empty())
6782 std::fprintf(stderr,
" %u/%u declarations read (%f%%)\n",
6783 NumDeclsLoaded, (
unsigned)DeclsLoaded.size(),
6784 ((float)NumDeclsLoaded/DeclsLoaded.size() * 100));
6785 if (!IdentifiersLoaded.empty())
6786 std::fprintf(stderr,
" %u/%u identifiers read (%f%%)\n",
6787 NumIdentifiersLoaded, (
unsigned)IdentifiersLoaded.size(),
6788 ((float)NumIdentifiersLoaded/IdentifiersLoaded.size() * 100));
6789 if (!MacrosLoaded.empty())
6790 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
6791 NumMacrosLoaded, (
unsigned)MacrosLoaded.size(),
6792 ((float)NumMacrosLoaded/MacrosLoaded.size() * 100));
6793 if (!SelectorsLoaded.empty())
6794 std::fprintf(stderr,
" %u/%u selectors read (%f%%)\n",
6795 NumSelectorsLoaded, (
unsigned)SelectorsLoaded.size(),
6796 ((float)NumSelectorsLoaded/SelectorsLoaded.size() * 100));
6797 if (TotalNumStatements)
6798 std::fprintf(stderr,
" %u/%u statements read (%f%%)\n",
6799 NumStatementsRead, TotalNumStatements,
6800 ((
float)NumStatementsRead/TotalNumStatements * 100));
6802 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
6803 NumMacrosRead, TotalNumMacros,
6804 ((
float)NumMacrosRead/TotalNumMacros * 100));
6805 if (TotalLexicalDeclContexts)
6806 std::fprintf(stderr,
" %u/%u lexical declcontexts read (%f%%)\n",
6807 NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
6808 ((
float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts
6810 if (TotalVisibleDeclContexts)
6811 std::fprintf(stderr,
" %u/%u visible declcontexts read (%f%%)\n",
6812 NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
6813 ((
float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
6815 if (TotalNumMethodPoolEntries) {
6816 std::fprintf(stderr,
" %u/%u method pool entries read (%f%%)\n",
6817 NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
6818 ((
float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
6821 if (NumMethodPoolLookups) {
6822 std::fprintf(stderr,
" %u/%u method pool lookups succeeded (%f%%)\n",
6823 NumMethodPoolHits, NumMethodPoolLookups,
6824 ((
float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
6826 if (NumMethodPoolTableLookups) {
6827 std::fprintf(stderr,
" %u/%u method pool table lookups succeeded (%f%%)\n",
6828 NumMethodPoolTableHits, NumMethodPoolTableLookups,
6829 ((
float)NumMethodPoolTableHits/NumMethodPoolTableLookups
6833 if (NumIdentifierLookupHits) {
6834 std::fprintf(stderr,
6835 " %u / %u identifier table lookups succeeded (%f%%)\n",
6836 NumIdentifierLookupHits, NumIdentifierLookups,
6837 (
double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
6841 std::fprintf(stderr,
"\n");
6842 GlobalIndex->printStats();
6845 std::fprintf(stderr,
"\n");
6847 std::fprintf(stderr,
"\n");
6850 template<
typename Key,
typename ModuleFile,
unsigned InitialCapacity>
6854 InitialCapacity> &
Map) {
6855 if (
Map.begin() ==
Map.end())
6859 llvm::errs() << Name <<
":\n";
6860 for (
typename MapType::const_iterator I =
Map.begin(), IEnd =
Map.end();
6862 llvm::errs() <<
" " << I->first <<
" -> " << I->second->FileName
6868 llvm::errs() <<
"*** PCH/ModuleFile Remappings:\n";
6870 dumpModuleIDMap(
"Global source location entry map", GlobalSLocEntryMap);
6878 GlobalPreprocessedEntityMap);
6880 llvm::errs() <<
"\n*** PCH/Modules Loaded:";
6882 MEnd = ModuleMgr.end();
6891 E = ModuleMgr.end(); I !=
E; ++
I) {
6892 if (llvm::MemoryBuffer *buf = (*I)->Buffer.get()) {
6893 size_t bytes = buf->getBufferSize();
6894 switch (buf->getBufferKind()) {
6895 case llvm::MemoryBuffer::MemoryBuffer_Malloc:
6898 case llvm::MemoryBuffer::MemoryBuffer_MMap:
6912 for (uint64_t ID : PreloadedDeclIDs) {
6913 NamedDecl *D = cast<NamedDecl>(GetDecl(ID));
6916 PreloadedDeclIDs.clear();
6919 if (!FPPragmaOptions.empty()) {
6920 assert(FPPragmaOptions.size() == 1 &&
"Wrong number of FP_PRAGMA_OPTIONS");
6921 SemaObj->FPFeatures.fp_contract = FPPragmaOptions[0];
6925 if (!OpenCLExtensions.empty()) {
6927 #define OPENCLEXT(nm) SemaObj->OpenCLFeatures.nm = OpenCLExtensions[I++];
6928 #include "clang/Basic/OpenCLExtensions.def"
6930 assert(OpenCLExtensions.size() == I &&
"Wrong number of OPENCL_EXTENSIONS");
6937 assert(SemaObj &&
"no Sema to update");
6941 if (!SemaDeclRefs.empty()) {
6942 assert(SemaDeclRefs.size() % 2 == 0);
6943 for (
unsigned I = 0; I != SemaDeclRefs.size(); I += 2) {
6944 if (!SemaObj->StdNamespace)
6945 SemaObj->StdNamespace = SemaDeclRefs[
I];
6946 if (!SemaObj->StdBadAlloc)
6947 SemaObj->StdBadAlloc = SemaDeclRefs[I+1];
6949 SemaDeclRefs.clear();
6954 if(OptimizeOffPragmaLocation.isValid())
6955 SemaObj->ActOnPragmaOptimize(
false, OptimizeOffPragmaLocation);
6956 if (PragmaMSStructState != -1)
6958 if (PointersToMembersPragmaLocation.isValid()) {
6959 SemaObj->ActOnPragmaMSPointersToMembers(
6961 PragmaMSPointersToMembersState,
6962 PointersToMembersPragmaLocation);
6970 IdentifierLookupVisitor Visitor(Name, 0,
6971 NumIdentifierLookups,
6972 NumIdentifierLookupHits);
6979 for (
auto F : ModuleMgr.pch_modules())
6987 if (!loadGlobalIndex()) {
6988 if (GlobalIndex->lookupIdentifier(Name, Hits)) {
6993 ModuleMgr.visit(Visitor, HitsPtr);
6997 markIdentifierUpToDate(II);
7014 ASTIdentifierLookupTable::key_iterator
Current;
7018 ASTIdentifierLookupTable::key_iterator
End;
7025 bool SkipModules =
false);
7027 StringRef
Next()
override;
7033 : Reader(Reader), Index(Reader.ModuleMgr.size()), SkipModules(SkipModules) {
7037 while (Current == End) {
7043 ModuleFile &F = Reader.ModuleMgr[Index];
7044 if (SkipModules && F.isModule())
7049 Current = IdTable->key_begin();
7050 End = IdTable->key_end();
7055 StringRef Result = *Current;
7063 std::unique_ptr<IdentifierIterator>
Current;
7064 std::unique_ptr<IdentifierIterator> Queued;
7067 ChainedIdentifierIterator(std::unique_ptr<IdentifierIterator> First,
7068 std::unique_ptr<IdentifierIterator> Second)
7069 :
Current(std::move(First)), Queued(std::move(Second)) {}
7071 StringRef
Next()
override {
7075 StringRef result =
Current->Next();
7076 if (!result.empty())
7089 std::unique_ptr<IdentifierIterator> ReaderIter(
7091 std::unique_ptr<IdentifierIterator> ModulesIter(
7092 GlobalIndex->createIdentifierIterator());
7093 return new ChainedIdentifierIterator(std::move(ReaderIter),
7094 std::move(ModulesIter));
7100 namespace clang {
namespace serialization {
7104 unsigned PriorGeneration;
7105 unsigned InstanceBits;
7106 unsigned FactoryBits;
7107 bool InstanceHasMoreThanOneDecl;
7108 bool FactoryHasMoreThanOneDecl;
7114 unsigned PriorGeneration)
7115 : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration),
7116 InstanceBits(0), FactoryBits(0), InstanceHasMoreThanOneDecl(
false),
7117 FactoryHasMoreThanOneDecl(
false) {}
7127 ++Reader.NumMethodPoolTableLookups;
7131 if (Pos == PoolTable->end())
7134 ++Reader.NumMethodPoolTableHits;
7135 ++Reader.NumSelectorsRead;
7139 ++Reader.NumMethodPoolEntriesRead;
7141 if (Reader.DeserializationListener)
7155 return InstanceMethods;
7160 return FactoryMethods;
7166 return InstanceHasMoreThanOneDecl;
7175 for (
unsigned I = 0, N = Methods.size(); I != N; ++
I) {
7182 unsigned &Generation = SelectorGeneration[Sel];
7183 unsigned PriorGeneration = Generation;
7185 SelectorOutOfDate[Sel] =
false;
7188 ++NumMethodPoolLookups;
7190 ModuleMgr.
visit(Visitor);
7196 ++NumMethodPoolHits;
7218 if (SelectorOutOfDate[Sel])
7226 for (
unsigned I = 0, N = KnownNamespaces.size(); I != N; ++
I) {
7228 = dyn_cast_or_null<NamespaceDecl>(
GetDecl(KnownNamespaces[I])))
7229 Namespaces.push_back(Namespace);
7234 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
7235 for (
unsigned Idx = 0, N = UndefinedButUsed.size(); Idx != N;) {
7239 Undefined.insert(std::make_pair(D, Loc));
7246 for (
unsigned Idx = 0, N = DelayedDeleteExprs.size(); Idx != N;) {
7248 uint64_t Count = DelayedDeleteExprs[Idx++];
7249 for (uint64_t C = 0; C <
Count; ++C) {
7252 const bool IsArrayForm = DelayedDeleteExprs[Idx++];
7253 Exprs[FD].push_back(std::make_pair(DeleteLoc, IsArrayForm));
7260 for (
unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++
I) {
7261 VarDecl *Var = dyn_cast_or_null<VarDecl>(
GetDecl(TentativeDefinitions[I]));
7263 TentativeDefs.push_back(Var);
7265 TentativeDefinitions.clear();
7270 for (
unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++
I) {
7272 = dyn_cast_or_null<DeclaratorDecl>(
GetDecl(UnusedFileScopedDecls[I]));
7276 UnusedFileScopedDecls.clear();
7281 for (
unsigned I = 0, N = DelegatingCtorDecls.size(); I != N; ++
I) {
7283 = dyn_cast_or_null<CXXConstructorDecl>(
GetDecl(DelegatingCtorDecls[I]));
7287 DelegatingCtorDecls.clear();
7291 for (
unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++
I) {
7293 = dyn_cast_or_null<TypedefNameDecl>(
GetDecl(ExtVectorDecls[I]));
7297 ExtVectorDecls.clear();
7302 for (
unsigned I = 0, N = UnusedLocalTypedefNameCandidates.size(); I != N;
7305 GetDecl(UnusedLocalTypedefNameCandidates[I]));
7309 UnusedLocalTypedefNameCandidates.clear();
7314 if (ReferencedSelectorsData.empty())
7319 unsigned int DataSize = ReferencedSelectorsData.size()-1;
7321 while (I < DataSize) {
7325 Sels.push_back(std::make_pair(Sel, SelLoc));
7327 ReferencedSelectorsData.clear();
7332 if (WeakUndeclaredIdentifiers.empty())
7335 for (
unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; ) {
7342 bool Used = WeakUndeclaredIdentifiers[I++];
7345 WeakIDs.push_back(std::make_pair(WeakId, WI));
7347 WeakUndeclaredIdentifiers.clear();
7351 for (
unsigned Idx = 0, N = VTableUses.size(); Idx < N; ) {
7353 VT.
Record = dyn_cast_or_null<CXXRecordDecl>(
GetDecl(VTableUses[Idx++]));
7356 VTables.push_back(VT);
7364 for (
unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
7369 Pending.push_back(std::make_pair(D, Loc));
7371 PendingInstantiations.clear();
7375 llvm::MapVector<const FunctionDecl *, LateParsedTemplate *> &LPTMap) {
7376 for (
unsigned Idx = 0, N = LateParsedTemplates.size(); Idx < N;
7381 LT->
D =
GetDecl(LateParsedTemplates[Idx++]);
7384 assert(F &&
"No module");
7386 unsigned TokN = LateParsedTemplates[Idx++];
7387 LT->Toks.reserve(TokN);
7388 for (
unsigned T = 0; T < TokN; ++T)
7389 LT->Toks.push_back(
ReadToken(*F, LateParsedTemplates, Idx));
7391 LPTMap.insert(std::make_pair(FD, LT));
7394 LateParsedTemplates.clear();
7403 assert(ID &&
"Non-zero identifier ID required");
7404 assert(ID <= IdentifiersLoaded.size() &&
"identifier ID out of range");
7405 IdentifiersLoaded[ID - 1] = II;
7406 if (DeserializationListener)
7430 if (NumCurrentElementsDeserializing && !Decls) {
7431 PendingIdentifierInfos[II].append(DeclIDs.begin(), DeclIDs.end());
7435 for (
unsigned I = 0, N = DeclIDs.size(); I != N; ++
I) {
7448 Decls->push_back(D);
7455 pushExternalDeclIntoScope(D, II);
7463 if (IdentifiersLoaded.empty()) {
7464 Error(
"no identifier table in AST file");
7469 if (!IdentifiersLoaded[ID]) {
7471 assert(I != GlobalIdentifierMap.
end() &&
"Corrupted global identifier map");
7472 ModuleFile *M = I->second;
7473 unsigned Index = ID - M->BaseIdentifierID;
7474 const char *Str = M->IdentifierTableData + M->IdentifierOffsets[Index];
7481 const unsigned char *StrLenPtr = (
const unsigned char*) Str - 2;
7482 unsigned StrLen = (((
unsigned) StrLenPtr[0])
7483 | (((
unsigned) StrLenPtr[1]) << 8)) - 1;
7485 IdentifiersLoaded[
ID] = &II;
7487 if (DeserializationListener)
7491 return IdentifiersLoaded[
ID];
7505 &&
"Invalid index into identifier index remap");
7507 return LocalID + I->second;
7514 if (MacrosLoaded.empty()) {
7515 Error(
"no macro table in AST file");
7520 if (!MacrosLoaded[ID]) {
7523 assert(I != GlobalMacroMap.
end() &&
"Corrupted global macro map");
7524 ModuleFile *M = I->second;
7525 unsigned Index = ID - M->BaseMacroID;
7528 if (DeserializationListener)
7533 return MacrosLoaded[
ID];
7542 assert(I != M.
MacroRemap.
end() &&
"Invalid index into macro index remap");
7544 return LocalID + I->second;
7549 if (LocalID < NUM_PREDEF_SUBMODULE_IDS)
7555 &&
"Invalid index into submodule index remap");
7557 return LocalID + I->second;
7561 if (GlobalID < NUM_PREDEF_SUBMODULE_IDS) {
7562 assert(GlobalID == 0 &&
"Unhandled global submodule ID");
7566 if (GlobalID > SubmodulesLoaded.size()) {
7567 Error(
"submodule ID out of range in AST file");
7582 return I == GlobalSubmoduleMap.
end() ?
nullptr : I->second;
7585 unsigned IndexFromEnd = ID >> 1;
7586 assert(IndexFromEnd &&
"got reference to unknown module file");
7603 auto I = std::find(PCHModules.begin(), PCHModules.end(), F);
7604 assert(I != PCHModules.end() &&
"emitting reference to unknown file");
7605 return (I - PCHModules.end()) << 1;
7615 if (ModuleMgr.
size() == 1) {
7618 StringRef FileName = llvm::sys::path::filename(MF.
FileName);
7633 if (ID > SelectorsLoaded.size()) {
7634 Error(
"selector ID out of range in AST file");
7638 if (SelectorsLoaded[ID - 1].getAsOpaquePtr() ==
nullptr) {
7641 assert(I != GlobalSelectorMap.
end() &&
"Corrupted global selector map");
7642 ModuleFile &M = *I->second;
7645 SelectorsLoaded[ID - 1] =
7646 Trait.
ReadKey(M.SelectorLookupTableData + M.SelectorOffsets[Idx], 0);
7647 if (DeserializationListener)
7648 DeserializationListener->
SelectorRead(ID, SelectorsLoaded[ID - 1]);
7651 return SelectorsLoaded[ID - 1];
7671 &&
"Invalid index into selector index remap");
7673 return LocalID + I->second;
7713 llvm_unreachable(
"Invalid NameKind!");
7761 unsigned NumTPLists = Record[Idx++];
7765 for (
unsigned i=0; i != NumTPLists; ++i)
7776 return TemplateName(ReadDeclAs<TemplateDecl>(F, Record, Idx));
7779 unsigned size = Record[Idx++];
7782 Decls.
addDecl(ReadDeclAs<NamedDecl>(F, Record, Idx));
7789 bool hasTemplKeyword = Record[Idx++];
7790 TemplateDecl *Template = ReadDeclAs<TemplateDecl>(F, Record, Idx);
7806 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
7814 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
7826 llvm_unreachable(
"Unhandled template name kind!");
7832 bool Canonicalize) {
7849 ValueDecl *D = ReadDeclAs<ValueDecl>(F, Record, Idx);
7864 if (
unsigned NumExpansions = Record[Idx++])
7865 NumTemplateExpansions = NumExpansions - 1;
7871 unsigned NumArgs = Record[Idx++];
7873 for (
unsigned I = 0; I !=
NumArgs; ++
I)
7879 llvm_unreachable(
"Unhandled template argument kind!");
7889 unsigned NumParams = Record[Idx++];
7891 Params.reserve(NumParams);
7893 Params.push_back(ReadDeclAs<NamedDecl>(F, Record, Idx));
7898 return TemplateParams;
7905 unsigned &Idx,
bool Canonicalize) {
7906 unsigned NumTemplateArgs = Record[Idx++];
7907 TemplArgs.reserve(NumTemplateArgs);
7908 while (NumTemplateArgs--)
7915 unsigned NumDecls = Record[Idx++];
7916 Set.
reserve(Context, NumDecls);
7917 while (NumDecls--) {
7927 bool isVirtual =
static_cast<bool>(Record[Idx++]);
7928 bool isBaseOfClass =
static_cast<bool>(Record[Idx++]);
7930 bool inheritConstructors =
static_cast<bool>(Record[Idx++]);
7943 unsigned NumInitializers = Record[Idx++];
7944 assert(NumInitializers &&
"wrote ctor initializers but have no inits");
7946 for (
unsigned i = 0; i != NumInitializers; ++i) {
7948 bool IsBaseVirtual =
false;
7956 IsBaseVirtual = Record[Idx++];
7964 Member = ReadDeclAs<FieldDecl>(F, Record, Idx);
7968 IndirectMember = ReadDeclAs<IndirectFieldDecl>(F, Record, Idx);
7976 bool IsWritten = Record[Idx++];
7977 unsigned SourceOrderOrNumArrayIndices;
7980 SourceOrderOrNumArrayIndices = Record[Idx++];
7982 SourceOrderOrNumArrayIndices = Record[Idx++];
7983 Indices.reserve(SourceOrderOrNumArrayIndices);
7984 for (
unsigned i=0; i != SourceOrderOrNumArrayIndices; ++i)
7985 Indices.push_back(ReadDeclAs<VarDecl>(F, Record, Idx));
7990 BOMInit =
new (Context)
7992 RParenLoc, MemberOrEllipsisLoc);
7994 BOMInit =
new (Context)
7996 }
else if (IsWritten) {
7999 Context, Member, MemberOrEllipsisLoc, LParenLoc, Init, RParenLoc);
8001 BOMInit =
new (Context)
8003 LParenLoc, Init, RParenLoc);
8005 if (IndirectMember) {
8006 assert(Indices.empty() &&
"Indirect field improperly initialized");
8007 BOMInit =
new (Context)
8009 LParenLoc, Init, RParenLoc);
8012 Context, Member, MemberOrEllipsisLoc, LParenLoc, Init, RParenLoc,
8013 Indices.data(), Indices.size());
8019 CtorInitializers[i] = BOMInit;
8022 return CtorInitializers;
8028 unsigned N = Record[Idx++];
8030 for (
unsigned I = 0; I != N; ++
I) {
8041 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
8058 bool Template = Record[Idx++];
8070 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
8083 unsigned N = Record[Idx++];
8085 for (
unsigned I = 0; I != N; ++
I) {
8097 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
8099 Builder.
Extend(Context, NS, Range.getBegin(), Range.getEnd());
8106 Builder.
Extend(Context, Alias, Range.getBegin(), Range.getEnd());
8112 bool Template = Record[Idx++];
8132 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
8134 Builder.
MakeSuper(Context, RD, Range.getBegin(), Range.getEnd());
8153 unsigned BitWidth = Record[Idx++];
8154 unsigned NumWords = llvm::APInt::getNumWords(BitWidth);
8155 llvm::APInt
Result(BitWidth, NumWords, &Record[Idx]);
8162 bool isUnsigned = Record[Idx++];
8163 return llvm::APSInt(
ReadAPInt(Record, Idx), isUnsigned);
8168 const llvm::fltSemantics &Sem,
8170 return llvm::APFloat(Sem,
ReadAPInt(Record, Idx));
8175 unsigned Len = Record[Idx++];
8176 std::string
Result(Record.data() + Idx, Record.data() + Idx + Len);
8183 std::string Filename =
ReadString(Record, Idx);
8190 unsigned Major = Record[Idx++];
8191 unsigned Minor = Record[Idx++];
8192 unsigned Subminor = Record[Idx++];
8208 return Diag(CurrentImportLoc, DiagID);
8212 return Diags.
Report(Loc, DiagID);
8224 assert((*CurrSwitchCaseStmts)[ID] ==
nullptr &&
8225 "Already have a SwitchCase with this ID");
8226 (*CurrSwitchCaseStmts)[
ID] = SC;
8231 assert((*CurrSwitchCaseStmts)[ID] !=
nullptr &&
"No SwitchCase with this ID");
8232 return (*CurrSwitchCaseStmts)[
ID];
8236 CurrSwitchCaseStmts->clear();
8240 std::vector<RawComment *> Comments;
8247 BitstreamCursor &Cursor = I->first;
8253 llvm::BitstreamEntry Entry =
8254 Cursor.advanceSkippingSubblocks(BitstreamCursor::AF_DontPopBlockAtEnd);
8256 switch (Entry.Kind) {
8257 case llvm::BitstreamEntry::SubBlock:
8259 Error(
"malformed block record in AST file");
8261 case llvm::BitstreamEntry::EndBlock:
8263 case llvm::BitstreamEntry::Record:
8276 bool IsTrailingComment = Record[Idx++];
8277 bool IsAlmostTrailingComment = Record[Idx++];
8279 SR, Kind, IsTrailingComment, IsAlmostTrailingComment,
8286 Context.
Comments.addDeserializedComments(Comments);
8292 if (
Module *M = D->getImportedOwningModule())
8293 return M->getFullModuleName();
8303 void ASTReader::finishPendingActions() {
8304 while (!PendingIdentifierInfos.empty() ||
8305 !PendingIncompleteDeclChains.empty() || !PendingDeclChains.empty() ||
8306 !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
8307 !PendingUpdateRecords.empty()) {
8310 typedef llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2> >
8312 TopLevelDeclsMap TopLevelDecls;
8314 while (!PendingIdentifierInfos.empty()) {
8317 std::move(PendingIdentifierInfos.back().second);
8318 PendingIdentifierInfos.pop_back();
8325 for (
unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++
I) {
8326 markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
8328 PendingIncompleteDeclChains.clear();
8331 for (
unsigned I = 0; I != PendingDeclChains.size(); ++
I)
8332 loadPendingDeclChain(PendingDeclChains[I].first, PendingDeclChains[I].second);
8333 PendingDeclChains.clear();
8337 TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) {
8339 for (
unsigned I = 0, N = TLD->second.size(); I != N; ++
I) {
8340 pushExternalDeclIntoScope(cast<NamedDecl>(TLD->second[I]), II);
8345 for (
unsigned I = 0; I != PendingMacroIDs.size(); ++
I) {
8348 GlobalIDs.swap(PendingMacroIDs.begin()[
I].second);
8350 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
8352 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
8358 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
8360 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
8366 PendingMacroIDs.clear();
8370 while (!PendingDeclContextInfos.empty()) {
8371 PendingDeclContextInfo Info = PendingDeclContextInfos.front();
8372 PendingDeclContextInfos.pop_front();
8375 Info.D->setDeclContextsImpl(SemaDC, LexicalDC,
getContext());
8379 while (!PendingUpdateRecords.empty()) {
8380 auto Update = PendingUpdateRecords.pop_back_val();
8381 ReadingKindTracker ReadingKind(Read_Decl, *
this);
8382 loadDeclUpdateRecords(Update.first, Update.second);
8388 assert(PendingFakeDefinitionData.empty() &&
8389 "faked up a class definition but never saw the real one");
8395 for (Decl *D : PendingDefinitions) {
8396 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
8397 if (
const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) {
8402 if (
auto RD = dyn_cast<CXXRecordDecl>(D)) {
8403 for (
auto *R = getMostRecentExistingDecl(RD); R;
8404 R = R->getPreviousDecl()) {
8406 cast<CXXRecordDecl>(R)->isThisDeclarationADefinition() &&
8407 "declaration thinks it's the definition but it isn't");
8408 cast<CXXRecordDecl>(R)->DefinitionData = RD->DefinitionData;
8415 if (
auto ID = dyn_cast<ObjCInterfaceDecl>(D)) {
8420 for (
auto *R = getMostRecentExistingDecl(ID); R; R = R->getPreviousDecl())
8421 cast<ObjCInterfaceDecl>(R)->Data = ID->Data;
8426 if (
auto PD = dyn_cast<ObjCProtocolDecl>(D)) {
8427 for (
auto *R = getMostRecentExistingDecl(PD); R; R = R->getPreviousDecl())
8428 cast<ObjCProtocolDecl>(R)->Data = PD->Data;
8434 for (
auto *R = getMostRecentExistingDecl(RTD); R; R = R->getPreviousDecl())
8435 cast<RedeclarableTemplateDecl>(R)->Common = RTD->Common;
8437 PendingDefinitions.clear();
8444 PBEnd = PendingBodies.end();
8445 PB != PBEnd; ++PB) {
8446 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
8450 FD->setLazyBody(PB->second);
8458 PendingBodies.clear();
8461 for (
auto *ND : PendingMergedDefinitionsToDeduplicate)
8463 PendingMergedDefinitionsToDeduplicate.clear();
8466 void ASTReader::diagnoseOdrViolations() {
8467 if (PendingOdrMergeFailures.empty() && PendingOdrMergeChecks.empty())
8474 auto OdrMergeFailures = std::move(PendingOdrMergeFailures);
8475 PendingOdrMergeFailures.clear();
8476 for (
auto &Merge : OdrMergeFailures) {
8477 Merge.first->buildLookup();
8478 Merge.first->decls_begin();
8479 Merge.first->bases_begin();
8480 Merge.first->vbases_begin();
8481 for (
auto *RD : Merge.second) {
8494 while (!PendingOdrMergeChecks.empty()) {
8495 NamedDecl *D = PendingOdrMergeChecks.pop_back_val();
8501 if (D->isImplicit())
8507 const Decl *DCanon = D->getCanonicalDecl();
8509 for (
auto RI : D->redecls()) {
8510 if (RI->getLexicalDeclContext() == CanonDef) {
8525 for (
auto *CanonMember : CanonDef->
decls()) {
8526 if (CanonMember->getCanonicalDecl() == DCanon) {
8535 if (
auto *ND = dyn_cast<NamedDecl>(CanonMember))
8537 Candidates.push_back(ND);
8543 if (!isa<TagDecl>(D))
8544 D->setInvalidDecl();
8548 Deserializing RecursionGuard(
this);
8550 std::string CanonDefModule =
8552 Diag(D->getLocation(), diag::err_module_odr_violation_missing_decl)
8554 << CanonDef << CanonDefModule.empty() << CanonDefModule;
8556 if (Candidates.empty())
8557 Diag(cast<Decl>(CanonDef)->getLocation(),
8558 diag::note_module_odr_violation_no_possible_decls) << D;
8560 for (
unsigned I = 0, N = Candidates.size(); I != N; ++
I)
8561 Diag(Candidates[I]->getLocation(),
8562 diag::note_module_odr_violation_possible_decl)
8566 DiagnosedOdrMergeFailures.insert(CanonDef);
8570 if (OdrMergeFailures.empty())
8575 Deserializing RecursionGuard(
this);
8578 for (
auto &Merge : OdrMergeFailures) {
8581 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
8584 bool Diagnosed =
false;
8585 for (
auto *RD : Merge.second) {
8588 if (Merge.first != RD) {
8593 Diag(Merge.first->getLocation(),
8594 diag::err_module_odr_violation_different_definitions)
8595 << Merge.first << Module.empty() << Module;
8599 Diag(RD->getLocation(),
8600 diag::note_module_odr_violation_different_definitions)
8612 Diag(Merge.first->getLocation(),
8613 diag::err_module_odr_violation_different_instantiations)
8620 if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get())
8621 ReadTimer->startTimer();
8625 assert(NumCurrentElementsDeserializing &&
8626 "FinishedDeserializing not paired with StartedDeserializing");
8627 if (NumCurrentElementsDeserializing == 1) {
8630 finishPendingActions();
8632 --NumCurrentElementsDeserializing;
8634 if (NumCurrentElementsDeserializing == 0) {
8636 while (!PendingExceptionSpecUpdates.empty()) {
8637 auto Updates = std::move(PendingExceptionSpecUpdates);
8638 PendingExceptionSpecUpdates.clear();
8640 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
8642 auto ESI = FPT->getExtProtoInfo().ExceptionSpec;
8644 Listener->ResolvedExceptionSpec(cast<FunctionDecl>(Update.second));
8645 for (
auto *Redecl : Update.second->redecls())
8651 ReadTimer->stopTimer();
8653 diagnoseOdrViolations();
8658 PassInterestingDeclsToConsumer();
8665 auto It = PendingFakeLookupResults.find(II);
8666 if (It != PendingFakeLookupResults.end()) {
8667 for (
auto *ND : It->second)
8678 }
else if (SemaObj->
TUScope) {
8688 ASTReader::ASTReader(
8692 StringRef isysroot,
bool DisableValidation,
8693 bool AllowASTWithCompilerErrors,
8694 bool AllowConfigurationMismatch,
bool ValidateSystemInputs,
8695 bool UseGlobalIndex,
8696 std::unique_ptr<llvm::Timer> ReadTimer)
8697 : Listener(new
PCHValidator(PP, *this)), DeserializationListener(nullptr),
8698 OwnsDeserializationListener(
false), SourceMgr(PP.getSourceManager()),
8699 FileMgr(PP.getFileManager()), PCHContainerRdr(PCHContainerRdr),
8700 Diags(PP.getDiagnostics()), SemaObj(nullptr), PP(PP), Context(Context),
8701 Consumer(nullptr), ModuleMgr(PP.getFileManager(), PCHContainerRdr),
8702 DummyIdResolver(PP),
8703 ReadTimer(std::move(ReadTimer)),
8704 PragmaMSStructState(-1),
8705 PragmaMSPointersToMembersState(-1),
8706 isysroot(isysroot), DisableValidation(DisableValidation),
8707 AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
8708 AllowConfigurationMismatch(AllowConfigurationMismatch),
8709 ValidateSystemInputs(ValidateSystemInputs),
8710 UseGlobalIndex(UseGlobalIndex), TriedLoadingGlobalIndex(
false),
8711 ProcessingUpdateRecords(
false),
8712 CurrSwitchCaseStmts(&SwitchCaseStmts), NumSLocEntriesRead(0),
8713 TotalNumSLocEntries(0), NumStatementsRead(0), TotalNumStatements(0),
8714 NumMacrosRead(0), TotalNumMacros(0), NumIdentifierLookups(0),
8715 NumIdentifierLookupHits(0), NumSelectorsRead(0),
8716 NumMethodPoolEntriesRead(0), NumMethodPoolLookups(0),
8717 NumMethodPoolHits(0), NumMethodPoolTableLookups(0),
8718 NumMethodPoolTableHits(0), TotalNumMethodPoolEntries(0),
8719 NumLexicalDeclContextsRead(0), TotalLexicalDeclContexts(0),
8720 NumVisibleDeclContextsRead(0), TotalVisibleDeclContexts(0),
8721 TotalModulesSizeInBits(0), NumCurrentElementsDeserializing(0),
8722 PassingDeclsToConsumer(
false), ReadingKind(Read_None) {
8725 for (
const auto &Ext : Extensions) {
8726 auto BlockName = Ext->getExtensionMetadata().BlockName;
8727 auto Known = ModuleFileExtensions.find(BlockName);
8728 if (Known != ModuleFileExtensions.end()) {
8729 Diags.
Report(diag::warn_duplicate_module_file_extension)
8734 ModuleFileExtensions.insert({BlockName, Ext});
8739 if (OwnsDeserializationListener)
8740 delete DeserializationListener;
8744 return SemaObj ? SemaObj->
IdResolver : DummyIdResolver;
llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx)
Read an integral value.
Decl * GetExistingDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration.
unsigned IsAvailable
Whether this module is available in the current translation unit.
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
bool isPoisoned() const
Return true if this token has been poisoned.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
SmallVector< std::pair< llvm::BitstreamCursor, serialization::ModuleFile * >, 8 > CommentsCursors
Cursors for comments blocks.
Defines the clang::ASTContext interface.
SourceLocation getEnd() const
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.
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons...
Record code for the preprocessor options table.
static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts, const PreprocessorOptions &ExistingPPOpts, DiagnosticsEngine *Diags, FileManager &FileMgr, std::string &SuggestedPredefines, const LangOptions &LangOpts)
Check the preprocessor options deserialized from the control block against the preprocessor options i...
std::vector< unsigned > PreloadIdentifierOffsets
Offsets of identifiers that we're going to preload within IdentifierTableData.
SmallVector< UnresolvedExportDecl, 2 > UnresolvedExports
The set of export declarations that have yet to be resolved.
static const Decl * getCanonicalDecl(const Decl *D)
The client can handle an AST file that cannot load because it was built with a different version of C...
void setInfo(const DeclarationNameLoc &Info)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
std::string Name
The name of this module.
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.
Source range/offset of a preprocessed entity.
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
std::vector< std::pair< std::string, bool > > Macros
IdentifierIterator * getIdentifiers() override
Retrieve an iterator into the set of all identifiers in all loaded AST files.
Record code for the signature that identifiers this AST file.
void * IdentifierLookupTable
A pointer to an on-disk hash table of opaque type IdentifierHashTable.
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Record code for potentially unused local typedef names.
Record code for map of Objective-C class definition IDs to the ObjC categories in a module that are a...
Smart pointer class that efficiently represents Objective-C method names.
static void updateModuleTimestamp(ModuleFile &MF)
static hash_value_type ComputeHash(Selector Sel)
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system...
static bool checkTargetOptions(const TargetOptions &TargetOpts, const TargetOptions &ExistingTargetOpts, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true)
Compare the given set of target options against an existing set of target options.
A (possibly-)qualified type.
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines)
Receives the preprocessor options.
CtorInitializerType
The different kinds of data that can occur in a CtorInitializer.
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
void setChangedSinceDeserialization()
Note that this identifier has changed since it was loaded from an AST file.
void AddTokenToBody(const Token &Tok)
Add the specified token to the replacement text for the macro.
void setStarLoc(SourceLocation Loc)
NameKind
NameKind - The kind of name this object contains.
The macro directives history for a particular identifier.
Represents a version number in the form major[.minor[.subminor[.build]]].
static bool startsWithASTFileMagic(BitstreamCursor &Stream)
Whether Stream starts with the AST/PCH file magic number 'CPCH'.
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...
The (signed) 'long long' type.
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.
A simple structure that captures a vtable use for the purposes of the ExternalSemaSource.
bool operator()(ModuleFile &M)
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
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...
Record code for the source manager line table information, which stores information about #line direc...
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
bool tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name)
Try to add the given declaration to the top level scope, if it (or a redeclaration of it) hasn't alre...
ObjCXXARCStandardLibraryKind
Enumerate the kinds of standard library that.
This header is part of the module (for layering purposes) but should be textually included...
The 'bool' or '_Bool' type.
bool factoryHasMoreThanOneDecl() const
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
void setKWLoc(SourceLocation Loc)
unsigned getHash() const
Compute a fingerprint of this key for use in on-disk hash table.
void setRParenLoc(SourceLocation Loc)
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
void setStarLoc(SourceLocation Loc)
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 setLAngleLoc(SourceLocation Loc)
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
SourceLocation DirectImportLoc
The source location where the module was explicitly or implicitly imported in the local translation u...
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "...
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
ControlRecordTypes
Record types that occur within the control block.
void addTopHeaderFilename(StringRef Filename)
Add a top-level header filename associated with this module.
unsigned Generation
The generation of which this module file is a part.
void ReadComments() override
Loads comments ranges.
std::vector< UnresolvedConflict > UnresolvedConflicts
The list of conflicts for which the module-id has not yet been resolved.
C Language Family Type Representation.
Defines the SourceManager interface.
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
The 'unknown any' placeholder type.
void setWrittenWidthSpec(TypeSpecifierWidth written)
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
RawCommentList Comments
All comments in this translation unit.
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
unsigned size() const
Number of modules loaded.
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
SmallVector< uint64_t, 4 > PreloadSLocEntries
SLocEntries that we're going to preload.
Module * getCurrentModule()
Retrieves the module that we're currently building, if any.
std::string getTimestampFilename() const
virtual void MacroRead(serialization::MacroID ID, MacroInfo *MI)
A macro was read from the AST file.
CanQualType ObjCBuiltinSelTy
RetTy Visit(TypeLoc TyLoc)
ModuleManager::ModuleConstIterator ModuleConstIterator
void VisitFunctionTypeLoc(FunctionTypeLoc)
ModuleKind Kind
The type of this module.
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
Defines the C++ template declaration subclasses.
Describes a source location entry (SLocEntry) for a macro expansion.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
unsigned getFactoryBits() const
std::vector< std::string > Includes
An LValueReferenceType record.
The placeholder type for builtin functions.
static void completeRedeclChainForTemplateSpecialization(Decl *D)
Defines the clang::MacroInfo and clang::MacroDirective classes.
Specifies the submodules that are imported by this submodule.
std::string ModuleName
The name of the module.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
CanQualType ARCUnbridgedCastTy
A record that stores the set of declarations that are lexically stored within a given DeclContext...
The module file is out-of-date.
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
Specifies an umbrella directory.
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)
unsigned LocalNumObjCCategoriesInMap
The number of redeclaration info entries in ObjCCategoriesMap.
void setHasLineDirectives()
Set the flag that indicates that this FileID has line table entries associated with it...
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
#define CHECK_TARGET_OPT(Field, Name)
A SubstTemplateTypeParmType record.
QualType getRecordType(const RecordDecl *Decl) const
std::unique_ptr< llvm::MemoryBuffer > Buffer
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void setTemplateKeywordLoc(SourceLocation Loc)
void setFlag(TokenFlags Flag)
Set the specified flag.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamespaceDecl - Represent a C++ namespace.
Wrapper for source info for typedefs.
static void markIdentifierFromAST(ASTReader &Reader, IdentifierInfo &II)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
A container of type source information.
RefQualifierKind RefQualifier
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
uint64_t GlobalBitOffset
The global bit offset (or base) of this module.
SmallVector< ObjCMethodDecl *, 2 > Instance
Record code for enabled OpenCL extensions.
Record code for the module build directory.
void * getAsOpaquePtr() const
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...
An ElaboratedType record.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
virtual void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II)
An identifier was deserialized from the AST file.
An UnresolvedUsingType record.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
Wrapper for source info for pointers decayed from arrays and functions.
bool hasAttrEnumOperand() const
ASTFileSignature Signature
The signature of the module file, which may be used along with size and modification time to identify...
Represents a C++ constructor within a class.
TypeLoc getNextTypeLoc() const
An IncompleteArrayType record.
QualType getPipeType(QualType T) const
Return pipe type for the specified type.
The internal '__type_pack_element' template.
A template template parameter that has been substituted for some other template name.
void addPendingMacro(IdentifierInfo *II, ModuleFile *M, uint64_t MacroDirectivesOffset)
Add a macro to deserialize its macro directive history.
Specifies a header that is part of the module but must be textually included.
const uint32_t * SLocEntryOffsets
Offsets for all of the source location entries in the AST file.
bool RelocatablePCH
Whether this precompiled header is a relocatable PCH file.
CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a C++ base specifier.
ARC's unbridged-cast placeholder type.
The client can handle an AST file that cannot load because it is out-of-date relative to its input fi...
void visit(llvm::function_ref< bool(ModuleFile &M)> Visitor, llvm::SmallPtrSetImpl< ModuleFile * > *ModuleFilesHit=nullptr)
Visit each of the modules.
unsigned NumPreprocessedEntities
ArrayRef< ObjCMethodDecl * > getInstanceMethods() const
Retrieve the instance methods found by this visitor.
bool getWarningsAsErrors() const
uint32_t IdentifierID
An ID number that refers to an identifier in an AST file.
An identifier, stored as an IdentifierInfo*.
The internal '__builtin_va_list' typedef.
void addRequirement(StringRef Feature, bool RequiredState, const LangOptions &LangOpts, const TargetInfo &Target)
Add the given feature requirement to the list of features required by this module.
void getExportedModules(SmallVectorImpl< Module * > &Exported) const
Appends this module's list of exported modules to Exported.
Manages the set of modules loaded by an AST reader.
static Qualifiers fromOpaqueValue(unsigned opaque)
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation > > &Sels) override
Read the set of referenced selectors known to the external Sema source.
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type...
std::string ImplicitPTHInclude
The implicit PTH input included at the start of the translation unit, or empty.
const FileEntry * getASTFile() const
The serialized AST file for this module, if one was created.
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
Wrapper for source info for member pointers.
void VisitArrayTypeLoc(ArrayTypeLoc)
Options for controlling the target.
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const
Map a local type ID within a given AST file into a global type ID.
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing)...
bool hasAttrExprOperand() const
void CompleteRedeclChain(const Decl *D) override
If any redeclarations of D have been imported since it was last checked, this digs out those redeclar...
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
The value of the next COUNTER to dispense.
ObjCMethodDecl - Represents an instance or class method declaration.
unsigned getLineTableFilenameID(StringRef Str)
Specifies the umbrella header used to create this module, if any.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
A namespace, stored as a NamespaceDecl*.
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
Record code for header search information.
data_type ReadData(Selector, const unsigned char *d, unsigned DataLen)
Stores a list of template parameters for a TemplateDecl and its derived classes.
void setBegin(SourceLocation b)
Describes a source location entry (SLocEntry) for a buffer.
Used to hold and unique data used to represent #line information.
Record code for the target options table.
static StringRef bytes(const std::vector< T, Allocator > &v)
bool hasAttrOperand() const
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Record code for the array of eagerly deserialized decls.
Defines the clang::Expr interface and subclasses for C++ expressions.
Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx)
int SLocEntryBaseID
The base ID in the source manager's view of this module.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
ContinuousRangeMap< uint32_t, int, 2 > DeclRemap
Remapping table for declaration IDs in this module.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
The collection of all-type qualifiers we support.
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
SourceLocation ImportLoc
The source location where this module was first imported.
Record code for the diagnostic options table.
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...
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
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.
Base wrapper for a particular "section" of type source info.
RecordDecl - Represents a struct/union/class.
C ucontext_t typedef type.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class...
SourceLocation getBegin() const
DeclarationName getName() const
getName - Returns the embedded declaration name.
FunctionType::ExtInfo ExtInfo
One of these records is kept for each identifier that is lexed.
A macro directive exported by a module.
void setLocalRangeEnd(SourceLocation L)
void addLazyDecl(ASTContext &C, uintptr_t ID, AccessSpecifier AS)
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
void disableFileContentsOverride(const FileEntry *File)
Disable overridding the contents of a file, previously enabled with overrideFileContents.
Specifies a top-level header that falls into this (sub)module.
std::string ActualOriginalSourceFileName
The actual original source file name that was used to build this AST file.
The block containing comments.
SmallVectorImpl< ModuleFile * >::const_iterator ModuleConstIterator
This table allows us to fully hide how we implement multi-keyword caching.
AddModuleResult
The result of attempting to add a new module.
The Objective-C 'SEL' type.
bool isDeclInLexicalTraversal(const Decl *D) const
Determine whether the given declaration is stored in the list of declarations lexically within this c...
A library or framework to link against when an entity from this module is used.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
bool instanceHasMoreThanOneDecl() const
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
Iteration over the preprocessed entities.
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
CXXRecordDecl * getPreviousDecl()
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.
Record the location of a macro definition.
unsigned getNumArgs() const
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
The 'char' type, when it is signed.
static std::string resolveFileRelativeToOriginalDir(const std::string &Filename, const std::string &OriginalDir, const std::string &CurrDir)
If a header file is not found at the path that we expect it to be and the PCH file was moved from its...
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...
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
void setBuiltinLoc(SourceLocation Loc)
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions, ASTReaderListener &Listener)
Read the control block for the named AST file.
The 'unsigned long' type.
Specifies a header that has been explicitly excluded from this submodule.
void setRBracketLoc(SourceLocation Loc)
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
SmallVector< Requirement, 2 > Requirements
The set of language features required to use this module.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, LateParsedTemplate * > &LPTMap) override
Read the set of late parsed template functions for this source.
The unsigned 128-bit integer type.
ContinuousRangeMap< uint32_t, int, 2 > PreprocessedEntityRemap
Remapping table for preprocessed entity IDs in this module.
Record code for the module map file that was used to build this AST file.
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args) const
Delete expressions that will be analyzed later.
llvm::SmallPtrSet< ModuleFile *, 4 > HitSet
A set of module files in which we found a result.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
unsigned ASTFileSignature
Helper class that saves the current stream position and then restores it when destroyed.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
static CXXCtorInitializer * Create(ASTContext &Context, FieldDecl *Member, SourceLocation MemberLoc, SourceLocation L, Expr *Init, SourceLocation R, VarDecl **Indices, unsigned NumIndices)
Creates a new member initializer that optionally contains array indices used to describe an elementwi...
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
void setElaboratedKeywordLoc(SourceLocation Loc)
TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template name.
bool isFileOverridden(const FileEntry *File)
Returns true if the file contents have been overridden.
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
Token - This structure provides full information about a lexed token.
method_range methods() const
void setUmbrellaDir(Module *Mod, const DirectoryEntry *UmbrellaDir, Twine NameAsWritten)
Sets the umbrella directory of the given module to the given directory.
unsigned DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
QualType getTypeOfType(QualType t) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes...
unsigned getNumProtocols() const
Wrapper for source info for unresolved typename using decls.
std::string OriginalDir
The directory that the PCH was originally created in.
void setKind(tok::TokenKind K)
Sema * getSema()
Retrieve the semantic analysis object used to analyze the translation unit in which the precompiled h...
void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl * > &Decls) override
Read the set of ext_vector type declarations known to the external Sema source.
An AttributedType record.
An object-like macro definition.
The client can handle an AST file that cannot load because it's compiled configuration doesn't match ...
CanQualType OCLReserveIDTy
StringRef internal_key_type
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
SourceLocation getEnd() const
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
internal_key_type ReadKey(const unsigned char *d, unsigned)
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.
unsigned LocalNumHeaderFileInfos
The number of local HeaderFileInfo structures.
Record code for the set of ext_vector type names.
iterator end()
end - Returns an iterator that has 'finished'.
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.
static void collectMacroDefinitions(const PreprocessorOptions &PPOpts, MacroDefinitionsMap &Macros, SmallVectorImpl< StringRef > *MacroNames=nullptr)
Collect the macro definitions provided by the given preprocessor options.
SourceLocation getBeginLoc() const
Get the begin source location.
const PPEntityOffset * PreprocessedEntityOffsets
Specifies the submodules that are re-exported from this submodule.
TemplateParameterList ** TemplParamLists
TemplParamLists - A new-allocated array of size NumTemplParamLists, containing pointers to the "outer...
serialization::MacroID BaseMacroID
Base macro ID for macros local to this module.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
QualType getParenType(QualType NamedType) const
The Objective-C 'id' type.
void setLParenLoc(SourceLocation Loc)
unsigned InferExportWildcard
Whether, when inferring submodules, the inferr submodules should export all modules they import (e...
void setNameLoc(SourceLocation Loc)
A qualified template name, where the qualification is kept to describe the source code as written...
const TargetInfo & getTargetInfo() const
virtual void HandleInterestingDecl(DeclGroupRef D)
HandleInterestingDecl - Handle the specified interesting declaration.
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.
void setCaretLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
const LangOptions & getLangOpts() const
Wrapper for source info for injected class names of class templates.
bool isAvailable() const
Determine whether this module is available for use within the current translation unit...
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
TypeSourceInfo * GetTypeSourceInfo(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declarator info from the given record.
const unsigned NumSpecialTypeIDs
The number of special type IDs.
A convenient class for passing around template argument information.
void setcudaConfigureCallDecl(FunctionDecl *FD)
Describes a blob that contains the data for a buffer entry.
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Record code for the language options table.
ModuleManager & getModuleManager()
Retrieve the module manager.
void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, const RecordData &Record, unsigned &Idx)
std::string Message
The message provided to the user when there is a conflict.
Wrapper for source info for functions.
Specifies a conflict with another module.
The signed 128-bit integer type.
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.
A UnaryTransformType record.
An ObjCObjectType record.
A ConstantArrayType record.
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
Wrapper for substituted template type parameters.
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...
TemplateName getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param, TemplateName replacement) const
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.
Record code for #pragma optimize options.
uint32_t BitOffset
Offset in the AST file.
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
Specifies a header that is private to this submodule but must be textually included.
Record code for pending implicit instantiations.
Wrapper for substituted template type parameters.
TypeLocReader(ASTReader &Reader, ModuleFile &F, const ASTReader::RecordData &Record, unsigned &Idx)
CanQualType PseudoObjectTy
The internal '__make_integer_seq' template.
bool needsExtraLocalData() const
void setRParenLoc(SourceLocation Loc)
void setLazyBody(uint64_t Offset)
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.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
Record code for #pragma diagnostic mappings.
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
Record code for floating point #pragma options.
CommentRecordTypes
Record types used within a comments block.
static internal_key_type ReadKey(const unsigned char *d, unsigned n)
void setMustBuildLookupTable()
Mark that there are external lexical declarations that we need to include in our lookup table (and th...
The module file is missing.
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
unsigned IsFromModuleFile
Whether this module was loaded from a module file.
std::string OriginalSourceFileName
The original source file name that was used to build the primary AST file, which may have been modifi...
Wrapper for source info for ObjC interfaces.
Record code for the set of known namespaces, which are used for typo correction.
static bool isDiagnosedResult(ASTReader::ASTReadResult ARR, unsigned Caps)
Record code for an array of all of the (sub)modules that were imported by the AST file...
The 'unsigned short' type.
serialization::DeclID BaseDeclID
Base declaration ID for declarations local to this module.
Present this diagnostic as an error.
ModuleManager::ModuleIterator ModuleIterator
SourceLocation FirstLoc
The first source location in this module.
void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation > > &Pending) override
Read the set of pending instantiations known to the external Sema source.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
A BlockPointerType record.
void setProtocolLoc(unsigned i, SourceLocation Loc)
A MemberPointerType record.
ContinuousRangeMap< uint32_t, int, 2 > SLocRemap
Remapping table for source locations in this module.
void setLocalRangeBegin(SourceLocation L)
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
Represents an ObjC class declaration.
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
The AST file itself appears corrupted.
detail::InMemoryDirectory::const_iterator I
void dump()
Dump information about the AST reader to standard error.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
unsigned getNumParams() const
void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &Exprs) override
uint64_t PreprocessorDetailStartOffset
The offset of the start of the preprocessor detail cursor.
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type...
CanQualType UnsignedCharTy
Record code for the table of offsets into the block of source-location information.
friend class ASTIdentifierIterator
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
A SubstTemplateTypeParmPackType record.
Objective-C "id" redefinition type.
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)
TypeCode
Record codes for each kind of type.
Records the location of a macro expansion.
DiagnosticsEngine & getDiagnostics() const
virtual void SelectorRead(serialization::SelectorID iD, Selector Sel)
A selector was read from the AST file.
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
void setUnderlyingTInfo(TypeSourceInfo *TI) const
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
Class that aids in the construction of nested-name-specifiers along with source-location information ...
unsigned getObjCOrBuiltinID() const
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
unsigned IsSystem
Whether this is a "system" module (which assumes that all headers in it are system headers)...
The block containing information about the source manager.
IdentifierInfo * GetIdentifierInfo(ModuleFile &M, const RecordData &Record, unsigned &Idx)
The placeholder type for OpenMP array section.
A VariableArrayType record.
const FileEntry * getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
Sema - This implements semantic analysis and AST building for C.
diag::Severity getExtensionHandlingBehavior() const
const unsigned int NUM_PREDEF_PP_ENTITY_IDS
The number of predefined preprocessed entity IDs.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
void setUsedForHeaderGuard(bool Val)
ASTRecordTypes
Record types that occur within the AST block itself.
A little helper class used to produce diagnostics.
static bool parseModuleFileExtensionMetadata(const SmallVectorImpl< uint64_t > &Record, StringRef Blob, ModuleFileExtensionMetadata &Metadata)
Parse a record and blob containing module file extension metadata.
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
unsigned NumTemplParamLists
NumTemplParamLists - The number of "outer" template parameter lists.
Represents a prototype with parameter type info, e.g.
Defines the major attributes of a submodule, including its name and parent.
llvm::BitstreamCursor Stream
The main bitstream cursor for the main block.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
llvm::DenseMap< ModuleFile *, serialization::DeclID > GlobalToLocalDeclIDs
Mapping from the module files that this module file depends on to the base declaration ID for that mo...
Represents a ValueDecl that came out of a declarator.
The "auto &&" deduction type.
ModuleHeaderRole
Flags describing the role of a module header.
ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel, unsigned PriorGeneration)
ModuleKind
Specifies the kind of module that has been loaded.
A dependent template name that has not been resolved to a template (or set of templates).
DeclarationNameTable DeclarationNames
ArraySizeModifier
Capture whether this is a normal array (e.g.
void SetGloballyVisibleDecls(IdentifierInfo *II, const SmallVectorImpl< uint32_t > &DeclIDs, SmallVectorImpl< Decl * > *Decls=nullptr)
Set the globally-visible declarations associated with the given identifier.
std::vector< bool > & Stack
void ReadModuleMapFile(StringRef ModuleMapPath) override
void setSizeExpr(Expr *Size)
unsigned LocalNumSLocEntries
The number of source location entries in this AST file.
void setCFConstantStringType(QualType T)
Captures information about a #pragma weak directive.
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
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...
Record code for the table of offsets of each macro ID.
const DirectoryEntry * Entry
const uint32_t * TypeOffsets
Offset of each type within the bitstream, indexed by the type ID, or the representation of a Type*...
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo)
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
unsigned UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
void setTemplateNameLoc(SourceLocation Loc)
static NestedNameSpecifier * SuperSpecifier(const ASTContext &Context, CXXRecordDecl *RD)
Returns the nested name specifier representing the __super scope for the given CXXRecordDecl.
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...
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
A record containing CXXBaseSpecifiers.
ASTReaderListener implementation to validate the information of the PCH file against an initialized P...
uint64_t Signature
The module signature.
CommentOptions CommentOpts
Options for parsing comments.
An TemplateSpecializationType record.
An ObjCObjectPointerType record.
Type source information for an attributed type.
An ObjCInterfaceType record.
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
const Type * getTypePtrOrNull() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override
Read the header file information for the given file entry.
Describes a zlib-compressed blob that contains the data for a buffer 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.
StringRef getName() const
Return the actual identifier string.
Record code for the array of VTable uses.
IncludeDirGroup
IncludeDirGroup - Identifies the group an include Entry belongs to, representing its relative positiv...
The 'char' type, when it is unsigned.
void setHasCommaPasting()
static bool isInterestingIdentifier(ASTReader &Reader, IdentifierInfo &II, bool IsModule)
Whether the given identifier is "interesting".
void setModeAttr(bool written)
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...
The directory that the PCH was originally created in.
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...
Declaration of a template type parameter.
std::string WorkingDir
If set, paths are resolved as if the working directory was set to the value of WorkingDir.
unsigned LocalNumIdentifiers
The number of identifiers in this AST file.
void ReadUsedVTables(SmallVectorImpl< ExternalVTableUse > &VTables) override
Read the set of used vtables known to the external Sema source.
The placeholder type for overloaded function sets.
std::string OMPHostIRFile
Name of the IR file that contains the result of the OpenMP target host code generation.
Implements an efficient mapping from strings to IdentifierInfo nodes.
Defines implementation details of the clang::SourceManager class.
MacroArgs - An instance of this class captures information about the formal arguments specified to a ...
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
virtual void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata)
Indicates that a particular module file extension has been read.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
unsigned ConfigMacrosExhaustive
Whether the set of configuration macros is exhaustive.
Record code for the table of offsets to entries in the preprocessing record.
std::unique_ptr< llvm::MemoryBuffer > Buffer
The memory buffer that stores the data associated with this AST file.
Represents a C++ destructor within a class.
ContinuousRangeMap< uint32_t, int, 2 > IdentifierRemap
Remapping table for identifier IDs in this module.
CanQualType OMPArraySectionTy
llvm::BitstreamCursor SLocEntryCursor
Cursor used to read source location entries.
TranslationUnitDecl * getTranslationUnitDecl() const
Defines version macros and version-related utility functions for Clang.
The OpenCL 'half' / ARM NEON __fp16 type.
Defines the clang::Preprocessor interface.
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. ...
The block containing the detailed preprocessing record.
ArgKind getKind() const
Return the kind of stored template argument.
std::pair< SourceLocation, StringRef > getModuleImportLoc(int ID) override
Retrieve the module import location and module name for the given source manager entry ID...
static LineEntry get(unsigned Offs, unsigned Line, int Filename, SrcMgr::CharacteristicKind FileKind, unsigned IncludeOffset)
void setWrittenSignSpec(TypeSpecifierSign written)
llvm::BitstreamCursor InputFilesCursor
The cursor to the start of the input-files block.
unsigned LocalNumMacros
The number of macros in this AST file.
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a source range.
A record containing CXXCtorInitializers.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Record code for the original file that was used to generate the AST file, including both its file ID ...
void setRParenLoc(SourceLocation Loc)
Represents a C++ template name within the type system.
llvm::SmallVector< LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used...
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.
A namespace alias, stored as a NamespaceAliasDecl*.
virtual ~ASTReaderListener()
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
CanQualType UnsignedInt128Ty
An iterator that walks over all of the known identifiers in the lookup table.
SmallVector< uint64_t, 1 > ObjCCategories
The Objective-C category lists for categories known to this module.
void setNameLoc(SourceLocation Loc)
unsigned getInstanceBits() const
void setLParenLoc(SourceLocation Loc)
FileID OriginalSourceFileID
The file ID for the original source file that was used to build this AST file.
A FunctionProtoType record.
void setInheritConstructors(bool Inherit=true)
Set that this base class's constructors should be inherited.
bool HasTimestamps
Whether timestamps are included in this module file.
Describes a source location entry (SLocEntry) for a file.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
Wrapper for source info for enum types.
A block containing a module file extension.
bool isInstanceMethod() const
clang::ObjCRuntime ObjCRuntime
std::string FileName
The file name of the module file.
void setUmbrellaHeader(Module *Mod, const FileEntry *UmbrellaHeader, Twine NameAsWritten)
Sets the umbrella header of the given module to the given header.
void setEllipsisLoc(SourceLocation Loc)
Record code for an update to a decl context's lookup table.
void setHasBaseTypeAsWritten(bool HasBaseType)
Record the location of an inclusion directive, such as an #include or #import statement.
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Record code for #pragma ms_struct options.
InclusionKind
The kind of inclusion directives known to the preprocessor.
QualType withFastQualifiers(unsigned TQs) const
struct CXXOpName CXXOperatorName
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
QualType getSubstTemplateTypeParmPackType(const TemplateTypeParmType *Replaced, const TemplateArgument &ArgPack)
Retrieve a.
void insertOrReplace(const value_type &Val)
void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method)
Add the given method to the list of globally-known methods.
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
void deduplicateMergedDefinitonsFor(NamedDecl *ND)
Clean up the merged definition list.
void StartedDeserializing() override
Notify ASTReader that we started deserialization of a decl or type so until FinishedDeserializing is ...
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
void setArgumentList(ArrayRef< IdentifierInfo * > List, llvm::BumpPtrAllocator &PPAllocator)
Set the specified list of identifiers as the argument list for this macro.
BuiltinTemplateDecl * getMakeIntegerSeqDecl() const
The result type of a method or function.
unsigned SLocEntryBaseOffset
The base offset in the source manager's view of this module.
Record code for the table of offsets of each identifier ID.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
A type, stored as a Type*.
SmallVector< uint64_t, 16 > PreloadedDeclIDs
Record code for undefined but used functions and variables that need a definition in this TU...
void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, const RecordData &Record, unsigned &Idx)
A DependentNameType record.
SmallVector< ObjCMethodDecl *, 2 > Factory
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Record code for the identifier table.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
The AST file was missing.
NestedNameSpecifier * ReadNestedNameSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
void AddEntry(FileID FID, const std::vector< LineEntry > &Entries)
Add a new line entry that has already been encoded into the internal representation of the line table...
The placeholder type for bound member functions.
void setIsUsed(bool Val)
Set the value of the IsUsed flag.
The "auto" deduction type.
std::string CPU
If given, the name of the target CPU to generate code for.
bool getSuppressSystemWarnings() const
void setStarLoc(SourceLocation Loc)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc)
std::vector< std::unique_ptr< ModuleFileExtensionReader > > ExtensionReaders
The list of extension readers that are attached to this module file.
Representation::const_iterator const_iterator
QualType getPackExpansionType(QualType Pattern, Optional< unsigned > NumExpansions)
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
void setTypeofLoc(SourceLocation Loc)
The Objective-C 'Class' type.
SpecifierKind
The kind of specifier that completes this nested name specifier.
std::pair< Module *, bool > findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework, bool IsExplicit)
Find a new module or submodule, or create it if it does not already exist.
void makeNamesVisible(const HiddenNames &Names, Module *Owner)
Make the names within this set of hidden names visible.
StringRef Next() override
Retrieve the next string in the identifier table and advances the iterator for the following string...
The 'unsigned long long' type.
A template template parameter pack that has been substituted for a template template argument pack...
Wrapper for source info for arrays.
virtual void ExtractPCH(llvm::MemoryBufferRef Buffer, llvm::BitstreamReader &StreamFile) const =0
Initialize an llvm::BitstreamReader with the serialized AST inside the PCH container Buffer...
Record code for the set of source location entries that need to be preloaded by the AST reader...
QualifierInfo - A struct with extended info about a syntactic name qualifier, to be used for the case...
The control block was read successfully.
The list of delegating constructor declarations.
Information about a FileID, basically just the logical file that it represents and include stack info...
void setSourceOrder(int pos)
Set the source order of this initializer.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
void setAttrOperandParensRange(SourceRange range)
static bool readBit(unsigned &Bits)
void setIsFunctionLike()
Function/Object-likeness.
const unsigned char * SelectorLookupTableData
A pointer to the character data that comprises the selector table.
Encapsulates changes to the "macros namespace" (the location where the macro name became active...
Representation::iterator iterator
bool ReadFullVersionInformation(StringRef FullVersion) override
Receives the full Clang version information.
serialization::TypeID BaseTypeIndex
Base type ID for types local to this module as represented in the global type ID space.
ContinuousRangeMap< uint32_t, int, 2 > SelectorRemap
Remapping table for selector IDs in this module.
std::string ABI
If given, the name of the target ABI to use.
void setASTFile(const FileEntry *File)
Set the serialized AST file for the top-level module of this module.
bool isGlobalIndexUnavailable() const
Determine whether we tried to load the global index, but failed, e.g., because it is out-of-date or d...
bool hasRevertedBuiltin() const
True if setNotBuiltin() was called.
ExceptionSpecificationType Type
The kind of exception specification this is.
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
void setLAngleLoc(SourceLocation Loc)
serialization::IdentID BaseIdentifierID
Base identifier ID for identifiers local to this module.
MacroInfo * ReadMacroRecord(ModuleFile &F, uint64_t Offset)
Reads the macro record located at the given offset.
File is a PCH file treated as the preamble.
ContinuousRangeMap< unsigned, int, 2 > SLocRemap
const char * getName() const
static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method)
Move the given method to the back of the global list of methods.
const ExtParameterInfo * ExtParameterInfos
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
ExternCContextDecl * getExternCContextDecl() const
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static bool checkHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, StringRef ExistingModuleCachePath, DiagnosticsEngine *Diags, const LangOptions &LangOpts)
Check the header search options deserialized from the control block against the header search options...
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
const TemplateArgument * iterator
A record that stores the set of declarations that are visible from a given DeclContext.
File is a PCH file treated as such.
IdentifierInfo * get(StringRef Name) override
Retrieve the IdentifierInfo for the named identifier.
void setLength(unsigned Len)
Specifies a library or framework to link against.
Record code for file ID of the file or buffer that was used to generate the AST file.
Represents a C++ temporary.
Interfaces are the core concept in Objective-C for object oriented design.
void InitializeContext()
Initializes the ASTContext.
Specifies a header that falls into this (sub)module.
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
ContinuousRangeMap< uint32_t, int, 2 > SubmoduleRemap
Remapping table for submodule IDs in this module.
void setUsed(bool Used=true)
Record code for special CUDA declarations.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
Options for controlling the compiler diagnostics engine.
A list of "interesting" identifiers.
NameVisibilityKind NameVisibility
The visibility of names within this particular module.
An identifier-lookup iterator that enumerates all of the identifiers stored within a set of AST files...
The block of configuration options, used to check that a module is being used in a configuration comp...
TagDecl - Represents the declaration of a struct/union/class/enum.
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply...
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...
PredefinedTypeIDs
Predefined type IDs.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
llvm::BitstreamReader StreamFile
The bitstream reader from which we'll read the AST file.
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
All of the names in this module are hidden.
File is an implicitly-loaded module.
IdentifierTable & getIdentifierTable()
void setProtocolRAngleLoc(SourceLocation Loc)
The 'unsigned char' type.
Cached information about one file (either on disk or in the virtual file system). ...
Metadata describing this particular extension.
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
void setIsC99Varargs()
Varargs querying methods. This can only be set for function-like macros.
MacroInfo * getMacro(serialization::MacroID ID)
Retrieve the macro with the given ID.
uint64_t SizeInBits
The size of this file, in bits.
TemplateParameterList * ReadTemplateParameterList(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template parameter list.
void ProcessWarningOptions(DiagnosticsEngine &Diags, const DiagnosticOptions &Opts, bool ReportDiags=true)
ProcessWarningOptions - Initialize the diagnostic client and process the warning options specified on...
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
The (signed) 'long' type.
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
ModuleReverseIterator rbegin()
Reverse iterator to traverse all loaded modules.
Record code for the offsets of each decl.
void setIdentifierInfo(IdentifierInfo *II)
void ReadMethodPool(Selector Sel) override
Load the contents of the global method pool for a given selector.
void * SelectorLookupTable
A pointer to an on-disk hash table of opaque type ASTSelectorLookupTable.
Metadata for submodules as a whole.
const uint32_t * IdentifierOffsets
Offsets into the identifier table data.
The width of the "fast" qualifier mask.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Class that performs lookup for a selector's entries in the global method pool stored in an AST file...
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
Record code for late parsed template functions.
The (signed) 'short' type.
Defines the clang::TargetOptions class.
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
QualType getIncompleteArrayType(QualType EltTy, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type...
void setDefinitionEndLoc(SourceLocation EndLoc)
Set the location of the last token in the macro.
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings starting...
unsigned LocalNumDecls
The number of declarations in this AST file.
unsigned NumFileSortedDecls
The internal 'instancetype' typedef.
OptionsRecordTypes
Record types that occur within the options block inside the control block.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
void addDecl(NamedDecl *D)
unsigned getNumTypeArgs() const
Describes the categories of an Objective-C class.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
The AST block, which acts as a container around the full AST block.
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
IdentID ReadIdentifierID(const unsigned char *d)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setWrittenTypeSpec(TypeSpecifierType written)
Objective-C "SEL" redefinition type.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line...
SourceLocation getBegin() const
void setAmpLoc(SourceLocation Loc)
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void setLBracketLoc(SourceLocation Loc)
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
static bool checkLanguageOptions(const LangOptions &LangOpts, const LangOptions &ExistingLangOpts, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true)
Compare the given set of language options against an existing set of language options.
An InjectedClassNameType record.
const serialization::DeclID * FileSortedDecls
Array of file-level DeclIDs sorted by file.
PragmaMSPointersToMembersKind
Record code for the extra statistics we gather while generating an AST file.
bool getEnableAllWarnings() const
static Decl * getPredefinedDecl(ASTContext &Context, PredefinedDeclIDs ID)
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
virtual void visitImport(StringRef Filename)
If needsImportVisitation returns true, this is called for each AST file imported by this AST file...
static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags, DiagnosticsEngine &Diags, bool Complain)
std::vector< InputFile > InputFilesLoaded
The input files that have been loaded from this AST file.
The module file was just loaded in response to this call.
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.
HashTableTy::const_iterator iterator
unsigned ComputeHash(Selector Sel)
The AST file was writtten with a different language/target configuration.
ArrayRef< ObjCMethodDecl * > getFactoryMethods() const
Retrieve the instance methods found by this visitor.
const char * HeaderFileInfoTableData
Actual data for the on-disk hash table of header file information.
void markIdentifierUpToDate(IdentifierInfo *II)
Note that this identifier is up-to-date.
const llvm::support::unaligned_uint64_t * InputFileOffsets
Offsets for all of the input file entries in the AST file.
void addArgument(const TemplateArgumentLoc &Loc)
void addHeader(Module *Mod, Module::Header Header, ModuleHeaderRole Role, bool Imported=false)
Adds this header to the given module.
File is a PCH file treated as the actual main file.
llvm::APFloat ReadAPFloat(const RecordData &Record, const llvm::fltSemantics &Sem, unsigned &Idx)
Read a floating-point value.
Record code for referenced selector pool.
std::vector< std::string > MacroIncludes
The injected class name of a C++ class template or class template partial specialization.
ModuleFile * getLocalModuleFile(ModuleFile &M, unsigned ID)
Retrieve the module file with a given local ID within the specified ModuleFile.
Record code for the set of non-builtin, special types.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
void setLParenLoc(SourceLocation Loc)
void setTemplateKeywordLoc(SourceLocation Loc)
void setTypeArgsLAngleLoc(SourceLocation Loc)
uint64_t InputFilesValidationTimestamp
If non-zero, specifies the time when we last validated input files.
CanQualType UnsignedShortTy
const uint32_t * MacroOffsets
Offsets of macros in the preprocessor block.
Base class for declarations which introduce a typedef-name.
unsigned LocalNumSelectors
The number of selectors new to this file.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
Represents a template argument.
Record code for the list of other AST files imported by this AST file.
Selector getLocalSelector(ModuleFile &M, unsigned LocalID)
Retrieve a selector from the given module with its local ID number.
Describes a macro definition within the preprocessing record.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
const ASTTemplateArgumentListInfo * ReadASTTemplateArgumentListInfo(ModuleFile &F, const RecordData &Record, unsigned &Index)
A conflict between two modules.
void setClassTInfo(TypeSourceInfo *TI)
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.
The internal '__NSConstantString' typedef.
Record code for the module name.
Selector getObjCSelector() const
getObjCSelector - Get the Objective-C selector stored in this declaration name.
TemplateName getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param, const TemplateArgument &ArgPack) const
CanQualType ObjCBuiltinIdTy
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.
Describes an inclusion directive within the preprocessing record.
The internal '__builtin_ms_va_list' typedef.
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.
unsigned IsMissingRequirement
Whether this module is missing a feature from Requirements.
not evaluated yet, for special member function
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Record code for a file sorted array of DeclIDs in a module.
void setAmpAmpLoc(SourceLocation Loc)
Record code for the array of Objective-C categories (including extensions).
void updateOutOfDateIdentifier(IdentifierInfo &II) override
Update an out-of-date identifier.
void reserve(ASTContext &C, unsigned N)
Specifies a configuration macro for this module.
void ReadDefinedMacros() override
Read the set of macros defined by this external macro source.
The base class of all kinds of template declarations (e.g., class, function, etc.).
PreprocessorDetailRecordTypes
Record types used within a preprocessor detail block.
static std::pair< GlobalModuleIndex *, ErrorCode > readIndex(StringRef Path)
Read a global index file for the given directory.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
static unsigned moduleKindForDiagnostic(ModuleKind Kind)
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain) override
Receives the file system options.
The basic abstraction for the target Objective-C runtime.
uint64_t MacroStartOffset
The offset of the start of the set of defined macros.
The template argument is a pack expansion of a template name that was provided for a template templat...
Record code for the array of unused file scoped decls.
A FunctionNoProtoType record.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
static bool SkipCursorToBlock(BitstreamCursor &Cursor, unsigned BlockID)
Given a cursor at the start of an AST file, scan ahead and drop the cursor into the start of the give...
Reads an AST files chain containing the contents of a translation unit.
File is an explicitly-loaded module.
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
Expr * ReadExpr(ModuleFile &F)
Reads an expression.
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...
CanQualType UnsignedLongLongTy
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...
QualType getEnumType(const EnumDecl *Decl) const
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(const FileEntry *Entry, bool isVolatile=false, bool ShouldCloseOpenFile=true)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
DeclarationName - The name of a declaration.
Record code for the Objective-C method pool,.
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
Specifies a header that is private to this submodule.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool needsInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
Describes a macro expansion within the preprocessing record.
QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
Selector getSelector() const
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.
detail::InMemoryDirectory::const_iterator E
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
IdentifierResolver IdResolver
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
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.
void setExternalSLocEntrySource(ExternalSLocEntrySource *Source)
ContinuousRangeMap< uint32_t, int, 2 > MacroRemap
Remapping table for macro IDs in this module.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
An RValueReferenceType record.
void ReadDeclarationNameLoc(ModuleFile &F, DeclarationNameLoc &DNLoc, DeclarationName Name, const RecordData &Record, unsigned &Idx)
A type that was preceded by the 'template' keyword, stored as a Type*.
void ClearSwitchCaseIDs()
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, uint32_t Raw) const
Read a source location from raw form.
void setHasExternalLexicalStorage(bool ES=true)
State whether this DeclContext has external storage for declarations lexically in this context...
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
unsigned Map[Count]
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
BuiltinTemplateDecl * getTypePackElementDecl() const
static void PassObjCImplDeclToConsumer(ObjCImplDecl *ImplD, ASTConsumer *Consumer)
Under non-PCH compilation the consumer receives the objc methods before receiving the implementation...
The placeholder type for dependent types.
All of the names in this module are visible.
void setNameLoc(SourceLocation Loc)
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...
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
uint32_t getGeneration() const
Get the current generation of this AST source.
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
time_t getModificationTime() const
void ReadUnresolvedSet(ModuleFile &F, LazyASTUnresolvedSet &Set, const RecordData &Record, unsigned &Idx)
Read a UnresolvedSet structure.
void setAttrEnumOperandLoc(SourceLocation loc)
struct CXXLitOpName CXXLiteralOperatorName
Abstract interface for callback invocations by the ASTReader.
Location wrapper for a TemplateArgument.
C sigjmp_buf typedef type.
std::vector< Conflict > Conflicts
The list of conflicts.
const T * getAs() const
Member-template getAs<specific type>'.
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...
Record code for the table of offsets into the Objective-C method pool.
Represents a C++ base or member initializer.
llvm::iterator_range< ModuleConstIterator > pch_modules() const
A range covering the PCH and preamble module files loaded.
A DependentSizedArrayType record.
CanQualType UnsignedLongTy
Record code for the remapping information used to relate loaded modules to the various offsets and ID...
virtual bool needsImportVisitation() const
Returns true if this ASTReaderListener wants to receive the imports of the AST file via visitImport...
bool InstanceHasMoreThanOneDecl
A key used when looking up entities by DeclarationName.
void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata) override
Indicates that a particular module file extension has been read.
unsigned getNumArgs() const
Record code for declarations that Sema keeps references of.
void ReadTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument array.
void * HeaderFileInfoTable
The on-disk hash table that contains information about each of the header files.
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
bool hasBody() const override
Determine whether this method has a body.
Offsets into the input-files block where input files reside.
bool FactoryHasMoreThanOneDecl
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
CanQualType ObjCBuiltinClassTy
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
PreprocessorRecordTypes
Record types used within a preprocessor block.
static bool isExtHandlingFromDiagsError(DiagnosticsEngine &Diags)
CanQualType BoundMemberTy
The block containing the submodule structure.
void setTypeArgsRAngleLoc(SourceLocation Loc)
Wrapper for source info for record types.
std::string BaseDirectory
The base directory of the module.
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
The template argument is a type.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
Wraps an ObjCPointerType with source location information.
const TypeClass * getTypePtr() const
ContinuousRangeMap< uint32_t, int, 2 > TypeRemap
Remapping table for type IDs in this module.
Selector DecodeSelector(serialization::SelectorID Idx)
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
The template argument is actually a parameter pack.
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
Represents a base class of a C++ class.
Cached information about one directory (either on disk or in the virtual file system).
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any...
uint32_t GetNumExternalSelectors() override
Returns the number of selectors known to the external AST source.
void PrintStats() override
Print some statistics about AST usage.
void insert(const value_type &Val)
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
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.
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
IdentifierInfo * DecodeIdentifierInfo(serialization::IdentifierID ID)
Expr * NoexceptExpr
Noexcept expression, if this is EST_ComputedNoexcept.
NestedNameSpecifierLoc QualifierLoc
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain)
Receives the header search options.
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Canon=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
QualType getTypeOfExprType(Expr *e) const
GCC extension.
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
void setKWLoc(SourceLocation Loc)
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.
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type...
TemplateArgumentLoc ReadTemplateArgumentLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLoc.
unsigned InferSubmodules
Whether we should infer submodules for this module based on the headers.
void setEnd(SourceLocation e)
TemplateArgumentLocInfo GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind.
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
static const ASTTemplateArgumentListInfo * Create(ASTContext &C, const TemplateArgumentListInfo &List)
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.
static ASTFileSignature readASTFileSignature(llvm::BitstreamReader &StreamFile)
Reads and return the signature record from StreamFile's control block, or else returns 0...
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
An TemplateTypeParmType record.
llvm::PointerIntPair< Module *, 1, bool > ExportDecl
Describes an exported module.
Decl * D
The template function declaration to be late parsed.
The template argument is a template name that was provided for a template template parameter...
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
SmallVector< uint64_t, 8 > PragmaDiagMappings
Diagnostic IDs and their mappings that the user changed.
Record code for the filesystem options table.
static hash_value_type ComputeHash(const internal_key_type &a)
Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx)
Reads a token out of a record.
const char * IdentifierTableData
Actual data for the on-disk hash table of identifiers.
void setParam(unsigned i, ParmVarDecl *VD)
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
void * Allocate(size_t Size, unsigned Align=8) const
Level
The level of the diagnostic, after it has been through mapping.
void setOutOfDate(bool OOD)
Set whether the information for this identifier is out of date with respect to the external source...
void setLParenLoc(SourceLocation Loc)
const DeclOffset * DeclOffsets
Offset of each declaration within the bitstream, indexed by the declaration ID (-1).
Location information for a TemplateArgument.
virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the target options.
Record code for the offsets of each type.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
The block containing the definitions of all of the types and decls used within the AST file...
The internal '__va_list_tag' struct, if any.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
virtual void ReadModuleName(StringRef ModuleName)
TypedefDecl * getCFConstantStringDecl() const
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
ASTIdentifierIterator(const ASTReader &Reader, bool SkipModules=false)
The module file had already been loaded.
Defines the clang::TargetInfo interface.
The AST file is out-of-date relative to its input files, and needs to be regenerated.
A SourceLocation and its associated SourceManager.
Defines the clang::VersionTuple class, which represents a version in the form major[.minor[.subminor]].
NameVisibilityKind
Describes the visibility of the various names within a particular module.
void setPrevious(MacroDirective *Prev)
Set previous definition of the macro with the same name.
a linked list of methods with the same selector name but different signatures.
void setRAngleLoc(SourceLocation Loc)
std::pair< ObjCMethodList, ObjCMethodList > GlobalMethods
data_type ReadData(const internal_key_type &k, const unsigned char *d, unsigned DataLen)
Specifies a required feature.
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated, or computed.
SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID)
Returns the source location for the decl ID.
std::vector< std::string > ConfigMacros
The set of "configuration macros", which are macros that (intentionally) change how this module is bu...
TagDecl * getDecl() const
Abstracts clang modules and precompiled header files and holds everything needed to generate debug in...
The AST file was written by a different version of Clang.
Record for offsets of DECL_UPDATES records for declarations that were modified after being deserializ...
static bool checkDiagnosticMappings(DiagnosticsEngine &StoredDiags, DiagnosticsEngine &Diags, bool IsSystem, bool Complain)
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
static void dumpModuleIDMap(StringRef Name, const ContinuousRangeMap< Key, ModuleFile *, InitialCapacity > &Map)
llvm::BitstreamCursor PreprocessorDetailCursor
The cursor to the start of the (optional) detailed preprocessing record block.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
void setProtocolLAngleLoc(SourceLocation Loc)
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
ModuleFile * getOwningModuleFile(const Decl *D)
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
Contains a late templated function.
RecordDecl * getCFConstantStringTagDecl() const
Record code for weak undeclared identifiers.
The block containing information about the preprocessor.
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type...
void StartTranslationUnit(ASTConsumer *Consumer) override
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
void setLocation(SourceLocation L)
bool hadMacroDefinition() const
Returns true if this identifier was #defined to some value at any moment.
uint32_t TypeID
An ID number that refers to a type in an AST file.
Wrapper for source info for builtin types.
void setRParenLoc(SourceLocation Loc)
A set of overloaded template declarations.
Wrapper for template type parameters.
Record code for the headers search options table.
Module * Other
The module that this module conflicts with.
A trivial tuple used to represent a source range.
std::string ModuleMapPath
NamedDecl - This represents a decl with a name.
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
AST file metadata, including the AST file version number and information about the compiler used to b...
The block of input files, which were used as inputs to create this AST file.
static DeclarationName getUsingDirectiveName()
getUsingDirectiveName - Return name for all using-directives.
Present this diagnostic as a warning.
ObjCMethodList * getNext() const
llvm::BitstreamCursor MacroCursor
The cursor to the start of the preprocessor block, which stores all of the macro definitions.
const uint32_t * SelectorOffsets
Offsets into the selector lookup table's data array where each selector resides.
void UpdateSema()
Update the state of Sema after loading some additional modules.
unsigned LocalNumTypes
The number of types in this AST file.
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
Represents a C++ namespace alias.
void setTemplateNameLoc(SourceLocation Loc)
Kind
The basic Objective-C runtimes that we know about.
The internal '__NSConstantString' tag type.
static TypeIdx fromTypeID(TypeID ID)
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...
InputFileRecordTypes
Record types that occur within the input-files block inside the control block.
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.
A function-like macro definition.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
The Objective-C 'Protocol' type.
QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced, QualType Replacement) const
Retrieve a substitution-result type.
The global specifier '::'. There is no stored value.
T * getFETokenInfo() const
getFETokenInfo/setFETokenInfo - The language front-end is allowed to associate arbitrary metadata wit...
The control block, which contains all of the information that needs to be validated prior to committi...
Wrapper for source info for pointers.
std::string Triple
If given, the name of the target triple to compile for.
Wrapper for source info for block pointers.
void ReadModuleName(StringRef ModuleName) override
This class handles loading and caching of source files into memory.
ExceptionSpecInfo ExceptionSpec
PredefinedDeclIDs
Predefined declaration IDs.
Record code for an update to the TU's lexically contained declarations.
A class which abstracts out some details necessary for making a call.
void setElaboratedKeywordLoc(SourceLocation Loc)
Source range/offset of a preprocessed entity.
void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind) override
This is called for each AST file loaded.
const serialization::ObjCCategoriesInfo * ObjCCategoriesMap
Array of category list location information within this module file, sorted by the definition ID...
bool loadGlobalIndex()
Attempts to load the global index.
void startToken()
Reset all flags to cleared.
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
Objective-C "Class" redefinition type.
A PackExpansionType record.
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls) override
Read the set of potentially unused typedefs known to the source.
A single template declaration.
CanQualType OCLClkEventTy
The pseudo-object placeholder type.
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
virtual bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain)
Receives the diagnostic options.
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.
Record code for #pragma ms_struct 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.
A DependentTemplateSpecializationType record.
CanQualType UnsignedIntTy
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, unsigned LocalID)
Record code for the array of tentative definitions.
static void addMethodsToPool(Sema &S, ArrayRef< ObjCMethodDecl * > Methods, ObjCMethodList &List)
Add the given set of methods to the method list.
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.