47 #include "llvm/ADT/Hashing.h"
48 #include "llvm/ADT/StringExtras.h"
49 #include "llvm/Bitcode/BitstreamReader.h"
50 #include "llvm/Support/ErrorHandling.h"
51 #include "llvm/Support/FileSystem.h"
52 #include "llvm/Support/MemoryBuffer.h"
53 #include "llvm/Support/Path.h"
54 #include "llvm/Support/SaveAndRestore.h"
55 #include "llvm/Support/raw_ostream.h"
59 #include <system_error>
61 using namespace clang;
62 using namespace clang::serialization;
63 using namespace clang::serialization::reader;
64 using llvm::BitstreamCursor;
73 return First->ReadFullVersionInformation(FullVersion) ||
74 Second->ReadFullVersionInformation(FullVersion);
77 First->ReadModuleName(ModuleName);
78 Second->ReadModuleName(ModuleName);
81 First->ReadModuleMapFile(ModuleMapPath);
82 Second->ReadModuleMapFile(ModuleMapPath);
87 bool AllowCompatibleDifferences) {
88 return First->ReadLanguageOptions(LangOpts, Complain,
89 AllowCompatibleDifferences) ||
90 Second->ReadLanguageOptions(LangOpts, Complain,
91 AllowCompatibleDifferences);
95 bool AllowCompatibleDifferences) {
96 return First->ReadTargetOptions(TargetOpts, Complain,
97 AllowCompatibleDifferences) ||
98 Second->ReadTargetOptions(TargetOpts, Complain,
99 AllowCompatibleDifferences);
103 return First->ReadDiagnosticOptions(DiagOpts, Complain) ||
104 Second->ReadDiagnosticOptions(DiagOpts, Complain);
109 return First->ReadFileSystemOptions(FSOpts, Complain) ||
110 Second->ReadFileSystemOptions(FSOpts, Complain);
116 return First->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
118 Second->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
123 std::string &SuggestedPredefines) {
124 return First->ReadPreprocessorOptions(PPOpts, Complain,
125 SuggestedPredefines) ||
126 Second->ReadPreprocessorOptions(PPOpts, Complain, SuggestedPredefines);
130 First->ReadCounter(M, Value);
131 Second->ReadCounter(M, Value);
134 return First->needsInputFileVisitation() ||
135 Second->needsInputFileVisitation();
138 return First->needsSystemInputFileVisitation() ||
139 Second->needsSystemInputFileVisitation();
142 First->visitModuleFile(Filename);
143 Second->visitModuleFile(Filename);
148 bool Continue =
false;
149 if (First->needsInputFileVisitation() &&
150 (!isSystem || First->needsSystemInputFileVisitation()))
151 Continue |= First->visitInputFile(Filename, isSystem, isOverridden);
152 if (Second->needsInputFileVisitation() &&
153 (!isSystem || Second->needsSystemInputFileVisitation()))
154 Continue |= Second->visitInputFile(Filename, isSystem, isOverridden);
175 bool AllowCompatibleDifferences =
true) {
176 #define LANGOPT(Name, Bits, Default, Description) \
177 if (ExistingLangOpts.Name != LangOpts.Name) { \
179 Diags->Report(diag::err_pch_langopt_mismatch) \
180 << Description << LangOpts.Name << ExistingLangOpts.Name; \
184 #define VALUE_LANGOPT(Name, Bits, Default, Description) \
185 if (ExistingLangOpts.Name != LangOpts.Name) { \
187 Diags->Report(diag::err_pch_langopt_value_mismatch) \
192 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
193 if (ExistingLangOpts.get##Name() != LangOpts.get##Name()) { \
195 Diags->Report(diag::err_pch_langopt_value_mismatch) \
200 #define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
201 if (!AllowCompatibleDifferences) \
202 LANGOPT(Name, Bits, Default, Description)
204 #define COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) \
205 if (!AllowCompatibleDifferences) \
206 ENUM_LANGOPT(Name, Bits, Default, Description)
208 #define BENIGN_LANGOPT(Name, Bits, Default, Description)
209 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
210 #include "clang/Basic/LangOptions.def"
214 Diags->
Report(diag::err_pch_langopt_value_mismatch) <<
"module features";
220 Diags->
Report(diag::err_pch_langopt_value_mismatch)
221 <<
"target Objective-C runtime";
228 Diags->
Report(diag::err_pch_langopt_value_mismatch)
229 <<
"block command names";
245 bool AllowCompatibleDifferences =
true) {
246 #define CHECK_TARGET_OPT(Field, Name) \
247 if (TargetOpts.Field != ExistingTargetOpts.Field) { \
249 Diags->Report(diag::err_pch_targetopt_mismatch) \
250 << Name << TargetOpts.Field << ExistingTargetOpts.Field; \
261 if (!AllowCompatibleDifferences)
264 #undef CHECK_TARGET_OPT
272 std::sort(ExistingFeatures.begin(), ExistingFeatures.end());
273 std::sort(ReadFeatures.begin(), ReadFeatures.end());
279 ExistingFeatures.begin(), ExistingFeatures.end(), ReadFeatures.begin(),
280 ReadFeatures.end(), std::back_inserter(UnmatchedExistingFeatures));
281 std::set_difference(ReadFeatures.begin(), ReadFeatures.end(),
282 ExistingFeatures.begin(), ExistingFeatures.end(),
283 std::back_inserter(UnmatchedReadFeatures));
287 if (AllowCompatibleDifferences && UnmatchedReadFeatures.empty())
291 for (StringRef Feature : UnmatchedReadFeatures)
292 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
294 for (StringRef Feature : UnmatchedExistingFeatures)
295 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
299 return !UnmatchedReadFeatures.empty() || !UnmatchedExistingFeatures.empty();
305 bool AllowCompatibleDifferences) {
306 const LangOptions &ExistingLangOpts = PP.getLangOpts();
308 Complain ? &Reader.Diags :
nullptr,
309 AllowCompatibleDifferences);
314 bool AllowCompatibleDifferences) {
315 const TargetOptions &ExistingTargetOpts = PP.getTargetInfo().getTargetOpts();
317 Complain ? &Reader.Diags :
nullptr,
318 AllowCompatibleDifferences);
322 typedef llvm::StringMap<std::pair<StringRef,
bool > >
324 typedef llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8> >
339 for (
auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) {
348 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror=" +
367 bool IsSystem,
bool Complain) {
375 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Wsystem-headers";
382 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror";
389 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Weverything -Werror";
396 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-pedantic-errors";
414 assert(ModuleMgr.
size() >= 1 &&
"what ASTFile is this then");
423 ModuleFile *TopImport = *ModuleMgr.
rbegin();
424 while (!TopImport->ImportedBy.empty())
425 TopImport = TopImport->ImportedBy[0];
429 StringRef ModuleName = TopImport->ModuleName;
430 assert(!ModuleName.empty() &&
"diagnostic options read before module name");
432 Module *M = PP.getHeaderSearchInfo().lookupModule(ModuleName);
433 assert(M &&
"missing module");
444 MacroDefinitionsMap &Macros,
446 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
447 StringRef Macro = PPOpts.
Macros[I].first;
448 bool IsUndef = PPOpts.
Macros[I].second;
450 std::pair<StringRef, StringRef> MacroPair = Macro.split(
'=');
451 StringRef MacroName = MacroPair.first;
452 StringRef MacroBody = MacroPair.second;
456 if (MacroNames && !Macros.count(MacroName))
457 MacroNames->push_back(MacroName);
459 Macros[MacroName] = std::make_pair(
"",
true);
464 if (MacroName.size() == Macro.size())
468 StringRef::size_type
End = MacroBody.find_first_of(
"\n\r");
469 MacroBody = MacroBody.substr(0, End);
472 if (MacroNames && !Macros.count(MacroName))
473 MacroNames->push_back(MacroName);
474 Macros[MacroName] = std::make_pair(MacroBody,
false);
486 std::string &SuggestedPredefines,
489 MacroDefinitionsMap ASTFileMacros;
491 MacroDefinitionsMap ExistingMacros;
495 for (
unsigned I = 0, N = ExistingMacroNames.size(); I != N; ++I) {
497 StringRef MacroName = ExistingMacroNames[I];
498 std::pair<StringRef, bool> Existing = ExistingMacros[MacroName];
501 llvm::StringMap<std::pair<StringRef,
bool > >::iterator Known
502 = ASTFileMacros.find(MacroName);
503 if (Known == ASTFileMacros.end()) {
508 if (Existing.second) {
509 SuggestedPredefines +=
"#undef ";
510 SuggestedPredefines += MacroName.str();
511 SuggestedPredefines +=
'\n';
513 SuggestedPredefines +=
"#define ";
514 SuggestedPredefines += MacroName.str();
515 SuggestedPredefines +=
' ';
516 SuggestedPredefines += Existing.first.str();
517 SuggestedPredefines +=
'\n';
524 if (Existing.second != Known->second.second) {
526 Diags->
Report(diag::err_pch_macro_def_undef)
527 << MacroName << Known->second.second;
534 if (Existing.second || Existing.first == Known->second.first)
539 Diags->
Report(diag::err_pch_macro_def_conflict)
540 << MacroName << Known->second.first << Existing.first;
554 if (LangOpts.Modules &&
563 for (
unsigned I = 0, N = ExistingPPOpts.
Includes.size(); I != N; ++I) {
564 StringRef File = ExistingPPOpts.
Includes[I];
572 SuggestedPredefines +=
"#include \"";
573 SuggestedPredefines += File;
574 SuggestedPredefines +=
"\"\n";
577 for (
unsigned I = 0, N = ExistingPPOpts.
MacroIncludes.size(); I != N; ++I) {
584 SuggestedPredefines +=
"#__include_macros \"";
585 SuggestedPredefines += File;
586 SuggestedPredefines +=
"\"\n##\n";
594 std::string &SuggestedPredefines) {
598 Complain? &Reader.Diags :
nullptr,
609 StringRef SpecificModuleCachePath,
610 StringRef ExistingModuleCachePath,
613 if (LangOpts.Modules) {
614 if (SpecificModuleCachePath != ExistingModuleCachePath) {
616 Diags->
Report(diag::err_pch_modulecache_mismatch)
617 << SpecificModuleCachePath << ExistingModuleCachePath;
626 StringRef SpecificModuleCachePath,
629 PP.getHeaderSearchInfo().getModuleCachePath(),
630 Complain ? &Reader.Diags :
nullptr,
635 PP.setCounterValue(Value);
643 bool TakeOwnership) {
644 DeserializationListener = Listener;
645 OwnsDeserializationListener = TakeOwnership;
655 std::pair<unsigned, unsigned>
657 using namespace llvm::support;
658 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
659 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
660 return std::make_pair(KeyLen, DataLen);
665 using namespace llvm::support;
667 unsigned N = endian::readNext<uint16_t, little, unaligned>(d);
669 F, endian::readNext<uint32_t, little, unaligned>(d));
671 return SelTable.getNullarySelector(FirstII);
673 return SelTable.getUnarySelector(FirstII);
676 Args.push_back(FirstII);
677 for (
unsigned I = 1; I != N; ++I)
678 Args.push_back(Reader.getLocalIdentifier(
679 F, endian::readNext<uint32_t, little, unaligned>(d)));
681 return SelTable.getSelector(N, Args.data());
687 using namespace llvm::support;
691 Result.ID = Reader.getGlobalSelectorID(
692 F, endian::readNext<uint32_t, little, unaligned>(d));
693 unsigned FullInstanceBits = endian::readNext<uint16_t, little, unaligned>(d);
694 unsigned FullFactoryBits = endian::readNext<uint16_t, little, unaligned>(d);
695 Result.InstanceBits = FullInstanceBits & 0x3;
696 Result.InstanceHasMoreThanOneDecl = (FullInstanceBits >> 2) & 0x1;
697 Result.FactoryBits = FullFactoryBits & 0x3;
698 Result.FactoryHasMoreThanOneDecl = (FullFactoryBits >> 2) & 0x1;
699 unsigned NumInstanceMethods = FullInstanceBits >> 3;
700 unsigned NumFactoryMethods = FullFactoryBits >> 3;
703 for (
unsigned I = 0; I != NumInstanceMethods; ++I) {
705 F, endian::readNext<uint32_t, little, unaligned>(d)))
706 Result.Instance.push_back(Method);
710 for (
unsigned I = 0; I != NumFactoryMethods; ++I) {
712 F, endian::readNext<uint32_t, little, unaligned>(d)))
713 Result.Factory.push_back(Method);
720 return llvm::HashString(a);
723 std::pair<unsigned, unsigned>
725 using namespace llvm::support;
726 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
727 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
728 return std::make_pair(KeyLen, DataLen);
733 assert(n >= 2 && d[n-1] ==
'\0');
734 return StringRef((
const char*) d, n-1);
748 const unsigned char* d,
750 using namespace llvm::support;
751 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
752 bool IsInteresting = RawID & 0x01;
757 IdentID ID = Reader.getGlobalIdentifierID(F, RawID);
758 if (!IsInteresting) {
763 II = &Reader.getIdentifierTable().getOwn(k);
766 Reader.SetIdentifierInfo(
ID, II);
773 Reader.markIdentifierUpToDate(II);
777 unsigned ObjCOrBuiltinID = endian::readNext<uint16_t, little, unaligned>(d);
778 unsigned Bits = endian::readNext<uint16_t, little, unaligned>(d);
779 bool CPlusPlusOperatorKeyword = Bits & 0x01;
781 bool HasRevertedTokenIDToIdentifier = Bits & 0x01;
783 bool Poisoned = Bits & 0x01;
785 bool ExtensionToken = Bits & 0x01;
787 bool hadMacroDefinition = Bits & 0x01;
790 assert(Bits == 0 &&
"Extra bits in the identifier?");
797 II = &Reader.getIdentifierTable().getOwn(StringRef(k));
800 Reader.markIdentifierUpToDate(II);
801 if (!II->isFromAST()) {
805 II->setChangedSinceDeserialization();
810 if (HasRevertedTokenIDToIdentifier && II->getTokenID() != tok::identifier)
811 II->RevertTokenIDToIdentifier();
812 II->setObjCOrBuiltinID(ObjCOrBuiltinID);
813 assert(II->isExtensionToken() == ExtensionToken &&
814 "Incorrect extension token flag");
815 (void)ExtensionToken;
817 II->setIsPoisoned(
true);
818 assert(II->isCPlusPlusOperatorKeyword() == CPlusPlusOperatorKeyword &&
819 "Incorrect C++ operator keyword flag");
820 (void)CPlusPlusOperatorKeyword;
824 if (hadMacroDefinition) {
825 uint32_t MacroDirectivesOffset =
826 endian::readNext<uint32_t, little, unaligned>(d);
829 Reader.addPendingMacro(II, &F, MacroDirectivesOffset);
832 Reader.SetIdentifierInfo(
ID, II);
838 for (; DataLen > 0; DataLen -= 4)
839 DeclIDs.push_back(Reader.getGlobalDeclID(
840 F, endian::readNext<uint32_t, little, unaligned>(d)));
841 Reader.SetGloballyVisibleDecls(II, DeclIDs);
849 llvm::FoldingSetNodeID
ID;
850 ID.AddInteger(Key.
Kind);
872 return ID.ComputeHash();
906 std::pair<unsigned, unsigned>
908 using namespace llvm::support;
909 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
910 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
911 return std::make_pair(KeyLen, DataLen);
916 using namespace llvm::support;
922 Key.Data = (uint64_t)Reader.getLocalIdentifier(
923 F, endian::readNext<uint32_t, little, unaligned>(d));
929 (uint64_t)Reader.getLocalSelector(
930 F, endian::readNext<uint32_t, little, unaligned>(
931 d)).getAsOpaquePtr();
937 Key.Data = (uint64_t)Reader.getLocalIdentifier(
938 F, endian::readNext<uint32_t, little, unaligned>(d));
953 const unsigned char* d,
955 using namespace llvm::support;
956 unsigned NumDecls = endian::readNext<uint16_t, little, unaligned>(d);
958 const_cast<unsigned char *
>(d));
959 return std::make_pair(Start, Start + NumDecls);
962 bool ASTReader::ReadDeclContextStorage(
ModuleFile &M,
964 const std::pair<uint64_t, uint64_t> &Offsets,
968 if (Offsets.first != 0) {
969 Cursor.JumpToBit(Offsets.first);
973 unsigned Code = Cursor.ReadCode();
974 unsigned RecCode = Cursor.readRecord(Code, Record, &Blob);
976 Error(
"Expected lexical block");
985 if (Offsets.second != 0) {
986 Cursor.JumpToBit(Offsets.second);
990 unsigned Code = Cursor.ReadCode();
991 unsigned RecCode = Cursor.readRecord(Code, Record, &Blob);
993 Error(
"Expected visible lookup table block");
997 (
const unsigned char *)Blob.data() + Record[0],
998 (
const unsigned char *)Blob.data() +
sizeof(uint32_t),
999 (
const unsigned char *)Blob.data(),
1006 void ASTReader::Error(StringRef Msg) {
1007 Error(diag::err_fe_pch_malformed, Msg);
1009 Diag(diag::note_module_cache_path)
1010 << PP.getHeaderSearchInfo().getModuleCachePath();
1014 void ASTReader::Error(
unsigned DiagID,
1015 StringRef Arg1, StringRef Arg2) {
1016 if (Diags.isDiagnosticInFlight())
1017 Diags.SetDelayedDiagnostic(DiagID, Arg1, Arg2);
1019 Diag(DiagID) << Arg1 << Arg2;
1028 bool ASTReader::ParseLineTable(
ModuleFile &F,
1029 const RecordData &Record) {
1034 std::map<int, int> FileIDs;
1035 for (
int I = 0, N = Record[Idx++]; I != N; ++I) {
1037 auto Filename = ReadPath(F, Record, Idx);
1042 std::vector<LineEntry> Entries;
1043 while (Idx < Record.size()) {
1044 int FID = Record[Idx++];
1045 assert(FID >= 0 &&
"Serialized line entries for non-local file.");
1050 unsigned NumEntries = Record[Idx++];
1051 assert(NumEntries &&
"Numentries is 00000");
1053 Entries.reserve(NumEntries);
1054 for (
unsigned I = 0; I != NumEntries; ++I) {
1055 unsigned FileOffset = Record[Idx++];
1056 unsigned LineNo = Record[Idx++];
1057 int FilenameID = FileIDs[Record[Idx++]];
1060 unsigned IncludeOffset = Record[Idx++];
1062 FileKind, IncludeOffset));
1064 LineTable.
AddEntry(FileID::get(FID), Entries);
1071 bool ASTReader::ReadSourceManagerBlock(
ModuleFile &F) {
1072 using namespace SrcMgr;
1080 SLocEntryCursor = F.
Stream;
1083 if (F.
Stream.SkipBlock()) {
1084 Error(
"malformed block record in AST file");
1090 Error(
"malformed source manager block record in AST file");
1096 llvm::BitstreamEntry E = SLocEntryCursor.advanceSkippingSubblocks();
1099 case llvm::BitstreamEntry::SubBlock:
1101 Error(
"malformed block record in AST file");
1103 case llvm::BitstreamEntry::EndBlock:
1105 case llvm::BitstreamEntry::Record:
1113 switch (SLocEntryCursor.readRecord(E.ID, Record, &Blob)) {
1132 const std::string &OriginalDir,
1133 const std::string &CurrDir) {
1134 assert(OriginalDir != CurrDir &&
1135 "No point trying to resolve the file if the PCH dir didn't change");
1136 using namespace llvm::sys;
1138 fs::make_absolute(filePath);
1139 assert(path::is_absolute(OriginalDir));
1142 path::const_iterator fileDirI = path::begin(path::parent_path(filePath)),
1143 fileDirE = path::end(path::parent_path(filePath));
1144 path::const_iterator origDirI = path::begin(OriginalDir),
1145 origDirE = path::end(OriginalDir);
1147 while (fileDirI != fileDirE && origDirI != origDirE &&
1148 *fileDirI == *origDirI) {
1152 for (; origDirI != origDirE; ++origDirI)
1153 path::append(currPCHPath,
"..");
1154 path::append(currPCHPath, fileDirI, fileDirE);
1155 path::append(currPCHPath, path::filename(Filename));
1156 return currPCHPath.str();
1163 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1164 Error(
"source location entry ID out-of-range for AST file");
1168 ModuleFile *F = GlobalSLocEntryMap.find(-ID)->second;
1173 ++NumSLocEntriesRead;
1174 llvm::BitstreamEntry Entry = SLocEntryCursor.advance();
1175 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1176 Error(
"incorrectly-formatted source location entry in AST file");
1182 switch (SLocEntryCursor.readRecord(Entry.ID, Record, &Blob)) {
1184 Error(
"incorrectly-formatted source location entry in AST file");
1190 unsigned InputID = Record[4];
1191 InputFile IF = getInputFile(*F, InputID);
1204 IncludeLoc = getImportLocation(F);
1209 ID, BaseOffset + Record[0]);
1212 FileInfo.NumCreatedFIDs = Record[5];
1217 unsigned NumFileDecls = Record[7];
1219 assert(F->
FileSortedDecls &&
"FILE_SORTED_DECLS not encountered yet ?");
1220 FileDeclIDs[FID] = FileDeclsInfo(F, llvm::makeArrayRef(FirstDecl,
1224 const SrcMgr::ContentCache *ContentCache
1225 =
SourceMgr.getOrCreateContentCache(File,
1227 if (OverriddenBuffer && !ContentCache->BufferOverridden &&
1228 ContentCache->ContentsEntry == ContentCache->OrigEntry) {
1229 unsigned Code = SLocEntryCursor.ReadCode();
1231 unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, &Blob);
1234 Error(
"AST record has invalid code");
1238 std::unique_ptr<llvm::MemoryBuffer> Buffer
1239 = llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), File->
getName());
1247 const char *Name = Blob.data();
1248 unsigned Offset = Record[0];
1254 IncludeLoc = getImportLocation(F);
1256 unsigned Code = SLocEntryCursor.ReadCode();
1259 = SLocEntryCursor.readRecord(Code, Record, &Blob);
1262 Error(
"AST record has invalid code");
1266 std::unique_ptr<llvm::MemoryBuffer> Buffer =
1267 llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name);
1269 BaseOffset + Offset, IncludeLoc);
1276 ReadSourceLocation(*F, Record[2]),
1277 ReadSourceLocation(*F, Record[3]),
1280 BaseOffset + Record[0]);
1292 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1293 Error(
"source location entry ID out-of-range for AST file");
1298 ModuleFile *M = GlobalSLocEntryMap.find(-ID)->second;
1309 if (F->ImportLoc.isValid())
1310 return F->ImportLoc;
1314 if (F->ImportedBy.empty() || !F->ImportedBy[0]) {
1319 return F->ImportedBy[0]->FirstLoc;
1326 if (Cursor.EnterSubBlock(BlockID)) {
1327 Error(
"malformed block record in AST file");
1332 uint64_t
Offset = Cursor.GetCurrentBitNo();
1333 unsigned Code = Cursor.ReadCode();
1336 if (Code != llvm::bitc::DEFINE_ABBREV) {
1337 Cursor.JumpToBit(Offset);
1340 Cursor.ReadAbbrevRecord();
1348 Tok.
setLocation(ReadSourceLocation(F, Record, Idx));
1364 Stream.JumpToBit(Offset);
1373 unsigned Flags = BitstreamCursor::AF_DontPopBlockAtEnd;
1374 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks(Flags);
1376 switch (Entry.Kind) {
1377 case llvm::BitstreamEntry::SubBlock:
1379 Error(
"malformed block record in AST file");
1381 case llvm::BitstreamEntry::EndBlock:
1383 case llvm::BitstreamEntry::Record:
1406 SubmoduleID SubModID = getGlobalSubmoduleID(F, Record[NextIndex++]);
1408 MacroInfo *MI = PP.AllocateDeserializedMacroInfo(Loc, SubModID);
1415 bool isC99VarArgs = Record[NextIndex++];
1416 bool isGNUVarArgs = Record[NextIndex++];
1417 bool hasCommaPasting = Record[NextIndex++];
1419 unsigned NumArgs = Record[NextIndex++];
1420 for (
unsigned i = 0; i != NumArgs; ++i)
1421 MacroArgs.push_back(getLocalIdentifier(F, Record[NextIndex++]));
1429 PP.getPreprocessorAllocator());
1436 if (NextIndex + 1 == Record.size() && PP.getPreprocessingRecord() &&
1440 GlobalID = getGlobalPreprocessedEntityID(F, Record[NextIndex]);
1442 PreprocessingRecord::PPEntityID PPID =
1443 PPRec.getPPEntityID(GlobalID - 1,
true);
1445 PPRec.getPreprocessedEntity(PPID));
1447 PPRec.RegisterMacroDefinition(Macro, PPDef);
1460 Token Tok = ReadToken(F, Record, Idx);
1473 &&
"Invalid index into preprocessed entity index remap");
1475 return LocalID + I->second;
1479 return llvm::hash_combine(ikey.
Size, ikey.
ModTime);
1493 if (llvm::sys::path::is_absolute(a.
Filename) &&
1501 return FileMgr.
getFile(Key.Filename);
1503 std::string Resolved = Key.Filename;
1505 return FileMgr.
getFile(Resolved);
1510 return FEA && FEA == FEB;
1513 std::pair<unsigned, unsigned>
1515 using namespace llvm::support;
1516 unsigned KeyLen = (
unsigned) endian::readNext<uint16_t, little, unaligned>(d);
1517 unsigned DataLen = (
unsigned) *d++;
1518 return std::make_pair(KeyLen, DataLen);
1523 using namespace llvm::support;
1525 ikey.
Size = off_t(endian::readNext<uint64_t, little, unaligned>(d));
1526 ikey.ModTime = time_t(endian::readNext<uint64_t, little, unaligned>(d));
1527 ikey.Filename = (
const char *)d;
1528 ikey.Imported =
true;
1535 const unsigned char *
End = d + DataLen;
1536 using namespace llvm::support;
1538 unsigned Flags = *d++;
1540 ((Flags >> 6) & 0x03);
1541 HFI.isImport = (Flags >> 5) & 0x01;
1542 HFI.isPragmaOnce = (Flags >> 4) & 0x01;
1543 HFI.DirInfo = (Flags >> 2) & 0x03;
1544 HFI.Resolved = (Flags >> 1) & 0x01;
1545 HFI.IndexHeaderMapHeader = Flags & 0x01;
1546 HFI.NumIncludes = endian::readNext<uint16_t, little, unaligned>(d);
1547 HFI.ControllingMacroID = Reader.getGlobalIdentifierID(
1548 M, endian::readNext<uint32_t, little, unaligned>(d));
1549 if (
unsigned FrameworkOffset =
1550 endian::readNext<uint32_t, little, unaligned>(d)) {
1553 StringRef FrameworkName(FrameworkStrings + FrameworkOffset - 1);
1554 HFI.Framework = HS->getUniqueFrameworkName(FrameworkName);
1558 uint32_t LocalSMID = endian::readNext<uint32_t, little, unaligned>(d);
1562 SubmoduleID GlobalSMID = Reader.getGlobalSubmoduleID(M, LocalSMID);
1563 Module *Mod = Reader.getSubmodule(GlobalSMID);
1564 HFI.isModuleHeader =
true;
1567 Reader.getPreprocessor().getHeaderSearchInfo().getModuleMap();
1571 std::string Filename = key.
Filename;
1573 Reader.ResolveImportedPath(M, Filename);
1575 ModMap.
addHeader(Mod, H, HFI.getHeaderRole());
1579 assert(End == d &&
"Wrong data length in HeaderFileInfo deserialization");
1583 HFI.External =
true;
1589 uint64_t MacroDirectivesOffset) {
1590 assert(NumCurrentElementsDeserializing > 0 &&
"Missing deserialization guard");
1591 PendingMacroIDs[II].push_back(PendingMacroInfo(M, MacroDirectivesOffset));
1599 E = ModuleMgr.rend(); I != E; ++I) {
1600 BitstreamCursor &MacroCursor = (*I)->MacroCursor;
1603 if (!MacroCursor.getBitStreamReader())
1606 BitstreamCursor Cursor = MacroCursor;
1607 Cursor.JumpToBit((*I)->MacroStartOffset);
1611 llvm::BitstreamEntry E = Cursor.advanceSkippingSubblocks();
1614 case llvm::BitstreamEntry::SubBlock:
1616 Error(
"malformed block record in AST file");
1618 case llvm::BitstreamEntry::EndBlock:
1621 case llvm::BitstreamEntry::Record:
1623 switch (Cursor.readRecord(E.ID, Record)) {
1629 getLocalIdentifier(**I, Record[0]);
1645 class IdentifierLookupVisitor {
1648 unsigned PriorGeneration;
1649 unsigned &NumIdentifierLookups;
1650 unsigned &NumIdentifierLookupHits;
1654 IdentifierLookupVisitor(StringRef Name,
unsigned PriorGeneration,
1655 unsigned &NumIdentifierLookups,
1656 unsigned &NumIdentifierLookupHits)
1658 PriorGeneration(PriorGeneration),
1659 NumIdentifierLookups(NumIdentifierLookups),
1660 NumIdentifierLookupHits(NumIdentifierLookupHits),
1665 static bool visit(
ModuleFile &M,
void *UserData) {
1666 IdentifierLookupVisitor *This
1667 =
static_cast<IdentifierLookupVisitor *
>(UserData);
1680 ++This->NumIdentifierLookups;
1681 ASTIdentifierLookupTable::iterator Pos =
1682 IdTable->find_hashed(This->Name, This->NameHash, &Trait);
1683 if (Pos == IdTable->end())
1689 ++This->NumIdentifierLookupHits;
1704 unsigned PriorGeneration = 0;
1705 if (getContext().getLangOpts().Modules)
1706 PriorGeneration = IdentifierGeneration[&II];
1712 if (!loadGlobalIndex()) {
1713 if (GlobalIndex->lookupIdentifier(II.
getName(), Hits)) {
1718 IdentifierLookupVisitor Visitor(II.
getName(), PriorGeneration,
1719 NumIdentifierLookups,
1720 NumIdentifierLookupHits);
1721 ModuleMgr.visit(IdentifierLookupVisitor::visit, &Visitor, HitsPtr);
1722 markIdentifierUpToDate(&II);
1732 if (getContext().getLangOpts().Modules)
1733 IdentifierGeneration[II] = getGeneration();
1737 const PendingMacroInfo &PMInfo) {
1742 Cursor.JumpToBit(PMInfo.MacroDirectivesOffset);
1744 struct ModuleMacroRecord {
1756 llvm::BitstreamEntry Entry =
1757 Cursor.advance(BitstreamCursor::AF_DontPopBlockAtEnd);
1758 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1759 Error(
"malformed block record in AST file");
1769 ModuleMacros.push_back(ModuleMacroRecord());
1770 auto &Info = ModuleMacros.back();
1771 Info.SubModID = getGlobalSubmoduleID(M, Record[0]);
1772 Info.MI = getMacro(getGlobalMacroID(M, Record[1]));
1773 for (
int I = 2, N = Record.size(); I != N; ++I)
1774 Info.Overrides.push_back(getGlobalSubmoduleID(M, Record[I]));
1779 Error(
"malformed block record in AST file");
1790 std::reverse(ModuleMacros.begin(), ModuleMacros.end());
1792 for (
auto &MMR : ModuleMacros) {
1794 for (
unsigned ModID : MMR.Overrides) {
1795 Module *Mod = getSubmodule(ModID);
1796 auto *Macro = PP.getModuleMacro(Mod, II);
1797 assert(Macro &&
"missing definition for overridden macro");
1798 Overrides.push_back(Macro);
1801 bool Inserted =
false;
1802 Module *Owner = getSubmodule(MMR.SubModID);
1803 PP.addModuleMacro(Owner, II, MMR.MI, Overrides, Inserted);
1814 unsigned Idx = 0, N = Record.size();
1821 MacroInfo *MI = getMacro(getGlobalMacroID(M, Record[Idx++]));
1822 MD = PP.AllocateDefMacroDirective(MI, Loc);
1826 MD = PP.AllocateUndefMacroDirective(Loc);
1830 bool isPublic = Record[Idx++];
1831 MD = PP.AllocateVisibilityMacroDirective(Loc, isPublic);
1843 PP.setLoadedMacroDirective(II, Latest);
1846 ASTReader::InputFileInfo
1847 ASTReader::readInputFileInfo(ModuleFile &F,
unsigned ID) {
1849 BitstreamCursor &Cursor = F.InputFilesCursor;
1851 Cursor.JumpToBit(F.InputFileOffsets[ID-1]);
1853 unsigned Code = Cursor.ReadCode();
1857 unsigned Result = Cursor.readRecord(Code, Record, &Blob);
1858 assert(static_cast<InputFileRecordTypes>(Result) ==
INPUT_FILE &&
1859 "invalid record type for input file");
1862 std::string Filename;
1867 assert(Record[0] == ID &&
"Bogus stored ID or offset");
1868 StoredSize =
static_cast<off_t
>(Record[1]);
1869 StoredTime =
static_cast<time_t
>(Record[2]);
1870 Overridden =
static_cast<bool>(Record[3]);
1872 ResolveImportedPath(F, Filename);
1874 InputFileInfo R = { std::move(Filename), StoredSize, StoredTime, Overridden };
1878 std::string ASTReader::getInputFileName(
ModuleFile &F,
unsigned int ID) {
1879 return readInputFileInfo(F, ID).Filename;
1899 InputFileInfo FI = readInputFileInfo(F, ID);
1900 off_t StoredSize = FI.StoredSize;
1901 time_t StoredTime = FI.StoredTime;
1902 bool Overridden = FI.Overridden;
1903 StringRef Filename = FI.Filename;
1906 = Overridden? FileMgr.getVirtualFile(Filename, StoredSize, StoredTime)
1907 : FileMgr.getFile(Filename,
false);
1911 if (File ==
nullptr && !F.
OriginalDir.empty() && !CurrentDir.empty() &&
1916 if (!Resolved.empty())
1917 File = FileMgr.getFile(Resolved);
1922 if (Overridden && File ==
nullptr) {
1923 File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime);
1926 if (File ==
nullptr) {
1928 std::string ErrorStr =
"could not find file '";
1929 ErrorStr += Filename;
1930 ErrorStr +=
"' referenced by AST file";
1931 Error(ErrorStr.c_str());
1945 Error(diag::err_fe_pch_file_overridden, Filename);
1952 FileMgr.modifyFileEntry(const_cast<FileEntry*>(File),
1953 StoredSize, StoredTime);
1956 bool IsOutOfDate =
false;
1960 (StoredSize != File->
getSize() ||
1961 #if defined(LLVM_ON_WIN32)
1981 while (ImportStack.back()->ImportedBy.size() > 0)
1982 ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
1985 StringRef TopLevelPCHName(ImportStack.back()->FileName);
1986 Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
1989 if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
1990 Diag(diag::note_pch_required_by)
1991 << Filename << ImportStack[0]->FileName;
1992 for (
unsigned I = 1; I < ImportStack.size(); ++I)
1993 Diag(diag::note_pch_required_by)
1994 << ImportStack[I-1]->FileName << ImportStack[I]->FileName;
1997 if (!Diags.isDiagnosticInFlight())
1998 Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
2021 if (Filename.empty() || llvm::sys::path::is_absolute(Filename))
2025 llvm::sys::path::append(Buffer, Prefix, Filename);
2026 Filename.assign(Buffer.begin(), Buffer.end());
2030 ASTReader::ReadControlBlock(ModuleFile &F,
2032 const ModuleFile *ImportedBy,
2033 unsigned ClientLoadCapabilities) {
2034 BitstreamCursor &Stream = F.Stream;
2037 Error(
"malformed block record in AST file");
2049 unsigned NumInputs = 0;
2050 unsigned NumUserInputs = 0;
2052 llvm::BitstreamEntry Entry = Stream.advance();
2054 switch (Entry.Kind) {
2056 Error(
"malformed block record in AST file");
2058 case llvm::BitstreamEntry::EndBlock: {
2061 PP.getHeaderSearchInfo().getHeaderSearchOpts();
2065 if (!DisableValidation) {
2066 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
2072 unsigned N = NumUserInputs;
2073 if (ValidateSystemInputs ||
2079 for (
unsigned I = 0; I < N; ++I) {
2080 InputFile IF = getInputFile(F, I+1, Complain);
2087 Listener->visitModuleFile(F.FileName);
2089 if (Listener && Listener->needsInputFileVisitation()) {
2090 unsigned N = Listener->needsSystemInputFileVisitation() ? NumInputs
2092 for (
unsigned I = 0; I < N; ++I) {
2093 bool IsSystem = I >= NumUserInputs;
2094 InputFileInfo FI = readInputFileInfo(F, I+1);
2095 Listener->visitInputFile(FI.Filename, IsSystem, FI.Overridden);
2102 case llvm::BitstreamEntry::SubBlock:
2105 F.InputFilesCursor = Stream;
2106 if (Stream.SkipBlock() ||
2109 Error(
"malformed block record in AST file");
2115 if (Stream.SkipBlock()) {
2116 Error(
"malformed block record in AST file");
2122 case llvm::BitstreamEntry::Record:
2133 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2135 : diag::err_pch_version_too_new);
2139 bool hasErrors = Record[5];
2140 if (hasErrors && !DisableValidation && !AllowASTWithCompilerErrors) {
2141 Diag(diag::err_pch_with_compiler_errors);
2145 F.RelocatablePCH = Record[4];
2147 if (F.RelocatablePCH)
2148 F.BaseDirectory = isysroot.empty() ?
"/" : isysroot;
2151 StringRef ASTBranch = Blob;
2152 if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
2153 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2154 Diag(diag::err_pch_different_branch) << ASTBranch << CurBranch;
2161 assert((!F.Signature || F.Signature == Record[0]) &&
"signature changed");
2162 F.Signature = Record[0];
2167 unsigned Idx = 0, N = Record.size();
2176 off_t StoredSize = (off_t)Record[Idx++];
2177 time_t StoredModTime = (time_t)Record[Idx++];
2179 auto ImportedFile = ReadPath(F, Record, Idx);
2182 switch(ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F, Loaded,
2183 StoredSize, StoredModTime, StoredSignature,
2184 ClientLoadCapabilities)) {
2185 case Failure:
return Failure;
2188 case OutOfDate:
return OutOfDate;
2190 case ConfigurationMismatch:
return ConfigurationMismatch;
2191 case HadErrors:
return HadErrors;
2202 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2204 if (Listener && &F == *ModuleMgr.begin() &&
2205 ParseLanguageOptions(Record, Complain, *Listener,
2206 AllowCompatibleConfigurationMismatch) &&
2207 !DisableValidation && !AllowConfigurationMismatch)
2208 return ConfigurationMismatch;
2213 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch)==0;
2214 if (Listener && &F == *ModuleMgr.begin() &&
2215 ParseTargetOptions(Record, Complain, *Listener,
2216 AllowCompatibleConfigurationMismatch) &&
2217 !DisableValidation && !AllowConfigurationMismatch)
2218 return ConfigurationMismatch;
2223 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate)==0;
2224 if (Listener && &F == *ModuleMgr.begin() &&
2225 !AllowCompatibleConfigurationMismatch &&
2226 ParseDiagnosticOptions(Record, Complain, *Listener) &&
2233 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch)==0;
2234 if (Listener && &F == *ModuleMgr.begin() &&
2235 !AllowCompatibleConfigurationMismatch &&
2236 ParseFileSystemOptions(Record, Complain, *Listener) &&
2237 !DisableValidation && !AllowConfigurationMismatch)
2238 return ConfigurationMismatch;
2243 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch)==0;
2244 if (Listener && &F == *ModuleMgr.begin() &&
2245 !AllowCompatibleConfigurationMismatch &&
2246 ParseHeaderSearchOptions(Record, Complain, *Listener) &&
2247 !DisableValidation && !AllowConfigurationMismatch)
2248 return ConfigurationMismatch;
2253 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch)==0;
2254 if (Listener && &F == *ModuleMgr.begin() &&
2255 !AllowCompatibleConfigurationMismatch &&
2256 ParsePreprocessorOptions(Record, Complain, *Listener,
2257 SuggestedPredefines) &&
2258 !DisableValidation && !AllowConfigurationMismatch)
2259 return ConfigurationMismatch;
2264 F.OriginalSourceFileID = FileID::get(Record[0]);
2265 F.ActualOriginalSourceFileName = Blob;
2266 F.OriginalSourceFileName = F.ActualOriginalSourceFileName;
2267 ResolveImportedPath(F, F.OriginalSourceFileName);
2271 F.OriginalSourceFileID = FileID::get(Record[0]);
2275 F.OriginalDir = Blob;
2279 F.ModuleName = Blob;
2281 Listener->ReadModuleName(F.ModuleName);
2285 assert(!F.ModuleName.empty() &&
2286 "MODULE_DIRECTORY found before MODULE_NAME");
2289 Module *M = PP.getHeaderSearchInfo().lookupModule(F.ModuleName);
2290 if (M && M->Directory) {
2295 PP.getFileManager().getDirectory(Blob);
2296 if (!BuildDir || BuildDir != M->Directory) {
2297 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2298 Diag(diag::err_imported_module_relocated)
2299 << F.ModuleName << Blob << M->Directory->getName();
2303 F.BaseDirectory = M->Directory->getName();
2305 F.BaseDirectory = Blob;
2311 if (ASTReadResult Result =
2312 ReadModuleMapFileBlock(Record, F, ImportedBy, ClientLoadCapabilities))
2317 NumInputs = Record[0];
2318 NumUserInputs = Record[1];
2319 F.InputFileOffsets =
2320 (
const llvm::support::unaligned_uint64_t *)Blob.data();
2321 F.InputFilesLoaded.resize(NumInputs);
2328 ASTReader::ReadASTBlock(
ModuleFile &F,
unsigned ClientLoadCapabilities) {
2329 BitstreamCursor &Stream = F.
Stream;
2332 Error(
"malformed block record in AST file");
2339 llvm::BitstreamEntry Entry = Stream.advance();
2341 switch (Entry.Kind) {
2343 Error(
"error at end of module block in AST file");
2345 case llvm::BitstreamEntry::EndBlock: {
2353 !getContext().getLangOpts().CPlusPlus)
2358 case llvm::BitstreamEntry::SubBlock:
2366 if (Stream.SkipBlock() ||
2369 Error(
"malformed block record in AST file");
2376 if (!PP.getExternalSource())
2377 PP.setExternalSource(
this);
2379 if (Stream.SkipBlock() ||
2381 Error(
"malformed block record in AST file");
2389 if (Stream.SkipBlock() ||
2392 Error(
"malformed preprocessor detail record in AST file");
2398 if (!PP.getPreprocessingRecord())
2399 PP.createPreprocessingRecord();
2400 if (!PP.getPreprocessingRecord()->getExternalSource())
2401 PP.getPreprocessingRecord()->SetExternalSource(*
this);
2405 if (ReadSourceManagerBlock(F))
2410 if (ASTReadResult Result = ReadSubmoduleBlock(F, ClientLoadCapabilities))
2415 BitstreamCursor
C = Stream;
2416 if (Stream.SkipBlock() ||
2418 Error(
"malformed comments block in AST file");
2421 CommentsCursors.push_back(std::make_pair(C, &F));
2426 if (Stream.SkipBlock()) {
2427 Error(
"malformed block record in AST file");
2434 case llvm::BitstreamEntry::Record:
2442 switch ((
ASTRecordTypes)Stream.readRecord(Entry.ID, Record, &Blob)) {
2448 Error(
"duplicate TYPE_OFFSET record in AST file");
2453 unsigned LocalBaseTypeIndex = Record[1];
2458 GlobalTypeMap.insert(std::make_pair(getTotalNumTypes(), &F));
2462 std::make_pair(LocalBaseTypeIndex,
2472 Error(
"duplicate DECL_OFFSET record in AST file");
2477 unsigned LocalBaseDeclID = Record[1];
2483 GlobalDeclMap.insert(
2489 std::make_pair(LocalBaseDeclID, F.
BaseDeclID - LocalBaseDeclID));
2505 =
static_cast<unsigned int>(Blob.size() /
sizeof(
KindDeclIDPair));
2515 (
const unsigned char *)Blob.data() + Record[Idx++],
2516 (
const unsigned char *)Blob.data() +
sizeof(uint32_t),
2517 (
const unsigned char *)Blob.data(),
2519 if (
Decl *D = GetExistingDecl(ID)) {
2520 auto *DC = cast<DeclContext>(D);
2524 LookupTable = Table;
2526 PendingVisibleUpdates[
ID].push_back(std::make_pair(Table, &F));
2539 PP.getIdentifierTable().setExternalIdentifierLookup(
this);
2545 Error(
"duplicate IDENTIFIER_OFFSET record in AST file");
2550 unsigned LocalBaseIdentifierID = Record[1];
2556 GlobalIdentifierMap.insert(std::make_pair(getTotalNumIdentifiers() + 1,
2562 std::make_pair(LocalBaseIdentifierID,
2565 IdentifiersLoaded.resize(IdentifiersLoaded.size()
2574 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2575 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
2579 if (SpecialTypes.empty()) {
2580 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2581 SpecialTypes.push_back(getGlobalTypeID(F, Record[I]));
2585 if (SpecialTypes.size() != Record.size()) {
2586 Error(
"invalid special-types record");
2590 for (
unsigned I = 0, N = Record.size(); I != N; ++I) {
2592 if (!SpecialTypes[I])
2593 SpecialTypes[I] =
ID;
2600 TotalNumStatements += Record[0];
2601 TotalNumMacros += Record[1];
2602 TotalLexicalDeclContexts += Record[2];
2603 TotalVisibleDeclContexts += Record[3];
2607 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2608 UnusedFileScopedDecls.push_back(getGlobalDeclID(F, Record[I]));
2612 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2613 DelegatingCtorDecls.push_back(getGlobalDeclID(F, Record[I]));
2617 if (Record.size() % 4 != 0) {
2618 Error(
"invalid weak identifiers record");
2624 WeakUndeclaredIdentifiers.clear();
2627 for (
unsigned I = 0, N = Record.size(); I < N; ) {
2628 WeakUndeclaredIdentifiers.push_back(
2629 getGlobalIdentifierID(F, Record[I++]));
2630 WeakUndeclaredIdentifiers.push_back(
2631 getGlobalIdentifierID(F, Record[I++]));
2632 WeakUndeclaredIdentifiers.push_back(
2633 ReadSourceLocation(F, Record, I).getRawEncoding());
2634 WeakUndeclaredIdentifiers.push_back(Record[I++]);
2641 unsigned LocalBaseSelectorID = Record[1];
2647 GlobalSelectorMap.insert(std::make_pair(getTotalNumSelectors()+1, &F));
2652 std::make_pair(LocalBaseSelectorID,
2668 TotalNumMethodPoolEntries += Record[1];
2672 if (!Record.empty()) {
2673 for (
unsigned Idx = 0, N = Record.size() - 1; Idx < N; ) {
2674 ReferencedSelectorsData.push_back(getGlobalSelectorID(F,
2676 ReferencedSelectorsData.push_back(ReadSourceLocation(F, Record, Idx).
2683 if (!Record.empty() && Listener)
2684 Listener->ReadCounter(F, Record[0]);
2695 unsigned SLocSpaceSize = Record[1];
2702 unsigned RangeStart =
2704 GlobalSLocEntryMap.insert(std::make_pair(RangeStart, &F));
2709 GlobalSLocOffsetMap.insert(
2711 - SLocSpaceSize,&F));
2726 const unsigned char *Data = (
const unsigned char*)Blob.data();
2727 const unsigned char *DataEnd = Data + Blob.size();
2747 while(Data < DataEnd) {
2748 using namespace llvm::support;
2749 uint16_t Len = endian::readNext<uint16_t, little, unaligned>(Data);
2750 StringRef Name = StringRef((
const char*)Data, Len);
2754 Error(
"SourceLocation remap refers to unknown module");
2758 uint32_t SLocOffset =
2759 endian::readNext<uint32_t, little, unaligned>(Data);
2760 uint32_t IdentifierIDOffset =
2761 endian::readNext<uint32_t, little, unaligned>(Data);
2762 uint32_t MacroIDOffset =
2763 endian::readNext<uint32_t, little, unaligned>(Data);
2764 uint32_t PreprocessedEntityIDOffset =
2765 endian::readNext<uint32_t, little, unaligned>(Data);
2766 uint32_t SubmoduleIDOffset =
2767 endian::readNext<uint32_t, little, unaligned>(Data);
2768 uint32_t SelectorIDOffset =
2769 endian::readNext<uint32_t, little, unaligned>(Data);
2770 uint32_t DeclIDOffset =
2771 endian::readNext<uint32_t, little, unaligned>(Data);
2772 uint32_t TypeIndexOffset =
2773 endian::readNext<uint32_t, little, unaligned>(Data);
2775 uint32_t
None = std::numeric_limits<uint32_t>::max();
2777 auto mapOffset = [&](uint32_t
Offset, uint32_t BaseOffset,
2778 RemapBuilder &Remap) {
2780 Remap.insert(std::make_pair(
Offset,
2781 static_cast<int>(BaseOffset -
Offset)));
2783 mapOffset(SLocOffset, OM->SLocEntryBaseOffset,
SLocRemap);
2784 mapOffset(IdentifierIDOffset, OM->BaseIdentifierID, IdentifierRemap);
2785 mapOffset(MacroIDOffset, OM->BaseMacroID, MacroRemap);
2786 mapOffset(PreprocessedEntityIDOffset, OM->BasePreprocessedEntityID,
2787 PreprocessedEntityRemap);
2788 mapOffset(SubmoduleIDOffset, OM->BaseSubmoduleID, SubmoduleRemap);
2789 mapOffset(SelectorIDOffset, OM->BaseSelectorID, SelectorRemap);
2790 mapOffset(DeclIDOffset, OM->BaseDeclID, DeclRemap);
2791 mapOffset(TypeIndexOffset, OM->BaseTypeIndex, TypeRemap);
2800 if (ParseLineTable(F, Record))
2808 Error(
"Multiple SOURCE_LOCATION_PRELOADS records in AST file");
2817 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2818 ExtVectorDecls.push_back(getGlobalDeclID(F, Record[I]));
2822 if (Record.size() % 3 != 0) {
2823 Error(
"Invalid VTABLE_USES record");
2832 for (
unsigned Idx = 0, N = Record.size(); Idx != N; ) {
2833 VTableUses.push_back(getGlobalDeclID(F, Record[Idx++]));
2834 VTableUses.push_back(
2835 ReadSourceLocation(F, Record, Idx).getRawEncoding());
2836 VTableUses.push_back(Record[Idx++]);
2841 if (PendingInstantiations.size() % 2 != 0) {
2842 Error(
"Invalid existing PendingInstantiations");
2846 if (Record.size() % 2 != 0) {
2847 Error(
"Invalid PENDING_IMPLICIT_INSTANTIATIONS block");
2851 for (
unsigned I = 0, N = Record.size(); I != N; ) {
2852 PendingInstantiations.push_back(getGlobalDeclID(F, Record[I++]));
2853 PendingInstantiations.push_back(
2854 ReadSourceLocation(F, Record, I).getRawEncoding());
2859 if (Record.size() != 2) {
2860 Error(
"Invalid SEMA_DECL_REFS block");
2863 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2864 SemaDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
2872 unsigned LocalBasePreprocessedEntityID = Record[0];
2874 unsigned StartingID;
2875 if (!PP.getPreprocessingRecord())
2876 PP.createPreprocessingRecord();
2877 if (!PP.getPreprocessingRecord()->getExternalSource())
2878 PP.getPreprocessingRecord()->SetExternalSource(*
this);
2880 = PP.getPreprocessingRecord()
2887 GlobalPreprocessedEntityMap.insert(std::make_pair(StartingID, &F));
2892 std::make_pair(LocalBasePreprocessedEntityID,
2900 if (Record.size() % 2 != 0) {
2901 Error(
"invalid DECL_UPDATE_OFFSETS block in AST file");
2904 for (
unsigned I = 0, N = Record.size(); I != N; I += 2) {
2906 DeclUpdateOffsets[
ID].push_back(std::make_pair(&F, Record[I + 1]));
2910 if (
Decl *D = GetExistingDecl(ID))
2911 PendingUpdateRecords.push_back(std::make_pair(ID, D));
2917 if (Record.size() % 3 != 0) {
2918 Error(
"invalid DECL_REPLACEMENTS block in AST file");
2921 for (
unsigned I = 0, N = Record.size(); I != N; I += 3)
2922 ReplacedDecls[getGlobalDeclID(F, Record[I])]
2923 = ReplacedDeclInfo(&F, Record[I+1], Record[I+2]);
2929 Error(
"duplicate OBJC_CATEGORIES_MAP record in AST file");
2944 Error(
"duplicate CXX_BASE_SPECIFIER_OFFSETS record in AST file");
2955 Error(
"duplicate CXX_CTOR_INITIALIZERS_OFFSETS record in AST file");
2969 Record.begin(), Record.end());
2975 CUDASpecialDeclRefs.clear();
2976 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2977 CUDASpecialDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
2989 &PP.getHeaderSearchInfo(),
2990 Blob.data() + Record[2]));
2992 PP.getHeaderSearchInfo().SetExternalSource(
this);
2993 if (!PP.getHeaderSearchInfo().getExternalLookup())
2994 PP.getHeaderSearchInfo().SetExternalLookup(
this);
3001 FPPragmaOptions.swap(Record);
3006 OpenCLExtensions.swap(Record);
3010 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3011 TentativeDefinitions.push_back(getGlobalDeclID(F, Record[I]));
3015 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3016 KnownNamespaces.push_back(getGlobalDeclID(F, Record[I]));
3020 if (UndefinedButUsed.size() % 2 != 0) {
3021 Error(
"Invalid existing UndefinedButUsed");
3025 if (Record.size() % 2 != 0) {
3026 Error(
"invalid undefined-but-used record");
3029 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3030 UndefinedButUsed.push_back(getGlobalDeclID(F, Record[I++]));
3031 UndefinedButUsed.push_back(
3032 ReadSourceLocation(F, Record, I).getRawEncoding());
3036 for (
unsigned I = 0, N = Record.size(); I != N;) {
3037 DelayedDeleteExprs.push_back(getGlobalDeclID(F, Record[I++]));
3038 const uint64_t
Count = Record[I++];
3039 DelayedDeleteExprs.push_back(Count);
3040 for (uint64_t C = 0; C <
Count; ++
C) {
3041 DelayedDeleteExprs.push_back(ReadSourceLocation(F, Record, I).getRawEncoding());
3042 bool IsArrayForm = Record[I++] == 1;
3043 DelayedDeleteExprs.push_back(IsArrayForm);
3053 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3054 unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
3057 ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
3070 Error(
"duplicate LOCAL_REDECLARATIONS_MAP record in AST file");
3081 Error(
"duplicate MACRO_OFFSET record in AST file");
3086 unsigned LocalBaseMacroID = Record[1];
3091 GlobalMacroMap.insert(std::make_pair(getTotalNumMacros() + 1, &F));
3095 std::make_pair(LocalBaseMacroID,
3104 LateParsedTemplates.append(Record.begin(), Record.end());
3109 if (Record.size() != 1) {
3110 Error(
"invalid pragma optimize record");
3113 OptimizeOffPragmaLocation = ReadSourceLocation(F, Record[0]);
3117 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3118 UnusedLocalTypedefNameCandidates.push_back(
3119 getGlobalDeclID(F, Record[I]));
3126 ASTReader::ReadModuleMapFileBlock(RecordData &Record,
ModuleFile &F,
3128 unsigned ClientLoadCapabilities) {
3143 "MODULE_NAME should come before MODULE_MAP_FILE");
3149 auto &
Map = PP.getHeaderSearchInfo().getModuleMap();
3150 const FileEntry *ModMap = M ?
Map.getModuleMapFileForUniquing(M) :
nullptr;
3152 assert(ImportedBy &&
"top-level import should be verified");
3153 if ((ClientLoadCapabilities & ARR_Missing) == 0)
3160 assert(M->
Name == F.
ModuleName &&
"found module with different name");
3164 if (StoredModMap ==
nullptr || StoredModMap != ModMap) {
3165 assert(ModMap &&
"found module is missing module map file");
3166 assert(ImportedBy &&
"top-level import should be verified");
3167 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3168 Diag(diag::err_imported_module_modmap_changed)
3174 llvm::SmallPtrSet<const FileEntry *, 1> AdditionalStoredMaps;
3175 for (
unsigned I = 0, N = Record[Idx++]; I < N; ++I) {
3177 std::string Filename = ReadPath(F, Record, Idx);
3179 FileMgr.getFile(Filename,
false,
false);
3181 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3182 Error(
"could not find file '" + Filename +
"' referenced by AST file");
3185 AdditionalStoredMaps.insert(F);
3190 if (
auto *AdditionalModuleMaps =
Map.getAdditionalModuleMapFiles(M)) {
3191 for (
const FileEntry *ModMap : *AdditionalModuleMaps) {
3194 if (!AdditionalStoredMaps.erase(ModMap)) {
3195 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3196 Diag(diag::err_module_different_modmap)
3197 << F.ModuleName << 0 << ModMap->
getName();
3205 for (
const FileEntry *ModMap : AdditionalStoredMaps) {
3206 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3207 Diag(diag::err_module_different_modmap)
3208 << F.ModuleName << 1 << ModMap->
getName();
3214 Listener->ReadModuleMapFile(F.ModuleMapPath);
3222 Sema::GlobalMethodPool::iterator Known
3229 : Known->second.second;
3233 if (List->getMethod() == Method) {
3241 if (List->getNext())
3242 List->setMethod(List->getNext()->getMethod());
3244 List->setMethod(Method);
3250 for (
Decl *D : Names) {
3251 bool wasHidden = D->Hidden;
3254 if (wasHidden && SemaObj) {
3265 llvm::SmallPtrSet<Module *, 4> Visited;
3267 Stack.push_back(Mod);
3268 while (!Stack.empty()) {
3269 Mod = Stack.pop_back_val();
3271 if (NameVisibility <= Mod->NameVisibility) {
3287 HiddenNamesMapType::iterator Hidden = HiddenNamesMap.find(Mod);
3288 if (Hidden != HiddenNamesMap.end()) {
3290 HiddenNamesMap.erase(Hidden);
3292 assert(HiddenNamesMap.find(Mod) == HiddenNamesMap.end() &&
3293 "making names visible added hidden names");
3300 I = Exports.begin(), E = Exports.end(); I != E; ++I) {
3302 if (Visited.insert(Exported).second)
3303 Stack.push_back(Exported);
3312 if (TriedLoadingGlobalIndex || !UseGlobalIndex ||
3317 TriedLoadingGlobalIndex =
true;
3318 StringRef ModuleCachePath
3319 = getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
3320 std::pair<GlobalModuleIndex *, GlobalModuleIndex::ErrorCode> Result
3325 GlobalIndex.reset(Result.first);
3326 ModuleMgr.setGlobalIndex(GlobalIndex.get());
3332 !hasGlobalIndex() && TriedLoadingGlobalIndex;
3339 llvm::raw_fd_ostream OS(TimestampFilename, EC, llvm::sys::fs::F_Text);
3342 OS <<
"Timestamp file\n";
3348 unsigned ClientLoadCapabilities) {
3350 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
3356 unsigned PreviousGeneration = incrementGeneration(
Context);
3358 unsigned NumModules = ModuleMgr.size();
3360 switch(
ASTReadResult ReadResult = ReadASTCore(FileName, Type, ImportLoc,
3363 ClientLoadCapabilities)) {
3367 case VersionMismatch:
3368 case ConfigurationMismatch:
3370 llvm::SmallPtrSet<ModuleFile *, 4> LoadedSet;
3371 for (
const ImportedModule &IM : Loaded)
3372 LoadedSet.insert(IM.Mod);
3374 ModuleMgr.removeModules(ModuleMgr.begin() + NumModules, ModuleMgr.end(),
3377 ? &PP.getHeaderSearchInfo().getModuleMap()
3382 GlobalIndex.reset();
3383 ModuleMgr.setGlobalIndex(
nullptr);
3394 MEnd = Loaded.end();
3399 if (
ASTReadResult Result = ReadASTBlock(F, ClientLoadCapabilities))
3415 SourceMgr.getLoadedSLocEntryByID(Index);
3422 MEnd = Loaded.end();
3426 ModuleMgr.moduleFileAccepted(&F);
3433 F.
ImportLoc = ReadSourceLocation(*M->ImportedBy,
3434 M->ImportLoc.getRawEncoding());
3441 IdEnd = PP.getIdentifierTable().end();
3443 Id->second->setOutOfDate(
true);
3446 for (
unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I) {
3447 UnresolvedModuleRef &Unresolved = UnresolvedModuleRefs[I];
3448 SubmoduleID GlobalID = getGlobalSubmoduleID(*Unresolved.File,Unresolved.ID);
3449 Module *ResolvedMod = getSubmodule(GlobalID);
3451 switch (Unresolved.Kind) {
3452 case UnresolvedModuleRef::Conflict:
3455 Conflict.
Other = ResolvedMod;
3456 Conflict.
Message = Unresolved.String.str();
3457 Unresolved.Mod->Conflicts.push_back(Conflict);
3461 case UnresolvedModuleRef::Import:
3463 Unresolved.Mod->Imports.insert(ResolvedMod);
3466 case UnresolvedModuleRef::Export:
3467 if (ResolvedMod || Unresolved.IsWildcard)
3468 Unresolved.Mod->Exports.push_back(
3473 UnresolvedModuleRefs.clear();
3479 InitializeContext();
3484 if (DeserializationListener)
3485 DeserializationListener->ReaderInitialized(
this);
3487 ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule();
3505 for (
unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++I) {
3506 loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
3507 ObjCClassesLoaded[I],
3508 PreviousGeneration);
3511 if (PP.getHeaderSearchInfo()
3512 .getHeaderSearchOpts()
3513 .ModulesValidateOncePerBuildSession) {
3518 for (
unsigned I = 0, N = Loaded.size(); I != N; ++I) {
3519 ImportedModule &M = Loaded[I];
3533 return Stream.Read(8) ==
'C' &&
3534 Stream.Read(8) ==
'P' &&
3535 Stream.Read(8) ==
'C' &&
3536 Stream.Read(8) ==
'H';
3540 ASTReader::ReadASTCore(StringRef FileName,
3545 off_t ExpectedSize, time_t ExpectedModTime,
3547 unsigned ClientLoadCapabilities) {
3549 std::string ErrorStr;
3551 = ModuleMgr.addModule(FileName, Type, ImportLoc, ImportedBy,
3552 getGeneration(), ExpectedSize, ExpectedModTime,
3556 switch (AddResult) {
3567 if (ClientLoadCapabilities & ARR_Missing)
3572 std::string Msg =
"Unable to load module \"" + FileName.str() +
"\": "
3581 if (ClientLoadCapabilities & ARR_OutOfDate)
3586 std::string Msg =
"Unable to load module \"" + FileName.str() +
"\": "
3593 assert(M &&
"Missing module file");
3597 if (FileName !=
"-") {
3598 CurrentDir = llvm::sys::path::parent_path(FileName);
3599 if (CurrentDir.empty()) CurrentDir =
".";
3603 BitstreamCursor &Stream = F.
Stream;
3610 Diag(diag::err_not_a_pch_file) << FileName;
3615 bool HaveReadControlBlock =
false;
3618 llvm::BitstreamEntry Entry = Stream.advance();
3620 switch (Entry.Kind) {
3622 case llvm::BitstreamEntry::EndBlock:
3623 case llvm::BitstreamEntry::Record:
3624 Error(
"invalid record at top-level of AST file");
3627 case llvm::BitstreamEntry::SubBlock:
3633 case llvm::bitc::BLOCKINFO_BLOCK_ID:
3634 if (Stream.ReadBlockInfoBlock()) {
3635 Error(
"malformed BlockInfoBlock in AST file");
3640 HaveReadControlBlock =
true;
3641 switch (ReadControlBlock(F, Loaded, ImportedBy, ClientLoadCapabilities)) {
3645 case Failure:
return Failure;
3646 case Missing:
return Missing;
3647 case OutOfDate:
return OutOfDate;
3649 case ConfigurationMismatch:
return ConfigurationMismatch;
3650 case HadErrors:
return HadErrors;
3654 if (!HaveReadControlBlock) {
3655 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
3656 Diag(diag::err_pch_version_too_old);
3661 Loaded.push_back(ImportedModule(M, ImportedBy, ImportLoc));
3665 if (Stream.SkipBlock()) {
3666 Error(
"malformed block record in AST file");
3678 if (DeserializationListener)
3688 if (!
Context.CFConstantStringTypeDecl)
3695 Error(
"FILE type is NULL");
3705 Error(
"Invalid FILE type in AST file");
3714 QualType Jmp_bufType = GetType(Jmp_buf);
3715 if (Jmp_bufType.
isNull()) {
3716 Error(
"jmp_buf type is NULL");
3726 Error(
"Invalid jmp_buf type in AST file");
3735 QualType Sigjmp_bufType = GetType(Sigjmp_buf);
3736 if (Sigjmp_bufType.
isNull()) {
3737 Error(
"sigjmp_buf type is NULL");
3741 if (!
Context.sigjmp_bufDecl) {
3746 assert(Tag &&
"Invalid sigjmp_buf type in AST file");
3752 if (
unsigned ObjCIdRedef
3755 Context.ObjCIdRedefinitionType = GetType(ObjCIdRedef);
3758 if (
unsigned ObjCClassRedef
3761 Context.ObjCClassRedefinitionType = GetType(ObjCClassRedef);
3764 if (
unsigned ObjCSelRedef
3767 Context.ObjCSelRedefinitionType = GetType(ObjCSelRedef);
3771 QualType Ucontext_tType = GetType(Ucontext_t);
3772 if (Ucontext_tType.
isNull()) {
3773 Error(
"ucontext_t type is NULL");
3777 if (!
Context.ucontext_tDecl) {
3782 assert(Tag &&
"Invalid ucontext_t type in AST file");
3792 if (!CUDASpecialDeclRefs.empty()) {
3793 assert(CUDASpecialDeclRefs.size() == 1 &&
"More decl refs than expected!");
3795 cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
3800 for (
auto &Import : ImportedModules) {
3801 if (
Module *Imported = getSubmodule(Import.ID)) {
3804 PP.makeModuleVisible(Imported, Import.ImportLoc);
3807 ImportedModules.clear();
3819 llvm::BitstreamEntry Entry = Cursor.advance();
3820 switch (Entry.Kind) {
3822 case llvm::BitstreamEntry::EndBlock:
3825 case llvm::BitstreamEntry::Record:
3827 Cursor.skipRecord(Entry.ID);
3830 case llvm::BitstreamEntry::SubBlock:
3831 if (Entry.ID == BlockID) {
3832 if (Cursor.EnterSubBlock(BlockID))
3838 if (Cursor.SkipBlock())
3847 BitstreamCursor Stream(StreamFile);
3858 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
3859 if (Entry.Kind == llvm::BitstreamEntry::EndBlock ||
3860 Entry.Kind != llvm::BitstreamEntry::Record)
3865 if (
SIGNATURE == Stream.readRecord(Entry.ID, Record, &Blob))
3874 const std::string &ASTFileName,
FileManager &FileMgr,
3879 Diags.
Report(diag::err_fe_unable_to_read_pch_file)
3880 << ASTFileName << Buffer.getError().message();
3881 return std::string();
3885 llvm::BitstreamReader StreamFile;
3886 PCHContainerRdr.
ExtractPCH((*Buffer)->getMemBufferRef(), StreamFile);
3887 BitstreamCursor Stream(StreamFile);
3891 Diags.
Report(diag::err_fe_not_a_pch_file) << ASTFileName;
3892 return std::string();
3897 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
3898 return std::string();
3904 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
3905 if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
3906 return std::string();
3908 if (Entry.Kind != llvm::BitstreamEntry::Record) {
3909 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
3910 return std::string();
3915 if (Stream.readRecord(Entry.ID, Record, &Blob) ==
ORIGINAL_FILE)
3925 std::string ExistingModuleCachePath;
3929 SimplePCHValidator(
const LangOptions &ExistingLangOpts,
3932 StringRef ExistingModuleCachePath,
3934 : ExistingLangOpts(ExistingLangOpts),
3935 ExistingTargetOpts(ExistingTargetOpts),
3936 ExistingPPOpts(ExistingPPOpts),
3937 ExistingModuleCachePath(ExistingModuleCachePath),
3942 bool ReadLanguageOptions(
const LangOptions &LangOpts,
bool Complain,
3943 bool AllowCompatibleDifferences)
override {
3945 AllowCompatibleDifferences);
3947 bool ReadTargetOptions(
const TargetOptions &TargetOpts,
bool Complain,
3948 bool AllowCompatibleDifferences)
override {
3950 AllowCompatibleDifferences);
3953 StringRef SpecificModuleCachePath,
3954 bool Complain)
override {
3956 ExistingModuleCachePath,
3957 nullptr, ExistingLangOpts);
3961 std::string &SuggestedPredefines)
override {
3963 SuggestedPredefines, ExistingLangOpts);
3981 llvm::BitstreamReader StreamFile;
3982 PCHContainerRdr.
ExtractPCH((*Buffer)->getMemBufferRef(), StreamFile);
3983 BitstreamCursor Stream(StreamFile);
3996 BitstreamCursor InputFilesCursor;
3997 if (NeedsInputFiles) {
3998 InputFilesCursor = Stream;
4004 uint64_t
Offset = InputFilesCursor.GetCurrentBitNo();
4005 unsigned Code = InputFilesCursor.ReadCode();
4008 if (Code != llvm::bitc::DEFINE_ABBREV) {
4009 InputFilesCursor.JumpToBit(Offset);
4012 InputFilesCursor.ReadAbbrevRecord();
4018 std::string ModuleDir;
4020 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
4021 if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
4024 if (Entry.Kind != llvm::BitstreamEntry::Record)
4029 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4048 auto Path = ReadString(Record, Idx);
4049 ResolveImportedPath(Path, ModuleDir);
4054 if (ParseLanguageOptions(Record,
false, Listener,
4060 if (ParseTargetOptions(Record,
false, Listener,
4066 if (ParseDiagnosticOptions(Record,
false, Listener))
4071 if (ParseFileSystemOptions(Record,
false, Listener))
4076 if (ParseHeaderSearchOptions(Record,
false, Listener))
4081 std::string IgnoredSuggestedPredefines;
4082 if (ParsePreprocessorOptions(Record,
false, Listener,
4083 IgnoredSuggestedPredefines))
4089 if (!NeedsInputFiles)
4092 unsigned NumInputFiles = Record[0];
4093 unsigned NumUserFiles = Record[1];
4094 const uint64_t *InputFileOffs = (
const uint64_t *)Blob.data();
4095 for (
unsigned I = 0; I != NumInputFiles; ++I) {
4097 bool isSystemFile = I >= NumUserFiles;
4099 if (isSystemFile && !NeedsSystemInputFiles)
4102 BitstreamCursor &Cursor = InputFilesCursor;
4104 Cursor.JumpToBit(InputFileOffs[I]);
4106 unsigned Code = Cursor.ReadCode();
4109 bool shouldContinue =
false;
4112 bool Overridden =
static_cast<bool>(Record[3]);
4113 std::string Filename = Blob;
4114 ResolveImportedPath(Filename, ModuleDir);
4119 if (!shouldContinue)
4129 unsigned Idx = 0, N = Record.size();
4133 std::string Filename = ReadString(Record, Idx);
4134 ResolveImportedPath(Filename, ModuleDir);
4145 unsigned Idx = 0, N = Record.size();
4147 std::string Filename = ReadString(Record, Idx);
4148 ResolveImportedPath(Filename, ModuleDir);
4165 std::string ExistingModuleCachePath) {
4166 SimplePCHValidator validator(LangOpts, TargetOpts, PPOpts,
4167 ExistingModuleCachePath, FileMgr);
4168 return !readASTFileControlBlock(Filename, FileMgr, PCHContainerRdr,
4173 ASTReader::ReadSubmoduleBlock(ModuleFile &F,
unsigned ClientLoadCapabilities) {
4176 Error(
"malformed submodule block record in AST file");
4180 ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
4182 Module *CurrentModule =
nullptr;
4185 llvm::BitstreamEntry Entry = F.Stream.advanceSkippingSubblocks();
4187 switch (Entry.Kind) {
4188 case llvm::BitstreamEntry::SubBlock:
4190 Error(
"malformed block record in AST file");
4192 case llvm::BitstreamEntry::EndBlock:
4194 case llvm::BitstreamEntry::Record:
4202 auto Kind = F.Stream.readRecord(Entry.ID, Record, &Blob);
4205 Error(
"submodule metadata record should be at beginning of block");
4221 if (Record.size() < 8) {
4222 Error(
"malformed module definition");
4226 StringRef Name = Blob;
4228 SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);
4229 SubmoduleID Parent = getGlobalSubmoduleID(F, Record[Idx++]);
4230 bool IsFramework = Record[Idx++];
4231 bool IsExplicit = Record[Idx++];
4232 bool IsSystem = Record[Idx++];
4233 bool IsExternC = Record[Idx++];
4234 bool InferSubmodules = Record[Idx++];
4235 bool InferExplicitSubmodules = Record[Idx++];
4236 bool InferExportWildcard = Record[Idx++];
4237 bool ConfigMacrosExhaustive = Record[Idx++];
4239 Module *ParentModule =
nullptr;
4241 ParentModule = getSubmodule(Parent);
4252 if (GlobalIndex >= SubmodulesLoaded.size() ||
4253 SubmodulesLoaded[GlobalIndex]) {
4254 Error(
"too many submodules");
4258 if (!ParentModule) {
4260 if (CurFile != F.File) {
4261 if (!Diags.isDiagnosticInFlight()) {
4262 Diag(diag::err_module_file_conflict)
4264 << CurFile->getName()
4265 << F.File->getName();
4282 if (DeserializationListener)
4283 DeserializationListener->ModuleRead(GlobalID, CurrentModule);
4285 SubmodulesLoaded[GlobalIndex] = CurrentModule;
4296 std::string Filename = Blob;
4297 ResolveImportedPath(F, Filename);
4298 if (
auto *Umbrella = PP.getFileManager().getFile(Filename)) {
4334 std::string Dirname = Blob;
4335 ResolveImportedPath(F, Dirname);
4336 if (
auto *Umbrella = PP.getFileManager().getDirectory(Dirname)) {
4340 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
4341 Error(
"mismatched umbrella directories in submodule");
4349 F.BaseSubmoduleID = getTotalNumSubmodules();
4350 F.LocalNumSubmodules = Record[0];
4351 unsigned LocalBaseSubmoduleID = Record[1];
4352 if (F.LocalNumSubmodules > 0) {
4355 GlobalSubmoduleMap.insert(std::make_pair(getTotalNumSubmodules()+1,&F));
4359 F.SubmoduleRemap.insertOrReplace(
4360 std::make_pair(LocalBaseSubmoduleID,
4361 F.BaseSubmoduleID - LocalBaseSubmoduleID));
4363 SubmodulesLoaded.resize(SubmodulesLoaded.size() + F.LocalNumSubmodules);
4369 for (
unsigned Idx = 0; Idx != Record.size(); ++Idx) {
4370 UnresolvedModuleRef Unresolved;
4371 Unresolved.File = &F;
4372 Unresolved.Mod = CurrentModule;
4373 Unresolved.ID = Record[Idx];
4374 Unresolved.Kind = UnresolvedModuleRef::Import;
4375 Unresolved.IsWildcard =
false;
4376 UnresolvedModuleRefs.push_back(Unresolved);
4382 for (
unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
4383 UnresolvedModuleRef Unresolved;
4384 Unresolved.File = &F;
4385 Unresolved.Mod = CurrentModule;
4386 Unresolved.ID = Record[Idx];
4387 Unresolved.Kind = UnresolvedModuleRef::Export;
4388 Unresolved.IsWildcard = Record[Idx + 1];
4389 UnresolvedModuleRefs.push_back(Unresolved);
4413 UnresolvedModuleRef Unresolved;
4414 Unresolved.File = &F;
4415 Unresolved.Mod = CurrentModule;
4416 Unresolved.ID = Record[0];
4417 Unresolved.Kind = UnresolvedModuleRef::Conflict;
4418 Unresolved.IsWildcard =
false;
4419 Unresolved.String = Blob;
4420 UnresolvedModuleRefs.push_back(Unresolved);
4434 bool ASTReader::ParseLanguageOptions(
const RecordData &Record,
4437 bool AllowCompatibleDifferences) {
4440 #define LANGOPT(Name, Bits, Default, Description) \
4441 LangOpts.Name = Record[Idx++];
4442 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
4443 LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++]));
4444 #include "clang/Basic/LangOptions.def"
4445 #define SANITIZER(NAME, ID) \
4446 LangOpts.Sanitize.set(SanitizerKind::ID, Record[Idx++]);
4447 #include "clang/Basic/Sanitizers.def"
4449 for (
unsigned N = Record[Idx++]; N; --N)
4453 VersionTuple runtimeVersion = ReadVersionTuple(Record, Idx);
4459 for (
unsigned N = Record[Idx++]; N; --N) {
4461 ReadString(Record, Idx));
4466 AllowCompatibleDifferences);
4469 bool ASTReader::ParseTargetOptions(
const RecordData &Record,
bool Complain,
4471 bool AllowCompatibleDifferences) {
4474 TargetOpts.
Triple = ReadString(Record, Idx);
4475 TargetOpts.
CPU = ReadString(Record, Idx);
4476 TargetOpts.
ABI = ReadString(Record, Idx);
4477 for (
unsigned N = Record[Idx++]; N; --N) {
4480 for (
unsigned N = Record[Idx++]; N; --N) {
4481 TargetOpts.
Features.push_back(ReadString(Record, Idx));
4485 AllowCompatibleDifferences);
4488 bool ASTReader::ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
4492 #define DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++];
4493 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
4494 DiagOpts->set##Name(static_cast<Type>(Record[Idx++]));
4495 #include "clang/Basic/DiagnosticOptions.def"
4497 for (
unsigned N = Record[Idx++]; N; --N)
4498 DiagOpts->Warnings.push_back(ReadString(Record, Idx));
4499 for (
unsigned N = Record[Idx++]; N; --N)
4500 DiagOpts->Remarks.push_back(ReadString(Record, Idx));
4505 bool ASTReader::ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
4513 bool ASTReader::ParseHeaderSearchOptions(
const RecordData &Record,
4518 HSOpts.
Sysroot = ReadString(Record, Idx);
4521 for (
unsigned N = Record[Idx++]; N; --N) {
4522 std::string Path = ReadString(Record, Idx);
4525 bool IsFramework = Record[Idx++];
4526 bool IgnoreSysRoot = Record[Idx++];
4527 HSOpts.
UserEntries.emplace_back(std::move(Path), Group, IsFramework,
4532 for (
unsigned N = Record[Idx++]; N; --N) {
4533 std::string Prefix = ReadString(Record, Idx);
4534 bool IsSystemHeader = Record[Idx++];
4546 std::string SpecificModuleCachePath = ReadString(Record, Idx);
4552 bool ASTReader::ParsePreprocessorOptions(
const RecordData &Record,
4555 std::string &SuggestedPredefines) {
4560 for (
unsigned N = Record[Idx++]; N; --N) {
4561 std::string Macro = ReadString(Record, Idx);
4562 bool IsUndef = Record[Idx++];
4563 PPOpts.
Macros.push_back(std::make_pair(Macro, IsUndef));
4567 for (
unsigned N = Record[Idx++]; N; --N) {
4568 PPOpts.
Includes.push_back(ReadString(Record, Idx));
4572 for (
unsigned N = Record[Idx++]; N; --N) {
4582 SuggestedPredefines.clear();
4584 SuggestedPredefines);
4587 std::pair<ModuleFile *, unsigned>
4588 ASTReader::getModulePreprocessedEntity(
unsigned GlobalIndex) {
4589 GlobalPreprocessedEntityMapType::iterator
4590 I = GlobalPreprocessedEntityMap.find(GlobalIndex);
4591 assert(I != GlobalPreprocessedEntityMap.end() &&
4592 "Corrupted global preprocessed entity map");
4594 unsigned LocalIndex = GlobalIndex - M->BasePreprocessedEntityID;
4595 return std::make_pair(M, LocalIndex);
4598 llvm::iterator_range<PreprocessingRecord::iterator>
4599 ASTReader::getModulePreprocessedEntities(
ModuleFile &Mod)
const {
4608 llvm::iterator_range<ASTReader::ModuleDeclIterator>
4609 ASTReader::getModuleFileLevelDecls(
ModuleFile &Mod) {
4610 return llvm::make_range(
4612 ModuleDeclIterator(
this, &Mod,
4618 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
4620 unsigned LocalIndex = PPInfo.second;
4623 if (!PP.getPreprocessingRecord()) {
4624 Error(
"no preprocessing record");
4631 llvm::BitstreamEntry Entry =
4633 if (Entry.Kind != llvm::BitstreamEntry::Record)
4638 ReadSourceLocation(M, PPOffs.
End));
4644 Entry.ID, Record, &Blob);
4647 bool isBuiltin = Record[0];
4651 Name = getLocalIdentifier(M, Record[1]);
4654 getGlobalPreprocessedEntityID(M, Record[1]);
4655 Def = cast<MacroDefinitionRecord>(
4656 PPRec.getLoadedPreprocessedEntity(GlobalID - 1));
4674 if (DeserializationListener)
4675 DeserializationListener->MacroDefinitionRead(PPID, MD);
4681 const char *FullFileNameStart = Blob.data() + Record[0];
4682 StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]);
4684 if (!FullFileName.empty())
4685 File = PP.getFileManager().getFile(FullFileName);
4692 StringRef(Blob.data(), Record[0]),
4693 Record[1], Record[3],
4700 llvm_unreachable(
"Invalid PreprocessorDetailRecordTypes");
4708 GlobalSLocOffsetMapType::const_iterator SLocMapI)
const {
4710 for (GlobalSLocOffsetMapType::const_iterator
4711 EndI = GlobalSLocOffsetMap.end(); SLocMapI != EndI; ++SLocMapI) {
4712 ModuleFile &M = *SLocMapI->second;
4713 if (M.NumPreprocessedEntities)
4717 return getTotalNumPreprocessedEntities();
4722 template <
unsigned PPEntityOffset::*PPLoc>
4723 struct PPEntityComp {
4732 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
4737 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
4742 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
4746 return Reader.ReadSourceLocation(M, PPE.*PPLoc);
4753 bool EndsAfter)
const {
4755 return getTotalNumPreprocessedEntities();
4757 GlobalSLocOffsetMapType::const_iterator SLocMapI = GlobalSLocOffsetMap.find(
4758 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
4759 assert(SLocMapI != GlobalSLocOffsetMap.end() &&
4760 "Corrupted global sloc offset map");
4762 if (SLocMapI->second->NumPreprocessedEntities == 0)
4763 return findNextPreprocessedEntity(SLocMapI);
4772 pp_iterator First = pp_begin;
4776 PPI = std::upper_bound(pp_begin, pp_end, Loc,
4777 PPEntityComp<&PPEntityOffset::Begin>(*
this, M));
4786 std::advance(PPI, Half);
4791 Count = Count - Half - 1;
4798 return findNextPreprocessedEntity(SLocMapI);
4805 std::pair<unsigned, unsigned>
4808 return std::make_pair(0,0);
4812 findPreprocessedEntity(Range.
getBegin(),
false);
4814 return std::make_pair(BeginID, EndID);
4824 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
4826 unsigned LocalIndex = PPInfo.second;
4841 class HeaderFileInfoVisitor {
4847 explicit HeaderFileInfoVisitor(
const FileEntry *FE)
4850 static bool visit(
ModuleFile &M,
void *UserData) {
4851 HeaderFileInfoVisitor *This
4852 =
static_cast<HeaderFileInfoVisitor *
>(UserData);
4860 HeaderFileInfoLookupTable::iterator Pos = Table->find(This->FE);
4861 if (Pos == Table->end())
4873 HeaderFileInfoVisitor Visitor(FE);
4874 ModuleMgr.visit(&HeaderFileInfoVisitor::visit, &Visitor);
4884 for (
ModuleIterator I = ModuleMgr.begin(), E = ModuleMgr.end(); I != E; ++I) {
4888 assert(!Diag.DiagStates.empty());
4889 DiagStates.push_back(&Diag.DiagStates.front());
4893 if (DiagStateID != 0) {
4894 Diag.DiagStatePoints.push_back(
4895 DiagnosticsEngine::DiagStatePoint(DiagStates[DiagStateID-1],
4900 assert(DiagStateID == 0);
4902 Diag.DiagStates.push_back(*Diag.GetCurDiagState());
4903 DiagnosticsEngine::DiagState *NewState = &Diag.DiagStates.back();
4904 DiagStates.push_back(NewState);
4905 Diag.DiagStatePoints.push_back(
4906 DiagnosticsEngine::DiagStatePoint(NewState,
4910 "Invalid data, didn't find '-1' marking end of diag/map pairs");
4916 if (DiagID == (
unsigned)-1) {
4921 Diag.GetCurDiagState()->setMapping(DiagID, Mapping);
4928 ASTReader::RecordLocation ASTReader::TypeCursorForIndex(
unsigned Index) {
4929 GlobalTypeMapType::iterator I = GlobalTypeMap.find(Index);
4930 assert(I != GlobalTypeMap.end() &&
"Corrupted global type map");
4931 ModuleFile *M = I->second;
4932 return RecordLocation(M, M->TypeOffsets[Index - M->BaseTypeIndex]);
4941 QualType ASTReader::readTypeRecord(
unsigned Index) {
4942 RecordLocation Loc = TypeCursorForIndex(Index);
4943 BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
4949 ReadingKindTracker ReadingKind(Read_Type, *
this);
4952 Deserializing AType(
this);
4955 DeclsCursor.JumpToBit(Loc.Offset);
4957 unsigned Code = DeclsCursor.ReadCode();
4958 switch ((
TypeCode)DeclsCursor.readRecord(Code, Record)) {
4960 if (Record.size() != 2) {
4961 Error(
"Incorrect encoding of extended qualifier type");
4970 if (Record.size() != 1) {
4971 Error(
"Incorrect encoding of complex type");
4974 QualType ElemType = readType(*Loc.F, Record, Idx);
4979 if (Record.size() != 1) {
4980 Error(
"Incorrect encoding of pointer type");
4983 QualType PointeeType = readType(*Loc.F, Record, Idx);
4988 if (Record.size() != 1) {
4989 Error(
"Incorrect encoding of decayed type");
4992 QualType OriginalType = readType(*Loc.F, Record, Idx);
4994 if (!isa<DecayedType>(DT))
4995 Error(
"Decayed type does not decay");
5000 if (Record.size() != 2) {
5001 Error(
"Incorrect encoding of adjusted type");
5004 QualType OriginalTy = readType(*Loc.F, Record, Idx);
5005 QualType AdjustedTy = readType(*Loc.F, Record, Idx);
5010 if (Record.size() != 1) {
5011 Error(
"Incorrect encoding of block pointer type");
5014 QualType PointeeType = readType(*Loc.F, Record, Idx);
5019 if (Record.size() != 2) {
5020 Error(
"Incorrect encoding of lvalue reference type");
5023 QualType PointeeType = readType(*Loc.F, Record, Idx);
5028 if (Record.size() != 1) {
5029 Error(
"Incorrect encoding of rvalue reference type");
5032 QualType PointeeType = readType(*Loc.F, Record, Idx);
5037 if (Record.size() != 2) {
5038 Error(
"Incorrect encoding of member pointer type");
5041 QualType PointeeType = readType(*Loc.F, Record, Idx);
5042 QualType ClassType = readType(*Loc.F, Record, Idx);
5050 QualType ElementType = readType(*Loc.F, Record, Idx);
5052 unsigned IndexTypeQuals = Record[2];
5054 llvm::APInt Size = ReadAPInt(Record, Idx);
5056 ASM, IndexTypeQuals);
5060 QualType ElementType = readType(*Loc.F, Record, Idx);
5062 unsigned IndexTypeQuals = Record[2];
5067 QualType ElementType = readType(*Loc.F, Record, Idx);
5069 unsigned IndexTypeQuals = Record[2];
5073 ASM, IndexTypeQuals,
5078 if (Record.size() != 3) {
5079 Error(
"incorrect encoding of vector type in AST file");
5083 QualType ElementType = readType(*Loc.F, Record, Idx);
5084 unsigned NumElements = Record[1];
5085 unsigned VecKind = Record[2];
5091 if (Record.size() != 3) {
5092 Error(
"incorrect encoding of extended vector type in AST file");
5096 QualType ElementType = readType(*Loc.F, Record, Idx);
5097 unsigned NumElements = Record[1];
5102 if (Record.size() != 6) {
5103 Error(
"incorrect encoding of no-proto function type");
5106 QualType ResultType = readType(*Loc.F, Record, Idx);
5113 QualType ResultType = readType(*Loc.F, Record, Idx);
5119 static_cast<CallingConv>(Record[4]),
5129 readExceptionSpec(*Loc.F, ExceptionStorage, EPI.
ExceptionSpec, Record, Idx);
5131 unsigned NumParams = Record[Idx++];
5133 for (
unsigned I = 0; I != NumParams; ++I)
5134 ParamTypes.push_back(readType(*Loc.F, Record, Idx));
5142 ReadDeclAs<UnresolvedUsingTypenameDecl>(*Loc.F, Record, Idx));
5146 if (Record.size() != 2) {
5147 Error(
"incorrect encoding of typedef type");
5152 QualType Canonical = readType(*Loc.F, Record, Idx);
5153 if (!Canonical.isNull())
5162 if (Record.size() != 1) {
5163 Error(
"incorrect encoding of typeof(type) in AST file");
5166 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
5171 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
5176 QualType BaseType = readType(*Loc.F, Record, Idx);
5177 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
5183 QualType Deduced = readType(*Loc.F, Record, Idx);
5184 bool IsDecltypeAuto = Record[Idx++];
5185 bool IsDependent = Deduced.
isNull() ? Record[Idx++] :
false;
5190 if (Record.size() != 2) {
5191 Error(
"incorrect encoding of record type");
5195 bool IsDependent = Record[Idx++];
5196 RecordDecl *RD = ReadDeclAs<RecordDecl>(*Loc.F, Record, Idx);
5197 RD = cast_or_null<RecordDecl>(RD->getCanonicalDecl());
5199 const_cast<Type*
>(T.getTypePtr())->setDependent(IsDependent);
5204 if (Record.size() != 2) {
5205 Error(
"incorrect encoding of enum type");
5209 bool IsDependent = Record[Idx++];
5212 const_cast<Type*
>(T.
getTypePtr())->setDependent(IsDependent);
5217 if (Record.size() != 3) {
5218 Error(
"incorrect encoding of attributed type");
5221 QualType modifiedType = readType(*Loc.F, Record, Idx);
5222 QualType equivalentType = readType(*Loc.F, Record, Idx);
5228 if (Record.size() != 1) {
5229 Error(
"incorrect encoding of paren type");
5232 QualType InnerType = readType(*Loc.F, Record, Idx);
5237 if (Record.size() != 2) {
5238 Error(
"incorrect encoding of pack expansion type");
5241 QualType Pattern = readType(*Loc.F, Record, Idx);
5246 NumExpansions = Record[1] - 1;
5254 QualType NamedType = readType(*Loc.F, Record, Idx);
5261 = ReadDeclAs<ObjCInterfaceDecl>(*Loc.F, Record, Idx);
5267 QualType Base = readType(*Loc.F, Record, Idx);
5268 unsigned NumTypeArgs = Record[Idx++];
5270 for (
unsigned I = 0; I != NumTypeArgs; ++I)
5271 TypeArgs.push_back(readType(*Loc.F, Record, Idx));
5272 unsigned NumProtos = Record[Idx++];
5274 for (
unsigned I = 0; I != NumProtos; ++I)
5275 Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
5276 bool IsKindOf = Record[Idx++];
5282 QualType Pointee = readType(*Loc.F, Record, Idx);
5288 QualType Parm = readType(*Loc.F, Record, Idx);
5289 QualType Replacement = readType(*Loc.F, Record, Idx);
5291 cast<TemplateTypeParmType>(Parm),
5297 QualType Parm = readType(*Loc.F, Record, Idx);
5300 cast<TemplateTypeParmType>(Parm),
5305 CXXRecordDecl *D = ReadDeclAs<CXXRecordDecl>(*Loc.F, Record, Idx);
5306 QualType TST = readType(*Loc.F, Record, Idx);
5309 const Type *T =
nullptr;
5311 if (
const Type *Existing = DI->getTypeForDecl()) {
5319 DI->setTypeForDecl(T);
5326 unsigned Depth = Record[Idx++];
5327 unsigned Index = Record[Idx++];
5328 bool Pack = Record[Idx++];
5330 = ReadDeclAs<TemplateTypeParmDecl>(*Loc.F, Record, Idx);
5338 const IdentifierInfo *Name = this->GetIdentifierInfo(*Loc.F, Record, Idx);
5339 QualType Canon = readType(*Loc.F, Record, Idx);
5349 const IdentifierInfo *Name = this->GetIdentifierInfo(*Loc.F, Record, Idx);
5350 unsigned NumArgs = Record[Idx++];
5352 Args.reserve(NumArgs);
5354 Args.push_back(ReadTemplateArgument(*Loc.F, Record, Idx));
5356 Args.size(), Args.data());
5363 QualType ElementType = readType(*Loc.F, Record, Idx);
5366 unsigned IndexTypeQuals = Record[Idx++];
5369 Expr *NumElts = ReadExpr(*Loc.F);
5370 SourceRange Brackets = ReadSourceRange(*Loc.F, Record, Idx);
5373 IndexTypeQuals, Brackets);
5378 bool IsDependent = Record[Idx++];
5379 TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx);
5381 ReadTemplateArgumentList(Args, *Loc.F, Record, Idx);
5382 QualType Underlying = readType(*Loc.F, Record, Idx);
5389 Args.size(), Underlying);
5390 const_cast<Type*
>(T.
getTypePtr())->setDependent(IsDependent);
5395 if (Record.size() != 1) {
5396 Error(
"Incorrect encoding of atomic type");
5399 QualType ValueType = readType(*Loc.F, Record, Idx);
5403 llvm_unreachable(
"Invalid TypeCode!");
5409 const RecordData &Record,
unsigned &Idx) {
5414 for (
unsigned I = 0, N = Record[Idx++]; I != N; ++I)
5415 Exceptions.push_back(readType(ModuleFile, Record, Idx));
5420 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
5421 ESI.
SourceTemplate = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
5423 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
5435 return Reader.ReadSourceLocation(F, R, I);
5438 template<
typename T>
5440 return Reader.ReadDeclAs<T>(F, Record, Idx);
5446 : Reader(Reader), F(F), Record(Record), Idx(Idx)
5452 #define ABSTRACT_TYPELOC(CLASS, PARENT)
5453 #define TYPELOC(CLASS, PARENT) \
5454 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
5455 #include "clang/AST/TypeLocNodes.def"
5474 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5477 TL.
setStarLoc(ReadSourceLocation(Record, Idx));
5489 TL.
setAmpLoc(ReadSourceLocation(Record, Idx));
5495 TL.
setStarLoc(ReadSourceLocation(Record, Idx));
5507 VisitArrayTypeLoc(TL);
5510 VisitArrayTypeLoc(TL);
5513 VisitArrayTypeLoc(TL);
5515 void TypeLocReader::VisitDependentSizedArrayTypeLoc(
5517 VisitArrayTypeLoc(TL);
5519 void TypeLocReader::VisitDependentSizedExtVectorTypeLoc(
5521 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5524 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5527 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5534 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i) {
5535 TL.
setParam(i, ReadDeclAs<ParmVarDecl>(Record, Idx));
5539 VisitFunctionTypeLoc(TL);
5542 VisitFunctionTypeLoc(TL);
5545 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5548 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5562 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5565 TL.
setKWLoc(ReadSourceLocation(Record, Idx));
5570 void TypeLocReader::VisitAutoTypeLoc(
AutoTypeLoc TL) {
5571 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5574 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5576 void TypeLocReader::VisitEnumTypeLoc(
EnumTypeLoc TL) {
5577 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5580 TL.setAttrNameLoc(ReadSourceLocation(Record, Idx));
5583 range.
setBegin(ReadSourceLocation(Record, Idx));
5584 range.
setEnd(ReadSourceLocation(Record, Idx));
5589 TL.setAttrExprOperand(Reader.
ReadExpr(F));
5591 TL.setAttrExprOperand(
nullptr);
5596 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5598 void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
5600 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5602 void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
5604 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5606 void TypeLocReader::VisitTemplateSpecializationTypeLoc(
5612 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
5618 void TypeLocReader::VisitParenTypeLoc(
ParenTypeLoc TL) {
5627 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5632 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5634 void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc(
5642 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I)
5652 TL.
setNameLoc(ReadSourceLocation(Record, Idx));
5666 TL.
setStarLoc(ReadSourceLocation(Record, Idx));
5669 TL.
setKWLoc(ReadSourceLocation(Record, Idx));
5677 QualType InfoTy = readType(F, Record, Idx);
5681 TypeSourceInfo *TInfo = getContext().CreateTypeSourceInfo(InfoTy);
5760 assert(!T.
isNull() &&
"Unknown predefined type");
5765 assert(Index < TypesLoaded.size() &&
"Type index out-of-range");
5766 if (TypesLoaded[Index].isNull()) {
5767 TypesLoaded[Index] = readTypeRecord(Index);
5768 if (TypesLoaded[Index].isNull())
5771 TypesLoaded[Index]->setFromAST();
5772 if (DeserializationListener)
5774 TypesLoaded[Index]);
5777 return TypesLoaded[Index].withFastQualifiers(FastQuals);
5781 return GetType(getGlobalTypeID(F, LocalID));
5794 assert(I != F.
TypeRemap.
end() &&
"Invalid index into type index remap");
5796 unsigned GlobalIndex = LocalIndex + I->second;
5797 return (GlobalIndex << Qualifiers::FastWidth) | FastQuals;
5809 return GetTypeSourceInfo(F, Record, Index);
5813 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
5820 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
5821 SourceLocation EllipsisLoc = ReadSourceLocation(F, Record, Index);
5833 llvm_unreachable(
"unexpected template argument loc");
5842 if (Record[Index++])
5855 unsigned NumArgsAsWritten = Record[Index++];
5857 for (
unsigned i = 0; i != NumArgsAsWritten; ++i)
5858 TemplArgsInfo.
addArgument(ReadTemplateArgumentLoc(F, Record, Index));
5866 template<
typename TemplateSpecializationDecl>
5868 if (
auto *TSD = dyn_cast<TemplateSpecializationDecl>(D))
5869 TSD->getSpecializedTemplate()->LoadLazySpecializations();
5873 if (NumCurrentElementsDeserializing) {
5878 PendingIncompleteDeclChains.push_back(const_cast<Decl*>(D));
5889 if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC) ||
5890 isa<CXXRecordDecl>(DC) || isa<EnumDecl>(DC)) {
5892 auto *II = Name.getAsIdentifierInfo();
5893 if (isa<TranslationUnitDecl>(DC) && II) {
5896 if (II->isOutOfDate())
5897 updateOutOfDateIdentifier(*II);
5906 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D))
5907 CTSD->getSpecializedTemplate()->LoadLazySpecializations();
5908 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D))
5909 VTSD->getSpecializedTemplate()->LoadLazySpecializations();
5910 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
5911 if (
auto *Template = FD->getPrimaryTemplate())
5912 Template->LoadLazySpecializations();
5920 Error(
"malformed AST file: missing C++ ctor initializers");
5924 unsigned LocalID = Record[Idx++];
5930 RecordLocation Loc = getLocalBitOffset(Offset);
5931 BitstreamCursor &Cursor = Loc.F->DeclsCursor;
5933 Cursor.JumpToBit(Loc.Offset);
5934 ReadingKindTracker ReadingKind(Read_Decl, *
this);
5937 unsigned Code = Cursor.ReadCode();
5938 unsigned RecCode = Cursor.readRecord(Code, Record);
5940 Error(
"malformed AST file: missing C++ ctor initializers");
5945 return ReadCXXCtorInitializers(*Loc.F, Record, Idx);
5952 Error(
"malformed AST file: missing C++ base specifier");
5956 unsigned LocalID = Record[Idx++];
5961 RecordLocation Loc = getLocalBitOffset(Offset);
5962 BitstreamCursor &Cursor = Loc.F->DeclsCursor;
5964 Cursor.JumpToBit(Loc.Offset);
5965 ReadingKindTracker ReadingKind(Read_Decl, *
this);
5967 unsigned Code = Cursor.ReadCode();
5968 unsigned RecCode = Cursor.readRecord(Code, Record);
5970 Error(
"malformed AST file: missing C++ base specifiers");
5975 unsigned NumBases = Record[Idx++];
5978 for (
unsigned I = 0; I != NumBases; ++I)
5979 Bases[I] = ReadCXXBaseSpecifier(*Loc.F, Record, Idx);
5990 assert(I != F.
DeclRemap.
end() &&
"Invalid index into decl index remap");
5992 return LocalID + I->second;
5996 ModuleFile &M)
const {
6009 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
6019 if (Index > DeclsLoaded.size()) {
6020 Error(
"declaration ID out-of-range for AST file");
6024 if (Decl *D = DeclsLoaded[Index])
6027 unsigned RawLocation = 0;
6028 RecordLocation Rec = DeclCursorForID(ID, RawLocation);
6029 return ReadSourceLocation(*Rec.F, RawLocation);
6067 llvm_unreachable(
"PredefinedDeclIDs unknown enum value");
6078 Merged.push_back(ID);
6085 if (Index >= DeclsLoaded.size()) {
6086 assert(0 &&
"declaration ID out-of-range for AST file");
6087 Error(
"declaration ID out-of-range for AST file");
6091 return DeclsLoaded[Index];
6096 return GetExistingDecl(ID);
6100 if (Index >= DeclsLoaded.size()) {
6101 assert(0 &&
"declaration ID out-of-range for AST file");
6102 Error(
"declaration ID out-of-range for AST file");
6106 if (!DeclsLoaded[Index]) {
6108 if (DeserializationListener)
6109 DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);
6112 return DeclsLoaded[Index];
6121 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
6122 ModuleFile *Owner = I->second;
6124 llvm::DenseMap<ModuleFile *, serialization::DeclID>::iterator Pos
6129 return GlobalID - Owner->BaseDeclID + Pos->second;
6135 if (Idx >= Record.size()) {
6136 Error(
"Corrupted AST file");
6140 return getGlobalDeclID(F, Record[Idx++]);
6150 ClearSwitchCaseIDs();
6153 RecordLocation Loc = getLocalBitOffset(Offset);
6154 Loc.F->DeclsCursor.JumpToBit(Loc.Offset);
6155 return ReadStmtFromStream(*Loc.F);
6159 class FindExternalLexicalDeclsVisitor {
6171 : Reader(Reader), DC(DC), isKindWeWant(isKindWeWant), Decls(Decls)
6174 PredefsVisited[I] =
false;
6177 static bool visitPostorder(ModuleFile &M,
void *UserData) {
6178 FindExternalLexicalDeclsVisitor *This
6179 =
static_cast<FindExternalLexicalDeclsVisitor *
>(UserData);
6181 ModuleFile::DeclContextInfosMap::iterator Info
6188 *IDE = ID + Info->second.NumLexicalDecls;
6190 if (This->isKindWeWant && !This->isKindWeWant((
Decl::Kind)ID->first))
6196 if (This->PredefsVisited[ID->second])
6199 This->PredefsVisited[ID->second] =
true;
6202 if (Decl *D = This->Reader.GetLocalDecl(M, ID->second)) {
6203 if (!This->DC->isDeclInLexicalTraversal(D))
6204 This->Decls.push_back(D);
6218 FindExternalLexicalDeclsVisitor Visitor(*
this, DC, isKindWeWant, Decls);
6219 ModuleMgr.visitDepthFirst(
6220 nullptr, &FindExternalLexicalDeclsVisitor::visitPostorder, &Visitor);
6221 ++NumLexicalDeclContextsRead;
6232 DeclIDComp(
ASTReader &Reader, ModuleFile &M) : Reader(Reader), Mod(M) {}
6259 unsigned Offset,
unsigned Length,
6263 llvm::DenseMap<FileID, FileDeclsInfo>::iterator I = FileDeclIDs.find(File);
6264 if (I == FileDeclIDs.end())
6267 FileDeclsInfo &DInfo = I->second;
6268 if (DInfo.Decls.empty())
6275 DeclIDComp DIDComp(*
this, *DInfo.Mod);
6277 BeginIt = std::lower_bound(DInfo.Decls.begin(), DInfo.Decls.end(),
6279 if (BeginIt != DInfo.Decls.begin())
6285 while (BeginIt != DInfo.Decls.begin() &&
6286 GetDecl(getGlobalDeclID(*DInfo.Mod, *BeginIt))
6287 ->isTopLevelDeclInObjCContainer())
6291 EndIt = std::upper_bound(DInfo.Decls.begin(), DInfo.Decls.end(),
6293 if (EndIt != DInfo.Decls.end())
6297 DIt = BeginIt; DIt != EndIt; ++DIt)
6298 Decls.push_back(GetDecl(getGlobalDeclID(*DInfo.Mod, *DIt)));
6325 class DeclContextNameLookupVisitor {
6329 ASTDeclContextNameLookupTrait::DeclNameKey NameKey;
6332 llvm::SmallPtrSetImpl<NamedDecl *> &DeclSet;
6335 DeclContextNameLookupVisitor(
ASTReader &Reader,
6338 llvm::SmallPtrSetImpl<NamedDecl *> &DeclSet)
6339 : Reader(Reader), Name(Name),
6342 Decls(Decls), DeclSet(DeclSet) {}
6345 if (Contexts.empty())
6351 ModuleFile *Definitive;
6352 if (Contexts.size() == 1 &&
6354 visit(*Definitive,
this);
6361 static bool visit(ModuleFile &M,
void *UserData) {
6362 DeclContextNameLookupVisitor *This
6363 =
static_cast<DeclContextNameLookupVisitor *
>(UserData);
6367 ModuleFile::DeclContextInfosMap::iterator Info;
6368 bool FoundInfo =
false;
6369 for (
auto *DC : This->Contexts) {
6372 Info->second.NameLookupTableData) {
6383 Info->second.NameLookupTableData;
6384 ASTDeclContextNameLookupTable::iterator Pos
6385 = LookupTable->find_hashed(This->NameKey, This->NameHash);
6386 if (Pos == LookupTable->end())
6389 bool FoundAnything =
false;
6391 for (; Data.first != Data.second; ++Data.first) {
6407 FoundAnything =
true;
6408 if (This->DeclSet.insert(ND).second)
6409 This->Decls.push_back(ND);
6412 return FoundAnything;
6421 "DeclContext has no visible decls in storage");
6428 llvm::SmallPtrSet<NamedDecl*, 64> DeclSet;
6435 Contexts.push_back(DC);
6438 auto Key = KeyDecls.find(const_cast<Decl *>(cast<Decl>(DC)));
6439 if (Key != KeyDecls.end()) {
6440 for (
unsigned I = 0, N = Key->second.size(); I != N; ++I)
6441 Contexts.push_back(cast<DeclContext>(GetDecl(Key->second[I])));
6445 DeclContextNameLookupVisitor Visitor(*
this, Name, Decls, DeclSet);
6446 Visitor.visitContexts(Contexts);
6452 if (isa<CXXRecordDecl>(DC)) {
6453 auto Merged = MergedLookups.find(DC);
6454 if (Merged != MergedLookups.end()) {
6455 for (
unsigned I = 0; I != Merged->second.size(); ++I) {
6457 Visitor.visitContexts(Context);
6460 Merged = MergedLookups.find(DC);
6465 ++NumVisibleDeclContextsRead;
6466 SetExternalVisibleDeclsForName(DC, Name, Decls);
6467 return !Decls.empty();
6473 class DeclContextAllNamesVisitor {
6477 llvm::SmallPtrSet<NamedDecl *, 256> DeclSet;
6481 DeclContextAllNamesVisitor(
ASTReader &Reader,
6483 DeclsMap &Decls,
bool VisitAll)
6484 : Reader(Reader), Contexts(Contexts), Decls(Decls), VisitAll(VisitAll) { }
6486 static bool visit(ModuleFile &M,
void *UserData) {
6487 DeclContextAllNamesVisitor *This
6488 =
static_cast<DeclContextAllNamesVisitor *
>(UserData);
6492 ModuleFile::DeclContextInfosMap::iterator Info;
6493 bool FoundInfo =
false;
6494 for (
unsigned I = 0, N = This->Contexts.size(); I != N; ++I) {
6497 Info->second.NameLookupTableData) {
6507 Info->second.NameLookupTableData;
6508 bool FoundAnything =
false;
6509 for (ASTDeclContextNameLookupTable::data_iterator
6510 I = LookupTable->data_begin(), E = LookupTable->data_end();
6514 for (; Data.first != Data.second; ++Data.first) {
6521 FoundAnything =
true;
6522 if (This->DeclSet.insert(ND).second)
6527 return FoundAnything && !This->VisitAll;
6542 Contexts.push_back(DC);
6545 KeyDeclsMap::iterator Key =
6546 KeyDecls.find(const_cast<Decl *>(cast<Decl>(DC)));
6547 if (Key != KeyDecls.end()) {
6548 for (
unsigned I = 0, N = Key->second.size(); I != N; ++I)
6549 Contexts.push_back(cast<DeclContext>(GetDecl(Key->second[I])));
6553 DeclContextAllNamesVisitor Visitor(*
this, Contexts, Decls,
6555 ModuleMgr.visit(&DeclContextAllNamesVisitor::visit, &Visitor);
6556 ++NumVisibleDeclContextsRead;
6558 for (DeclsMap::iterator I = Decls.begin(), E = Decls.end(); I != E; ++I) {
6559 SetExternalVisibleDeclsForName(DC, I->first, I->second);
6561 const_cast<DeclContext *
>(DC)->setHasExternalVisibleStorage(
false);
6570 assert(ImplD && Consumer);
6572 for (
auto *I : ImplD->
methods())
6578 void ASTReader::PassInterestingDeclsToConsumer() {
6581 if (PassingDeclsToConsumer)
6591 for (
auto ID : EagerlyDeserializedDecls)
6593 EagerlyDeserializedDecls.clear();
6595 while (!InterestingDecls.empty()) {
6596 Decl *D = InterestingDecls.front();
6597 InterestingDecls.pop_front();
6599 PassInterestingDeclToConsumer(D);
6603 void ASTReader::PassInterestingDeclToConsumer(Decl *D) {
6611 this->Consumer = Consumer;
6614 PassInterestingDeclsToConsumer();
6616 if (DeserializationListener)
6617 DeserializationListener->ReaderInitialized(
this);
6621 std::fprintf(stderr,
"*** AST File Statistics:\n");
6623 unsigned NumTypesLoaded
6624 = TypesLoaded.size() - std::count(TypesLoaded.begin(), TypesLoaded.end(),
6626 unsigned NumDeclsLoaded
6627 = DeclsLoaded.size() - std::count(DeclsLoaded.begin(), DeclsLoaded.end(),
6629 unsigned NumIdentifiersLoaded
6630 = IdentifiersLoaded.size() - std::count(IdentifiersLoaded.begin(),
6631 IdentifiersLoaded.end(),
6633 unsigned NumMacrosLoaded
6634 = MacrosLoaded.size() - std::count(MacrosLoaded.begin(),
6637 unsigned NumSelectorsLoaded
6638 = SelectorsLoaded.size() - std::count(SelectorsLoaded.begin(),
6639 SelectorsLoaded.end(),
6642 if (
unsigned TotalNumSLocEntries = getTotalNumSLocs())
6643 std::fprintf(stderr,
" %u/%u source location entries read (%f%%)\n",
6644 NumSLocEntriesRead, TotalNumSLocEntries,
6645 ((
float)NumSLocEntriesRead/TotalNumSLocEntries * 100));
6646 if (!TypesLoaded.empty())
6647 std::fprintf(stderr,
" %u/%u types read (%f%%)\n",
6648 NumTypesLoaded, (
unsigned)TypesLoaded.size(),
6649 ((float)NumTypesLoaded/TypesLoaded.size() * 100));
6650 if (!DeclsLoaded.empty())
6651 std::fprintf(stderr,
" %u/%u declarations read (%f%%)\n",
6652 NumDeclsLoaded, (
unsigned)DeclsLoaded.size(),
6653 ((float)NumDeclsLoaded/DeclsLoaded.size() * 100));
6654 if (!IdentifiersLoaded.empty())
6655 std::fprintf(stderr,
" %u/%u identifiers read (%f%%)\n",
6656 NumIdentifiersLoaded, (
unsigned)IdentifiersLoaded.size(),
6657 ((float)NumIdentifiersLoaded/IdentifiersLoaded.size() * 100));
6658 if (!MacrosLoaded.empty())
6659 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
6660 NumMacrosLoaded, (
unsigned)MacrosLoaded.size(),
6661 ((float)NumMacrosLoaded/MacrosLoaded.size() * 100));
6662 if (!SelectorsLoaded.empty())
6663 std::fprintf(stderr,
" %u/%u selectors read (%f%%)\n",
6664 NumSelectorsLoaded, (
unsigned)SelectorsLoaded.size(),
6665 ((float)NumSelectorsLoaded/SelectorsLoaded.size() * 100));
6666 if (TotalNumStatements)
6667 std::fprintf(stderr,
" %u/%u statements read (%f%%)\n",
6668 NumStatementsRead, TotalNumStatements,
6669 ((
float)NumStatementsRead/TotalNumStatements * 100));
6671 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
6672 NumMacrosRead, TotalNumMacros,
6673 ((
float)NumMacrosRead/TotalNumMacros * 100));
6674 if (TotalLexicalDeclContexts)
6675 std::fprintf(stderr,
" %u/%u lexical declcontexts read (%f%%)\n",
6676 NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
6677 ((
float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts
6679 if (TotalVisibleDeclContexts)
6680 std::fprintf(stderr,
" %u/%u visible declcontexts read (%f%%)\n",
6681 NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
6682 ((
float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
6684 if (TotalNumMethodPoolEntries) {
6685 std::fprintf(stderr,
" %u/%u method pool entries read (%f%%)\n",
6686 NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
6687 ((
float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
6690 if (NumMethodPoolLookups) {
6691 std::fprintf(stderr,
" %u/%u method pool lookups succeeded (%f%%)\n",
6692 NumMethodPoolHits, NumMethodPoolLookups,
6693 ((
float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
6695 if (NumMethodPoolTableLookups) {
6696 std::fprintf(stderr,
" %u/%u method pool table lookups succeeded (%f%%)\n",
6697 NumMethodPoolTableHits, NumMethodPoolTableLookups,
6698 ((
float)NumMethodPoolTableHits/NumMethodPoolTableLookups
6702 if (NumIdentifierLookupHits) {
6703 std::fprintf(stderr,
6704 " %u / %u identifier table lookups succeeded (%f%%)\n",
6705 NumIdentifierLookupHits, NumIdentifierLookups,
6706 (
double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
6710 std::fprintf(stderr,
"\n");
6711 GlobalIndex->printStats();
6714 std::fprintf(stderr,
"\n");
6716 std::fprintf(stderr,
"\n");
6719 template<
typename Key,
typename ModuleFile,
unsigned InitialCapacity>
6723 InitialCapacity> &
Map) {
6724 if (
Map.begin() ==
Map.end())
6728 llvm::errs() << Name <<
":\n";
6729 for (
typename MapType::const_iterator I =
Map.begin(), IEnd =
Map.end();
6731 llvm::errs() <<
" " << I->first <<
" -> " << I->second->FileName
6737 llvm::errs() <<
"*** PCH/ModuleFile Remappings:\n";
6739 dumpModuleIDMap(
"Global source location entry map", GlobalSLocEntryMap);
6747 GlobalPreprocessedEntityMap);
6749 llvm::errs() <<
"\n*** PCH/Modules Loaded:";
6751 MEnd = ModuleMgr.end();
6760 E = ModuleMgr.end(); I != E; ++I) {
6761 if (llvm::MemoryBuffer *buf = (*I)->Buffer.get()) {
6762 size_t bytes = buf->getBufferSize();
6763 switch (buf->getBufferKind()) {
6764 case llvm::MemoryBuffer::MemoryBuffer_Malloc:
6767 case llvm::MemoryBuffer::MemoryBuffer_MMap:
6781 for (uint64_t ID : PreloadedDeclIDs) {
6782 NamedDecl *D = cast<NamedDecl>(GetDecl(ID));
6785 PreloadedDeclIDs.clear();
6788 if (!FPPragmaOptions.empty()) {
6789 assert(FPPragmaOptions.size() == 1 &&
"Wrong number of FP_PRAGMA_OPTIONS");
6790 SemaObj->FPFeatures.fp_contract = FPPragmaOptions[0];
6794 if (!OpenCLExtensions.empty()) {
6796 #define OPENCLEXT(nm) SemaObj->OpenCLFeatures.nm = OpenCLExtensions[I++];
6797 #include "clang/Basic/OpenCLExtensions.def"
6799 assert(OpenCLExtensions.size() == I &&
"Wrong number of OPENCL_EXTENSIONS");
6806 assert(SemaObj &&
"no Sema to update");
6810 if (!SemaDeclRefs.empty()) {
6811 assert(SemaDeclRefs.size() % 2 == 0);
6812 for (
unsigned I = 0; I != SemaDeclRefs.size(); I += 2) {
6813 if (!SemaObj->StdNamespace)
6814 SemaObj->StdNamespace = SemaDeclRefs[I];
6815 if (!SemaObj->StdBadAlloc)
6816 SemaObj->StdBadAlloc = SemaDeclRefs[I+1];
6818 SemaDeclRefs.clear();
6823 if(OptimizeOffPragmaLocation.isValid())
6824 SemaObj->ActOnPragmaOptimize(
false, OptimizeOffPragmaLocation);
6830 StringRef Name(NameStart, NameEnd - NameStart);
6836 if (!loadGlobalIndex()) {
6837 if (GlobalIndex->lookupIdentifier(Name, Hits)) {
6841 IdentifierLookupVisitor Visitor(Name, 0,
6842 NumIdentifierLookups,
6843 NumIdentifierLookupHits);
6844 ModuleMgr.visit(IdentifierLookupVisitor::visit, &Visitor, HitsPtr);
6846 markIdentifierUpToDate(II);
6863 ASTIdentifierLookupTable::key_iterator
Current;
6867 ASTIdentifierLookupTable::key_iterator
End;
6872 StringRef
Next()
override;
6877 : Reader(Reader), Index(Reader.ModuleMgr.size() - 1) {
6880 Current = IdTable->key_begin();
6881 End = IdTable->key_end();
6885 while (Current == End) {
6893 IdentifierLookupTable;
6894 Current = IdTable->key_begin();
6895 End = IdTable->key_end();
6900 StringRef Result = *Current;
6907 return GlobalIndex->createIdentifierIterator();
6912 namespace clang {
namespace serialization {
6916 unsigned PriorGeneration;
6917 unsigned InstanceBits;
6918 unsigned FactoryBits;
6919 bool InstanceHasMoreThanOneDecl;
6920 bool FactoryHasMoreThanOneDecl;
6926 unsigned PriorGeneration)
6927 : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration),
6928 InstanceBits(0), FactoryBits(0), InstanceHasMoreThanOneDecl(
false),
6929 FactoryHasMoreThanOneDecl(
false) {}
6931 static bool visit(ModuleFile &M,
void *UserData) {
6942 ++This->Reader.NumMethodPoolTableLookups;
6945 ASTSelectorLookupTable::iterator Pos = PoolTable->find(This->Sel);
6946 if (Pos == PoolTable->end())
6949 ++This->Reader.NumMethodPoolTableHits;
6950 ++This->Reader.NumSelectorsRead;
6954 ++This->Reader.NumMethodPoolEntriesRead;
6956 if (This->Reader.DeserializationListener)
6961 This->FactoryMethods.append(Data.
Factory.begin(), Data.
Factory.end());
6971 return InstanceMethods;
6976 return FactoryMethods;
6982 return InstanceHasMoreThanOneDecl;
6991 for (
unsigned I = 0, N = Methods.size(); I != N; ++I) {
6998 unsigned &Generation = SelectorGeneration[Sel];
6999 unsigned PriorGeneration = Generation;
7003 ++NumMethodPoolLookups;
7005 ModuleMgr.
visit(&ReadMethodPoolVisitor::visit, &Visitor);
7011 ++NumMethodPoolHits;
7017 Sema::GlobalMethodPool::iterator Pos
7036 for (
unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) {
7038 = dyn_cast_or_null<NamespaceDecl>(
GetDecl(KnownNamespaces[I])))
7039 Namespaces.push_back(Namespace);
7044 llvm::DenseMap<NamedDecl*, SourceLocation> &Undefined) {
7045 for (
unsigned Idx = 0, N = UndefinedButUsed.size(); Idx != N;) {
7049 Undefined.insert(std::make_pair(D, Loc));
7056 for (
unsigned Idx = 0, N = DelayedDeleteExprs.size(); Idx != N;) {
7058 uint64_t Count = DelayedDeleteExprs[Idx++];
7059 for (uint64_t C = 0; C <
Count; ++
C) {
7062 const bool IsArrayForm = DelayedDeleteExprs[Idx++];
7063 Exprs[FD].push_back(std::make_pair(DeleteLoc, IsArrayForm));
7070 for (
unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) {
7071 VarDecl *Var = dyn_cast_or_null<VarDecl>(
GetDecl(TentativeDefinitions[I]));
7073 TentativeDefs.push_back(Var);
7075 TentativeDefinitions.clear();
7080 for (
unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++I) {
7082 = dyn_cast_or_null<DeclaratorDecl>(
GetDecl(UnusedFileScopedDecls[I]));
7086 UnusedFileScopedDecls.clear();
7091 for (
unsigned I = 0, N = DelegatingCtorDecls.size(); I != N; ++I) {
7093 = dyn_cast_or_null<CXXConstructorDecl>(
GetDecl(DelegatingCtorDecls[I]));
7097 DelegatingCtorDecls.clear();
7101 for (
unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++I) {
7103 = dyn_cast_or_null<TypedefNameDecl>(
GetDecl(ExtVectorDecls[I]));
7107 ExtVectorDecls.clear();
7112 for (
unsigned I = 0, N = UnusedLocalTypedefNameCandidates.size(); I != N;
7115 GetDecl(UnusedLocalTypedefNameCandidates[I]));
7119 UnusedLocalTypedefNameCandidates.clear();
7124 if (ReferencedSelectorsData.empty())
7129 unsigned int DataSize = ReferencedSelectorsData.size()-1;
7131 while (I < DataSize) {
7135 Sels.push_back(std::make_pair(Sel, SelLoc));
7137 ReferencedSelectorsData.clear();
7142 if (WeakUndeclaredIdentifiers.empty())
7145 for (
unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; ) {
7152 bool Used = WeakUndeclaredIdentifiers[I++];
7155 WeakIDs.push_back(std::make_pair(WeakId, WI));
7157 WeakUndeclaredIdentifiers.clear();
7161 for (
unsigned Idx = 0, N = VTableUses.size(); Idx < N; ) {
7163 VT.
Record = dyn_cast_or_null<CXXRecordDecl>(
GetDecl(VTableUses[Idx++]));
7166 VTables.push_back(VT);
7174 for (
unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
7179 Pending.push_back(std::make_pair(D, Loc));
7181 PendingInstantiations.clear();
7185 llvm::MapVector<const FunctionDecl *, LateParsedTemplate *> &LPTMap) {
7186 for (
unsigned Idx = 0, N = LateParsedTemplates.size(); Idx < N;
7191 LT->
D =
GetDecl(LateParsedTemplates[Idx++]);
7194 assert(F &&
"No module");
7196 unsigned TokN = LateParsedTemplates[Idx++];
7197 LT->Toks.reserve(TokN);
7198 for (
unsigned T = 0; T < TokN; ++T)
7199 LT->Toks.push_back(
ReadToken(*F, LateParsedTemplates, Idx));
7201 LPTMap.insert(std::make_pair(FD, LT));
7204 LateParsedTemplates.clear();
7213 assert(ID &&
"Non-zero identifier ID required");
7214 assert(ID <= IdentifiersLoaded.size() &&
"identifier ID out of range");
7215 IdentifiersLoaded[ID - 1] = II;
7216 if (DeserializationListener)
7240 if (NumCurrentElementsDeserializing && !Decls) {
7241 PendingIdentifierInfos[II].append(DeclIDs.begin(), DeclIDs.end());
7245 for (
unsigned I = 0, N = DeclIDs.size(); I != N; ++I) {
7258 Decls->push_back(D);
7265 pushExternalDeclIntoScope(D, II);
7273 if (IdentifiersLoaded.empty()) {
7274 Error(
"no identifier table in AST file");
7279 if (!IdentifiersLoaded[ID]) {
7281 assert(I != GlobalIdentifierMap.
end() &&
"Corrupted global identifier map");
7282 ModuleFile *M = I->second;
7283 unsigned Index = ID - M->BaseIdentifierID;
7284 const char *Str = M->IdentifierTableData + M->IdentifierOffsets[Index];
7291 const unsigned char *StrLenPtr = (
const unsigned char*) Str - 2;
7292 unsigned StrLen = (((
unsigned) StrLenPtr[0])
7293 | (((
unsigned) StrLenPtr[1]) << 8)) - 1;
7294 IdentifiersLoaded[
ID]
7296 if (DeserializationListener)
7297 DeserializationListener->
IdentifierRead(ID + 1, IdentifiersLoaded[ID]);
7300 return IdentifiersLoaded[
ID];
7314 &&
"Invalid index into identifier index remap");
7316 return LocalID + I->second;
7323 if (MacrosLoaded.empty()) {
7324 Error(
"no macro table in AST file");
7329 if (!MacrosLoaded[ID]) {
7332 assert(I != GlobalMacroMap.
end() &&
"Corrupted global macro map");
7333 ModuleFile *M = I->second;
7334 unsigned Index = ID - M->BaseMacroID;
7337 if (DeserializationListener)
7342 return MacrosLoaded[
ID];
7351 assert(I != M.
MacroRemap.
end() &&
"Invalid index into macro index remap");
7353 return LocalID + I->second;
7358 if (LocalID < NUM_PREDEF_SUBMODULE_IDS)
7364 &&
"Invalid index into submodule index remap");
7366 return LocalID + I->second;
7370 if (GlobalID < NUM_PREDEF_SUBMODULE_IDS) {
7371 assert(GlobalID == 0 &&
"Unhandled global submodule ID");
7375 if (GlobalID > SubmodulesLoaded.size()) {
7376 Error(
"submodule ID out of range in AST file");
7389 StringRef Dir, Filename;
7407 if (ModuleMgr.
size() == 1) {
7426 if (ID > SelectorsLoaded.size()) {
7427 Error(
"selector ID out of range in AST file");
7431 if (SelectorsLoaded[ID - 1].getAsOpaquePtr() ==
nullptr) {
7434 assert(I != GlobalSelectorMap.
end() &&
"Corrupted global selector map");
7435 ModuleFile &M = *I->second;
7438 SelectorsLoaded[ID - 1] =
7439 Trait.
ReadKey(M.SelectorLookupTableData + M.SelectorOffsets[Idx], 0);
7440 if (DeserializationListener)
7441 DeserializationListener->
SelectorRead(ID, SelectorsLoaded[ID - 1]);
7444 return SelectorsLoaded[ID - 1];
7464 &&
"Invalid index into selector index remap");
7466 return LocalID + I->second;
7506 llvm_unreachable(
"Invalid NameKind!");
7554 unsigned NumTPLists = Record[Idx++];
7558 for (
unsigned i=0; i != NumTPLists; ++i)
7569 return TemplateName(ReadDeclAs<TemplateDecl>(F, Record, Idx));
7572 unsigned size = Record[Idx++];
7575 Decls.
addDecl(ReadDeclAs<NamedDecl>(F, Record, Idx));
7582 bool hasTemplKeyword = Record[Idx++];
7583 TemplateDecl *Template = ReadDeclAs<TemplateDecl>(F, Record, Idx);
7599 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
7607 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
7619 llvm_unreachable(
"Unhandled template name kind!");
7632 ValueDecl *D = ReadDeclAs<ValueDecl>(F, Record, Idx);
7647 if (
unsigned NumExpansions = Record[Idx++])
7648 NumTemplateExpansions = NumExpansions - 1;
7654 unsigned NumArgs = Record[Idx++];
7656 for (
unsigned I = 0; I != NumArgs; ++I)
7662 llvm_unreachable(
"Unhandled template argument kind!");
7672 unsigned NumParams = Record[Idx++];
7674 Params.reserve(NumParams);
7676 Params.push_back(ReadDeclAs<NamedDecl>(F, Record, Idx));
7680 Params.data(), Params.size(), RAngleLoc);
7681 return TemplateParams;
7689 unsigned NumTemplateArgs = Record[Idx++];
7690 TemplArgs.reserve(NumTemplateArgs);
7691 while (NumTemplateArgs--)
7698 unsigned NumDecls = Record[Idx++];
7699 Set.
reserve(Context, NumDecls);
7700 while (NumDecls--) {
7710 bool isVirtual =
static_cast<bool>(Record[Idx++]);
7711 bool isBaseOfClass =
static_cast<bool>(Record[Idx++]);
7713 bool inheritConstructors =
static_cast<bool>(Record[Idx++]);
7726 unsigned NumInitializers = Record[Idx++];
7727 assert(NumInitializers &&
"wrote ctor initializers but have no inits");
7729 for (
unsigned i = 0; i != NumInitializers; ++i) {
7731 bool IsBaseVirtual =
false;
7739 IsBaseVirtual = Record[Idx++];
7747 Member = ReadDeclAs<FieldDecl>(F, Record, Idx);
7751 IndirectMember = ReadDeclAs<IndirectFieldDecl>(F, Record, Idx);
7759 bool IsWritten = Record[Idx++];
7760 unsigned SourceOrderOrNumArrayIndices;
7763 SourceOrderOrNumArrayIndices = Record[Idx++];
7765 SourceOrderOrNumArrayIndices = Record[Idx++];
7766 Indices.reserve(SourceOrderOrNumArrayIndices);
7767 for (
unsigned i=0; i != SourceOrderOrNumArrayIndices; ++i)
7768 Indices.push_back(ReadDeclAs<VarDecl>(F, Record, Idx));
7773 BOMInit =
new (Context)
7775 RParenLoc, MemberOrEllipsisLoc);
7777 BOMInit =
new (Context)
7779 }
else if (IsWritten) {
7782 Context, Member, MemberOrEllipsisLoc, LParenLoc, Init, RParenLoc);
7784 BOMInit =
new (Context)
7786 LParenLoc, Init, RParenLoc);
7788 if (IndirectMember) {
7789 assert(Indices.empty() &&
"Indirect field improperly initialized");
7790 BOMInit =
new (Context)
7792 LParenLoc, Init, RParenLoc);
7795 Context, Member, MemberOrEllipsisLoc, LParenLoc, Init, RParenLoc,
7796 Indices.data(), Indices.size());
7802 CtorInitializers[i] = BOMInit;
7805 return CtorInitializers;
7811 unsigned N = Record[Idx++];
7813 for (
unsigned I = 0; I != N; ++I) {
7824 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
7841 bool Template = Record[Idx++];
7853 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
7866 unsigned N = Record[Idx++];
7868 for (
unsigned I = 0; I != N; ++I) {
7880 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
7882 Builder.
Extend(Context, NS, Range.getBegin(), Range.getEnd());
7889 Builder.
Extend(Context, Alias, Range.getBegin(), Range.getEnd());
7895 bool Template = Record[Idx++];
7915 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
7917 Builder.
MakeSuper(Context, RD, Range.getBegin(), Range.getEnd());
7936 unsigned BitWidth = Record[Idx++];
7937 unsigned NumWords = llvm::APInt::getNumWords(BitWidth);
7938 llvm::APInt
Result(BitWidth, NumWords, &Record[Idx]);
7945 bool isUnsigned = Record[Idx++];
7946 return llvm::APSInt(
ReadAPInt(Record, Idx), isUnsigned);
7951 const llvm::fltSemantics &Sem,
7953 return llvm::APFloat(Sem,
ReadAPInt(Record, Idx));
7958 unsigned Len = Record[Idx++];
7959 std::string
Result(Record.data() + Idx, Record.data() + Idx + Len);
7966 std::string Filename =
ReadString(Record, Idx);
7973 unsigned Major = Record[Idx++];
7974 unsigned Minor = Record[Idx++];
7975 unsigned Subminor = Record[Idx++];
7991 return Diag(CurrentImportLoc, DiagID);
7995 return Diags.
Report(Loc, DiagID);
8007 assert((*CurrSwitchCaseStmts)[ID] ==
nullptr &&
8008 "Already have a SwitchCase with this ID");
8009 (*CurrSwitchCaseStmts)[
ID] = SC;
8014 assert((*CurrSwitchCaseStmts)[ID] !=
nullptr &&
"No SwitchCase with this ID");
8015 return (*CurrSwitchCaseStmts)[
ID];
8019 CurrSwitchCaseStmts->clear();
8023 std::vector<RawComment *> Comments;
8030 BitstreamCursor &Cursor = I->first;
8036 llvm::BitstreamEntry Entry =
8037 Cursor.advanceSkippingSubblocks(BitstreamCursor::AF_DontPopBlockAtEnd);
8039 switch (Entry.Kind) {
8040 case llvm::BitstreamEntry::SubBlock:
8042 Error(
"malformed block record in AST file");
8044 case llvm::BitstreamEntry::EndBlock:
8046 case llvm::BitstreamEntry::Record:
8059 bool IsTrailingComment = Record[Idx++];
8060 bool IsAlmostTrailingComment = Record[Idx++];
8062 SR, Kind, IsTrailingComment, IsAlmostTrailingComment,
8069 Context.
Comments.addDeserializedComments(Comments);
8077 Files.push_back(getInputFile(F, ID));
8084 return M->getFullModuleName();
8094 void ASTReader::finishPendingActions() {
8095 while (!PendingIdentifierInfos.empty() ||
8096 !PendingIncompleteDeclChains.empty() || !PendingDeclChains.empty() ||
8097 !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
8098 !PendingUpdateRecords.empty()) {
8101 typedef llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2> >
8103 TopLevelDeclsMap TopLevelDecls;
8105 while (!PendingIdentifierInfos.empty()) {
8108 std::move(PendingIdentifierInfos.back().second);
8109 PendingIdentifierInfos.pop_back();
8116 for (
unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
8117 markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
8119 PendingIncompleteDeclChains.clear();
8122 for (
unsigned I = 0; I != PendingDeclChains.size(); ++I) {
8123 PendingDeclChainsKnown.erase(PendingDeclChains[I]);
8124 loadPendingDeclChain(PendingDeclChains[I]);
8126 assert(PendingDeclChainsKnown.empty());
8127 PendingDeclChains.clear();
8130 for (TopLevelDeclsMap::iterator TLD = TopLevelDecls.begin(),
8131 TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) {
8133 for (
unsigned I = 0, N = TLD->second.size(); I != N; ++I) {
8134 pushExternalDeclIntoScope(cast<NamedDecl>(TLD->second[I]), II);
8139 for (
unsigned I = 0; I != PendingMacroIDs.size(); ++I) {
8142 GlobalIDs.swap(PendingMacroIDs.begin()[I].second);
8144 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
8146 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
8152 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
8154 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
8160 PendingMacroIDs.clear();
8164 while (!PendingDeclContextInfos.empty()) {
8165 PendingDeclContextInfo Info = PendingDeclContextInfos.front();
8166 PendingDeclContextInfos.pop_front();
8169 Info.D->setDeclContextsImpl(SemaDC, LexicalDC,
getContext());
8173 while (!PendingUpdateRecords.empty()) {
8174 auto Update = PendingUpdateRecords.pop_back_val();
8175 ReadingKindTracker ReadingKind(Read_Decl, *
this);
8176 loadDeclUpdateRecords(Update.first, Update.second);
8182 assert(PendingFakeDefinitionData.empty() &&
8183 "faked up a class definition but never saw the real one");
8189 for (Decl *D : PendingDefinitions) {
8190 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
8191 if (
const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) {
8196 if (
auto RD = dyn_cast<CXXRecordDecl>(D)) {
8197 for (
auto *R = getMostRecentExistingDecl(RD); R;
8200 cast<CXXRecordDecl>(R)->isThisDeclarationADefinition() &&
8201 "declaration thinks it's the definition but it isn't");
8202 cast<CXXRecordDecl>(R)->DefinitionData = RD->DefinitionData;
8209 if (
auto ID = dyn_cast<ObjCInterfaceDecl>(D)) {
8214 for (
auto *R = getMostRecentExistingDecl(ID); R; R = R->
getPreviousDecl())
8215 cast<ObjCInterfaceDecl>(R)->Data = ID->Data;
8220 if (
auto PD = dyn_cast<ObjCProtocolDecl>(D)) {
8221 for (
auto *R = getMostRecentExistingDecl(PD); R; R = R->
getPreviousDecl())
8222 cast<ObjCProtocolDecl>(R)->Data = PD->Data;
8227 auto RTD = cast<RedeclarableTemplateDecl>(D)->getCanonicalDecl();
8228 for (
auto *R = getMostRecentExistingDecl(RTD); R; R = R->
getPreviousDecl())
8229 cast<RedeclarableTemplateDecl>(R)->Common = RTD->Common;
8231 PendingDefinitions.clear();
8238 for (PendingBodiesMap::iterator PB = PendingBodies.begin(),
8239 PBEnd = PendingBodies.end();
8240 PB != PBEnd; ++PB) {
8241 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
8245 FD->setLazyBody(PB->second);
8253 PendingBodies.clear();
8256 for (
auto *ND : PendingMergedDefinitionsToDeduplicate)
8258 PendingMergedDefinitionsToDeduplicate.clear();
8261 void ASTReader::diagnoseOdrViolations() {
8262 if (PendingOdrMergeFailures.empty() && PendingOdrMergeChecks.empty())
8269 auto OdrMergeFailures = std::move(PendingOdrMergeFailures);
8270 PendingOdrMergeFailures.clear();
8271 for (
auto &Merge : OdrMergeFailures) {
8272 Merge.first->buildLookup();
8273 Merge.first->decls_begin();
8274 Merge.first->bases_begin();
8275 Merge.first->vbases_begin();
8276 for (
auto *RD : Merge.second) {
8289 while (!PendingOdrMergeChecks.empty()) {
8290 NamedDecl *D = PendingOdrMergeChecks.pop_back_val();
8304 for (
auto RI : D->
redecls()) {
8305 if (RI->getLexicalDeclContext() == CanonDef) {
8316 !Found && I != E; ++I) {
8317 for (
auto RI : (*I)->redecls()) {
8318 if (RI->getLexicalDeclContext() == CanonDef) {
8321 if (RI->getCanonicalDecl() == DCanon)
8324 Candidates.push_back(cast<NamedDecl>(RI));
8333 if (!isa<TagDecl>(D))
8338 Deserializing RecursionGuard(
this);
8340 std::string CanonDefModule =
8344 << CanonDef << CanonDefModule.empty() << CanonDefModule;
8346 if (Candidates.empty())
8347 Diag(cast<Decl>(CanonDef)->getLocation(),
8348 diag::note_module_odr_violation_no_possible_decls) << D;
8350 for (
unsigned I = 0, N = Candidates.size(); I != N; ++I)
8351 Diag(Candidates[I]->getLocation(),
8352 diag::note_module_odr_violation_possible_decl)
8356 DiagnosedOdrMergeFailures.insert(CanonDef);
8360 if (OdrMergeFailures.empty())
8365 Deserializing RecursionGuard(
this);
8368 for (
auto &Merge : OdrMergeFailures) {
8371 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
8374 bool Diagnosed =
false;
8375 for (
auto *RD : Merge.second) {
8378 if (Merge.first != RD) {
8383 Diag(Merge.first->getLocation(),
8384 diag::err_module_odr_violation_different_definitions)
8385 << Merge.first << Module.empty() << Module;
8389 Diag(RD->getLocation(),
8390 diag::note_module_odr_violation_different_definitions)
8402 Diag(Merge.first->getLocation(),
8403 diag::err_module_odr_violation_different_instantiations)
8410 if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get())
8411 ReadTimer->startTimer();
8415 assert(NumCurrentElementsDeserializing &&
8416 "FinishedDeserializing not paired with StartedDeserializing");
8417 if (NumCurrentElementsDeserializing == 1) {
8420 finishPendingActions();
8422 --NumCurrentElementsDeserializing;
8424 if (NumCurrentElementsDeserializing == 0) {
8426 while (!PendingExceptionSpecUpdates.empty()) {
8427 auto Updates = std::move(PendingExceptionSpecUpdates);
8428 PendingExceptionSpecUpdates.clear();
8432 FPT->getExtProtoInfo().ExceptionSpec);
8436 diagnoseOdrViolations();
8439 ReadTimer->stopTimer();
8444 PassInterestingDeclsToConsumer();
8451 auto It = PendingFakeLookupResults.find(II);
8452 if (It != PendingFakeLookupResults.end()) {
8453 for (
auto *ND : PendingFakeLookupResults[II])
8464 }
else if (SemaObj->
TUScope) {
8476 StringRef isysroot,
bool DisableValidation,
8477 bool AllowASTWithCompilerErrors,
8478 bool AllowConfigurationMismatch,
bool ValidateSystemInputs,
8479 bool UseGlobalIndex,
8480 std::unique_ptr<llvm::Timer> ReadTimer)
8481 : Listener(new
PCHValidator(PP, *this)), DeserializationListener(nullptr),
8482 OwnsDeserializationListener(
false),
SourceMgr(PP.getSourceManager()),
8483 FileMgr(PP.getFileManager()), PCHContainerRdr(PCHContainerRdr),
8484 Diags(PP.getDiagnostics()), SemaObj(nullptr), PP(PP), Context(Context),
8485 Consumer(nullptr), ModuleMgr(PP.getFileManager(), PCHContainerRdr),
8486 ReadTimer(std::move(ReadTimer)),
8487 isysroot(isysroot), DisableValidation(DisableValidation),
8488 AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
8489 AllowConfigurationMismatch(AllowConfigurationMismatch),
8490 ValidateSystemInputs(ValidateSystemInputs),
8491 UseGlobalIndex(UseGlobalIndex), TriedLoadingGlobalIndex(
false),
8492 CurrSwitchCaseStmts(&SwitchCaseStmts), NumSLocEntriesRead(0),
8493 TotalNumSLocEntries(0), NumStatementsRead(0), TotalNumStatements(0),
8494 NumMacrosRead(0), TotalNumMacros(0), NumIdentifierLookups(0),
8495 NumIdentifierLookupHits(0), NumSelectorsRead(0),
8496 NumMethodPoolEntriesRead(0), NumMethodPoolLookups(0),
8497 NumMethodPoolHits(0), NumMethodPoolTableLookups(0),
8498 NumMethodPoolTableHits(0), TotalNumMethodPoolEntries(0),
8499 NumLexicalDeclContextsRead(0), TotalLexicalDeclContexts(0),
8500 NumVisibleDeclContextsRead(0), TotalVisibleDeclContexts(0),
8501 TotalModulesSizeInBits(0), NumCurrentElementsDeserializing(0),
8502 PassingDeclsToConsumer(
false), ReadingKind(Read_None) {
8507 if (OwnsDeserializationListener)
8508 delete DeserializationListener;
8510 for (DeclContextVisibleUpdatesPending::iterator
8511 I = PendingVisibleUpdates.begin(),
8512 E = PendingVisibleUpdates.end();
8514 for (DeclContextVisibleUpdates::iterator J = I->second.begin(),
8515 F = I->second.end();
llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx)
Read an integral value.
Decl * GetExistingDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration. Return 0 if it's not been loaded yet.
void addHeader(Module *Mod, Module::Header Header, ModuleHeaderRole Role)
Adds this header to the given module.
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
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override
Finds all the visible declarations with a given name. The current implementation of this method just ...
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons...
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...
SmallVector< UnresolvedExportDecl, 2 > UnresolvedExports
The set of export declarations that have yet to be resolved.
void setInfo(const DeclarationNameLoc &Info)
std::string Name
The name of this module.
std::pair< LE32DeclID *, LE32DeclID * > data_type
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)
const KindDeclIDPair * LexicalDecls
bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden) override
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type, SourceLocation ImportLoc, unsigned ClientLoadCapabilities)
Load the AST file designated by the given file name.
static hash_value_type ComputeHash(Selector Sel)
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.
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.
data_type ReadData(internal_key_type, const unsigned char *d, unsigned DataLen)
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]]].
CanQualType OCLImage1dBufferTy
static bool startsWithASTFileMagic(BitstreamCursor &Stream)
Whether Stream starts with the AST/PCH file magic number 'CPCH'.
void SetIdentifierInfo(unsigned ID, IdentifierInfo *II)
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
Implements support for file system lookup, file system caching, and directory search management...
The (signed) 'long long' type.
A simple structure that captures a vtable use for the purposes of the ExternalSemaSource.
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.
The 'bool' or '_Bool' type.
bool factoryHasMoreThanOneDecl() const
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
void setRParenLoc(SourceLocation Loc)
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
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 setArgumentList(IdentifierInfo *const *List, unsigned NumArgs, llvm::BumpPtrAllocator &PPAllocator)
Set the specified list of identifiers as the argument list for this macro.
void setLAngleLoc(SourceLocation Loc)
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, unsigned Raw) const
Read a source location from raw form.
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...
const serialization::LocalRedeclarationsInfo * RedeclarationsMap
Array of redeclaration chain location information within this module file, sorted by the first declar...
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "...
IdentifierInfo * getCXXLiteralIdentifier() const
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 comment ranges.
std::vector< UnresolvedConflict > UnresolvedConflicts
The list of conflicts for which the module-id has not yet been resolved.
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.
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.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, NamedDecl **Params, unsigned NumParams, SourceLocation RAngleLoc)
std::string getTimestampFilename() const
virtual void MacroRead(serialization::MacroID ID, MacroInfo *MI)
A macro was read from the AST file.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
CanQualType ObjCBuiltinSelTy
RetTy Visit(TypeLoc TyLoc)
ModuleManager::ModuleConstIterator ModuleConstIterator
void VisitFunctionTypeLoc(FunctionTypeLoc)
ModuleKind Kind
The type of this module.
unsigned Begin
Raw source location of beginning of range.
Defines the C++ template declaration subclasses.
Describes a source location entry (SLocEntry) for a macro expansion.
unsigned getFactoryBits() const
std::vector< std::string > Includes
An LValueReferenceType record.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
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.
IdentifierInfo * getAsIdentifierInfo() const
Specifies an umbrella directory.
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)
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, ASTReaderListener &Listener)
Read the control block for the named AST file.
A SubstTemplateTypeParmType record.
QualType getRecordType(const RecordDecl *Decl) const
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
Class that performs name lookup into a DeclContext stored in an AST file.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void setTemplateKeywordLoc(SourceLocation Loc)
void setFlag(TokenFlags Flag)
Set the specified flag.
NamespaceDecl - Represent a C++ namespace.
Wrapper for source info for typedefs.
static hash_value_type ComputeHash(const DeclNameKey &Key)
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.
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.
llvm::OnDiskIterableChainedHashTable< reader::ASTDeclContextNameLookupTrait > * NameLookupTableData
TypeLoc getNextTypeLoc() const
An IncompleteArrayType record.
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.
CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a C++ base specifier.
ARC's unbridged-cast placeholder type.
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.
QualType getVaListTagType() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
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
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)
void setPreambleFileID(FileID Preamble)
Set the file ID for the precompiled preamble.
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.
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...
void dump()
Dump information about the AST reader to standard error.
ModuleManager::ModuleReverseIterator ModuleReverseIterator
Represents an empty template argument, e.g., one that has not been deduced.
ExtProtoInfo - 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 ...
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
TemplateArgument ReadTemplateArgument(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template argument.
The value of the next COUNTER to dispense. [PP_COUNTER_VALUE, Val].
unsigned getLineTableFilenameID(StringRef Str)
const DeclContext * getDefinitiveDeclContext(const DeclContext *DC)
Retrieve the "definitive" declaration that provides all of the visible entries for the given declarat...
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>". This is safe to be used inside an AST node, in contrast with TemplateArgumentListInfo.
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.
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.
static bool visit(ModuleFile &M, void *UserData)
Defines the clang::Expr interface and subclasses for C++ expressions.
Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx)
void setHasExternalVisibleStorage(bool ES=true)
State whether this DeclContext has external storage for declarations visible in this context...
int SLocEntryBaseID
The base ID in the source manager's view of this module.
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)
Record code for the array of redeclaration chains.
MemoryBufferSizes getMemoryBufferSizes() const
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
SourceLocation ImportLoc
The source location where this module was first imported.
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'.
Base wrapper for a particular "section" of type source info.
C ucontext_t typedef type.
std::string getFullModuleName() const
Retrieve the full name of this module, including the path from its top-level module.
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...
DeclarationName getName() const
getName - Returns the embedded declaration name.
FunctionType::ExtInfo ExtInfo
A macro directive exported by a module. [PP_MODULE_MACRO, SubmoduleID, MacroID, (Overridden Submodule...
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.
void setMainFileID(FileID FID)
Set the file ID for the main source file.
Specifies a top-level header that falls into this (sub)module.
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.
A library or framework to link against when an entity from this module is used.
bool instanceHasMoreThanOneDecl() const
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
QualType getAutoType(QualType DeducedType, bool IsDecltypeAuto, bool IsDependent) const
C++11 deduced auto type.
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.
CanQualType OCLImage2dArrayTy
The results of name lookup within a DeclContext. This is either a single result (with no stable stora...
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...
void setBuiltinLoc(SourceLocation Loc)
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
DeclarationName::NameKind Kind
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.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
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.
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...
void ReadUndefinedButUsed(llvm::DenseMap< 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.
OpenCL 1d image buffer 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.
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
unsigned getNumProtocols() const
Wrapper for source info for unresolved typename using decls.
std::string OriginalDir
The directory that the PCH was originally created in. Used to allow resolving headers even after head...
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. [PP_MACRO_OBJECT_LIKE, IdentInfoID, SLoc, IsUsed].
StringRef internal_key_type
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Describes one token. [PP_TOKEN, SLoc, Length, IdentInfoID, Kind, Flags].
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.
Record code for the diagnostic options table.
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'.
Record code for the headers search options table.
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
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)
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.
void setcudaConfigureCallDecl(FunctionDecl *FD)
Describes a blob that contains the data for a buffer entry. This kind of record always directly follo...
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
ModuleManager & getModuleManager()
Retrieve the module manager.
void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, const RecordData &Record, unsigned &Idx)
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.
uint64_t readCXXBaseSpecifiers(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Read a CXXBaseSpecifiers ID form the given record and return its global bit offset.
An ObjCObjectType record.
A ConstantArrayType record.
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
void RemoveDecl(NamedDecl *D)
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
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
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
bool needsExtraLocalData() const
void setRParenLoc(SourceLocation Loc)
void setLazyBody(uint64_t Offset)
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
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.
unsigned LocalNumRedeclarationsInMap
The number of redeclaration info entries in RedeclarationsMap.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep)
Creates clause with a list of variables VL and a linear step Step.
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. If an external source already exists, creates a multiplex external sour...
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.
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location...
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.
decl_iterator decls_begin() const
FunctionDecl * SourceDecl
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.
std::pair< uint32_t, DeclID > KindDeclIDPair
a Decl::Kind/DeclID pair.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
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.
QualType getTemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon=QualType()) const
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)
Record code for the array describing the locations (in the LOCAL_REDECLARATIONS record) of the redecl...
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.
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
unsigned NumTemplParamLists
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.
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. Contains type source information through TypeSo...
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
Record code for the preprocessor options table.
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...
ID
Defines the set of possible language-specific address spaces.
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
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.
bool isInFileID(SourceLocation Loc, FileID FID, unsigned *RelativeOffset=nullptr) const
Given a specific FileID, returns true if Loc is inside that FileID chunk and sets relative offset (of...
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.
StringRef getName() const
Return the actual identifier string.
Record code for the array of VTable uses.
The 'char' type, when it is unsigned.
void setHasCommaPasting()
Record code for the target options table.
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.
ExternalLoadResult
Enumeration describing the result of loading information from an external source. ...
DiagnosticBuilder Diag(unsigned DiagID)
Report a diagnostic.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
virtual bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden)
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
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.
FileID createFileID(const FileEntry *SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, unsigned LoadedOffset=0)
Create a new FileID that represents the specified file being #included from the specified IncludePosi...
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.
Implements an efficient mapping from strings to IdentifierInfo nodes.
Defines implementation details of the clang::SourceManager class.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
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.
unsigned LocalNumCXXBaseSpecifiers
The number of C++ base specifier sets in this AST file.
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.
Loading the external information has succeeded.
ContinuousRangeMap< uint32_t, int, 2 > IdentifierRemap
Remapping table for identifier IDs in this module.
llvm::BitstreamCursor SLocEntryCursor
Cursor used to read source location entries.
void setInvalidDecl(bool Invalid=true)
TranslationUnitDecl * getTranslationUnitDecl() const
Defines version macros and version-related utility functions for Clang.
The OpenCL 'half' / ARM NEON __fp16 type.
llvm::support::ulittle32_t LE32DeclID
Pair of begin/end iterators for DeclIDs.
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...
DeclContext * getDeclContext()
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.
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*.
void visit(bool(*Visitor)(ModuleFile &M, void *UserData), void *UserData, llvm::SmallPtrSetImpl< ModuleFile * > *ModuleFilesHit=nullptr)
Visit each of the modules.
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.
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.
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)
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
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.
InclusionKind
The kind of inclusion directives known to the preprocessor.
The width of the "fast" qualifier mask.
QualType withFastQualifiers(unsigned TQs) const
SourceLocation createExpansionLoc(SourceLocation Loc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned TokLength, int LoadedID=0, unsigned LoadedOffset=0)
Return a new SourceLocation that encodes the fact that a token from SpellingLoc should actually be re...
Record code for the filesystem options table.
struct CXXOpName CXXOperatorName
DeclarationName getDeclName() const
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.
void deduplicateMergedDefinitonsFor(NamedDecl *ND)
Clean up the merged definition list. Call this if you might have added duplicates into the 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.
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.
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
const DirectoryEntry * Directory
The build directory of this module. This is the directory in which the module is notionally built...
void overrideFileContents(const FileEntry *SourceFile, llvm::MemoryBuffer *Buffer, bool DoNotFree)
Override the contents of the given source file by providing an already-allocated buffer.
void setStarLoc(SourceLocation Loc)
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
Record code for the set of source location entries that need to be preloaded by the AST reader...
Special internal key for declaration names. The hash table creates keys for comparison; we do not cre...
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)
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.
ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC, bool(*isKindWeWant)(Decl::Kind), SmallVectorImpl< Decl * > &Decls) override
Read all of the declarations lexically stored in a declaration context.
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...
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.
const uint32_t * CXXCtorInitializersOffsets
Offset of each C++ ctor initializer list within the bitstream, indexed by the C++ ctor initializer li...
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.
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. The SourceManager can decode this to get at the full include stack...
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)
const Type * getTypePtr() const
Record code for the language options table.
A record that stores the set of declarations that are visible from a given DeclContext.
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.
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.
Record code for the table of offsets to CXXBaseSpecifier sets.
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
Options for controlling the compiler diagnostics engine.
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...
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.
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). ...
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)
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. This is in source order.
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.
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
unsigned LocalNumDecls
The number of declarations in this AST file.
unsigned NumFileSortedDecls
The internal 'instancetype' typedef.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
void addDecl(NamedDecl *D)
unsigned getNumTypeArgs() const
Information about the contents of a DeclContext.
Describes the categories of an Objective-C class.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
const FileInfo & getFile() const
The AST block, which acts as a container around the full AST block.
RefQualifierKind
The kind of C++0x ref-qualifier associated with a function type, which determines whether a member fu...
Record code for the list of other AST files made available by this AST file but not actually used by ...
The __va_list_tag placeholder type.
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
void setLBracketLoc(SourceLocation Loc)
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
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.
FileID getMainFileID() const
Returns the FileID of the main source file.
bool isFileContext() const
const serialization::DeclID * FileSortedDecls
Array of file-level DeclIDs sorted by file.
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.
virtual IdentifierInfo * get(const char *NameStart, const char *NameEnd)
Retrieve the IdentifierInfo for the named identifier.
DeclarationName ReadDeclarationName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a declaration name.
HashTableTy::const_iterator iterator
unsigned ComputeHash(Selector Sel)
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.
const char * getName() const
void addArgument(const TemplateArgumentLoc &Loc)
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.
bool isLocalSourceLocation(SourceLocation Loc) const
Returns true if Loc did not come from a PCH/Module.
std::vector< std::string > MacroIncludes
The injected class name of a C++ class template or class template partial specialization. Used to record that a type was spelled with a bare identifier rather than as a template-id; the equivalent for non-templated classes is just RecordType.
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
void setLParenLoc(SourceLocation Loc)
void setTemplateKeywordLoc(SourceLocation Loc)
void setTypeArgsLAngleLoc(SourceLocation Loc)
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.
Record code for a decl replacement block.
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.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl. It will iterate at least once ...
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.
DeclContextInfosMap DeclContextInfos
Information about the lexical and visible declarations for each DeclContext.
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.
Record code for the module name.
Selector getObjCSelector() const
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.
llvm::BitstreamCursor DeclsCursor
QualType getCanonicalTemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs) const
not evaluated yet, for special member function
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.
SmallVector< uint64_t, 1 > RedeclarationChains
The redeclaration chains for declarations local to this module file.
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.
Record code for the array of unused file scoped decls.
A FunctionNoProtoType record.
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.
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
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.
void getInputFiles(ModuleFile &F, SmallVectorImpl< serialization::InputFile > &Files)
Return all input files for the given module file.
uint64_t ReadCXXCtorInitializersRef(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Read a CXXCtorInitializers ID from the given record and return its global bit offset.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
void visitModuleFile(StringRef Filename) override
This is called for each AST file loaded.
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
SourceManager & getSourceManager() const
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.
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()
void setHasExternalLexicalStorage(bool ES=true)
State whether this DeclContext has external storage for declarations lexically in this context...
bool isExtensionToken() const
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
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.
const TemplateArgument & getArg(unsigned Idx) const
All of the names in this module are visible.
SmallVector< Context, 8 > Contexts
void setNameLoc(SourceLocation Loc)
Encapsulates the data about a macro definition (e.g. its tokens).
OpenCL 2d image array type.
Decl * GetExternalDecl(uint32_t ID) override
Resolve a declaration ID into a declaration, potentially building a new declaration.
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
uint32_t getGeneration() const
Get the current generation of this AST source. This number is incremented each time the AST source la...
FunctionDecl * SourceTemplate
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.
C sigjmp_buf typedef type.
std::vector< Conflict > Conflicts
The list of conflicts.
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.
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
unsigned getNumArgs() const
Record code for declarations that Sema keeps references of.
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)
DeclContext * getRedeclContext()
PreprocessorRecordTypes
Record types used within a preprocessor block.
static bool isExtHandlingFromDiagsError(DiagnosticsEngine &Diags)
CanQualType BoundMemberTy
The block containing the submodule structure.
std::pair< int, unsigned > AllocateLoadedSLocEntries(unsigned NumSLocEntries, unsigned TotalSize)
Allocate a number of loaded SLocEntries, which will be actually loaded on demand from the external so...
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 uint32_t * CXXBaseSpecifiersOffsets
Offset of each C++ base specifier set within the bitstream, indexed by the C++ base specifier set ID ...
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...
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
const TemplateArgument & getArg(unsigned Idx) const
Retrieve a specific template argument as a type.
Represents a base class of a C++ class.
Cached information about one directory (either on disk or in the virtual file system).
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)
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Keeps track of options that affect how file operations are performed.
unsigned End
Raw source location of end of range.
bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID)
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. Length can be 0 to indicate a ...
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...
FileManager & getFileManager() const
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.
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
void ReadTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template argument array.
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
SmallVector< uint64_t, 8 > PragmaDiagMappings
Diagnostic IDs and their mappings that the user changed.
static internal_key_type GetInternalKey(const external_key_type &Name)
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.
CanQualType OCLImage1dArrayTy
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...
ASTIdentifierIterator(const ASTReader &Reader)
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.
static ModuleFile * getDefinitiveModuleFileFor(const DeclContext *DC, ASTReader &Reader)
Retrieve the "definitive" module file for the definition of the given declaration context...
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...
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Record code for the table of offsets to CXXCtorInitializers lists.
virtual void ReadModuleName(StringRef ModuleName)
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
The module file had already been loaded.
LineTableInfo & getLineTable()
Retrieve the stored line table.
Defines the clang::TargetInfo interface.
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.
Describes the redeclarations of a declaration.
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)
Kind
Lists the kind of concrete classes of Decl.
Specifies a required feature.
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
Record for offsets of DECL_UPDATES records for declarations that were modified after being deserializ...
internal_key_type ReadKey(const unsigned char *d, unsigned)
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()
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. Will be parsed at the end of the translation unit, used by Sema & Parser.
static const internal_key_type & GetInternalKey(const external_key_type &x)
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.
void StartTranslationUnit(ASTConsumer *Consumer) override
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
OpenCL 1d image array type.
void setLocation(SourceLocation L)
bool hadMacroDefinition() const
Returns true if this identifier was #defined to some value at any moment. In this case there should b...
uint32_t TypeID
An ID number that refers to a type in an AST file.
unsigned getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where in the...
Wrapper for source info for builtin types.
void setRParenLoc(SourceLocation Loc)
A set of overloaded template declarations.
Wrapper for template type parameters.
Module * Other
The module that this module conflicts with.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
std::string ModuleMapPath
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.
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. Must be paired with StartedD...
A function-like macro definition. [PP_MACRO_FUNCTION_LIKE, <ObjectLikeStuff>, IsC99Varargs, IsGNUVarars, NumArgs, ArgIdentInfoID* ].
bool isNull() const
isNull - 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
The control block, which contains all of the information that needs to be validated prior to committi...
Wrapper for source info for pointers.
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
Holds everything needed to generate debug info for an imported module or precompiled header file...
PredefinedDeclIDs
Predefined declaration IDs.
Record code for an update to the TU's lexically contained declarations.
void setElaboratedKeywordLoc(SourceLocation Loc)
Source range/offset of a preprocessed entity.
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.
unsigned LocalNumCXXCtorInitializers
The number of C++ ctor initializer lists in this AST file.
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.
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.
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
static bool isInterestingIdentifier(IdentifierInfo &II)
Whether the given identifier is "interesting".
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.