85 #include "llvm/ADT/APFloat.h" 86 #include "llvm/ADT/APInt.h" 87 #include "llvm/ADT/APSInt.h" 88 #include "llvm/ADT/ArrayRef.h" 89 #include "llvm/ADT/DenseMap.h" 90 #include "llvm/ADT/FoldingSet.h" 91 #include "llvm/ADT/Hashing.h" 92 #include "llvm/ADT/IntrusiveRefCntPtr.h" 93 #include "llvm/ADT/None.h" 94 #include "llvm/ADT/Optional.h" 95 #include "llvm/ADT/STLExtras.h" 96 #include "llvm/ADT/SmallPtrSet.h" 97 #include "llvm/ADT/SmallString.h" 98 #include "llvm/ADT/SmallVector.h" 99 #include "llvm/ADT/StringExtras.h" 100 #include "llvm/ADT/StringMap.h" 101 #include "llvm/ADT/StringRef.h" 102 #include "llvm/ADT/Triple.h" 103 #include "llvm/ADT/iterator_range.h" 104 #include "llvm/Bitcode/BitstreamReader.h" 105 #include "llvm/Support/Casting.h" 106 #include "llvm/Support/Compiler.h" 107 #include "llvm/Support/Compression.h" 108 #include "llvm/Support/DJB.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/VersionTuple.h" 118 #include "llvm/Support/raw_ostream.h" 130 #include <system_error> 135 using namespace clang;
138 using llvm::BitstreamCursor;
146 return First->ReadFullVersionInformation(FullVersion) ||
147 Second->ReadFullVersionInformation(FullVersion);
151 First->ReadModuleName(ModuleName);
152 Second->ReadModuleName(ModuleName);
156 First->ReadModuleMapFile(ModuleMapPath);
157 Second->ReadModuleMapFile(ModuleMapPath);
163 bool AllowCompatibleDifferences) {
164 return First->ReadLanguageOptions(LangOpts, Complain,
165 AllowCompatibleDifferences) ||
166 Second->ReadLanguageOptions(LangOpts, Complain,
167 AllowCompatibleDifferences);
172 bool AllowCompatibleDifferences) {
173 return First->ReadTargetOptions(TargetOpts, Complain,
174 AllowCompatibleDifferences) ||
175 Second->ReadTargetOptions(TargetOpts, Complain,
176 AllowCompatibleDifferences);
181 return First->ReadDiagnosticOptions(DiagOpts, Complain) ||
182 Second->ReadDiagnosticOptions(DiagOpts, Complain);
188 return First->ReadFileSystemOptions(FSOpts, Complain) ||
189 Second->ReadFileSystemOptions(FSOpts, Complain);
195 return First->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
197 Second->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
203 std::string &SuggestedPredefines) {
204 return First->ReadPreprocessorOptions(PPOpts, Complain,
205 SuggestedPredefines) ||
206 Second->ReadPreprocessorOptions(PPOpts, Complain, SuggestedPredefines);
211 First->ReadCounter(M, Value);
212 Second->ReadCounter(M, Value);
216 return First->needsInputFileVisitation() ||
217 Second->needsInputFileVisitation();
221 return First->needsSystemInputFileVisitation() ||
222 Second->needsSystemInputFileVisitation();
227 First->visitModuleFile(Filename, Kind);
228 Second->visitModuleFile(Filename, Kind);
234 bool isExplicitModule) {
235 bool Continue =
false;
236 if (
First->needsInputFileVisitation() &&
237 (!isSystem ||
First->needsSystemInputFileVisitation()))
238 Continue |=
First->visitInputFile(Filename, isSystem, isOverridden,
240 if (Second->needsInputFileVisitation() &&
241 (!isSystem || Second->needsSystemInputFileVisitation()))
242 Continue |= Second->visitInputFile(Filename, isSystem, isOverridden,
249 First->readModuleFileExtension(Metadata);
250 Second->readModuleFileExtension(Metadata);
270 bool AllowCompatibleDifferences =
true) {
271 #define LANGOPT(Name, Bits, Default, Description) \ 272 if (ExistingLangOpts.Name != LangOpts.Name) { \ 274 Diags->Report(diag::err_pch_langopt_mismatch) \ 275 << Description << LangOpts.Name << ExistingLangOpts.Name; \ 279 #define VALUE_LANGOPT(Name, Bits, Default, Description) \ 280 if (ExistingLangOpts.Name != LangOpts.Name) { \ 282 Diags->Report(diag::err_pch_langopt_value_mismatch) \ 287 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 288 if (ExistingLangOpts.get##Name() != LangOpts.get##Name()) { \ 290 Diags->Report(diag::err_pch_langopt_value_mismatch) \ 295 #define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \ 296 if (!AllowCompatibleDifferences) \ 297 LANGOPT(Name, Bits, Default, Description) 299 #define COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) \ 300 if (!AllowCompatibleDifferences) \ 301 ENUM_LANGOPT(Name, Bits, Default, Description) 303 #define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \ 304 if (!AllowCompatibleDifferences) \ 305 VALUE_LANGOPT(Name, Bits, Default, Description) 307 #define BENIGN_LANGOPT(Name, Bits, Default, Description) 308 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) 309 #define BENIGN_VALUE_LANGOPT(Name, Type, Bits, Default, Description) 310 #include "clang/Basic/LangOptions.def" 314 Diags->
Report(diag::err_pch_langopt_value_mismatch) <<
"module features";
320 Diags->
Report(diag::err_pch_langopt_value_mismatch)
321 <<
"target Objective-C runtime";
328 Diags->
Report(diag::err_pch_langopt_value_mismatch)
329 <<
"block command names";
337 if (!AllowCompatibleDifferences) {
341 ExistingSanitizers.
clear(ModularSanitizers);
342 ImportedSanitizers.
clear(ModularSanitizers);
343 if (ExistingSanitizers.
Mask != ImportedSanitizers.
Mask) {
344 const std::string Flag =
"-fsanitize=";
346 #define SANITIZER(NAME, ID) \ 348 bool InExistingModule = ExistingSanitizers.has(SanitizerKind::ID); \ 349 bool InImportedModule = ImportedSanitizers.has(SanitizerKind::ID); \ 350 if (InExistingModule != InImportedModule) \ 351 Diags->Report(diag::err_pch_targetopt_feature_mismatch) \ 352 << InExistingModule << (Flag + NAME); \ 354 #include "clang/Basic/Sanitizers.def" 372 bool AllowCompatibleDifferences =
true) {
373 #define CHECK_TARGET_OPT(Field, Name) \ 374 if (TargetOpts.Field != ExistingTargetOpts.Field) { \ 376 Diags->Report(diag::err_pch_targetopt_mismatch) \ 377 << Name << TargetOpts.Field << ExistingTargetOpts.Field; \ 388 if (!AllowCompatibleDifferences)
391 #undef CHECK_TARGET_OPT 399 llvm::sort(ExistingFeatures.begin(), ExistingFeatures.end());
400 llvm::sort(ReadFeatures.begin(), ReadFeatures.end());
406 ExistingFeatures.begin(), ExistingFeatures.end(), ReadFeatures.begin(),
407 ReadFeatures.end(), std::back_inserter(UnmatchedExistingFeatures));
408 std::set_difference(ReadFeatures.begin(), ReadFeatures.end(),
409 ExistingFeatures.begin(), ExistingFeatures.end(),
410 std::back_inserter(UnmatchedReadFeatures));
414 if (AllowCompatibleDifferences && UnmatchedReadFeatures.empty())
418 for (StringRef Feature : UnmatchedReadFeatures)
419 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
421 for (StringRef Feature : UnmatchedExistingFeatures)
422 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
426 return !UnmatchedReadFeatures.empty() || !UnmatchedExistingFeatures.empty();
432 bool AllowCompatibleDifferences) {
433 const LangOptions &ExistingLangOpts = PP.getLangOpts();
435 Complain ? &Reader.Diags :
nullptr,
436 AllowCompatibleDifferences);
441 bool AllowCompatibleDifferences) {
442 const TargetOptions &ExistingTargetOpts = PP.getTargetInfo().getTargetOpts();
444 Complain ? &Reader.Diags :
nullptr,
445 AllowCompatibleDifferences);
450 using MacroDefinitionsMap =
451 llvm::StringMap<std::pair<StringRef,
bool >>;
452 using DeclsMap = llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8>>;
467 for (
auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) {
476 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror=" +
495 bool IsSystem,
bool Complain) {
503 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Wsystem-headers";
510 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror";
517 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Weverything -Werror";
524 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-pedantic-errors";
548 assert(!ModuleName.empty() &&
"diagnostic options read before module name");
551 assert(M &&
"missing module");
566 assert(ModuleMgr.
size() >= 1 &&
"what ASTFile is this then");
582 MacroDefinitionsMap &Macros,
584 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
585 StringRef Macro = PPOpts.
Macros[I].first;
586 bool IsUndef = PPOpts.
Macros[I].second;
588 std::pair<StringRef, StringRef> MacroPair = Macro.split(
'=');
589 StringRef MacroName = MacroPair.first;
590 StringRef MacroBody = MacroPair.second;
594 if (MacroNames && !Macros.count(MacroName))
595 MacroNames->push_back(MacroName);
597 Macros[MacroName] = std::make_pair(
"",
true);
602 if (MacroName.size() == Macro.size())
606 StringRef::size_type
End = MacroBody.find_first_of(
"\n\r");
607 MacroBody = MacroBody.substr(0, End);
610 if (MacroNames && !Macros.count(MacroName))
611 MacroNames->push_back(MacroName);
612 Macros[MacroName] = std::make_pair(MacroBody,
false);
627 std::string &SuggestedPredefines,
629 bool Validate =
true) {
631 MacroDefinitionsMap ASTFileMacros;
633 MacroDefinitionsMap ExistingMacros;
637 for (
unsigned I = 0, N = ExistingMacroNames.size(); I != N; ++I) {
639 StringRef MacroName = ExistingMacroNames[I];
640 std::pair<StringRef, bool> Existing = ExistingMacros[MacroName];
643 llvm::StringMap<std::pair<StringRef,
bool >>::iterator Known =
644 ASTFileMacros.find(MacroName);
645 if (!Validate || Known == ASTFileMacros.end()) {
650 if (Existing.second) {
651 SuggestedPredefines +=
"#undef ";
652 SuggestedPredefines += MacroName.str();
653 SuggestedPredefines +=
'\n';
655 SuggestedPredefines +=
"#define ";
656 SuggestedPredefines += MacroName.str();
657 SuggestedPredefines +=
' ';
658 SuggestedPredefines += Existing.first.str();
659 SuggestedPredefines +=
'\n';
666 if (Existing.second != Known->second.second) {
668 Diags->
Report(diag::err_pch_macro_def_undef)
669 << MacroName << Known->second.second;
676 if (Existing.second || Existing.first == Known->second.first)
681 Diags->
Report(diag::err_pch_macro_def_conflict)
682 << MacroName << Known->second.first << Existing.first;
696 if (LangOpts.Modules &&
705 for (
unsigned I = 0, N = ExistingPPOpts.
Includes.size(); I != N; ++I) {
706 StringRef File = ExistingPPOpts.
Includes[I];
712 SuggestedPredefines +=
"#include \"";
713 SuggestedPredefines += File;
714 SuggestedPredefines +=
"\"\n";
725 SuggestedPredefines +=
"#include \"";
726 SuggestedPredefines += File;
727 SuggestedPredefines +=
"\"\n";
730 for (
unsigned I = 0, N = ExistingPPOpts.
MacroIncludes.size(); I != N; ++I) {
737 SuggestedPredefines +=
"#__include_macros \"";
738 SuggestedPredefines += File;
739 SuggestedPredefines +=
"\"\n##\n";
747 std::string &SuggestedPredefines) {
751 Complain? &Reader.Diags :
nullptr,
760 std::string &SuggestedPredefines) {
762 PP.getPreprocessorOpts(),
775 StringRef SpecificModuleCachePath,
776 StringRef ExistingModuleCachePath,
779 if (LangOpts.Modules) {
780 if (SpecificModuleCachePath != ExistingModuleCachePath) {
782 Diags->
Report(diag::err_pch_modulecache_mismatch)
783 << SpecificModuleCachePath << ExistingModuleCachePath;
792 StringRef SpecificModuleCachePath,
795 PP.getHeaderSearchInfo().getModuleCachePath(),
796 Complain ? &Reader.Diags :
nullptr,
801 PP.setCounterValue(Value);
809 bool TakeOwnership) {
810 DeserializationListener = Listener;
811 OwnsDeserializationListener = TakeOwnership;
818 std::pair<unsigned, unsigned>
820 using namespace llvm::support;
822 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
823 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
824 return std::make_pair(KeyLen, DataLen);
829 using namespace llvm::support;
832 unsigned N = endian::readNext<uint16_t, little, unaligned>(d);
834 F, endian::readNext<uint32_t, little, unaligned>(d));
841 Args.push_back(FirstII);
842 for (
unsigned I = 1; I != N; ++I)
843 Args.push_back(Reader.getLocalIdentifier(
844 F, endian::readNext<uint32_t, little, unaligned>(d)));
852 using namespace llvm::support;
856 Result.
ID = Reader.getGlobalSelectorID(
857 F, endian::readNext<uint32_t, little, unaligned>(d));
858 unsigned FullInstanceBits = endian::readNext<uint16_t, little, unaligned>(d);
859 unsigned FullFactoryBits = endian::readNext<uint16_t, little, unaligned>(d);
864 unsigned NumInstanceMethods = FullInstanceBits >> 3;
865 unsigned NumFactoryMethods = FullFactoryBits >> 3;
868 for (
unsigned I = 0; I != NumInstanceMethods; ++I) {
870 F, endian::readNext<uint32_t, little, unaligned>(d)))
875 for (
unsigned I = 0; I != NumFactoryMethods; ++I) {
877 F, endian::readNext<uint32_t, little, unaligned>(d)))
878 Result.
Factory.push_back(Method);
885 return llvm::djbHash(a);
888 std::pair<unsigned, unsigned>
890 using namespace llvm::support;
892 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
893 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
894 return std::make_pair(KeyLen, DataLen);
899 assert(n >= 2 && d[n-1] ==
'\0');
900 return StringRef((
const char*) d, n-1);
915 bool Value = Bits & 0x1;
921 using namespace llvm::support;
923 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
924 return Reader.getGlobalIdentifierID(F, RawID >> 1);
937 const unsigned char* d,
939 using namespace llvm::support;
941 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
942 bool IsInteresting = RawID & 0x01;
950 II = &Reader.getIdentifierTable().getOwn(k);
954 Reader.markIdentifierUpToDate(II);
956 IdentID ID = Reader.getGlobalIdentifierID(F, RawID);
957 if (!IsInteresting) {
960 Reader.SetIdentifierInfo(ID, II);
964 unsigned ObjCOrBuiltinID = endian::readNext<uint16_t, little, unaligned>(d);
965 unsigned Bits = endian::readNext<uint16_t, little, unaligned>(d);
966 bool CPlusPlusOperatorKeyword =
readBit(Bits);
967 bool HasRevertedTokenIDToIdentifier =
readBit(Bits);
968 bool HasRevertedBuiltin =
readBit(Bits);
970 bool ExtensionToken =
readBit(Bits);
971 bool HadMacroDefinition =
readBit(Bits);
973 assert(Bits == 0 &&
"Extra bits in the identifier?");
978 if (HasRevertedTokenIDToIdentifier && II->
getTokenID() != tok::identifier)
986 "Incorrect ObjC keyword or builtin ID");
989 "Incorrect extension token flag");
990 (void)ExtensionToken;
994 "Incorrect C++ operator keyword flag");
995 (void)CPlusPlusOperatorKeyword;
999 if (HadMacroDefinition) {
1000 uint32_t MacroDirectivesOffset =
1001 endian::readNext<uint32_t, little, unaligned>(d);
1004 Reader.addPendingMacro(II, &F, MacroDirectivesOffset);
1007 Reader.SetIdentifierInfo(ID, II);
1013 for (; DataLen > 0; DataLen -= 4)
1014 DeclIDs.push_back(Reader.getGlobalDeclID(
1015 F, endian::readNext<uint32_t, little, unaligned>(d)));
1016 Reader.SetGloballyVisibleDecls(II, DeclIDs);
1023 :
Kind(Name.getNameKind()) {
1053 llvm::FoldingSetNodeID
ID;
1054 ID.AddInteger(
Kind);
1077 return ID.ComputeHash();
1081 ASTDeclContextNameLookupTrait::ReadFileRef(
const unsigned char *&d) {
1082 using namespace llvm::support;
1084 uint32_t ModuleFileID = endian::readNext<uint32_t, little, unaligned>(d);
1085 return Reader.getLocalModuleFile(F, ModuleFileID);
1088 std::pair<unsigned, unsigned>
1089 ASTDeclContextNameLookupTrait::ReadKeyDataLength(
const unsigned char *&d) {
1090 using namespace llvm::support;
1092 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
1093 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
1094 return std::make_pair(KeyLen, DataLen);
1098 ASTDeclContextNameLookupTrait::ReadKey(
const unsigned char *d,
unsigned) {
1099 using namespace llvm::support;
1107 Data = (uint64_t)Reader.getLocalIdentifier(
1108 F, endian::readNext<uint32_t, little, unaligned>(d));
1114 (uint64_t)Reader.getLocalSelector(
1115 F, endian::readNext<uint32_t, little, unaligned>(
1116 d)).getAsOpaquePtr();
1133 const unsigned char *d,
1136 using namespace llvm::support;
1138 for (
unsigned NumDecls = DataLen / 4; NumDecls; --NumDecls) {
1139 uint32_t LocalID = endian::readNext<uint32_t, little, unaligned>(d);
1140 Val.
insert(Reader.getGlobalDeclID(F, LocalID));
1144 bool ASTReader::ReadLexicalDeclContextStorage(
ModuleFile &M,
1155 unsigned Code =
Cursor.ReadCode();
1156 unsigned RecCode =
Cursor.readRecord(Code, Record, &Blob);
1158 Error(
"Expected lexical block");
1162 assert(!isa<TranslationUnitDecl>(DC) &&
1163 "expected a TU_UPDATE_LEXICAL record for TU");
1168 auto &Lex = LexicalDecls[DC];
1170 Lex = std::make_pair(
1171 &M, llvm::makeArrayRef(
1172 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
1180 bool ASTReader::ReadVisibleDeclContextStorage(
ModuleFile &M,
1191 unsigned Code =
Cursor.ReadCode();
1192 unsigned RecCode =
Cursor.readRecord(Code, Record, &Blob);
1194 Error(
"Expected visible lookup table block");
1200 auto *Data = (
const unsigned char*)Blob.data();
1201 PendingVisibleUpdates[
ID].push_back(PendingVisibleUpdate{&M, Data});
1205 void ASTReader::Error(StringRef Msg)
const {
1206 Error(diag::err_fe_pch_malformed, Msg);
1207 if (PP.getLangOpts().Modules && !Diags.isDiagnosticInFlight() &&
1208 !PP.getHeaderSearchInfo().getModuleCachePath().empty()) {
1209 Diag(diag::note_module_cache_path)
1210 << PP.getHeaderSearchInfo().getModuleCachePath();
1214 void ASTReader::Error(
unsigned DiagID,
1215 StringRef Arg1, StringRef Arg2)
const {
1216 if (Diags.isDiagnosticInFlight())
1217 Diags.SetDelayedDiagnostic(DiagID, Arg1, Arg2);
1219 Diag(DiagID) << Arg1 << Arg2;
1228 bool ASTReader::ParseLineTable(
ModuleFile &F,
1229 const RecordData &Record) {
1234 std::map<int, int> FileIDs;
1236 for (
unsigned I = 0; Record[Idx]; ++I) {
1238 auto Filename = ReadPath(F, Record, Idx);
1244 std::vector<LineEntry> Entries;
1245 while (Idx < Record.size()) {
1246 int FID = Record[Idx++];
1247 assert(FID >= 0 &&
"Serialized line entries for non-local file.");
1252 unsigned NumEntries = Record[Idx++];
1253 assert(NumEntries &&
"no line entries for file ID");
1255 Entries.reserve(NumEntries);
1256 for (
unsigned I = 0; I != NumEntries; ++I) {
1257 unsigned FileOffset = Record[Idx++];
1258 unsigned LineNo = Record[Idx++];
1259 int FilenameID = FileIDs[Record[Idx++]];
1262 unsigned IncludeOffset = Record[Idx++];
1264 FileKind, IncludeOffset));
1266 LineTable.
AddEntry(FileID::get(FID), Entries);
1273 bool ASTReader::ReadSourceManagerBlock(
ModuleFile &F) {
1274 using namespace SrcMgr;
1282 SLocEntryCursor = F.
Stream;
1285 if (F.
Stream.SkipBlock()) {
1286 Error(
"malformed block record in AST file");
1292 Error(
"malformed source manager block record in AST file");
1298 llvm::BitstreamEntry E = SLocEntryCursor.advanceSkippingSubblocks();
1301 case llvm::BitstreamEntry::SubBlock:
1303 Error(
"malformed block record in AST file");
1305 case llvm::BitstreamEntry::EndBlock:
1307 case llvm::BitstreamEntry::Record:
1315 switch (SLocEntryCursor.readRecord(E.ID, Record, &Blob)) {
1334 const std::string &OriginalDir,
1335 const std::string &CurrDir) {
1336 assert(OriginalDir != CurrDir &&
1337 "No point trying to resolve the file if the PCH dir didn't change");
1342 fs::make_absolute(filePath);
1343 assert(path::is_absolute(OriginalDir));
1346 path::const_iterator fileDirI = path::begin(path::parent_path(filePath)),
1347 fileDirE = path::end(path::parent_path(filePath));
1348 path::const_iterator origDirI = path::begin(OriginalDir),
1349 origDirE = path::end(OriginalDir);
1351 while (fileDirI != fileDirE && origDirI != origDirE &&
1352 *fileDirI == *origDirI) {
1356 for (; origDirI != origDirE; ++origDirI)
1357 path::append(currPCHPath,
"..");
1358 path::append(currPCHPath, fileDirI, fileDirE);
1359 path::append(currPCHPath, path::filename(Filename));
1360 return currPCHPath.str();
1367 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1368 Error(
"source location entry ID out-of-range for AST file");
1374 auto ReadBuffer = [
this](
1375 BitstreamCursor &SLocEntryCursor,
1376 StringRef Name) -> std::unique_ptr<llvm::MemoryBuffer> {
1379 unsigned Code = SLocEntryCursor.ReadCode();
1380 unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, &Blob);
1383 if (!llvm::zlib::isAvailable()) {
1384 Error(
"zlib is not available");
1389 llvm::zlib::uncompress(Blob, Uncompressed, Record[0])) {
1390 Error(
"could not decompress embedded file contents: " +
1394 return llvm::MemoryBuffer::getMemBufferCopy(Uncompressed, Name);
1396 return llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name,
true);
1398 Error(
"AST record has invalid code");
1403 ModuleFile *F = GlobalSLocEntryMap.find(-ID)->second;
1408 ++NumSLocEntriesRead;
1409 llvm::BitstreamEntry Entry = SLocEntryCursor.advance();
1410 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1411 Error(
"incorrectly-formatted source location entry in AST file");
1417 switch (SLocEntryCursor.readRecord(Entry.ID, Record, &Blob)) {
1419 Error(
"incorrectly-formatted source location entry in AST file");
1425 unsigned InputID = Record[4];
1426 InputFile IF = getInputFile(*F, InputID);
1439 IncludeLoc = getImportLocation(F);
1443 FileID FID = SourceMgr.createFileID(File, IncludeLoc, FileCharacter,
1444 ID, BaseOffset + Record[0]);
1447 FileInfo.NumCreatedFIDs = Record[5];
1452 unsigned NumFileDecls = Record[7];
1453 if (NumFileDecls && ContextObj) {
1454 assert(F->
FileSortedDecls &&
"FILE_SORTED_DECLS not encountered yet ?");
1455 FileDeclIDs[FID] = FileDeclsInfo(F, llvm::makeArrayRef(FirstDecl,
1460 = SourceMgr.getOrCreateContentCache(File,
isSystem(FileCharacter));
1464 auto Buffer = ReadBuffer(SLocEntryCursor, File->
getName());
1467 SourceMgr.overrideFileContents(File, std::move(Buffer));
1474 const char *Name = Blob.data();
1475 unsigned Offset = Record[0];
1480 IncludeLoc = getImportLocation(F);
1483 auto Buffer = ReadBuffer(SLocEntryCursor, Name);
1486 SourceMgr.createFileID(std::move(Buffer), FileCharacter, ID,
1487 BaseOffset + Offset, IncludeLoc);
1493 SourceMgr.createExpansionLoc(SpellingLoc,
1494 ReadSourceLocation(*F, Record[2]),
1495 ReadSourceLocation(*F, Record[3]),
1499 BaseOffset + Record[0]);
1511 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1512 Error(
"source location entry ID out-of-range for AST file");
1517 ModuleFile *M = GlobalSLocEntryMap.find(-ID)->second;
1535 assert(SourceMgr.getMainFileID().isValid() &&
"missing main file");
1536 return SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
1545 if (Cursor.EnterSubBlock(BlockID))
1549 uint64_t
Offset = Cursor.GetCurrentBitNo();
1550 unsigned Code = Cursor.ReadCode();
1553 if (Code != llvm::bitc::DEFINE_ABBREV) {
1554 Cursor.JumpToBit(Offset);
1557 Cursor.ReadAbbrevRecord();
1565 Tok.
setLocation(ReadSourceLocation(F, Record, Idx));
1581 Stream.JumpToBit(Offset);
1590 unsigned Flags = BitstreamCursor::AF_DontPopBlockAtEnd;
1591 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks(Flags);
1593 switch (Entry.Kind) {
1594 case llvm::BitstreamEntry::SubBlock:
1596 Error(
"malformed block record in AST file");
1598 case llvm::BitstreamEntry::EndBlock:
1600 case llvm::BitstreamEntry::Record:
1622 unsigned NextIndex = 1;
1624 MacroInfo *MI = PP.AllocateMacroInfo(Loc);
1631 bool isC99VarArgs = Record[NextIndex++];
1632 bool isGNUVarArgs = Record[NextIndex++];
1633 bool hasCommaPasting = Record[NextIndex++];
1634 MacroParams.clear();
1635 unsigned NumArgs = Record[NextIndex++];
1636 for (
unsigned i = 0; i != NumArgs; ++i)
1637 MacroParams.push_back(getLocalIdentifier(F, Record[NextIndex++]));
1651 if (NextIndex + 1 == Record.size() && PP.getPreprocessingRecord() &&
1652 Record[NextIndex]) {
1655 GlobalID = getGlobalPreprocessedEntityID(F, Record[NextIndex]);
1657 PreprocessingRecord::PPEntityID PPID =
1658 PPRec.getPPEntityID(GlobalID - 1,
true);
1660 PPRec.getPreprocessedEntity(PPID));
1662 PPRec.RegisterMacroDefinition(Macro, PPDef);
1675 Token Tok = ReadToken(F, Record, Idx);
1685 unsigned LocalID)
const {
1687 ReadModuleOffsetMap(M);
1692 &&
"Invalid index into preprocessed entity index remap");
1694 return LocalID + I->second;
1720 return FileMgr.
getFile(Key.Filename);
1722 std::string Resolved = Key.Filename;
1723 Reader.ResolveImportedPath(M, Resolved);
1724 return FileMgr.
getFile(Resolved);
1729 return FEA && FEA == FEB;
1732 std::pair<unsigned, unsigned>
1733 HeaderFileInfoTrait::ReadKeyDataLength(
const unsigned char*& d) {
1734 using namespace llvm::support;
1736 unsigned KeyLen = (unsigned) endian::readNext<uint16_t, little, unaligned>(d);
1737 unsigned DataLen = (unsigned) *d++;
1738 return std::make_pair(KeyLen, DataLen);
1742 HeaderFileInfoTrait::ReadKey(
const unsigned char *d,
unsigned) {
1743 using namespace llvm::support;
1746 ikey.
Size = off_t(endian::readNext<uint64_t, little, unaligned>(d));
1747 ikey.
ModTime = time_t(endian::readNext<uint64_t, little, unaligned>(d));
1756 using namespace llvm::support;
1758 const unsigned char *
End = d + DataLen;
1760 unsigned Flags = *d++;
1762 HFI.
isImport |= (Flags >> 5) & 0x01;
1764 HFI.
DirInfo = (Flags >> 1) & 0x07;
1771 M, endian::readNext<uint32_t, little, unaligned>(d));
1772 if (
unsigned FrameworkOffset =
1773 endian::readNext<uint32_t, little, unaligned>(d)) {
1776 StringRef FrameworkName(FrameworkStrings + FrameworkOffset - 1);
1777 HFI.
Framework = HS->getUniqueFrameworkName(FrameworkName);
1780 assert((End - d) % 4 == 0 &&
1781 "Wrong data length in HeaderFileInfo deserialization");
1783 uint32_t LocalSMID = endian::readNext<uint32_t, little, unaligned>(d);
1789 SubmoduleID GlobalSMID = Reader.getGlobalSubmoduleID(M, LocalSMID);
1790 Module *Mod = Reader.getSubmodule(GlobalSMID);
1793 Reader.getPreprocessor().getHeaderSearchInfo().getModuleMap();
1797 Reader.ResolveImportedPath(M, Filename);
1802 ModMap.
addHeader(Mod, H, HeaderRole,
true);
1814 uint64_t MacroDirectivesOffset) {
1815 assert(NumCurrentElementsDeserializing > 0 &&
"Missing deserialization guard");
1816 PendingMacroIDs[II].push_back(PendingMacroInfo(M, MacroDirectivesOffset));
1823 for (
ModuleFile &I : llvm::reverse(ModuleMgr)) {
1824 BitstreamCursor &MacroCursor = I.MacroCursor;
1827 if (MacroCursor.getBitcodeBytes().empty())
1830 BitstreamCursor
Cursor = MacroCursor;
1831 Cursor.JumpToBit(I.MacroStartOffset);
1835 llvm::BitstreamEntry E = Cursor.advanceSkippingSubblocks();
1838 case llvm::BitstreamEntry::SubBlock:
1840 Error(
"malformed block record in AST file");
1842 case llvm::BitstreamEntry::EndBlock:
1845 case llvm::BitstreamEntry::Record:
1847 switch (Cursor.readRecord(E.ID, Record)) {
1855 updateOutOfDateIdentifier(*II);
1873 class IdentifierLookupVisitor {
1876 unsigned PriorGeneration;
1877 unsigned &NumIdentifierLookups;
1878 unsigned &NumIdentifierLookupHits;
1882 IdentifierLookupVisitor(StringRef Name,
unsigned PriorGeneration,
1883 unsigned &NumIdentifierLookups,
1884 unsigned &NumIdentifierLookupHits)
1886 PriorGeneration(PriorGeneration),
1887 NumIdentifierLookups(NumIdentifierLookups),
1888 NumIdentifierLookupHits(NumIdentifierLookupHits) {}
1902 ++NumIdentifierLookups;
1903 ASTIdentifierLookupTable::iterator Pos =
1904 IdTable->find_hashed(Name, NameHash, &Trait);
1905 if (Pos == IdTable->end())
1911 ++NumIdentifierLookupHits;
1927 unsigned PriorGeneration = 0;
1928 if (getContext().getLangOpts().Modules)
1929 PriorGeneration = IdentifierGeneration[&II];
1935 if (!loadGlobalIndex()) {
1936 if (GlobalIndex->lookupIdentifier(II.
getName(), Hits)) {
1941 IdentifierLookupVisitor Visitor(II.
getName(), PriorGeneration,
1942 NumIdentifierLookups,
1943 NumIdentifierLookupHits);
1944 ModuleMgr.visit(Visitor, HitsPtr);
1945 markIdentifierUpToDate(&II);
1955 if (getContext().getLangOpts().Modules)
1956 IdentifierGeneration[II] = getGeneration();
1960 const PendingMacroInfo &PMInfo) {
1965 Cursor.JumpToBit(PMInfo.MacroDirectivesOffset);
1967 struct ModuleMacroRecord {
1979 llvm::BitstreamEntry Entry =
1980 Cursor.advance(BitstreamCursor::AF_DontPopBlockAtEnd);
1981 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1982 Error(
"malformed block record in AST file");
1992 ModuleMacros.push_back(ModuleMacroRecord());
1993 auto &Info = ModuleMacros.back();
1994 Info.SubModID = getGlobalSubmoduleID(M, Record[0]);
1995 Info.MI = getMacro(getGlobalMacroID(M, Record[1]));
1996 for (
int I = 2, N = Record.size(); I != N; ++I)
1997 Info.Overrides.push_back(getGlobalSubmoduleID(M, Record[I]));
2002 Error(
"malformed block record in AST file");
2013 std::reverse(ModuleMacros.begin(), ModuleMacros.end());
2015 for (
auto &MMR : ModuleMacros) {
2017 for (
unsigned ModID : MMR.Overrides) {
2018 Module *Mod = getSubmodule(ModID);
2019 auto *Macro = PP.getModuleMacro(Mod, II);
2020 assert(Macro &&
"missing definition for overridden macro");
2021 Overrides.push_back(Macro);
2024 bool Inserted =
false;
2025 Module *Owner = getSubmodule(MMR.SubModID);
2026 PP.addModuleMacro(Owner, II, MMR.MI, Overrides, Inserted);
2037 unsigned Idx = 0, N = Record.size();
2044 MacroInfo *MI = getMacro(getGlobalMacroID(M, Record[Idx++]));
2045 MD = PP.AllocateDefMacroDirective(MI, Loc);
2049 MD = PP.AllocateUndefMacroDirective(Loc);
2052 bool isPublic = Record[Idx++];
2053 MD = PP.AllocateVisibilityMacroDirective(Loc, isPublic);
2065 PP.setLoadedMacroDirective(II, Earliest, Latest);
2068 ASTReader::InputFileInfo
2069 ASTReader::readInputFileInfo(
ModuleFile &F,
unsigned ID) {
2075 unsigned Code = Cursor.ReadCode();
2079 unsigned Result = Cursor.readRecord(Code, Record, &Blob);
2080 assert(static_cast<InputFileRecordTypes>(Result) ==
INPUT_FILE &&
2081 "invalid record type for input file");
2084 assert(Record[0] == ID &&
"Bogus stored ID or offset");
2086 R.StoredSize =
static_cast<off_t
>(Record[1]);
2087 R.StoredTime =
static_cast<time_t
>(Record[2]);
2088 R.Overridden =
static_cast<bool>(Record[3]);
2089 R.Transient =
static_cast<bool>(Record[4]);
2090 R.TopLevelModuleMap =
static_cast<bool>(Record[5]);
2092 ResolveImportedPath(F, R.Filename);
2114 InputFileInfo FI = readInputFileInfo(F,
ID);
2115 off_t StoredSize = FI.StoredSize;
2116 time_t StoredTime = FI.StoredTime;
2117 bool Overridden = FI.Overridden;
2118 bool Transient = FI.Transient;
2121 const FileEntry *File = FileMgr.getFile(Filename,
false);
2128 if (!Resolved.empty())
2129 File = FileMgr.getFile(Resolved);
2134 if ((Overridden || Transient) && File ==
nullptr)
2135 File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime);
2137 if (File ==
nullptr) {
2139 std::string ErrorStr =
"could not find file '";
2141 ErrorStr +=
"' referenced by AST file '";
2159 Error(diag::err_fe_pch_file_overridden, Filename);
2171 FileMgr.modifyFileEntry(const_cast<FileEntry*>(File),
2172 StoredSize, StoredTime);
2175 bool IsOutOfDate =
false;
2179 (StoredSize != File->
getSize() ||
2186 while (!ImportStack.back()->ImportedBy.empty())
2187 ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
2190 StringRef TopLevelPCHName(ImportStack.back()->FileName);
2192 if (DiagnosticKind == 0)
2193 Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
2194 else if (DiagnosticKind == 1)
2195 Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName);
2197 Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName);
2200 if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
2201 Diag(diag::note_pch_required_by)
2202 << Filename << ImportStack[0]->FileName;
2203 for (
unsigned I = 1; I < ImportStack.size(); ++I)
2204 Diag(diag::note_pch_required_by)
2205 << ImportStack[I-1]->FileName << ImportStack[I]->FileName;
2208 if (!Diags.isDiagnosticInFlight())
2209 Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
2234 if (Filename.empty() || llvm::sys::path::is_absolute(Filename))
2238 llvm::sys::path::append(Buffer, Prefix, Filename);
2239 Filename.assign(Buffer.begin(), Buffer.end());
2254 llvm_unreachable(
"unknown ASTReadResult");
2258 BitstreamCursor &Stream,
unsigned ClientLoadCapabilities,
2260 std::string &SuggestedPredefines) {
2266 ASTReadResult Result = Success;
2268 llvm::BitstreamEntry Entry = Stream.advance();
2270 switch (Entry.Kind) {
2272 case llvm::BitstreamEntry::SubBlock:
2275 case llvm::BitstreamEntry::EndBlock:
2278 case llvm::BitstreamEntry::Record:
2287 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2288 if (ParseLanguageOptions(Record, Complain, Listener,
2289 AllowCompatibleConfigurationMismatch))
2290 Result = ConfigurationMismatch;
2295 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2296 if (ParseTargetOptions(Record, Complain, Listener,
2297 AllowCompatibleConfigurationMismatch))
2298 Result = ConfigurationMismatch;
2303 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2304 if (!AllowCompatibleConfigurationMismatch &&
2305 ParseFileSystemOptions(Record, Complain, Listener))
2306 Result = ConfigurationMismatch;
2311 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2312 if (!AllowCompatibleConfigurationMismatch &&
2313 ParseHeaderSearchOptions(Record, Complain, Listener))
2314 Result = ConfigurationMismatch;
2319 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2320 if (!AllowCompatibleConfigurationMismatch &&
2321 ParsePreprocessorOptions(Record, Complain, Listener,
2322 SuggestedPredefines))
2323 Result = ConfigurationMismatch;
2333 unsigned ClientLoadCapabilities) {
2334 BitstreamCursor &Stream = F.
Stream;
2335 ASTReadResult Result = Success;
2338 Error(
"malformed block record in AST file");
2348 bool HasReadUnhashedControlBlock =
false;
2349 auto readUnhashedControlBlockOnce = [&]() {
2350 if (!HasReadUnhashedControlBlock) {
2351 HasReadUnhashedControlBlock =
true;
2352 if (ASTReadResult Result =
2353 readUnhashedControlBlock(F, ImportedBy, ClientLoadCapabilities))
2361 unsigned NumInputs = 0;
2362 unsigned NumUserInputs = 0;
2364 llvm::BitstreamEntry Entry = Stream.advance();
2366 switch (Entry.Kind) {
2368 Error(
"malformed block record in AST file");
2370 case llvm::BitstreamEntry::EndBlock: {
2373 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2378 PP.getHeaderSearchInfo().getHeaderSearchOpts();
2385 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
2391 unsigned N = NumUserInputs;
2392 if (ValidateSystemInputs ||
2398 for (
unsigned I = 0; I < N; ++I) {
2399 InputFile IF = getInputFile(F, I+1, Complain);
2411 for (
unsigned I = 0; I < N; ++I) {
2412 bool IsSystem = I >= NumUserInputs;
2413 InputFileInfo FI = readInputFileInfo(F, I+1);
2423 case llvm::BitstreamEntry::SubBlock:
2427 if (Stream.SkipBlock() ||
2430 Error(
"malformed block record in AST file");
2439 if (Listener && !ImportedBy) {
2445 bool AllowCompatibleConfigurationMismatch =
2448 Result = ReadOptionsBlock(Stream, ClientLoadCapabilities,
2449 AllowCompatibleConfigurationMismatch,
2450 *Listener, SuggestedPredefines);
2451 if (Result == Failure) {
2452 Error(
"malformed block record in AST file");
2456 if (DisableValidation ||
2457 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
2463 if (Result != Success)
2465 }
else if (Stream.SkipBlock()) {
2466 Error(
"malformed block record in AST file");
2472 if (Stream.SkipBlock()) {
2473 Error(
"malformed block record in AST file");
2479 case llvm::BitstreamEntry::Record:
2490 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2492 : diag::err_pch_version_too_new);
2493 return VersionMismatch;
2496 bool hasErrors = Record[7];
2497 if (hasErrors && !DisableValidation && !AllowASTWithCompilerErrors) {
2498 Diag(diag::err_pch_with_compiler_errors);
2502 Diags.ErrorOccurred =
true;
2503 Diags.UncompilableErrorOccurred =
true;
2504 Diags.UnrecoverableErrorOccurred =
true;
2517 StringRef ASTBranch = Blob;
2518 if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
2519 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2520 Diag(diag::err_pch_different_branch) << ASTBranch << CurBranch;
2521 return VersionMismatch;
2530 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2534 unsigned Idx = 0, N = Record.size();
2542 ReadUntranslatedSourceLocation(Record[Idx++]);
2543 off_t StoredSize = (off_t)Record[Idx++];
2544 time_t StoredModTime = (time_t)Record[Idx++];
2546 {{(uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
2547 (uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
2548 (uint32_t)Record[Idx++]}}};
2550 std::string ImportedName = ReadString(Record, Idx);
2551 std::string ImportedFile;
2559 ImportedFile = PP.getHeaderSearchInfo().getPrebuiltModuleFileName(
2560 ImportedName,
true);
2562 if (ImportedFile.empty())
2563 ImportedFile = ReadPath(F, Record, Idx);
2565 SkipPath(Record, Idx);
2569 unsigned Capabilities = ClientLoadCapabilities;
2570 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2571 Capabilities &= ~ARR_Missing;
2574 auto Result = ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F,
2575 Loaded, StoredSize, StoredModTime,
2576 StoredSignature, Capabilities);
2580 Diag(diag::note_module_file_imported_by)
2584 case Failure:
return Failure;
2587 case OutOfDate:
return OutOfDate;
2588 case VersionMismatch:
return VersionMismatch;
2589 case ConfigurationMismatch:
return ConfigurationMismatch;
2590 case HadErrors:
return HadErrors;
2591 case Success:
break;
2619 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2626 "MODULE_DIRECTORY found before MODULE_NAME");
2629 Module *M = PP.getHeaderSearchInfo().lookupModule(
2632 if (M && M->Directory) {
2636 if (!PP.getPreprocessorOpts().DisablePCHValidation &&
2639 PP.getFileManager().getDirectory(Blob);
2640 if (!BuildDir || BuildDir != M->Directory) {
2641 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2642 Diag(diag::err_imported_module_relocated)
2643 << F.
ModuleName << Blob << M->Directory->getName();
2655 if (ASTReadResult Result =
2656 ReadModuleMapFileBlock(Record, F, ImportedBy, ClientLoadCapabilities))
2661 NumInputs = Record[0];
2662 NumUserInputs = Record[1];
2664 (
const llvm::support::unaligned_uint64_t *)Blob.data();
2673 ASTReader::ReadASTBlock(
ModuleFile &F,
unsigned ClientLoadCapabilities) {
2674 BitstreamCursor &Stream = F.
Stream;
2677 Error(
"malformed block record in AST file");
2684 llvm::BitstreamEntry Entry = Stream.advance();
2686 switch (Entry.Kind) {
2688 Error(
"error at end of module block in AST file");
2690 case llvm::BitstreamEntry::EndBlock:
2703 case llvm::BitstreamEntry::SubBlock:
2711 if (Stream.SkipBlock() ||
2714 Error(
"malformed block record in AST file");
2721 if (!PP.getExternalSource())
2722 PP.setExternalSource(
this);
2724 if (Stream.SkipBlock() ||
2726 Error(
"malformed block record in AST file");
2734 if (Stream.SkipBlock() ||
2737 Error(
"malformed preprocessor detail record in AST file");
2743 if (!PP.getPreprocessingRecord())
2744 PP.createPreprocessingRecord();
2745 if (!PP.getPreprocessingRecord()->getExternalSource())
2746 PP.getPreprocessingRecord()->SetExternalSource(*
this);
2750 if (ReadSourceManagerBlock(F))
2755 if (ASTReadResult Result =
2756 ReadSubmoduleBlock(F, ClientLoadCapabilities))
2761 BitstreamCursor C = Stream;
2762 if (Stream.SkipBlock() ||
2764 Error(
"malformed comments block in AST file");
2767 CommentsCursors.push_back(std::make_pair(C, &F));
2772 if (Stream.SkipBlock()) {
2773 Error(
"malformed block record in AST file");
2780 case llvm::BitstreamEntry::Record:
2820 Error(
"duplicate TYPE_OFFSET record in AST file");
2825 unsigned LocalBaseTypeIndex = Record[1];
2830 GlobalTypeMap.insert(std::make_pair(getTotalNumTypes(), &F));
2834 std::make_pair(LocalBaseTypeIndex,
2844 Error(
"duplicate DECL_OFFSET record in AST file");
2849 unsigned LocalBaseDeclID = Record[1];
2855 GlobalDeclMap.insert(
2861 std::make_pair(LocalBaseDeclID, F.
BaseDeclID - LocalBaseDeclID));
2873 DeclContext *TU = ContextObj->getTranslationUnitDecl();
2874 LexicalContents Contents(
2875 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
2877 static_cast<unsigned int>(Blob.size() / 4));
2878 TULexicalDecls.push_back(std::make_pair(&F, Contents));
2886 auto *Data = (
const unsigned char*)Blob.data();
2887 PendingVisibleUpdates[
ID].push_back(PendingVisibleUpdate{&F, Data});
2890 if (
Decl *D = GetExistingDecl(ID))
2891 PendingUpdateRecords.push_back(
2892 PendingUpdateRecord(ID, D,
false));
2905 PP.getIdentifierTable().setExternalIdentifierLookup(
this);
2911 Error(
"duplicate IDENTIFIER_OFFSET record in AST file");
2916 unsigned LocalBaseIdentifierID = Record[1];
2922 GlobalIdentifierMap.insert(std::make_pair(getTotalNumIdentifiers() + 1,
2928 std::make_pair(LocalBaseIdentifierID,
2931 IdentifiersLoaded.resize(IdentifiersLoaded.size()
2944 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2945 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
2952 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2953 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
2957 if (SpecialTypes.empty()) {
2958 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2959 SpecialTypes.push_back(getGlobalTypeID(F, Record[I]));
2963 if (SpecialTypes.size() != Record.size()) {
2964 Error(
"invalid special-types record");
2968 for (
unsigned I = 0, N = Record.size(); I != N; ++I) {
2970 if (!SpecialTypes[I])
2971 SpecialTypes[I] =
ID;
2978 TotalNumStatements += Record[0];
2979 TotalNumMacros += Record[1];
2980 TotalLexicalDeclContexts += Record[2];
2981 TotalVisibleDeclContexts += Record[3];
2985 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2986 UnusedFileScopedDecls.push_back(getGlobalDeclID(F, Record[I]));
2990 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
2991 DelegatingCtorDecls.push_back(getGlobalDeclID(F, Record[I]));
2995 if (Record.size() % 4 != 0) {
2996 Error(
"invalid weak identifiers record");
3002 WeakUndeclaredIdentifiers.clear();
3005 for (
unsigned I = 0, N = Record.size(); I < N; ) {
3006 WeakUndeclaredIdentifiers.push_back(
3007 getGlobalIdentifierID(F, Record[I++]));
3008 WeakUndeclaredIdentifiers.push_back(
3009 getGlobalIdentifierID(F, Record[I++]));
3010 WeakUndeclaredIdentifiers.push_back(
3011 ReadSourceLocation(F, Record, I).getRawEncoding());
3012 WeakUndeclaredIdentifiers.push_back(Record[I++]);
3019 unsigned LocalBaseSelectorID = Record[1];
3025 GlobalSelectorMap.insert(std::make_pair(getTotalNumSelectors()+1, &F));
3030 std::make_pair(LocalBaseSelectorID,
3046 TotalNumMethodPoolEntries += Record[1];
3050 if (!Record.empty()) {
3051 for (
unsigned Idx = 0, N = Record.size() - 1; Idx < N; ) {
3052 ReferencedSelectorsData.push_back(getGlobalSelectorID(F,
3054 ReferencedSelectorsData.push_back(ReadSourceLocation(F, Record, Idx).
3061 if (!Record.empty()) {
3062 unsigned Idx = 0,
End = Record.size() - 1;
3063 bool ReachedEOFWhileSkipping = Record[Idx++];
3065 if (ReachedEOFWhileSkipping) {
3068 bool FoundNonSkipPortion = Record[Idx++];
3069 bool FoundElse = Record[Idx++];
3071 SkipInfo.emplace(HashToken, IfTokenLoc, FoundNonSkipPortion,
3072 FoundElse, ElseLoc);
3076 auto Loc = ReadSourceLocation(F, Record, Idx);
3077 bool WasSkipping = Record[Idx++];
3078 bool FoundNonSkip = Record[Idx++];
3079 bool FoundElse = Record[Idx++];
3080 ConditionalStack.push_back(
3081 {Loc, WasSkipping, FoundNonSkip, FoundElse});
3083 PP.setReplayablePreambleConditionalStack(ConditionalStack, SkipInfo);
3088 if (!Record.empty() && Listener)
3100 unsigned SLocSpaceSize = Record[1];
3105 Error(
"ran out of source locations");
3111 unsigned RangeStart =
3113 GlobalSLocEntryMap.insert(std::make_pair(RangeStart, &F));
3118 GlobalSLocOffsetMap.insert(
3120 - SLocSpaceSize,&F));
3138 if (ParseLineTable(F, Record))
3146 Error(
"Multiple SOURCE_LOCATION_PRELOADS records in AST file");
3155 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3156 ExtVectorDecls.push_back(getGlobalDeclID(F, Record[I]));
3160 if (Record.size() % 3 != 0) {
3161 Error(
"Invalid VTABLE_USES record");
3170 for (
unsigned Idx = 0, N = Record.size(); Idx != N; ) {
3171 VTableUses.push_back(getGlobalDeclID(F, Record[Idx++]));
3172 VTableUses.push_back(
3173 ReadSourceLocation(F, Record, Idx).getRawEncoding());
3174 VTableUses.push_back(Record[Idx++]);
3179 if (PendingInstantiations.size() % 2 != 0) {
3180 Error(
"Invalid existing PendingInstantiations");
3184 if (Record.size() % 2 != 0) {
3185 Error(
"Invalid PENDING_IMPLICIT_INSTANTIATIONS block");
3189 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3190 PendingInstantiations.push_back(getGlobalDeclID(F, Record[I++]));
3191 PendingInstantiations.push_back(
3192 ReadSourceLocation(F, Record, I).getRawEncoding());
3197 if (Record.size() != 3) {
3198 Error(
"Invalid SEMA_DECL_REFS block");
3201 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3202 SemaDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
3210 unsigned LocalBasePreprocessedEntityID = Record[0];
3212 unsigned StartingID;
3213 if (!PP.getPreprocessingRecord())
3214 PP.createPreprocessingRecord();
3215 if (!PP.getPreprocessingRecord()->getExternalSource())
3216 PP.getPreprocessingRecord()->SetExternalSource(*
this);
3218 = PP.getPreprocessingRecord()
3225 GlobalPreprocessedEntityMap.insert(std::make_pair(StartingID, &F));
3230 std::make_pair(LocalBasePreprocessedEntityID,
3242 if (!PP.getPreprocessingRecord())
3243 PP.createPreprocessingRecord();
3244 if (!PP.getPreprocessingRecord()->getExternalSource())
3245 PP.getPreprocessingRecord()->SetExternalSource(*
this);
3250 GlobalSkippedRangeMap.insert(
3256 if (Record.size() % 2 != 0) {
3257 Error(
"invalid DECL_UPDATE_OFFSETS block in AST file");
3260 for (
unsigned I = 0, N = Record.size(); I != N; I += 2) {
3262 DeclUpdateOffsets[
ID].push_back(std::make_pair(&F, Record[I + 1]));
3266 if (
Decl *D = GetExistingDecl(ID))
3267 PendingUpdateRecords.push_back(
3268 PendingUpdateRecord(ID, D,
false));
3274 Error(
"duplicate OBJC_CATEGORIES_MAP record in AST file");
3289 CUDASpecialDeclRefs.clear();
3290 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3291 CUDASpecialDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
3303 &PP.getHeaderSearchInfo(),
3304 Blob.data() + Record[2]));
3306 PP.getHeaderSearchInfo().SetExternalSource(
this);
3307 if (!PP.getHeaderSearchInfo().getExternalLookup())
3308 PP.getHeaderSearchInfo().SetExternalLookup(
this);
3314 FPPragmaOptions.swap(Record);
3318 for (
unsigned I = 0, E = Record.size(); I != E; ) {
3319 auto Name = ReadString(Record, I);
3320 auto &Opt = OpenCLExtensions.OptMap[Name];
3321 Opt.Supported = Record[I++] != 0;
3322 Opt.Enabled = Record[I++] != 0;
3323 Opt.Avail = Record[I++];
3324 Opt.Core = Record[I++];
3329 for (
unsigned I = 0, E = Record.size(); I != E;) {
3332 auto NumExt =
static_cast<unsigned>(Record[I++]);
3333 for (
unsigned II = 0; II != NumExt; ++II) {
3334 auto Ext = ReadString(Record, I);
3335 OpenCLTypeExtMap[
Type].insert(Ext);
3341 for (
unsigned I = 0, E = Record.size(); I != E;) {
3344 auto NumExt =
static_cast<unsigned>(Record[I++]);
3345 for (
unsigned II = 0; II != NumExt; ++II) {
3346 auto Ext = ReadString(Record, I);
3347 OpenCLDeclExtMap[
Decl].insert(Ext);
3353 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3354 TentativeDefinitions.push_back(getGlobalDeclID(F, Record[I]));
3358 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3359 KnownNamespaces.push_back(getGlobalDeclID(F, Record[I]));
3363 if (UndefinedButUsed.size() % 2 != 0) {
3364 Error(
"Invalid existing UndefinedButUsed");
3368 if (Record.size() % 2 != 0) {
3369 Error(
"invalid undefined-but-used record");
3372 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3373 UndefinedButUsed.push_back(getGlobalDeclID(F, Record[I++]));
3374 UndefinedButUsed.push_back(
3375 ReadSourceLocation(F, Record, I).getRawEncoding());
3380 for (
unsigned I = 0, N = Record.size(); I != N;) {
3381 DelayedDeleteExprs.push_back(getGlobalDeclID(F, Record[I++]));
3382 const uint64_t Count = Record[I++];
3383 DelayedDeleteExprs.push_back(Count);
3384 for (uint64_t C = 0; C < Count; ++C) {
3385 DelayedDeleteExprs.push_back(ReadSourceLocation(F, Record, I).getRawEncoding());
3386 bool IsArrayForm = Record[I++] == 1;
3387 DelayedDeleteExprs.push_back(IsArrayForm);
3397 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3398 unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
3401 ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
3402 if (DeserializationListener)
3403 DeserializationListener->ModuleImportRead(GlobalID, Loc);
3411 Error(
"duplicate MACRO_OFFSET record in AST file");
3416 unsigned LocalBaseMacroID = Record[1];
3421 GlobalMacroMap.insert(std::make_pair(getTotalNumMacros() + 1, &F));
3425 std::make_pair(LocalBaseMacroID,
3434 LateParsedTemplates.append(Record.begin(), Record.end());
3438 if (Record.size() != 1) {
3439 Error(
"invalid pragma optimize record");
3442 OptimizeOffPragmaLocation = ReadSourceLocation(F, Record[0]);
3446 if (Record.size() != 1) {
3447 Error(
"invalid pragma ms_struct record");
3450 PragmaMSStructState = Record[0];
3454 if (Record.size() != 2) {
3455 Error(
"invalid pragma ms_struct record");
3458 PragmaMSPointersToMembersState = Record[0];
3459 PointersToMembersPragmaLocation = ReadSourceLocation(F, Record[1]);
3463 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3464 UnusedLocalTypedefNameCandidates.push_back(
3465 getGlobalDeclID(F, Record[I]));
3469 if (Record.size() != 1) {
3470 Error(
"invalid cuda pragma options record");
3473 ForceCUDAHostDeviceDepth = Record[0];
3477 if (Record.size() < 3) {
3478 Error(
"invalid pragma pack record");
3481 PragmaPackCurrentValue = Record[0];
3482 PragmaPackCurrentLocation = ReadSourceLocation(F, Record[1]);
3483 unsigned NumStackEntries = Record[2];
3486 PragmaPackStack.clear();
3487 for (
unsigned I = 0; I < NumStackEntries; ++I) {
3488 PragmaPackStackEntry Entry;
3489 Entry.Value = Record[Idx++];
3490 Entry.Location = ReadSourceLocation(F, Record[Idx++]);
3491 Entry.PushLocation = ReadSourceLocation(F, Record[Idx++]);
3492 PragmaPackStrings.push_back(ReadString(Record, Idx));
3493 Entry.SlotLabel = PragmaPackStrings.back();
3494 PragmaPackStack.push_back(Entry);
3502 void ASTReader::ReadModuleOffsetMap(
ModuleFile &F)
const {
3506 const unsigned char *Data = (
const unsigned char*)F.
ModuleOffsetMap.data();
3527 while (Data < DataEnd) {
3531 using namespace llvm::support;
3533 endian::readNext<uint8_t, little, unaligned>(Data));
3534 uint16_t Len = endian::readNext<uint16_t, little, unaligned>(Data);
3535 StringRef Name = StringRef((
const char*)Data, Len);
3538 ? ModuleMgr.lookupByModuleName(Name)
3539 : ModuleMgr.lookupByFileName(Name));
3542 "SourceLocation remap refers to unknown module, cannot find ";
3548 uint32_t SLocOffset =
3549 endian::readNext<uint32_t, little, unaligned>(Data);
3550 uint32_t IdentifierIDOffset =
3551 endian::readNext<uint32_t, little, unaligned>(Data);
3552 uint32_t MacroIDOffset =
3553 endian::readNext<uint32_t, little, unaligned>(Data);
3554 uint32_t PreprocessedEntityIDOffset =
3555 endian::readNext<uint32_t, little, unaligned>(Data);
3556 uint32_t SubmoduleIDOffset =
3557 endian::readNext<uint32_t, little, unaligned>(Data);
3558 uint32_t SelectorIDOffset =
3559 endian::readNext<uint32_t, little, unaligned>(Data);
3560 uint32_t DeclIDOffset =
3561 endian::readNext<uint32_t, little, unaligned>(Data);
3562 uint32_t TypeIndexOffset =
3563 endian::readNext<uint32_t, little, unaligned>(Data);
3567 auto mapOffset = [&](uint32_t
Offset, uint32_t BaseOffset,
3568 RemapBuilder &Remap) {
3570 Remap.insert(std::make_pair(Offset,
3571 static_cast<int>(BaseOffset - Offset)));
3575 mapOffset(MacroIDOffset, OM->
BaseMacroID, MacroRemap);
3577 PreprocessedEntityRemap);
3580 mapOffset(DeclIDOffset, OM->
BaseDeclID, DeclRemap);
3589 ASTReader::ReadModuleMapFileBlock(RecordData &Record,
ModuleFile &F,
3591 unsigned ClientLoadCapabilities) {
3600 "MODULE_NAME should come before MODULE_MAP_FILE");
3605 auto &Map = PP.getHeaderSearchInfo().getModuleMap();
3606 const FileEntry *ModMap = M ? Map.getModuleMapFileForUniquing(M) :
nullptr;
3608 if (!PP.getPreprocessorOpts().DisablePCHValidation && !ModMap) {
3609 assert(ImportedBy &&
"top-level import should be verified");
3610 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) {
3611 if (
auto *ASTFE = M ? M->
getASTFile() :
nullptr) {
3614 << ASTFE->getName();
3617 Diag(diag::err_imported_module_not_found)
3624 Diag(diag::note_imported_by_pch_module_not_found)
3631 assert(M->
Name == F.
ModuleName &&
"found module with different name");
3635 if (StoredModMap ==
nullptr || StoredModMap != ModMap) {
3636 assert(ModMap &&
"found module is missing module map file");
3637 assert(ImportedBy &&
"top-level import should be verified");
3638 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3639 Diag(diag::err_imported_module_modmap_changed)
3645 llvm::SmallPtrSet<const FileEntry *, 1> AdditionalStoredMaps;
3646 for (
unsigned I = 0, N = Record[Idx++]; I < N; ++I) {
3648 std::string
Filename = ReadPath(F, Record, Idx);
3650 FileMgr.getFile(Filename,
false,
false);
3652 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3653 Error(
"could not find file '" + Filename +
"' referenced by AST file");
3656 AdditionalStoredMaps.insert(F);
3661 if (
auto *AdditionalModuleMaps = Map.getAdditionalModuleMapFiles(M)) {
3662 for (
const FileEntry *ModMap : *AdditionalModuleMaps) {
3665 if (!AdditionalStoredMaps.erase(ModMap)) {
3666 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3667 Diag(diag::err_module_different_modmap)
3676 for (
const FileEntry *ModMap : AdditionalStoredMaps) {
3677 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3678 Diag(diag::err_module_different_modmap)
3692 Sema::GlobalMethodPool::iterator Known
3699 : Known->second.second;
3701 for (
ObjCMethodList *List = &Start; List; List = List->getNext()) {
3703 if (List->getMethod() == Method) {
3711 if (List->getNext())
3712 List->setMethod(List->getNext()->getMethod());
3714 List->setMethod(Method);
3720 for (
Decl *D : Names) {
3721 bool wasHidden = D->isHidden();
3722 D->setVisibleDespiteOwningModule();
3724 if (wasHidden && SemaObj) {
3735 llvm::SmallPtrSet<Module *, 4> Visited;
3737 Stack.push_back(Mod);
3738 while (!Stack.empty()) {
3739 Mod = Stack.pop_back_val();
3741 if (NameVisibility <= Mod->NameVisibility) {
3757 HiddenNamesMapType::iterator Hidden = HiddenNamesMap.find(Mod);
3758 if (Hidden != HiddenNamesMap.end()) {
3760 HiddenNamesMap.erase(Hidden);
3762 assert(HiddenNamesMap.find(Mod) == HiddenNamesMap.end() &&
3763 "making names visible added hidden names");
3770 I = Exports.begin(), E = Exports.end(); I != E; ++I) {
3772 if (Visited.insert(Exported).second)
3773 Stack.push_back(Exported);
3790 else if (getContext().getLangOpts().ModulesLocalVisibility) {
3791 getContext().mergeDefinitionIntoModule(
3794 PendingMergedDefinitionsToDeduplicate.insert(Def);
3797 assert(
SubmoduleID &&
"hidden definition in no module");
3798 HiddenNamesMap[getSubmodule(
SubmoduleID)].push_back(Def);
3807 if (TriedLoadingGlobalIndex || !UseGlobalIndex ||
3808 !PP.getLangOpts().Modules)
3812 TriedLoadingGlobalIndex =
true;
3813 StringRef ModuleCachePath
3814 = getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
3815 std::pair<GlobalModuleIndex *, GlobalModuleIndex::ErrorCode> Result
3820 GlobalIndex.reset(Result.first);
3821 ModuleMgr.setGlobalIndex(GlobalIndex.get());
3826 return PP.getLangOpts().Modules && UseGlobalIndex &&
3827 !hasGlobalIndex() && TriedLoadingGlobalIndex;
3834 llvm::raw_fd_ostream OS(TimestampFilename, EC, llvm::sys::fs::F_Text);
3837 OS <<
"Timestamp file\n";
3847 llvm::BitstreamEntry Entry = Cursor.advance();
3848 switch (Entry.Kind) {
3850 case llvm::BitstreamEntry::EndBlock:
3853 case llvm::BitstreamEntry::Record:
3855 Cursor.skipRecord(Entry.ID);
3858 case llvm::BitstreamEntry::SubBlock:
3859 if (Entry.ID == BlockID) {
3860 if (Cursor.EnterSubBlock(BlockID))
3866 if (Cursor.SkipBlock())
3875 unsigned ClientLoadCapabilities,
3878 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
3884 unsigned PreviousGeneration = 0;
3886 PreviousGeneration = incrementGeneration(*ContextObj);
3888 unsigned NumModules = ModuleMgr.size();
3891 ReadASTCore(FileName, Type, ImportLoc,
3892 nullptr, Loaded, 0, 0,
3897 case VersionMismatch:
3898 case ConfigurationMismatch:
3900 llvm::SmallPtrSet<ModuleFile *, 4> LoadedSet;
3901 for (
const ImportedModule &IM : Loaded)
3902 LoadedSet.insert(IM.Mod);
3904 ModuleMgr.removeModules(ModuleMgr.begin() + NumModules, LoadedSet,
3905 PP.getLangOpts().Modules
3906 ? &PP.getHeaderSearchInfo().getModuleMap()
3911 GlobalIndex.reset();
3912 ModuleMgr.setGlobalIndex(
nullptr);
3923 MEnd = Loaded.end();
3928 if (
ASTReadResult Result = ReadASTBlock(F, ClientLoadCapabilities))
3950 SourceMgr.getLoadedSLocEntryByID(Index);
3963 const unsigned char *Data =
reinterpret_cast<const unsigned char *
>(
3968 auto Key = Trait.
ReadKey(Data, KeyDataLen.first);
3969 auto &II = PP.getIdentifierTable().getOwn(Key);
3970 II.setOutOfDate(
true);
3978 SetIdentifierInfo(
ID, &II);
3985 MEnd = Loaded.end();
3989 ModuleMgr.moduleFileAccepted(&F);
4001 if (!PP.getLangOpts().CPlusPlus ||
4012 IdEnd = PP.getIdentifierTable().end();
4014 Id->second->setOutOfDate(
true);
4017 for (
auto Sel : SelectorGeneration)
4018 SelectorOutOfDate[Sel.first] =
true;
4021 for (
unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I) {
4022 UnresolvedModuleRef &Unresolved = UnresolvedModuleRefs[I];
4023 SubmoduleID GlobalID = getGlobalSubmoduleID(*Unresolved.File,Unresolved.ID);
4024 Module *ResolvedMod = getSubmodule(GlobalID);
4026 switch (Unresolved.Kind) {
4027 case UnresolvedModuleRef::Conflict:
4030 Conflict.
Other = ResolvedMod;
4031 Conflict.
Message = Unresolved.String.str();
4032 Unresolved.Mod->Conflicts.push_back(Conflict);
4036 case UnresolvedModuleRef::Import:
4038 Unresolved.Mod->Imports.insert(ResolvedMod);
4041 case UnresolvedModuleRef::Export:
4042 if (ResolvedMod || Unresolved.IsWildcard)
4043 Unresolved.Mod->Exports.push_back(
4048 UnresolvedModuleRefs.clear();
4051 Imported->append(ImportedModules.begin(),
4052 ImportedModules.end());
4059 InitializeContext();
4064 if (DeserializationListener)
4065 DeserializationListener->ReaderInitialized(
this);
4067 ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule();
4082 for (
unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++I) {
4083 loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
4084 ObjCClassesLoaded[I],
4085 PreviousGeneration);
4089 if (PP.getHeaderSearchInfo()
4090 .getHeaderSearchOpts()
4091 .ModulesValidateOncePerBuildSession) {
4096 for (
unsigned I = 0, N = Loaded.size(); I != N; ++I) {
4097 ImportedModule &M = Loaded[I];
4111 return Stream.canSkipToPos(4) &&
4112 Stream.Read(8) ==
'C' &&
4113 Stream.Read(8) ==
'P' &&
4114 Stream.Read(8) ==
'C' &&
4115 Stream.Read(8) ==
'H';
4130 llvm_unreachable(
"unknown module kind");
4134 ASTReader::ReadASTCore(StringRef FileName,
4139 off_t ExpectedSize, time_t ExpectedModTime,
4141 unsigned ClientLoadCapabilities) {
4143 std::string ErrorStr;
4145 = ModuleMgr.addModule(FileName,
Type, ImportLoc, ImportedBy,
4146 getGeneration(), ExpectedSize, ExpectedModTime,
4147 ExpectedSignature, readASTFileSignature,
4150 switch (AddResult) {
4161 if (ClientLoadCapabilities & ARR_Missing)
4166 << FileName << !ErrorStr.empty()
4173 if (ClientLoadCapabilities & ARR_OutOfDate)
4178 << FileName << !ErrorStr.empty()
4183 assert(M &&
"Missing module file");
4186 BitstreamCursor &Stream = F.
Stream;
4187 Stream = BitstreamCursor(PCHContainerRdr.ExtractPCH(*F.
Buffer));
4198 bool HaveReadControlBlock =
false;
4200 llvm::BitstreamEntry Entry = Stream.advance();
4202 switch (Entry.Kind) {
4204 case llvm::BitstreamEntry::Record:
4205 case llvm::BitstreamEntry::EndBlock:
4206 Error(
"invalid record at top-level of AST file");
4209 case llvm::BitstreamEntry::SubBlock:
4215 HaveReadControlBlock =
true;
4216 switch (ReadControlBlock(F, Loaded, ImportedBy, ClientLoadCapabilities)) {
4226 if (Result != OutOfDate ||
4227 (ClientLoadCapabilities & ARR_OutOfDate) == 0)
4228 Diag(diag::err_module_file_not_module) << FileName;
4233 case Failure:
return Failure;
4234 case Missing:
return Missing;
4235 case OutOfDate:
return OutOfDate;
4236 case VersionMismatch:
return VersionMismatch;
4237 case ConfigurationMismatch:
return ConfigurationMismatch;
4238 case HadErrors:
return HadErrors;
4243 if (!HaveReadControlBlock) {
4244 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
4245 Diag(diag::err_pch_version_too_old);
4246 return VersionMismatch;
4250 Loaded.push_back(ImportedModule(M, ImportedBy, ImportLoc));
4256 Error(
"malformed block record in AST file");
4260 if (Stream.SkipBlock()) {
4261 Error(
"malformed block record in AST file");
4272 ASTReader::readUnhashedControlBlock(
ModuleFile &F,
bool WasImportedBy,
4273 unsigned ClientLoadCapabilities) {
4275 PP.getHeaderSearchInfo().getHeaderSearchOpts();
4276 bool AllowCompatibleConfigurationMismatch =
4279 ASTReadResult Result = readUnhashedControlBlockImpl(
4280 &F, F.
Data, ClientLoadCapabilities, AllowCompatibleConfigurationMismatch,
4286 if (DisableValidation || WasImportedBy ||
4287 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
4290 if (Result == Failure) {
4291 Error(
"malformed block record in AST file");
4314 if (PCMCache.isBufferFinal(F.
FileName)) {
4315 Diag(diag::warn_module_system_bit_conflict) << F.
FileName;
4324 ModuleFile *F, llvm::StringRef StreamData,
unsigned ClientLoadCapabilities,
4326 bool ValidateDiagnosticOptions) {
4328 BitstreamCursor Stream(StreamData);
4340 ASTReadResult Result = Success;
4342 llvm::BitstreamEntry Entry = Stream.advance();
4344 switch (Entry.Kind) {
4346 case llvm::BitstreamEntry::SubBlock:
4349 case llvm::BitstreamEntry::EndBlock:
4352 case llvm::BitstreamEntry::Record:
4363 std::copy(Record.begin(), Record.end(), F->
Signature.data());
4366 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
4367 if (Listener && ValidateDiagnosticOptions &&
4368 !AllowCompatibleConfigurationMismatch &&
4369 ParseDiagnosticOptions(Record, Complain, *Listener))
4380 Record.begin(), Record.end());
4391 if (Record.size() < 4)
return true;
4396 unsigned BlockNameLen = Record[2];
4397 unsigned UserInfoLen = Record[3];
4399 if (BlockNameLen + UserInfoLen > Blob.size())
return true;
4401 Metadata.
BlockName = std::string(Blob.data(), Blob.data() + BlockNameLen);
4402 Metadata.
UserInfo = std::string(Blob.data() + BlockNameLen,
4403 Blob.data() + BlockNameLen + UserInfoLen);
4408 BitstreamCursor &Stream = F.
Stream;
4412 llvm::BitstreamEntry Entry = Stream.advance();
4413 switch (Entry.Kind) {
4414 case llvm::BitstreamEntry::SubBlock:
4415 if (Stream.SkipBlock())
4420 case llvm::BitstreamEntry::EndBlock:
4426 case llvm::BitstreamEntry::Record:
4432 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4440 auto Known = ModuleFileExtensions.find(Metadata.
BlockName);
4441 if (Known == ModuleFileExtensions.end())
break;
4444 if (
auto Reader = Known->second->createExtensionReader(Metadata, *
this,
4458 assert(ContextObj &&
"no context to initialize");
4462 if (DeserializationListener)
4472 if (!Context.CFConstantStringTypeDecl)
4479 Error(
"FILE type is NULL");
4483 if (!Context.FILEDecl) {
4489 Error(
"Invalid FILE type in AST file");
4498 QualType Jmp_bufType = GetType(Jmp_buf);
4499 if (Jmp_bufType.
isNull()) {
4500 Error(
"jmp_buf type is NULL");
4504 if (!Context.jmp_bufDecl) {
4510 Error(
"Invalid jmp_buf type in AST file");
4519 QualType Sigjmp_bufType = GetType(Sigjmp_buf);
4520 if (Sigjmp_bufType.
isNull()) {
4521 Error(
"sigjmp_buf type is NULL");
4525 if (!Context.sigjmp_bufDecl) {
4530 assert(Tag &&
"Invalid sigjmp_buf type in AST file");
4536 if (
unsigned ObjCIdRedef
4538 if (Context.ObjCIdRedefinitionType.
isNull())
4539 Context.ObjCIdRedefinitionType = GetType(ObjCIdRedef);
4542 if (
unsigned ObjCClassRedef
4544 if (Context.ObjCClassRedefinitionType.
isNull())
4545 Context.ObjCClassRedefinitionType = GetType(ObjCClassRedef);
4548 if (
unsigned ObjCSelRedef
4550 if (Context.ObjCSelRedefinitionType.
isNull())
4551 Context.ObjCSelRedefinitionType = GetType(ObjCSelRedef);
4555 QualType Ucontext_tType = GetType(Ucontext_t);
4556 if (Ucontext_tType.
isNull()) {
4557 Error(
"ucontext_t type is NULL");
4561 if (!Context.ucontext_tDecl) {
4566 assert(Tag &&
"Invalid ucontext_t type in AST file");
4576 if (!CUDASpecialDeclRefs.empty()) {
4577 assert(CUDASpecialDeclRefs.size() == 1 &&
"More decl refs than expected!");
4579 cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
4584 for (
auto &Import : ImportedModules) {
4585 if (
Module *Imported = getSubmodule(Import.ID)) {
4588 if (Import.ImportLoc.isValid())
4589 PP.makeModuleVisible(Imported, Import.ImportLoc);
4593 ImportedModules.clear();
4603 BitstreamCursor Stream(PCH);
4614 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
4615 if (Entry.Kind != llvm::BitstreamEntry::Record)
4620 if (
SIGNATURE == Stream.readRecord(Entry.ID, Record, &Blob))
4621 return {{{(uint32_t)Record[0], (uint32_t)Record[1], (uint32_t)Record[2],
4622 (uint32_t)Record[3], (uint32_t)Record[4]}}};
4630 const std::string &ASTFileName,
FileManager &FileMgr,
4635 Diags.
Report(diag::err_fe_unable_to_read_pch_file)
4636 << ASTFileName << Buffer.getError().message();
4637 return std::string();
4641 BitstreamCursor Stream(PCHContainerRdr.
ExtractPCH(**Buffer));
4645 Diags.
Report(diag::err_fe_not_a_pch_file) << ASTFileName;
4646 return std::string();
4651 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
4652 return std::string();
4658 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
4659 if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
4660 return std::string();
4662 if (Entry.Kind != llvm::BitstreamEntry::Record) {
4663 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
4664 return std::string();
4669 if (Stream.readRecord(Entry.ID, Record, &Blob) ==
ORIGINAL_FILE)
4680 std::string ExistingModuleCachePath;
4684 SimplePCHValidator(
const LangOptions &ExistingLangOpts,
4687 StringRef ExistingModuleCachePath,
4689 : ExistingLangOpts(ExistingLangOpts),
4690 ExistingTargetOpts(ExistingTargetOpts),
4691 ExistingPPOpts(ExistingPPOpts),
4692 ExistingModuleCachePath(ExistingModuleCachePath),
4695 bool ReadLanguageOptions(
const LangOptions &LangOpts,
bool Complain,
4696 bool AllowCompatibleDifferences)
override {
4698 AllowCompatibleDifferences);
4701 bool ReadTargetOptions(
const TargetOptions &TargetOpts,
bool Complain,
4702 bool AllowCompatibleDifferences)
override {
4704 AllowCompatibleDifferences);
4708 StringRef SpecificModuleCachePath,
4709 bool Complain)
override {
4711 ExistingModuleCachePath,
4712 nullptr, ExistingLangOpts);
4717 std::string &SuggestedPredefines)
override {
4719 SuggestedPredefines, ExistingLangOpts);
4728 bool FindModuleFileExtensions,
4739 StringRef Bytes = PCHContainerRdr.
ExtractPCH(**Buffer);
4740 BitstreamCursor Stream(Bytes);
4753 BitstreamCursor InputFilesCursor;
4756 std::string ModuleDir;
4757 bool DoneWithControlBlock =
false;
4758 while (!DoneWithControlBlock) {
4759 llvm::BitstreamEntry Entry = Stream.advance();
4761 switch (Entry.Kind) {
4762 case llvm::BitstreamEntry::SubBlock: {
4765 std::string IgnoredSuggestedPredefines;
4766 if (ReadOptionsBlock(Stream, ARR_ConfigurationMismatch | ARR_OutOfDate,
4768 Listener, IgnoredSuggestedPredefines) != Success)
4774 InputFilesCursor = Stream;
4775 if (Stream.SkipBlock() ||
4782 if (Stream.SkipBlock())
4790 case llvm::BitstreamEntry::EndBlock:
4791 DoneWithControlBlock =
true;
4797 case llvm::BitstreamEntry::Record:
4801 if (DoneWithControlBlock)
break;
4805 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4821 auto Path = ReadString(Record, Idx);
4822 ResolveImportedPath(Path, ModuleDir);
4827 if (!NeedsInputFiles)
4830 unsigned NumInputFiles = Record[0];
4831 unsigned NumUserFiles = Record[1];
4832 const llvm::support::unaligned_uint64_t *InputFileOffs =
4833 (
const llvm::support::unaligned_uint64_t *)Blob.data();
4834 for (
unsigned I = 0; I != NumInputFiles; ++I) {
4836 bool isSystemFile = I >= NumUserFiles;
4838 if (isSystemFile && !NeedsSystemInputFiles)
4841 BitstreamCursor &
Cursor = InputFilesCursor;
4843 Cursor.JumpToBit(InputFileOffs[I]);
4845 unsigned Code = Cursor.ReadCode();
4848 bool shouldContinue =
false;
4851 bool Overridden =
static_cast<bool>(Record[3]);
4852 std::string Filename = Blob;
4853 ResolveImportedPath(Filename, ModuleDir);
4855 Filename, isSystemFile, Overridden,
false);
4858 if (!shouldContinue)
4868 unsigned Idx = 0, N = Record.size();
4872 SkipString(Record, Idx);
4873 std::string Filename = ReadString(Record, Idx);
4874 ResolveImportedPath(Filename, ModuleDir);
4887 if (FindModuleFileExtensions) {
4888 BitstreamCursor SavedStream = Stream;
4890 bool DoneWithExtensionBlock =
false;
4891 while (!DoneWithExtensionBlock) {
4892 llvm::BitstreamEntry Entry = Stream.advance();
4894 switch (Entry.Kind) {
4895 case llvm::BitstreamEntry::SubBlock:
4896 if (Stream.SkipBlock())
4901 case llvm::BitstreamEntry::EndBlock:
4902 DoneWithExtensionBlock =
true;
4908 case llvm::BitstreamEntry::Record:
4914 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4927 Stream = SavedStream;
4931 if (readUnhashedControlBlockImpl(
4932 nullptr, Bytes, ARR_ConfigurationMismatch | ARR_OutOfDate,
4934 ValidateDiagnosticOptions) != Success)
4945 StringRef ExistingModuleCachePath) {
4946 SimplePCHValidator validator(LangOpts, TargetOpts, PPOpts,
4947 ExistingModuleCachePath, FileMgr);
4948 return !readASTFileControlBlock(Filename, FileMgr, PCHContainerRdr,
4955 ASTReader::ReadSubmoduleBlock(
ModuleFile &F,
unsigned ClientLoadCapabilities) {
4958 Error(
"malformed submodule block record in AST file");
4962 ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
4964 Module *CurrentModule =
nullptr;
4967 llvm::BitstreamEntry Entry = F.
Stream.advanceSkippingSubblocks();
4969 switch (Entry.Kind) {
4970 case llvm::BitstreamEntry::SubBlock:
4972 Error(
"malformed block record in AST file");
4974 case llvm::BitstreamEntry::EndBlock:
4976 case llvm::BitstreamEntry::Record:
4984 auto Kind = F.
Stream.readRecord(Entry.ID, Record, &Blob);
4987 Error(
"submodule metadata record should be at beginning of block");
5003 if (Record.size() < 12) {
5004 Error(
"malformed module definition");
5008 StringRef Name = Blob;
5010 SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);
5013 bool IsFramework = Record[Idx++];
5014 bool IsExplicit = Record[Idx++];
5015 bool IsSystem = Record[Idx++];
5016 bool IsExternC = Record[Idx++];
5017 bool InferSubmodules = Record[Idx++];
5018 bool InferExplicitSubmodules = Record[Idx++];
5019 bool InferExportWildcard = Record[Idx++];
5020 bool ConfigMacrosExhaustive = Record[Idx++];
5021 bool ModuleMapIsPrivate = Record[Idx++];
5023 Module *ParentModule =
nullptr;
5025 ParentModule = getSubmodule(Parent);
5037 if (GlobalIndex >= SubmodulesLoaded.size() ||
5038 SubmodulesLoaded[GlobalIndex]) {
5039 Error(
"too many submodules");
5043 if (!ParentModule) {
5046 if (!PP.getPreprocessorOpts().DisablePCHValidation &&
5047 CurFile != F.
File) {
5048 if (!Diags.isDiagnosticInFlight()) {
5049 Diag(diag::err_module_file_conflict)
5051 << CurFile->getName()
5062 CurrentModule->
Kind = Kind;
5072 if (DeserializationListener)
5073 DeserializationListener->ModuleRead(GlobalID, CurrentModule);
5075 SubmodulesLoaded[GlobalIndex] = CurrentModule;
5098 ResolveImportedPath(F, Filename);
5099 if (
auto *Umbrella = PP.getFileManager().getFile(Filename)) {
5103 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
5104 Error(
"mismatched umbrella headers in submodule");
5130 std::string Dirname = Blob;
5131 ResolveImportedPath(F, Dirname);
5132 if (
auto *Umbrella = PP.getFileManager().getDirectory(Dirname)) {
5136 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
5137 Error(
"mismatched umbrella directories in submodule");
5147 unsigned LocalBaseSubmoduleID = Record[1];
5151 GlobalSubmoduleMap.insert(std::make_pair(getTotalNumSubmodules()+1,&F));
5156 std::make_pair(LocalBaseSubmoduleID,
5165 for (
unsigned Idx = 0; Idx != Record.size(); ++Idx) {
5166 UnresolvedModuleRef Unresolved;
5167 Unresolved.File = &F;
5168 Unresolved.Mod = CurrentModule;
5169 Unresolved.ID = Record[Idx];
5170 Unresolved.Kind = UnresolvedModuleRef::Import;
5171 Unresolved.IsWildcard =
false;
5172 UnresolvedModuleRefs.push_back(Unresolved);
5177 for (
unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
5178 UnresolvedModuleRef Unresolved;
5179 Unresolved.File = &F;
5180 Unresolved.Mod = CurrentModule;
5181 Unresolved.ID = Record[Idx];
5182 Unresolved.Kind = UnresolvedModuleRef::Export;
5183 Unresolved.IsWildcard = Record[Idx + 1];
5184 UnresolvedModuleRefs.push_back(Unresolved);
5194 PP.getTargetInfo());
5208 UnresolvedModuleRef Unresolved;
5209 Unresolved.File = &F;
5210 Unresolved.Mod = CurrentModule;
5211 Unresolved.ID = Record[0];
5212 Unresolved.Kind = UnresolvedModuleRef::Conflict;
5213 Unresolved.IsWildcard =
false;
5214 Unresolved.String = Blob;
5215 UnresolvedModuleRefs.push_back(Unresolved);
5223 for (
auto &
ID : Record)
5224 Inits.push_back(getGlobalDeclID(F,
ID));
5225 ContextObj->addLazyModuleInitializers(CurrentModule, Inits);
5244 bool ASTReader::ParseLanguageOptions(
const RecordData &Record,
5247 bool AllowCompatibleDifferences) {
5250 #define LANGOPT(Name, Bits, Default, Description) \ 5251 LangOpts.Name = Record[Idx++]; 5252 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 5253 LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++])); 5254 #include "clang/Basic/LangOptions.def" 5255 #define SANITIZER(NAME, ID) \ 5256 LangOpts.Sanitize.set(SanitizerKind::ID, Record[Idx++]); 5257 #include "clang/Basic/Sanitizers.def" 5259 for (
unsigned N = Record[Idx++]; N; --N)
5263 VersionTuple runtimeVersion = ReadVersionTuple(Record, Idx);
5269 for (
unsigned N = Record[Idx++]; N; --N) {
5271 ReadString(Record, Idx));
5276 for (
unsigned N = Record[Idx++]; N; --N) {
5277 LangOpts.
OMPTargetTriples.push_back(llvm::Triple(ReadString(Record, Idx)));
5283 AllowCompatibleDifferences);
5286 bool ASTReader::ParseTargetOptions(
const RecordData &Record,
bool Complain,
5288 bool AllowCompatibleDifferences) {
5291 TargetOpts.
Triple = ReadString(Record, Idx);
5292 TargetOpts.
CPU = ReadString(Record, Idx);
5293 TargetOpts.
ABI = ReadString(Record, Idx);
5294 for (
unsigned N = Record[Idx++]; N; --N) {
5297 for (
unsigned N = Record[Idx++]; N; --N) {
5298 TargetOpts.
Features.push_back(ReadString(Record, Idx));
5302 AllowCompatibleDifferences);
5305 bool ASTReader::ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
5309 #define DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++]; 5310 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ 5311 DiagOpts->set##Name(static_cast<Type>(Record[Idx++])); 5312 #include "clang/Basic/DiagnosticOptions.def" 5314 for (
unsigned N = Record[Idx++]; N; --N)
5315 DiagOpts->Warnings.push_back(ReadString(Record, Idx));
5316 for (
unsigned N = Record[Idx++]; N; --N)
5317 DiagOpts->Remarks.push_back(ReadString(Record, Idx));
5322 bool ASTReader::ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
5330 bool ASTReader::ParseHeaderSearchOptions(
const RecordData &Record,
5335 HSOpts.
Sysroot = ReadString(Record, Idx);
5338 for (
unsigned N = Record[Idx++]; N; --N) {
5339 std::string Path = ReadString(Record, Idx);
5342 bool IsFramework = Record[Idx++];
5343 bool IgnoreSysRoot = Record[Idx++];
5344 HSOpts.
UserEntries.emplace_back(std::move(Path), Group, IsFramework,
5349 for (
unsigned N = Record[Idx++]; N; --N) {
5350 std::string Prefix = ReadString(Record, Idx);
5351 bool IsSystemHeader = Record[Idx++];
5365 std::string SpecificModuleCachePath = ReadString(Record, Idx);
5371 bool ASTReader::ParsePreprocessorOptions(
const RecordData &Record,
5374 std::string &SuggestedPredefines) {
5379 for (
unsigned N = Record[Idx++]; N; --N) {
5380 std::string Macro = ReadString(Record, Idx);
5381 bool IsUndef = Record[Idx++];
5382 PPOpts.
Macros.push_back(std::make_pair(Macro, IsUndef));
5386 for (
unsigned N = Record[Idx++]; N; --N) {
5387 PPOpts.
Includes.push_back(ReadString(Record, Idx));
5391 for (
unsigned N = Record[Idx++]; N; --N) {
5401 SuggestedPredefines.clear();
5403 SuggestedPredefines);
5406 std::pair<ModuleFile *, unsigned>
5407 ASTReader::getModulePreprocessedEntity(
unsigned GlobalIndex) {
5409 I = GlobalPreprocessedEntityMap.find(GlobalIndex);
5410 assert(I != GlobalPreprocessedEntityMap.end() &&
5411 "Corrupted global preprocessed entity map");
5414 return std::make_pair(M, LocalIndex);
5417 llvm::iterator_range<PreprocessingRecord::iterator>
5418 ASTReader::getModulePreprocessedEntities(
ModuleFile &Mod)
const {
5427 llvm::iterator_range<ASTReader::ModuleDeclIterator>
5429 return llvm::make_range(
5436 auto I = GlobalSkippedRangeMap.find(GlobalIndex);
5437 assert(I != GlobalSkippedRangeMap.end() &&
5438 "Corrupted global skipped range map");
5440 unsigned LocalIndex = GlobalIndex - M->BasePreprocessedSkippedRangeID;
5441 assert(LocalIndex < M->NumPreprocessedSkippedRanges);
5442 PPSkippedRange RawRange = M->PreprocessedSkippedRangeOffsets[LocalIndex];
5444 TranslateSourceLocation(*M, RawRange.
getEnd()));
5451 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
5453 unsigned LocalIndex = PPInfo.second;
5456 if (!PP.getPreprocessingRecord()) {
5457 Error(
"no preprocessing record");
5464 llvm::BitstreamEntry Entry =
5466 if (Entry.Kind != llvm::BitstreamEntry::Record)
5471 TranslateSourceLocation(M, PPOffs.
getEnd()));
5477 Entry.ID, Record, &Blob);
5480 bool isBuiltin = Record[0];
5484 Name = getLocalIdentifier(M, Record[1]);
5487 getGlobalPreprocessedEntityID(M, Record[1]);
5488 Def = cast<MacroDefinitionRecord>(
5489 PPRec.getLoadedPreprocessedEntity(GlobalID - 1));
5507 if (DeserializationListener)
5508 DeserializationListener->MacroDefinitionRead(PPID, MD);
5514 const char *FullFileNameStart = Blob.data() + Record[0];
5515 StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]);
5517 if (!FullFileName.empty())
5518 File = PP.getFileManager().getFile(FullFileName);
5525 StringRef(Blob.data(), Record[0]),
5526 Record[1], Record[3],
5533 llvm_unreachable(
"Invalid PreprocessorDetailRecordTypes");
5546 EndI = GlobalSLocOffsetMap.end(); SLocMapI != EndI; ++SLocMapI) {
5552 return getTotalNumPreprocessedEntities();
5557 struct PPEntityComp {
5587 bool EndsAfter)
const {
5588 if (SourceMgr.isLocalSourceLocation(Loc))
5589 return getTotalNumPreprocessedEntities();
5592 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
5593 assert(SLocMapI != GlobalSLocOffsetMap.end() &&
5594 "Corrupted global sloc offset map");
5596 if (SLocMapI->second->NumPreprocessedEntities == 0)
5597 return findNextPreprocessedEntity(SLocMapI);
5608 pp_iterator
First = pp_begin;
5612 PPI = std::upper_bound(pp_begin, pp_end, Loc,
5613 PPEntityComp(*
this, M));
5622 std::advance(PPI, Half);
5623 if (SourceMgr.isBeforeInTranslationUnit(
5624 TranslateSourceLocation(M, PPI->getEnd()), Loc)) {
5627 Count = Count - Half - 1;
5634 return findNextPreprocessedEntity(SLocMapI);
5641 std::pair<unsigned, unsigned>
5644 return std::make_pair(0,0);
5645 assert(!SourceMgr.isBeforeInTranslationUnit(Range.
getEnd(),Range.
getBegin()));
5648 findPreprocessedEntity(Range.
getBegin(),
false);
5650 return std::make_pair(BeginID, EndID);
5660 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
5662 unsigned LocalIndex = PPInfo.second;
5669 if (SourceMgr.isInFileID(SourceMgr.getFileLoc(Loc), FID))
5678 class HeaderFileInfoVisitor {
5683 explicit HeaderFileInfoVisitor(
const FileEntry *FE) : FE(FE) {}
5692 HeaderFileInfoLookupTable::iterator Pos = Table->find(FE);
5693 if (Pos == Table->end())
5706 HeaderFileInfoVisitor Visitor(FE);
5707 ModuleMgr.visit(Visitor);
5715 using DiagState = DiagnosticsEngine::DiagState;
5726 auto ReadDiagState =
5728 bool IncludeNonPragmaStates) -> DiagnosticsEngine::DiagState * {
5729 unsigned BackrefID = Record[Idx++];
5731 return DiagStates[BackrefID - 1];
5734 Diag.DiagStates.push_back(BasedOn);
5735 DiagState *NewState = &Diag.DiagStates.back();
5736 DiagStates.push_back(NewState);
5737 unsigned Size = Record[Idx++];
5738 assert(Idx + Size * 2 <= Record.size() &&
5739 "Invalid data, not enough diag/map pairs");
5741 unsigned DiagID = Record[Idx++];
5744 if (!NewMapping.
isPragma() && !IncludeNonPragmaStates)
5757 Mapping = NewMapping;
5763 DiagState *FirstState;
5768 FirstState = Diag.DiagStatesByLoc.FirstDiagState;
5769 DiagStates.push_back(FirstState);
5772 assert(Record[1] == 0 &&
5773 "Invalid data, unexpected backref in initial state");
5774 Idx = 3 + Record[2] * 2;
5775 assert(Idx < Record.size() &&
5776 "Invalid data, not enough state change pairs in initial state");
5781 unsigned Flags = Record[Idx++];
5783 Initial.SuppressSystemWarnings = Flags & 1; Flags >>= 1;
5784 Initial.ErrorsAsFatal = Flags & 1; Flags >>= 1;
5785 Initial.WarningsAsErrors = Flags & 1; Flags >>= 1;
5786 Initial.EnableAllWarnings = Flags & 1; Flags >>= 1;
5787 Initial.IgnoreAllWarnings = Flags & 1; Flags >>= 1;
5797 .StateTransitions.push_back({FirstState, 0});
5802 FirstState = ReadDiagState(*Diag.DiagStatesByLoc.CurDiagState,
5807 unsigned NumLocations = Record[Idx++];
5808 while (NumLocations--) {
5809 assert(Idx < Record.size() &&
5810 "Invalid data, missing pragma diagnostic states");
5812 auto IDAndOffset = SourceMgr.getDecomposedLoc(Loc);
5813 assert(IDAndOffset.first.isValid() &&
"invalid FileID for transition");
5814 assert(IDAndOffset.second == 0 &&
"not a start location for a FileID");
5815 unsigned Transitions = Record[Idx++];
5821 auto &F = Diag.DiagStatesByLoc.Files[IDAndOffset.first];
5822 F.StateTransitions.reserve(F.StateTransitions.size() + Transitions);
5823 for (
unsigned I = 0; I != Transitions; ++I) {
5824 unsigned Offset = Record[Idx++];
5826 ReadDiagState(*FirstState, Loc.getLocWithOffset(Offset),
false);
5827 F.StateTransitions.push_back({
State, Offset});
5832 assert(Idx < Record.size() &&
5833 "Invalid data, missing final pragma diagnostic state");
5836 auto *CurState = ReadDiagState(*FirstState, CurStateLoc,
false);
5839 Diag.DiagStatesByLoc.CurDiagState = CurState;
5840 Diag.DiagStatesByLoc.CurDiagStateLoc = CurStateLoc;
5845 auto &T = Diag.DiagStatesByLoc.Files[NullFile].StateTransitions;
5847 T.push_back({CurState, 0});
5849 T[0].State = CurState;
5858 ASTReader::RecordLocation ASTReader::TypeCursorForIndex(
unsigned Index) {
5860 assert(I != GlobalTypeMap.end() &&
"Corrupted global type map");
5862 return RecordLocation(M, M->TypeOffsets[Index - M->BaseTypeIndex]);
5871 QualType ASTReader::readTypeRecord(
unsigned Index) {
5872 assert(ContextObj &&
"reading type with no AST context");
5874 RecordLocation Loc = TypeCursorForIndex(Index);
5875 BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
5881 ReadingKindTracker ReadingKind(Read_Type, *
this);
5887 DeclsCursor.JumpToBit(Loc.Offset);
5889 unsigned Code = DeclsCursor.ReadCode();
5890 switch ((
TypeCode)DeclsCursor.readRecord(Code, Record)) {
5892 if (Record.size() != 2) {
5893 Error(
"Incorrect encoding of extended qualifier type");
5902 if (Record.size() != 1) {
5903 Error(
"Incorrect encoding of complex type");
5906 QualType ElemType = readType(*Loc.F, Record, Idx);
5911 if (Record.size() != 1) {
5912 Error(
"Incorrect encoding of pointer type");
5915 QualType PointeeType = readType(*Loc.F, Record, Idx);
5920 if (Record.size() != 1) {
5921 Error(
"Incorrect encoding of decayed type");
5924 QualType OriginalType = readType(*Loc.F, Record, Idx);
5926 if (!isa<DecayedType>(DT))
5927 Error(
"Decayed type does not decay");
5932 if (Record.size() != 2) {
5933 Error(
"Incorrect encoding of adjusted type");
5936 QualType OriginalTy = readType(*Loc.F, Record, Idx);
5937 QualType AdjustedTy = readType(*Loc.F, Record, Idx);
5942 if (Record.size() != 1) {
5943 Error(
"Incorrect encoding of block pointer type");
5946 QualType PointeeType = readType(*Loc.F, Record, Idx);
5951 if (Record.size() != 2) {
5952 Error(
"Incorrect encoding of lvalue reference type");
5955 QualType PointeeType = readType(*Loc.F, Record, Idx);
5960 if (Record.size() != 1) {
5961 Error(
"Incorrect encoding of rvalue reference type");
5964 QualType PointeeType = readType(*Loc.F, Record, Idx);
5969 if (Record.size() != 2) {
5970 Error(
"Incorrect encoding of member pointer type");
5973 QualType PointeeType = readType(*Loc.F, Record, Idx);
5974 QualType ClassType = readType(*Loc.F, Record, Idx);
5982 QualType ElementType = readType(*Loc.F, Record, Idx);
5984 unsigned IndexTypeQuals = Record[2];
5986 llvm::APInt Size = ReadAPInt(Record, Idx);
5988 ASM, IndexTypeQuals);
5992 QualType ElementType = readType(*Loc.F, Record, Idx);
5994 unsigned IndexTypeQuals = Record[2];
5999 QualType ElementType = readType(*Loc.F, Record, Idx);
6001 unsigned IndexTypeQuals = Record[2];
6005 ASM, IndexTypeQuals,
6010 if (Record.size() != 3) {
6011 Error(
"incorrect encoding of vector type in AST file");
6015 QualType ElementType = readType(*Loc.F, Record, Idx);
6016 unsigned NumElements = Record[1];
6017 unsigned VecKind = Record[2];
6023 if (Record.size() != 3) {
6024 Error(
"incorrect encoding of extended vector type in AST file");
6028 QualType ElementType = readType(*Loc.F, Record, Idx);
6029 unsigned NumElements = Record[1];
6034 if (Record.size() != 8) {
6035 Error(
"incorrect encoding of no-proto function type");
6038 QualType ResultType = readType(*Loc.F, Record, Idx);
6046 QualType ResultType = readType(*Loc.F, Record, Idx);
6052 static_cast<CallingConv>(Record[4]),
6064 readExceptionSpec(*Loc.F, ExceptionStorage, EPI.
ExceptionSpec, Record, Idx);
6066 unsigned NumParams = Record[Idx++];
6068 for (
unsigned I = 0; I != NumParams; ++I)
6069 ParamTypes.push_back(readType(*Loc.F, Record, Idx));
6072 if (Idx != Record.size()) {
6073 for (
unsigned I = 0; I != NumParams; ++I)
6074 ExtParameterInfos.push_back(
6076 ::getFromOpaqueValue(Record[Idx++]));
6080 assert(Idx == Record.size());
6088 ReadDeclAs<UnresolvedUsingTypenameDecl>(*Loc.F, Record, Idx));
6092 if (Record.size() != 2) {
6093 Error(
"incorrect encoding of typedef type");
6098 QualType Canonical = readType(*Loc.F, Record, Idx);
6099 if (!Canonical.isNull())
6108 if (Record.size() != 1) {
6109 Error(
"incorrect encoding of typeof(type) in AST file");
6112 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
6117 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
6122 QualType BaseType = readType(*Loc.F, Record, Idx);
6123 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
6129 QualType Deduced = readType(*Loc.F, Record, Idx);
6131 bool IsDependent = Deduced.
isNull() ? Record[Idx++] :
false;
6132 return Context.
getAutoType(Deduced, Keyword, IsDependent);
6136 TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx);
6137 QualType Deduced = readType(*Loc.F, Record, Idx);
6138 bool IsDependent = Deduced.
isNull() ? Record[Idx++] :
false;
6144 if (Record.size() != 2) {
6145 Error(
"incorrect encoding of record type");
6149 bool IsDependent = Record[Idx++];
6150 RecordDecl *RD = ReadDeclAs<RecordDecl>(*Loc.F, Record, Idx);
6151 RD = cast_or_null<RecordDecl>(RD->getCanonicalDecl());
6153 const_cast<Type*
>(T.getTypePtr())->setDependent(IsDependent);
6158 if (Record.size() != 2) {
6159 Error(
"incorrect encoding of enum type");
6163 bool IsDependent = Record[Idx++];
6165 = Context.
getEnumType(ReadDeclAs<EnumDecl>(*Loc.F, Record, Idx));
6171 if (Record.size() != 3) {
6172 Error(
"incorrect encoding of attributed type");
6175 QualType modifiedType = readType(*Loc.F, Record, Idx);
6176 QualType equivalentType = readType(*Loc.F, Record, Idx);
6182 if (Record.size() != 1) {
6183 Error(
"incorrect encoding of paren type");
6186 QualType InnerType = readType(*Loc.F, Record, Idx);
6191 if (Record.size() != 2) {
6192 Error(
"incorrect encoding of pack expansion type");
6195 QualType Pattern = readType(*Loc.F, Record, Idx);
6200 NumExpansions = Record[1] - 1;
6208 QualType NamedType = readType(*Loc.F, Record, Idx);
6209 TagDecl *OwnedTagDecl = ReadDeclAs<TagDecl>(*Loc.F, Record, Idx);
6216 = ReadDeclAs<ObjCInterfaceDecl>(*Loc.F, Record, Idx);
6223 = ReadDeclAs<ObjCTypeParamDecl>(*Loc.F, Record, Idx);
6224 unsigned NumProtos = Record[Idx++];
6226 for (
unsigned I = 0; I != NumProtos; ++I)
6227 Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
6234 unsigned NumTypeArgs = Record[Idx++];
6236 for (
unsigned I = 0; I != NumTypeArgs; ++I)
6237 TypeArgs.push_back(readType(*Loc.F, Record, Idx));
6238 unsigned NumProtos = Record[Idx++];
6240 for (
unsigned I = 0; I != NumProtos; ++I)
6241 Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
6242 bool IsKindOf = Record[Idx++];
6248 QualType Pointee = readType(*Loc.F, Record, Idx);
6254 QualType Parm = readType(*Loc.F, Record, Idx);
6257 cast<TemplateTypeParmType>(Parm),
6263 QualType Parm = readType(*Loc.F, Record, Idx);
6266 cast<TemplateTypeParmType>(Parm),
6271 CXXRecordDecl *D = ReadDeclAs<CXXRecordDecl>(*Loc.F, Record, Idx);
6272 QualType TST = readType(*Loc.F, Record, Idx);
6275 const Type *T =
nullptr;
6277 if (
const Type *Existing = DI->getTypeForDecl()) {
6285 DI->setTypeForDecl(T);
6292 unsigned Depth = Record[Idx++];
6293 unsigned Index = Record[Idx++];
6294 bool Pack = Record[Idx++];
6296 = ReadDeclAs<TemplateTypeParmDecl>(*Loc.F, Record, Idx);
6304 const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx);
6305 QualType Canon = readType(*Loc.F, Record, Idx);
6315 const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx);
6316 unsigned NumArgs = Record[Idx++];
6318 Args.reserve(NumArgs);
6320 Args.push_back(ReadTemplateArgument(*Loc.F, Record, Idx));
6329 QualType ElementType = readType(*Loc.F, Record, Idx);
6332 unsigned IndexTypeQuals = Record[Idx++];
6335 Expr *NumElts = ReadExpr(*Loc.F);
6336 SourceRange Brackets = ReadSourceRange(*Loc.F, Record, Idx);
6339 IndexTypeQuals, Brackets);
6344 bool IsDependent = Record[Idx++];
6345 TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx);
6347 ReadTemplateArgumentList(Args, *Loc.F, Record, Idx);
6348 QualType Underlying = readType(*Loc.F, Record, Idx);
6359 if (Record.size() != 1) {
6360 Error(
"Incorrect encoding of atomic type");
6363 QualType ValueType = readType(*Loc.F, Record, Idx);
6368 if (Record.size() != 2) {
6369 Error(
"Incorrect encoding of pipe type");
6374 QualType ElementType = readType(*Loc.F, Record, Idx);
6375 unsigned ReadOnly = Record[1];
6376 return Context.getPipeType(ElementType, ReadOnly);
6381 QualType ElementType = readType(*Loc.F, Record, Idx);
6382 Expr *SizeExpr = ReadExpr(*Loc.F);
6383 SourceLocation AttrLoc = ReadSourceLocation(*Loc.F, Record, Idx);
6384 unsigned VecKind = Record[Idx];
6394 QualType ElementType = readType(*Loc.F, Record, Idx);
6395 Expr *SizeExpr = ReadExpr(*Loc.F);
6396 SourceLocation AttrLoc = ReadSourceLocation(*Loc.F, Record, Idx);
6406 QualType PointeeType = readType(*Loc.F, Record, Idx);
6407 Expr *AddrSpaceExpr = ReadExpr(*Loc.F);
6408 SourceLocation AttrLoc = ReadSourceLocation(*Loc.F, Record, Idx);
6414 llvm_unreachable(
"Invalid TypeCode!");
6425 for (
unsigned I = 0, N = Record[Idx++]; I != N; ++I)
6426 Exceptions.push_back(readType(ModuleFile, Record, Idx));
6431 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6432 ESI.
SourceTemplate = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6434 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6461 : F(&F), Reader(&Reader), Record(Record), Idx(Idx) {}
6466 #define ABSTRACT_TYPELOC(CLASS, PARENT) 6467 #define TYPELOC(CLASS, PARENT) \ 6468 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc); 6469 #include "clang/AST/TypeLocNodes.def" 6534 VisitArrayTypeLoc(TL);
6538 VisitArrayTypeLoc(TL);
6542 VisitArrayTypeLoc(TL);
6545 void TypeLocReader::VisitDependentSizedArrayTypeLoc(
6547 VisitArrayTypeLoc(TL);
6550 void TypeLocReader::VisitDependentAddressSpaceTypeLoc(
6555 range.
setBegin(ReadSourceLocation());
6556 range.
setEnd(ReadSourceLocation());
6561 void TypeLocReader::VisitDependentSizedExtVectorTypeLoc(
6570 void TypeLocReader::VisitDependentVectorTypeLoc(
6584 Reader->ReadSourceLocation(*F, Record, Idx)));
6586 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i) {
6592 VisitFunctionTypeLoc(TL);
6596 VisitFunctionTypeLoc(TL);
6631 void TypeLocReader::VisitAutoTypeLoc(
AutoTypeLoc TL) {
6635 void TypeLocReader::VisitDeducedTemplateSpecializationTypeLoc(
6644 void TypeLocReader::VisitEnumTypeLoc(
EnumTypeLoc TL) {
6652 range.
setBegin(ReadSourceLocation());
6653 range.
setEnd(ReadSourceLocation());
6669 void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
6674 void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
6679 void TypeLocReader::VisitTemplateSpecializationTypeLoc(
6685 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
6688 Reader->GetTemplateArgumentLocInfo(
6692 void TypeLocReader::VisitParenTypeLoc(
ParenTypeLoc TL) {
6712 void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc(
6720 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I)
6723 Reader->GetTemplateArgumentLocInfo(
6766 void TypeLocReader::VisitPipeTypeLoc(
PipeTypeLoc TL) {
6780 QualType InfoTy = readType(F, Record, Idx);
6784 TypeSourceInfo *TInfo = getContext().CreateTypeSourceInfo(InfoTy);
6785 ReadTypeLoc(F, Record, Idx, TInfo->
getTypeLoc());
6790 assert(ContextObj &&
"reading type with no AST context");
6977 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 6978 case PREDEF_TYPE_##Id##_ID: \ 6979 T = Context.SingletonId; \ 6981 #include "clang/Basic/OpenCLImageTypes.def" 7014 assert(!T.
isNull() &&
"Unknown predefined type");
7019 assert(Index < TypesLoaded.size() &&
"Type index out-of-range");
7020 if (TypesLoaded[Index].isNull()) {
7021 TypesLoaded[Index] = readTypeRecord(Index);
7022 if (TypesLoaded[Index].isNull())
7025 TypesLoaded[Index]->setFromAST();
7026 if (DeserializationListener)
7028 TypesLoaded[Index]);
7031 return TypesLoaded[Index].withFastQualifiers(FastQuals);
7035 return GetType(getGlobalTypeID(F, LocalID));
7047 ReadModuleOffsetMap(F);
7051 assert(I != F.
TypeRemap.
end() &&
"Invalid index into type index remap");
7053 unsigned GlobalIndex = LocalIndex + I->second;
7054 return (GlobalIndex << Qualifiers::FastWidth) | FastQuals;
7066 return GetTypeSourceInfo(F, Record, Index);
7070 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
7077 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
7078 SourceLocation EllipsisLoc = ReadSourceLocation(F, Record, Index);
7090 llvm_unreachable(
"unexpected template argument loc");
7099 if (Record[Index++])
7112 unsigned NumArgsAsWritten = Record[Index++];
7114 for (
unsigned i = 0; i != NumArgsAsWritten; ++i)
7115 TemplArgsInfo.
addArgument(ReadTemplateArgumentLoc(F, Record, Index));
7124 if (NumCurrentElementsDeserializing) {
7129 PendingIncompleteDeclChains.push_back(const_cast<Decl*>(D));
7140 if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC) ||
7141 isa<CXXRecordDecl>(DC) || isa<EnumDecl>(DC)) {
7143 if (!getContext().getLangOpts().
CPlusPlus &&
7144 isa<TranslationUnitDecl>(DC)) {
7148 auto *II = Name.getAsIdentifierInfo();
7149 assert(II &&
"non-identifier name in C?");
7150 if (II->isOutOfDate())
7151 updateOutOfDateIdentifier(*II);
7157 auto *DC = cast<DeclContext>(DCDecl);
7159 FindExternalLexicalDecls(
7165 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D))
7166 CTSD->getSpecializedTemplate()->LoadLazySpecializations();
7167 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D))
7168 VTSD->getSpecializedTemplate()->LoadLazySpecializations();
7169 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
7170 if (
auto *Template = FD->getPrimaryTemplate())
7171 Template->LoadLazySpecializations();
7177 RecordLocation Loc = getLocalBitOffset(Offset);
7178 BitstreamCursor &
Cursor = Loc.F->DeclsCursor;
7180 Cursor.JumpToBit(Loc.Offset);
7181 ReadingKindTracker ReadingKind(Read_Decl, *
this);
7184 unsigned Code = Cursor.ReadCode();
7185 unsigned RecCode = Cursor.readRecord(Code, Record);
7187 Error(
"malformed AST file: missing C++ ctor initializers");
7192 return ReadCXXCtorInitializers(*Loc.F, Record, Idx);
7196 assert(ContextObj &&
"reading base specifiers with no AST context");
7199 RecordLocation Loc = getLocalBitOffset(Offset);
7200 BitstreamCursor &
Cursor = Loc.F->DeclsCursor;
7202 Cursor.JumpToBit(Loc.Offset);
7203 ReadingKindTracker ReadingKind(Read_Decl, *
this);
7205 unsigned Code = Cursor.ReadCode();
7206 unsigned RecCode = Cursor.readRecord(Code, Record);
7208 Error(
"malformed AST file: missing C++ base specifiers");
7213 unsigned NumBases = Record[Idx++];
7216 for (
unsigned I = 0; I != NumBases; ++I)
7217 Bases[I] = ReadCXXBaseSpecifier(*Loc.F, Record, Idx);
7227 ReadModuleOffsetMap(F);
7231 assert(I != F.
DeclRemap.
end() &&
"Invalid index into decl index remap");
7233 return LocalID + I->second;
7237 ModuleFile &M)
const {
7250 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
7260 if (Index > DeclsLoaded.size()) {
7261 Error(
"declaration ID out-of-range for AST file");
7265 if (
Decl *D = DeclsLoaded[Index])
7266 return D->getLocation();
7269 DeclCursorForID(ID, Loc);
7326 llvm_unreachable(
"PredefinedDeclIDs unknown enum value");
7330 assert(ContextObj &&
"reading decl with no AST context");
7338 Merged.push_back(ID);
7345 if (Index >= DeclsLoaded.size()) {
7346 assert(0 &&
"declaration ID out-of-range for AST file");
7347 Error(
"declaration ID out-of-range for AST file");
7351 return DeclsLoaded[Index];
7356 return GetExistingDecl(ID);
7360 if (Index >= DeclsLoaded.size()) {
7361 assert(0 &&
"declaration ID out-of-range for AST file");
7362 Error(
"declaration ID out-of-range for AST file");
7366 if (!DeclsLoaded[Index]) {
7368 if (DeserializationListener)
7369 DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);
7372 return DeclsLoaded[Index];
7381 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
7382 ModuleFile *Owner = I->second;
7384 llvm::DenseMap<ModuleFile *, serialization::DeclID>::iterator Pos
7389 return GlobalID - Owner->BaseDeclID + Pos->second;
7395 if (Idx >= Record.size()) {
7396 Error(
"Corrupted AST file");
7400 return getGlobalDeclID(F, Record[Idx++]);
7410 ClearSwitchCaseIDs();
7413 RecordLocation Loc = getLocalBitOffset(Offset);
7414 Loc.F->DeclsCursor.JumpToBit(Loc.Offset);
7415 assert(NumCurrentElementsDeserializing == 0 &&
7416 "should not be called while already deserializing");
7418 return ReadStmtFromStream(*Loc.F);
7427 assert(LexicalDecls.size() % 2 == 0 &&
"expected an even number of entries");
7428 for (
int I = 0, N = LexicalDecls.size(); I != N; I += 2) {
7430 if (!IsKindWeWant(K))
7438 if (PredefsVisited[
ID])
7441 PredefsVisited[
ID] =
true;
7444 if (
Decl *D = GetLocalDecl(*M,
ID)) {
7445 assert(D->getKind() == K &&
"wrong kind for lexical decl");
7452 if (isa<TranslationUnitDecl>(DC)) {
7453 for (
auto Lexical : TULexicalDecls)
7454 Visit(Lexical.first, Lexical.second);
7456 auto I = LexicalDecls.find(DC);
7457 if (I != LexicalDecls.end())
7458 Visit(I->second.first, I->second.second);
7461 ++NumLexicalDeclContextsRead;
7471 DeclIDComp(
ASTReader &Reader, ModuleFile &M) : Reader(Reader), Mod(M) {}
7498 unsigned Offset,
unsigned Length,
7502 llvm::DenseMap<FileID, FileDeclsInfo>::iterator I = FileDeclIDs.find(File);
7503 if (I == FileDeclIDs.end())
7506 FileDeclsInfo &DInfo = I->second;
7507 if (DInfo.Decls.empty())
7514 DeclIDComp DIDComp(*
this, *DInfo.Mod);
7516 BeginIt = std::lower_bound(DInfo.Decls.begin(), DInfo.Decls.end(),
7518 if (BeginIt != DInfo.Decls.begin())
7524 while (BeginIt != DInfo.Decls.begin() &&
7525 GetDecl(getGlobalDeclID(*DInfo.Mod, *BeginIt))
7526 ->isTopLevelDeclInObjCContainer())
7530 EndIt = std::upper_bound(DInfo.Decls.begin(), DInfo.Decls.end(),
7532 if (EndIt != DInfo.Decls.end())
7536 DIt = BeginIt; DIt != EndIt; ++DIt)
7537 Decls.push_back(GetDecl(getGlobalDeclID(*DInfo.Mod, *DIt)));
7544 "DeclContext has no visible decls in storage");
7548 auto It = Lookups.find(DC);
7549 if (It == Lookups.end())
7556 for (
DeclID ID : It->second.Table.find(Name)) {
7559 Decls.push_back(ND);
7562 ++NumVisibleDeclContextsRead;
7563 SetExternalVisibleDeclsForName(DC, Name, Decls);
7564 return !Decls.empty();
7571 auto It = Lookups.find(DC);
7572 assert(It != Lookups.end() &&
7573 "have external visible storage but no lookup tables");
7577 for (
DeclID ID : It->second.Table.findAll()) {
7582 ++NumVisibleDeclContextsRead;
7584 for (DeclsMap::iterator I = Decls.begin(), E = Decls.end(); I != E; ++I) {
7585 SetExternalVisibleDeclsForName(DC, I->first, I->second);
7587 const_cast<DeclContext *
>(DC)->setHasExternalVisibleStorage(
false);
7592 auto I = Lookups.find(Primary);
7593 return I == Lookups.end() ? nullptr : &I->second;
7602 assert(ImplD && Consumer);
7604 for (
auto *I : ImplD->
methods())
7610 void ASTReader::PassInterestingDeclToConsumer(
Decl *D) {
7618 this->Consumer = Consumer;
7621 PassInterestingDeclsToConsumer();
7623 if (DeserializationListener)
7624 DeserializationListener->ReaderInitialized(
this);
7628 std::fprintf(stderr,
"*** AST File Statistics:\n");
7630 unsigned NumTypesLoaded
7631 = TypesLoaded.size() - std::count(TypesLoaded.begin(), TypesLoaded.end(),
7633 unsigned NumDeclsLoaded
7634 = DeclsLoaded.size() - std::count(DeclsLoaded.begin(), DeclsLoaded.end(),
7636 unsigned NumIdentifiersLoaded
7637 = IdentifiersLoaded.size() - std::count(IdentifiersLoaded.begin(),
7638 IdentifiersLoaded.end(),
7640 unsigned NumMacrosLoaded
7641 = MacrosLoaded.size() - std::count(MacrosLoaded.begin(),
7644 unsigned NumSelectorsLoaded
7645 = SelectorsLoaded.size() - std::count(SelectorsLoaded.begin(),
7646 SelectorsLoaded.end(),
7649 if (
unsigned TotalNumSLocEntries = getTotalNumSLocs())
7650 std::fprintf(stderr,
" %u/%u source location entries read (%f%%)\n",
7651 NumSLocEntriesRead, TotalNumSLocEntries,
7652 ((
float)NumSLocEntriesRead/TotalNumSLocEntries * 100));
7653 if (!TypesLoaded.empty())
7654 std::fprintf(stderr,
" %u/%u types read (%f%%)\n",
7655 NumTypesLoaded, (
unsigned)TypesLoaded.size(),
7656 ((float)NumTypesLoaded/TypesLoaded.size() * 100));
7657 if (!DeclsLoaded.empty())
7658 std::fprintf(stderr,
" %u/%u declarations read (%f%%)\n",
7659 NumDeclsLoaded, (
unsigned)DeclsLoaded.size(),
7660 ((float)NumDeclsLoaded/DeclsLoaded.size() * 100));
7661 if (!IdentifiersLoaded.empty())
7662 std::fprintf(stderr,
" %u/%u identifiers read (%f%%)\n",
7663 NumIdentifiersLoaded, (
unsigned)IdentifiersLoaded.size(),
7664 ((float)NumIdentifiersLoaded/IdentifiersLoaded.size() * 100));
7665 if (!MacrosLoaded.empty())
7666 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
7667 NumMacrosLoaded, (
unsigned)MacrosLoaded.size(),
7668 ((float)NumMacrosLoaded/MacrosLoaded.size() * 100));
7669 if (!SelectorsLoaded.empty())
7670 std::fprintf(stderr,
" %u/%u selectors read (%f%%)\n",
7671 NumSelectorsLoaded, (
unsigned)SelectorsLoaded.size(),
7672 ((float)NumSelectorsLoaded/SelectorsLoaded.size() * 100));
7673 if (TotalNumStatements)
7674 std::fprintf(stderr,
" %u/%u statements read (%f%%)\n",
7675 NumStatementsRead, TotalNumStatements,
7676 ((
float)NumStatementsRead/TotalNumStatements * 100));
7678 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
7679 NumMacrosRead, TotalNumMacros,
7680 ((
float)NumMacrosRead/TotalNumMacros * 100));
7681 if (TotalLexicalDeclContexts)
7682 std::fprintf(stderr,
" %u/%u lexical declcontexts read (%f%%)\n",
7683 NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
7684 ((
float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts
7686 if (TotalVisibleDeclContexts)
7687 std::fprintf(stderr,
" %u/%u visible declcontexts read (%f%%)\n",
7688 NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
7689 ((
float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
7691 if (TotalNumMethodPoolEntries)
7692 std::fprintf(stderr,
" %u/%u method pool entries read (%f%%)\n",
7693 NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
7694 ((
float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
7696 if (NumMethodPoolLookups)
7697 std::fprintf(stderr,
" %u/%u method pool lookups succeeded (%f%%)\n",
7698 NumMethodPoolHits, NumMethodPoolLookups,
7699 ((
float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
7700 if (NumMethodPoolTableLookups)
7701 std::fprintf(stderr,
" %u/%u method pool table lookups succeeded (%f%%)\n",
7702 NumMethodPoolTableHits, NumMethodPoolTableLookups,
7703 ((
float)NumMethodPoolTableHits/NumMethodPoolTableLookups
7705 if (NumIdentifierLookupHits)
7706 std::fprintf(stderr,
7707 " %u / %u identifier table lookups succeeded (%f%%)\n",
7708 NumIdentifierLookupHits, NumIdentifierLookups,
7709 (
double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
7712 std::fprintf(stderr,
"\n");
7713 GlobalIndex->printStats();
7716 std::fprintf(stderr,
"\n");
7718 std::fprintf(stderr,
"\n");
7721 template<
typename Key,
typename ModuleFile,
unsigned InitialCapacity>
7722 LLVM_DUMP_METHOD
static void 7725 InitialCapacity> &Map) {
7726 if (Map.begin() == Map.end())
7731 llvm::errs() << Name <<
":\n";
7732 for (
typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
7734 llvm::errs() <<
" " << I->first <<
" -> " << I->second->FileName
7740 llvm::errs() <<
"*** PCH/ModuleFile Remappings:\n";
7742 dumpModuleIDMap(
"Global source location entry map", GlobalSLocEntryMap);
7750 GlobalPreprocessedEntityMap);
7752 llvm::errs() <<
"\n*** PCH/Modules Loaded:";
7753 for (ModuleFile &M : ModuleMgr)
7760 for (ModuleFile &I : ModuleMgr) {
7761 if (llvm::MemoryBuffer *buf = I.Buffer) {
7762 size_t bytes = buf->getBufferSize();
7763 switch (buf->getBufferKind()) {
7764 case llvm::MemoryBuffer::MemoryBuffer_Malloc:
7767 case llvm::MemoryBuffer::MemoryBuffer_MMap:
7781 for (uint64_t
ID : PreloadedDeclIDs) {
7785 PreloadedDeclIDs.clear();
7788 if (!FPPragmaOptions.empty()) {
7789 assert(FPPragmaOptions.size() == 1 &&
"Wrong number of FP_PRAGMA_OPTIONS");
7790 SemaObj->FPFeatures =
FPOptions(FPPragmaOptions[0]);
7793 SemaObj->OpenCLFeatures.copy(OpenCLExtensions);
7794 SemaObj->OpenCLTypeExtMap = OpenCLTypeExtMap;
7795 SemaObj->OpenCLDeclExtMap = OpenCLDeclExtMap;
7801 assert(SemaObj &&
"no Sema to update");
7805 if (!SemaDeclRefs.empty()) {
7806 assert(SemaDeclRefs.size() % 3 == 0);
7807 for (
unsigned I = 0; I != SemaDeclRefs.size(); I += 3) {
7808 if (!SemaObj->StdNamespace)
7809 SemaObj->StdNamespace = SemaDeclRefs[I];
7810 if (!SemaObj->StdBadAlloc)
7811 SemaObj->StdBadAlloc = SemaDeclRefs[I+1];
7812 if (!SemaObj->StdAlignValT)
7813 SemaObj->StdAlignValT = SemaDeclRefs[I+2];
7815 SemaDeclRefs.clear();
7820 if(OptimizeOffPragmaLocation.isValid())
7821 SemaObj->ActOnPragmaOptimize(
false, OptimizeOffPragmaLocation);
7822 if (PragmaMSStructState != -1)
7824 if (PointersToMembersPragmaLocation.isValid()) {
7825 SemaObj->ActOnPragmaMSPointersToMembers(
7827 PragmaMSPointersToMembersState,
7828 PointersToMembersPragmaLocation);
7830 SemaObj->ForceCUDAHostDeviceDepth = ForceCUDAHostDeviceDepth;
7832 if (PragmaPackCurrentValue) {
7836 bool DropFirst =
false;
7837 if (!PragmaPackStack.empty() &&
7838 PragmaPackStack.front().Location.isInvalid()) {
7839 assert(PragmaPackStack.front().Value == SemaObj->PackStack.DefaultValue &&
7840 "Expected a default alignment value");
7841 SemaObj->PackStack.Stack.emplace_back(
7842 PragmaPackStack.front().SlotLabel, SemaObj->PackStack.CurrentValue,
7843 SemaObj->PackStack.CurrentPragmaLocation,
7844 PragmaPackStack.front().PushLocation);
7847 for (
const auto &Entry :
7848 llvm::makeArrayRef(PragmaPackStack).drop_front(DropFirst ? 1 : 0))
7849 SemaObj->PackStack.Stack.emplace_back(Entry.SlotLabel, Entry.Value,
7850 Entry.Location, Entry.PushLocation);
7851 if (PragmaPackCurrentLocation.isInvalid()) {
7852 assert(*PragmaPackCurrentValue == SemaObj->PackStack.DefaultValue &&
7853 "Expected a default alignment value");
7856 SemaObj->PackStack.CurrentValue = *PragmaPackCurrentValue;
7857 SemaObj->PackStack.CurrentPragmaLocation = PragmaPackCurrentLocation;
7866 IdentifierLookupVisitor Visitor(Name, 0,
7867 NumIdentifierLookups,
7868 NumIdentifierLookupHits);
7874 if (PP.getLangOpts().CPlusPlus) {
7875 for (
auto F : ModuleMgr.pch_modules())
7883 if (!loadGlobalIndex()) {
7884 if (GlobalIndex->lookupIdentifier(Name, Hits)) {
7889 ModuleMgr.visit(Visitor, HitsPtr);
7893 markIdentifierUpToDate(II);
7911 ASTIdentifierLookupTable::key_iterator Current;
7915 ASTIdentifierLookupTable::key_iterator
End;
7922 bool SkipModules =
false);
7924 StringRef Next()
override;
7931 : Reader(Reader), Index(Reader.ModuleMgr.size()), SkipModules(SkipModules) {
7935 while (Current == End) {
7941 ModuleFile &F = Reader.ModuleMgr[Index];
7947 Current = IdTable->key_begin();
7948 End = IdTable->key_end();
7953 StringRef
Result = *Current;
7962 std::unique_ptr<IdentifierIterator> Current;
7963 std::unique_ptr<IdentifierIterator> Queued;
7966 ChainedIdentifierIterator(std::unique_ptr<IdentifierIterator>
First,
7967 std::unique_ptr<IdentifierIterator> Second)
7968 : Current(std::move(First)), Queued(std::move(Second)) {}
7970 StringRef
Next()
override {
7974 StringRef result = Current->Next();
7975 if (!result.empty())
7980 std::swap(Current, Queued);
7988 if (!loadGlobalIndex()) {
7989 std::unique_ptr<IdentifierIterator> ReaderIter(
7991 std::unique_ptr<IdentifierIterator> ModulesIter(
7992 GlobalIndex->createIdentifierIterator());
7993 return new ChainedIdentifierIterator(std::move(ReaderIter),
7994 std::move(ModulesIter));
8001 namespace serialization {
8006 unsigned PriorGeneration;
8007 unsigned InstanceBits = 0;
8008 unsigned FactoryBits = 0;
8009 bool InstanceHasMoreThanOneDecl =
false;
8010 bool FactoryHasMoreThanOneDecl =
false;
8016 unsigned PriorGeneration)
8017 : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) {}
8027 ++Reader.NumMethodPoolTableLookups;
8030 ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel);
8031 if (Pos == PoolTable->end())
8034 ++Reader.NumMethodPoolTableHits;
8035 ++Reader.NumSelectorsRead;
8039 ++Reader.NumMethodPoolEntriesRead;
8041 if (Reader.DeserializationListener)
8055 return InstanceMethods;
8060 return FactoryMethods;
8067 return InstanceHasMoreThanOneDecl;
8079 for (
unsigned I = 0, N = Methods.size(); I != N; ++I) {
8086 unsigned &Generation = SelectorGeneration[Sel];
8087 unsigned PriorGeneration = Generation;
8088 Generation = getGeneration();
8089 SelectorOutOfDate[Sel] =
false;
8092 ++NumMethodPoolLookups;
8094 ModuleMgr.visit(Visitor);
8100 ++NumMethodPoolHits;
8105 Sema &S = *getSema();
8106 Sema::GlobalMethodPool::iterator Pos
8122 if (SelectorOutOfDate[Sel])
8123 ReadMethodPool(Sel);
8130 for (
unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) {
8132 = dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespaces[I])))
8133 Namespaces.push_back(Namespace);
8138 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
8139 for (
unsigned Idx = 0, N = UndefinedButUsed.size(); Idx != N;) {
8140 NamedDecl *D = cast<NamedDecl>(GetDecl(UndefinedButUsed[Idx++]));
8143 Undefined.insert(std::make_pair(D, Loc));
8150 for (
unsigned Idx = 0, N = DelayedDeleteExprs.size(); Idx != N;) {
8151 FieldDecl *FD = cast<FieldDecl>(GetDecl(DelayedDeleteExprs[Idx++]));
8152 uint64_t Count = DelayedDeleteExprs[Idx++];
8153 for (uint64_t
C = 0;
C < Count; ++
C) {
8156 const bool IsArrayForm = DelayedDeleteExprs[Idx++];
8157 Exprs[FD].push_back(std::make_pair(DeleteLoc, IsArrayForm));
8164 for (
unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) {
8165 VarDecl *Var = dyn_cast_or_null<VarDecl>(GetDecl(TentativeDefinitions[I]));
8167 TentativeDefs.push_back(Var);
8169 TentativeDefinitions.clear();
8174 for (
unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++I) {
8176 = dyn_cast_or_null<DeclaratorDecl>(GetDecl(UnusedFileScopedDecls[I]));
8180 UnusedFileScopedDecls.clear();
8185 for (
unsigned I = 0, N = DelegatingCtorDecls.size(); I != N; ++I) {
8187 = dyn_cast_or_null<CXXConstructorDecl>(GetDecl(DelegatingCtorDecls[I]));
8191 DelegatingCtorDecls.clear();
8195 for (
unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++I) {
8197 = dyn_cast_or_null<TypedefNameDecl>(GetDecl(ExtVectorDecls[I]));
8201 ExtVectorDecls.clear();
8206 for (
unsigned I = 0, N = UnusedLocalTypedefNameCandidates.size(); I != N;
8209 GetDecl(UnusedLocalTypedefNameCandidates[I]));
8213 UnusedLocalTypedefNameCandidates.clear();
8218 if (ReferencedSelectorsData.empty())
8223 unsigned int DataSize = ReferencedSelectorsData.size()-1;
8225 while (I < DataSize) {
8226 Selector Sel = DecodeSelector(ReferencedSelectorsData[I++]);
8229 Sels.push_back(std::make_pair(Sel, SelLoc));
8231 ReferencedSelectorsData.clear();
8236 if (WeakUndeclaredIdentifiers.empty())
8239 for (
unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; ) {
8241 = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
8243 = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
8246 bool Used = WeakUndeclaredIdentifiers[I++];
8249 WeakIDs.push_back(std::make_pair(WeakId, WI));
8251 WeakUndeclaredIdentifiers.clear();
8255 for (
unsigned Idx = 0, N = VTableUses.size(); Idx < N; ) {
8257 VT.
Record = dyn_cast_or_null<CXXRecordDecl>(GetDecl(VTableUses[Idx++]));
8260 VTables.push_back(VT);
8268 for (
unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
8269 ValueDecl *D = cast<ValueDecl>(GetDecl(PendingInstantiations[Idx++]));
8273 Pending.push_back(std::make_pair(D, Loc));
8275 PendingInstantiations.clear();
8279 llvm::MapVector<
const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
8281 for (
unsigned Idx = 0, N = LateParsedTemplates.size(); Idx < N;
8283 FunctionDecl *FD = cast<FunctionDecl>(GetDecl(LateParsedTemplates[Idx++]));
8285 auto LT = llvm::make_unique<LateParsedTemplate>();
8286 LT->D = GetDecl(LateParsedTemplates[Idx++]);
8288 ModuleFile *F = getOwningModuleFile(LT->D);
8289 assert(F &&
"No module");
8291 unsigned TokN = LateParsedTemplates[Idx++];
8292 LT->Toks.reserve(TokN);
8293 for (
unsigned T = 0; T < TokN; ++T)
8294 LT->Toks.push_back(ReadToken(*F, LateParsedTemplates, Idx));
8296 LPTMap.insert(std::make_pair(FD, std::move(LT)));
8299 LateParsedTemplates.clear();
8304 ReadMethodPool(Sel);
8308 assert(ID &&
"Non-zero identifier ID required");
8309 assert(ID <= IdentifiersLoaded.size() &&
"identifier ID out of range");
8310 IdentifiersLoaded[ID - 1] = II;
8311 if (DeserializationListener)
8312 DeserializationListener->IdentifierRead(ID, II);
8335 if (NumCurrentElementsDeserializing && !Decls) {
8336 PendingIdentifierInfos[II].append(DeclIDs.begin(), DeclIDs.end());
8340 for (
unsigned I = 0, N = DeclIDs.size(); I != N; ++I) {
8345 PreloadedDeclIDs.push_back(DeclIDs[I]);
8349 NamedDecl *D = cast<NamedDecl>(GetDecl(DeclIDs[I]));
8353 Decls->push_back(D);
8360 pushExternalDeclIntoScope(D, II);
8368 if (IdentifiersLoaded.empty()) {
8369 Error(
"no identifier table in AST file");
8374 if (!IdentifiersLoaded[ID]) {
8376 assert(I != GlobalIdentifierMap.end() &&
"Corrupted global identifier map");
8377 ModuleFile *M = I->second;
8378 unsigned Index = ID - M->BaseIdentifierID;
8379 const char *Str = M->IdentifierTableData + M->IdentifierOffsets[Index];
8386 const unsigned char *StrLenPtr = (
const unsigned char*) Str - 2;
8387 unsigned StrLen = (((unsigned) StrLenPtr[0])
8388 | (((unsigned) StrLenPtr[1]) << 8)) - 1;
8389 auto &II = PP.getIdentifierTable().get(StringRef(Str, StrLen));
8390 IdentifiersLoaded[
ID] = &II;
8392 if (DeserializationListener)
8393 DeserializationListener->IdentifierRead(ID + 1, &II);
8396 return IdentifiersLoaded[
ID];
8400 return DecodeIdentifierInfo(getGlobalIdentifierID(M, LocalID));
8408 ReadModuleOffsetMap(M);
8413 &&
"Invalid index into identifier index remap");
8415 return LocalID + I->second;
8422 if (MacrosLoaded.empty()) {
8423 Error(
"no macro table in AST file");
8428 if (!MacrosLoaded[ID]) {
8431 assert(I != GlobalMacroMap.end() &&
"Corrupted global macro map");
8432 ModuleFile *M = I->second;
8433 unsigned Index = ID - M->BaseMacroID;
8434 MacrosLoaded[
ID] = ReadMacroRecord(*M, M->MacroOffsets[Index]);
8436 if (DeserializationListener)
8441 return MacrosLoaded[
ID];
8449 ReadModuleOffsetMap(M);
8453 assert(I != M.
MacroRemap.
end() &&
"Invalid index into macro index remap");
8455 return LocalID + I->second;
8464 ReadModuleOffsetMap(M);
8469 &&
"Invalid index into submodule index remap");
8471 return LocalID + I->second;
8476 assert(GlobalID == 0 &&
"Unhandled global submodule ID");
8480 if (GlobalID > SubmodulesLoaded.size()) {
8481 Error(
"submodule ID out of range in AST file");
8489 return getSubmodule(ID);
8493 ModuleFile *MF = getOwningModuleFile(D);
8500 auto I = GlobalSubmoduleMap.find(getGlobalSubmoduleID(F, ID >> 1));
8501 return I == GlobalSubmoduleMap.end() ? nullptr : I->second;
8504 unsigned IndexFromEnd = ID >> 1;
8505 assert(IndexFromEnd &&
"got reference to unknown module file");
8506 return getModuleManager().pch_modules().end()[-IndexFromEnd];
8521 auto PCHModules = getModuleManager().pch_modules();
8522 auto I = std::find(PCHModules.begin(), PCHModules.end(), F);
8523 assert(I != PCHModules.end() &&
"emitting reference to unknown file");
8524 return (I - PCHModules.end()) << 1;
8529 if (
const Module *M = getSubmodule(ID))
8534 const auto &PCHChain = ModuleMgr.pch_modules();
8535 if (
std::distance(std::begin(PCHChain), std::end(PCHChain))) {
8536 ModuleFile &MF = ModuleMgr.getPrimaryModule();
8538 StringRef FileName = llvm::sys::path::filename(MF.
FileName);
8546 auto I = DefinitionSource.find(FD);
8547 if (I == DefinitionSource.end())
8548 return EK_ReplyHazy;
8549 return I->second ? EK_Never : EK_Always;
8553 return DecodeSelector(getGlobalSelectorID(M, LocalID));
8560 if (ID > SelectorsLoaded.size()) {
8561 Error(
"selector ID out of range in AST file");
8565 if (SelectorsLoaded[ID - 1].getAsOpaquePtr() ==
nullptr) {
8568 assert(I != GlobalSelectorMap.end() &&
"Corrupted global selector map");
8569 ModuleFile &M = *I->second;
8572 SelectorsLoaded[ID - 1] =
8573 Trait.
ReadKey(M.SelectorLookupTableData + M.SelectorOffsets[Idx], 0);
8574 if (DeserializationListener)
8575 DeserializationListener->SelectorRead(ID, SelectorsLoaded[ID - 1]);
8578 return SelectorsLoaded[ID - 1];
8582 return DecodeSelector(ID);
8587 return getTotalNumSelectors() + 1;
8596 ReadModuleOffsetMap(M);
8601 &&
"Invalid index into selector index remap");
8603 return LocalID + I->second;
8630 ReadDeclAs<TemplateDecl>(F, Record, Idx));
8642 GetIdentifierInfo(F, Record, Idx));
8648 llvm_unreachable(
"Invalid NameKind!");
8664 = ReadSourceLocation(F, Record, Idx).getRawEncoding();
8666 = ReadSourceLocation(F, Record, Idx).getRawEncoding();
8671 = ReadSourceLocation(F, Record, Idx).getRawEncoding();
8687 NameInfo.
setName(ReadDeclarationName(F, Record, Idx));
8688 NameInfo.
setLoc(ReadSourceLocation(F, Record, Idx));
8690 ReadDeclarationNameLoc(F, DNLoc, NameInfo.
getName(), Record, Idx);
8696 Info.
QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
8697 unsigned NumTPLists = Record[Idx++];
8702 for (
unsigned i = 0; i != NumTPLists; ++i)
8714 return TemplateName(ReadDeclAs<TemplateDecl>(F, Record, Idx));
8717 unsigned size = Record[Idx++];
8720 Decls.
addDecl(ReadDeclAs<NamedDecl>(F, Record, Idx));
8727 bool hasTemplKeyword = Record[Idx++];
8728 TemplateDecl *Template = ReadDeclAs<TemplateDecl>(F, Record, Idx);
8736 GetIdentifierInfo(F, Record,
8744 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
8746 TemplateName replacement = ReadTemplateName(F, Record, Idx);
8752 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
8764 llvm_unreachable(
"Unhandled template name kind!");
8770 bool Canonicalize) {
8788 ValueDecl *D = ReadDeclAs<ValueDecl>(F, Record, Idx);
8794 llvm::APSInt
Value = ReadAPSInt(Record, Idx);
8795 QualType T = readType(F, Record, Idx);
8803 if (
unsigned NumExpansions = Record[Idx++])
8804 NumTemplateExpansions = NumExpansions - 1;
8810 unsigned NumArgs = Record[Idx++];
8812 for (
unsigned I = 0; I != NumArgs; ++I)
8813 Args[I] = ReadTemplateArgument(F, Record, Idx);
8818 llvm_unreachable(
"Unhandled template argument kind!");
8828 unsigned NumParams = Record[Idx++];
8830 Params.reserve(NumParams);
8832 Params.push_back(ReadDeclAs<NamedDecl>(F, Record, Idx));
8836 getContext(), TemplateLoc, LAngleLoc, Params, RAngleLoc,
nullptr);
8837 return TemplateParams;
8844 unsigned &Idx,
bool Canonicalize) {
8845 unsigned NumTemplateArgs = Record[Idx++];
8846 TemplArgs.reserve(NumTemplateArgs);
8847 while (NumTemplateArgs--)
8848 TemplArgs.push_back(ReadTemplateArgument(F, Record, Idx, Canonicalize));
8854 unsigned NumDecls = Record[Idx++];
8855 Set.
reserve(getContext(), NumDecls);
8856 while (NumDecls--) {
8857 DeclID ID = ReadDeclID(F, Record, Idx);
8866 bool isVirtual =
static_cast<bool>(Record[Idx++]);
8867 bool isBaseOfClass =
static_cast<bool>(Record[Idx++]);
8869 bool inheritConstructors =
static_cast<bool>(Record[Idx++]);
8871 SourceRange Range = ReadSourceRange(F, Record, Idx);
8883 unsigned NumInitializers = Record[Idx++];
8884 assert(NumInitializers &&
"wrote ctor initializers but have no inits");
8886 for (
unsigned i = 0; i != NumInitializers; ++i) {
8888 bool IsBaseVirtual =
false;
8895 TInfo = GetTypeSourceInfo(F, Record, Idx);
8896 IsBaseVirtual = Record[Idx++];
8900 TInfo = GetTypeSourceInfo(F, Record, Idx);
8904 Member = ReadDeclAs<FieldDecl>(F, Record, Idx);
8908 IndirectMember = ReadDeclAs<IndirectFieldDecl>(F, Record, Idx);
8912 SourceLocation MemberOrEllipsisLoc = ReadSourceLocation(F, Record, Idx);
8913 Expr *Init = ReadExpr(F);
8919 BOMInit =
new (Context)
8921 RParenLoc, MemberOrEllipsisLoc);
8923 BOMInit =
new (Context)
8926 BOMInit =
new (Context)
8930 BOMInit =
new (Context)
8932 LParenLoc, Init, RParenLoc);
8934 if (Record[Idx++]) {
8935 unsigned SourceOrder = Record[Idx++];
8939 CtorInitializers[i] = BOMInit;
8942 return CtorInitializers;
8949 unsigned N = Record[Idx++];
8951 for (
unsigned I = 0; I != N; ++I) {
8962 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
8975 const Type *T = readType(F, Record, Idx).getTypePtrOrNull();
8979 bool Template = Record[Idx++];
8990 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
9004 unsigned N = Record[Idx++];
9006 for (
unsigned I = 0; I != N; ++I) {
9012 SourceRange Range = ReadSourceRange(F, Record, Idx);
9018 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
9019 SourceRange Range = ReadSourceRange(F, Record, Idx);
9020 Builder.
Extend(Context, NS, Range.getBegin(), Range.getEnd());
9026 SourceRange Range = ReadSourceRange(F, Record, Idx);
9027 Builder.
Extend(Context, Alias, Range.getBegin(), Range.getEnd());
9033 bool Template = Record[Idx++];
9037 SourceLocation ColonColonLoc = ReadSourceLocation(F, Record, Idx);
9047 SourceLocation ColonColonLoc = ReadSourceLocation(F, Record, Idx);
9053 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
9054 SourceRange Range = ReadSourceRange(F, Record, Idx);
9055 Builder.
MakeSuper(Context, RD, Range.getBegin(), Range.getEnd());
9074 unsigned BitWidth = Record[Idx++];
9075 unsigned NumWords = llvm::APInt::getNumWords(BitWidth);
9076 llvm::APInt
Result(BitWidth, NumWords, &Record[Idx]);
9083 bool isUnsigned = Record[Idx++];
9084 return llvm::APSInt(ReadAPInt(Record, Idx), isUnsigned);
9089 const llvm::fltSemantics &Sem,
9091 return llvm::APFloat(Sem, ReadAPInt(Record, Idx));
9096 unsigned Len = Record[Idx++];
9097 std::string
Result(Record.data() + Idx, Record.data() + Idx + Len);
9104 std::string
Filename = ReadString(Record, Idx);
9105 ResolveImportedPath(F, Filename);
9111 unsigned Major = Record[Idx++];
9112 unsigned Minor = Record[Idx++];
9113 unsigned Subminor = Record[Idx++];
9115 return VersionTuple(Major);
9117 return VersionTuple(Major, Minor - 1);
9118 return VersionTuple(Major, Minor - 1, Subminor - 1);
9129 return Diag(CurrentImportLoc, DiagID);
9133 return Diags.Report(Loc, DiagID);
9139 return PP.getIdentifierTable();
9145 assert((*CurrSwitchCaseStmts)[ID] ==
nullptr &&
9146 "Already have a SwitchCase with this ID");
9147 (*CurrSwitchCaseStmts)[
ID] = SC;
9152 assert((*CurrSwitchCaseStmts)[ID] !=
nullptr &&
"No SwitchCase with this ID");
9153 return (*CurrSwitchCaseStmts)[
ID];
9157 CurrSwitchCaseStmts->clear();
9162 std::vector<RawComment *> Comments;
9165 I = CommentsCursors.begin(),
9166 E = CommentsCursors.end();
9169 BitstreamCursor &
Cursor = I->first;
9175 llvm::BitstreamEntry Entry =
9176 Cursor.advanceSkippingSubblocks(BitstreamCursor::AF_DontPopBlockAtEnd);
9178 switch (Entry.Kind) {
9179 case llvm::BitstreamEntry::SubBlock:
9181 Error(
"malformed block record in AST file");
9183 case llvm::BitstreamEntry::EndBlock:
9185 case llvm::BitstreamEntry::Record:
9198 bool IsTrailingComment = Record[Idx++];
9199 bool IsAlmostTrailingComment = Record[Idx++];
9201 SR, Kind, IsTrailingComment, IsAlmostTrailingComment));
9209 llvm::sort(Comments.begin(), Comments.end(),
9211 Context.
Comments.addDeserializedComments(Comments);
9216 bool IncludeSystem,
bool Complain,
9221 assert(NumUserInputs <= NumInputs);
9222 unsigned N = IncludeSystem ? NumInputs : NumUserInputs;
9223 for (
unsigned I = 0; I < N; ++I) {
9224 bool IsSystem = I >= NumUserInputs;
9225 InputFile IF = getInputFile(MF, I+1, Complain);
9226 Visitor(IF, IsSystem);
9232 llvm::function_ref<
void(
const FileEntry *FE)> Visitor) {
9234 for (
unsigned I = 0; I < NumInputs; ++I) {
9235 InputFileInfo IFI = readInputFileInfo(MF, I + 1);
9236 if (IFI.TopLevelModuleMap)
9238 if (
auto *FE = getInputFile(MF, I + 1).getFile())
9246 return M->getFullModuleName();
9249 if (ModuleFile *M = getOwningModuleFile(D))
9256 void ASTReader::finishPendingActions() {
9257 while (!PendingIdentifierInfos.empty() ||
9258 !PendingIncompleteDeclChains.empty() || !PendingDeclChains.empty() ||
9259 !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
9260 !PendingUpdateRecords.empty()) {
9263 using TopLevelDeclsMap =
9264 llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2>>;
9265 TopLevelDeclsMap TopLevelDecls;
9267 while (!PendingIdentifierInfos.empty()) {
9270 std::move(PendingIdentifierInfos.back().second);
9271 PendingIdentifierInfos.pop_back();
9273 SetGloballyVisibleDecls(II, DeclIDs, &TopLevelDecls[II]);
9278 for (
unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
9279 markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
9281 PendingIncompleteDeclChains.clear();
9284 for (
unsigned I = 0; I != PendingDeclChains.size(); ++I)
9285 loadPendingDeclChain(PendingDeclChains[I].first, PendingDeclChains[I].second);
9286 PendingDeclChains.clear();
9289 for (TopLevelDeclsMap::iterator TLD = TopLevelDecls.begin(),
9290 TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) {
9292 for (
unsigned I = 0, N = TLD->second.size(); I != N; ++I) {
9293 pushExternalDeclIntoScope(cast<NamedDecl>(TLD->second[I]), II);
9298 for (
unsigned I = 0; I != PendingMacroIDs.size(); ++I) {
9301 GlobalIDs.swap(PendingMacroIDs.begin()[I].second);
9303 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9305 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9306 if (!Info.M->isModule())
9307 resolvePendingMacro(II, Info);
9310 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9312 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9313 if (Info.M->isModule())
9314 resolvePendingMacro(II, Info);
9317 PendingMacroIDs.clear();
9321 while (!PendingDeclContextInfos.empty()) {
9322 PendingDeclContextInfo Info = PendingDeclContextInfos.front();
9323 PendingDeclContextInfos.pop_front();
9324 DeclContext *SemaDC = cast<DeclContext>(GetDecl(Info.SemaDC));
9325 DeclContext *LexicalDC = cast<DeclContext>(GetDecl(Info.LexicalDC));
9326 Info.D->setDeclContextsImpl(SemaDC, LexicalDC, getContext());
9330 while (!PendingUpdateRecords.empty()) {
9331 auto Update = PendingUpdateRecords.pop_back_val();
9332 ReadingKindTracker ReadingKind(Read_Decl, *
this);
9333 loadDeclUpdateRecords(
Update);
9339 assert(PendingFakeDefinitionData.empty() &&
9340 "faked up a class definition but never saw the real one");
9346 for (
Decl *D : PendingDefinitions) {
9347 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
9348 if (
const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) {
9353 if (
auto RD = dyn_cast<CXXRecordDecl>(D)) {
9354 for (
auto *R = getMostRecentExistingDecl(RD); R;
9355 R = R->getPreviousDecl()) {
9357 cast<CXXRecordDecl>(R)->isThisDeclarationADefinition() &&
9358 "declaration thinks it's the definition but it isn't");
9359 cast<CXXRecordDecl>(R)->DefinitionData = RD->DefinitionData;
9366 if (
auto ID = dyn_cast<ObjCInterfaceDecl>(D)) {
9371 for (
auto *R = getMostRecentExistingDecl(
ID); R; R = R->getPreviousDecl())
9372 cast<ObjCInterfaceDecl>(R)->Data =
ID->Data;
9377 if (
auto PD = dyn_cast<ObjCProtocolDecl>(D)) {
9378 for (
auto *R = getMostRecentExistingDecl(PD); R; R = R->getPreviousDecl())
9379 cast<ObjCProtocolDecl>(R)->Data = PD->Data;
9385 for (
auto *R = getMostRecentExistingDecl(RTD); R; R = R->getPreviousDecl())
9386 cast<RedeclarableTemplateDecl>(R)->Common = RTD->Common;
9388 PendingDefinitions.clear();
9394 for (PendingBodiesMap::iterator PB = PendingBodies.begin(),
9395 PBEnd = PendingBodies.end();
9396 PB != PBEnd; ++PB) {
9397 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
9407 if (
auto *RD = dyn_cast<CXXRecordDecl>(FD->getLexicalParent()))
9408 if (RD->isDependentContext() && !RD->isThisDeclarationADefinition())
9414 if (!getContext().getLangOpts().Modules || !FD->hasBody(Defn)) {
9418 mergeDefinitionVisibility(NonConstDefn, FD);
9420 if (!FD->isLateTemplateParsed() &&
9421 !NonConstDefn->isLateTemplateParsed() &&
9422 FD->getODRHash() != NonConstDefn->getODRHash()) {
9423 if (!isa<CXXMethodDecl>(FD)) {
9424 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
9425 }
else if (FD->getLexicalParent()->isFileContext() &&
9426 NonConstDefn->getLexicalParent()->isFileContext()) {
9430 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
9438 if (!getContext().getLangOpts().Modules || !MD->
hasBody())
9441 PendingBodies.clear();
9444 for (
auto *ND : PendingMergedDefinitionsToDeduplicate)
9445 getContext().deduplicateMergedDefinitonsFor(ND);
9446 PendingMergedDefinitionsToDeduplicate.clear();
9449 void ASTReader::diagnoseOdrViolations() {
9450 if (PendingOdrMergeFailures.empty() && PendingOdrMergeChecks.empty() &&
9451 PendingFunctionOdrMergeFailures.empty() &&
9452 PendingEnumOdrMergeFailures.empty())
9459 auto OdrMergeFailures = std::move(PendingOdrMergeFailures);
9460 PendingOdrMergeFailures.clear();
9461 for (
auto &Merge : OdrMergeFailures) {
9462 Merge.first->buildLookup();
9463 Merge.first->decls_begin();
9464 Merge.first->bases_begin();
9465 Merge.first->vbases_begin();
9466 for (
auto &RecordPair : Merge.second) {
9467 auto *RD = RecordPair.first;
9475 auto FunctionOdrMergeFailures = std::move(PendingFunctionOdrMergeFailures);
9476 PendingFunctionOdrMergeFailures.clear();
9477 for (
auto &Merge : FunctionOdrMergeFailures) {
9478 Merge.first->buildLookup();
9479 Merge.first->decls_begin();
9480 Merge.first->getBody();
9481 for (
auto &FD : Merge.second) {
9489 auto EnumOdrMergeFailures = std::move(PendingEnumOdrMergeFailures);
9490 PendingEnumOdrMergeFailures.clear();
9491 for (
auto &Merge : EnumOdrMergeFailures) {
9492 Merge.first->decls_begin();
9493 for (
auto &Enum : Merge.second) {
9494 Enum->decls_begin();
9504 while (!PendingOdrMergeChecks.empty()) {
9505 NamedDecl *D = PendingOdrMergeChecks.pop_back_val();
9519 for (
auto RI : D->
redecls()) {
9520 if (RI->getLexicalDeclContext() == CanonDef) {
9535 for (
auto *CanonMember : CanonDef->
decls()) {
9536 if (CanonMember->getCanonicalDecl() == DCanon) {
9545 if (
auto *ND = dyn_cast<NamedDecl>(CanonMember))
9547 Candidates.push_back(ND);
9553 if (!isa<TagDecl>(D))
9560 std::string CanonDefModule =
9561 getOwningModuleNameForDiagnostic(cast<Decl>(CanonDef));
9563 << D << getOwningModuleNameForDiagnostic(D)
9564 << CanonDef << CanonDefModule.empty() << CanonDefModule;
9566 if (Candidates.empty())
9567 Diag(cast<Decl>(CanonDef)->getLocation(),
9568 diag::note_module_odr_violation_no_possible_decls) << D;
9570 for (
unsigned I = 0, N = Candidates.size(); I != N; ++I)
9571 Diag(Candidates[I]->getLocation(),
9572 diag::note_module_odr_violation_possible_decl)
9576 DiagnosedOdrMergeFailures.insert(CanonDef);
9580 if (OdrMergeFailures.empty() && FunctionOdrMergeFailures.empty() &&
9581 EnumOdrMergeFailures.empty())
9590 auto ComputeQualTypeODRHash = [&Hash](
QualType Ty) {
9596 auto ComputeODRHash = [&Hash](
const Stmt *S) {
9603 auto ComputeSubDeclODRHash = [&Hash](
const Decl *D) {
9610 auto ComputeTemplateArgumentODRHash = [&Hash](
const TemplateArgument &TA) {
9616 auto ComputeTemplateParameterListODRHash =
9625 for (
auto &Merge : OdrMergeFailures) {
9628 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
9631 bool Diagnosed =
false;
9633 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstRecord);
9634 for (
auto &RecordPair : Merge.second) {
9638 if (FirstRecord == SecondRecord)
9641 std::string SecondModule = getOwningModuleNameForDiagnostic(SecondRecord);
9643 auto *FirstDD = FirstRecord->DefinitionData;
9644 auto *SecondDD = RecordPair.second;
9646 assert(FirstDD && SecondDD &&
"Definitions without DefinitionData");
9649 if (FirstDD != SecondDD) {
9650 enum ODRDefinitionDataDifference {
9657 auto ODRDiagError = [FirstRecord, &FirstModule,
9659 ODRDefinitionDataDifference DiffType) {
9660 return Diag(Loc, diag::err_module_odr_violation_definition_data)
9661 << FirstRecord << FirstModule.empty() << FirstModule << Range
9664 auto ODRDiagNote = [&SecondModule,
9666 ODRDefinitionDataDifference DiffType) {
9667 return Diag(Loc, diag::note_module_odr_violation_definition_data)
9668 << SecondModule << Range << DiffType;
9671 unsigned FirstNumBases = FirstDD->NumBases;
9672 unsigned FirstNumVBases = FirstDD->NumVBases;
9673 unsigned SecondNumBases = SecondDD->NumBases;
9674 unsigned SecondNumVBases = SecondDD->NumVBases;
9676 auto GetSourceRange = [](
struct CXXRecordDecl::DefinitionData *DD) {
9677 unsigned NumBases = DD->NumBases;
9679 auto bases = DD->bases();
9681 bases[NumBases - 1].getLocEnd());
9684 if (FirstNumBases != SecondNumBases) {
9685 ODRDiagError(FirstRecord->
getLocation(), GetSourceRange(FirstDD),
9688 ODRDiagNote(SecondRecord->
getLocation(), GetSourceRange(SecondDD),
9695 if (FirstNumVBases != SecondNumVBases) {
9696 ODRDiagError(FirstRecord->
getLocation(), GetSourceRange(FirstDD),
9699 ODRDiagNote(SecondRecord->
getLocation(), GetSourceRange(SecondDD),
9706 auto FirstBases = FirstDD->bases();
9707 auto SecondBases = SecondDD->bases();
9709 for (i = 0; i < FirstNumBases; ++i) {
9710 auto FirstBase = FirstBases[i];
9711 auto SecondBase = SecondBases[i];
9712 if (ComputeQualTypeODRHash(FirstBase.getType()) !=
9713 ComputeQualTypeODRHash(SecondBase.getType())) {
9714 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
9716 << (i + 1) << FirstBase.getType();
9718 SecondBase.getSourceRange(), BaseType)
9719 << (i + 1) << SecondBase.getType();
9723 if (FirstBase.isVirtual() != SecondBase.isVirtual()) {
9724 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
9726 << (i + 1) << FirstBase.isVirtual() << FirstBase.getType();
9728 SecondBase.getSourceRange(), BaseVirtual)
9729 << (i + 1) << SecondBase.isVirtual() << SecondBase.getType();
9733 if (FirstBase.getAccessSpecifierAsWritten() !=
9734 SecondBase.getAccessSpecifierAsWritten()) {
9735 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
9737 << (i + 1) << FirstBase.getType()
9738 << (int)FirstBase.getAccessSpecifierAsWritten();
9740 SecondBase.getSourceRange(), BaseAccess)
9741 << (i + 1) << SecondBase.getType()
9742 << (int)SecondBase.getAccessSpecifierAsWritten();
9747 if (i != FirstNumBases) {
9760 assert(!FirstTemplate == !SecondTemplate &&
9761 "Both pointers should be null or non-null");
9763 enum ODRTemplateDifference {
9766 ParamSingleDefaultArgument,
9767 ParamDifferentDefaultArgument,
9770 if (FirstTemplate && SecondTemplate) {
9771 DeclHashes FirstTemplateHashes;
9772 DeclHashes SecondTemplateHashes;
9774 auto PopulateTemplateParameterHashs =
9775 [&ComputeSubDeclODRHash](DeclHashes &Hashes,
9777 for (
auto *D : TD->getTemplateParameters()->asArray()) {
9778 Hashes.emplace_back(D, ComputeSubDeclODRHash(D));
9782 PopulateTemplateParameterHashs(FirstTemplateHashes, FirstTemplate);
9783 PopulateTemplateParameterHashs(SecondTemplateHashes, SecondTemplate);
9785 assert(FirstTemplateHashes.size() == SecondTemplateHashes.size() &&
9786 "Number of template parameters should be equal.");
9788 auto FirstIt = FirstTemplateHashes.begin();
9789 auto FirstEnd = FirstTemplateHashes.end();
9790 auto SecondIt = SecondTemplateHashes.begin();
9791 for (; FirstIt != FirstEnd; ++FirstIt, ++SecondIt) {
9792 if (FirstIt->second == SecondIt->second)
9795 auto ODRDiagError = [FirstRecord, &FirstModule,
9797 ODRTemplateDifference DiffType) {
9798 return Diag(Loc, diag::err_module_odr_violation_template_parameter)
9799 << FirstRecord << FirstModule.empty() << FirstModule << Range
9802 auto ODRDiagNote = [&SecondModule,
9804 ODRTemplateDifference DiffType) {
9805 return Diag(Loc, diag::note_module_odr_violation_template_parameter)
9806 << SecondModule << Range << DiffType;
9809 const NamedDecl* FirstDecl = cast<NamedDecl>(FirstIt->first);
9810 const NamedDecl* SecondDecl = cast<NamedDecl>(SecondIt->first);
9812 assert(FirstDecl->
getKind() == SecondDecl->getKind() &&
9813 "Parameter Decl's should be the same kind.");
9818 if (FirstName != SecondName) {
9819 const bool FirstNameEmpty =
9820 FirstName.
isIdentifier() && !FirstName.getAsIdentifierInfo();
9821 const bool SecondNameEmpty =
9823 assert((!FirstNameEmpty || !SecondNameEmpty) &&
9824 "Both template parameters cannot be unnamed.");
9826 FirstNameEmpty ? ParamEmptyName : ParamName)
9828 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9829 SecondNameEmpty ? ParamEmptyName : ParamName)
9834 switch (FirstDecl->
getKind()) {
9836 llvm_unreachable(
"Invalid template parameter type.");
9837 case Decl::TemplateTypeParm: {
9838 const auto *FirstParam = cast<TemplateTypeParmDecl>(FirstDecl);
9839 const auto *SecondParam = cast<TemplateTypeParmDecl>(SecondDecl);
9840 const bool HasFirstDefaultArgument =
9841 FirstParam->hasDefaultArgument() &&
9842 !FirstParam->defaultArgumentWasInherited();
9843 const bool HasSecondDefaultArgument =
9844 SecondParam->hasDefaultArgument() &&
9845 !SecondParam->defaultArgumentWasInherited();
9847 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9850 ParamSingleDefaultArgument)
9851 << HasFirstDefaultArgument;
9852 ODRDiagNote(SecondDecl->getLocation(),
9853 SecondDecl->getSourceRange(),
9854 ParamSingleDefaultArgument)
9855 << HasSecondDefaultArgument;
9859 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9860 "Expecting default arguments.");
9863 ParamDifferentDefaultArgument);
9864 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9865 ParamDifferentDefaultArgument);
9869 case Decl::NonTypeTemplateParm: {
9870 const auto *FirstParam = cast<NonTypeTemplateParmDecl>(FirstDecl);
9871 const auto *SecondParam = cast<NonTypeTemplateParmDecl>(SecondDecl);
9872 const bool HasFirstDefaultArgument =
9873 FirstParam->hasDefaultArgument() &&
9874 !FirstParam->defaultArgumentWasInherited();
9875 const bool HasSecondDefaultArgument =
9876 SecondParam->hasDefaultArgument() &&
9877 !SecondParam->defaultArgumentWasInherited();
9879 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9882 ParamSingleDefaultArgument)
9883 << HasFirstDefaultArgument;
9884 ODRDiagNote(SecondDecl->getLocation(),
9885 SecondDecl->getSourceRange(),
9886 ParamSingleDefaultArgument)
9887 << HasSecondDefaultArgument;
9891 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9892 "Expecting default arguments.");
9895 ParamDifferentDefaultArgument);
9896 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9897 ParamDifferentDefaultArgument);
9901 case Decl::TemplateTemplateParm: {
9902 const auto *FirstParam = cast<TemplateTemplateParmDecl>(FirstDecl);
9903 const auto *SecondParam =
9904 cast<TemplateTemplateParmDecl>(SecondDecl);
9905 const bool HasFirstDefaultArgument =
9906 FirstParam->hasDefaultArgument() &&
9907 !FirstParam->defaultArgumentWasInherited();
9908 const bool HasSecondDefaultArgument =
9909 SecondParam->hasDefaultArgument() &&
9910 !SecondParam->defaultArgumentWasInherited();
9912 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9915 ParamSingleDefaultArgument)
9916 << HasFirstDefaultArgument;
9917 ODRDiagNote(SecondDecl->getLocation(),
9918 SecondDecl->getSourceRange(),
9919 ParamSingleDefaultArgument)
9920 << HasSecondDefaultArgument;
9924 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9925 "Expecting default arguments.");
9928 ParamDifferentDefaultArgument);
9929 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9930 ParamDifferentDefaultArgument);
9939 if (FirstIt != FirstEnd) {
9945 DeclHashes FirstHashes;
9946 DeclHashes SecondHashes;
9948 auto PopulateHashes = [&ComputeSubDeclODRHash, FirstRecord](
9950 for (
auto *D : Record->decls()) {
9955 Hashes.emplace_back(D, ComputeSubDeclODRHash(D));
9958 PopulateHashes(FirstHashes, FirstRecord);
9959 PopulateHashes(SecondHashes, SecondRecord);
9978 } FirstDiffType = Other,
9979 SecondDiffType = Other;
9981 auto DifferenceSelector = [](
Decl *D) {
9982 assert(D &&
"valid Decl required");
9986 case Decl::AccessSpec:
9989 return PublicSpecifer;
9991 return PrivateSpecifer;
9993 return ProtectedSpecifer;
9997 llvm_unreachable(
"Invalid access specifier");
9998 case Decl::StaticAssert:
9999 return StaticAssert;
10002 case Decl::CXXMethod:
10003 case Decl::CXXConstructor:
10004 case Decl::CXXDestructor:
10006 case Decl::TypeAlias:
10008 case Decl::Typedef:
10014 case Decl::FunctionTemplate:
10015 return FunctionTemplate;
10019 Decl *FirstDecl =
nullptr;
10020 Decl *SecondDecl =
nullptr;
10021 auto FirstIt = FirstHashes.begin();
10022 auto SecondIt = SecondHashes.begin();
10027 while (FirstIt != FirstHashes.end() || SecondIt != SecondHashes.end()) {
10028 if (FirstIt != FirstHashes.end() && SecondIt != SecondHashes.end() &&
10029 FirstIt->second == SecondIt->second) {
10035 FirstDecl = FirstIt == FirstHashes.end() ? nullptr : FirstIt->first;
10036 SecondDecl = SecondIt == SecondHashes.end() ? nullptr : SecondIt->first;
10038 FirstDiffType = FirstDecl ? DifferenceSelector(FirstDecl) : EndOfClass;
10040 SecondDecl ? DifferenceSelector(SecondDecl) : EndOfClass;
10045 if (FirstDiffType == Other || SecondDiffType == Other) {
10050 diag::err_module_odr_violation_different_definitions)
10051 << FirstRecord << FirstModule.empty() << FirstModule;
10059 diag::note_module_odr_violation_different_definitions)
10071 if (FirstDiffType != SecondDiffType) {
10074 if (FirstDiffType == EndOfClass) {
10077 FirstLoc = FirstIt->first->getLocation();
10078 FirstRange = FirstIt->first->getSourceRange();
10080 Diag(FirstLoc, diag::err_module_odr_violation_mismatch_decl)
10081 << FirstRecord << FirstModule.empty() << FirstModule << FirstRange
10086 if (SecondDiffType == EndOfClass) {
10092 Diag(SecondLoc, diag::note_module_odr_violation_mismatch_decl)
10093 << SecondModule << SecondRange << SecondDiffType;
10098 assert(FirstDiffType == SecondDiffType);
10102 enum ODRDeclDifference {
10103 StaticAssertCondition,
10104 StaticAssertMessage,
10105 StaticAssertOnlyMessage,
10108 FieldSingleBitField,
10109 FieldDifferentWidthBitField,
10110 FieldSingleMutable,
10111 FieldSingleInitializer,
10112 FieldDifferentInitializers,
10121 MethodNumberParameters,
10122 MethodParameterType,
10123 MethodParameterName,
10124 MethodParameterSingleDefaultArgument,
10125 MethodParameterDifferentDefaultArgument,
10126 MethodNoTemplateArguments,
10127 MethodDifferentNumberTemplateArguments,
10128 MethodDifferentTemplateArgument,
10130 MethodDifferentBody,
10135 VarSingleInitializer,
10136 VarDifferentInitializer,
10138 FriendTypeFunction,
10141 FunctionTemplateDifferentNumberParameters,
10142 FunctionTemplateParameterDifferentKind,
10143 FunctionTemplateParameterName,
10144 FunctionTemplateParameterSingleDefaultArgument,
10145 FunctionTemplateParameterDifferentDefaultArgument,
10146 FunctionTemplateParameterDifferentType,
10147 FunctionTemplatePackParameter,
10153 auto ODRDiagError = [FirstRecord, &FirstModule,
this](
10155 return Diag(Loc, diag::err_module_odr_violation_mismatch_decl_diff)
10156 << FirstRecord << FirstModule.empty() << FirstModule << Range
10159 auto ODRDiagNote = [&SecondModule,
this](
10161 return Diag(Loc, diag::note_module_odr_violation_mismatch_decl_diff)
10162 << SecondModule << Range << DiffType;
10165 switch (FirstDiffType) {
10168 case PublicSpecifer:
10169 case PrivateSpecifer:
10170 case ProtectedSpecifer:
10171 llvm_unreachable(
"Invalid diff type");
10173 case StaticAssert: {
10178 Expr *SecondExpr = SecondSA->getAssertExpr();
10179 unsigned FirstODRHash = ComputeODRHash(FirstExpr);
10180 unsigned SecondODRHash = ComputeODRHash(SecondExpr);
10181 if (FirstODRHash != SecondODRHash) {
10182 ODRDiagError(FirstExpr->getLocStart(), FirstExpr->getSourceRange(),
10183 StaticAssertCondition);
10192 assert((FirstStr || SecondStr) &&
"Both messages cannot be empty");
10193 if ((FirstStr && !SecondStr) || (!FirstStr && SecondStr)) {
10207 SecondLoc = SecondSA->getLocStart();
10208 SecondRange = SecondSA->getSourceRange();
10210 ODRDiagError(FirstLoc, FirstRange, StaticAssertOnlyMessage)
10211 << (FirstStr ==
nullptr);
10212 ODRDiagNote(SecondLoc, SecondRange, StaticAssertOnlyMessage)
10213 << (SecondStr ==
nullptr);
10218 if (FirstStr && SecondStr &&
10221 StaticAssertMessage);
10223 StaticAssertMessage);
10230 FieldDecl *FirstField = cast<FieldDecl>(FirstDecl);
10231 FieldDecl *SecondField = cast<FieldDecl>(SecondDecl);
10234 if (FirstII->getName() != SecondII->
getName()) {
10238 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10246 assert(getContext().hasSameType(FirstField->
getType(),
10247 SecondField->getType()));
10250 QualType SecondType = SecondField->getType();
10251 if (ComputeQualTypeODRHash(FirstType) !=
10252 ComputeQualTypeODRHash(SecondType)) {
10255 << FirstII << FirstType;
10256 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10258 << SecondII << SecondType;
10264 const bool IsFirstBitField = FirstField->
isBitField();
10265 const bool IsSecondBitField = SecondField->isBitField();
10266 if (IsFirstBitField != IsSecondBitField) {
10268 FieldSingleBitField)
10269 << FirstII << IsFirstBitField;
10270 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10271 FieldSingleBitField)
10272 << SecondII << IsSecondBitField;
10277 if (IsFirstBitField && IsSecondBitField) {
10279 FieldDifferentWidthBitField)
10281 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10282 FieldDifferentWidthBitField)
10283 << SecondII << SecondField->getBitWidth()->getSourceRange();
10288 const bool IsFirstMutable = FirstField->
isMutable();
10289 const bool IsSecondMutable = SecondField->isMutable();
10290 if (IsFirstMutable != IsSecondMutable) {
10292 FieldSingleMutable)
10293 << FirstII << IsFirstMutable;
10294 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10295 FieldSingleMutable)
10296 << SecondII << IsSecondMutable;
10302 const Expr *SecondInitializer = SecondField->getInClassInitializer();
10303 if ((!FirstInitializer && SecondInitializer) ||
10304 (FirstInitializer && !SecondInitializer)) {
10306 FieldSingleInitializer)
10307 << FirstII << (FirstInitializer !=
nullptr);
10308 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10309 FieldSingleInitializer)
10310 << SecondII << (SecondInitializer !=
nullptr);
10315 if (FirstInitializer && SecondInitializer) {
10316 unsigned FirstInitHash = ComputeODRHash(FirstInitializer);
10317 unsigned SecondInitHash = ComputeODRHash(SecondInitializer);
10318 if (FirstInitHash != SecondInitHash) {
10321 FieldDifferentInitializers)
10323 ODRDiagNote(SecondField->getLocation(),
10324 SecondField->getSourceRange(),
10325 FieldDifferentInitializers)
10341 auto GetMethodTypeForDiagnostics = [](
const CXXMethodDecl* D) {
10342 if (isa<CXXConstructorDecl>(D))
return DiagConstructor;
10343 if (isa<CXXDestructorDecl>(D))
return DiagDestructor;
10346 const CXXMethodDecl *FirstMethod = cast<CXXMethodDecl>(FirstDecl);
10347 const CXXMethodDecl *SecondMethod = cast<CXXMethodDecl>(SecondDecl);
10348 FirstMethodType = GetMethodTypeForDiagnostics(FirstMethod);
10349 SecondMethodType = GetMethodTypeForDiagnostics(SecondMethod);
10351 auto SecondName = SecondMethod->getDeclName();
10352 if (FirstMethodType != SecondMethodType || FirstName != SecondName) {
10355 << FirstMethodType << FirstName;
10356 ODRDiagNote(SecondMethod->getLocation(),
10357 SecondMethod->getSourceRange(), MethodName)
10358 << SecondMethodType << SecondName;
10365 const bool SecondDeleted = SecondMethod->isDeletedAsWritten();
10366 if (FirstDeleted != SecondDeleted) {
10369 << FirstMethodType << FirstName << FirstDeleted;
10371 ODRDiagNote(SecondMethod->getLocation(),
10372 SecondMethod->getSourceRange(), MethodDeleted)
10373 << SecondMethodType << SecondName << SecondDeleted;
10379 const bool SecondDefaulted = SecondMethod->isExplicitlyDefaulted();
10380 if (FirstDefaulted != SecondDefaulted) {
10383 << FirstMethodType << FirstName << FirstDefaulted;
10385 ODRDiagNote(SecondMethod->getLocation(),
10386 SecondMethod->getSourceRange(), MethodDefaulted)
10387 << SecondMethodType << SecondName << SecondDefaulted;
10393 const bool SecondVirtual = SecondMethod->isVirtualAsWritten();
10394 const bool FirstPure = FirstMethod->
isPure();
10395 const bool SecondPure = SecondMethod->isPure();
10396 if ((FirstVirtual || SecondVirtual) &&
10397 (FirstVirtual != SecondVirtual || FirstPure != SecondPure)) {
10400 << FirstMethodType << FirstName << FirstPure << FirstVirtual;
10401 ODRDiagNote(SecondMethod->getLocation(),
10402 SecondMethod->getSourceRange(), MethodVirtual)
10403 << SecondMethodType << SecondName << SecondPure << SecondVirtual;
10412 const auto SecondStorage = SecondMethod->getStorageClass();
10413 const bool FirstStatic = FirstStorage ==
SC_Static;
10414 const bool SecondStatic = SecondStorage ==
SC_Static;
10415 if (FirstStatic != SecondStatic) {
10418 << FirstMethodType << FirstName << FirstStatic;
10419 ODRDiagNote(SecondMethod->getLocation(),
10420 SecondMethod->getSourceRange(), MethodStatic)
10421 << SecondMethodType << SecondName << SecondStatic;
10426 const bool FirstVolatile = FirstMethod->
isVolatile();
10427 const bool SecondVolatile = SecondMethod->isVolatile();
10428 if (FirstVolatile != SecondVolatile) {
10431 << FirstMethodType << FirstName << FirstVolatile;
10432 ODRDiagNote(SecondMethod->getLocation(),
10433 SecondMethod->getSourceRange(), MethodVolatile)
10434 << SecondMethodType << SecondName << SecondVolatile;
10439 const bool FirstConst = FirstMethod->
isConst();
10440 const bool SecondConst = SecondMethod->isConst();
10441 if (FirstConst != SecondConst) {
10444 << FirstMethodType << FirstName << FirstConst;
10445 ODRDiagNote(SecondMethod->getLocation(),
10446 SecondMethod->getSourceRange(), MethodConst)
10447 << SecondMethodType << SecondName << SecondConst;
10453 const bool SecondInline = SecondMethod->isInlineSpecified();
10454 if (FirstInline != SecondInline) {
10457 << FirstMethodType << FirstName << FirstInline;
10458 ODRDiagNote(SecondMethod->getLocation(),
10459 SecondMethod->getSourceRange(), MethodInline)
10460 << SecondMethodType << SecondName << SecondInline;
10465 const unsigned FirstNumParameters = FirstMethod->
param_size();
10466 const unsigned SecondNumParameters = SecondMethod->param_size();
10467 if (FirstNumParameters != SecondNumParameters) {
10470 << FirstMethodType << FirstName << FirstNumParameters;
10471 ODRDiagNote(SecondMethod->getLocation(),
10472 SecondMethod->getSourceRange(), MethodNumberParameters)
10473 << SecondMethodType << SecondName << SecondNumParameters;
10479 bool ParameterMismatch =
false;
10480 for (
unsigned I = 0; I < FirstNumParameters; ++I) {
10482 const ParmVarDecl *SecondParam = SecondMethod->getParamDecl(I);
10486 if (FirstParamType != SecondParamType &&
10487 ComputeQualTypeODRHash(FirstParamType) !=
10488 ComputeQualTypeODRHash(SecondParamType)) {
10493 << FirstMethodType << FirstName << (I + 1) << FirstParamType
10494 <<
true << ParamDecayedType->getOriginalType();
10498 << FirstMethodType << FirstName << (I + 1) << FirstParamType
10504 ODRDiagNote(SecondMethod->getLocation(),
10505 SecondMethod->getSourceRange(), MethodParameterType)
10506 << SecondMethodType << SecondName << (I + 1)
10507 << SecondParamType <<
true 10508 << ParamDecayedType->getOriginalType();
10510 ODRDiagNote(SecondMethod->getLocation(),
10511 SecondMethod->getSourceRange(), MethodParameterType)
10512 << SecondMethodType << SecondName << (I + 1)
10513 << SecondParamType <<
false;
10515 ParameterMismatch =
true;
10521 if (FirstParamName != SecondParamName) {
10524 << FirstMethodType << FirstName << (I + 1) << FirstParamName;
10525 ODRDiagNote(SecondMethod->getLocation(),
10526 SecondMethod->getSourceRange(), MethodParameterName)
10527 << SecondMethodType << SecondName << (I + 1) << SecondParamName;
10528 ParameterMismatch =
true;
10534 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
10537 MethodParameterSingleDefaultArgument)
10538 << FirstMethodType << FirstName << (I + 1)
10539 << (FirstInit ==
nullptr)
10541 ODRDiagNote(SecondMethod->getLocation(),
10542 SecondMethod->getSourceRange(),
10543 MethodParameterSingleDefaultArgument)
10544 << SecondMethodType << SecondName << (I + 1)
10545 << (SecondInit ==
nullptr)
10547 ParameterMismatch =
true;
10551 if (FirstInit && SecondInit &&
10552 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
10555 MethodParameterDifferentDefaultArgument)
10556 << FirstMethodType << FirstName << (I + 1)
10558 ODRDiagNote(SecondMethod->getLocation(),
10559 SecondMethod->getSourceRange(),
10560 MethodParameterDifferentDefaultArgument)
10561 << SecondMethodType << SecondName << (I + 1)
10563 ParameterMismatch =
true;
10569 if (ParameterMismatch) {
10574 const auto *FirstTemplateArgs =
10576 const auto *SecondTemplateArgs =
10577 SecondMethod->getTemplateSpecializationArgs();
10579 if ((FirstTemplateArgs && !SecondTemplateArgs) ||
10580 (!FirstTemplateArgs && SecondTemplateArgs)) {
10583 << FirstMethodType << FirstName << (FirstTemplateArgs !=
nullptr);
10584 ODRDiagNote(SecondMethod->getLocation(),
10585 SecondMethod->getSourceRange(), MethodNoTemplateArguments)
10586 << SecondMethodType << SecondName
10587 << (SecondTemplateArgs !=
nullptr);
10593 if (FirstTemplateArgs && SecondTemplateArgs) {
10595 auto ExpandTemplateArgumentList =
10600 ExpandedList.push_back(&TA);
10604 ExpandedList.push_back(&PackTA);
10607 return ExpandedList;
10610 ExpandTemplateArgumentList(FirstTemplateArgs);
10612 ExpandTemplateArgumentList(SecondTemplateArgs);
10614 if (FirstExpandedList.size() != SecondExpandedList.size()) {
10617 MethodDifferentNumberTemplateArguments)
10618 << FirstMethodType << FirstName
10619 << (
unsigned)FirstExpandedList.size();
10620 ODRDiagNote(SecondMethod->getLocation(),
10621 SecondMethod->getSourceRange(),
10622 MethodDifferentNumberTemplateArguments)
10623 << SecondMethodType << SecondName
10624 << (
unsigned)SecondExpandedList.size();
10630 bool TemplateArgumentMismatch =
false;
10631 for (
unsigned i = 0, e = FirstExpandedList.size(); i != e; ++i) {
10633 &SecondTA = *SecondExpandedList[i];
10634 if (ComputeTemplateArgumentODRHash(FirstTA) ==
10635 ComputeTemplateArgumentODRHash(SecondTA)) {
10641 MethodDifferentTemplateArgument)
10642 << FirstMethodType << FirstName << FirstTA << i + 1;
10643 ODRDiagNote(SecondMethod->getLocation(),
10644 SecondMethod->getSourceRange(),
10645 MethodDifferentTemplateArgument)
10646 << SecondMethodType << SecondName << SecondTA << i + 1;
10648 TemplateArgumentMismatch =
true;
10652 if (TemplateArgumentMismatch) {
10659 auto ComputeCXXMethodODRHash = [&Hash](
const CXXMethodDecl *D) {
10668 const bool HasFirstBody =
10669 ComputeCXXMethodODRHash(FirstMethod) != FirstMethod->
getODRHash();
10670 const bool HasSecondBody =
10671 ComputeCXXMethodODRHash(SecondMethod) != SecondMethod->getODRHash();
10673 if (HasFirstBody != HasSecondBody) {
10676 << FirstMethodType << FirstName << HasFirstBody;
10677 ODRDiagNote(SecondMethod->getLocation(),
10678 SecondMethod->getSourceRange(), MethodSingleBody)
10679 << SecondMethodType << SecondName << HasSecondBody;
10684 if (HasFirstBody && HasSecondBody) {
10687 << FirstMethodType << FirstName;
10688 ODRDiagNote(SecondMethod->getLocation(),
10689 SecondMethod->getSourceRange(), MethodDifferentBody)
10690 << SecondMethodType << SecondName;
10702 auto SecondName = SecondTD->getDeclName();
10703 if (FirstName != SecondName) {
10706 << (FirstDiffType == TypeAlias) << FirstName;
10707 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
10709 << (FirstDiffType == TypeAlias) << SecondName;
10715 QualType SecondType = SecondTD->getUnderlyingType();
10716 if (ComputeQualTypeODRHash(FirstType) !=
10717 ComputeQualTypeODRHash(SecondType)) {
10720 << (FirstDiffType == TypeAlias) << FirstName << FirstType;
10721 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
10723 << (FirstDiffType == TypeAlias) << SecondName << SecondType;
10730 VarDecl *FirstVD = cast<VarDecl>(FirstDecl);
10731 VarDecl *SecondVD = cast<VarDecl>(SecondDecl);
10733 auto SecondName = SecondVD->getDeclName();
10734 if (FirstName != SecondName) {
10738 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10746 QualType SecondType = SecondVD->getType();
10747 if (ComputeQualTypeODRHash(FirstType) !=
10748 ComputeQualTypeODRHash(SecondType)) {
10751 << FirstName << FirstType;
10752 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10754 << SecondName << SecondType;
10760 const Expr *SecondInit = SecondVD->getInit();
10761 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
10763 VarSingleInitializer)
10764 << FirstName << (FirstInit ==
nullptr)
10766 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10767 VarSingleInitializer)
10768 << SecondName << (SecondInit ==
nullptr)
10774 if (FirstInit && SecondInit &&
10775 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
10777 VarDifferentInitializer)
10779 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10780 VarDifferentInitializer)
10786 const bool FirstIsConstexpr = FirstVD->
isConstexpr();
10787 const bool SecondIsConstexpr = SecondVD->isConstexpr();
10788 if (FirstIsConstexpr != SecondIsConstexpr) {
10791 << FirstName << FirstIsConstexpr;
10792 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10794 << SecondName << SecondIsConstexpr;
10801 FriendDecl *FirstFriend = cast<FriendDecl>(FirstDecl);
10802 FriendDecl *SecondFriend = cast<FriendDecl>(SecondDecl);
10805 NamedDecl *SecondND = SecondFriend->getFriendDecl();
10810 if (FirstND && SecondND) {
10814 ODRDiagNote(SecondFriend->getFriendLoc(),
10815 SecondFriend->getSourceRange(), FriendFunction)
10822 if (FirstTSI && SecondTSI) {
10825 assert(ComputeQualTypeODRHash(FirstFriendType) !=
10826 ComputeQualTypeODRHash(SecondFriendType));
10829 << FirstFriendType;
10830 ODRDiagNote(SecondFriend->getFriendLoc(),
10831 SecondFriend->getSourceRange(), FriendType)
10832 << SecondFriendType;
10838 FriendTypeFunction)
10839 << (FirstTSI ==
nullptr);
10840 ODRDiagNote(SecondFriend->getFriendLoc(),
10841 SecondFriend->getSourceRange(), FriendTypeFunction)
10842 << (SecondTSI ==
nullptr);
10847 case FunctionTemplate: {
10849 cast<FunctionTemplateDecl>(FirstDecl);
10851 cast<FunctionTemplateDecl>(SecondDecl);
10856 SecondTemplate->getTemplateParameters();
10858 if (FirstTPL->size() != SecondTPL->
size()) {
10861 FunctionTemplateDifferentNumberParameters)
10862 << FirstTemplate << FirstTPL->size();
10863 ODRDiagNote(SecondTemplate->getLocation(),
10864 SecondTemplate->getSourceRange(),
10865 FunctionTemplateDifferentNumberParameters)
10866 << SecondTemplate << SecondTPL->
size();
10872 bool ParameterMismatch =
false;
10873 for (
unsigned i = 0, e = FirstTPL->size(); i != e; ++i) {
10874 NamedDecl *FirstParam = FirstTPL->getParam(i);
10879 TemplateTypeParameter,
10880 NonTypeTemplateParameter,
10881 TemplateTemplateParameter,
10886 llvm_unreachable(
"Unexpected template parameter type");
10887 case Decl::TemplateTypeParm:
10888 return TemplateTypeParameter;
10889 case Decl::NonTypeTemplateParm:
10890 return NonTypeTemplateParameter;
10891 case Decl::TemplateTemplateParm:
10892 return TemplateTemplateParameter;
10898 FunctionTemplateParameterDifferentKind)
10899 << FirstTemplate << (i + 1) << GetParamType(FirstParam);
10900 ODRDiagNote(SecondTemplate->getLocation(),
10901 SecondTemplate->getSourceRange(),
10902 FunctionTemplateParameterDifferentKind)
10903 << SecondTemplate << (i + 1) << GetParamType(SecondParam);
10905 ParameterMismatch =
true;
10912 FunctionTemplateParameterName)
10915 ODRDiagNote(SecondTemplate->getLocation(),
10916 SecondTemplate->getSourceRange(),
10917 FunctionTemplateParameterName)
10918 << SecondTemplate << (i + 1)
10920 ParameterMismatch =
true;
10924 if (isa<TemplateTypeParmDecl>(FirstParam) &&
10925 isa<TemplateTypeParmDecl>(SecondParam)) {
10927 cast<TemplateTypeParmDecl>(FirstParam);
10929 cast<TemplateTypeParmDecl>(SecondParam);
10930 bool HasFirstDefaultArgument =
10933 bool HasSecondDefaultArgument =
10934 SecondTTPD->hasDefaultArgument() &&
10935 !SecondTTPD->defaultArgumentWasInherited();
10936 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
10939 FunctionTemplateParameterSingleDefaultArgument)
10940 << FirstTemplate << (i + 1) << HasFirstDefaultArgument;
10941 ODRDiagNote(SecondTemplate->getLocation(),
10942 SecondTemplate->getSourceRange(),
10943 FunctionTemplateParameterSingleDefaultArgument)
10944 << SecondTemplate << (i + 1) << HasSecondDefaultArgument;
10945 ParameterMismatch =
true;
10949 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
10951 QualType SecondType = SecondTTPD->getDefaultArgument();
10952 if (ComputeQualTypeODRHash(FirstType) !=
10953 ComputeQualTypeODRHash(SecondType)) {
10956 FunctionTemplateParameterDifferentDefaultArgument)
10957 << FirstTemplate << (i + 1) << FirstType;
10958 ODRDiagNote(SecondTemplate->getLocation(),
10959 SecondTemplate->getSourceRange(),
10960 FunctionTemplateParameterDifferentDefaultArgument)
10961 << SecondTemplate << (i + 1) << SecondType;
10962 ParameterMismatch =
true;
10968 SecondTTPD->isParameterPack()) {
10971 FunctionTemplatePackParameter)
10973 ODRDiagNote(SecondTemplate->getLocation(),
10974 SecondTemplate->getSourceRange(),
10975 FunctionTemplatePackParameter)
10976 << SecondTemplate << (i + 1) << SecondTTPD->isParameterPack();
10977 ParameterMismatch =
true;
10982 if (isa<TemplateTemplateParmDecl>(FirstParam) &&
10983 isa<TemplateTemplateParmDecl>(SecondParam)) {
10985 cast<TemplateTemplateParmDecl>(FirstParam);
10987 cast<TemplateTemplateParmDecl>(SecondParam);
10992 SecondTTPD->getTemplateParameters();
10994 if (ComputeTemplateParameterListODRHash(FirstTPL) !=
10995 ComputeTemplateParameterListODRHash(SecondTPL)) {
10998 FunctionTemplateParameterDifferentType)
10999 << FirstTemplate << (i + 1);
11000 ODRDiagNote(SecondTemplate->getLocation(),
11001 SecondTemplate->getSourceRange(),
11002 FunctionTemplateParameterDifferentType)
11003 << SecondTemplate << (i + 1);
11004 ParameterMismatch =
true;
11008 bool HasFirstDefaultArgument =
11011 bool HasSecondDefaultArgument =
11012 SecondTTPD->hasDefaultArgument() &&
11013 !SecondTTPD->defaultArgumentWasInherited();
11014 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
11017 FunctionTemplateParameterSingleDefaultArgument)
11018 << FirstTemplate << (i + 1) << HasFirstDefaultArgument;
11019 ODRDiagNote(SecondTemplate->getLocation(),
11020 SecondTemplate->getSourceRange(),
11021 FunctionTemplateParameterSingleDefaultArgument)
11022 << SecondTemplate << (i + 1) << HasSecondDefaultArgument;
11023 ParameterMismatch =
true;
11027 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
11031 SecondTTPD->getDefaultArgument().getArgument();
11032 if (ComputeTemplateArgumentODRHash(FirstTA) !=
11033 ComputeTemplateArgumentODRHash(SecondTA)) {
11036 FunctionTemplateParameterDifferentDefaultArgument)
11037 << FirstTemplate << (i + 1) << FirstTA;
11038 ODRDiagNote(SecondTemplate->getLocation(),
11039 SecondTemplate->getSourceRange(),
11040 FunctionTemplateParameterDifferentDefaultArgument)
11041 << SecondTemplate << (i + 1) << SecondTA;
11042 ParameterMismatch =
true;
11048 SecondTTPD->isParameterPack()) {
11051 FunctionTemplatePackParameter)
11053 ODRDiagNote(SecondTemplate->getLocation(),
11054 SecondTemplate->getSourceRange(),
11055 FunctionTemplatePackParameter)
11056 << SecondTemplate << (i + 1) << SecondTTPD->isParameterPack();
11057 ParameterMismatch =
true;
11062 if (isa<NonTypeTemplateParmDecl>(FirstParam) &&
11063 isa<NonTypeTemplateParmDecl>(SecondParam)) {
11065 cast<NonTypeTemplateParmDecl>(FirstParam);
11067 cast<NonTypeTemplateParmDecl>(SecondParam);
11070 QualType SecondType = SecondNTTPD->getType();
11071 if (ComputeQualTypeODRHash(FirstType) !=
11072 ComputeQualTypeODRHash(SecondType)) {
11075 FunctionTemplateParameterDifferentType)
11076 << FirstTemplate << (i + 1);
11077 ODRDiagNote(SecondTemplate->getLocation(),
11078 SecondTemplate->getSourceRange(),
11079 FunctionTemplateParameterDifferentType)
11080 << SecondTemplate << (i + 1);
11081 ParameterMismatch =
true;
11085 bool HasFirstDefaultArgument =
11088 bool HasSecondDefaultArgument =
11089 SecondNTTPD->hasDefaultArgument() &&
11090 !SecondNTTPD->defaultArgumentWasInherited();
11091 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
11094 FunctionTemplateParameterSingleDefaultArgument)
11095 << FirstTemplate << (i + 1) << HasFirstDefaultArgument;
11096 ODRDiagNote(SecondTemplate->getLocation(),
11097 SecondTemplate->getSourceRange(),
11098 FunctionTemplateParameterSingleDefaultArgument)
11099 << SecondTemplate << (i + 1) << HasSecondDefaultArgument;
11100 ParameterMismatch =
true;
11104 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
11106 Expr *SecondDefaultArgument = SecondNTTPD->getDefaultArgument();
11107 if (ComputeODRHash(FirstDefaultArgument) !=
11108 ComputeODRHash(SecondDefaultArgument)) {
11111 FunctionTemplateParameterDifferentDefaultArgument)
11112 << FirstTemplate << (i + 1) << FirstDefaultArgument;
11113 ODRDiagNote(SecondTemplate->getLocation(),
11114 SecondTemplate->getSourceRange(),
11115 FunctionTemplateParameterDifferentDefaultArgument)
11116 << SecondTemplate << (i + 1) << SecondDefaultArgument;
11117 ParameterMismatch =
true;
11123 SecondNTTPD->isParameterPack()) {
11126 FunctionTemplatePackParameter)
11128 ODRDiagNote(SecondTemplate->getLocation(),
11129 SecondTemplate->getSourceRange(),
11130 FunctionTemplatePackParameter)
11131 << SecondTemplate << (i + 1)
11132 << SecondNTTPD->isParameterPack();
11133 ParameterMismatch =
true;
11139 if (ParameterMismatch) {
11152 diag::err_module_odr_violation_mismatch_decl_unknown)
11153 << FirstRecord << FirstModule.empty() << FirstModule << FirstDiffType
11156 diag::note_module_odr_violation_mismatch_decl_unknown)
11157 << SecondModule << FirstDiffType << SecondDecl->
getSourceRange();
11168 Diag(Merge.first->getLocation(),
11169 diag::err_module_odr_violation_different_instantiations)
11175 for (
auto &Merge : FunctionOdrMergeFailures) {
11176 enum ODRFunctionDifference {
11180 ParameterSingleDefaultArgument,
11181 ParameterDifferentDefaultArgument,
11186 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstFunction);
11188 bool Diagnosed =
false;
11189 for (
auto &SecondFunction : Merge.second) {
11191 if (FirstFunction == SecondFunction)
11194 std::string SecondModule =
11195 getOwningModuleNameForDiagnostic(SecondFunction);
11197 auto ODRDiagError = [FirstFunction, &FirstModule,
11199 ODRFunctionDifference DiffType) {
11200 return Diag(Loc, diag::err_module_odr_violation_function)
11201 << FirstFunction << FirstModule.empty() << FirstModule << Range
11206 ODRFunctionDifference DiffType) {
11207 return Diag(Loc, diag::note_module_odr_violation_function)
11208 << SecondModule << Range << DiffType;
11211 if (ComputeQualTypeODRHash(FirstFunction->
getReturnType()) !=
11212 ComputeQualTypeODRHash(SecondFunction->getReturnType())) {
11216 ODRDiagNote(SecondFunction->getReturnTypeSourceRange().getBegin(),
11217 SecondFunction->getReturnTypeSourceRange(), ReturnType)
11218 << SecondFunction->getReturnType();
11223 assert(FirstFunction->
param_size() == SecondFunction->param_size() &&
11224 "Merged functions with different number of parameters");
11226 auto ParamSize = FirstFunction->
param_size();
11227 bool ParameterMismatch =
false;
11228 for (
unsigned I = 0; I < ParamSize; ++I) {
11230 auto *SecondParam = SecondFunction->getParamDecl(I);
11232 assert(getContext().hasSameType(FirstParam->getType(),
11233 SecondParam->getType()) &&
11234 "Merged function has different parameter types.");
11236 if (FirstParam->getDeclName() != SecondParam->getDeclName()) {
11237 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11239 << I + 1 << FirstParam->getDeclName();
11240 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11242 << I + 1 << SecondParam->getDeclName();
11243 ParameterMismatch =
true;
11247 QualType FirstParamType = FirstParam->getType();
11248 QualType SecondParamType = SecondParam->getType();
11249 if (FirstParamType != SecondParamType &&
11250 ComputeQualTypeODRHash(FirstParamType) !=
11251 ComputeQualTypeODRHash(SecondParamType)) {
11254 ODRDiagError(FirstParam->getLocation(),
11255 FirstParam->getSourceRange(), ParameterType)
11256 << (I + 1) << FirstParamType <<
true 11257 << ParamDecayedType->getOriginalType();
11259 ODRDiagError(FirstParam->getLocation(),
11260 FirstParam->getSourceRange(), ParameterType)
11261 << (I + 1) << FirstParamType <<
false;
11266 ODRDiagNote(SecondParam->getLocation(),
11267 SecondParam->getSourceRange(), ParameterType)
11268 << (I + 1) << SecondParamType <<
true 11269 << ParamDecayedType->getOriginalType();
11271 ODRDiagNote(SecondParam->getLocation(),
11272 SecondParam->getSourceRange(), ParameterType)
11273 << (I + 1) << SecondParamType <<
false;
11275 ParameterMismatch =
true;
11279 const Expr *FirstInit = FirstParam->getInit();
11280 const Expr *SecondInit = SecondParam->getInit();
11281 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
11282 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11283 ParameterSingleDefaultArgument)
11284 << (I + 1) << (FirstInit ==
nullptr)
11286 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11287 ParameterSingleDefaultArgument)
11288 << (I + 1) << (SecondInit ==
nullptr)
11290 ParameterMismatch =
true;
11294 if (FirstInit && SecondInit &&
11295 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
11296 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11297 ParameterDifferentDefaultArgument)
11299 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11300 ParameterDifferentDefaultArgument)
11302 ParameterMismatch =
true;
11306 assert(ComputeSubDeclODRHash(FirstParam) ==
11307 ComputeSubDeclODRHash(SecondParam) &&
11308 "Undiagnosed parameter difference.");
11311 if (ParameterMismatch) {
11320 ODRDiagNote(SecondFunction->getLocation(),
11321 SecondFunction->getSourceRange(), FunctionBody);
11326 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
11330 for (
auto &Merge : EnumOdrMergeFailures) {
11331 enum ODREnumDifference {
11333 EnumTagKeywordMismatch,
11334 SingleSpecifiedType,
11335 DifferentSpecifiedTypes,
11336 DifferentNumberEnumConstants,
11338 EnumConstantSingleInitilizer,
11339 EnumConstantDifferentInitilizer,
11344 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
11347 EnumDecl *FirstEnum = Merge.first;
11348 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstEnum);
11352 auto PopulateHashes = [&ComputeSubDeclODRHash, FirstEnum](
11354 for (
auto *D :
Enum->decls()) {
11359 assert(isa<EnumConstantDecl>(D) &&
"Unexpected Decl kind");
11360 Hashes.emplace_back(cast<EnumConstantDecl>(D),
11361 ComputeSubDeclODRHash(D));
11364 DeclHashes FirstHashes;
11365 PopulateHashes(FirstHashes, FirstEnum);
11366 bool Diagnosed =
false;
11367 for (
auto &SecondEnum : Merge.second) {
11369 if (FirstEnum == SecondEnum)
11372 std::string SecondModule =
11373 getOwningModuleNameForDiagnostic(SecondEnum);
11375 auto ODRDiagError = [FirstEnum, &FirstModule,
11377 ODREnumDifference DiffType) {
11378 return Diag(Loc, diag::err_module_odr_violation_enum)
11379 << FirstEnum << FirstModule.empty() << FirstModule << Range
11384 ODREnumDifference DiffType) {
11385 return Diag(Loc, diag::note_module_odr_violation_enum)
11386 << SecondModule << Range << DiffType;
11389 if (FirstEnum->
isScoped() != SecondEnum->isScoped()) {
11393 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11395 << SecondEnum->isScoped();
11400 if (FirstEnum->
isScoped() && SecondEnum->isScoped()) {
11402 SecondEnum->isScopedUsingClassTag()) {
11404 EnumTagKeywordMismatch)
11406 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11407 EnumTagKeywordMismatch)
11408 << SecondEnum->isScopedUsingClassTag();
11419 SecondEnum->getIntegerTypeSourceInfo()
11420 ? SecondEnum->getIntegerTypeSourceInfo()->getType()
11422 if (FirstUnderlyingType.
isNull() != SecondUnderlyingType.
isNull()) {
11424 SingleSpecifiedType)
11425 << !FirstUnderlyingType.
isNull();
11426 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11427 SingleSpecifiedType)
11428 << !SecondUnderlyingType.
isNull();
11433 if (!FirstUnderlyingType.
isNull() && !SecondUnderlyingType.
isNull()) {
11434 if (ComputeQualTypeODRHash(FirstUnderlyingType) !=
11435 ComputeQualTypeODRHash(SecondUnderlyingType)) {
11437 DifferentSpecifiedTypes)
11438 << FirstUnderlyingType;
11439 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11440 DifferentSpecifiedTypes)
11441 << SecondUnderlyingType;
11447 DeclHashes SecondHashes;
11448 PopulateHashes(SecondHashes, SecondEnum);
11450 if (FirstHashes.size() != SecondHashes.size()) {
11452 DifferentNumberEnumConstants)
11453 << (
int)FirstHashes.size();
11454 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11455 DifferentNumberEnumConstants)
11456 << (
int)SecondHashes.size();
11461 for (
unsigned I = 0; I < FirstHashes.size(); ++I) {
11462 if (FirstHashes[I].second == SecondHashes[I].second)
11472 << I + 1 << FirstEnumConstant;
11475 << I + 1 << SecondEnumConstant;
11482 if (!FirstInit && !SecondInit)
11485 if (!FirstInit || !SecondInit) {
11488 EnumConstantSingleInitilizer)
11489 << I + 1 << FirstEnumConstant << (FirstInit !=
nullptr);
11492 EnumConstantSingleInitilizer)
11493 << I + 1 << SecondEnumConstant << (SecondInit !=
nullptr);
11498 if (ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
11501 EnumConstantDifferentInitilizer)
11502 << I + 1 << FirstEnumConstant;
11505 EnumConstantDifferentInitilizer)
11506 << I + 1 << SecondEnumConstant;
11514 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
11519 if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get())
11520 ReadTimer->startTimer();
11524 assert(NumCurrentElementsDeserializing &&
11525 "FinishedDeserializing not paired with StartedDeserializing");
11526 if (NumCurrentElementsDeserializing == 1) {
11529 finishPendingActions();
11531 --NumCurrentElementsDeserializing;
11533 if (NumCurrentElementsDeserializing == 0) {
11535 while (!PendingExceptionSpecUpdates.empty()) {
11536 auto Updates = std::move(PendingExceptionSpecUpdates);
11537 PendingExceptionSpecUpdates.clear();
11539 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
11541 auto ESI = FPT->getExtProtoInfo().ExceptionSpec;
11542 if (
auto *Listener = getContext().getASTMutationListener())
11543 Listener->ResolvedExceptionSpec(cast<FunctionDecl>(
Update.second));
11544 for (
auto *Redecl :
Update.second->redecls())
11545 getContext().adjustExceptionSpec(cast<FunctionDecl>(Redecl), ESI);
11550 ReadTimer->stopTimer();
11552 diagnoseOdrViolations();
11557 PassInterestingDeclsToConsumer();
11564 auto It = PendingFakeLookupResults.find(II);
11565 if (It != PendingFakeLookupResults.end()) {
11566 for (
auto *ND : It->second)
11567 SemaObj->IdResolver.RemoveDecl(ND);
11571 It->second.clear();
11575 if (SemaObj->IdResolver.tryAddTopLevelDecl(D, Name) && SemaObj->TUScope) {
11576 SemaObj->TUScope->AddDecl(D);
11577 }
else if (SemaObj->TUScope) {
11581 if (std::find(SemaObj->IdResolver.begin(Name),
11582 SemaObj->IdResolver.end(), D) != SemaObj->IdResolver.end())
11583 SemaObj->TUScope->AddDecl(D);
11589 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
11590 StringRef isysroot,
bool DisableValidation,
11591 bool AllowASTWithCompilerErrors,
11592 bool AllowConfigurationMismatch,
bool ValidateSystemInputs,
11593 bool UseGlobalIndex,
11594 std::unique_ptr<llvm::Timer> ReadTimer)
11595 : Listener(DisableValidation
11598 SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()),
11599 PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()), PP(PP),
11600 ContextObj(Context),
11601 ModuleMgr(PP.getFileManager(), PP.getPCMCache(), PCHContainerRdr,
11602 PP.getHeaderSearchInfo()),
11603 PCMCache(PP.getPCMCache()), DummyIdResolver(PP),
11604 ReadTimer(
std::move(ReadTimer)), isysroot(isysroot),
11605 DisableValidation(DisableValidation),
11606 AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
11607 AllowConfigurationMismatch(AllowConfigurationMismatch),
11608 ValidateSystemInputs(ValidateSystemInputs),
11609 UseGlobalIndex(UseGlobalIndex), CurrSwitchCaseStmts(&SwitchCaseStmts) {
11612 for (
const auto &Ext : Extensions) {
11613 auto BlockName = Ext->getExtensionMetadata().BlockName;
11614 auto Known = ModuleFileExtensions.find(BlockName);
11615 if (Known != ModuleFileExtensions.end()) {
11616 Diags.
Report(diag::warn_duplicate_module_file_extension)
11621 ModuleFileExtensions.insert({BlockName, Ext});
11626 if (OwnsDeserializationListener)
11627 delete DeserializationListener;
11631 return SemaObj ? SemaObj->
IdResolver : DummyIdResolver;
11635 unsigned AbbrevID) {
11638 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.
CanQualType SatShortAccumTy
void setSourceOrder(int Pos)
Set the source order of this initializer.
CanQualType SatUnsignedLongFractTy
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.
The 'unsigned _Accum' type.
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)
Represents 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.
The 'unsigned short _Fract' 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.
unsigned BasePreprocessedSkippedRangeID
Base ID for preprocessed skipped ranges local to this module.
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.
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...
CanQualType UnsignedLongFractTy
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...
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
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.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
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.
An instance of this object exists for each enum constant that is defined.
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...
Source range of a skipped preprocessor region.
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.
QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc, VectorType::VectorKind VecKind) const
Return the unique reference to the type for a dependently sized vector of the specified element type...
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.
CanQualType SatUnsignedAccumTy
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.
Represent a C++ namespace.
Wrapper for source info for typedefs.
static void markIdentifierFromAST(ASTReader &Reader, IdentifierInfo &II)
NamedDecl * getParam(unsigned Idx)
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.
The 'short _Fract' type.
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...
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
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)
Represents 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...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
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 AddTemplateArgument(TemplateArgument TA)
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.
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.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
std::string getName(ArrayRef< StringRef > Parts) const
Get the platform-specific name separator.
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. ...
bool DeclIsFromPCHWithObjectFile(const Decl *D) override
Determine whether D comes from a PCH which was built with a corresponding object file.
IdentifierInfo * getIdentifier() const
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.
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
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.
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
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)
CanQualType UnsignedFractTy
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
Represents a member of a struct/union/class.
bool isCPlusPlusOperatorKeyword() const
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
The '_Sat unsigned _Accum' type.
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.
The 'unsigned long _Fract' type.
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
SanitizerMask Mask
Bitmask of enabled sanitizers.
The 'long _Fract' type.
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.
void AddTemplateParameterList(const TemplateParameterList *TPL)
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)
An AttributedType record.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
llvm::OnDiskChainedHashTable< HeaderFileInfoTrait > HeaderFileInfoLookupTable
The on-disk hash table used for known header files.
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...
The 'short _Accum' type.
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.
The 'long _Accum' type.
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
A new-allocated array of size NumTemplParamLists, containing pointers to the "outer" template paramet...
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.
bool PCHHasObjectFile
Whether the PCH has a corresponding object file.
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)
CanQualType SatShortFractTy
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.
The 'unsigned short _Accum' type.
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
void AddFunctionDecl(const FunctionDecl *Function, bool SkipBody=false)
void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, const RecordData &Record, unsigned &Idx)
CanQualType SatUnsignedShortAccumTy
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.
unsigned NumPreprocessedSkippedRanges
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.
const Expr * getInitExpr() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
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.
The '_Sat short _Fract' type.
The 'unsigned long _Accum' type.
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.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
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.
The '_Sat unsigned long _Fract' type.
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
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 table of skipped ranges within the preprocessing record.
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.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
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
CanQualType UnsignedAccumTy
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.
CanQualType UnsignedShortFractTy
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.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
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.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
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.
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
The '_Sat long _Fract' type.
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.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
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)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
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.
CanQualType SatLongAccumTy
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)
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
Record code for the identifier table.
The '_Sat unsigned long _Accum' type.
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.
The '_Sat short _Accum' type.
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.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
Record code for the set of source location entries that need to be preloaded by the AST reader...
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
The control block was read successfully.
The list of delegating constructor declarations.
Information about a FileID, basically just the logical file that it represents and include stack info...
The C++ 'char8_t' type.
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.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
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
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.
The '_Sat unsigned _Fract' type.
bool isParameterPack() const
Returns whether this is a parameter pack.
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
CanQualType UnsignedLongAccumTy
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.
Represents the declaration of a struct/union/class/enum.
PredefinedTypeIDs
Predefined type IDs.
SourceLocation getLocStart() const LLVM_READONLY
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.
A dependentSizedVectorType record.
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.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isPoisoned() const
Return true if this token has been poisoned.
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
CanQualType SatUnsignedLongAccumTy
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings startin...
The '_Sat _Accum' type.
unsigned LocalNumDecls
The number of declarations in this AST file.
void setUpgradedFromWarning(bool Value)
unsigned NumFileSortedDecls
SourceRange ReadSkippedRange(unsigned Index) override
Read a preallocated skipped range from the external source.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
The internal 'instancetype' typedef.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
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)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
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.
CanQualType SatLongFractTy
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...
unsigned getODRHash()
Returns ODRHash of the function.
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...
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
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.
CanQualType SatUnsignedFractTy
std::string PCHThroughHeader
If non-empty, the filename used in an #include directive in the primary source file (or command-line ...
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.
CanQualType SatUnsignedShortFractTy
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)
SourceLocation getBegin() const
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
const PPSkippedRange * PreprocessedSkippedRangeOffsets
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.
const TemplateArgument & getArgument() const
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...
The '_Accum' type.
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 '_Fract' type.
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.
CanQualType UnsignedShortAccumTy
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...
The '_Sat unsigned short _Accum' type.
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.
Represents a field injected from an anonymous union/struct into the parent scope. ...
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.
The '_Sat long _Accum' type.
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.
llvm::OnDiskChainedHashTable< ASTSelectorLookupTrait > ASTSelectorLookupTable
The on-disk hash table used for the global method pool.
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.
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
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.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
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.
unsigned ModuleMapIsPrivate
Whether this module came from a "private" module map, found next to a regular (public) module map...
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.
void addLinkAsDependency(Module *Mod)
Make module to use export_as as the link dependency name if enough information is available or add it...
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.
The 'unsigned _Fract' 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.
ContinuousRangeMap< unsigned, int, 2 > SLocRemap
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
SourceLocation getEnd() const
The block containing the submodule structure.
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
void setTypeArgsRAngleLoc(SourceLocation Loc)
void ReadTypeLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx, TypeLoc TL)
Raad the type locations for the given TInfo.
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.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
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)
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Keeps track of options that affect how file operations are performed.
llvm::OnDiskIterableChainedHashTable< ASTIdentifierLookupTrait > ASTIdentifierLookupTable
The on-disk hash table used to contain information about all of the identifiers in the program...
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.
A template argument list.
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 a computed noexcept specification.
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
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)
void resolveLinkAsDependencies(Module *Mod)
Use PendingLinkAsModule information to mark top level link names that are going to be replaced by exp...
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)
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)
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
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
__DEVICE__ int max(int __a, int __b)
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.
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...
static bool isWhitelistedDecl(const Decl *D, const DeclContext *Parent)
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...
QualType getDefaultArgument() const
Retrieve the default argument, if any.
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
This represents a decl that may have 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...
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)
StringRef internal_key_type
Wrapper for source info for block pointers.
void ReadModuleName(StringRef ModuleName) override
The '_Sat unsigned short _Fract' type.
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.
Declaration of a template function.
Record code for an update to the TU's lexically contained declarations.
A class which abstracts out some details necessary for making a call.
The '_Sat _Fract' type.
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.
bool isDeletedAsWritten() const
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.