86 #include "llvm/ADT/APFloat.h" 87 #include "llvm/ADT/APInt.h" 88 #include "llvm/ADT/APSInt.h" 89 #include "llvm/ADT/ArrayRef.h" 90 #include "llvm/ADT/DenseMap.h" 91 #include "llvm/ADT/FoldingSet.h" 92 #include "llvm/ADT/Hashing.h" 93 #include "llvm/ADT/IntrusiveRefCntPtr.h" 94 #include "llvm/ADT/None.h" 95 #include "llvm/ADT/Optional.h" 96 #include "llvm/ADT/STLExtras.h" 97 #include "llvm/ADT/SmallPtrSet.h" 98 #include "llvm/ADT/SmallString.h" 99 #include "llvm/ADT/SmallVector.h" 100 #include "llvm/ADT/StringExtras.h" 101 #include "llvm/ADT/StringMap.h" 102 #include "llvm/ADT/StringRef.h" 103 #include "llvm/ADT/Triple.h" 104 #include "llvm/ADT/iterator_range.h" 105 #include "llvm/Bitcode/BitstreamReader.h" 106 #include "llvm/Support/Casting.h" 107 #include "llvm/Support/Compression.h" 108 #include "llvm/Support/Compiler.h" 109 #include "llvm/Support/Endian.h" 110 #include "llvm/Support/Error.h" 111 #include "llvm/Support/ErrorHandling.h" 112 #include "llvm/Support/FileSystem.h" 113 #include "llvm/Support/MemoryBuffer.h" 114 #include "llvm/Support/Path.h" 115 #include "llvm/Support/SaveAndRestore.h" 116 #include "llvm/Support/Timer.h" 117 #include "llvm/Support/raw_ostream.h" 129 #include <system_error> 134 using namespace clang;
137 using llvm::BitstreamCursor;
145 return First->ReadFullVersionInformation(FullVersion) ||
146 Second->ReadFullVersionInformation(FullVersion);
150 First->ReadModuleName(ModuleName);
151 Second->ReadModuleName(ModuleName);
155 First->ReadModuleMapFile(ModuleMapPath);
156 Second->ReadModuleMapFile(ModuleMapPath);
162 bool AllowCompatibleDifferences) {
163 return First->ReadLanguageOptions(LangOpts, Complain,
164 AllowCompatibleDifferences) ||
165 Second->ReadLanguageOptions(LangOpts, Complain,
166 AllowCompatibleDifferences);
171 bool AllowCompatibleDifferences) {
172 return First->ReadTargetOptions(TargetOpts, Complain,
173 AllowCompatibleDifferences) ||
174 Second->ReadTargetOptions(TargetOpts, Complain,
175 AllowCompatibleDifferences);
180 return First->ReadDiagnosticOptions(DiagOpts, Complain) ||
181 Second->ReadDiagnosticOptions(DiagOpts, Complain);
187 return First->ReadFileSystemOptions(FSOpts, Complain) ||
188 Second->ReadFileSystemOptions(FSOpts, Complain);
194 return First->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
196 Second->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
202 std::string &SuggestedPredefines) {
203 return First->ReadPreprocessorOptions(PPOpts, Complain,
204 SuggestedPredefines) ||
205 Second->ReadPreprocessorOptions(PPOpts, Complain, SuggestedPredefines);
210 First->ReadCounter(M, Value);
211 Second->ReadCounter(M, Value);
215 return First->needsInputFileVisitation() ||
216 Second->needsInputFileVisitation();
220 return First->needsSystemInputFileVisitation() ||
221 Second->needsSystemInputFileVisitation();
226 First->visitModuleFile(Filename, Kind);
227 Second->visitModuleFile(Filename, Kind);
233 bool isExplicitModule) {
234 bool Continue =
false;
235 if (First->needsInputFileVisitation() &&
236 (!isSystem || First->needsSystemInputFileVisitation()))
237 Continue |= First->visitInputFile(Filename, isSystem, isOverridden,
239 if (Second->needsInputFileVisitation() &&
240 (!isSystem || Second->needsSystemInputFileVisitation()))
241 Continue |= Second->visitInputFile(Filename, isSystem, isOverridden,
248 First->readModuleFileExtension(Metadata);
249 Second->readModuleFileExtension(Metadata);
269 bool AllowCompatibleDifferences =
true) {
270 #define LANGOPT(Name, Bits, Default, Description) \ 271 if (ExistingLangOpts.Name != LangOpts.Name) { \ 273 Diags->Report(diag::err_pch_langopt_mismatch) \ 274 << Description << LangOpts.Name << ExistingLangOpts.Name; \ 278 #define VALUE_LANGOPT(Name, Bits, Default, Description) \ 279 if (ExistingLangOpts.Name != LangOpts.Name) { \ 281 Diags->Report(diag::err_pch_langopt_value_mismatch) \ 286 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 287 if (ExistingLangOpts.get##Name() != LangOpts.get##Name()) { \ 289 Diags->Report(diag::err_pch_langopt_value_mismatch) \ 294 #define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \ 295 if (!AllowCompatibleDifferences) \ 296 LANGOPT(Name, Bits, Default, Description) 298 #define COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) \ 299 if (!AllowCompatibleDifferences) \ 300 ENUM_LANGOPT(Name, Bits, Default, Description) 302 #define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \ 303 if (!AllowCompatibleDifferences) \ 304 VALUE_LANGOPT(Name, Bits, Default, Description) 306 #define BENIGN_LANGOPT(Name, Bits, Default, Description) 307 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) 308 #define BENIGN_VALUE_LANGOPT(Name, Type, Bits, Default, Description) 309 #include "clang/Basic/LangOptions.def" 313 Diags->
Report(diag::err_pch_langopt_value_mismatch) <<
"module features";
319 Diags->
Report(diag::err_pch_langopt_value_mismatch)
320 <<
"target Objective-C runtime";
327 Diags->
Report(diag::err_pch_langopt_value_mismatch)
328 <<
"block command names";
336 if (!AllowCompatibleDifferences) {
340 ExistingSanitizers.
clear(ModularSanitizers);
341 ImportedSanitizers.
clear(ModularSanitizers);
342 if (ExistingSanitizers.
Mask != ImportedSanitizers.
Mask) {
343 const std::string Flag =
"-fsanitize=";
345 #define SANITIZER(NAME, ID) \ 347 bool InExistingModule = ExistingSanitizers.has(SanitizerKind::ID); \ 348 bool InImportedModule = ImportedSanitizers.has(SanitizerKind::ID); \ 349 if (InExistingModule != InImportedModule) \ 350 Diags->Report(diag::err_pch_targetopt_feature_mismatch) \ 351 << InExistingModule << (Flag + NAME); \ 353 #include "clang/Basic/Sanitizers.def" 371 bool AllowCompatibleDifferences =
true) {
372 #define CHECK_TARGET_OPT(Field, Name) \ 373 if (TargetOpts.Field != ExistingTargetOpts.Field) { \ 375 Diags->Report(diag::err_pch_targetopt_mismatch) \ 376 << Name << TargetOpts.Field << ExistingTargetOpts.Field; \ 387 if (!AllowCompatibleDifferences)
390 #undef CHECK_TARGET_OPT 398 std::sort(ExistingFeatures.begin(), ExistingFeatures.end());
399 std::sort(ReadFeatures.begin(), ReadFeatures.end());
405 ExistingFeatures.begin(), ExistingFeatures.end(), ReadFeatures.begin(),
406 ReadFeatures.end(), std::back_inserter(UnmatchedExistingFeatures));
407 std::set_difference(ReadFeatures.begin(), ReadFeatures.end(),
408 ExistingFeatures.begin(), ExistingFeatures.end(),
409 std::back_inserter(UnmatchedReadFeatures));
413 if (AllowCompatibleDifferences && UnmatchedReadFeatures.empty())
417 for (StringRef Feature : UnmatchedReadFeatures)
418 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
420 for (StringRef Feature : UnmatchedExistingFeatures)
421 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
425 return !UnmatchedReadFeatures.empty() || !UnmatchedExistingFeatures.empty();
431 bool AllowCompatibleDifferences) {
432 const LangOptions &ExistingLangOpts = PP.getLangOpts();
434 Complain ? &Reader.Diags :
nullptr,
435 AllowCompatibleDifferences);
440 bool AllowCompatibleDifferences) {
441 const TargetOptions &ExistingTargetOpts = PP.getTargetInfo().getTargetOpts();
443 Complain ? &Reader.Diags :
nullptr,
444 AllowCompatibleDifferences);
449 using MacroDefinitionsMap =
450 llvm::StringMap<std::pair<StringRef,
bool >>;
451 using DeclsMap = llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8>>;
466 for (
auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) {
475 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror=" +
494 bool IsSystem,
bool Complain) {
502 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Wsystem-headers";
509 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror";
516 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Weverything -Werror";
523 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-pedantic-errors";
547 assert(!ModuleName.empty() &&
"diagnostic options read before module name");
550 assert(M &&
"missing module");
565 assert(ModuleMgr.
size() >= 1 &&
"what ASTFile is this then");
581 MacroDefinitionsMap &Macros,
583 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
584 StringRef Macro = PPOpts.
Macros[I].first;
585 bool IsUndef = PPOpts.
Macros[I].second;
587 std::pair<StringRef, StringRef> MacroPair = Macro.split(
'=');
588 StringRef MacroName = MacroPair.first;
589 StringRef MacroBody = MacroPair.second;
593 if (MacroNames && !Macros.count(MacroName))
594 MacroNames->push_back(MacroName);
596 Macros[MacroName] = std::make_pair(
"",
true);
601 if (MacroName.size() == Macro.size())
605 StringRef::size_type
End = MacroBody.find_first_of(
"\n\r");
606 MacroBody = MacroBody.substr(0, End);
609 if (MacroNames && !Macros.count(MacroName))
610 MacroNames->push_back(MacroName);
611 Macros[MacroName] = std::make_pair(MacroBody,
false);
626 std::string &SuggestedPredefines,
628 bool Validate =
true) {
630 MacroDefinitionsMap ASTFileMacros;
632 MacroDefinitionsMap ExistingMacros;
636 for (
unsigned I = 0, N = ExistingMacroNames.size(); I != N; ++I) {
638 StringRef MacroName = ExistingMacroNames[I];
639 std::pair<StringRef, bool> Existing = ExistingMacros[MacroName];
642 llvm::StringMap<std::pair<StringRef,
bool >>::iterator Known =
643 ASTFileMacros.find(MacroName);
644 if (!Validate || Known == ASTFileMacros.end()) {
649 if (Existing.second) {
650 SuggestedPredefines +=
"#undef ";
651 SuggestedPredefines += MacroName.str();
652 SuggestedPredefines +=
'\n';
654 SuggestedPredefines +=
"#define ";
655 SuggestedPredefines += MacroName.str();
656 SuggestedPredefines +=
' ';
657 SuggestedPredefines += Existing.first.str();
658 SuggestedPredefines +=
'\n';
665 if (Existing.second != Known->second.second) {
667 Diags->
Report(diag::err_pch_macro_def_undef)
668 << MacroName << Known->second.second;
675 if (Existing.second || Existing.first == Known->second.first)
680 Diags->
Report(diag::err_pch_macro_def_conflict)
681 << MacroName << Known->second.first << Existing.first;
695 if (LangOpts.Modules &&
704 for (
unsigned I = 0, N = ExistingPPOpts.
Includes.size(); I != N; ++I) {
705 StringRef File = ExistingPPOpts.
Includes[I];
713 SuggestedPredefines +=
"#include \"";
714 SuggestedPredefines += File;
715 SuggestedPredefines +=
"\"\n";
718 for (
unsigned I = 0, N = ExistingPPOpts.
MacroIncludes.size(); I != N; ++I) {
725 SuggestedPredefines +=
"#__include_macros \"";
726 SuggestedPredefines += File;
727 SuggestedPredefines +=
"\"\n##\n";
735 std::string &SuggestedPredefines) {
739 Complain? &Reader.Diags :
nullptr,
748 std::string &SuggestedPredefines) {
750 PP.getPreprocessorOpts(),
763 StringRef SpecificModuleCachePath,
764 StringRef ExistingModuleCachePath,
767 if (LangOpts.Modules) {
768 if (SpecificModuleCachePath != ExistingModuleCachePath) {
770 Diags->
Report(diag::err_pch_modulecache_mismatch)
771 << SpecificModuleCachePath << ExistingModuleCachePath;
780 StringRef SpecificModuleCachePath,
783 PP.getHeaderSearchInfo().getModuleCachePath(),
784 Complain ? &Reader.Diags :
nullptr,
789 PP.setCounterValue(Value);
797 bool TakeOwnership) {
798 DeserializationListener = Listener;
799 OwnsDeserializationListener = TakeOwnership;
806 std::pair<unsigned, unsigned>
808 using namespace llvm::support;
810 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
811 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
812 return std::make_pair(KeyLen, DataLen);
817 using namespace llvm::support;
820 unsigned N = endian::readNext<uint16_t, little, unaligned>(d);
822 F, endian::readNext<uint32_t, little, unaligned>(d));
829 Args.push_back(FirstII);
830 for (
unsigned I = 1; I != N; ++I)
831 Args.push_back(Reader.getLocalIdentifier(
832 F, endian::readNext<uint32_t, little, unaligned>(d)));
840 using namespace llvm::support;
844 Result.
ID = Reader.getGlobalSelectorID(
845 F, endian::readNext<uint32_t, little, unaligned>(d));
846 unsigned FullInstanceBits = endian::readNext<uint16_t, little, unaligned>(d);
847 unsigned FullFactoryBits = endian::readNext<uint16_t, little, unaligned>(d);
852 unsigned NumInstanceMethods = FullInstanceBits >> 3;
853 unsigned NumFactoryMethods = FullFactoryBits >> 3;
856 for (
unsigned I = 0; I != NumInstanceMethods; ++I) {
858 F, endian::readNext<uint32_t, little, unaligned>(d)))
863 for (
unsigned I = 0; I != NumFactoryMethods; ++I) {
865 F, endian::readNext<uint32_t, little, unaligned>(d)))
866 Result.
Factory.push_back(Method);
873 return llvm::HashString(a);
876 std::pair<unsigned, unsigned>
878 using namespace llvm::support;
880 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
881 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
882 return std::make_pair(KeyLen, DataLen);
887 assert(n >= 2 && d[n-1] ==
'\0');
888 return StringRef((
const char*) d, n-1);
903 bool Value = Bits & 0x1;
909 using namespace llvm::support;
911 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
912 return Reader.getGlobalIdentifierID(F, RawID >> 1);
925 const unsigned char* d,
927 using namespace llvm::support;
929 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
930 bool IsInteresting = RawID & 0x01;
938 II = &Reader.getIdentifierTable().getOwn(k);
942 Reader.markIdentifierUpToDate(II);
944 IdentID ID = Reader.getGlobalIdentifierID(F, RawID);
945 if (!IsInteresting) {
948 Reader.SetIdentifierInfo(ID, II);
952 unsigned ObjCOrBuiltinID = endian::readNext<uint16_t, little, unaligned>(d);
953 unsigned Bits = endian::readNext<uint16_t, little, unaligned>(d);
954 bool CPlusPlusOperatorKeyword =
readBit(Bits);
955 bool HasRevertedTokenIDToIdentifier =
readBit(Bits);
956 bool HasRevertedBuiltin =
readBit(Bits);
958 bool ExtensionToken =
readBit(Bits);
959 bool HadMacroDefinition =
readBit(Bits);
961 assert(Bits == 0 &&
"Extra bits in the identifier?");
966 if (HasRevertedTokenIDToIdentifier && II->
getTokenID() != tok::identifier)
974 "Incorrect ObjC keyword or builtin ID");
977 "Incorrect extension token flag");
978 (void)ExtensionToken;
982 "Incorrect C++ operator keyword flag");
983 (void)CPlusPlusOperatorKeyword;
987 if (HadMacroDefinition) {
988 uint32_t MacroDirectivesOffset =
989 endian::readNext<uint32_t, little, unaligned>(d);
992 Reader.addPendingMacro(II, &F, MacroDirectivesOffset);
995 Reader.SetIdentifierInfo(ID, II);
1001 for (; DataLen > 0; DataLen -= 4)
1002 DeclIDs.push_back(Reader.getGlobalDeclID(
1003 F, endian::readNext<uint32_t, little, unaligned>(d)));
1004 Reader.SetGloballyVisibleDecls(II, DeclIDs);
1011 :
Kind(Name.getNameKind()) {
1041 llvm::FoldingSetNodeID
ID;
1042 ID.AddInteger(
Kind);
1065 return ID.ComputeHash();
1069 ASTDeclContextNameLookupTrait::ReadFileRef(
const unsigned char *&d) {
1070 using namespace llvm::support;
1072 uint32_t ModuleFileID = endian::readNext<uint32_t, little, unaligned>(d);
1073 return Reader.getLocalModuleFile(F, ModuleFileID);
1076 std::pair<unsigned, unsigned>
1077 ASTDeclContextNameLookupTrait::ReadKeyDataLength(
const unsigned char *&d) {
1078 using namespace llvm::support;
1080 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
1081 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
1082 return std::make_pair(KeyLen, DataLen);
1086 ASTDeclContextNameLookupTrait::ReadKey(
const unsigned char *d,
unsigned) {
1087 using namespace llvm::support;
1095 Data = (uint64_t)Reader.getLocalIdentifier(
1096 F, endian::readNext<uint32_t, little, unaligned>(d));
1102 (uint64_t)Reader.getLocalSelector(
1103 F, endian::readNext<uint32_t, little, unaligned>(
1104 d)).getAsOpaquePtr();
1121 const unsigned char *d,
1124 using namespace llvm::support;
1126 for (
unsigned NumDecls = DataLen / 4; NumDecls; --NumDecls) {
1127 uint32_t LocalID = endian::readNext<uint32_t, little, unaligned>(d);
1128 Val.
insert(Reader.getGlobalDeclID(F, LocalID));
1132 bool ASTReader::ReadLexicalDeclContextStorage(
ModuleFile &M,
1143 unsigned Code =
Cursor.ReadCode();
1144 unsigned RecCode =
Cursor.readRecord(Code, Record, &Blob);
1146 Error(
"Expected lexical block");
1150 assert(!isa<TranslationUnitDecl>(DC) &&
1151 "expected a TU_UPDATE_LEXICAL record for TU");
1156 auto &Lex = LexicalDecls[DC];
1158 Lex = std::make_pair(
1159 &M, llvm::makeArrayRef(
1160 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
1168 bool ASTReader::ReadVisibleDeclContextStorage(
ModuleFile &M,
1179 unsigned Code =
Cursor.ReadCode();
1180 unsigned RecCode =
Cursor.readRecord(Code, Record, &Blob);
1182 Error(
"Expected visible lookup table block");
1188 auto *Data = (
const unsigned char*)Blob.data();
1189 PendingVisibleUpdates[
ID].push_back(PendingVisibleUpdate{&M, Data});
1193 void ASTReader::Error(StringRef Msg)
const {
1194 Error(diag::err_fe_pch_malformed, Msg);
1195 if (PP.getLangOpts().Modules && !Diags.isDiagnosticInFlight() &&
1196 !PP.getHeaderSearchInfo().getModuleCachePath().empty()) {
1197 Diag(diag::note_module_cache_path)
1198 << PP.getHeaderSearchInfo().getModuleCachePath();
1202 void ASTReader::Error(
unsigned DiagID,
1203 StringRef Arg1, StringRef Arg2)
const {
1204 if (Diags.isDiagnosticInFlight())
1205 Diags.SetDelayedDiagnostic(DiagID, Arg1, Arg2);
1207 Diag(DiagID) << Arg1 << Arg2;
1216 bool ASTReader::ParseLineTable(
ModuleFile &F,
1217 const RecordData &Record) {
1222 std::map<int, int> FileIDs;
1224 for (
unsigned I = 0; Record[Idx]; ++I) {
1226 auto Filename = ReadPath(F, Record, Idx);
1232 std::vector<LineEntry> Entries;
1233 while (Idx < Record.size()) {
1234 int FID = Record[Idx++];
1235 assert(FID >= 0 &&
"Serialized line entries for non-local file.");
1240 unsigned NumEntries = Record[Idx++];
1241 assert(NumEntries &&
"no line entries for file ID");
1243 Entries.reserve(NumEntries);
1244 for (
unsigned I = 0; I != NumEntries; ++I) {
1245 unsigned FileOffset = Record[Idx++];
1246 unsigned LineNo = Record[Idx++];
1247 int FilenameID = FileIDs[Record[Idx++]];
1250 unsigned IncludeOffset = Record[Idx++];
1252 FileKind, IncludeOffset));
1254 LineTable.
AddEntry(FileID::get(FID), Entries);
1261 bool ASTReader::ReadSourceManagerBlock(
ModuleFile &F) {
1262 using namespace SrcMgr;
1270 SLocEntryCursor = F.
Stream;
1273 if (F.
Stream.SkipBlock()) {
1274 Error(
"malformed block record in AST file");
1280 Error(
"malformed source manager block record in AST file");
1286 llvm::BitstreamEntry E = SLocEntryCursor.advanceSkippingSubblocks();
1289 case llvm::BitstreamEntry::SubBlock:
1291 Error(
"malformed block record in AST file");
1293 case llvm::BitstreamEntry::EndBlock:
1295 case llvm::BitstreamEntry::Record:
1303 switch (SLocEntryCursor.readRecord(E.ID, Record, &Blob)) {
1322 const std::string &OriginalDir,
1323 const std::string &CurrDir) {
1324 assert(OriginalDir != CurrDir &&
1325 "No point trying to resolve the file if the PCH dir didn't change");
1330 fs::make_absolute(filePath);
1331 assert(path::is_absolute(OriginalDir));
1334 path::const_iterator fileDirI = path::begin(path::parent_path(filePath)),
1335 fileDirE = path::end(path::parent_path(filePath));
1336 path::const_iterator origDirI = path::begin(OriginalDir),
1337 origDirE = path::end(OriginalDir);
1339 while (fileDirI != fileDirE && origDirI != origDirE &&
1340 *fileDirI == *origDirI) {
1344 for (; origDirI != origDirE; ++origDirI)
1345 path::append(currPCHPath,
"..");
1346 path::append(currPCHPath, fileDirI, fileDirE);
1347 path::append(currPCHPath, path::filename(Filename));
1348 return currPCHPath.str();
1355 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1356 Error(
"source location entry ID out-of-range for AST file");
1362 auto ReadBuffer = [
this](
1363 BitstreamCursor &SLocEntryCursor,
1364 StringRef Name) -> std::unique_ptr<llvm::MemoryBuffer> {
1367 unsigned Code = SLocEntryCursor.ReadCode();
1368 unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, &Blob);
1371 if (!llvm::zlib::isAvailable()) {
1372 Error(
"zlib is not available");
1377 llvm::zlib::uncompress(Blob, Uncompressed, Record[0])) {
1378 Error(
"could not decompress embedded file contents: " +
1382 return llvm::MemoryBuffer::getMemBufferCopy(Uncompressed, Name);
1384 return llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name,
true);
1386 Error(
"AST record has invalid code");
1391 ModuleFile *F = GlobalSLocEntryMap.find(-ID)->second;
1396 ++NumSLocEntriesRead;
1397 llvm::BitstreamEntry Entry = SLocEntryCursor.advance();
1398 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1399 Error(
"incorrectly-formatted source location entry in AST file");
1405 switch (SLocEntryCursor.readRecord(Entry.ID, Record, &Blob)) {
1407 Error(
"incorrectly-formatted source location entry in AST file");
1413 unsigned InputID = Record[4];
1414 InputFile IF = getInputFile(*F, InputID);
1427 IncludeLoc = getImportLocation(F);
1431 FileID FID = SourceMgr.createFileID(File, IncludeLoc, FileCharacter,
1432 ID, BaseOffset + Record[0]);
1435 FileInfo.NumCreatedFIDs = Record[5];
1440 unsigned NumFileDecls = Record[7];
1441 if (NumFileDecls && ContextObj) {
1442 assert(F->
FileSortedDecls &&
"FILE_SORTED_DECLS not encountered yet ?");
1443 FileDeclIDs[FID] = FileDeclsInfo(F, llvm::makeArrayRef(FirstDecl,
1448 = SourceMgr.getOrCreateContentCache(File,
isSystem(FileCharacter));
1452 auto Buffer = ReadBuffer(SLocEntryCursor, File->
getName());
1455 SourceMgr.overrideFileContents(File, std::move(Buffer));
1462 const char *Name = Blob.data();
1463 unsigned Offset = Record[0];
1468 IncludeLoc = getImportLocation(F);
1471 auto Buffer = ReadBuffer(SLocEntryCursor, Name);
1474 SourceMgr.createFileID(std::move(Buffer), FileCharacter, ID,
1475 BaseOffset + Offset, IncludeLoc);
1481 SourceMgr.createExpansionLoc(SpellingLoc,
1482 ReadSourceLocation(*F, Record[2]),
1483 ReadSourceLocation(*F, Record[3]),
1486 BaseOffset + Record[0]);
1498 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1499 Error(
"source location entry ID out-of-range for AST file");
1504 ModuleFile *M = GlobalSLocEntryMap.find(-ID)->second;
1522 assert(SourceMgr.getMainFileID().isValid() &&
"missing main file");
1523 return SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
1532 if (Cursor.EnterSubBlock(BlockID))
1536 uint64_t
Offset = Cursor.GetCurrentBitNo();
1537 unsigned Code = Cursor.ReadCode();
1540 if (Code != llvm::bitc::DEFINE_ABBREV) {
1541 Cursor.JumpToBit(Offset);
1544 Cursor.ReadAbbrevRecord();
1552 Tok.
setLocation(ReadSourceLocation(F, Record, Idx));
1568 Stream.JumpToBit(Offset);
1577 unsigned Flags = BitstreamCursor::AF_DontPopBlockAtEnd;
1578 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks(Flags);
1580 switch (Entry.Kind) {
1581 case llvm::BitstreamEntry::SubBlock:
1583 Error(
"malformed block record in AST file");
1585 case llvm::BitstreamEntry::EndBlock:
1587 case llvm::BitstreamEntry::Record:
1609 unsigned NextIndex = 1;
1611 MacroInfo *MI = PP.AllocateMacroInfo(Loc);
1618 bool isC99VarArgs = Record[NextIndex++];
1619 bool isGNUVarArgs = Record[NextIndex++];
1620 bool hasCommaPasting = Record[NextIndex++];
1621 MacroParams.clear();
1622 unsigned NumArgs = Record[NextIndex++];
1623 for (
unsigned i = 0; i != NumArgs; ++i)
1624 MacroParams.push_back(getLocalIdentifier(F, Record[NextIndex++]));
1638 if (NextIndex + 1 == Record.size() && PP.getPreprocessingRecord() &&
1639 Record[NextIndex]) {
1642 GlobalID = getGlobalPreprocessedEntityID(F, Record[NextIndex]);
1644 PreprocessingRecord::PPEntityID PPID =
1645 PPRec.getPPEntityID(GlobalID - 1,
true);
1647 PPRec.getPreprocessedEntity(PPID));
1649 PPRec.RegisterMacroDefinition(Macro, PPDef);
1662 Token Tok = ReadToken(F, Record, Idx);
1672 unsigned LocalID)
const {
1674 ReadModuleOffsetMap(M);
1679 &&
"Invalid index into preprocessed entity index remap");
1681 return LocalID + I->second;
1707 return FileMgr.
getFile(Key.Filename);
1709 std::string Resolved = Key.Filename;
1710 Reader.ResolveImportedPath(M, Resolved);
1711 return FileMgr.
getFile(Resolved);
1716 return FEA && FEA == FEB;
1719 std::pair<unsigned, unsigned>
1720 HeaderFileInfoTrait::ReadKeyDataLength(
const unsigned char*& d) {
1721 using namespace llvm::support;
1723 unsigned KeyLen = (unsigned) endian::readNext<uint16_t, little, unaligned>(d);
1724 unsigned DataLen = (unsigned) *d++;
1725 return std::make_pair(KeyLen, DataLen);
1729 HeaderFileInfoTrait::ReadKey(
const unsigned char *d,
unsigned) {
1730 using namespace llvm::support;
1733 ikey.
Size = off_t(endian::readNext<uint64_t, little, unaligned>(d));
1734 ikey.
ModTime = time_t(endian::readNext<uint64_t, little, unaligned>(d));
1743 using namespace llvm::support;
1745 const unsigned char *
End = d + DataLen;
1747 unsigned Flags = *d++;
1749 HFI.
isImport |= (Flags >> 5) & 0x01;
1751 HFI.
DirInfo = (Flags >> 1) & 0x07;
1758 M, endian::readNext<uint32_t, little, unaligned>(d));
1759 if (
unsigned FrameworkOffset =
1760 endian::readNext<uint32_t, little, unaligned>(d)) {
1763 StringRef FrameworkName(FrameworkStrings + FrameworkOffset - 1);
1764 HFI.
Framework = HS->getUniqueFrameworkName(FrameworkName);
1767 assert((End - d) % 4 == 0 &&
1768 "Wrong data length in HeaderFileInfo deserialization");
1770 uint32_t LocalSMID = endian::readNext<uint32_t, little, unaligned>(d);
1776 SubmoduleID GlobalSMID = Reader.getGlobalSubmoduleID(M, LocalSMID);
1777 Module *Mod = Reader.getSubmodule(GlobalSMID);
1780 Reader.getPreprocessor().getHeaderSearchInfo().getModuleMap();
1784 Reader.ResolveImportedPath(M, Filename);
1789 ModMap.
addHeader(Mod, H, HeaderRole,
true);
1801 uint64_t MacroDirectivesOffset) {
1802 assert(NumCurrentElementsDeserializing > 0 &&
"Missing deserialization guard");
1803 PendingMacroIDs[II].push_back(PendingMacroInfo(M, MacroDirectivesOffset));
1810 for (
ModuleFile &I : llvm::reverse(ModuleMgr)) {
1811 BitstreamCursor &MacroCursor = I.MacroCursor;
1814 if (MacroCursor.getBitcodeBytes().empty())
1817 BitstreamCursor
Cursor = MacroCursor;
1818 Cursor.JumpToBit(I.MacroStartOffset);
1822 llvm::BitstreamEntry E = Cursor.advanceSkippingSubblocks();
1825 case llvm::BitstreamEntry::SubBlock:
1827 Error(
"malformed block record in AST file");
1829 case llvm::BitstreamEntry::EndBlock:
1832 case llvm::BitstreamEntry::Record:
1834 switch (Cursor.readRecord(E.ID, Record)) {
1842 updateOutOfDateIdentifier(*II);
1860 class IdentifierLookupVisitor {
1863 unsigned PriorGeneration;
1864 unsigned &NumIdentifierLookups;
1865 unsigned &NumIdentifierLookupHits;
1869 IdentifierLookupVisitor(StringRef Name,
unsigned PriorGeneration,
1870 unsigned &NumIdentifierLookups,
1871 unsigned &NumIdentifierLookupHits)
1873 PriorGeneration(PriorGeneration),
1874 NumIdentifierLookups(NumIdentifierLookups),
1875 NumIdentifierLookupHits(NumIdentifierLookupHits) {}
1889 ++NumIdentifierLookups;
1890 ASTIdentifierLookupTable::iterator Pos =
1891 IdTable->find_hashed(Name, NameHash, &Trait);
1892 if (Pos == IdTable->end())
1898 ++NumIdentifierLookupHits;
1914 unsigned PriorGeneration = 0;
1915 if (getContext().getLangOpts().Modules)
1916 PriorGeneration = IdentifierGeneration[&II];
1922 if (!loadGlobalIndex()) {
1923 if (GlobalIndex->lookupIdentifier(II.
getName(), Hits)) {
1928 IdentifierLookupVisitor Visitor(II.
getName(), PriorGeneration,
1929 NumIdentifierLookups,
1930 NumIdentifierLookupHits);
1931 ModuleMgr.visit(Visitor, HitsPtr);
1932 markIdentifierUpToDate(&II);
1942 if (getContext().getLangOpts().Modules)
1943 IdentifierGeneration[II] = getGeneration();
1947 const PendingMacroInfo &PMInfo) {
1952 Cursor.JumpToBit(PMInfo.MacroDirectivesOffset);
1954 struct ModuleMacroRecord {
1966 llvm::BitstreamEntry Entry =
1967 Cursor.advance(BitstreamCursor::AF_DontPopBlockAtEnd);
1968 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1969 Error(
"malformed block record in AST file");
1979 ModuleMacros.push_back(ModuleMacroRecord());
1980 auto &Info = ModuleMacros.back();
1981 Info.SubModID = getGlobalSubmoduleID(M, Record[0]);
1982 Info.MI = getMacro(getGlobalMacroID(M, Record[1]));
1983 for (
int I = 2, N = Record.size(); I != N; ++I)
1984 Info.Overrides.push_back(getGlobalSubmoduleID(M, Record[I]));
1989 Error(
"malformed block record in AST file");
2000 std::reverse(ModuleMacros.begin(), ModuleMacros.end());
2002 for (
auto &MMR : ModuleMacros) {
2004 for (
unsigned ModID : MMR.Overrides) {
2005 Module *Mod = getSubmodule(ModID);
2006 auto *Macro = PP.getModuleMacro(Mod, II);
2007 assert(Macro &&
"missing definition for overridden macro");
2008 Overrides.push_back(Macro);
2011 bool Inserted =
false;
2012 Module *Owner = getSubmodule(MMR.SubModID);
2013 PP.addModuleMacro(Owner, II, MMR.MI, Overrides, Inserted);
2024 unsigned Idx = 0, N = Record.size();
2031 MacroInfo *MI = getMacro(getGlobalMacroID(M, Record[Idx++]));
2032 MD = PP.AllocateDefMacroDirective(MI, Loc);
2036 MD = PP.AllocateUndefMacroDirective(Loc);
2039 bool isPublic = Record[Idx++];
2040 MD = PP.AllocateVisibilityMacroDirective(Loc, isPublic);
2052 PP.setLoadedMacroDirective(II, Earliest, Latest);
2055 ASTReader::InputFileInfo
2056 ASTReader::readInputFileInfo(
ModuleFile &F,
unsigned ID) {
2062 unsigned Code = Cursor.ReadCode();
2066 unsigned Result = Cursor.readRecord(Code, Record, &Blob);
2067 assert(static_cast<InputFileRecordTypes>(Result) ==
INPUT_FILE &&
2068 "invalid record type for input file");
2071 assert(Record[0] == ID &&
"Bogus stored ID or offset");
2073 R.StoredSize =
static_cast<off_t
>(Record[1]);
2074 R.StoredTime =
static_cast<time_t
>(Record[2]);
2075 R.Overridden =
static_cast<bool>(Record[3]);
2076 R.Transient =
static_cast<bool>(Record[4]);
2077 R.TopLevelModuleMap =
static_cast<bool>(Record[5]);
2079 ResolveImportedPath(F, R.Filename);
2101 InputFileInfo FI = readInputFileInfo(F,
ID);
2102 off_t StoredSize = FI.StoredSize;
2103 time_t StoredTime = FI.StoredTime;
2104 bool Overridden = FI.Overridden;
2105 bool Transient = FI.Transient;
2108 const FileEntry *File = FileMgr.getFile(Filename,
false);
2115 if (!Resolved.empty())
2116 File = FileMgr.getFile(Resolved);
2121 if ((Overridden || Transient) && File ==
nullptr)
2122 File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime);
2124 if (File ==
nullptr) {
2126 std::string ErrorStr =
"could not find file '";
2128 ErrorStr +=
"' referenced by AST file '";
2146 Error(diag::err_fe_pch_file_overridden, Filename);
2158 FileMgr.modifyFileEntry(const_cast<FileEntry*>(File),
2159 StoredSize, StoredTime);
2162 bool IsOutOfDate =
false;
2166 (StoredSize != File->
getSize() ||
2173 while (!ImportStack.back()->ImportedBy.empty())
2174 ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
2177 StringRef TopLevelPCHName(ImportStack.back()->FileName);
2179 if (DiagnosticKind == 0)
2180 Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
2181 else if (DiagnosticKind == 1)
2182 Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName);
2184 Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName);
2187 if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
2188 Diag(diag::note_pch_required_by)
2189 << Filename << ImportStack[0]->FileName;
2190 for (
unsigned I = 1; I < ImportStack.size(); ++I)
2191 Diag(diag::note_pch_required_by)
2192 << ImportStack[I-1]->FileName << ImportStack[I]->FileName;
2195 if (!Diags.isDiagnosticInFlight())
2196 Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
2221 if (Filename.empty() || llvm::sys::path::is_absolute(Filename))
2225 llvm::sys::path::append(Buffer, Prefix, Filename);
2226 Filename.assign(Buffer.begin(), Buffer.end());
2241 llvm_unreachable(
"unknown ASTReadResult");
2245 BitstreamCursor &Stream,
unsigned ClientLoadCapabilities,
2247 std::string &SuggestedPredefines) {
2253 ASTReadResult Result = Success;
2255 llvm::BitstreamEntry Entry = Stream.advance();
2257 switch (Entry.Kind) {
2259 case llvm::BitstreamEntry::SubBlock:
2262 case llvm::BitstreamEntry::EndBlock:
2265 case llvm::BitstreamEntry::Record:
2274 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2275 if (ParseLanguageOptions(Record, Complain, Listener,
2276 AllowCompatibleConfigurationMismatch))
2277 Result = ConfigurationMismatch;
2282 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2283 if (ParseTargetOptions(Record, Complain, Listener,
2284 AllowCompatibleConfigurationMismatch))
2285 Result = ConfigurationMismatch;
2290 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2291 if (!AllowCompatibleConfigurationMismatch &&
2292 ParseFileSystemOptions(Record, Complain, Listener))
2293 Result = ConfigurationMismatch;
2298 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2299 if (!AllowCompatibleConfigurationMismatch &&
2300 ParseHeaderSearchOptions(Record, Complain, Listener))
2301 Result = ConfigurationMismatch;
2306 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2307 if (!AllowCompatibleConfigurationMismatch &&
2308 ParsePreprocessorOptions(Record, Complain, Listener,
2309 SuggestedPredefines))
2310 Result = ConfigurationMismatch;
2320 unsigned ClientLoadCapabilities) {
2321 BitstreamCursor &Stream = F.
Stream;
2322 ASTReadResult Result = Success;
2325 Error(
"malformed block record in AST file");
2335 bool HasReadUnhashedControlBlock =
false;
2336 auto readUnhashedControlBlockOnce = [&]() {
2337 if (!HasReadUnhashedControlBlock) {
2338 HasReadUnhashedControlBlock =
true;
2339 if (ASTReadResult Result =
2340 readUnhashedControlBlock(F, ImportedBy, ClientLoadCapabilities))
2348 unsigned NumInputs = 0;
2349 unsigned NumUserInputs = 0;
2351 llvm::BitstreamEntry Entry = Stream.advance();
2353 switch (Entry.Kind) {
2355 Error(
"malformed block record in AST file");
2357 case llvm::BitstreamEntry::EndBlock: {
2360 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2365 PP.getHeaderSearchInfo().getHeaderSearchOpts();
2372 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
2378 unsigned N = NumUserInputs;
2379 if (ValidateSystemInputs ||
2385 for (
unsigned I = 0; I < N; ++I) {
2386 InputFile IF = getInputFile(F, I+1, Complain);
2398 for (
unsigned I = 0; I < N; ++I) {
2399 bool IsSystem = I >= NumUserInputs;
2400 InputFileInfo FI = readInputFileInfo(F, I+1);
2410 case llvm::BitstreamEntry::SubBlock:
2414 if (Stream.SkipBlock() ||
2417 Error(
"malformed block record in AST file");
2426 if (Listener && !ImportedBy) {
2432 bool AllowCompatibleConfigurationMismatch =
2435 Result = ReadOptionsBlock(Stream, ClientLoadCapabilities,
2436 AllowCompatibleConfigurationMismatch,
2437 *Listener, SuggestedPredefines);
2438 if (Result == Failure) {
2439 Error(
"malformed block record in AST file");
2443 if (DisableValidation ||
2444 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
2450 if (Result != Success)
2452 }
else if (Stream.SkipBlock()) {
2453 Error(
"malformed block record in AST file");
2459 if (Stream.SkipBlock()) {
2460 Error(
"malformed block record in AST file");
2466 case llvm::BitstreamEntry::Record:
2477 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2479 : diag::err_pch_version_too_new);
2480 return VersionMismatch;
2483 bool hasErrors = Record[6];
2484 if (hasErrors && !DisableValidation && !AllowASTWithCompilerErrors) {
2485 Diag(diag::err_pch_with_compiler_errors);
2489 Diags.ErrorOccurred =
true;
2490 Diags.UncompilableErrorOccurred =
true;
2491 Diags.UnrecoverableErrorOccurred =
true;
2502 StringRef ASTBranch = Blob;
2503 if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
2504 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2505 Diag(diag::err_pch_different_branch) << ASTBranch << CurBranch;
2506 return VersionMismatch;
2515 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2519 unsigned Idx = 0, N = Record.size();
2527 ReadUntranslatedSourceLocation(Record[Idx++]);
2528 off_t StoredSize = (off_t)Record[Idx++];
2529 time_t StoredModTime = (time_t)Record[Idx++];
2531 {{(uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
2532 (uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
2533 (uint32_t)Record[Idx++]}}};
2535 std::string ImportedName = ReadString(Record, Idx);
2536 std::string ImportedFile;
2544 ImportedFile = PP.getHeaderSearchInfo().getPrebuiltModuleFileName(
2545 ImportedName,
true);
2547 if (ImportedFile.empty())
2548 ImportedFile = ReadPath(F, Record, Idx);
2550 SkipPath(Record, Idx);
2554 unsigned Capabilities = ClientLoadCapabilities;
2555 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2556 Capabilities &= ~ARR_Missing;
2559 auto Result = ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F,
2560 Loaded, StoredSize, StoredModTime,
2561 StoredSignature, Capabilities);
2565 Diag(diag::note_module_file_imported_by)
2569 case Failure:
return Failure;
2572 case OutOfDate:
return OutOfDate;
2573 case VersionMismatch:
return VersionMismatch;
2574 case ConfigurationMismatch:
return ConfigurationMismatch;
2575 case HadErrors:
return HadErrors;
2576 case Success:
break;
2604 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2611 "MODULE_DIRECTORY found before MODULE_NAME");
2615 if (M && M->Directory) {
2620 PP.getFileManager().getDirectory(Blob);
2621 if (!BuildDir || BuildDir != M->Directory) {
2622 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2623 Diag(diag::err_imported_module_relocated)
2624 << F.
ModuleName << Blob << M->Directory->getName();
2636 if (ASTReadResult Result =
2637 ReadModuleMapFileBlock(Record, F, ImportedBy, ClientLoadCapabilities))
2642 NumInputs = Record[0];
2643 NumUserInputs = Record[1];
2645 (
const llvm::support::unaligned_uint64_t *)Blob.data();
2654 ASTReader::ReadASTBlock(
ModuleFile &F,
unsigned ClientLoadCapabilities) {
2655 BitstreamCursor &Stream = F.
Stream;
2658 Error(
"malformed block record in AST file");
2665 llvm::BitstreamEntry Entry = Stream.advance();
2667 switch (Entry.Kind) {
2669 Error(
"error at end of module block in AST file");
2671 case llvm::BitstreamEntry::EndBlock:
2684 case llvm::BitstreamEntry::SubBlock:
2692 if (Stream.SkipBlock() ||
2695 Error(
"malformed block record in AST file");
2702 if (!PP.getExternalSource())
2703 PP.setExternalSource(
this);
2705 if (Stream.SkipBlock() ||
2707 Error(
"malformed block record in AST file");
2715 if (Stream.SkipBlock() ||
2718 Error(
"malformed preprocessor detail record in AST file");
2724 if (!PP.getPreprocessingRecord())
2725 PP.createPreprocessingRecord();
2726 if (!PP.getPreprocessingRecord()->getExternalSource())
2727 PP.getPreprocessingRecord()->SetExternalSource(*
this);
2731 if (ReadSourceManagerBlock(F))
2736 if (ASTReadResult Result =
2737 ReadSubmoduleBlock(F, ClientLoadCapabilities))
2742 BitstreamCursor C = Stream;
2743 if (Stream.SkipBlock() ||
2745 Error(
"malformed comments block in AST file");
2748 CommentsCursors.push_back(std::make_pair(C, &F));
2753 if (Stream.SkipBlock()) {
2754 Error(
"malformed block record in AST file");
2761 case llvm::BitstreamEntry::Record:
2801 Error(
"duplicate TYPE_OFFSET record in AST file");
2806 unsigned LocalBaseTypeIndex = Record[1];
2811 GlobalTypeMap.insert(std::make_pair(getTotalNumTypes(), &F));
2815 std::make_pair(LocalBaseTypeIndex,
2825 Error(
"duplicate DECL_OFFSET record in AST file");
2830 unsigned LocalBaseDeclID = Record[1];
2836 GlobalDeclMap.insert(
2842 std::make_pair(LocalBaseDeclID, F.
BaseDeclID - LocalBaseDeclID));
2854 DeclContext *TU = ContextObj->getTranslationUnitDecl();
2855 LexicalContents Contents(
2856 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
2858 static_cast<unsigned int>(Blob.size() / 4));
2859 TULexicalDecls.push_back(std::make_pair(&F, Contents));
2867 auto *Data = (
const unsigned char*)Blob.data();
2868 PendingVisibleUpdates[
ID].push_back(PendingVisibleUpdate{&F, Data});
2871 if (
Decl *D = GetExistingDecl(ID))
2872 PendingUpdateRecords.push_back(
2873 PendingUpdateRecord(ID, D,
false));
2886 PP.getIdentifierTable().setExternalIdentifierLookup(
this);
2892 Error(
"duplicate IDENTIFIER_OFFSET record in AST file");
2897 unsigned LocalBaseIdentifierID = Record[1];
2903 GlobalIdentifierMap.insert(std::make_pair(getTotalNumIdentifiers() + 1,
2909 std::make_pair(LocalBaseIdentifierID,
2912 IdentifiersLoaded.resize(IdentifiersLoaded.size()
2925 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2926 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
2933 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2934 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
2938 if (SpecialTypes.empty()) {
2939 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2940 SpecialTypes.push_back(getGlobalTypeID(F, Record[I]));
2944 if (SpecialTypes.size() != Record.size()) {
2945 Error(
"invalid special-types record");
2949 for (
unsigned I = 0, N = Record.size(); I != N; ++I) {
2951 if (!SpecialTypes[I])
2952 SpecialTypes[I] =
ID;
2959 TotalNumStatements += Record[0];
2960 TotalNumMacros += Record[1];
2961 TotalLexicalDeclContexts += Record[2];
2962 TotalVisibleDeclContexts += Record[3];
2966 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2967 UnusedFileScopedDecls.push_back(getGlobalDeclID(F, Record[I]));
2971 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2972 DelegatingCtorDecls.push_back(getGlobalDeclID(F, Record[I]));
2976 if (Record.size() % 4 != 0) {
2977 Error(
"invalid weak identifiers record");
2983 WeakUndeclaredIdentifiers.clear();
2986 for (
unsigned I = 0, N = Record.size(); I < N; ) {
2987 WeakUndeclaredIdentifiers.push_back(
2988 getGlobalIdentifierID(F, Record[I++]));
2989 WeakUndeclaredIdentifiers.push_back(
2990 getGlobalIdentifierID(F, Record[I++]));
2991 WeakUndeclaredIdentifiers.push_back(
2992 ReadSourceLocation(F, Record, I).getRawEncoding());
2993 WeakUndeclaredIdentifiers.push_back(Record[I++]);
3000 unsigned LocalBaseSelectorID = Record[1];
3006 GlobalSelectorMap.insert(std::make_pair(getTotalNumSelectors()+1, &F));
3011 std::make_pair(LocalBaseSelectorID,
3027 TotalNumMethodPoolEntries += Record[1];
3031 if (!Record.empty()) {
3032 for (
unsigned Idx = 0, N = Record.size() - 1; Idx < N; ) {
3033 ReferencedSelectorsData.push_back(getGlobalSelectorID(F,
3035 ReferencedSelectorsData.push_back(ReadSourceLocation(F, Record, Idx).
3042 if (!Record.empty()) {
3043 unsigned Idx = 0,
End = Record.size() - 1;
3044 bool ReachedEOFWhileSkipping = Record[Idx++];
3046 if (ReachedEOFWhileSkipping) {
3049 bool FoundNonSkipPortion = Record[Idx++];
3050 bool FoundElse = Record[Idx++];
3052 SkipInfo.emplace(HashToken, IfTokenLoc, FoundNonSkipPortion,
3053 FoundElse, ElseLoc);
3057 auto Loc = ReadSourceLocation(F, Record, Idx);
3058 bool WasSkipping = Record[Idx++];
3059 bool FoundNonSkip = Record[Idx++];
3060 bool FoundElse = Record[Idx++];
3061 ConditionalStack.push_back(
3062 {Loc, WasSkipping, FoundNonSkip, FoundElse});
3064 PP.setReplayablePreambleConditionalStack(ConditionalStack, SkipInfo);
3069 if (!Record.empty() && Listener)
3081 unsigned SLocSpaceSize = Record[1];
3086 Error(
"ran out of source locations");
3092 unsigned RangeStart =
3094 GlobalSLocEntryMap.insert(std::make_pair(RangeStart, &F));
3099 GlobalSLocOffsetMap.insert(
3101 - SLocSpaceSize,&F));
3119 if (ParseLineTable(F, Record))
3127 Error(
"Multiple SOURCE_LOCATION_PRELOADS records in AST file");
3136 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3137 ExtVectorDecls.push_back(getGlobalDeclID(F, Record[I]));
3141 if (Record.size() % 3 != 0) {
3142 Error(
"Invalid VTABLE_USES record");
3151 for (
unsigned Idx = 0, N = Record.size(); Idx != N; ) {
3152 VTableUses.push_back(getGlobalDeclID(F, Record[Idx++]));
3153 VTableUses.push_back(
3154 ReadSourceLocation(F, Record, Idx).getRawEncoding());
3155 VTableUses.push_back(Record[Idx++]);
3160 if (PendingInstantiations.size() % 2 != 0) {
3161 Error(
"Invalid existing PendingInstantiations");
3165 if (Record.size() % 2 != 0) {
3166 Error(
"Invalid PENDING_IMPLICIT_INSTANTIATIONS block");
3170 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3171 PendingInstantiations.push_back(getGlobalDeclID(F, Record[I++]));
3172 PendingInstantiations.push_back(
3173 ReadSourceLocation(F, Record, I).getRawEncoding());
3178 if (Record.size() != 3) {
3179 Error(
"Invalid SEMA_DECL_REFS block");
3182 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3183 SemaDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
3191 unsigned LocalBasePreprocessedEntityID = Record[0];
3193 unsigned StartingID;
3194 if (!PP.getPreprocessingRecord())
3195 PP.createPreprocessingRecord();
3196 if (!PP.getPreprocessingRecord()->getExternalSource())
3197 PP.getPreprocessingRecord()->SetExternalSource(*
this);
3199 = PP.getPreprocessingRecord()
3206 GlobalPreprocessedEntityMap.insert(std::make_pair(StartingID, &F));
3211 std::make_pair(LocalBasePreprocessedEntityID,
3219 if (Record.size() % 2 != 0) {
3220 Error(
"invalid DECL_UPDATE_OFFSETS block in AST file");
3223 for (
unsigned I = 0, N = Record.size(); I != N; I += 2) {
3225 DeclUpdateOffsets[
ID].push_back(std::make_pair(&F, Record[I + 1]));
3229 if (
Decl *D = GetExistingDecl(ID))
3230 PendingUpdateRecords.push_back(
3231 PendingUpdateRecord(ID, D,
false));
3237 Error(
"duplicate OBJC_CATEGORIES_MAP record in AST file");
3252 CUDASpecialDeclRefs.clear();
3253 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3254 CUDASpecialDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
3266 &PP.getHeaderSearchInfo(),
3267 Blob.data() + Record[2]));
3269 PP.getHeaderSearchInfo().SetExternalSource(
this);
3270 if (!PP.getHeaderSearchInfo().getExternalLookup())
3271 PP.getHeaderSearchInfo().SetExternalLookup(
this);
3277 FPPragmaOptions.swap(Record);
3281 for (
unsigned I = 0, E = Record.size(); I != E; ) {
3282 auto Name = ReadString(Record, I);
3283 auto &Opt = OpenCLExtensions.OptMap[Name];
3284 Opt.Supported = Record[I++] != 0;
3285 Opt.Enabled = Record[I++] != 0;
3286 Opt.Avail = Record[I++];
3287 Opt.Core = Record[I++];
3292 for (
unsigned I = 0, E = Record.size(); I != E;) {
3295 auto NumExt =
static_cast<unsigned>(Record[I++]);
3296 for (
unsigned II = 0; II != NumExt; ++II) {
3297 auto Ext = ReadString(Record, I);
3298 OpenCLTypeExtMap[
Type].insert(Ext);
3304 for (
unsigned I = 0, E = Record.size(); I != E;) {
3307 auto NumExt =
static_cast<unsigned>(Record[I++]);
3308 for (
unsigned II = 0; II != NumExt; ++II) {
3309 auto Ext = ReadString(Record, I);
3310 OpenCLDeclExtMap[
Decl].insert(Ext);
3316 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3317 TentativeDefinitions.push_back(getGlobalDeclID(F, Record[I]));
3321 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3322 KnownNamespaces.push_back(getGlobalDeclID(F, Record[I]));
3326 if (UndefinedButUsed.size() % 2 != 0) {
3327 Error(
"Invalid existing UndefinedButUsed");
3331 if (Record.size() % 2 != 0) {
3332 Error(
"invalid undefined-but-used record");
3335 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3336 UndefinedButUsed.push_back(getGlobalDeclID(F, Record[I++]));
3337 UndefinedButUsed.push_back(
3338 ReadSourceLocation(F, Record, I).getRawEncoding());
3343 for (
unsigned I = 0, N = Record.size(); I != N;) {
3344 DelayedDeleteExprs.push_back(getGlobalDeclID(F, Record[I++]));
3345 const uint64_t Count = Record[I++];
3346 DelayedDeleteExprs.push_back(Count);
3347 for (uint64_t C = 0; C < Count; ++C) {
3348 DelayedDeleteExprs.push_back(ReadSourceLocation(F, Record, I).getRawEncoding());
3349 bool IsArrayForm = Record[I++] == 1;
3350 DelayedDeleteExprs.push_back(IsArrayForm);
3360 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3361 unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
3364 ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
3365 if (DeserializationListener)
3366 DeserializationListener->ModuleImportRead(GlobalID, Loc);
3374 Error(
"duplicate MACRO_OFFSET record in AST file");
3379 unsigned LocalBaseMacroID = Record[1];
3384 GlobalMacroMap.insert(std::make_pair(getTotalNumMacros() + 1, &F));
3388 std::make_pair(LocalBaseMacroID,
3397 LateParsedTemplates.append(Record.begin(), Record.end());
3401 if (Record.size() != 1) {
3402 Error(
"invalid pragma optimize record");
3405 OptimizeOffPragmaLocation = ReadSourceLocation(F, Record[0]);
3409 if (Record.size() != 1) {
3410 Error(
"invalid pragma ms_struct record");
3413 PragmaMSStructState = Record[0];
3417 if (Record.size() != 2) {
3418 Error(
"invalid pragma ms_struct record");
3421 PragmaMSPointersToMembersState = Record[0];
3422 PointersToMembersPragmaLocation = ReadSourceLocation(F, Record[1]);
3426 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3427 UnusedLocalTypedefNameCandidates.push_back(
3428 getGlobalDeclID(F, Record[I]));
3432 if (Record.size() != 1) {
3433 Error(
"invalid cuda pragma options record");
3436 ForceCUDAHostDeviceDepth = Record[0];
3440 if (Record.size() < 3) {
3441 Error(
"invalid pragma pack record");
3444 PragmaPackCurrentValue = Record[0];
3445 PragmaPackCurrentLocation = ReadSourceLocation(F, Record[1]);
3446 unsigned NumStackEntries = Record[2];
3449 PragmaPackStack.clear();
3450 for (
unsigned I = 0; I < NumStackEntries; ++I) {
3451 PragmaPackStackEntry Entry;
3452 Entry.Value = Record[Idx++];
3453 Entry.Location = ReadSourceLocation(F, Record[Idx++]);
3454 Entry.PushLocation = ReadSourceLocation(F, Record[Idx++]);
3455 PragmaPackStrings.push_back(ReadString(Record, Idx));
3456 Entry.SlotLabel = PragmaPackStrings.back();
3457 PragmaPackStack.push_back(Entry);
3465 void ASTReader::ReadModuleOffsetMap(
ModuleFile &F)
const {
3469 const unsigned char *Data = (
const unsigned char*)F.
ModuleOffsetMap.data();
3490 while (Data < DataEnd) {
3494 using namespace llvm::support;
3496 endian::readNext<uint8_t, little, unaligned>(Data));
3497 uint16_t Len = endian::readNext<uint16_t, little, unaligned>(Data);
3498 StringRef Name = StringRef((
const char*)Data, Len);
3501 ? ModuleMgr.lookupByModuleName(Name)
3502 : ModuleMgr.lookupByFileName(Name));
3505 "SourceLocation remap refers to unknown module, cannot find ";
3511 uint32_t SLocOffset =
3512 endian::readNext<uint32_t, little, unaligned>(Data);
3513 uint32_t IdentifierIDOffset =
3514 endian::readNext<uint32_t, little, unaligned>(Data);
3515 uint32_t MacroIDOffset =
3516 endian::readNext<uint32_t, little, unaligned>(Data);
3517 uint32_t PreprocessedEntityIDOffset =
3518 endian::readNext<uint32_t, little, unaligned>(Data);
3519 uint32_t SubmoduleIDOffset =
3520 endian::readNext<uint32_t, little, unaligned>(Data);
3521 uint32_t SelectorIDOffset =
3522 endian::readNext<uint32_t, little, unaligned>(Data);
3523 uint32_t DeclIDOffset =
3524 endian::readNext<uint32_t, little, unaligned>(Data);
3525 uint32_t TypeIndexOffset =
3526 endian::readNext<uint32_t, little, unaligned>(Data);
3530 auto mapOffset = [&](uint32_t
Offset, uint32_t BaseOffset,
3531 RemapBuilder &Remap) {
3533 Remap.insert(std::make_pair(Offset,
3534 static_cast<int>(BaseOffset - Offset)));
3538 mapOffset(MacroIDOffset, OM->
BaseMacroID, MacroRemap);
3540 PreprocessedEntityRemap);
3543 mapOffset(DeclIDOffset, OM->
BaseDeclID, DeclRemap);
3552 ASTReader::ReadModuleMapFileBlock(RecordData &Record,
ModuleFile &F,
3554 unsigned ClientLoadCapabilities) {
3563 "MODULE_NAME should come before MODULE_MAP_FILE");
3568 auto &Map = PP.getHeaderSearchInfo().getModuleMap();
3569 const FileEntry *ModMap = M ? Map.getModuleMapFileForUniquing(M) :
nullptr;
3571 assert(ImportedBy &&
"top-level import should be verified");
3572 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) {
3573 if (
auto *ASTFE = M ? M->
getASTFile() :
nullptr) {
3576 << ASTFE->getName();
3579 Diag(diag::err_imported_module_not_found)
3586 Diag(diag::note_imported_by_pch_module_not_found)
3593 assert(M->
Name == F.
ModuleName &&
"found module with different name");
3597 if (StoredModMap ==
nullptr || StoredModMap != ModMap) {
3598 assert(ModMap &&
"found module is missing module map file");
3599 assert(ImportedBy &&
"top-level import should be verified");
3600 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3601 Diag(diag::err_imported_module_modmap_changed)
3607 llvm::SmallPtrSet<const FileEntry *, 1> AdditionalStoredMaps;
3608 for (
unsigned I = 0, N = Record[Idx++]; I < N; ++I) {
3610 std::string
Filename = ReadPath(F, Record, Idx);
3612 FileMgr.getFile(Filename,
false,
false);
3614 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3615 Error(
"could not find file '" + Filename +
"' referenced by AST file");
3618 AdditionalStoredMaps.insert(F);
3623 if (
auto *AdditionalModuleMaps = Map.getAdditionalModuleMapFiles(M)) {
3624 for (
const FileEntry *ModMap : *AdditionalModuleMaps) {
3627 if (!AdditionalStoredMaps.erase(ModMap)) {
3628 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3629 Diag(diag::err_module_different_modmap)
3638 for (
const FileEntry *ModMap : AdditionalStoredMaps) {
3639 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3640 Diag(diag::err_module_different_modmap)
3654 Sema::GlobalMethodPool::iterator Known
3661 : Known->second.second;
3663 for (
ObjCMethodList *List = &Start; List; List = List->getNext()) {
3665 if (List->getMethod() == Method) {
3673 if (List->getNext())
3674 List->setMethod(List->getNext()->getMethod());
3676 List->setMethod(Method);
3682 for (
Decl *D : Names) {
3683 bool wasHidden = D->isHidden();
3684 D->setVisibleDespiteOwningModule();
3686 if (wasHidden && SemaObj) {
3697 llvm::SmallPtrSet<Module *, 4> Visited;
3699 Stack.push_back(Mod);
3700 while (!Stack.empty()) {
3701 Mod = Stack.pop_back_val();
3703 if (NameVisibility <= Mod->NameVisibility) {
3719 HiddenNamesMapType::iterator Hidden = HiddenNamesMap.find(Mod);
3720 if (Hidden != HiddenNamesMap.end()) {
3722 HiddenNamesMap.erase(Hidden);
3724 assert(HiddenNamesMap.find(Mod) == HiddenNamesMap.end() &&
3725 "making names visible added hidden names");
3732 I = Exports.begin(), E = Exports.end(); I != E; ++I) {
3734 if (Visited.insert(Exported).second)
3735 Stack.push_back(Exported);
3752 else if (getContext().getLangOpts().ModulesLocalVisibility) {
3753 getContext().mergeDefinitionIntoModule(
3756 PendingMergedDefinitionsToDeduplicate.insert(Def);
3759 assert(
SubmoduleID &&
"hidden definition in no module");
3760 HiddenNamesMap[getSubmodule(
SubmoduleID)].push_back(Def);
3769 if (TriedLoadingGlobalIndex || !UseGlobalIndex ||
3770 !PP.getLangOpts().Modules)
3774 TriedLoadingGlobalIndex =
true;
3775 StringRef ModuleCachePath
3776 = getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
3777 std::pair<GlobalModuleIndex *, GlobalModuleIndex::ErrorCode> Result
3782 GlobalIndex.reset(Result.first);
3783 ModuleMgr.setGlobalIndex(GlobalIndex.get());
3788 return PP.getLangOpts().Modules && UseGlobalIndex &&
3789 !hasGlobalIndex() && TriedLoadingGlobalIndex;
3796 llvm::raw_fd_ostream OS(TimestampFilename, EC, llvm::sys::fs::F_Text);
3799 OS <<
"Timestamp file\n";
3809 llvm::BitstreamEntry Entry = Cursor.advance();
3810 switch (Entry.Kind) {
3812 case llvm::BitstreamEntry::EndBlock:
3815 case llvm::BitstreamEntry::Record:
3817 Cursor.skipRecord(Entry.ID);
3820 case llvm::BitstreamEntry::SubBlock:
3821 if (Entry.ID == BlockID) {
3822 if (Cursor.EnterSubBlock(BlockID))
3828 if (Cursor.SkipBlock())
3837 unsigned ClientLoadCapabilities,
3840 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
3846 unsigned PreviousGeneration = 0;
3848 PreviousGeneration = incrementGeneration(*ContextObj);
3850 unsigned NumModules = ModuleMgr.size();
3853 ReadASTCore(FileName, Type, ImportLoc,
3854 nullptr, Loaded, 0, 0,
3859 case VersionMismatch:
3860 case ConfigurationMismatch:
3862 llvm::SmallPtrSet<ModuleFile *, 4> LoadedSet;
3863 for (
const ImportedModule &IM : Loaded)
3864 LoadedSet.insert(IM.Mod);
3866 ModuleMgr.removeModules(ModuleMgr.begin() + NumModules, LoadedSet,
3867 PP.getLangOpts().Modules
3868 ? &PP.getHeaderSearchInfo().getModuleMap()
3873 GlobalIndex.reset();
3874 ModuleMgr.setGlobalIndex(
nullptr);
3885 MEnd = Loaded.end();
3890 if (
ASTReadResult Result = ReadASTBlock(F, ClientLoadCapabilities))
3912 SourceMgr.getLoadedSLocEntryByID(Index);
3925 const unsigned char *Data =
reinterpret_cast<const unsigned char *
>(
3930 auto Key = Trait.
ReadKey(Data, KeyDataLen.first);
3931 auto &II = PP.getIdentifierTable().getOwn(Key);
3932 II.setOutOfDate(
true);
3940 SetIdentifierInfo(
ID, &II);
3947 MEnd = Loaded.end();
3951 ModuleMgr.moduleFileAccepted(&F);
3963 if (!PP.getLangOpts().CPlusPlus ||
3974 IdEnd = PP.getIdentifierTable().end();
3976 Id->second->setOutOfDate(
true);
3979 for (
auto Sel : SelectorGeneration)
3980 SelectorOutOfDate[Sel.first] =
true;
3983 for (
unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I) {
3984 UnresolvedModuleRef &Unresolved = UnresolvedModuleRefs[I];
3985 SubmoduleID GlobalID = getGlobalSubmoduleID(*Unresolved.File,Unresolved.ID);
3986 Module *ResolvedMod = getSubmodule(GlobalID);
3988 switch (Unresolved.Kind) {
3989 case UnresolvedModuleRef::Conflict:
3992 Conflict.
Other = ResolvedMod;
3993 Conflict.
Message = Unresolved.String.str();
3994 Unresolved.Mod->Conflicts.push_back(Conflict);
3998 case UnresolvedModuleRef::Import:
4000 Unresolved.Mod->Imports.insert(ResolvedMod);
4003 case UnresolvedModuleRef::Export:
4004 if (ResolvedMod || Unresolved.IsWildcard)
4005 Unresolved.Mod->Exports.push_back(
4010 UnresolvedModuleRefs.clear();
4013 Imported->append(ImportedModules.begin(),
4014 ImportedModules.end());
4021 InitializeContext();
4026 if (DeserializationListener)
4027 DeserializationListener->ReaderInitialized(
this);
4029 ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule();
4044 for (
unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++I) {
4045 loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
4046 ObjCClassesLoaded[I],
4047 PreviousGeneration);
4051 if (PP.getHeaderSearchInfo()
4052 .getHeaderSearchOpts()
4053 .ModulesValidateOncePerBuildSession) {
4058 for (
unsigned I = 0, N = Loaded.size(); I != N; ++I) {
4059 ImportedModule &M = Loaded[I];
4073 return Stream.canSkipToPos(4) &&
4074 Stream.Read(8) ==
'C' &&
4075 Stream.Read(8) ==
'P' &&
4076 Stream.Read(8) ==
'C' &&
4077 Stream.Read(8) ==
'H';
4092 llvm_unreachable(
"unknown module kind");
4096 ASTReader::ReadASTCore(StringRef FileName,
4101 off_t ExpectedSize, time_t ExpectedModTime,
4103 unsigned ClientLoadCapabilities) {
4105 std::string ErrorStr;
4107 = ModuleMgr.addModule(FileName,
Type, ImportLoc, ImportedBy,
4108 getGeneration(), ExpectedSize, ExpectedModTime,
4109 ExpectedSignature, readASTFileSignature,
4112 switch (AddResult) {
4123 if (ClientLoadCapabilities & ARR_Missing)
4128 << FileName << !ErrorStr.empty()
4135 if (ClientLoadCapabilities & ARR_OutOfDate)
4140 << FileName << !ErrorStr.empty()
4145 assert(M &&
"Missing module file");
4148 BitstreamCursor &Stream = F.
Stream;
4149 Stream = BitstreamCursor(PCHContainerRdr.ExtractPCH(*F.
Buffer));
4160 bool HaveReadControlBlock =
false;
4162 llvm::BitstreamEntry Entry = Stream.advance();
4164 switch (Entry.Kind) {
4166 case llvm::BitstreamEntry::Record:
4167 case llvm::BitstreamEntry::EndBlock:
4168 Error(
"invalid record at top-level of AST file");
4171 case llvm::BitstreamEntry::SubBlock:
4177 HaveReadControlBlock =
true;
4178 switch (ReadControlBlock(F, Loaded, ImportedBy, ClientLoadCapabilities)) {
4188 if (Result != OutOfDate ||
4189 (ClientLoadCapabilities & ARR_OutOfDate) == 0)
4190 Diag(diag::err_module_file_not_module) << FileName;
4195 case Failure:
return Failure;
4196 case Missing:
return Missing;
4197 case OutOfDate:
return OutOfDate;
4198 case VersionMismatch:
return VersionMismatch;
4199 case ConfigurationMismatch:
return ConfigurationMismatch;
4200 case HadErrors:
return HadErrors;
4205 if (!HaveReadControlBlock) {
4206 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
4207 Diag(diag::err_pch_version_too_old);
4208 return VersionMismatch;
4212 Loaded.push_back(ImportedModule(M, ImportedBy, ImportLoc));
4218 Error(
"malformed block record in AST file");
4222 if (Stream.SkipBlock()) {
4223 Error(
"malformed block record in AST file");
4234 ASTReader::readUnhashedControlBlock(
ModuleFile &F,
bool WasImportedBy,
4235 unsigned ClientLoadCapabilities) {
4237 PP.getHeaderSearchInfo().getHeaderSearchOpts();
4238 bool AllowCompatibleConfigurationMismatch =
4241 ASTReadResult Result = readUnhashedControlBlockImpl(
4242 &F, F.
Data, ClientLoadCapabilities, AllowCompatibleConfigurationMismatch,
4248 if (DisableValidation || WasImportedBy ||
4249 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
4252 if (Result == Failure) {
4253 Error(
"malformed block record in AST file");
4276 if (PCMCache.isBufferFinal(F.
FileName)) {
4277 Diag(diag::warn_module_system_bit_conflict) << F.
FileName;
4286 ModuleFile *F, llvm::StringRef StreamData,
unsigned ClientLoadCapabilities,
4288 bool ValidateDiagnosticOptions) {
4290 BitstreamCursor Stream(StreamData);
4302 ASTReadResult Result = Success;
4304 llvm::BitstreamEntry Entry = Stream.advance();
4306 switch (Entry.Kind) {
4308 case llvm::BitstreamEntry::SubBlock:
4311 case llvm::BitstreamEntry::EndBlock:
4314 case llvm::BitstreamEntry::Record:
4325 std::copy(Record.begin(), Record.end(), F->
Signature.data());
4328 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
4329 if (Listener && ValidateDiagnosticOptions &&
4330 !AllowCompatibleConfigurationMismatch &&
4331 ParseDiagnosticOptions(Record, Complain, *Listener))
4342 Record.begin(), Record.end());
4353 if (Record.size() < 4)
return true;
4358 unsigned BlockNameLen = Record[2];
4359 unsigned UserInfoLen = Record[3];
4361 if (BlockNameLen + UserInfoLen > Blob.size())
return true;
4363 Metadata.
BlockName = std::string(Blob.data(), Blob.data() + BlockNameLen);
4364 Metadata.
UserInfo = std::string(Blob.data() + BlockNameLen,
4365 Blob.data() + BlockNameLen + UserInfoLen);
4370 BitstreamCursor &Stream = F.
Stream;
4374 llvm::BitstreamEntry Entry = Stream.advance();
4375 switch (Entry.Kind) {
4376 case llvm::BitstreamEntry::SubBlock:
4377 if (Stream.SkipBlock())
4382 case llvm::BitstreamEntry::EndBlock:
4388 case llvm::BitstreamEntry::Record:
4394 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4402 auto Known = ModuleFileExtensions.find(Metadata.
BlockName);
4403 if (Known == ModuleFileExtensions.end())
break;
4406 if (
auto Reader = Known->second->createExtensionReader(Metadata, *
this,
4420 assert(ContextObj &&
"no context to initialize");
4424 if (DeserializationListener)
4434 if (!Context.CFConstantStringTypeDecl)
4441 Error(
"FILE type is NULL");
4445 if (!Context.FILEDecl) {
4451 Error(
"Invalid FILE type in AST file");
4460 QualType Jmp_bufType = GetType(Jmp_buf);
4461 if (Jmp_bufType.
isNull()) {
4462 Error(
"jmp_buf type is NULL");
4466 if (!Context.jmp_bufDecl) {
4472 Error(
"Invalid jmp_buf type in AST file");
4481 QualType Sigjmp_bufType = GetType(Sigjmp_buf);
4482 if (Sigjmp_bufType.
isNull()) {
4483 Error(
"sigjmp_buf type is NULL");
4487 if (!Context.sigjmp_bufDecl) {
4492 assert(Tag &&
"Invalid sigjmp_buf type in AST file");
4498 if (
unsigned ObjCIdRedef
4500 if (Context.ObjCIdRedefinitionType.
isNull())
4501 Context.ObjCIdRedefinitionType = GetType(ObjCIdRedef);
4504 if (
unsigned ObjCClassRedef
4506 if (Context.ObjCClassRedefinitionType.
isNull())
4507 Context.ObjCClassRedefinitionType = GetType(ObjCClassRedef);
4510 if (
unsigned ObjCSelRedef
4512 if (Context.ObjCSelRedefinitionType.
isNull())
4513 Context.ObjCSelRedefinitionType = GetType(ObjCSelRedef);
4517 QualType Ucontext_tType = GetType(Ucontext_t);
4518 if (Ucontext_tType.
isNull()) {
4519 Error(
"ucontext_t type is NULL");
4523 if (!Context.ucontext_tDecl) {
4528 assert(Tag &&
"Invalid ucontext_t type in AST file");
4538 if (!CUDASpecialDeclRefs.empty()) {
4539 assert(CUDASpecialDeclRefs.size() == 1 &&
"More decl refs than expected!");
4541 cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
4546 for (
auto &Import : ImportedModules) {
4547 if (
Module *Imported = getSubmodule(Import.ID)) {
4550 if (Import.ImportLoc.isValid())
4551 PP.makeModuleVisible(Imported, Import.ImportLoc);
4555 ImportedModules.clear();
4565 BitstreamCursor Stream(PCH);
4576 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
4577 if (Entry.Kind != llvm::BitstreamEntry::Record)
4582 if (
SIGNATURE == Stream.readRecord(Entry.ID, Record, &Blob))
4583 return {{{(uint32_t)Record[0], (uint32_t)Record[1], (uint32_t)Record[2],
4584 (uint32_t)Record[3], (uint32_t)Record[4]}}};
4592 const std::string &ASTFileName,
FileManager &FileMgr,
4597 Diags.
Report(diag::err_fe_unable_to_read_pch_file)
4598 << ASTFileName << Buffer.getError().message();
4599 return std::string();
4603 BitstreamCursor Stream(PCHContainerRdr.
ExtractPCH(**Buffer));
4607 Diags.
Report(diag::err_fe_not_a_pch_file) << ASTFileName;
4608 return std::string();
4613 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
4614 return std::string();
4620 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
4621 if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
4622 return std::string();
4624 if (Entry.Kind != llvm::BitstreamEntry::Record) {
4625 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
4626 return std::string();
4631 if (Stream.readRecord(Entry.ID, Record, &Blob) ==
ORIGINAL_FILE)
4642 std::string ExistingModuleCachePath;
4646 SimplePCHValidator(
const LangOptions &ExistingLangOpts,
4649 StringRef ExistingModuleCachePath,
4651 : ExistingLangOpts(ExistingLangOpts),
4652 ExistingTargetOpts(ExistingTargetOpts),
4653 ExistingPPOpts(ExistingPPOpts),
4654 ExistingModuleCachePath(ExistingModuleCachePath),
4657 bool ReadLanguageOptions(
const LangOptions &LangOpts,
bool Complain,
4658 bool AllowCompatibleDifferences)
override {
4660 AllowCompatibleDifferences);
4663 bool ReadTargetOptions(
const TargetOptions &TargetOpts,
bool Complain,
4664 bool AllowCompatibleDifferences)
override {
4666 AllowCompatibleDifferences);
4670 StringRef SpecificModuleCachePath,
4671 bool Complain)
override {
4673 ExistingModuleCachePath,
4674 nullptr, ExistingLangOpts);
4679 std::string &SuggestedPredefines)
override {
4681 SuggestedPredefines, ExistingLangOpts);
4690 bool FindModuleFileExtensions,
4701 StringRef Bytes = PCHContainerRdr.
ExtractPCH(**Buffer);
4702 BitstreamCursor Stream(Bytes);
4715 BitstreamCursor InputFilesCursor;
4718 std::string ModuleDir;
4719 bool DoneWithControlBlock =
false;
4720 while (!DoneWithControlBlock) {
4721 llvm::BitstreamEntry Entry = Stream.advance();
4723 switch (Entry.Kind) {
4724 case llvm::BitstreamEntry::SubBlock: {
4727 std::string IgnoredSuggestedPredefines;
4728 if (ReadOptionsBlock(Stream, ARR_ConfigurationMismatch | ARR_OutOfDate,
4730 Listener, IgnoredSuggestedPredefines) != Success)
4736 InputFilesCursor = Stream;
4737 if (Stream.SkipBlock() ||
4744 if (Stream.SkipBlock())
4752 case llvm::BitstreamEntry::EndBlock:
4753 DoneWithControlBlock =
true;
4759 case llvm::BitstreamEntry::Record:
4763 if (DoneWithControlBlock)
break;
4767 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4783 auto Path = ReadString(Record, Idx);
4784 ResolveImportedPath(Path, ModuleDir);
4789 if (!NeedsInputFiles)
4792 unsigned NumInputFiles = Record[0];
4793 unsigned NumUserFiles = Record[1];
4794 const uint64_t *InputFileOffs = (
const uint64_t *)Blob.data();
4795 for (
unsigned I = 0; I != NumInputFiles; ++I) {
4797 bool isSystemFile = I >= NumUserFiles;
4799 if (isSystemFile && !NeedsSystemInputFiles)
4802 BitstreamCursor &
Cursor = InputFilesCursor;
4804 Cursor.JumpToBit(InputFileOffs[I]);
4806 unsigned Code = Cursor.ReadCode();
4809 bool shouldContinue =
false;
4812 bool Overridden =
static_cast<bool>(Record[3]);
4813 std::string Filename = Blob;
4814 ResolveImportedPath(Filename, ModuleDir);
4816 Filename, isSystemFile, Overridden,
false);
4819 if (!shouldContinue)
4829 unsigned Idx = 0, N = Record.size();
4833 SkipString(Record, Idx);
4834 std::string Filename = ReadString(Record, Idx);
4835 ResolveImportedPath(Filename, ModuleDir);
4848 if (FindModuleFileExtensions) {
4849 BitstreamCursor SavedStream = Stream;
4851 bool DoneWithExtensionBlock =
false;
4852 while (!DoneWithExtensionBlock) {
4853 llvm::BitstreamEntry Entry = Stream.advance();
4855 switch (Entry.Kind) {
4856 case llvm::BitstreamEntry::SubBlock:
4857 if (Stream.SkipBlock())
4862 case llvm::BitstreamEntry::EndBlock:
4863 DoneWithExtensionBlock =
true;
4869 case llvm::BitstreamEntry::Record:
4875 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4888 Stream = SavedStream;
4892 if (readUnhashedControlBlockImpl(
4893 nullptr, Bytes, ARR_ConfigurationMismatch | ARR_OutOfDate,
4895 ValidateDiagnosticOptions) != Success)
4906 StringRef ExistingModuleCachePath) {
4907 SimplePCHValidator validator(LangOpts, TargetOpts, PPOpts,
4908 ExistingModuleCachePath, FileMgr);
4909 return !readASTFileControlBlock(Filename, FileMgr, PCHContainerRdr,
4916 ASTReader::ReadSubmoduleBlock(
ModuleFile &F,
unsigned ClientLoadCapabilities) {
4919 Error(
"malformed submodule block record in AST file");
4923 ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
4925 Module *CurrentModule =
nullptr;
4928 llvm::BitstreamEntry Entry = F.
Stream.advanceSkippingSubblocks();
4930 switch (Entry.Kind) {
4931 case llvm::BitstreamEntry::SubBlock:
4933 Error(
"malformed block record in AST file");
4935 case llvm::BitstreamEntry::EndBlock:
4937 case llvm::BitstreamEntry::Record:
4945 auto Kind = F.
Stream.readRecord(Entry.ID, Record, &Blob);
4948 Error(
"submodule metadata record should be at beginning of block");
4964 if (Record.size() < 8) {
4965 Error(
"malformed module definition");
4969 StringRef Name = Blob;
4971 SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);
4974 bool IsFramework = Record[Idx++];
4975 bool IsExplicit = Record[Idx++];
4976 bool IsSystem = Record[Idx++];
4977 bool IsExternC = Record[Idx++];
4978 bool InferSubmodules = Record[Idx++];
4979 bool InferExplicitSubmodules = Record[Idx++];
4980 bool InferExportWildcard = Record[Idx++];
4981 bool ConfigMacrosExhaustive = Record[Idx++];
4983 Module *ParentModule =
nullptr;
4985 ParentModule = getSubmodule(Parent);
4997 if (GlobalIndex >= SubmodulesLoaded.size() ||
4998 SubmodulesLoaded[GlobalIndex]) {
4999 Error(
"too many submodules");
5003 if (!ParentModule) {
5005 if (CurFile != F.
File) {
5006 if (!Diags.isDiagnosticInFlight()) {
5007 Diag(diag::err_module_file_conflict)
5009 << CurFile->getName()
5020 CurrentModule->
Kind = Kind;
5029 if (DeserializationListener)
5030 DeserializationListener->ModuleRead(GlobalID, CurrentModule);
5032 SubmodulesLoaded[GlobalIndex] = CurrentModule;
5055 ResolveImportedPath(F, Filename);
5056 if (
auto *Umbrella = PP.getFileManager().getFile(Filename)) {
5060 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
5061 Error(
"mismatched umbrella headers in submodule");
5087 std::string Dirname = Blob;
5088 ResolveImportedPath(F, Dirname);
5089 if (
auto *Umbrella = PP.getFileManager().getDirectory(Dirname)) {
5093 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
5094 Error(
"mismatched umbrella directories in submodule");
5104 unsigned LocalBaseSubmoduleID = Record[1];
5108 GlobalSubmoduleMap.insert(std::make_pair(getTotalNumSubmodules()+1,&F));
5113 std::make_pair(LocalBaseSubmoduleID,
5122 for (
unsigned Idx = 0; Idx != Record.size(); ++Idx) {
5123 UnresolvedModuleRef Unresolved;
5124 Unresolved.File = &F;
5125 Unresolved.Mod = CurrentModule;
5126 Unresolved.ID = Record[Idx];
5127 Unresolved.Kind = UnresolvedModuleRef::Import;
5128 Unresolved.IsWildcard =
false;
5129 UnresolvedModuleRefs.push_back(Unresolved);
5134 for (
unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
5135 UnresolvedModuleRef Unresolved;
5136 Unresolved.File = &F;
5137 Unresolved.Mod = CurrentModule;
5138 Unresolved.ID = Record[Idx];
5139 Unresolved.Kind = UnresolvedModuleRef::Export;
5140 Unresolved.IsWildcard = Record[Idx + 1];
5141 UnresolvedModuleRefs.push_back(Unresolved);
5151 PP.getTargetInfo());
5164 UnresolvedModuleRef Unresolved;
5165 Unresolved.File = &F;
5166 Unresolved.Mod = CurrentModule;
5167 Unresolved.ID = Record[0];
5168 Unresolved.Kind = UnresolvedModuleRef::Conflict;
5169 Unresolved.IsWildcard =
false;
5170 Unresolved.String = Blob;
5171 UnresolvedModuleRefs.push_back(Unresolved);
5179 for (
auto &
ID : Record)
5180 Inits.push_back(getGlobalDeclID(F,
ID));
5181 ContextObj->addLazyModuleInitializers(CurrentModule, Inits);
5199 bool ASTReader::ParseLanguageOptions(
const RecordData &Record,
5202 bool AllowCompatibleDifferences) {
5205 #define LANGOPT(Name, Bits, Default, Description) \ 5206 LangOpts.Name = Record[Idx++]; 5207 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 5208 LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++])); 5209 #include "clang/Basic/LangOptions.def" 5210 #define SANITIZER(NAME, ID) \ 5211 LangOpts.Sanitize.set(SanitizerKind::ID, Record[Idx++]); 5212 #include "clang/Basic/Sanitizers.def" 5214 for (
unsigned N = Record[Idx++]; N; --N)
5218 VersionTuple runtimeVersion = ReadVersionTuple(Record, Idx);
5224 for (
unsigned N = Record[Idx++]; N; --N) {
5226 ReadString(Record, Idx));
5231 for (
unsigned N = Record[Idx++]; N; --N) {
5232 LangOpts.
OMPTargetTriples.push_back(llvm::Triple(ReadString(Record, Idx)));
5238 AllowCompatibleDifferences);
5241 bool ASTReader::ParseTargetOptions(
const RecordData &Record,
bool Complain,
5243 bool AllowCompatibleDifferences) {
5246 TargetOpts.
Triple = ReadString(Record, Idx);
5247 TargetOpts.
CPU = ReadString(Record, Idx);
5248 TargetOpts.
ABI = ReadString(Record, Idx);
5249 for (
unsigned N = Record[Idx++]; N; --N) {
5252 for (
unsigned N = Record[Idx++]; N; --N) {
5253 TargetOpts.
Features.push_back(ReadString(Record, Idx));
5257 AllowCompatibleDifferences);
5260 bool ASTReader::ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
5264 #define DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++]; 5265 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ 5266 DiagOpts->set##Name(static_cast<Type>(Record[Idx++])); 5267 #include "clang/Basic/DiagnosticOptions.def" 5269 for (
unsigned N = Record[Idx++]; N; --N)
5270 DiagOpts->Warnings.push_back(ReadString(Record, Idx));
5271 for (
unsigned N = Record[Idx++]; N; --N)
5272 DiagOpts->Remarks.push_back(ReadString(Record, Idx));
5277 bool ASTReader::ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
5285 bool ASTReader::ParseHeaderSearchOptions(
const RecordData &Record,
5290 HSOpts.
Sysroot = ReadString(Record, Idx);
5293 for (
unsigned N = Record[Idx++]; N; --N) {
5294 std::string Path = ReadString(Record, Idx);
5297 bool IsFramework = Record[Idx++];
5298 bool IgnoreSysRoot = Record[Idx++];
5299 HSOpts.
UserEntries.emplace_back(std::move(Path), Group, IsFramework,
5304 for (
unsigned N = Record[Idx++]; N; --N) {
5305 std::string Prefix = ReadString(Record, Idx);
5306 bool IsSystemHeader = Record[Idx++];
5320 std::string SpecificModuleCachePath = ReadString(Record, Idx);
5326 bool ASTReader::ParsePreprocessorOptions(
const RecordData &Record,
5329 std::string &SuggestedPredefines) {
5334 for (
unsigned N = Record[Idx++]; N; --N) {
5335 std::string Macro = ReadString(Record, Idx);
5336 bool IsUndef = Record[Idx++];
5337 PPOpts.
Macros.push_back(std::make_pair(Macro, IsUndef));
5341 for (
unsigned N = Record[Idx++]; N; --N) {
5342 PPOpts.
Includes.push_back(ReadString(Record, Idx));
5346 for (
unsigned N = Record[Idx++]; N; --N) {
5356 SuggestedPredefines.clear();
5358 SuggestedPredefines);
5361 std::pair<ModuleFile *, unsigned>
5362 ASTReader::getModulePreprocessedEntity(
unsigned GlobalIndex) {
5364 I = GlobalPreprocessedEntityMap.find(GlobalIndex);
5365 assert(I != GlobalPreprocessedEntityMap.end() &&
5366 "Corrupted global preprocessed entity map");
5369 return std::make_pair(M, LocalIndex);
5372 llvm::iterator_range<PreprocessingRecord::iterator>
5373 ASTReader::getModulePreprocessedEntities(
ModuleFile &Mod)
const {
5382 llvm::iterator_range<ASTReader::ModuleDeclIterator>
5384 return llvm::make_range(
5392 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
5394 unsigned LocalIndex = PPInfo.second;
5397 if (!PP.getPreprocessingRecord()) {
5398 Error(
"no preprocessing record");
5405 llvm::BitstreamEntry Entry =
5407 if (Entry.Kind != llvm::BitstreamEntry::Record)
5412 TranslateSourceLocation(M, PPOffs.
getEnd()));
5418 Entry.ID, Record, &Blob);
5421 bool isBuiltin = Record[0];
5425 Name = getLocalIdentifier(M, Record[1]);
5428 getGlobalPreprocessedEntityID(M, Record[1]);
5429 Def = cast<MacroDefinitionRecord>(
5430 PPRec.getLoadedPreprocessedEntity(GlobalID - 1));
5448 if (DeserializationListener)
5449 DeserializationListener->MacroDefinitionRead(PPID, MD);
5455 const char *FullFileNameStart = Blob.data() + Record[0];
5456 StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]);
5458 if (!FullFileName.empty())
5459 File = PP.getFileManager().getFile(FullFileName);
5466 StringRef(Blob.data(), Record[0]),
5467 Record[1], Record[3],
5474 llvm_unreachable(
"Invalid PreprocessorDetailRecordTypes");
5487 EndI = GlobalSLocOffsetMap.end(); SLocMapI != EndI; ++SLocMapI) {
5493 return getTotalNumPreprocessedEntities();
5498 struct PPEntityComp {
5528 bool EndsAfter)
const {
5529 if (SourceMgr.isLocalSourceLocation(Loc))
5530 return getTotalNumPreprocessedEntities();
5533 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
5534 assert(SLocMapI != GlobalSLocOffsetMap.end() &&
5535 "Corrupted global sloc offset map");
5537 if (SLocMapI->second->NumPreprocessedEntities == 0)
5538 return findNextPreprocessedEntity(SLocMapI);
5549 pp_iterator First = pp_begin;
5553 PPI = std::upper_bound(pp_begin, pp_end, Loc,
5554 PPEntityComp(*
this, M));
5563 std::advance(PPI, Half);
5564 if (SourceMgr.isBeforeInTranslationUnit(
5565 TranslateSourceLocation(M, PPI->getEnd()), Loc)) {
5568 Count = Count - Half - 1;
5575 return findNextPreprocessedEntity(SLocMapI);
5582 std::pair<unsigned, unsigned>
5585 return std::make_pair(0,0);
5586 assert(!SourceMgr.isBeforeInTranslationUnit(Range.
getEnd(),Range.
getBegin()));
5589 findPreprocessedEntity(Range.
getBegin(),
false);
5591 return std::make_pair(BeginID, EndID);
5601 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
5603 unsigned LocalIndex = PPInfo.second;
5610 if (SourceMgr.isInFileID(SourceMgr.getFileLoc(Loc), FID))
5619 class HeaderFileInfoVisitor {
5624 explicit HeaderFileInfoVisitor(
const FileEntry *FE) : FE(FE) {}
5633 HeaderFileInfoLookupTable::iterator Pos = Table->find(FE);
5634 if (Pos == Table->end())
5647 HeaderFileInfoVisitor Visitor(FE);
5648 ModuleMgr.visit(Visitor);
5656 using DiagState = DiagnosticsEngine::DiagState;
5667 auto ReadDiagState =
5669 bool IncludeNonPragmaStates) -> DiagnosticsEngine::DiagState * {
5670 unsigned BackrefID = Record[Idx++];
5672 return DiagStates[BackrefID - 1];
5675 Diag.DiagStates.push_back(BasedOn);
5676 DiagState *NewState = &Diag.DiagStates.back();
5677 DiagStates.push_back(NewState);
5678 unsigned Size = Record[Idx++];
5679 assert(Idx + Size * 2 <= Record.size() &&
5680 "Invalid data, not enough diag/map pairs");
5682 unsigned DiagID = Record[Idx++];
5685 if (!NewMapping.
isPragma() && !IncludeNonPragmaStates)
5698 Mapping = NewMapping;
5704 DiagState *FirstState;
5709 FirstState = Diag.DiagStatesByLoc.FirstDiagState;
5710 DiagStates.push_back(FirstState);
5713 assert(Record[1] == 0 &&
5714 "Invalid data, unexpected backref in initial state");
5715 Idx = 3 + Record[2] * 2;
5716 assert(Idx < Record.size() &&
5717 "Invalid data, not enough state change pairs in initial state");
5722 unsigned Flags = Record[Idx++];
5724 Initial.SuppressSystemWarnings = Flags & 1; Flags >>= 1;
5725 Initial.ErrorsAsFatal = Flags & 1; Flags >>= 1;
5726 Initial.WarningsAsErrors = Flags & 1; Flags >>= 1;
5727 Initial.EnableAllWarnings = Flags & 1; Flags >>= 1;
5728 Initial.IgnoreAllWarnings = Flags & 1; Flags >>= 1;
5736 .StateTransitions.push_back({FirstState, 0});
5741 FirstState = ReadDiagState(*Diag.DiagStatesByLoc.CurDiagState,
5746 unsigned NumLocations = Record[Idx++];
5747 while (NumLocations--) {
5748 assert(Idx < Record.size() &&
5749 "Invalid data, missing pragma diagnostic states");
5751 auto IDAndOffset = SourceMgr.getDecomposedLoc(Loc);
5752 assert(IDAndOffset.second == 0 &&
"not a start location for a FileID");
5753 unsigned Transitions = Record[Idx++];
5759 auto &F = Diag.DiagStatesByLoc.Files[IDAndOffset.first];
5760 F.StateTransitions.reserve(F.StateTransitions.size() + Transitions);
5761 for (
unsigned I = 0; I != Transitions; ++I) {
5762 unsigned Offset = Record[Idx++];
5764 ReadDiagState(*FirstState, Loc.getLocWithOffset(Offset),
false);
5765 F.StateTransitions.push_back({
State, Offset});
5770 assert(Idx < Record.size() &&
5771 "Invalid data, missing final pragma diagnostic state");
5774 auto *CurState = ReadDiagState(*FirstState, CurStateLoc,
false);
5777 Diag.DiagStatesByLoc.CurDiagState = CurState;
5778 Diag.DiagStatesByLoc.CurDiagStateLoc = CurStateLoc;
5783 auto &
T = Diag.DiagStatesByLoc.Files[NullFile].StateTransitions;
5785 T.push_back({CurState, 0});
5787 T[0].State = CurState;
5796 ASTReader::RecordLocation ASTReader::TypeCursorForIndex(
unsigned Index) {
5798 assert(I != GlobalTypeMap.end() &&
"Corrupted global type map");
5800 return RecordLocation(M, M->TypeOffsets[Index - M->BaseTypeIndex]);
5809 QualType ASTReader::readTypeRecord(
unsigned Index) {
5810 assert(ContextObj &&
"reading type with no AST context");
5812 RecordLocation Loc = TypeCursorForIndex(Index);
5813 BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
5819 ReadingKindTracker ReadingKind(Read_Type, *
this);
5825 DeclsCursor.JumpToBit(Loc.Offset);
5827 unsigned Code = DeclsCursor.ReadCode();
5828 switch ((
TypeCode)DeclsCursor.readRecord(Code, Record)) {
5830 if (Record.size() != 2) {
5831 Error(
"Incorrect encoding of extended qualifier type");
5840 if (Record.size() != 1) {
5841 Error(
"Incorrect encoding of complex type");
5844 QualType ElemType = readType(*Loc.F, Record, Idx);
5849 if (Record.size() != 1) {
5850 Error(
"Incorrect encoding of pointer type");
5853 QualType PointeeType = readType(*Loc.F, Record, Idx);
5858 if (Record.size() != 1) {
5859 Error(
"Incorrect encoding of decayed type");
5862 QualType OriginalType = readType(*Loc.F, Record, Idx);
5864 if (!isa<DecayedType>(DT))
5865 Error(
"Decayed type does not decay");
5870 if (Record.size() != 2) {
5871 Error(
"Incorrect encoding of adjusted type");
5874 QualType OriginalTy = readType(*Loc.F, Record, Idx);
5875 QualType AdjustedTy = readType(*Loc.F, Record, Idx);
5880 if (Record.size() != 1) {
5881 Error(
"Incorrect encoding of block pointer type");
5884 QualType PointeeType = readType(*Loc.F, Record, Idx);
5889 if (Record.size() != 2) {
5890 Error(
"Incorrect encoding of lvalue reference type");
5893 QualType PointeeType = readType(*Loc.F, Record, Idx);
5898 if (Record.size() != 1) {
5899 Error(
"Incorrect encoding of rvalue reference type");
5902 QualType PointeeType = readType(*Loc.F, Record, Idx);
5907 if (Record.size() != 2) {
5908 Error(
"Incorrect encoding of member pointer type");
5911 QualType PointeeType = readType(*Loc.F, Record, Idx);
5912 QualType ClassType = readType(*Loc.F, Record, Idx);
5920 QualType ElementType = readType(*Loc.F, Record, Idx);
5922 unsigned IndexTypeQuals = Record[2];
5924 llvm::APInt Size = ReadAPInt(Record, Idx);
5926 ASM, IndexTypeQuals);
5930 QualType ElementType = readType(*Loc.F, Record, Idx);
5932 unsigned IndexTypeQuals = Record[2];
5937 QualType ElementType = readType(*Loc.F, Record, Idx);
5939 unsigned IndexTypeQuals = Record[2];
5943 ASM, IndexTypeQuals,
5948 if (Record.size() != 3) {
5949 Error(
"incorrect encoding of vector type in AST file");
5953 QualType ElementType = readType(*Loc.F, Record, Idx);
5954 unsigned NumElements = Record[1];
5955 unsigned VecKind = Record[2];
5961 if (Record.size() != 3) {
5962 Error(
"incorrect encoding of extended vector type in AST file");
5966 QualType ElementType = readType(*Loc.F, Record, Idx);
5967 unsigned NumElements = Record[1];
5972 if (Record.size() != 7) {
5973 Error(
"incorrect encoding of no-proto function type");
5976 QualType ResultType = readType(*Loc.F, Record, Idx);
5983 QualType ResultType = readType(*Loc.F, Record, Idx);
5989 static_cast<CallingConv>(Record[4]),
6000 readExceptionSpec(*Loc.F, ExceptionStorage, EPI.
ExceptionSpec, Record, Idx);
6002 unsigned NumParams = Record[Idx++];
6004 for (
unsigned I = 0; I != NumParams; ++I)
6005 ParamTypes.push_back(readType(*Loc.F, Record, Idx));
6008 if (Idx != Record.size()) {
6009 for (
unsigned I = 0; I != NumParams; ++I)
6010 ExtParameterInfos.push_back(
6012 ::getFromOpaqueValue(Record[Idx++]));
6016 assert(Idx == Record.size());
6024 ReadDeclAs<UnresolvedUsingTypenameDecl>(*Loc.F, Record, Idx));
6028 if (Record.size() != 2) {
6029 Error(
"incorrect encoding of typedef type");
6034 QualType Canonical = readType(*Loc.F, Record, Idx);
6035 if (!Canonical.isNull())
6044 if (Record.size() != 1) {
6045 Error(
"incorrect encoding of typeof(type) in AST file");
6048 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
6053 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
6058 QualType BaseType = readType(*Loc.F, Record, Idx);
6059 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
6065 QualType Deduced = readType(*Loc.F, Record, Idx);
6067 bool IsDependent = Deduced.
isNull() ? Record[Idx++] :
false;
6068 return Context.
getAutoType(Deduced, Keyword, IsDependent);
6072 TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx);
6073 QualType Deduced = readType(*Loc.F, Record, Idx);
6074 bool IsDependent = Deduced.
isNull() ? Record[Idx++] :
false;
6080 if (Record.size() != 2) {
6081 Error(
"incorrect encoding of record type");
6085 bool IsDependent = Record[Idx++];
6086 RecordDecl *RD = ReadDeclAs<RecordDecl>(*Loc.F, Record, Idx);
6087 RD = cast_or_null<RecordDecl>(RD->getCanonicalDecl());
6089 const_cast<Type*
>(T.getTypePtr())->setDependent(IsDependent);
6094 if (Record.size() != 2) {
6095 Error(
"incorrect encoding of enum type");
6099 bool IsDependent = Record[Idx++];
6101 = Context.
getEnumType(ReadDeclAs<EnumDecl>(*Loc.F, Record, Idx));
6107 if (Record.size() != 3) {
6108 Error(
"incorrect encoding of attributed type");
6111 QualType modifiedType = readType(*Loc.F, Record, Idx);
6112 QualType equivalentType = readType(*Loc.F, Record, Idx);
6118 if (Record.size() != 1) {
6119 Error(
"incorrect encoding of paren type");
6122 QualType InnerType = readType(*Loc.F, Record, Idx);
6127 if (Record.size() != 2) {
6128 Error(
"incorrect encoding of pack expansion type");
6131 QualType Pattern = readType(*Loc.F, Record, Idx);
6136 NumExpansions = Record[1] - 1;
6144 QualType NamedType = readType(*Loc.F, Record, Idx);
6151 = ReadDeclAs<ObjCInterfaceDecl>(*Loc.F, Record, Idx);
6158 = ReadDeclAs<ObjCTypeParamDecl>(*Loc.F, Record, Idx);
6159 unsigned NumProtos = Record[Idx++];
6161 for (
unsigned I = 0; I != NumProtos; ++I)
6162 Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
6169 unsigned NumTypeArgs = Record[Idx++];
6171 for (
unsigned I = 0; I != NumTypeArgs; ++I)
6172 TypeArgs.push_back(readType(*Loc.F, Record, Idx));
6173 unsigned NumProtos = Record[Idx++];
6175 for (
unsigned I = 0; I != NumProtos; ++I)
6176 Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
6177 bool IsKindOf = Record[Idx++];
6183 QualType Pointee = readType(*Loc.F, Record, Idx);
6189 QualType Parm = readType(*Loc.F, Record, Idx);
6192 cast<TemplateTypeParmType>(Parm),
6198 QualType Parm = readType(*Loc.F, Record, Idx);
6201 cast<TemplateTypeParmType>(Parm),
6206 CXXRecordDecl *D = ReadDeclAs<CXXRecordDecl>(*Loc.F, Record, Idx);
6207 QualType TST = readType(*Loc.F, Record, Idx);
6210 const Type *
T =
nullptr;
6212 if (
const Type *Existing = DI->getTypeForDecl()) {
6220 DI->setTypeForDecl(T);
6227 unsigned Depth = Record[Idx++];
6228 unsigned Index = Record[Idx++];
6229 bool Pack = Record[Idx++];
6231 = ReadDeclAs<TemplateTypeParmDecl>(*Loc.F, Record, Idx);
6239 const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx);
6240 QualType Canon = readType(*Loc.F, Record, Idx);
6250 const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx);
6251 unsigned NumArgs = Record[Idx++];
6253 Args.reserve(NumArgs);
6255 Args.push_back(ReadTemplateArgument(*Loc.F, Record, Idx));
6264 QualType ElementType = readType(*Loc.F, Record, Idx);
6267 unsigned IndexTypeQuals = Record[Idx++];
6270 Expr *NumElts = ReadExpr(*Loc.F);
6271 SourceRange Brackets = ReadSourceRange(*Loc.F, Record, Idx);
6274 IndexTypeQuals, Brackets);
6279 bool IsDependent = Record[Idx++];
6280 TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx);
6282 ReadTemplateArgumentList(Args, *Loc.F, Record, Idx);
6283 QualType Underlying = readType(*Loc.F, Record, Idx);
6294 if (Record.size() != 1) {
6295 Error(
"Incorrect encoding of atomic type");
6298 QualType ValueType = readType(*Loc.F, Record, Idx);
6303 if (Record.size() != 2) {
6304 Error(
"Incorrect encoding of pipe type");
6309 QualType ElementType = readType(*Loc.F, Record, Idx);
6310 unsigned ReadOnly = Record[1];
6311 return Context.getPipeType(ElementType, ReadOnly);
6318 QualType ElementType = readType(*Loc.F, Record, Idx);
6319 Expr *SizeExpr = ReadExpr(*Loc.F);
6320 SourceLocation AttrLoc = ReadSourceLocation(*Loc.F, Record, Idx);
6330 QualType PointeeType = readType(*Loc.F, Record, Idx);
6331 Expr *AddrSpaceExpr = ReadExpr(*Loc.F);
6332 SourceLocation AttrLoc = ReadSourceLocation(*Loc.F, Record, Idx);
6338 llvm_unreachable(
"Invalid TypeCode!");
6349 for (
unsigned I = 0, N = Record[Idx++]; I != N; ++I)
6350 Exceptions.push_back(readType(ModuleFile, Record, Idx));
6355 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6356 ESI.
SourceTemplate = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6358 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6385 : F(&F), Reader(&Reader), Record(Record), Idx(Idx) {}
6390 #define ABSTRACT_TYPELOC(CLASS, PARENT) 6391 #define TYPELOC(CLASS, PARENT) \ 6392 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc); 6393 #include "clang/AST/TypeLocNodes.def" 6458 VisitArrayTypeLoc(TL);
6462 VisitArrayTypeLoc(TL);
6466 VisitArrayTypeLoc(TL);
6469 void TypeLocReader::VisitDependentSizedArrayTypeLoc(
6471 VisitArrayTypeLoc(TL);
6474 void TypeLocReader::VisitDependentAddressSpaceTypeLoc(
6479 range.
setBegin(ReadSourceLocation());
6480 range.
setEnd(ReadSourceLocation());
6485 void TypeLocReader::VisitDependentSizedExtVectorTypeLoc(
6503 Reader->ReadSourceLocation(*F, Record, Idx)));
6505 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i) {
6511 VisitFunctionTypeLoc(TL);
6515 VisitFunctionTypeLoc(TL);
6550 void TypeLocReader::VisitAutoTypeLoc(
AutoTypeLoc TL) {
6554 void TypeLocReader::VisitDeducedTemplateSpecializationTypeLoc(
6563 void TypeLocReader::VisitEnumTypeLoc(
EnumTypeLoc TL) {
6571 range.
setBegin(ReadSourceLocation());
6572 range.
setEnd(ReadSourceLocation());
6588 void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
6593 void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
6598 void TypeLocReader::VisitTemplateSpecializationTypeLoc(
6604 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
6607 Reader->GetTemplateArgumentLocInfo(
6611 void TypeLocReader::VisitParenTypeLoc(
ParenTypeLoc TL) {
6631 void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc(
6639 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I)
6642 Reader->GetTemplateArgumentLocInfo(
6685 void TypeLocReader::VisitPipeTypeLoc(
PipeTypeLoc TL) {
6692 QualType InfoTy = readType(F, Record, Idx);
6696 TypeSourceInfo *TInfo = getContext().CreateTypeSourceInfo(InfoTy);
6704 assert(ContextObj &&
"reading type with no AST context");
6816 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 6817 case PREDEF_TYPE_##Id##_ID: \ 6818 T = Context.SingletonId; \ 6820 #include "clang/Basic/OpenCLImageTypes.def" 6853 assert(!T.
isNull() &&
"Unknown predefined type");
6858 assert(Index < TypesLoaded.size() &&
"Type index out-of-range");
6859 if (TypesLoaded[Index].isNull()) {
6860 TypesLoaded[Index] = readTypeRecord(Index);
6861 if (TypesLoaded[Index].isNull())
6864 TypesLoaded[Index]->setFromAST();
6865 if (DeserializationListener)
6867 TypesLoaded[Index]);
6870 return TypesLoaded[Index].withFastQualifiers(FastQuals);
6874 return GetType(getGlobalTypeID(F, LocalID));
6886 ReadModuleOffsetMap(F);
6890 assert(I != F.
TypeRemap.
end() &&
"Invalid index into type index remap");
6892 unsigned GlobalIndex = LocalIndex + I->second;
6893 return (GlobalIndex << Qualifiers::FastWidth) | FastQuals;
6905 return GetTypeSourceInfo(F, Record, Index);
6909 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
6916 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
6917 SourceLocation EllipsisLoc = ReadSourceLocation(F, Record, Index);
6929 llvm_unreachable(
"unexpected template argument loc");
6938 if (Record[Index++])
6951 unsigned NumArgsAsWritten = Record[Index++];
6953 for (
unsigned i = 0; i != NumArgsAsWritten; ++i)
6954 TemplArgsInfo.
addArgument(ReadTemplateArgumentLoc(F, Record, Index));
6963 if (NumCurrentElementsDeserializing) {
6968 PendingIncompleteDeclChains.push_back(const_cast<Decl*>(D));
6979 if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC) ||
6980 isa<CXXRecordDecl>(DC) || isa<EnumDecl>(DC)) {
6982 if (!getContext().getLangOpts().
CPlusPlus &&
6983 isa<TranslationUnitDecl>(DC)) {
6987 auto *II = Name.getAsIdentifierInfo();
6988 assert(II &&
"non-identifier name in C?");
6989 if (II->isOutOfDate())
6990 updateOutOfDateIdentifier(*II);
6996 auto *DC = cast<DeclContext>(DCDecl);
6998 FindExternalLexicalDecls(
7004 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D))
7005 CTSD->getSpecializedTemplate()->LoadLazySpecializations();
7006 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D))
7007 VTSD->getSpecializedTemplate()->LoadLazySpecializations();
7008 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
7009 if (
auto *Template = FD->getPrimaryTemplate())
7010 Template->LoadLazySpecializations();
7016 RecordLocation Loc = getLocalBitOffset(Offset);
7017 BitstreamCursor &
Cursor = Loc.F->DeclsCursor;
7019 Cursor.JumpToBit(Loc.Offset);
7020 ReadingKindTracker ReadingKind(Read_Decl, *
this);
7023 unsigned Code = Cursor.ReadCode();
7024 unsigned RecCode = Cursor.readRecord(Code, Record);
7026 Error(
"malformed AST file: missing C++ ctor initializers");
7031 return ReadCXXCtorInitializers(*Loc.F, Record, Idx);
7035 assert(ContextObj &&
"reading base specifiers with no AST context");
7038 RecordLocation Loc = getLocalBitOffset(Offset);
7039 BitstreamCursor &
Cursor = Loc.F->DeclsCursor;
7041 Cursor.JumpToBit(Loc.Offset);
7042 ReadingKindTracker ReadingKind(Read_Decl, *
this);
7044 unsigned Code = Cursor.ReadCode();
7045 unsigned RecCode = Cursor.readRecord(Code, Record);
7047 Error(
"malformed AST file: missing C++ base specifiers");
7052 unsigned NumBases = Record[Idx++];
7055 for (
unsigned I = 0; I != NumBases; ++I)
7056 Bases[I] = ReadCXXBaseSpecifier(*Loc.F, Record, Idx);
7066 ReadModuleOffsetMap(F);
7070 assert(I != F.
DeclRemap.
end() &&
"Invalid index into decl index remap");
7072 return LocalID + I->second;
7076 ModuleFile &M)
const {
7089 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
7099 if (Index > DeclsLoaded.size()) {
7100 Error(
"declaration ID out-of-range for AST file");
7104 if (
Decl *D = DeclsLoaded[Index])
7105 return D->getLocation();
7108 DeclCursorForID(ID, Loc);
7165 llvm_unreachable(
"PredefinedDeclIDs unknown enum value");
7169 assert(ContextObj &&
"reading decl with no AST context");
7177 Merged.push_back(ID);
7184 if (Index >= DeclsLoaded.size()) {
7185 assert(0 &&
"declaration ID out-of-range for AST file");
7186 Error(
"declaration ID out-of-range for AST file");
7190 return DeclsLoaded[Index];
7195 return GetExistingDecl(ID);
7199 if (Index >= DeclsLoaded.size()) {
7200 assert(0 &&
"declaration ID out-of-range for AST file");
7201 Error(
"declaration ID out-of-range for AST file");
7205 if (!DeclsLoaded[Index]) {
7207 if (DeserializationListener)
7208 DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);
7211 return DeclsLoaded[Index];
7220 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
7221 ModuleFile *Owner = I->second;
7223 llvm::DenseMap<ModuleFile *, serialization::DeclID>::iterator Pos
7228 return GlobalID - Owner->BaseDeclID + Pos->second;
7234 if (Idx >= Record.size()) {
7235 Error(
"Corrupted AST file");
7239 return getGlobalDeclID(F, Record[Idx++]);
7249 ClearSwitchCaseIDs();
7252 RecordLocation Loc = getLocalBitOffset(Offset);
7253 Loc.F->DeclsCursor.JumpToBit(Loc.Offset);
7254 assert(NumCurrentElementsDeserializing == 0 &&
7255 "should not be called while already deserializing");
7257 return ReadStmtFromStream(*Loc.F);
7266 assert(LexicalDecls.size() % 2 == 0 &&
"expected an even number of entries");
7267 for (
int I = 0, N = LexicalDecls.size(); I != N; I += 2) {
7269 if (!IsKindWeWant(K))
7277 if (PredefsVisited[
ID])
7280 PredefsVisited[
ID] =
true;
7283 if (
Decl *D = GetLocalDecl(*M,
ID)) {
7284 assert(D->getKind() == K &&
"wrong kind for lexical decl");
7291 if (isa<TranslationUnitDecl>(DC)) {
7292 for (
auto Lexical : TULexicalDecls)
7293 Visit(Lexical.first, Lexical.second);
7295 auto I = LexicalDecls.find(DC);
7296 if (I != LexicalDecls.end())
7297 Visit(I->second.first, I->second.second);
7300 ++NumLexicalDeclContextsRead;
7310 DeclIDComp(
ASTReader &Reader, ModuleFile &M) : Reader(Reader), Mod(M) {}
7337 unsigned Offset,
unsigned Length,
7341 llvm::DenseMap<FileID, FileDeclsInfo>::iterator I = FileDeclIDs.find(File);
7342 if (I == FileDeclIDs.end())
7345 FileDeclsInfo &DInfo = I->second;
7346 if (DInfo.Decls.empty())
7353 DeclIDComp DIDComp(*
this, *DInfo.Mod);
7355 BeginIt = std::lower_bound(DInfo.Decls.begin(), DInfo.Decls.end(),
7357 if (BeginIt != DInfo.Decls.begin())
7363 while (BeginIt != DInfo.Decls.begin() &&
7364 GetDecl(getGlobalDeclID(*DInfo.Mod, *BeginIt))
7365 ->isTopLevelDeclInObjCContainer())
7369 EndIt = std::upper_bound(DInfo.Decls.begin(), DInfo.Decls.end(),
7371 if (EndIt != DInfo.Decls.end())
7375 DIt = BeginIt; DIt != EndIt; ++DIt)
7376 Decls.push_back(GetDecl(getGlobalDeclID(*DInfo.Mod, *DIt)));
7383 "DeclContext has no visible decls in storage");
7387 auto It = Lookups.find(DC);
7388 if (It == Lookups.end())
7395 for (
DeclID ID : It->second.Table.find(Name)) {
7398 Decls.push_back(ND);
7401 ++NumVisibleDeclContextsRead;
7402 SetExternalVisibleDeclsForName(DC, Name, Decls);
7403 return !Decls.empty();
7410 auto It = Lookups.find(DC);
7411 assert(It != Lookups.end() &&
7412 "have external visible storage but no lookup tables");
7416 for (
DeclID ID : It->second.Table.findAll()) {
7421 ++NumVisibleDeclContextsRead;
7423 for (DeclsMap::iterator I = Decls.begin(), E = Decls.end(); I != E; ++I) {
7424 SetExternalVisibleDeclsForName(DC, I->first, I->second);
7426 const_cast<DeclContext *
>(DC)->setHasExternalVisibleStorage(
false);
7431 auto I = Lookups.find(Primary);
7432 return I == Lookups.end() ? nullptr : &I->second;
7441 assert(ImplD && Consumer);
7443 for (
auto *I : ImplD->
methods())
7449 void ASTReader::PassInterestingDeclToConsumer(
Decl *D) {
7457 this->Consumer = Consumer;
7460 PassInterestingDeclsToConsumer();
7462 if (DeserializationListener)
7463 DeserializationListener->ReaderInitialized(
this);
7467 std::fprintf(stderr,
"*** AST File Statistics:\n");
7469 unsigned NumTypesLoaded
7470 = TypesLoaded.size() - std::count(TypesLoaded.begin(), TypesLoaded.end(),
7472 unsigned NumDeclsLoaded
7473 = DeclsLoaded.size() - std::count(DeclsLoaded.begin(), DeclsLoaded.end(),
7475 unsigned NumIdentifiersLoaded
7476 = IdentifiersLoaded.size() - std::count(IdentifiersLoaded.begin(),
7477 IdentifiersLoaded.end(),
7479 unsigned NumMacrosLoaded
7480 = MacrosLoaded.size() - std::count(MacrosLoaded.begin(),
7483 unsigned NumSelectorsLoaded
7484 = SelectorsLoaded.size() - std::count(SelectorsLoaded.begin(),
7485 SelectorsLoaded.end(),
7488 if (
unsigned TotalNumSLocEntries = getTotalNumSLocs())
7489 std::fprintf(stderr,
" %u/%u source location entries read (%f%%)\n",
7490 NumSLocEntriesRead, TotalNumSLocEntries,
7491 ((
float)NumSLocEntriesRead/TotalNumSLocEntries * 100));
7492 if (!TypesLoaded.empty())
7493 std::fprintf(stderr,
" %u/%u types read (%f%%)\n",
7494 NumTypesLoaded, (
unsigned)TypesLoaded.size(),
7495 ((float)NumTypesLoaded/TypesLoaded.size() * 100));
7496 if (!DeclsLoaded.empty())
7497 std::fprintf(stderr,
" %u/%u declarations read (%f%%)\n",
7498 NumDeclsLoaded, (
unsigned)DeclsLoaded.size(),
7499 ((float)NumDeclsLoaded/DeclsLoaded.size() * 100));
7500 if (!IdentifiersLoaded.empty())
7501 std::fprintf(stderr,
" %u/%u identifiers read (%f%%)\n",
7502 NumIdentifiersLoaded, (
unsigned)IdentifiersLoaded.size(),
7503 ((float)NumIdentifiersLoaded/IdentifiersLoaded.size() * 100));
7504 if (!MacrosLoaded.empty())
7505 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
7506 NumMacrosLoaded, (
unsigned)MacrosLoaded.size(),
7507 ((float)NumMacrosLoaded/MacrosLoaded.size() * 100));
7508 if (!SelectorsLoaded.empty())
7509 std::fprintf(stderr,
" %u/%u selectors read (%f%%)\n",
7510 NumSelectorsLoaded, (
unsigned)SelectorsLoaded.size(),
7511 ((float)NumSelectorsLoaded/SelectorsLoaded.size() * 100));
7512 if (TotalNumStatements)
7513 std::fprintf(stderr,
" %u/%u statements read (%f%%)\n",
7514 NumStatementsRead, TotalNumStatements,
7515 ((
float)NumStatementsRead/TotalNumStatements * 100));
7517 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
7518 NumMacrosRead, TotalNumMacros,
7519 ((
float)NumMacrosRead/TotalNumMacros * 100));
7520 if (TotalLexicalDeclContexts)
7521 std::fprintf(stderr,
" %u/%u lexical declcontexts read (%f%%)\n",
7522 NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
7523 ((
float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts
7525 if (TotalVisibleDeclContexts)
7526 std::fprintf(stderr,
" %u/%u visible declcontexts read (%f%%)\n",
7527 NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
7528 ((
float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
7530 if (TotalNumMethodPoolEntries)
7531 std::fprintf(stderr,
" %u/%u method pool entries read (%f%%)\n",
7532 NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
7533 ((
float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
7535 if (NumMethodPoolLookups)
7536 std::fprintf(stderr,
" %u/%u method pool lookups succeeded (%f%%)\n",
7537 NumMethodPoolHits, NumMethodPoolLookups,
7538 ((
float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
7539 if (NumMethodPoolTableLookups)
7540 std::fprintf(stderr,
" %u/%u method pool table lookups succeeded (%f%%)\n",
7541 NumMethodPoolTableHits, NumMethodPoolTableLookups,
7542 ((
float)NumMethodPoolTableHits/NumMethodPoolTableLookups
7544 if (NumIdentifierLookupHits)
7545 std::fprintf(stderr,
7546 " %u / %u identifier table lookups succeeded (%f%%)\n",
7547 NumIdentifierLookupHits, NumIdentifierLookups,
7548 (
double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
7551 std::fprintf(stderr,
"\n");
7552 GlobalIndex->printStats();
7555 std::fprintf(stderr,
"\n");
7557 std::fprintf(stderr,
"\n");
7560 template<
typename Key,
typename ModuleFile,
unsigned InitialCapacity>
7561 LLVM_DUMP_METHOD
static void 7564 InitialCapacity> &Map) {
7565 if (Map.begin() == Map.end())
7570 llvm::errs() << Name <<
":\n";
7571 for (
typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
7573 llvm::errs() <<
" " << I->first <<
" -> " << I->second->FileName
7579 llvm::errs() <<
"*** PCH/ModuleFile Remappings:\n";
7581 dumpModuleIDMap(
"Global source location entry map", GlobalSLocEntryMap);
7589 GlobalPreprocessedEntityMap);
7591 llvm::errs() <<
"\n*** PCH/Modules Loaded:";
7592 for (ModuleFile &M : ModuleMgr)
7599 for (ModuleFile &I : ModuleMgr) {
7600 if (llvm::MemoryBuffer *buf = I.Buffer) {
7601 size_t bytes = buf->getBufferSize();
7602 switch (buf->getBufferKind()) {
7603 case llvm::MemoryBuffer::MemoryBuffer_Malloc:
7606 case llvm::MemoryBuffer::MemoryBuffer_MMap:
7620 for (uint64_t
ID : PreloadedDeclIDs) {
7624 PreloadedDeclIDs.clear();
7627 if (!FPPragmaOptions.empty()) {
7628 assert(FPPragmaOptions.size() == 1 &&
"Wrong number of FP_PRAGMA_OPTIONS");
7629 SemaObj->FPFeatures =
FPOptions(FPPragmaOptions[0]);
7632 SemaObj->OpenCLFeatures.copy(OpenCLExtensions);
7633 SemaObj->OpenCLTypeExtMap = OpenCLTypeExtMap;
7634 SemaObj->OpenCLDeclExtMap = OpenCLDeclExtMap;
7640 assert(SemaObj &&
"no Sema to update");
7644 if (!SemaDeclRefs.empty()) {
7645 assert(SemaDeclRefs.size() % 3 == 0);
7646 for (
unsigned I = 0; I != SemaDeclRefs.size(); I += 3) {
7647 if (!SemaObj->StdNamespace)
7648 SemaObj->StdNamespace = SemaDeclRefs[I];
7649 if (!SemaObj->StdBadAlloc)
7650 SemaObj->StdBadAlloc = SemaDeclRefs[I+1];
7651 if (!SemaObj->StdAlignValT)
7652 SemaObj->StdAlignValT = SemaDeclRefs[I+2];
7654 SemaDeclRefs.clear();
7659 if(OptimizeOffPragmaLocation.isValid())
7660 SemaObj->ActOnPragmaOptimize(
false, OptimizeOffPragmaLocation);
7661 if (PragmaMSStructState != -1)
7663 if (PointersToMembersPragmaLocation.isValid()) {
7664 SemaObj->ActOnPragmaMSPointersToMembers(
7666 PragmaMSPointersToMembersState,
7667 PointersToMembersPragmaLocation);
7669 SemaObj->ForceCUDAHostDeviceDepth = ForceCUDAHostDeviceDepth;
7671 if (PragmaPackCurrentValue) {
7675 bool DropFirst =
false;
7676 if (!PragmaPackStack.empty() &&
7677 PragmaPackStack.front().Location.isInvalid()) {
7678 assert(PragmaPackStack.front().Value == SemaObj->PackStack.DefaultValue &&
7679 "Expected a default alignment value");
7680 SemaObj->PackStack.Stack.emplace_back(
7681 PragmaPackStack.front().SlotLabel, SemaObj->PackStack.CurrentValue,
7682 SemaObj->PackStack.CurrentPragmaLocation,
7683 PragmaPackStack.front().PushLocation);
7686 for (
const auto &Entry :
7687 llvm::makeArrayRef(PragmaPackStack).drop_front(DropFirst ? 1 : 0))
7688 SemaObj->PackStack.Stack.emplace_back(Entry.SlotLabel, Entry.Value,
7689 Entry.Location, Entry.PushLocation);
7690 if (PragmaPackCurrentLocation.isInvalid()) {
7691 assert(*PragmaPackCurrentValue == SemaObj->PackStack.DefaultValue &&
7692 "Expected a default alignment value");
7695 SemaObj->PackStack.CurrentValue = *PragmaPackCurrentValue;
7696 SemaObj->PackStack.CurrentPragmaLocation = PragmaPackCurrentLocation;
7705 IdentifierLookupVisitor Visitor(Name, 0,
7706 NumIdentifierLookups,
7707 NumIdentifierLookupHits);
7713 if (PP.getLangOpts().CPlusPlus) {
7714 for (
auto F : ModuleMgr.pch_modules())
7722 if (!loadGlobalIndex()) {
7723 if (GlobalIndex->lookupIdentifier(Name, Hits)) {
7728 ModuleMgr.visit(Visitor, HitsPtr);
7732 markIdentifierUpToDate(II);
7750 ASTIdentifierLookupTable::key_iterator Current;
7754 ASTIdentifierLookupTable::key_iterator
End;
7761 bool SkipModules =
false);
7763 StringRef Next()
override;
7770 : Reader(Reader), Index(Reader.ModuleMgr.size()), SkipModules(SkipModules) {
7774 while (Current == End) {
7780 ModuleFile &F = Reader.ModuleMgr[Index];
7786 Current = IdTable->key_begin();
7787 End = IdTable->key_end();
7792 StringRef
Result = *Current;
7801 std::unique_ptr<IdentifierIterator> Current;
7802 std::unique_ptr<IdentifierIterator> Queued;
7805 ChainedIdentifierIterator(std::unique_ptr<IdentifierIterator> First,
7806 std::unique_ptr<IdentifierIterator> Second)
7807 : Current(std::move(First)), Queued(std::move(Second)) {}
7809 StringRef
Next()
override {
7813 StringRef result = Current->Next();
7814 if (!result.empty())
7819 std::swap(Current, Queued);
7827 if (!loadGlobalIndex()) {
7828 std::unique_ptr<IdentifierIterator> ReaderIter(
7830 std::unique_ptr<IdentifierIterator> ModulesIter(
7831 GlobalIndex->createIdentifierIterator());
7832 return new ChainedIdentifierIterator(std::move(ReaderIter),
7833 std::move(ModulesIter));
7840 namespace serialization {
7845 unsigned PriorGeneration;
7846 unsigned InstanceBits = 0;
7847 unsigned FactoryBits = 0;
7848 bool InstanceHasMoreThanOneDecl =
false;
7849 bool FactoryHasMoreThanOneDecl =
false;
7855 unsigned PriorGeneration)
7856 : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) {}
7866 ++Reader.NumMethodPoolTableLookups;
7869 ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel);
7870 if (Pos == PoolTable->end())
7873 ++Reader.NumMethodPoolTableHits;
7874 ++Reader.NumSelectorsRead;
7878 ++Reader.NumMethodPoolEntriesRead;
7880 if (Reader.DeserializationListener)
7894 return InstanceMethods;
7899 return FactoryMethods;
7906 return InstanceHasMoreThanOneDecl;
7918 for (
unsigned I = 0, N = Methods.size(); I != N; ++I) {
7925 unsigned &Generation = SelectorGeneration[Sel];
7926 unsigned PriorGeneration = Generation;
7927 Generation = getGeneration();
7928 SelectorOutOfDate[Sel] =
false;
7931 ++NumMethodPoolLookups;
7933 ModuleMgr.visit(Visitor);
7939 ++NumMethodPoolHits;
7944 Sema &S = *getSema();
7945 Sema::GlobalMethodPool::iterator Pos
7961 if (SelectorOutOfDate[Sel])
7962 ReadMethodPool(Sel);
7969 for (
unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) {
7971 = dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespaces[I])))
7972 Namespaces.push_back(Namespace);
7977 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
7978 for (
unsigned Idx = 0, N = UndefinedButUsed.size(); Idx != N;) {
7979 NamedDecl *D = cast<NamedDecl>(GetDecl(UndefinedButUsed[Idx++]));
7982 Undefined.insert(std::make_pair(D, Loc));
7989 for (
unsigned Idx = 0, N = DelayedDeleteExprs.size(); Idx != N;) {
7990 FieldDecl *FD = cast<FieldDecl>(GetDecl(DelayedDeleteExprs[Idx++]));
7991 uint64_t Count = DelayedDeleteExprs[Idx++];
7992 for (uint64_t
C = 0;
C < Count; ++
C) {
7995 const bool IsArrayForm = DelayedDeleteExprs[Idx++];
7996 Exprs[FD].push_back(std::make_pair(DeleteLoc, IsArrayForm));
8003 for (
unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) {
8004 VarDecl *Var = dyn_cast_or_null<VarDecl>(GetDecl(TentativeDefinitions[I]));
8006 TentativeDefs.push_back(Var);
8008 TentativeDefinitions.clear();
8013 for (
unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++I) {
8015 = dyn_cast_or_null<DeclaratorDecl>(GetDecl(UnusedFileScopedDecls[I]));
8019 UnusedFileScopedDecls.clear();
8024 for (
unsigned I = 0, N = DelegatingCtorDecls.size(); I != N; ++I) {
8026 = dyn_cast_or_null<CXXConstructorDecl>(GetDecl(DelegatingCtorDecls[I]));
8030 DelegatingCtorDecls.clear();
8034 for (
unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++I) {
8036 = dyn_cast_or_null<TypedefNameDecl>(GetDecl(ExtVectorDecls[I]));
8040 ExtVectorDecls.clear();
8045 for (
unsigned I = 0, N = UnusedLocalTypedefNameCandidates.size(); I != N;
8048 GetDecl(UnusedLocalTypedefNameCandidates[I]));
8052 UnusedLocalTypedefNameCandidates.clear();
8057 if (ReferencedSelectorsData.empty())
8062 unsigned int DataSize = ReferencedSelectorsData.size()-1;
8064 while (I < DataSize) {
8065 Selector Sel = DecodeSelector(ReferencedSelectorsData[I++]);
8068 Sels.push_back(std::make_pair(Sel, SelLoc));
8070 ReferencedSelectorsData.clear();
8075 if (WeakUndeclaredIdentifiers.empty())
8078 for (
unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; ) {
8080 = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
8082 = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
8085 bool Used = WeakUndeclaredIdentifiers[I++];
8088 WeakIDs.push_back(std::make_pair(WeakId, WI));
8090 WeakUndeclaredIdentifiers.clear();
8094 for (
unsigned Idx = 0, N = VTableUses.size(); Idx < N; ) {
8096 VT.
Record = dyn_cast_or_null<CXXRecordDecl>(GetDecl(VTableUses[Idx++]));
8099 VTables.push_back(VT);
8107 for (
unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
8108 ValueDecl *D = cast<ValueDecl>(GetDecl(PendingInstantiations[Idx++]));
8112 Pending.push_back(std::make_pair(D, Loc));
8114 PendingInstantiations.clear();
8118 llvm::MapVector<
const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
8120 for (
unsigned Idx = 0, N = LateParsedTemplates.size(); Idx < N;
8122 FunctionDecl *FD = cast<FunctionDecl>(GetDecl(LateParsedTemplates[Idx++]));
8124 auto LT = llvm::make_unique<LateParsedTemplate>();
8125 LT->D = GetDecl(LateParsedTemplates[Idx++]);
8127 ModuleFile *F = getOwningModuleFile(LT->D);
8128 assert(F &&
"No module");
8130 unsigned TokN = LateParsedTemplates[Idx++];
8131 LT->Toks.reserve(TokN);
8132 for (
unsigned T = 0;
T < TokN; ++
T)
8133 LT->Toks.push_back(ReadToken(*F, LateParsedTemplates, Idx));
8135 LPTMap.insert(std::make_pair(FD, std::move(LT)));
8138 LateParsedTemplates.clear();
8143 ReadMethodPool(Sel);
8147 assert(ID &&
"Non-zero identifier ID required");
8148 assert(ID <= IdentifiersLoaded.size() &&
"identifier ID out of range");
8149 IdentifiersLoaded[ID - 1] = II;
8150 if (DeserializationListener)
8151 DeserializationListener->IdentifierRead(ID, II);
8174 if (NumCurrentElementsDeserializing && !Decls) {
8175 PendingIdentifierInfos[II].append(DeclIDs.begin(), DeclIDs.end());
8179 for (
unsigned I = 0, N = DeclIDs.size(); I != N; ++I) {
8184 PreloadedDeclIDs.push_back(DeclIDs[I]);
8188 NamedDecl *D = cast<NamedDecl>(GetDecl(DeclIDs[I]));
8192 Decls->push_back(D);
8199 pushExternalDeclIntoScope(D, II);
8207 if (IdentifiersLoaded.empty()) {
8208 Error(
"no identifier table in AST file");
8213 if (!IdentifiersLoaded[ID]) {
8215 assert(I != GlobalIdentifierMap.end() &&
"Corrupted global identifier map");
8216 ModuleFile *M = I->second;
8218 const char *Str = M->IdentifierTableData + M->IdentifierOffsets[Index];
8225 const unsigned char *StrLenPtr = (
const unsigned char*) Str - 2;
8226 unsigned StrLen = (((unsigned) StrLenPtr[0])
8227 | (((unsigned) StrLenPtr[1]) << 8)) - 1;
8228 auto &II = PP.getIdentifierTable().get(StringRef(Str, StrLen));
8229 IdentifiersLoaded[
ID] = &II;
8231 if (DeserializationListener)
8232 DeserializationListener->IdentifierRead(ID + 1, &II);
8235 return IdentifiersLoaded[
ID];
8239 return DecodeIdentifierInfo(getGlobalIdentifierID(M, LocalID));
8247 ReadModuleOffsetMap(M);
8252 &&
"Invalid index into identifier index remap");
8254 return LocalID + I->second;
8261 if (MacrosLoaded.empty()) {
8262 Error(
"no macro table in AST file");
8267 if (!MacrosLoaded[ID]) {
8270 assert(I != GlobalMacroMap.end() &&
"Corrupted global macro map");
8271 ModuleFile *M = I->second;
8273 MacrosLoaded[
ID] = ReadMacroRecord(*M, M->MacroOffsets[Index]);
8275 if (DeserializationListener)
8280 return MacrosLoaded[
ID];
8288 ReadModuleOffsetMap(M);
8292 assert(I != M.
MacroRemap.
end() &&
"Invalid index into macro index remap");
8294 return LocalID + I->second;
8303 ReadModuleOffsetMap(M);
8308 &&
"Invalid index into submodule index remap");
8310 return LocalID + I->second;
8315 assert(GlobalID == 0 &&
"Unhandled global submodule ID");
8319 if (GlobalID > SubmodulesLoaded.size()) {
8320 Error(
"submodule ID out of range in AST file");
8328 return getSubmodule(ID);
8334 auto I = GlobalSubmoduleMap.find(getGlobalSubmoduleID(F, ID >> 1));
8335 return I == GlobalSubmoduleMap.end() ? nullptr : I->second;
8338 unsigned IndexFromEnd = ID >> 1;
8339 assert(IndexFromEnd &&
"got reference to unknown module file");
8340 return getModuleManager().pch_modules().end()[-IndexFromEnd];
8355 auto PCHModules = getModuleManager().pch_modules();
8356 auto I = std::find(PCHModules.begin(), PCHModules.end(), F);
8357 assert(I != PCHModules.end() &&
"emitting reference to unknown file");
8358 return (I - PCHModules.end()) << 1;
8363 if (
const Module *M = getSubmodule(ID))
8368 const auto &PCHChain = ModuleMgr.pch_modules();
8369 if (
std::distance(std::begin(PCHChain), std::end(PCHChain))) {
8370 ModuleFile &MF = ModuleMgr.getPrimaryModule();
8372 StringRef FileName = llvm::sys::path::filename(MF.
FileName);
8380 auto I = DefinitionSource.find(FD);
8381 if (I == DefinitionSource.end())
8382 return EK_ReplyHazy;
8383 return I->second ? EK_Never : EK_Always;
8387 return DecodeSelector(getGlobalSelectorID(M, LocalID));
8394 if (ID > SelectorsLoaded.size()) {
8395 Error(
"selector ID out of range in AST file");
8399 if (SelectorsLoaded[ID - 1].getAsOpaquePtr() ==
nullptr) {
8402 assert(I != GlobalSelectorMap.end() &&
"Corrupted global selector map");
8403 ModuleFile &M = *I->second;
8406 SelectorsLoaded[ID - 1] =
8407 Trait.
ReadKey(M.SelectorLookupTableData + M.SelectorOffsets[Idx], 0);
8408 if (DeserializationListener)
8409 DeserializationListener->SelectorRead(ID, SelectorsLoaded[ID - 1]);
8412 return SelectorsLoaded[ID - 1];
8416 return DecodeSelector(ID);
8421 return getTotalNumSelectors() + 1;
8430 ReadModuleOffsetMap(M);
8435 &&
"Invalid index into selector index remap");
8437 return LocalID + I->second;
8464 ReadDeclAs<TemplateDecl>(F, Record, Idx));
8476 GetIdentifierInfo(F, Record, Idx));
8482 llvm_unreachable(
"Invalid NameKind!");
8498 = ReadSourceLocation(F, Record, Idx).getRawEncoding();
8500 = ReadSourceLocation(F, Record, Idx).getRawEncoding();
8505 = ReadSourceLocation(F, Record, Idx).getRawEncoding();
8521 NameInfo.
setName(ReadDeclarationName(F, Record, Idx));
8522 NameInfo.
setLoc(ReadSourceLocation(F, Record, Idx));
8524 ReadDeclarationNameLoc(F, DNLoc, NameInfo.
getName(), Record, Idx);
8530 Info.
QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
8531 unsigned NumTPLists = Record[Idx++];
8536 for (
unsigned i = 0; i != NumTPLists; ++i)
8548 return TemplateName(ReadDeclAs<TemplateDecl>(F, Record, Idx));
8551 unsigned size = Record[Idx++];
8554 Decls.
addDecl(ReadDeclAs<NamedDecl>(F, Record, Idx));
8561 bool hasTemplKeyword = Record[Idx++];
8562 TemplateDecl *Template = ReadDeclAs<TemplateDecl>(F, Record, Idx);
8570 GetIdentifierInfo(F, Record,
8578 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
8580 TemplateName replacement = ReadTemplateName(F, Record, Idx);
8586 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
8598 llvm_unreachable(
"Unhandled template name kind!");
8604 bool Canonicalize) {
8622 ValueDecl *D = ReadDeclAs<ValueDecl>(F, Record, Idx);
8628 llvm::APSInt
Value = ReadAPSInt(Record, Idx);
8637 if (
unsigned NumExpansions = Record[Idx++])
8638 NumTemplateExpansions = NumExpansions - 1;
8644 unsigned NumArgs = Record[Idx++];
8646 for (
unsigned I = 0; I != NumArgs; ++I)
8647 Args[I] = ReadTemplateArgument(F, Record, Idx);
8652 llvm_unreachable(
"Unhandled template argument kind!");
8662 unsigned NumParams = Record[Idx++];
8664 Params.reserve(NumParams);
8666 Params.push_back(ReadDeclAs<NamedDecl>(F, Record, Idx));
8670 getContext(), TemplateLoc, LAngleLoc, Params, RAngleLoc,
nullptr);
8671 return TemplateParams;
8678 unsigned &Idx,
bool Canonicalize) {
8679 unsigned NumTemplateArgs = Record[Idx++];
8680 TemplArgs.reserve(NumTemplateArgs);
8681 while (NumTemplateArgs--)
8682 TemplArgs.push_back(ReadTemplateArgument(F, Record, Idx, Canonicalize));
8688 unsigned NumDecls = Record[Idx++];
8689 Set.
reserve(getContext(), NumDecls);
8690 while (NumDecls--) {
8691 DeclID ID = ReadDeclID(F, Record, Idx);
8700 bool isVirtual =
static_cast<bool>(Record[Idx++]);
8701 bool isBaseOfClass =
static_cast<bool>(Record[Idx++]);
8703 bool inheritConstructors =
static_cast<bool>(Record[Idx++]);
8705 SourceRange Range = ReadSourceRange(F, Record, Idx);
8717 unsigned NumInitializers = Record[Idx++];
8718 assert(NumInitializers &&
"wrote ctor initializers but have no inits");
8720 for (
unsigned i = 0; i != NumInitializers; ++i) {
8722 bool IsBaseVirtual =
false;
8729 TInfo = GetTypeSourceInfo(F, Record, Idx);
8730 IsBaseVirtual = Record[Idx++];
8734 TInfo = GetTypeSourceInfo(F, Record, Idx);
8738 Member = ReadDeclAs<FieldDecl>(F, Record, Idx);
8742 IndirectMember = ReadDeclAs<IndirectFieldDecl>(F, Record, Idx);
8746 SourceLocation MemberOrEllipsisLoc = ReadSourceLocation(F, Record, Idx);
8747 Expr *Init = ReadExpr(F);
8753 BOMInit =
new (Context)
8755 RParenLoc, MemberOrEllipsisLoc);
8757 BOMInit =
new (Context)
8760 BOMInit =
new (Context)
8764 BOMInit =
new (Context)
8766 LParenLoc, Init, RParenLoc);
8768 if (Record[Idx++]) {
8769 unsigned SourceOrder = Record[Idx++];
8773 CtorInitializers[i] = BOMInit;
8776 return CtorInitializers;
8783 unsigned N = Record[Idx++];
8785 for (
unsigned I = 0; I != N; ++I) {
8796 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
8809 const Type *
T = readType(F, Record, Idx).getTypePtrOrNull();
8813 bool Template = Record[Idx++];
8824 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
8838 unsigned N = Record[Idx++];
8840 for (
unsigned I = 0; I != N; ++I) {
8846 SourceRange Range = ReadSourceRange(F, Record, Idx);
8852 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
8853 SourceRange Range = ReadSourceRange(F, Record, Idx);
8854 Builder.
Extend(Context, NS, Range.getBegin(), Range.getEnd());
8860 SourceRange Range = ReadSourceRange(F, Record, Idx);
8861 Builder.
Extend(Context, Alias, Range.getBegin(), Range.getEnd());
8867 bool Template = Record[Idx++];
8871 SourceLocation ColonColonLoc = ReadSourceLocation(F, Record, Idx);
8881 SourceLocation ColonColonLoc = ReadSourceLocation(F, Record, Idx);
8887 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
8888 SourceRange Range = ReadSourceRange(F, Record, Idx);
8889 Builder.
MakeSuper(Context, RD, Range.getBegin(), Range.getEnd());
8908 unsigned BitWidth = Record[Idx++];
8909 unsigned NumWords = llvm::APInt::getNumWords(BitWidth);
8910 llvm::APInt
Result(BitWidth, NumWords, &Record[Idx]);
8917 bool isUnsigned = Record[Idx++];
8918 return llvm::APSInt(ReadAPInt(Record, Idx), isUnsigned);
8923 const llvm::fltSemantics &Sem,
8925 return llvm::APFloat(Sem, ReadAPInt(Record, Idx));
8930 unsigned Len = Record[Idx++];
8931 std::string
Result(Record.data() + Idx, Record.data() + Idx + Len);
8938 std::string
Filename = ReadString(Record, Idx);
8939 ResolveImportedPath(F, Filename);
8945 unsigned Major = Record[Idx++];
8946 unsigned Minor = Record[Idx++];
8947 unsigned Subminor = Record[Idx++];
8963 return Diag(CurrentImportLoc, DiagID);
8967 return Diags.Report(Loc, DiagID);
8973 return PP.getIdentifierTable();
8979 assert((*CurrSwitchCaseStmts)[ID] ==
nullptr &&
8980 "Already have a SwitchCase with this ID");
8981 (*CurrSwitchCaseStmts)[
ID] = SC;
8986 assert((*CurrSwitchCaseStmts)[ID] !=
nullptr &&
"No SwitchCase with this ID");
8987 return (*CurrSwitchCaseStmts)[
ID];
8991 CurrSwitchCaseStmts->clear();
8996 std::vector<RawComment *> Comments;
8999 I = CommentsCursors.begin(),
9000 E = CommentsCursors.end();
9003 BitstreamCursor &
Cursor = I->first;
9009 llvm::BitstreamEntry Entry =
9010 Cursor.advanceSkippingSubblocks(BitstreamCursor::AF_DontPopBlockAtEnd);
9012 switch (Entry.Kind) {
9013 case llvm::BitstreamEntry::SubBlock:
9015 Error(
"malformed block record in AST file");
9017 case llvm::BitstreamEntry::EndBlock:
9019 case llvm::BitstreamEntry::Record:
9032 bool IsTrailingComment = Record[Idx++];
9033 bool IsAlmostTrailingComment = Record[Idx++];
9035 SR, Kind, IsTrailingComment, IsAlmostTrailingComment,
9044 std::sort(Comments.begin(), Comments.end(),
9046 Context.
Comments.addDeserializedComments(Comments);
9051 bool IncludeSystem,
bool Complain,
9056 assert(NumUserInputs <= NumInputs);
9057 unsigned N = IncludeSystem ? NumInputs : NumUserInputs;
9058 for (
unsigned I = 0; I < N; ++I) {
9059 bool IsSystem = I >= NumUserInputs;
9060 InputFile IF = getInputFile(MF, I+1, Complain);
9061 Visitor(IF, IsSystem);
9067 llvm::function_ref<
void(
const FileEntry *FE)> Visitor) {
9069 for (
unsigned I = 0; I < NumInputs; ++I) {
9070 InputFileInfo IFI = readInputFileInfo(MF, I + 1);
9071 if (IFI.TopLevelModuleMap)
9073 if (
auto *FE = getInputFile(MF, I + 1).getFile())
9081 return M->getFullModuleName();
9084 if (ModuleFile *M = getOwningModuleFile(D))
9091 void ASTReader::finishPendingActions() {
9092 while (!PendingIdentifierInfos.empty() ||
9093 !PendingIncompleteDeclChains.empty() || !PendingDeclChains.empty() ||
9094 !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
9095 !PendingUpdateRecords.empty()) {
9098 using TopLevelDeclsMap =
9099 llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2>>;
9100 TopLevelDeclsMap TopLevelDecls;
9102 while (!PendingIdentifierInfos.empty()) {
9105 std::move(PendingIdentifierInfos.back().second);
9106 PendingIdentifierInfos.pop_back();
9108 SetGloballyVisibleDecls(II, DeclIDs, &TopLevelDecls[II]);
9113 for (
unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
9114 markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
9116 PendingIncompleteDeclChains.clear();
9119 for (
unsigned I = 0; I != PendingDeclChains.size(); ++I)
9120 loadPendingDeclChain(PendingDeclChains[I].first, PendingDeclChains[I].second);
9121 PendingDeclChains.clear();
9124 for (TopLevelDeclsMap::iterator TLD = TopLevelDecls.begin(),
9125 TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) {
9127 for (
unsigned I = 0, N = TLD->second.size(); I != N; ++I) {
9128 pushExternalDeclIntoScope(cast<NamedDecl>(TLD->second[I]), II);
9133 for (
unsigned I = 0; I != PendingMacroIDs.size(); ++I) {
9136 GlobalIDs.swap(PendingMacroIDs.begin()[I].second);
9138 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9140 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9141 if (!Info.M->isModule())
9142 resolvePendingMacro(II, Info);
9145 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9147 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9148 if (Info.M->isModule())
9149 resolvePendingMacro(II, Info);
9152 PendingMacroIDs.clear();
9156 while (!PendingDeclContextInfos.empty()) {
9157 PendingDeclContextInfo Info = PendingDeclContextInfos.front();
9158 PendingDeclContextInfos.pop_front();
9159 DeclContext *SemaDC = cast<DeclContext>(GetDecl(Info.SemaDC));
9160 DeclContext *LexicalDC = cast<DeclContext>(GetDecl(Info.LexicalDC));
9161 Info.D->setDeclContextsImpl(SemaDC, LexicalDC, getContext());
9165 while (!PendingUpdateRecords.empty()) {
9166 auto Update = PendingUpdateRecords.pop_back_val();
9167 ReadingKindTracker ReadingKind(Read_Decl, *
this);
9168 loadDeclUpdateRecords(
Update);
9174 assert(PendingFakeDefinitionData.empty() &&
9175 "faked up a class definition but never saw the real one");
9181 for (
Decl *D : PendingDefinitions) {
9182 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
9183 if (
const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) {
9188 if (
auto RD = dyn_cast<CXXRecordDecl>(D)) {
9189 for (
auto *R = getMostRecentExistingDecl(RD); R;
9190 R = R->getPreviousDecl()) {
9192 cast<CXXRecordDecl>(R)->isThisDeclarationADefinition() &&
9193 "declaration thinks it's the definition but it isn't");
9194 cast<CXXRecordDecl>(R)->DefinitionData = RD->DefinitionData;
9201 if (
auto ID = dyn_cast<ObjCInterfaceDecl>(D)) {
9206 for (
auto *R = getMostRecentExistingDecl(
ID); R; R = R->getPreviousDecl())
9207 cast<ObjCInterfaceDecl>(R)->Data =
ID->Data;
9212 if (
auto PD = dyn_cast<ObjCProtocolDecl>(D)) {
9213 for (
auto *R = getMostRecentExistingDecl(PD); R; R = R->getPreviousDecl())
9214 cast<ObjCProtocolDecl>(R)->Data = PD->Data;
9220 for (
auto *R = getMostRecentExistingDecl(RTD); R; R = R->getPreviousDecl())
9221 cast<RedeclarableTemplateDecl>(R)->Common = RTD->Common;
9223 PendingDefinitions.clear();
9229 for (PendingBodiesMap::iterator PB = PendingBodies.begin(),
9230 PBEnd = PendingBodies.end();
9231 PB != PBEnd; ++PB) {
9232 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
9236 if (!getContext().getLangOpts().Modules || !FD->hasBody(Defn)) {
9240 mergeDefinitionVisibility(NonConstDefn, FD);
9242 if (!FD->isLateTemplateParsed() &&
9243 !NonConstDefn->isLateTemplateParsed() &&
9244 FD->getODRHash() != NonConstDefn->getODRHash()) {
9245 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
9252 if (!getContext().getLangOpts().Modules || !MD->
hasBody())
9255 PendingBodies.clear();
9258 for (
auto *ND : PendingMergedDefinitionsToDeduplicate)
9259 getContext().deduplicateMergedDefinitonsFor(ND);
9260 PendingMergedDefinitionsToDeduplicate.clear();
9263 void ASTReader::diagnoseOdrViolations() {
9264 if (PendingOdrMergeFailures.empty() && PendingOdrMergeChecks.empty() &&
9265 PendingFunctionOdrMergeFailures.empty())
9272 auto OdrMergeFailures = std::move(PendingOdrMergeFailures);
9273 PendingOdrMergeFailures.clear();
9274 for (
auto &Merge : OdrMergeFailures) {
9275 Merge.first->buildLookup();
9276 Merge.first->decls_begin();
9277 Merge.first->bases_begin();
9278 Merge.first->vbases_begin();
9279 for (
auto &RecordPair : Merge.second) {
9280 auto *RD = RecordPair.first;
9288 auto FunctionOdrMergeFailures = std::move(PendingFunctionOdrMergeFailures);
9289 PendingFunctionOdrMergeFailures.clear();
9290 for (
auto &Merge : FunctionOdrMergeFailures) {
9291 Merge.first->buildLookup();
9292 Merge.first->decls_begin();
9293 Merge.first->getBody();
9294 for (
auto &FD : Merge.second) {
9307 while (!PendingOdrMergeChecks.empty()) {
9308 NamedDecl *D = PendingOdrMergeChecks.pop_back_val();
9322 for (
auto RI : D->
redecls()) {
9323 if (RI->getLexicalDeclContext() == CanonDef) {
9338 for (
auto *CanonMember : CanonDef->
decls()) {
9339 if (CanonMember->getCanonicalDecl() == DCanon) {
9348 if (
auto *ND = dyn_cast<NamedDecl>(CanonMember))
9350 Candidates.push_back(ND);
9356 if (!isa<TagDecl>(D))
9363 std::string CanonDefModule =
9364 getOwningModuleNameForDiagnostic(cast<Decl>(CanonDef));
9366 << D << getOwningModuleNameForDiagnostic(D)
9367 << CanonDef << CanonDefModule.empty() << CanonDefModule;
9369 if (Candidates.empty())
9370 Diag(cast<Decl>(CanonDef)->getLocation(),
9371 diag::note_module_odr_violation_no_possible_decls) << D;
9373 for (
unsigned I = 0, N = Candidates.size(); I != N; ++I)
9374 Diag(Candidates[I]->getLocation(),
9375 diag::note_module_odr_violation_possible_decl)
9379 DiagnosedOdrMergeFailures.insert(CanonDef);
9383 if (OdrMergeFailures.empty() && FunctionOdrMergeFailures.empty())
9392 auto ComputeQualTypeODRHash = [&Hash](
QualType Ty) {
9398 auto ComputeODRHash = [&Hash](
const Stmt *S) {
9405 auto ComputeSubDeclODRHash = [&Hash](
const Decl *D) {
9413 for (
auto &Merge : OdrMergeFailures) {
9416 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
9419 bool Diagnosed =
false;
9421 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstRecord);
9422 for (
auto &RecordPair : Merge.second) {
9426 if (FirstRecord == SecondRecord)
9429 std::string SecondModule = getOwningModuleNameForDiagnostic(SecondRecord);
9431 auto *FirstDD = FirstRecord->DefinitionData;
9432 auto *SecondDD = RecordPair.second;
9434 assert(FirstDD && SecondDD &&
"Definitions without DefinitionData");
9437 if (FirstDD != SecondDD) {
9438 enum ODRDefinitionDataDifference {
9445 auto ODRDiagError = [FirstRecord, &FirstModule,
9447 ODRDefinitionDataDifference DiffType) {
9448 return Diag(Loc, diag::err_module_odr_violation_definition_data)
9449 << FirstRecord << FirstModule.empty() << FirstModule << Range
9452 auto ODRDiagNote = [&SecondModule,
9454 ODRDefinitionDataDifference DiffType) {
9455 return Diag(Loc, diag::note_module_odr_violation_definition_data)
9456 << SecondModule << Range << DiffType;
9459 unsigned FirstNumBases = FirstDD->NumBases;
9460 unsigned FirstNumVBases = FirstDD->NumVBases;
9461 unsigned SecondNumBases = SecondDD->NumBases;
9462 unsigned SecondNumVBases = SecondDD->NumVBases;
9464 auto GetSourceRange = [](
struct CXXRecordDecl::DefinitionData *DD) {
9465 unsigned NumBases = DD->NumBases;
9467 auto bases = DD->bases();
9469 bases[NumBases - 1].getLocEnd());
9472 if (FirstNumBases != SecondNumBases) {
9473 ODRDiagError(FirstRecord->
getLocation(), GetSourceRange(FirstDD),
9476 ODRDiagNote(SecondRecord->
getLocation(), GetSourceRange(SecondDD),
9483 if (FirstNumVBases != SecondNumVBases) {
9484 ODRDiagError(FirstRecord->
getLocation(), GetSourceRange(FirstDD),
9487 ODRDiagNote(SecondRecord->
getLocation(), GetSourceRange(SecondDD),
9494 auto FirstBases = FirstDD->bases();
9495 auto SecondBases = SecondDD->bases();
9497 for (i = 0; i < FirstNumBases; ++i) {
9498 auto FirstBase = FirstBases[i];
9499 auto SecondBase = SecondBases[i];
9500 if (ComputeQualTypeODRHash(FirstBase.getType()) !=
9501 ComputeQualTypeODRHash(SecondBase.getType())) {
9502 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
9504 << (i + 1) << FirstBase.getType();
9506 SecondBase.getSourceRange(), BaseType)
9507 << (i + 1) << SecondBase.getType();
9511 if (FirstBase.isVirtual() != SecondBase.isVirtual()) {
9512 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
9514 << (i + 1) << FirstBase.isVirtual() << FirstBase.getType();
9516 SecondBase.getSourceRange(), BaseVirtual)
9517 << (i + 1) << SecondBase.isVirtual() << SecondBase.getType();
9521 if (FirstBase.getAccessSpecifierAsWritten() !=
9522 SecondBase.getAccessSpecifierAsWritten()) {
9523 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
9525 << (i + 1) << FirstBase.getType()
9526 << (int)FirstBase.getAccessSpecifierAsWritten();
9528 SecondBase.getSourceRange(), BaseAccess)
9529 << (i + 1) << SecondBase.getType()
9530 << (int)SecondBase.getAccessSpecifierAsWritten();
9535 if (i != FirstNumBases) {
9548 assert(!FirstTemplate == !SecondTemplate &&
9549 "Both pointers should be null or non-null");
9551 enum ODRTemplateDifference {
9554 ParamSingleDefaultArgument,
9555 ParamDifferentDefaultArgument,
9558 if (FirstTemplate && SecondTemplate) {
9559 DeclHashes FirstTemplateHashes;
9560 DeclHashes SecondTemplateHashes;
9562 auto PopulateTemplateParameterHashs =
9563 [&ComputeSubDeclODRHash](DeclHashes &Hashes,
9565 for (
auto *D : TD->getTemplateParameters()->asArray()) {
9566 Hashes.emplace_back(D, ComputeSubDeclODRHash(D));
9570 PopulateTemplateParameterHashs(FirstTemplateHashes, FirstTemplate);
9571 PopulateTemplateParameterHashs(SecondTemplateHashes, SecondTemplate);
9573 assert(FirstTemplateHashes.size() == SecondTemplateHashes.size() &&
9574 "Number of template parameters should be equal.");
9576 auto FirstIt = FirstTemplateHashes.begin();
9577 auto FirstEnd = FirstTemplateHashes.end();
9578 auto SecondIt = SecondTemplateHashes.begin();
9579 for (; FirstIt != FirstEnd; ++FirstIt, ++SecondIt) {
9580 if (FirstIt->second == SecondIt->second)
9583 auto ODRDiagError = [FirstRecord, &FirstModule,
9585 ODRTemplateDifference DiffType) {
9586 return Diag(Loc, diag::err_module_odr_violation_template_parameter)
9587 << FirstRecord << FirstModule.empty() << FirstModule << Range
9590 auto ODRDiagNote = [&SecondModule,
9592 ODRTemplateDifference DiffType) {
9593 return Diag(Loc, diag::note_module_odr_violation_template_parameter)
9594 << SecondModule << Range << DiffType;
9597 const NamedDecl* FirstDecl = cast<NamedDecl>(FirstIt->first);
9598 const NamedDecl* SecondDecl = cast<NamedDecl>(SecondIt->first);
9600 assert(FirstDecl->
getKind() == SecondDecl->getKind() &&
9601 "Parameter Decl's should be the same kind.");
9606 if (FirstName != SecondName) {
9607 const bool FirstNameEmpty =
9608 FirstName.
isIdentifier() && !FirstName.getAsIdentifierInfo();
9609 const bool SecondNameEmpty =
9611 assert((!FirstNameEmpty || !SecondNameEmpty) &&
9612 "Both template parameters cannot be unnamed.");
9614 FirstNameEmpty ? ParamEmptyName : ParamName)
9616 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9617 SecondNameEmpty ? ParamEmptyName : ParamName)
9622 switch (FirstDecl->
getKind()) {
9624 llvm_unreachable(
"Invalid template parameter type.");
9625 case Decl::TemplateTypeParm: {
9626 const auto *FirstParam = cast<TemplateTypeParmDecl>(FirstDecl);
9627 const auto *SecondParam = cast<TemplateTypeParmDecl>(SecondDecl);
9628 const bool HasFirstDefaultArgument =
9629 FirstParam->hasDefaultArgument() &&
9630 !FirstParam->defaultArgumentWasInherited();
9631 const bool HasSecondDefaultArgument =
9632 SecondParam->hasDefaultArgument() &&
9633 !SecondParam->defaultArgumentWasInherited();
9635 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9638 ParamSingleDefaultArgument)
9639 << HasFirstDefaultArgument;
9640 ODRDiagNote(SecondDecl->getLocation(),
9641 SecondDecl->getSourceRange(),
9642 ParamSingleDefaultArgument)
9643 << HasSecondDefaultArgument;
9647 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9648 "Expecting default arguments.");
9651 ParamDifferentDefaultArgument);
9652 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9653 ParamDifferentDefaultArgument);
9657 case Decl::NonTypeTemplateParm: {
9658 const auto *FirstParam = cast<NonTypeTemplateParmDecl>(FirstDecl);
9659 const auto *SecondParam = cast<NonTypeTemplateParmDecl>(SecondDecl);
9660 const bool HasFirstDefaultArgument =
9661 FirstParam->hasDefaultArgument() &&
9662 !FirstParam->defaultArgumentWasInherited();
9663 const bool HasSecondDefaultArgument =
9664 SecondParam->hasDefaultArgument() &&
9665 !SecondParam->defaultArgumentWasInherited();
9667 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9670 ParamSingleDefaultArgument)
9671 << HasFirstDefaultArgument;
9672 ODRDiagNote(SecondDecl->getLocation(),
9673 SecondDecl->getSourceRange(),
9674 ParamSingleDefaultArgument)
9675 << HasSecondDefaultArgument;
9679 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9680 "Expecting default arguments.");
9683 ParamDifferentDefaultArgument);
9684 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9685 ParamDifferentDefaultArgument);
9689 case Decl::TemplateTemplateParm: {
9690 const auto *FirstParam = cast<TemplateTemplateParmDecl>(FirstDecl);
9691 const auto *SecondParam =
9692 cast<TemplateTemplateParmDecl>(SecondDecl);
9693 const bool HasFirstDefaultArgument =
9694 FirstParam->hasDefaultArgument() &&
9695 !FirstParam->defaultArgumentWasInherited();
9696 const bool HasSecondDefaultArgument =
9697 SecondParam->hasDefaultArgument() &&
9698 !SecondParam->defaultArgumentWasInherited();
9700 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9703 ParamSingleDefaultArgument)
9704 << HasFirstDefaultArgument;
9705 ODRDiagNote(SecondDecl->getLocation(),
9706 SecondDecl->getSourceRange(),
9707 ParamSingleDefaultArgument)
9708 << HasSecondDefaultArgument;
9712 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9713 "Expecting default arguments.");
9716 ParamDifferentDefaultArgument);
9717 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9718 ParamDifferentDefaultArgument);
9727 if (FirstIt != FirstEnd) {
9733 DeclHashes FirstHashes;
9734 DeclHashes SecondHashes;
9736 auto PopulateHashes = [&ComputeSubDeclODRHash, FirstRecord](
9738 for (
auto *D : Record->decls()) {
9743 Hashes.emplace_back(D, ComputeSubDeclODRHash(D));
9746 PopulateHashes(FirstHashes, FirstRecord);
9747 PopulateHashes(SecondHashes, SecondRecord);
9765 } FirstDiffType = Other,
9766 SecondDiffType = Other;
9768 auto DifferenceSelector = [](
Decl *D) {
9769 assert(D &&
"valid Decl required");
9773 case Decl::AccessSpec:
9776 return PublicSpecifer;
9778 return PrivateSpecifer;
9780 return ProtectedSpecifer;
9784 llvm_unreachable(
"Invalid access specifier");
9785 case Decl::StaticAssert:
9786 return StaticAssert;
9789 case Decl::CXXMethod:
9790 case Decl::CXXConstructor:
9791 case Decl::CXXDestructor:
9793 case Decl::TypeAlias:
9804 Decl *FirstDecl =
nullptr;
9805 Decl *SecondDecl =
nullptr;
9806 auto FirstIt = FirstHashes.begin();
9807 auto SecondIt = SecondHashes.begin();
9812 while (FirstIt != FirstHashes.end() || SecondIt != SecondHashes.end()) {
9813 if (FirstIt != FirstHashes.end() && SecondIt != SecondHashes.end() &&
9814 FirstIt->second == SecondIt->second) {
9820 FirstDecl = FirstIt == FirstHashes.end() ? nullptr : FirstIt->first;
9821 SecondDecl = SecondIt == SecondHashes.end() ? nullptr : SecondIt->first;
9823 FirstDiffType = FirstDecl ? DifferenceSelector(FirstDecl) : EndOfClass;
9825 SecondDecl ? DifferenceSelector(SecondDecl) : EndOfClass;
9830 if (FirstDiffType == Other || SecondDiffType == Other) {
9835 diag::err_module_odr_violation_different_definitions)
9836 << FirstRecord << FirstModule.empty() << FirstModule;
9844 diag::note_module_odr_violation_different_definitions)
9856 if (FirstDiffType != SecondDiffType) {
9859 if (FirstDiffType == EndOfClass) {
9862 FirstLoc = FirstIt->first->getLocation();
9863 FirstRange = FirstIt->first->getSourceRange();
9865 Diag(FirstLoc, diag::err_module_odr_violation_mismatch_decl)
9866 << FirstRecord << FirstModule.empty() << FirstModule << FirstRange
9871 if (SecondDiffType == EndOfClass) {
9877 Diag(SecondLoc, diag::note_module_odr_violation_mismatch_decl)
9878 << SecondModule << SecondRange << SecondDiffType;
9883 assert(FirstDiffType == SecondDiffType);
9887 enum ODRDeclDifference{
9888 StaticAssertCondition,
9889 StaticAssertMessage,
9890 StaticAssertOnlyMessage,
9893 FieldSingleBitField,
9894 FieldDifferentWidthBitField,
9896 FieldSingleInitializer,
9897 FieldDifferentInitializers,
9905 MethodNumberParameters,
9906 MethodParameterType,
9907 MethodParameterName,
9908 MethodParameterSingleDefaultArgument,
9909 MethodParameterDifferentDefaultArgument,
9914 VarSingleInitializer,
9915 VarDifferentInitializer,
9925 auto ODRDiagError = [FirstRecord, &FirstModule,
this](
9927 return Diag(Loc, diag::err_module_odr_violation_mismatch_decl_diff)
9928 << FirstRecord << FirstModule.empty() << FirstModule << Range
9931 auto ODRDiagNote = [&SecondModule,
this](
9933 return Diag(Loc, diag::note_module_odr_violation_mismatch_decl_diff)
9934 << SecondModule << Range << DiffType;
9937 switch (FirstDiffType) {
9940 case PublicSpecifer:
9941 case PrivateSpecifer:
9942 case ProtectedSpecifer:
9943 llvm_unreachable(
"Invalid diff type");
9945 case StaticAssert: {
9950 Expr *SecondExpr = SecondSA->getAssertExpr();
9951 unsigned FirstODRHash = ComputeODRHash(FirstExpr);
9952 unsigned SecondODRHash = ComputeODRHash(SecondExpr);
9953 if (FirstODRHash != SecondODRHash) {
9954 ODRDiagError(FirstExpr->getLocStart(), FirstExpr->getSourceRange(),
9955 StaticAssertCondition);
9964 assert((FirstStr || SecondStr) &&
"Both messages cannot be empty");
9965 if ((FirstStr && !SecondStr) || (!FirstStr && SecondStr)) {
9979 SecondLoc = SecondSA->getLocStart();
9980 SecondRange = SecondSA->getSourceRange();
9982 ODRDiagError(FirstLoc, FirstRange, StaticAssertOnlyMessage)
9983 << (FirstStr ==
nullptr);
9984 ODRDiagNote(SecondLoc, SecondRange, StaticAssertOnlyMessage)
9985 << (SecondStr ==
nullptr);
9990 if (FirstStr && SecondStr &&
9993 StaticAssertMessage);
9995 StaticAssertMessage);
10002 FieldDecl *FirstField = cast<FieldDecl>(FirstDecl);
10003 FieldDecl *SecondField = cast<FieldDecl>(SecondDecl);
10006 if (FirstII->getName() != SecondII->
getName()) {
10010 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10018 assert(getContext().hasSameType(FirstField->
getType(),
10019 SecondField->getType()));
10022 QualType SecondType = SecondField->getType();
10023 if (ComputeQualTypeODRHash(FirstType) !=
10024 ComputeQualTypeODRHash(SecondType)) {
10027 << FirstII << FirstType;
10028 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10030 << SecondII << SecondType;
10036 const bool IsFirstBitField = FirstField->
isBitField();
10037 const bool IsSecondBitField = SecondField->isBitField();
10038 if (IsFirstBitField != IsSecondBitField) {
10040 FieldSingleBitField)
10041 << FirstII << IsFirstBitField;
10042 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10043 FieldSingleBitField)
10044 << SecondII << IsSecondBitField;
10049 if (IsFirstBitField && IsSecondBitField) {
10051 FieldDifferentWidthBitField)
10053 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10054 FieldDifferentWidthBitField)
10055 << SecondII << SecondField->getBitWidth()->getSourceRange();
10060 const bool IsFirstMutable = FirstField->
isMutable();
10061 const bool IsSecondMutable = SecondField->isMutable();
10062 if (IsFirstMutable != IsSecondMutable) {
10064 FieldSingleMutable)
10065 << FirstII << IsFirstMutable;
10066 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10067 FieldSingleMutable)
10068 << SecondII << IsSecondMutable;
10074 const Expr *SecondInitializer = SecondField->getInClassInitializer();
10075 if ((!FirstInitializer && SecondInitializer) ||
10076 (FirstInitializer && !SecondInitializer)) {
10078 FieldSingleInitializer)
10079 << FirstII << (FirstInitializer !=
nullptr);
10080 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10081 FieldSingleInitializer)
10082 << SecondII << (SecondInitializer !=
nullptr);
10087 if (FirstInitializer && SecondInitializer) {
10088 unsigned FirstInitHash = ComputeODRHash(FirstInitializer);
10089 unsigned SecondInitHash = ComputeODRHash(SecondInitializer);
10090 if (FirstInitHash != SecondInitHash) {
10093 FieldDifferentInitializers)
10095 ODRDiagNote(SecondField->getLocation(),
10096 SecondField->getSourceRange(),
10097 FieldDifferentInitializers)
10113 auto GetMethodTypeForDiagnostics = [](
const CXXMethodDecl* D) {
10114 if (isa<CXXConstructorDecl>(D))
return DiagConstructor;
10115 if (isa<CXXDestructorDecl>(D))
return DiagDestructor;
10118 const CXXMethodDecl *FirstMethod = cast<CXXMethodDecl>(FirstDecl);
10119 const CXXMethodDecl *SecondMethod = cast<CXXMethodDecl>(SecondDecl);
10120 FirstMethodType = GetMethodTypeForDiagnostics(FirstMethod);
10121 SecondMethodType = GetMethodTypeForDiagnostics(SecondMethod);
10123 auto SecondName = SecondMethod->getDeclName();
10124 if (FirstMethodType != SecondMethodType || FirstName != SecondName) {
10127 << FirstMethodType << FirstName;
10128 ODRDiagNote(SecondMethod->getLocation(),
10129 SecondMethod->getSourceRange(), MethodName)
10130 << SecondMethodType << SecondName;
10136 const bool FirstDeleted = FirstMethod->
isDeleted();
10137 const bool SecondDeleted = SecondMethod->isDeleted();
10138 if (FirstDeleted != SecondDeleted) {
10141 << FirstMethodType << FirstName << FirstDeleted;
10143 ODRDiagNote(SecondMethod->getLocation(),
10144 SecondMethod->getSourceRange(), MethodDeleted)
10145 << SecondMethodType << SecondName << SecondDeleted;
10151 const bool SecondVirtual = SecondMethod->isVirtualAsWritten();
10152 const bool FirstPure = FirstMethod->
isPure();
10153 const bool SecondPure = SecondMethod->isPure();
10154 if ((FirstVirtual || SecondVirtual) &&
10155 (FirstVirtual != SecondVirtual || FirstPure != SecondPure)) {
10158 << FirstMethodType << FirstName << FirstPure << FirstVirtual;
10159 ODRDiagNote(SecondMethod->getLocation(),
10160 SecondMethod->getSourceRange(), MethodVirtual)
10161 << SecondMethodType << SecondName << SecondPure << SecondVirtual;
10170 const auto SecondStorage = SecondMethod->getStorageClass();
10171 const bool FirstStatic = FirstStorage ==
SC_Static;
10172 const bool SecondStatic = SecondStorage ==
SC_Static;
10173 if (FirstStatic != SecondStatic) {
10176 << FirstMethodType << FirstName << FirstStatic;
10177 ODRDiagNote(SecondMethod->getLocation(),
10178 SecondMethod->getSourceRange(), MethodStatic)
10179 << SecondMethodType << SecondName << SecondStatic;
10184 const bool FirstVolatile = FirstMethod->
isVolatile();
10185 const bool SecondVolatile = SecondMethod->isVolatile();
10186 if (FirstVolatile != SecondVolatile) {
10189 << FirstMethodType << FirstName << FirstVolatile;
10190 ODRDiagNote(SecondMethod->getLocation(),
10191 SecondMethod->getSourceRange(), MethodVolatile)
10192 << SecondMethodType << SecondName << SecondVolatile;
10197 const bool FirstConst = FirstMethod->
isConst();
10198 const bool SecondConst = SecondMethod->isConst();
10199 if (FirstConst != SecondConst) {
10202 << FirstMethodType << FirstName << FirstConst;
10203 ODRDiagNote(SecondMethod->getLocation(),
10204 SecondMethod->getSourceRange(), MethodConst)
10205 << SecondMethodType << SecondName << SecondConst;
10211 const bool SecondInline = SecondMethod->isInlineSpecified();
10212 if (FirstInline != SecondInline) {
10215 << FirstMethodType << FirstName << FirstInline;
10216 ODRDiagNote(SecondMethod->getLocation(),
10217 SecondMethod->getSourceRange(), MethodInline)
10218 << SecondMethodType << SecondName << SecondInline;
10223 const unsigned FirstNumParameters = FirstMethod->
param_size();
10224 const unsigned SecondNumParameters = SecondMethod->param_size();
10225 if (FirstNumParameters != SecondNumParameters) {
10228 << FirstMethodType << FirstName << FirstNumParameters;
10229 ODRDiagNote(SecondMethod->getLocation(),
10230 SecondMethod->getSourceRange(), MethodNumberParameters)
10231 << SecondMethodType << SecondName << SecondNumParameters;
10237 bool ParameterMismatch =
false;
10238 for (
unsigned I = 0; I < FirstNumParameters; ++I) {
10240 const ParmVarDecl *SecondParam = SecondMethod->getParamDecl(I);
10244 if (FirstParamType != SecondParamType &&
10245 ComputeQualTypeODRHash(FirstParamType) !=
10246 ComputeQualTypeODRHash(SecondParamType)) {
10251 << FirstMethodType << FirstName << (I + 1) << FirstParamType
10252 <<
true << ParamDecayedType->getOriginalType();
10256 << FirstMethodType << FirstName << (I + 1) << FirstParamType
10262 ODRDiagNote(SecondMethod->getLocation(),
10263 SecondMethod->getSourceRange(), MethodParameterType)
10264 << SecondMethodType << SecondName << (I + 1)
10265 << SecondParamType <<
true 10266 << ParamDecayedType->getOriginalType();
10268 ODRDiagNote(SecondMethod->getLocation(),
10269 SecondMethod->getSourceRange(), MethodParameterType)
10270 << SecondMethodType << SecondName << (I + 1)
10271 << SecondParamType <<
false;
10273 ParameterMismatch =
true;
10279 if (FirstParamName != SecondParamName) {
10282 << FirstMethodType << FirstName << (I + 1) << FirstParamName;
10283 ODRDiagNote(SecondMethod->getLocation(),
10284 SecondMethod->getSourceRange(), MethodParameterName)
10285 << SecondMethodType << SecondName << (I + 1) << SecondParamName;
10286 ParameterMismatch =
true;
10292 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
10295 MethodParameterSingleDefaultArgument)
10296 << FirstMethodType << FirstName << (I + 1)
10297 << (FirstInit ==
nullptr)
10299 ODRDiagNote(SecondMethod->getLocation(),
10300 SecondMethod->getSourceRange(),
10301 MethodParameterSingleDefaultArgument)
10302 << SecondMethodType << SecondName << (I + 1)
10303 << (SecondInit ==
nullptr)
10305 ParameterMismatch =
true;
10309 if (FirstInit && SecondInit &&
10310 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
10313 MethodParameterDifferentDefaultArgument)
10314 << FirstMethodType << FirstName << (I + 1)
10316 ODRDiagNote(SecondMethod->getLocation(),
10317 SecondMethod->getSourceRange(),
10318 MethodParameterDifferentDefaultArgument)
10319 << SecondMethodType << SecondName << (I + 1)
10321 ParameterMismatch =
true;
10327 if (ParameterMismatch) {
10339 auto SecondName = SecondTD->getDeclName();
10340 if (FirstName != SecondName) {
10343 << (FirstDiffType == TypeAlias) << FirstName;
10344 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
10346 << (FirstDiffType == TypeAlias) << SecondName;
10352 QualType SecondType = SecondTD->getUnderlyingType();
10353 if (ComputeQualTypeODRHash(FirstType) !=
10354 ComputeQualTypeODRHash(SecondType)) {
10357 << (FirstDiffType == TypeAlias) << FirstName << FirstType;
10358 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
10360 << (FirstDiffType == TypeAlias) << SecondName << SecondType;
10367 VarDecl *FirstVD = cast<VarDecl>(FirstDecl);
10368 VarDecl *SecondVD = cast<VarDecl>(SecondDecl);
10370 auto SecondName = SecondVD->getDeclName();
10371 if (FirstName != SecondName) {
10375 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10383 QualType SecondType = SecondVD->getType();
10384 if (ComputeQualTypeODRHash(FirstType) !=
10385 ComputeQualTypeODRHash(SecondType)) {
10388 << FirstName << FirstType;
10389 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10391 << SecondName << SecondType;
10397 const Expr *SecondInit = SecondVD->getInit();
10398 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
10400 VarSingleInitializer)
10401 << FirstName << (FirstInit ==
nullptr)
10403 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10404 VarSingleInitializer)
10405 << SecondName << (SecondInit ==
nullptr)
10411 if (FirstInit && SecondInit &&
10412 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
10414 VarDifferentInitializer)
10416 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10417 VarDifferentInitializer)
10423 const bool FirstIsConstexpr = FirstVD->
isConstexpr();
10424 const bool SecondIsConstexpr = SecondVD->isConstexpr();
10425 if (FirstIsConstexpr != SecondIsConstexpr) {
10428 << FirstName << FirstIsConstexpr;
10429 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10431 << SecondName << SecondIsConstexpr;
10438 FriendDecl *FirstFriend = cast<FriendDecl>(FirstDecl);
10439 FriendDecl *SecondFriend = cast<FriendDecl>(SecondDecl);
10442 NamedDecl *SecondND = SecondFriend->getFriendDecl();
10447 if (FirstND && SecondND) {
10451 ODRDiagNote(SecondFriend->getFriendLoc(),
10452 SecondFriend->getSourceRange(), FriendFunction)
10459 if (FirstTSI && SecondTSI) {
10462 assert(ComputeQualTypeODRHash(FirstFriendType) !=
10463 ComputeQualTypeODRHash(SecondFriendType));
10466 << FirstFriendType;
10467 ODRDiagNote(SecondFriend->getFriendLoc(),
10468 SecondFriend->getSourceRange(), FriendType)
10469 << SecondFriendType;
10475 FriendTypeFunction)
10476 << (FirstTSI ==
nullptr);
10477 ODRDiagNote(SecondFriend->getFriendLoc(),
10478 SecondFriend->getSourceRange(), FriendTypeFunction)
10479 << (SecondTSI ==
nullptr);
10490 diag::err_module_odr_violation_mismatch_decl_unknown)
10491 << FirstRecord << FirstModule.empty() << FirstModule << FirstDiffType
10494 diag::note_module_odr_violation_mismatch_decl_unknown)
10495 << SecondModule << FirstDiffType << SecondDecl->
getSourceRange();
10506 Diag(Merge.first->getLocation(),
10507 diag::err_module_odr_violation_different_instantiations)
10513 for (
auto &Merge : FunctionOdrMergeFailures) {
10514 enum ODRFunctionDifference {
10518 ParameterSingleDefaultArgument,
10519 ParameterDifferentDefaultArgument,
10524 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstFunction);
10526 bool Diagnosed =
false;
10527 for (
auto &SecondFunction : Merge.second) {
10529 if (FirstFunction == SecondFunction)
10532 std::string SecondModule =
10533 getOwningModuleNameForDiagnostic(SecondFunction);
10535 auto ODRDiagError = [FirstFunction, &FirstModule,
10537 ODRFunctionDifference DiffType) {
10538 return Diag(Loc, diag::err_module_odr_violation_function)
10539 << FirstFunction << FirstModule.empty() << FirstModule << Range
10544 ODRFunctionDifference DiffType) {
10545 return Diag(Loc, diag::note_module_odr_violation_function)
10546 << SecondModule << Range << DiffType;
10549 if (ComputeQualTypeODRHash(FirstFunction->
getReturnType()) !=
10550 ComputeQualTypeODRHash(SecondFunction->getReturnType())) {
10554 ODRDiagNote(SecondFunction->getReturnTypeSourceRange().getBegin(),
10555 SecondFunction->getReturnTypeSourceRange(), ReturnType)
10556 << SecondFunction->getReturnType();
10561 assert(FirstFunction->
param_size() == SecondFunction->param_size() &&
10562 "Merged functions with different number of parameters");
10564 auto ParamSize = FirstFunction->
param_size();
10565 bool ParameterMismatch =
false;
10566 for (
unsigned I = 0; I < ParamSize; ++I) {
10568 auto *SecondParam = SecondFunction->getParamDecl(I);
10570 assert(getContext().hasSameType(FirstParam->getType(),
10571 SecondParam->getType()) &&
10572 "Merged function has different parameter types.");
10574 if (FirstParam->getDeclName() != SecondParam->getDeclName()) {
10575 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
10577 << I + 1 << FirstParam->getDeclName();
10578 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
10580 << I + 1 << SecondParam->getDeclName();
10581 ParameterMismatch =
true;
10585 QualType FirstParamType = FirstParam->getType();
10586 QualType SecondParamType = SecondParam->getType();
10587 if (FirstParamType != SecondParamType &&
10588 ComputeQualTypeODRHash(FirstParamType) !=
10589 ComputeQualTypeODRHash(SecondParamType)) {
10592 ODRDiagError(FirstParam->getLocation(),
10593 FirstParam->getSourceRange(), ParameterType)
10594 << (I + 1) << FirstParamType <<
true 10595 << ParamDecayedType->getOriginalType();
10597 ODRDiagError(FirstParam->getLocation(),
10598 FirstParam->getSourceRange(), ParameterType)
10599 << (I + 1) << FirstParamType <<
false;
10604 ODRDiagNote(SecondParam->getLocation(),
10605 SecondParam->getSourceRange(), ParameterType)
10606 << (I + 1) << SecondParamType <<
true 10607 << ParamDecayedType->getOriginalType();
10609 ODRDiagNote(SecondParam->getLocation(),
10610 SecondParam->getSourceRange(), ParameterType)
10611 << (I + 1) << SecondParamType <<
false;
10613 ParameterMismatch =
true;
10617 const Expr *FirstInit = FirstParam->getInit();
10618 const Expr *SecondInit = SecondParam->getInit();
10619 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
10620 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
10621 ParameterSingleDefaultArgument)
10622 << (I + 1) << (FirstInit ==
nullptr)
10624 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
10625 ParameterSingleDefaultArgument)
10626 << (I + 1) << (SecondInit ==
nullptr)
10628 ParameterMismatch =
true;
10632 if (FirstInit && SecondInit &&
10633 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
10634 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
10635 ParameterDifferentDefaultArgument)
10637 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
10638 ParameterDifferentDefaultArgument)
10640 ParameterMismatch =
true;
10644 assert(ComputeSubDeclODRHash(FirstParam) ==
10645 ComputeSubDeclODRHash(SecondParam) &&
10646 "Undiagnosed parameter difference.");
10649 if (ParameterMismatch) {
10658 ODRDiagNote(SecondFunction->getLocation(),
10659 SecondFunction->getSourceRange(), FunctionBody);
10663 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
10668 if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get())
10669 ReadTimer->startTimer();
10673 assert(NumCurrentElementsDeserializing &&
10674 "FinishedDeserializing not paired with StartedDeserializing");
10675 if (NumCurrentElementsDeserializing == 1) {
10678 finishPendingActions();
10680 --NumCurrentElementsDeserializing;
10682 if (NumCurrentElementsDeserializing == 0) {
10684 while (!PendingExceptionSpecUpdates.empty()) {
10685 auto Updates = std::move(PendingExceptionSpecUpdates);
10686 PendingExceptionSpecUpdates.clear();
10688 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
10690 auto ESI = FPT->getExtProtoInfo().ExceptionSpec;
10691 if (
auto *Listener = getContext().getASTMutationListener())
10692 Listener->ResolvedExceptionSpec(cast<FunctionDecl>(
Update.second));
10693 for (
auto *Redecl :
Update.second->redecls())
10694 getContext().adjustExceptionSpec(cast<FunctionDecl>(Redecl), ESI);
10699 ReadTimer->stopTimer();
10701 diagnoseOdrViolations();
10706 PassInterestingDeclsToConsumer();
10713 auto It = PendingFakeLookupResults.find(II);
10714 if (It != PendingFakeLookupResults.end()) {
10715 for (
auto *ND : It->second)
10716 SemaObj->IdResolver.RemoveDecl(ND);
10720 It->second.clear();
10724 if (SemaObj->IdResolver.tryAddTopLevelDecl(D, Name) && SemaObj->TUScope) {
10725 SemaObj->TUScope->AddDecl(D);
10726 }
else if (SemaObj->TUScope) {
10730 if (std::find(SemaObj->IdResolver.begin(Name),
10731 SemaObj->IdResolver.end(), D) != SemaObj->IdResolver.end())
10732 SemaObj->TUScope->AddDecl(D);
10738 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
10739 StringRef isysroot,
bool DisableValidation,
10740 bool AllowASTWithCompilerErrors,
10741 bool AllowConfigurationMismatch,
bool ValidateSystemInputs,
10742 bool UseGlobalIndex,
10743 std::unique_ptr<llvm::Timer> ReadTimer)
10744 : Listener(DisableValidation
10747 SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()),
10748 PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()), PP(PP),
10749 ContextObj(Context),
10750 ModuleMgr(PP.getFileManager(), PP.getPCMCache(), PCHContainerRdr,
10751 PP.getHeaderSearchInfo()),
10752 PCMCache(PP.getPCMCache()), DummyIdResolver(PP),
10753 ReadTimer(
std::move(ReadTimer)), isysroot(isysroot),
10754 DisableValidation(DisableValidation),
10755 AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
10756 AllowConfigurationMismatch(AllowConfigurationMismatch),
10757 ValidateSystemInputs(ValidateSystemInputs),
10758 UseGlobalIndex(UseGlobalIndex), CurrSwitchCaseStmts(&SwitchCaseStmts) {
10761 for (
const auto &Ext : Extensions) {
10762 auto BlockName = Ext->getExtensionMetadata().BlockName;
10763 auto Known = ModuleFileExtensions.find(BlockName);
10764 if (Known != ModuleFileExtensions.end()) {
10765 Diags.
Report(diag::warn_duplicate_module_file_extension)
10770 ModuleFileExtensions.insert({BlockName, Ext});
10775 if (OwnsDeserializationListener)
10776 delete DeserializationListener;
10780 return SemaObj ? SemaObj->
IdResolver : DummyIdResolver;
10784 unsigned AbbrevID) {
10787 return Cursor.readRecord(AbbrevID, Record);
llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx)
Read an integral value.
Decl * GetExistingDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
unsigned IsAvailable
Whether this module is available in the current translation unit.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
void setSourceOrder(int Pos)
Set the source order of this initializer.
Defines the clang::ASTContext interface.
The ObjC 'SEL' type.
static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts, const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts, StringRef ExistingModuleCachePath)
Determine whether the given AST file is acceptable to load into a translation unit with the given lan...
const FileEntry * OrigEntry
Reference to the file entry representing this ContentCache.
void updateOutOfDateSelector(Selector Sel) override
Load the contents of the global method pool for a given selector if necessary.
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override
Finds all the visible declarations with a given name.
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons...
Record code for the preprocessor options table.
std::vector< unsigned > PreloadIdentifierOffsets
Offsets of identifiers that we're going to preload within IdentifierTableData.
SmallVector< UnresolvedExportDecl, 2 > UnresolvedExports
The set of export declarations that have yet to be resolved.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
static const Decl * getCanonicalDecl(const Decl *D)
The client can handle an AST file that cannot load because it was built with a different version of C...
void setInfo(const DeclarationNameLoc &Info)
An instance of this class is created to represent a function declaration or definition.
ASTReader(Preprocessor &PP, ASTContext *Context, const PCHContainerReader &PCHContainerRdr, ArrayRef< std::shared_ptr< ModuleFileExtension >> Extensions, StringRef isysroot="", bool DisableValidation=false, bool AllowASTWithCompilerErrors=false, bool AllowConfigurationMismatch=false, bool ValidateSystemInputs=false, bool UseGlobalIndex=true, std::unique_ptr< llvm::Timer > ReadTimer={})
Load the AST file and validate its contents against the given Preprocessor.
ASTFileSignature Signature
The module signature.
std::string Name
The name of this module.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Source range/offset of a preprocessed entity.
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...
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.
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.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
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)
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
TypedefDecl * getCFConstantStringDecl() const
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
static hash_value_type ComputeHash(Selector Sel)
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system...
static bool checkTargetOptions(const TargetOptions &TargetOpts, const TargetOptions &ExistingTargetOpts, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true)
Compare the given set of target options against an existing set of target options.
A (possibly-)qualified type.
static LLVM_DUMP_METHOD void dumpModuleIDMap(StringRef Name, const ContinuousRangeMap< Key, ModuleFile *, InitialCapacity > &Map)
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines)
Receives the preprocessor options.
static void addMethodsToPool(Sema &S, ArrayRef< ObjCMethodDecl *> Methods, ObjCMethodList &List)
Add the given set of methods to the method list.
void * getAsOpaquePtr() const
CtorInitializerType
The different kinds of data that can occur in a CtorInitializer.
The '_Float16' type.
void setChangedSinceDeserialization()
Note that this identifier has changed since it was loaded from an AST file.
void AddTokenToBody(const Token &Tok)
Add the specified token to the replacement text for the macro.
void setStarLoc(SourceLocation Loc)
NameKind
NameKind - The kind of name this object contains.
The macro directives history for a particular identifier.
Represents a version number in the form major[.minor[.subminor[.build]]].
static bool startsWithASTFileMagic(BitstreamCursor &Stream)
Whether Stream starts with the AST/PCH file magic number 'CPCH'.
void SetIdentifierInfo(unsigned ID, IdentifierInfo *II)
virtual bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule)
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Implements support for file system lookup, file system caching, and directory search management...
The 'unsigned int' type.
The (signed) 'long long' type.
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
virtual void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind)
This is called for each AST file loaded.
A simple structure that captures a vtable use for the purposes of the ExternalSemaSource.
SourceManager & getSourceManager() const
bool operator()(ModuleFile &M)
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
const TypeClass * getTypePtr() const
This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes...
Defines the clang::FileManager interface and associated types.
time_t getModificationTime() const
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...
virtual StringRef ExtractPCH(llvm::MemoryBufferRef Buffer) const =0
Returns the serialized AST inside the PCH container Buffer.
SourceRange getBraceRange() const
ObjCXXARCStandardLibraryKind
Enumerate the kinds of standard library that.
This header is part of the module (for layering purposes) but should be textually included...
The 'bool' or '_Bool' type.
void setKWLoc(SourceLocation Loc)
void setRParenLoc(SourceLocation Loc)
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Stmt - This represents one statement.
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...
Expr * getBitWidth() const
void setLAngleLoc(SourceLocation Loc)
bool getEnableAllWarnings() const
void AddQualType(QualType T)
void setExceptionSpecRange(SourceRange R)
SanitizerSet Sanitize
Set of enabled sanitizers.
SourceLocation DirectImportLoc
The source location where the module was explicitly or implicitly imported in the local translation u...
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "C"...
ControlRecordTypes
Record types that occur within the control block.
void addTopHeaderFilename(StringRef Filename)
Add a top-level header filename associated with this module.
llvm::MemoryBuffer * Buffer
The memory buffer that stores the data associated with this AST file, owned by the PCMCache in the Mo...
unsigned Generation
The generation of which this module file is a part.
void ReadComments() override
Loads comments ranges.
std::vector< UnresolvedConflict > UnresolvedConflicts
The list of conflicts for which the module-id has not yet been resolved.
C Language Family Type Representation.
Defines the SourceManager interface.
The 'unknown any' placeholder type.
void setWrittenWidthSpec(TypeSpecifierWidth written)
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
RawCommentList Comments
All comments in this translation unit.
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, uint32_t Raw) const
Read a source location from raw form.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getEnumType(const EnumDecl *Decl) const
Defines the clang::Module class, which describes a module in the source code.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
Decl - This represents one declaration (or definition), e.g.
SmallVector< uint64_t, 4 > PreloadSLocEntries
SLocEntries that we're going to preload.
Module * getCurrentModule()
Retrieves the module that we're currently building, if any.
TagDecl * getDecl() const
CanQualType ObjCBuiltinSelTy
RetTy Visit(TypeLoc TyLoc)
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.
Selector getObjCSelector() const
getObjCSelector - Get the Objective-C selector stored in this declaration name.
void VisitFunctionTypeLoc(FunctionTypeLoc)
ModuleKind Kind
The type of this module.
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
Defines the C++ template declaration subclasses.
Describes a source location entry (SLocEntry) for a macro expansion.
std::vector< std::string > Includes
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts, const PreprocessorOptions &ExistingPPOpts, DiagnosticsEngine *Diags, FileManager &FileMgr, std::string &SuggestedPredefines, const LangOptions &LangOpts, bool Validate=true)
Check the preprocessor options deserialized from the control block against the preprocessor options i...
void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl *> &Decls) override
Read the set of delegating constructors known to the external Sema source.
An LValueReferenceType record.
The placeholder type for builtin functions.
Defines the clang::MacroInfo and clang::MacroDirective classes.
const FileEntry * getASTFile() const
The serialized AST file for this module, if one was created.
Defines types useful for describing an Objective-C runtime.
Specifies the submodules that are imported by this submodule.
std::string ModuleName
The name of the module.
void ReadTentativeDefinitions(SmallVectorImpl< VarDecl *> &TentativeDefs) override
Read the set of tentative definitions known to the external Sema source.
CanQualType ARCUnbridgedCastTy
A record that stores the set of declarations that are lexically stored within a given DeclContext...
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
The module file is out-of-date.
Specifies an umbrella directory.
The base class of the type hierarchy.
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
IdentifierInfo * getLocalIdentifier(ModuleFile &M, unsigned LocalID)
DiagnosticsEngine & getDiagnostics() const
unsigned LocalNumObjCCategoriesInMap
The number of redeclaration info entries in ObjCCategoriesMap.
void setHasLineDirectives()
Set the flag that indicates that this FileID has line table entries associated with it...
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
#define CHECK_TARGET_OPT(Field, Name)
A SubstTemplateTypeParmType record.
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void setTemplateKeywordLoc(SourceLocation Loc)
void setFlag(TokenFlags Flag)
Set the specified flag.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamespaceDecl - Represent a C++ namespace.
Wrapper for source info for typedefs.
static void markIdentifierFromAST(ASTReader &Reader, IdentifierInfo &II)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
A container of type source information.
RefQualifierKind RefQualifier
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
uint64_t GlobalBitOffset
The global bit offset (or base) of this module.
bool isDeclInLexicalTraversal(const Decl *D) const
Determine whether the given declaration is stored in the list of declarations lexically within this c...
Record code for enabled OpenCL extensions.
Record code for the module build directory.
SmallVector< ObjCMethodDecl *, 2 > Instance
Floating point control options.
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
SourceLocation getLocStart() const LLVM_READONLY
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.
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
An UnresolvedUsingType record.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
bool getSuppressSystemWarnings() const
bool factoryHasMoreThanOneDecl() const
Wrapper for source info for pointers decayed from arrays and functions.
ASTFileSignature Signature
The signature of the module file, which may be used instead of the size and modification time to iden...
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
Represents a C++ constructor within a class.
The 'float' type.
An IncompleteArrayType record.
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
The internal '__type_pack_element' template.
diag::Severity getExtensionHandlingBehavior() const
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.
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
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.
size_t param_size() const
bool RelocatablePCH
Whether this precompiled header is a relocatable PCH file.
CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a C++ base specifier.
ARC's unbridged-cast placeholder type.
The client can handle an AST file that cannot load because it is out-of-date relative to its input fi...
The '__int128_t' type.
QualType withFastQualifiers(unsigned TQs) const
unsigned NumPreprocessedEntities
The C++ 'char32_t' type.
An identifier, stored as an IdentifierInfo*.
The internal '__builtin_va_list' typedef.
The stack of open #ifs/#ifdefs recorded in a preamble.
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.
Manages the set of modules loaded by an AST reader.
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
static Qualifiers fromOpaqueValue(unsigned opaque)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
Record code for #pragma pack options.
A block with unhashed content.
QualType getReturnType() const
std::string ImplicitPTHInclude
The implicit PTH input included at the start of the translation unit, or empty.
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
Wrapper for source info for member pointers.
void VisitArrayTypeLoc(ArrayTypeLoc)
Options for controlling the target.
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing)...
const T * getAs() const
Member-template getAs<specific type>'.
Record code for declarations associated with OpenCL extensions.
void CompleteRedeclChain(const Decl *D) override
If any redeclarations of D have been imported since it was last checked, this digs out those redeclar...
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
The value of the next COUNTER to dispense.
ObjCMethodDecl - Represents an instance or class method declaration.
unsigned getLineTableFilenameID(StringRef Str)
Specifies the umbrella header used to create this module, if any.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
A namespace, stored as a NamespaceDecl*.
void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation >> &Sels) override
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 ...
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)
void setAttrOperandParensRange(SourceRange range)
void setProtocolRAngleLoc(SourceLocation Loc)
Stores a list of template parameters for a TemplateDecl and its derived classes.
void setBegin(SourceLocation b)
TemplateName getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param, TemplateName replacement) const
Describes a source location entry (SLocEntry) for a buffer.
Used to hold and unique data used to represent #line information.
Record code for the target options table.
static StringRef bytes(const std::vector< T, Allocator > &v)
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
Record code for the array of eagerly deserialized decls.
std::string PresumedModuleMapFile
The presumed file name for the module map defining this module.
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
int SLocEntryBaseID
The base ID in the source manager's view of this module.
ContinuousRangeMap< uint32_t, int, 2 > DeclRemap
Remapping table for declaration IDs in this module.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
unsigned getFactoryBits() const
The collection of all-type qualifiers we support.
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
SourceLocation ImportLoc
The source location where this module was first imported.
An UnresolvedSet-like class that might not have been loaded from the external AST source yet...
bool needsExtraLocalData() const
The width of the "fast" qualifier mask.
ModuleKind Kind
The kind of this module.
The client can handle an AST file that cannot load because it is missing.
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
Defines the clang::SanitizerKind enum.
void ReadUndefinedButUsed(llvm::MapVector< NamedDecl *, SourceLocation > &Undefined) override
Load the set of used but not defined functions or variables with internal linkage, or used but not defined internal functions.
Base wrapper for a particular "section" of type source info.
StringRef ModuleOffsetMap
The module offset map data for this file.
RecordDecl - Represents a struct/union/class.
C ucontext_t typedef type.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
RecordDecl * getCFConstantStringTagDecl() const
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Selector getUnarySelector(IdentifierInfo *ID)
QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced, QualType Replacement) const
Retrieve a substitution-result type.
static bool isWhitelistedDecl(const Decl *D, const CXXRecordDecl *Record)
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
FunctionType::ExtInfo ExtInfo
One of these records is kept for each identifier that is lexed.
A macro directive exported by a module.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
void setLocalRangeEnd(SourceLocation L)
void addLazyDecl(ASTContext &C, uintptr_t ID, AccessSpecifier AS)
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
void disableFileContentsOverride(const FileEntry *File)
Disable overridding the contents of a file, previously enabled with overrideFileContents.
Specifies a top-level header that falls into this (sub)module.
std::string ActualOriginalSourceFileName
The actual original source file name that was used to build this AST file.
The block containing comments.
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.
StringLiteral * getMessage()
A library or framework to link against when an entity from this module is used.
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
T * getFETokenInfo() const
getFETokenInfo/setFETokenInfo - The language front-end is allowed to associate arbitrary metadata wit...
Iteration over the preprocessed entities.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
static Module * getTopImportImplicitModule(ModuleManager &ModuleMgr, Preprocessor &PP)
Return the top import module if it is implicit, nullptr otherwise.
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.
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...
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
void setBuiltinLoc(SourceLocation Loc)
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
The 'unsigned long' type.
Specifies a header that has been explicitly excluded from this submodule.
void setRBracketLoc(SourceLocation Loc)
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
SmallVector< Requirement, 2 > Requirements
The set of language features required to use this module.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
SourceLocation getBegin() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
bool isCPlusPlusOperatorKeyword() const
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
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.
One instance of this struct is kept for every file loaded or used.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
Delete expressions that will be analyzed later.
llvm::SmallPtrSet< ModuleFile *, 4 > HitSet
A set of module files in which we found a result.
method_range methods() const
Helper class that saves the current stream position and then restores it when destroyed.
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
void setElaboratedKeywordLoc(SourceLocation Loc)
TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template name.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
SanitizerMask Mask
Bitmask of enabled sanitizers.
Token - This structure provides full information about a lexed token.
void setUmbrellaDir(Module *Mod, const DirectoryEntry *UmbrellaDir, Twine NameAsWritten)
Sets the umbrella directory of the given module to the given directory.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
Wrapper for source info for unresolved typename using decls.
std::string OriginalDir
The directory that the PCH was originally created in.
void setKind(tok::TokenKind K)
TypeLoc getNextTypeLoc() const
An AttributedType record.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
An object-like macro definition.
The client can handle an AST file that cannot load because it's compiled configuration doesn't match ...
CanQualType OCLReserveIDTy
The signature of a module, which is a hash of the AST content.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
const LangOptions & getLangOpts() const
internal_key_type ReadKey(const unsigned char *d, unsigned)
Describes a module or submodule.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
ASTReadResult ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, unsigned ClientLoadCapabilities, SmallVectorImpl< ImportedSubmodule > *Imported=nullptr)
Load the AST file designated by the given file name.
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.
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.
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
const PPEntityOffset * PreprocessedEntityOffsets
Specifies the submodules that are re-exported from this submodule.
void setProtocolLoc(unsigned i, SourceLocation Loc)
TemplateParameterList ** TemplParamLists
TemplParamLists - A new-allocated array of size NumTemplParamLists, containing pointers to the "outer...
serialization::MacroID BaseMacroID
Base macro ID for macros local to this module.
bool isBitField() const
Determines whether this field is a bitfield.
Selector getNullarySelector(IdentifierInfo *ID)
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...
virtual void HandleInterestingDecl(DeclGroupRef D)
HandleInterestingDecl - Handle the specified interesting declaration.
PreprocessedEntity * ReadPreprocessedEntity(unsigned Index) override
Read a preallocated preprocessed entity from the external source.
void setCaretLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
Wrapper for source info for injected class names of class templates.
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.
HeaderSearch & getHeaderSearchInfo() const
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
unsigned getNumProtocols() const
const unsigned NumSpecialTypeIDs
The number of special type IDs.
A convenient class for passing around template argument information.
void setcudaConfigureCallDecl(FunctionDecl *FD)
Describes a blob that contains the data for a buffer entry.
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Record code for the language options table.
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, const RecordData &Record, unsigned &Idx)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
std::string Message
The message provided to the user when there is a conflict.
serialization::DeclID getGlobalDeclID(ModuleFile &F, serialization::LocalDeclID LocalID) const
Map from a local declaration ID within a given module to a global declaration ID. ...
Wrapper for source info for functions.
Specifies a conflict with another module.
The signed 128-bit integer type.
unsigned getHash() const
Compute a fingerprint of this key for use in on-disk hash table.
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.
bool isFileOverridden(const FileEntry *File) const
Returns true if the file contents have been overridden.
void FindExternalLexicalDecls(const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl *> &Decls) override
Read all of the declarations lexically stored in a declaration context.
An ObjCObjectType record.
A ConstantArrayType record.
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
llvm::iterator_range< ModuleDeclIterator > getModuleFileLevelDecls(ModuleFile &Mod)
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...
Concrete class used by the front-end to report problems and issues.
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID)
Retrieve the global submodule ID given a module and its local ID number.
Record code for #pragma optimize options.
uint32_t BitOffset
Offset in the AST file.
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
StringRef Data
The serialized bitstream data for this file.
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.
ExtKind hasExternalDefinitions(const Decl *D) override
CanQualType PseudoObjectTy
The internal '__make_integer_seq' template.
void setRParenLoc(SourceLocation Loc)
void setLazyBody(uint64_t Offset)
TemplateArgument ReadTemplateArgument(ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument.
const TemplateArgument & getArg(unsigned Idx) const
Record code for floating point #pragma options.
CommentRecordTypes
Record types used within a comments block.
Defines the Diagnostic-related interfaces.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
static internal_key_type ReadKey(const unsigned char *d, unsigned n)
void setMustBuildLookupTable()
Mark that there are external lexical declarations that we need to include in our lookup table (and th...
The module file is missing.
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
unsigned IsFromModuleFile
Whether this module was loaded from a module file.
std::string OriginalSourceFileName
The original source file name that was used to build the primary AST file, which may have been modifi...
Wrapper for source info for ObjC interfaces.
Record code for the set of known namespaces, which are used for typo correction.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
static bool isDiagnosedResult(ASTReader::ASTReadResult ARR, unsigned Caps)
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
bool hasRevertedBuiltin() const
True if setNotBuiltin() was called.
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.
SourceLocation FirstLoc
The first source location in this module.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
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 ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo >> &WI) override
void setLocalRangeBegin(SourceLocation L)
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
Represents an ObjC class declaration.
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
void revertBuiltin()
Revert the identifier to a non-builtin identifier.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
The AST file itself appears corrupted.
void dump()
Dump information about the AST reader to standard error.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &Exprs) override
unsigned getNumArgs() const
static ASTFileSignature readASTFileSignature(StringRef PCH)
Reads and return the signature record from PCH's control block, or else returns 0.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
A DependentSizedExtVectorType record.
The type of 'nullptr'.
uint64_t PreprocessorDetailStartOffset
The offset of the start of the preprocessor detail cursor.
CanQualType UnsignedCharTy
Record code for the table of offsets into the block of source-location information.
void setAttrNameLoc(SourceLocation loc)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
A SubstTemplateTypeParmPackType record.
Objective-C "id" redefinition type.
static std::string ReadString(const RecordData &Record, unsigned &Idx)
TypeCode
Record codes for each kind of type.
Records the location of a macro expansion.
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.
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void getExportedModules(SmallVectorImpl< Module *> &Exported) const
Appends this module's list of exported modules to Exported.
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.
bool DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
bool isErrorOrFatal() const
The placeholder type for OpenMP array section.
A VariableArrayType record.
const FileEntry * getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
void setLazyBody(uint64_t Offset)
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
typename Representation::iterator iterator
Sema - This implements semantic analysis and AST building for C.
const unsigned int NUM_PREDEF_PP_ENTITY_IDS
The number of predefined preprocessed entity IDs.
StringRef getString() const
void setUsedForHeaderGuard(bool Val)
ASTRecordTypes
Record types that occur within the AST block itself.
HashTableTy::const_iterator iterator
A little helper class used to produce diagnostics.
static bool parseModuleFileExtensionMetadata(const SmallVectorImpl< uint64_t > &Record, StringRef Blob, ModuleFileExtensionMetadata &Metadata)
Parse a record and blob containing module file extension metadata.
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
unsigned NumTemplParamLists
NumTemplParamLists - The number of "outer" template parameter lists.
Represents a prototype with parameter type info, e.g.
Defines the major attributes of a submodule, including its name and parent.
llvm::BitstreamCursor Stream
The main bitstream cursor for the main block.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
The '__uint128_t' type.
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...
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
virtual bool needsImportVisitation() const
Returns true if this ASTReaderListener wants to receive the imports of the AST file via visitImport...
Represents a ValueDecl that came out of a declarator.
DeclarationNameKey()=default
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
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type...
ArraySizeModifier
Capture whether this is a normal array (e.g.
void ReadModuleMapFile(StringRef ModuleMapPath) override
void setSizeExpr(Expr *Size)
unsigned LocalNumSLocEntries
The number of source location entries in this AST file.
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
void setCFConstantStringType(QualType T)
Captures information about a #pragma weak directive.
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
void visitInputFiles(serialization::ModuleFile &MF, bool IncludeSystem, bool Complain, llvm::function_ref< void(const serialization::InputFile &IF, bool isSystem)> Visitor)
Visit all the input files of the given module file.
ArrayRef< ObjCMethodDecl * > getInstanceMethods() const
Retrieve the instance methods found by this visitor.
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)
void setAttrNameLoc(SourceLocation loc)
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.
A record containing CXXBaseSpecifiers.
void setAttrExprOperand(Expr *e)
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
ASTReaderListener implementation to validate the information of the PCH file against an initialized P...
SourceLocation getBeginLoc() const
Get the begin source location.
CommentOptions CommentOpts
Options for parsing comments.
Specifies some declarations with initializers that must be emitted to initialize the module...
An TemplateSpecializationType record.
An ObjCObjectPointerType record.
File is from a prebuilt module path.
serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const
Map a local type ID within a given AST file into a global type ID.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Type source information for an attributed type.
An ObjCInterfaceType record.
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.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override
Read the header file information for the given file entry.
Describes a zlib-compressed blob that contains the data for a buffer entry.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
Defines the clang::LangOptions interface.
SourceLocation getEnd() const
Record code for the array of VTable uses.
IncludeDirGroup
IncludeDirGroup - Identifies the group an include Entry belongs to, representing its relative positiv...
The 'char' type, when it is unsigned.
void setHasCommaPasting()
static bool isInterestingIdentifier(ASTReader &Reader, IdentifierInfo &II, bool IsModule)
Whether the given identifier is "interesting".
void setModeAttr(bool written)
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID)
Retrieve the global macro ID corresponding to the given local ID within the given module file...
The directory that the PCH was originally created in.
const FunctionProtoType * T
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args) const
Declaration of a template type parameter.
bool wasUpgradedFromWarning() const
Whether this mapping attempted to map the diagnostic to a warning, but was overruled because the diag...
std::string WorkingDir
If set, paths are resolved as if the working directory was set to the value of WorkingDir.
unsigned LocalNumIdentifiers
The number of identifiers in this AST file.
void ReadUsedVTables(SmallVectorImpl< ExternalVTableUse > &VTables) override
Read the set of used vtables known to the external Sema source.
The placeholder type for overloaded function sets.
std::string OMPHostIRFile
Name of the IR file that contains the result of the OpenMP target host code generation.
Implements an efficient mapping from strings to IdentifierInfo nodes.
Defines implementation details of the clang::SourceManager class.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
virtual void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata)
Indicates that a particular module file extension has been read.
unsigned ConfigMacrosExhaustive
Whether the set of configuration macros is exhaustive.
QualType getTypeOfExprType(Expr *e) const
GCC extension.
Record code for the table of offsets to entries in the preprocessing record.
Represents a C++ destructor within a class.
ContinuousRangeMap< uint32_t, int, 2 > IdentifierRemap
Remapping table for identifier IDs in this module.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
QualType getParenType(QualType NamedType) const
CanQualType OMPArraySectionTy
llvm::BitstreamCursor SLocEntryCursor
Cursor used to read source location entries.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Defines version macros and version-related utility functions for Clang.
The OpenCL 'half' / ARM NEON __fp16 type.
const FileEntry * ContentsEntry
References the file which the contents were actually loaded from.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
Defines an enumeration for C++ overloaded operators.
Defines the clang::Preprocessor interface.
ArgKind
The kind of template argument we're storing.
The block containing the detailed preprocessing record.
ASTReaderListenter implementation to set SuggestedPredefines of ASTReader which is required to use a ...
Record code for #pragma diagnostic mappings.
void setIsPoisoned(bool Value=true)
setIsPoisoned - Mark this identifier as poisoned.
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.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Record code for the original file that was used to generate the AST file, including both its file ID ...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
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...
void clear(SanitizerMask K=SanitizerKind::All)
Disable the sanitizers specified in K.
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.
Defines the clang::TypeLoc interface and its subclasses.
A namespace alias, stored as a NamespaceAliasDecl*.
virtual ~ASTReaderListener()
The 'long double' type.
Record code for the diagnostic options table.
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
uint32_t IdentifierID
An ID number that refers to an identifier in an AST file.
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)
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.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool HasTimestamps
Whether timestamps are included in this module file.
Describes a source location entry (SLocEntry) for a file.
Wrapper for source info for enum types.
A block containing a module file extension.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
unsigned NumUserInputFiles
clang::ObjCRuntime ObjCRuntime
std::string FileName
The file name of the module file.
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 setUmbrellaHeader(Module *Mod, const FileEntry *UmbrellaHeader, Twine NameAsWritten)
Sets the umbrella header of the given module to the given header.
void setEllipsisLoc(SourceLocation Loc)
void setAttrExprOperand(Expr *e)
Record code for an update to a decl context's lookup table.
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
void setHasBaseTypeAsWritten(bool HasBaseType)
Record the location of an inclusion directive, such as an #include or #import statement.
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Record code for #pragma ms_struct options.
InclusionKind
The kind of inclusion directives known to the preprocessor.
QualType getRecordType(const RecordDecl *Decl) const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
SourceLocation getEnd() const
bool isInstanceMethod() const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
struct CXXOpName CXXOperatorName
void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation >> &Pending) override
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type...
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.
bool isAvailable() const
Determine whether this module is available for use within the current translation unit...
void StartedDeserializing() override
Notify ASTReader that we started deserialization of a decl or type so until FinishedDeserializing is ...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Selector getSelector() const
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
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)
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
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.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Record code for the identifier table.
The AST file was missing.
bool hasAttrExprOperand() const
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.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
void setIsUsed(bool Val)
Set the value of the IsUsed flag.
The "auto" deduction type.
void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef)
Note that MergedDef is a redefinition of the canonical definition Def, so Def should be visible whene...
std::string CPU
If given, the name of the target CPU to generate code for.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
unsigned readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID)
Reads a record with id AbbrevID from Cursor, resetting the internal state.
void setStarLoc(SourceLocation Loc)
std::vector< std::unique_ptr< ModuleFileExtensionReader > > ExtensionReaders
The list of extension readers that are attached to this module file.
QualType getPackExpansionType(QualType Pattern, Optional< unsigned > NumExpansions)
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
void setTypeofLoc(SourceLocation Loc)
SanitizerMask getPPTransparentSanitizers()
Return the sanitizers which do not affect preprocessing.
The Objective-C 'Class' type.
SpecifierKind
The kind of specifier that completes this nested name specifier.
SourceLocation getLocStart() const LLVM_READONLY
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.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
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.
Record code for the set of source location entries that need to be preloaded by the AST reader...
QualifierInfo - A struct with extended info about a syntactic name qualifier, to be used for the case...
The control block was read successfully.
The list of delegating constructor declarations.
Information about a FileID, basically just the logical file that it represents and include stack info...
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
Record code for types associated with OpenCL extensions.
void setAttrOperandParensRange(SourceRange range)
static bool readBit(unsigned &Bits)
void setIsFunctionLike()
Function/Object-likeness.
const unsigned char * SelectorLookupTableData
A pointer to the character data that comprises the selector table.
Encapsulates changes to the "macros namespace" (the location where the macro name became active...
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.
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply...
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.
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.
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...
File is a PCH file treated as the preamble.
std::string getTimestampFilename() const
ContinuousRangeMap< unsigned, int, 2 > SLocRemap
static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method)
Move the given method to the back of the global list of methods.
const ExtParameterInfo * ExtParameterInfos
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Encodes a location in the source.
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
bool isPure() const
Whether this virtual function is pure, i.e.
static bool checkHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, StringRef ExistingModuleCachePath, DiagnosticsEngine *Diags, const LangOptions &LangOpts)
Check the header search options deserialized from the control block against the header search options...
StringRef getName() const
A record that stores the set of declarations that are visible from a given DeclContext.
File is a PCH file treated as such.
IdentifierInfo * get(StringRef Name) override
Retrieve the IdentifierInfo for the named identifier.
void setLength(unsigned Len)
Specifies a library or framework to link against.
Record code for file ID of the file or buffer that was used to generate the AST file.
Represents a C++ temporary.
Interfaces are the core concept in Objective-C for object oriented design.
void InitializeContext()
Initializes the ASTContext.
Specifies a header that falls into this (sub)module.
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
std::string ExportAsModule
The module through which entities defined in this module will eventually be exposed, for use in "private" modules.
ContinuousRangeMap< uint32_t, int, 2 > SubmoduleRemap
Remapping table for submodule IDs in this module.
void setUsed(bool Used=true)
typename Representation::const_iterator const_iterator
Record code for special CUDA declarations.
Options for controlling the compiler diagnostics engine.
A list of "interesting" identifiers.
NameVisibilityKind NameVisibility
The visibility of names within this particular module.
An identifier-lookup iterator that enumerates all of the identifiers stored within a set of AST files...
void setProtocolLAngleLoc(SourceLocation Loc)
The block of configuration options, used to check that a module is being used in a configuration comp...
DeclarationName getName() const
getName - Returns the embedded declaration name.
TagDecl - Represents the declaration of a struct/union/class/enum.
PredefinedTypeIDs
Predefined type IDs.
All of the names in this module are hidden.
File is an implicitly-loaded module.
unsigned getInstanceBits() const
void setProtocolRAngleLoc(SourceLocation Loc)
The 'unsigned char' type.
Cached information about one file (either on disk or in the virtual file system). ...
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class...
Metadata describing this particular extension.
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
void setIsC99Varargs()
Varargs querying methods. This can only be set for function-like macros.
MacroInfo * getMacro(serialization::MacroID ID)
Retrieve the macro with the given ID.
uint64_t SizeInBits
The size of this file, in bits.
TemplateParameterList * ReadTemplateParameterList(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template parameter list.
An ObjCTypeParamType record.
void ProcessWarningOptions(DiagnosticsEngine &Diags, const DiagnosticOptions &Opts, bool ReportDiags=true)
ProcessWarningOptions - Initialize the diagnostic client and process the warning options specified on...
The (signed) 'long' type.
Represents a static or instance method of a struct/union/class.
ModuleReverseIterator rbegin()
Reverse iterator to traverse all loaded modules.
Record code for the offsets of each decl.
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
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.
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location...
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
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 '::'.
const ParmVarDecl * getParamDecl(unsigned i) const
void setDefinitionEndLoc(SourceLocation EndLoc)
Set the location of the last token in the macro.
bool isPoisoned() const
Return true if this token has been poisoned.
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings startin...
unsigned LocalNumDecls
The number of declarations in this AST file.
void setUpgradedFromWarning(bool Value)
unsigned NumFileSortedDecls
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
The internal 'instancetype' typedef.
OptionsRecordTypes
Record types that occur within the options block inside the control block.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
void addDecl(NamedDecl *D)
Describes the categories of an Objective-C class.
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl *> protocols, QualType Canonical=QualType()) const
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
The AST block, which acts as a container around the full AST block.
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
ArrayRef< ObjCMethodDecl * > getFactoryMethods() const
Retrieve the instance methods found by this visitor.
IdentID ReadIdentifierID(const unsigned char *d)
A DeducedTemplateSpecializationType record.
void setElaboratedKeywordLoc(SourceLocation Loc)
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
uint32_t TypeID
An ID number that refers to a type in an AST file.
void 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...
void setAmpLoc(SourceLocation Loc)
UnhashedControlBlockRecordTypes
Record codes for the unhashed control block.
llvm::SetVector< ModuleFile * > ImportedBy
List of modules which depend on this module.
void setLBracketLoc(SourceLocation Loc)
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
void dump()
Dump debugging output for this module.
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.
void SetGloballyVisibleDecls(IdentifierInfo *II, const SmallVectorImpl< uint32_t > &DeclIDs, SmallVectorImpl< Decl *> *Decls=nullptr)
Set the globally-visible declarations associated with the given identifier.
const serialization::DeclID * FileSortedDecls
Array of file-level DeclIDs sorted by file.
PragmaMSPointersToMembersKind
Record code for the extra statistics we gather while generating an AST file.
static Decl * getPredefinedDecl(ASTContext &Context, PredefinedDeclIDs ID)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
virtual void visitImport(StringRef Filename)
If needsImportVisitation returns true, this is called for each AST file imported by this AST file...
Represents a C++11 static_assert declaration.
static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags, DiagnosticsEngine &Diags, bool Complain)
std::vector< InputFile > InputFilesLoaded
The input files that have been loaded from this AST file.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
The module file was just loaded in response to this call.
DeclarationName ReadDeclarationName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a declaration name.
The 'signed char' type.
unsigned LocalNumSubmodules
The number of submodules in this module.
unsigned ComputeHash(Selector Sel)
The AST file was writtten with a different language/target configuration.
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...
const char * HeaderFileInfoTableData
Actual data for the on-disk hash table of header file information.
void markIdentifierUpToDate(IdentifierInfo *II)
Note that this identifier is up-to-date.
const llvm::support::unaligned_uint64_t * InputFileOffsets
Offsets for all of the input file entries in the AST file.
void addArgument(const TemplateArgumentLoc &Loc)
Record code for the signature that identifiers this AST file.
void addHeader(Module *Mod, Module::Header Header, ModuleHeaderRole Role, bool Imported=false)
Adds this header to the given module.
File is a PCH file treated as the actual main file.
llvm::APFloat ReadAPFloat(const RecordData &Record, const llvm::fltSemantics &Sem, unsigned &Idx)
Read a floating-point value.
Record code for referenced selector pool.
void AddSubDecl(const Decl *D)
std::vector< std::string > MacroIncludes
Represents a pointer type decayed from an array or function type.
The injected class name of a C++ class template or class template partial specialization.
ModuleFile * getLocalModuleFile(ModuleFile &M, unsigned ID)
Retrieve the module file with a given local ID within the specified ModuleFile.
Record code for the set of non-builtin, special types.
Defines various enumerations that describe declaration and type specifiers.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
void setLParenLoc(SourceLocation Loc)
void * Allocate(size_t Size, unsigned Align=8) const
void setTemplateKeywordLoc(SourceLocation Loc)
StringRef getName() const
Return the actual identifier string.
void setTypeArgsLAngleLoc(SourceLocation Loc)
uint64_t InputFilesValidationTimestamp
If non-zero, specifies the time when we last validated input files.
CanQualType UnsignedShortTy
llvm::MemoryBuffer * getRawBuffer() const
Get the underlying buffer, returning NULL if the buffer is not yet available.
const uint32_t * MacroOffsets
Offsets of macros in the preprocessor block.
The ObjC 'id' type.
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Canon=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
Base class for declarations which introduce a typedef-name.
unsigned LocalNumSelectors
The number of selectors new to this file.
unsigned getObjCOrBuiltinID() const
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
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.
const ASTTemplateArgumentListInfo * ReadASTTemplateArgumentListInfo(ModuleFile &F, const RecordData &Record, unsigned &Index)
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
A conflict between two modules.
void setClassTInfo(TypeSourceInfo *TI)
bool ReadSLocEntry(int ID) override
Read the source location entry with index ID.
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
The internal '__NSConstantString' typedef.
Record code for the module name.
QualType getTypeOfType(QualType t) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes.
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
CanQualType ObjCBuiltinIdTy
bool hadMacroDefinition() const
Returns true if this identifier was #defined to some value at any moment.
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...
Dataflow Directional Tag Classes.
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
TemplateName getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param, const TemplateArgument &ArgPack) const
bool isValid() const
Return true if this is a valid SourceLocation object.
void setDeserializationListener(ASTDeserializationListener *Listener, bool TakeOwnership=false)
Set the AST deserialization listener.
Describes an inclusion directive within the preprocessing record.
The internal '__builtin_ms_va_list' typedef.
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.
unsigned IsMissingRequirement
Whether this module is missing a feature from Requirements.
not evaluated yet, for special member function
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Record code for a file sorted array of DeclIDs in a module.
void setAmpAmpLoc(SourceLocation Loc)
Record code for the array of Objective-C categories (including extensions).
void updateOutOfDateIdentifier(IdentifierInfo &II) override
Update an out-of-date identifier.
void reserve(ASTContext &C, unsigned N)
Specifies a configuration macro for this module.
void ReadDefinedMacros() override
Read the set of macros defined by this external macro source.
The base class of all kinds of template declarations (e.g., class, function, etc.).
PreprocessorDetailRecordTypes
Record types used within a preprocessor detail block.
static std::pair< GlobalModuleIndex *, ErrorCode > readIndex(StringRef Path)
Read a global index file for the given directory.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
static unsigned moduleKindForDiagnostic(ModuleKind Kind)
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain) override
Receives the file system options.
The basic abstraction for the target Objective-C runtime.
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
uint64_t MacroStartOffset
The offset of the start of the set of defined macros.
The template argument is a pack expansion of a template name that was provided for a template templat...
SourceLocation TranslateSourceLocation(ModuleFile &ModuleFile, SourceLocation Loc) const
Translate a source location from another module file's source location space into ours...
Record code for the array of unused file scoped decls.
A FunctionNoProtoType record.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
static bool SkipCursorToBlock(BitstreamCursor &Cursor, unsigned BlockID)
Given a cursor at the start of an AST file, scan ahead and drop the cursor into the start of the give...
Reads an AST files chain containing the contents of a translation unit.
File is an explicitly-loaded module.
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
QualType getUnderlyingType() const
CanQualType UnsignedLongLongTy
bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule) override
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
const Expr * getInit() const
AccessSpecifier getAccess() 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 ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl *> &Decls) override
Read the set of ext_vector type declarations known to the external Sema source.
DeclarationName - The name of a declaration.
Represents the declaration of an Objective-C type parameter.
Record code for the Objective-C method pool,.
llvm::PointerIntPair< Module *, 1, bool > ExportDecl
Describes an exported module.
bool isExtensionToken() const
get/setExtension - Initialize information about whether or not this language token is an extension...
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
Specifies a header that is private to this submodule.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
bool needsInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
U cast(CodeGen::Address addr)
Describes a macro expansion within the preprocessing record.
bool isGlobalIndexUnavailable() const
Determine whether we tried to load the global index, but failed, e.g., because it is out-of-date or d...
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
IdentifierResolver IdResolver
A map from continuous integer ranges to some value, with a very specialized interface.
Class that performs lookup for an identifier stored in an AST file.
void setExternalSLocEntrySource(ExternalSLocEntrySource *Source)
ContinuousRangeMap< uint32_t, int, 2 > MacroRemap
Remapping table for macro IDs in this module.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
An RValueReferenceType record.
void ReadDeclarationNameLoc(ModuleFile &F, DeclarationNameLoc &DNLoc, DeclarationName Name, const RecordData &Record, unsigned &Idx)
A type that was preceded by the 'template' keyword, stored as a Type*.
void ClearSwitchCaseIDs()
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
void setHasExternalLexicalStorage(bool ES=true)
State whether this DeclContext has external storage for declarations lexically in this context...
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate >> &LPTMap) override
Read the set of late parsed template functions for this source.
static void PassObjCImplDeclToConsumer(ObjCImplDecl *ImplD, ASTConsumer *Consumer)
Under non-PCH compilation the consumer receives the objc methods before receiving the implementation...
The placeholder type for dependent types.
All of the names in this module are visible.
unsigned getNumParams() const
void setNameLoc(SourceLocation Loc)
bool hasAttrEnumOperand() const
Number of unmatched #pragma clang cuda_force_host_device begin directives we've seen.
Encapsulates the data about a macro definition (e.g.
Decl * GetExternalDecl(uint32_t ID) override
Resolve a declaration ID into a declaration, potentially building a new declaration.
std::string toString(const til::SExpr *E)
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope...
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
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...
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
bool instanceHasMoreThanOneDecl() 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.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Location wrapper for a TemplateArgument.
BuiltinTemplateDecl * getTypePackElementDecl() const
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.
Defines the clang::FileSystemOptions interface.
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...
const TemplateArgument & getArg(unsigned Idx) const
Retrieve a specific template argument as a type.
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
bool InstanceHasMoreThanOneDecl
A key used when looking up entities by DeclarationName.
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata) override
Indicates that a particular module file extension has been read.
unsigned getOwningModuleID() const
Retrieve the global ID of the module that owns this particular declaration.
Record code for declarations that Sema keeps references of.
void ReadTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument array.
void setTemplateNameLoc(SourceLocation Loc)
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.
void visitTopLevelModuleMaps(serialization::ModuleFile &MF, llvm::function_ref< void(const FileEntry *)> Visitor)
Visit all the top-level module maps loaded when building the given module file.
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
unsigned getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
PreprocessorRecordTypes
Record types used within a preprocessor block.
static bool isExtHandlingFromDiagsError(DiagnosticsEngine &Diags)
CanQualType BoundMemberTy
The block containing the submodule structure.
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
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.
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
unsigned getNumArgs() const
ContinuousRangeMap< uint32_t, int, 2 > TypeRemap
Remapping table for type IDs in this module.
Selector DecodeSelector(serialization::SelectorID Idx)
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
The template argument is actually a parameter pack.
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
Represents a base class of a C++ class.
Cached information about one directory (either on disk or in the virtual file system).
uint32_t GetNumExternalSelectors() override
Returns the number of selectors known to the external AST source.
unsigned BufferOverridden
Indicates whether the buffer itself was provided to override the actual file contents.
void PrintStats() override
Print some statistics about AST usage.
void setSeverity(diag::Severity Value)
unsigned size() const
Number of modules loaded.
Defines the clang::TokenKind enum and support functions.
void insert(const value_type &Val)
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Keeps track of options that affect how file operations are performed.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID)
ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the specified cursor.
QualType GetType(serialization::TypeID ID)
Resolve a type ID into a type, potentially building a new type.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
ExternCContextDecl * getExternCContextDecl() const
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.
ArgKind getKind() const
Return the kind of stored template argument.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void setKWLoc(SourceLocation Loc)
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...
TranslationUnitDecl * getTranslationUnitDecl() const
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
The C++ 'char16_t' type.
Defines the clang::SourceLocation class and associated facilities.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
TemplateArgumentLoc ReadTemplateArgumentLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLoc.
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
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.
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
static const ASTTemplateArgumentListInfo * Create(ASTContext &C, const TemplateArgumentListInfo &List)
serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declaration ID from the given position in a record in the given module.
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl *> &Decls) override
Read the set of unused file-scope declarations known to the external Sema source. ...
An TemplateTypeParmType record.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
The template argument is a template name that was provided for a template template parameter...
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
SmallVector< uint64_t, 8 > PragmaDiagMappings
Diagnostic IDs and their mappings that the user changed.
Record code for the filesystem options table.
static hash_value_type ComputeHash(const internal_key_type &a)
Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx)
Reads a token out of a record.
const char * IdentifierTableData
Actual data for the on-disk hash table of identifiers.
void setParam(unsigned i, ParmVarDecl *VD)
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Level
The level of the diagnostic, after it has been through mapping.
static DiagnosticMapping deserialize(unsigned Bits)
Deserialize a mapping.
void setOutOfDate(bool OOD)
Set whether the information for this identifier is out of date with respect to the external source...
unsigned getNumProtocols() const
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.
Declaration of a class template.
Record code for the offsets of each type.
A DependentAddressSpaceType record.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
The block containing the definitions of all of the types and decls used within the AST file...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
The internal '__va_list_tag' struct, if any.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
void revertTokenIDToIdentifier()
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility.
virtual void ReadModuleName(StringRef ModuleName)
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type...
bool hasAttrOperand() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
ASTIdentifierIterator(const ASTReader &Reader, bool SkipModules=false)
The module file had already been loaded.
Specifies the name of the module that will eventually re-export the entities in this module...
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
The 'double' type.
The AST file is out-of-date relative to its input files, and needs to be regenerated.
TypeLocReader(ModuleFile &F, ASTReader &Reader, const ASTReader::RecordData &Record, unsigned &Idx)
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.
The (signed) 'int' type.
a linked list of methods with the same selector name but different signatures.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
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...
void AddStmt(const Stmt *S)
SourceRange getSourceRange() const override LLVM_READONLY
Retrieves the source range for the friend declaration.
unsigned getNumTypeArgs() const
Abstracts clang modules and precompiled header files and holds everything needed to generate debug in...
The AST file was written by a different version of Clang.
Record for offsets of DECL_UPDATES records for declarations that were modified after being deserializ...
static bool checkDiagnosticMappings(DiagnosticsEngine &StoredDiags, DiagnosticsEngine &Diags, bool IsSystem, bool Complain)
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions, ASTReaderListener &Listener, bool ValidateDiagnosticOptions)
Read the control block for the named AST file.
llvm::BitstreamCursor PreprocessorDetailCursor
The cursor to the start of the (optional) detailed preprocessing record block.
The C++ 'wchar_t' type.
bool isDeleted() const
Whether this function has been deleted.
The ObjC 'Class' type.
void setProtocolLAngleLoc(SourceLocation Loc)
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
ModuleFile * getOwningModuleFile(const Decl *D)
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
Record code for weak undeclared identifiers.
The block containing information about the preprocessor.
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
void StartTranslationUnit(ASTConsumer *Consumer) override
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
void setLocation(SourceLocation L)
bool getWarningsAsErrors() const
Wrapper for source info for builtin types.
void setRParenLoc(SourceLocation Loc)
A set of overloaded template declarations.
Wrapper for template type parameters.
Record code for the headers search options table.
Module * Other
The module that this module conflicts with.
A trivial tuple used to represent a source range.
void setParameterList(ArrayRef< IdentifierInfo *> List, llvm::BumpPtrAllocator &PPAllocator)
Set the specified list of identifiers as the parameter list for this macro.
std::string ModuleMapPath
NamedDecl - This represents a decl with a name.
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
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.
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.
Represents a C++ namespace alias.
void setTemplateNameLoc(SourceLocation Loc)
Kind
The basic Objective-C runtimes that we know about.
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...
The internal '__NSConstantString' tag type.
static TypeIdx fromTypeID(TypeID ID)
serialization::DeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M, serialization::DeclID GlobalID)
Map a global declaration ID into the declaration ID used to refer to this declaration within the give...
InputFileRecordTypes
Record types that occur within the input-files block inside the control block.
void FinishedDeserializing() override
Notify ASTReader that we finished the deserialization of a decl or type.
A function-like macro definition.
The Objective-C 'Protocol' type.
The global specifier '::'. There is no stored value.
The control block, which contains all of the information that needs to be validated prior to committi...
SourceLocation getLocStart() const LLVM_READONLY
Wrapper for source info for pointers.
SourceLocation getBegin() const
const FileEntry * File
The file entry for the module file.
std::string Triple
The name of the target triple to compile for.
void setObjCOrBuiltinID(unsigned ID)
const LangOptions & getLangOpts() const
StringRef internal_key_type
Wrapper for source info for block pointers.
void ReadModuleName(StringRef ModuleName) override
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
This class handles loading and caching of source files into memory.
ExceptionSpecInfo ExceptionSpec
PredefinedDeclIDs
Predefined declaration IDs.
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
Record code for an update to the TU's lexically contained declarations.
A class which abstracts out some details necessary for making a call.
void setElaboratedKeywordLoc(SourceLocation Loc)
Source range/offset of a preprocessed entity.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind) override
This is called for each AST file loaded.
SourceLocation getLocation() const
const serialization::ObjCCategoriesInfo * ObjCCategoriesMap
Array of category list location information within this module file, sorted by the definition ID...
bool loadGlobalIndex()
Attempts to load the global index.
void startToken()
Reset all flags to cleared.
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
Objective-C "Class" redefinition type.
A PackExpansionType record.
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls) override
Read the set of potentially unused typedefs known to the source.
QualType getType() const
Return the type wrapped by this type source info.
A single template declaration.
CanQualType OCLClkEventTy
The pseudo-object placeholder type.
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
virtual bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain)
Receives the diagnostic options.
void setUnderlyingTInfo(TypeSourceInfo *TI) const
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
Record code for #pragma ms_struct options.
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID)
Record that the given ID maps to the given switch-case statement.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
A DependentTemplateSpecializationType record.
CanQualType UnsignedIntTy
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...
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, unsigned LocalID)
Record code for the array of tentative definitions.
The '__float128' type.
BuiltinTemplateDecl * getMakeIntegerSeqDecl() const
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.