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);
400 llvm::sort(ReadFeatures);
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);
3788 getContext().mergeDefinitionIntoModule(
3791 PendingMergedDefinitionsToDeduplicate.insert(Def);
3800 if (TriedLoadingGlobalIndex || !UseGlobalIndex ||
3801 !PP.getLangOpts().Modules)
3805 TriedLoadingGlobalIndex =
true;
3806 StringRef ModuleCachePath
3807 = getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
3808 std::pair<GlobalModuleIndex *, GlobalModuleIndex::ErrorCode> Result
3813 GlobalIndex.reset(Result.first);
3814 ModuleMgr.setGlobalIndex(GlobalIndex.get());
3819 return PP.getLangOpts().Modules && UseGlobalIndex &&
3820 !hasGlobalIndex() && TriedLoadingGlobalIndex;
3827 llvm::raw_fd_ostream OS(TimestampFilename, EC, llvm::sys::fs::F_Text);
3830 OS <<
"Timestamp file\n";
3840 llvm::BitstreamEntry Entry = Cursor.advance();
3841 switch (Entry.Kind) {
3843 case llvm::BitstreamEntry::EndBlock:
3846 case llvm::BitstreamEntry::Record:
3848 Cursor.skipRecord(Entry.ID);
3851 case llvm::BitstreamEntry::SubBlock:
3852 if (Entry.ID == BlockID) {
3853 if (Cursor.EnterSubBlock(BlockID))
3859 if (Cursor.SkipBlock())
3868 unsigned ClientLoadCapabilities,
3871 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
3877 unsigned PreviousGeneration = 0;
3879 PreviousGeneration = incrementGeneration(*ContextObj);
3881 unsigned NumModules = ModuleMgr.size();
3884 ReadASTCore(FileName, Type, ImportLoc,
3885 nullptr, Loaded, 0, 0,
3890 case VersionMismatch:
3891 case ConfigurationMismatch:
3893 llvm::SmallPtrSet<ModuleFile *, 4> LoadedSet;
3894 for (
const ImportedModule &IM : Loaded)
3895 LoadedSet.insert(IM.Mod);
3897 ModuleMgr.removeModules(ModuleMgr.begin() + NumModules, LoadedSet,
3898 PP.getLangOpts().Modules
3899 ? &PP.getHeaderSearchInfo().getModuleMap()
3904 GlobalIndex.reset();
3905 ModuleMgr.setGlobalIndex(
nullptr);
3916 MEnd = Loaded.end();
3921 if (
ASTReadResult Result = ReadASTBlock(F, ClientLoadCapabilities))
3943 SourceMgr.getLoadedSLocEntryByID(Index);
3956 const unsigned char *Data =
reinterpret_cast<const unsigned char *
>(
3961 auto Key = Trait.
ReadKey(Data, KeyDataLen.first);
3962 auto &II = PP.getIdentifierTable().getOwn(Key);
3963 II.setOutOfDate(
true);
3971 SetIdentifierInfo(
ID, &II);
3978 MEnd = Loaded.end();
3982 ModuleMgr.moduleFileAccepted(&F);
3994 if (!PP.getLangOpts().CPlusPlus ||
4005 IdEnd = PP.getIdentifierTable().end();
4007 Id->second->setOutOfDate(
true);
4010 for (
auto Sel : SelectorGeneration)
4011 SelectorOutOfDate[Sel.first] =
true;
4014 for (
unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I) {
4015 UnresolvedModuleRef &Unresolved = UnresolvedModuleRefs[I];
4016 SubmoduleID GlobalID = getGlobalSubmoduleID(*Unresolved.File,Unresolved.ID);
4017 Module *ResolvedMod = getSubmodule(GlobalID);
4019 switch (Unresolved.Kind) {
4020 case UnresolvedModuleRef::Conflict:
4023 Conflict.
Other = ResolvedMod;
4024 Conflict.
Message = Unresolved.String.str();
4025 Unresolved.Mod->Conflicts.push_back(Conflict);
4029 case UnresolvedModuleRef::Import:
4031 Unresolved.Mod->Imports.insert(ResolvedMod);
4034 case UnresolvedModuleRef::Export:
4035 if (ResolvedMod || Unresolved.IsWildcard)
4036 Unresolved.Mod->Exports.push_back(
4041 UnresolvedModuleRefs.clear();
4044 Imported->append(ImportedModules.begin(),
4045 ImportedModules.end());
4052 InitializeContext();
4057 if (DeserializationListener)
4058 DeserializationListener->ReaderInitialized(
this);
4060 ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule();
4075 for (
unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++I) {
4076 loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
4077 ObjCClassesLoaded[I],
4078 PreviousGeneration);
4082 if (PP.getHeaderSearchInfo()
4083 .getHeaderSearchOpts()
4084 .ModulesValidateOncePerBuildSession) {
4089 for (
unsigned I = 0, N = Loaded.size(); I != N; ++I) {
4090 ImportedModule &M = Loaded[I];
4104 return Stream.canSkipToPos(4) &&
4105 Stream.Read(8) ==
'C' &&
4106 Stream.Read(8) ==
'P' &&
4107 Stream.Read(8) ==
'C' &&
4108 Stream.Read(8) ==
'H';
4123 llvm_unreachable(
"unknown module kind");
4127 ASTReader::ReadASTCore(StringRef FileName,
4132 off_t ExpectedSize, time_t ExpectedModTime,
4134 unsigned ClientLoadCapabilities) {
4136 std::string ErrorStr;
4138 = ModuleMgr.addModule(FileName,
Type, ImportLoc, ImportedBy,
4139 getGeneration(), ExpectedSize, ExpectedModTime,
4140 ExpectedSignature, readASTFileSignature,
4143 switch (AddResult) {
4154 if (ClientLoadCapabilities & ARR_Missing)
4159 << FileName << !ErrorStr.empty()
4166 if (ClientLoadCapabilities & ARR_OutOfDate)
4171 << FileName << !ErrorStr.empty()
4176 assert(M &&
"Missing module file");
4179 BitstreamCursor &Stream = F.
Stream;
4180 Stream = BitstreamCursor(PCHContainerRdr.ExtractPCH(*F.
Buffer));
4191 bool HaveReadControlBlock =
false;
4193 llvm::BitstreamEntry Entry = Stream.advance();
4195 switch (Entry.Kind) {
4197 case llvm::BitstreamEntry::Record:
4198 case llvm::BitstreamEntry::EndBlock:
4199 Error(
"invalid record at top-level of AST file");
4202 case llvm::BitstreamEntry::SubBlock:
4208 HaveReadControlBlock =
true;
4209 switch (ReadControlBlock(F, Loaded, ImportedBy, ClientLoadCapabilities)) {
4219 if (Result != OutOfDate ||
4220 (ClientLoadCapabilities & ARR_OutOfDate) == 0)
4221 Diag(diag::err_module_file_not_module) << FileName;
4226 case Failure:
return Failure;
4227 case Missing:
return Missing;
4228 case OutOfDate:
return OutOfDate;
4229 case VersionMismatch:
return VersionMismatch;
4230 case ConfigurationMismatch:
return ConfigurationMismatch;
4231 case HadErrors:
return HadErrors;
4236 if (!HaveReadControlBlock) {
4237 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
4238 Diag(diag::err_pch_version_too_old);
4239 return VersionMismatch;
4243 Loaded.push_back(ImportedModule(M, ImportedBy, ImportLoc));
4249 Error(
"malformed block record in AST file");
4253 if (Stream.SkipBlock()) {
4254 Error(
"malformed block record in AST file");
4265 ASTReader::readUnhashedControlBlock(
ModuleFile &F,
bool WasImportedBy,
4266 unsigned ClientLoadCapabilities) {
4268 PP.getHeaderSearchInfo().getHeaderSearchOpts();
4269 bool AllowCompatibleConfigurationMismatch =
4272 ASTReadResult Result = readUnhashedControlBlockImpl(
4273 &F, F.
Data, ClientLoadCapabilities, AllowCompatibleConfigurationMismatch,
4279 if (DisableValidation || WasImportedBy ||
4280 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
4283 if (Result == Failure) {
4284 Error(
"malformed block record in AST file");
4307 if (PCMCache.isBufferFinal(F.
FileName)) {
4308 Diag(diag::warn_module_system_bit_conflict) << F.
FileName;
4317 ModuleFile *F, llvm::StringRef StreamData,
unsigned ClientLoadCapabilities,
4319 bool ValidateDiagnosticOptions) {
4321 BitstreamCursor Stream(StreamData);
4333 ASTReadResult Result = Success;
4335 llvm::BitstreamEntry Entry = Stream.advance();
4337 switch (Entry.Kind) {
4339 case llvm::BitstreamEntry::SubBlock:
4342 case llvm::BitstreamEntry::EndBlock:
4345 case llvm::BitstreamEntry::Record:
4356 std::copy(Record.begin(), Record.end(), F->
Signature.data());
4359 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
4360 if (Listener && ValidateDiagnosticOptions &&
4361 !AllowCompatibleConfigurationMismatch &&
4362 ParseDiagnosticOptions(Record, Complain, *Listener))
4373 Record.begin(), Record.end());
4384 if (Record.size() < 4)
return true;
4389 unsigned BlockNameLen = Record[2];
4390 unsigned UserInfoLen = Record[3];
4392 if (BlockNameLen + UserInfoLen > Blob.size())
return true;
4394 Metadata.
BlockName = std::string(Blob.data(), Blob.data() + BlockNameLen);
4395 Metadata.
UserInfo = std::string(Blob.data() + BlockNameLen,
4396 Blob.data() + BlockNameLen + UserInfoLen);
4401 BitstreamCursor &Stream = F.
Stream;
4405 llvm::BitstreamEntry Entry = Stream.advance();
4406 switch (Entry.Kind) {
4407 case llvm::BitstreamEntry::SubBlock:
4408 if (Stream.SkipBlock())
4413 case llvm::BitstreamEntry::EndBlock:
4419 case llvm::BitstreamEntry::Record:
4425 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4433 auto Known = ModuleFileExtensions.find(Metadata.
BlockName);
4434 if (Known == ModuleFileExtensions.end())
break;
4437 if (
auto Reader = Known->second->createExtensionReader(Metadata, *
this,
4451 assert(ContextObj &&
"no context to initialize");
4455 if (DeserializationListener)
4465 if (!Context.CFConstantStringTypeDecl)
4472 Error(
"FILE type is NULL");
4476 if (!Context.FILEDecl) {
4482 Error(
"Invalid FILE type in AST file");
4491 QualType Jmp_bufType = GetType(Jmp_buf);
4492 if (Jmp_bufType.
isNull()) {
4493 Error(
"jmp_buf type is NULL");
4497 if (!Context.jmp_bufDecl) {
4503 Error(
"Invalid jmp_buf type in AST file");
4512 QualType Sigjmp_bufType = GetType(Sigjmp_buf);
4513 if (Sigjmp_bufType.
isNull()) {
4514 Error(
"sigjmp_buf type is NULL");
4518 if (!Context.sigjmp_bufDecl) {
4523 assert(Tag &&
"Invalid sigjmp_buf type in AST file");
4529 if (
unsigned ObjCIdRedef
4531 if (Context.ObjCIdRedefinitionType.
isNull())
4532 Context.ObjCIdRedefinitionType = GetType(ObjCIdRedef);
4535 if (
unsigned ObjCClassRedef
4537 if (Context.ObjCClassRedefinitionType.
isNull())
4538 Context.ObjCClassRedefinitionType = GetType(ObjCClassRedef);
4541 if (
unsigned ObjCSelRedef
4543 if (Context.ObjCSelRedefinitionType.
isNull())
4544 Context.ObjCSelRedefinitionType = GetType(ObjCSelRedef);
4548 QualType Ucontext_tType = GetType(Ucontext_t);
4549 if (Ucontext_tType.
isNull()) {
4550 Error(
"ucontext_t type is NULL");
4554 if (!Context.ucontext_tDecl) {
4559 assert(Tag &&
"Invalid ucontext_t type in AST file");
4569 if (!CUDASpecialDeclRefs.empty()) {
4570 assert(CUDASpecialDeclRefs.size() == 1 &&
"More decl refs than expected!");
4572 cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
4577 for (
auto &Import : ImportedModules) {
4578 if (
Module *Imported = getSubmodule(Import.ID)) {
4581 if (Import.ImportLoc.isValid())
4582 PP.makeModuleVisible(Imported, Import.ImportLoc);
4586 ImportedModules.clear();
4596 BitstreamCursor Stream(PCH);
4607 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
4608 if (Entry.Kind != llvm::BitstreamEntry::Record)
4613 if (
SIGNATURE == Stream.readRecord(Entry.ID, Record, &Blob))
4614 return {{{(uint32_t)Record[0], (uint32_t)Record[1], (uint32_t)Record[2],
4615 (uint32_t)Record[3], (uint32_t)Record[4]}}};
4623 const std::string &ASTFileName,
FileManager &FileMgr,
4628 Diags.
Report(diag::err_fe_unable_to_read_pch_file)
4629 << ASTFileName << Buffer.getError().message();
4630 return std::string();
4634 BitstreamCursor Stream(PCHContainerRdr.
ExtractPCH(**Buffer));
4638 Diags.
Report(diag::err_fe_not_a_pch_file) << ASTFileName;
4639 return std::string();
4644 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
4645 return std::string();
4651 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
4652 if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
4653 return std::string();
4655 if (Entry.Kind != llvm::BitstreamEntry::Record) {
4656 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
4657 return std::string();
4662 if (Stream.readRecord(Entry.ID, Record, &Blob) ==
ORIGINAL_FILE)
4673 std::string ExistingModuleCachePath;
4677 SimplePCHValidator(
const LangOptions &ExistingLangOpts,
4680 StringRef ExistingModuleCachePath,
4682 : ExistingLangOpts(ExistingLangOpts),
4683 ExistingTargetOpts(ExistingTargetOpts),
4684 ExistingPPOpts(ExistingPPOpts),
4685 ExistingModuleCachePath(ExistingModuleCachePath),
4688 bool ReadLanguageOptions(
const LangOptions &LangOpts,
bool Complain,
4689 bool AllowCompatibleDifferences)
override {
4691 AllowCompatibleDifferences);
4694 bool ReadTargetOptions(
const TargetOptions &TargetOpts,
bool Complain,
4695 bool AllowCompatibleDifferences)
override {
4697 AllowCompatibleDifferences);
4701 StringRef SpecificModuleCachePath,
4702 bool Complain)
override {
4704 ExistingModuleCachePath,
4705 nullptr, ExistingLangOpts);
4710 std::string &SuggestedPredefines)
override {
4712 SuggestedPredefines, ExistingLangOpts);
4721 bool FindModuleFileExtensions,
4732 StringRef Bytes = PCHContainerRdr.
ExtractPCH(**Buffer);
4733 BitstreamCursor Stream(Bytes);
4746 BitstreamCursor InputFilesCursor;
4749 std::string ModuleDir;
4750 bool DoneWithControlBlock =
false;
4751 while (!DoneWithControlBlock) {
4752 llvm::BitstreamEntry Entry = Stream.advance();
4754 switch (Entry.Kind) {
4755 case llvm::BitstreamEntry::SubBlock: {
4758 std::string IgnoredSuggestedPredefines;
4759 if (ReadOptionsBlock(Stream, ARR_ConfigurationMismatch | ARR_OutOfDate,
4761 Listener, IgnoredSuggestedPredefines) != Success)
4767 InputFilesCursor = Stream;
4768 if (Stream.SkipBlock() ||
4775 if (Stream.SkipBlock())
4783 case llvm::BitstreamEntry::EndBlock:
4784 DoneWithControlBlock =
true;
4790 case llvm::BitstreamEntry::Record:
4794 if (DoneWithControlBlock)
break;
4798 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4814 auto Path = ReadString(Record, Idx);
4815 ResolveImportedPath(Path, ModuleDir);
4820 if (!NeedsInputFiles)
4823 unsigned NumInputFiles = Record[0];
4824 unsigned NumUserFiles = Record[1];
4825 const llvm::support::unaligned_uint64_t *InputFileOffs =
4826 (
const llvm::support::unaligned_uint64_t *)Blob.data();
4827 for (
unsigned I = 0; I != NumInputFiles; ++I) {
4829 bool isSystemFile = I >= NumUserFiles;
4831 if (isSystemFile && !NeedsSystemInputFiles)
4834 BitstreamCursor &
Cursor = InputFilesCursor;
4836 Cursor.JumpToBit(InputFileOffs[I]);
4838 unsigned Code = Cursor.ReadCode();
4841 bool shouldContinue =
false;
4844 bool Overridden =
static_cast<bool>(Record[3]);
4845 std::string Filename = Blob;
4846 ResolveImportedPath(Filename, ModuleDir);
4848 Filename, isSystemFile, Overridden,
false);
4851 if (!shouldContinue)
4861 unsigned Idx = 0, N = Record.size();
4865 std::string ModuleName = ReadString(Record, Idx);
4866 std::string Filename = ReadString(Record, Idx);
4867 ResolveImportedPath(Filename, ModuleDir);
4880 if (FindModuleFileExtensions) {
4881 BitstreamCursor SavedStream = Stream;
4883 bool DoneWithExtensionBlock =
false;
4884 while (!DoneWithExtensionBlock) {
4885 llvm::BitstreamEntry Entry = Stream.advance();
4887 switch (Entry.Kind) {
4888 case llvm::BitstreamEntry::SubBlock:
4889 if (Stream.SkipBlock())
4894 case llvm::BitstreamEntry::EndBlock:
4895 DoneWithExtensionBlock =
true;
4901 case llvm::BitstreamEntry::Record:
4907 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4920 Stream = SavedStream;
4924 if (readUnhashedControlBlockImpl(
4925 nullptr, Bytes, ARR_ConfigurationMismatch | ARR_OutOfDate,
4927 ValidateDiagnosticOptions) != Success)
4938 StringRef ExistingModuleCachePath) {
4939 SimplePCHValidator validator(LangOpts, TargetOpts, PPOpts,
4940 ExistingModuleCachePath, FileMgr);
4941 return !readASTFileControlBlock(Filename, FileMgr, PCHContainerRdr,
4948 ASTReader::ReadSubmoduleBlock(
ModuleFile &F,
unsigned ClientLoadCapabilities) {
4951 Error(
"malformed submodule block record in AST file");
4955 ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
4957 Module *CurrentModule =
nullptr;
4960 llvm::BitstreamEntry Entry = F.
Stream.advanceSkippingSubblocks();
4962 switch (Entry.Kind) {
4963 case llvm::BitstreamEntry::SubBlock:
4965 Error(
"malformed block record in AST file");
4967 case llvm::BitstreamEntry::EndBlock:
4969 case llvm::BitstreamEntry::Record:
4977 auto Kind = F.
Stream.readRecord(Entry.ID, Record, &Blob);
4980 Error(
"submodule metadata record should be at beginning of block");
4996 if (Record.size() < 12) {
4997 Error(
"malformed module definition");
5001 StringRef Name = Blob;
5003 SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);
5006 bool IsFramework = Record[Idx++];
5007 bool IsExplicit = Record[Idx++];
5008 bool IsSystem = Record[Idx++];
5009 bool IsExternC = Record[Idx++];
5010 bool InferSubmodules = Record[Idx++];
5011 bool InferExplicitSubmodules = Record[Idx++];
5012 bool InferExportWildcard = Record[Idx++];
5013 bool ConfigMacrosExhaustive = Record[Idx++];
5014 bool ModuleMapIsPrivate = Record[Idx++];
5016 Module *ParentModule =
nullptr;
5018 ParentModule = getSubmodule(Parent);
5030 if (GlobalIndex >= SubmodulesLoaded.size() ||
5031 SubmodulesLoaded[GlobalIndex]) {
5032 Error(
"too many submodules");
5036 if (!ParentModule) {
5039 if (!PP.getPreprocessorOpts().DisablePCHValidation &&
5040 CurFile != F.
File) {
5041 if (!Diags.isDiagnosticInFlight()) {
5042 Diag(diag::err_module_file_conflict)
5044 << CurFile->getName()
5055 CurrentModule->
Kind = Kind;
5065 if (DeserializationListener)
5066 DeserializationListener->ModuleRead(GlobalID, CurrentModule);
5068 SubmodulesLoaded[GlobalIndex] = CurrentModule;
5091 ResolveImportedPath(F, Filename);
5092 if (
auto *Umbrella = PP.getFileManager().getFile(Filename)) {
5096 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
5097 Error(
"mismatched umbrella headers in submodule");
5123 std::string Dirname = Blob;
5124 ResolveImportedPath(F, Dirname);
5125 if (
auto *Umbrella = PP.getFileManager().getDirectory(Dirname)) {
5129 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
5130 Error(
"mismatched umbrella directories in submodule");
5140 unsigned LocalBaseSubmoduleID = Record[1];
5144 GlobalSubmoduleMap.insert(std::make_pair(getTotalNumSubmodules()+1,&F));
5149 std::make_pair(LocalBaseSubmoduleID,
5158 for (
unsigned Idx = 0; Idx != Record.size(); ++Idx) {
5159 UnresolvedModuleRef Unresolved;
5160 Unresolved.File = &F;
5161 Unresolved.Mod = CurrentModule;
5162 Unresolved.ID = Record[Idx];
5163 Unresolved.Kind = UnresolvedModuleRef::Import;
5164 Unresolved.IsWildcard =
false;
5165 UnresolvedModuleRefs.push_back(Unresolved);
5170 for (
unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
5171 UnresolvedModuleRef Unresolved;
5172 Unresolved.File = &F;
5173 Unresolved.Mod = CurrentModule;
5174 Unresolved.ID = Record[Idx];
5175 Unresolved.Kind = UnresolvedModuleRef::Export;
5176 Unresolved.IsWildcard = Record[Idx + 1];
5177 UnresolvedModuleRefs.push_back(Unresolved);
5187 PP.getTargetInfo());
5201 UnresolvedModuleRef Unresolved;
5202 Unresolved.File = &F;
5203 Unresolved.Mod = CurrentModule;
5204 Unresolved.ID = Record[0];
5205 Unresolved.Kind = UnresolvedModuleRef::Conflict;
5206 Unresolved.IsWildcard =
false;
5207 Unresolved.String = Blob;
5208 UnresolvedModuleRefs.push_back(Unresolved);
5216 for (
auto &
ID : Record)
5217 Inits.push_back(getGlobalDeclID(F,
ID));
5218 ContextObj->addLazyModuleInitializers(CurrentModule, Inits);
5237 bool ASTReader::ParseLanguageOptions(
const RecordData &Record,
5240 bool AllowCompatibleDifferences) {
5243 #define LANGOPT(Name, Bits, Default, Description) \ 5244 LangOpts.Name = Record[Idx++]; 5245 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 5246 LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++])); 5247 #include "clang/Basic/LangOptions.def" 5248 #define SANITIZER(NAME, ID) \ 5249 LangOpts.Sanitize.set(SanitizerKind::ID, Record[Idx++]); 5250 #include "clang/Basic/Sanitizers.def" 5252 for (
unsigned N = Record[Idx++]; N; --N)
5256 VersionTuple runtimeVersion = ReadVersionTuple(Record, Idx);
5262 for (
unsigned N = Record[Idx++]; N; --N) {
5264 ReadString(Record, Idx));
5269 for (
unsigned N = Record[Idx++]; N; --N) {
5270 LangOpts.
OMPTargetTriples.push_back(llvm::Triple(ReadString(Record, Idx)));
5276 AllowCompatibleDifferences);
5279 bool ASTReader::ParseTargetOptions(
const RecordData &Record,
bool Complain,
5281 bool AllowCompatibleDifferences) {
5284 TargetOpts.
Triple = ReadString(Record, Idx);
5285 TargetOpts.
CPU = ReadString(Record, Idx);
5286 TargetOpts.
ABI = ReadString(Record, Idx);
5287 for (
unsigned N = Record[Idx++]; N; --N) {
5290 for (
unsigned N = Record[Idx++]; N; --N) {
5291 TargetOpts.
Features.push_back(ReadString(Record, Idx));
5295 AllowCompatibleDifferences);
5298 bool ASTReader::ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
5302 #define DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++]; 5303 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ 5304 DiagOpts->set##Name(static_cast<Type>(Record[Idx++])); 5305 #include "clang/Basic/DiagnosticOptions.def" 5307 for (
unsigned N = Record[Idx++]; N; --N)
5308 DiagOpts->Warnings.push_back(ReadString(Record, Idx));
5309 for (
unsigned N = Record[Idx++]; N; --N)
5310 DiagOpts->Remarks.push_back(ReadString(Record, Idx));
5315 bool ASTReader::ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
5323 bool ASTReader::ParseHeaderSearchOptions(
const RecordData &Record,
5328 HSOpts.
Sysroot = ReadString(Record, Idx);
5331 for (
unsigned N = Record[Idx++]; N; --N) {
5332 std::string Path = ReadString(Record, Idx);
5335 bool IsFramework = Record[Idx++];
5336 bool IgnoreSysRoot = Record[Idx++];
5337 HSOpts.
UserEntries.emplace_back(std::move(Path), Group, IsFramework,
5342 for (
unsigned N = Record[Idx++]; N; --N) {
5343 std::string Prefix = ReadString(Record, Idx);
5344 bool IsSystemHeader = Record[Idx++];
5358 std::string SpecificModuleCachePath = ReadString(Record, Idx);
5364 bool ASTReader::ParsePreprocessorOptions(
const RecordData &Record,
5367 std::string &SuggestedPredefines) {
5372 for (
unsigned N = Record[Idx++]; N; --N) {
5373 std::string Macro = ReadString(Record, Idx);
5374 bool IsUndef = Record[Idx++];
5375 PPOpts.
Macros.push_back(std::make_pair(Macro, IsUndef));
5379 for (
unsigned N = Record[Idx++]; N; --N) {
5380 PPOpts.
Includes.push_back(ReadString(Record, Idx));
5384 for (
unsigned N = Record[Idx++]; N; --N) {
5393 SuggestedPredefines.clear();
5395 SuggestedPredefines);
5398 std::pair<ModuleFile *, unsigned>
5399 ASTReader::getModulePreprocessedEntity(
unsigned GlobalIndex) {
5401 I = GlobalPreprocessedEntityMap.find(GlobalIndex);
5402 assert(I != GlobalPreprocessedEntityMap.end() &&
5403 "Corrupted global preprocessed entity map");
5406 return std::make_pair(M, LocalIndex);
5409 llvm::iterator_range<PreprocessingRecord::iterator>
5410 ASTReader::getModulePreprocessedEntities(
ModuleFile &Mod)
const {
5419 llvm::iterator_range<ASTReader::ModuleDeclIterator>
5421 return llvm::make_range(
5428 auto I = GlobalSkippedRangeMap.find(GlobalIndex);
5429 assert(I != GlobalSkippedRangeMap.end() &&
5430 "Corrupted global skipped range map");
5433 assert(LocalIndex < M->NumPreprocessedSkippedRanges);
5434 PPSkippedRange RawRange = M->PreprocessedSkippedRangeOffsets[LocalIndex];
5436 TranslateSourceLocation(*M, RawRange.
getEnd()));
5443 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
5445 unsigned LocalIndex = PPInfo.second;
5448 if (!PP.getPreprocessingRecord()) {
5449 Error(
"no preprocessing record");
5456 llvm::BitstreamEntry Entry =
5458 if (Entry.Kind != llvm::BitstreamEntry::Record)
5463 TranslateSourceLocation(M, PPOffs.
getEnd()));
5469 Entry.ID, Record, &Blob);
5472 bool isBuiltin = Record[0];
5476 Name = getLocalIdentifier(M, Record[1]);
5479 getGlobalPreprocessedEntityID(M, Record[1]);
5480 Def = cast<MacroDefinitionRecord>(
5481 PPRec.getLoadedPreprocessedEntity(GlobalID - 1));
5499 if (DeserializationListener)
5500 DeserializationListener->MacroDefinitionRead(PPID, MD);
5506 const char *FullFileNameStart = Blob.data() + Record[0];
5507 StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]);
5509 if (!FullFileName.empty())
5510 File = PP.getFileManager().getFile(FullFileName);
5517 StringRef(Blob.data(), Record[0]),
5518 Record[1], Record[3],
5525 llvm_unreachable(
"Invalid PreprocessorDetailRecordTypes");
5538 EndI = GlobalSLocOffsetMap.end(); SLocMapI != EndI; ++SLocMapI) {
5544 return getTotalNumPreprocessedEntities();
5549 struct PPEntityComp {
5579 bool EndsAfter)
const {
5580 if (SourceMgr.isLocalSourceLocation(Loc))
5581 return getTotalNumPreprocessedEntities();
5584 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
5585 assert(SLocMapI != GlobalSLocOffsetMap.end() &&
5586 "Corrupted global sloc offset map");
5588 if (SLocMapI->second->NumPreprocessedEntities == 0)
5589 return findNextPreprocessedEntity(SLocMapI);
5600 pp_iterator
First = pp_begin;
5604 PPI = std::upper_bound(pp_begin, pp_end, Loc,
5605 PPEntityComp(*
this, M));
5614 std::advance(PPI, Half);
5615 if (SourceMgr.isBeforeInTranslationUnit(
5616 TranslateSourceLocation(M, PPI->getEnd()), Loc)) {
5619 Count = Count - Half - 1;
5626 return findNextPreprocessedEntity(SLocMapI);
5633 std::pair<unsigned, unsigned>
5636 return std::make_pair(0,0);
5637 assert(!SourceMgr.isBeforeInTranslationUnit(Range.
getEnd(),Range.
getBegin()));
5640 findPreprocessedEntity(Range.
getBegin(),
false);
5642 return std::make_pair(BeginID, EndID);
5652 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
5654 unsigned LocalIndex = PPInfo.second;
5661 if (SourceMgr.isInFileID(SourceMgr.getFileLoc(Loc), FID))
5670 class HeaderFileInfoVisitor {
5675 explicit HeaderFileInfoVisitor(
const FileEntry *FE) : FE(FE) {}
5684 HeaderFileInfoLookupTable::iterator Pos = Table->find(FE);
5685 if (Pos == Table->end())
5698 HeaderFileInfoVisitor Visitor(FE);
5699 ModuleMgr.visit(Visitor);
5707 using DiagState = DiagnosticsEngine::DiagState;
5718 auto ReadDiagState =
5720 bool IncludeNonPragmaStates) -> DiagnosticsEngine::DiagState * {
5721 unsigned BackrefID = Record[Idx++];
5723 return DiagStates[BackrefID - 1];
5726 Diag.DiagStates.push_back(BasedOn);
5727 DiagState *NewState = &Diag.DiagStates.back();
5728 DiagStates.push_back(NewState);
5729 unsigned Size = Record[Idx++];
5730 assert(Idx + Size * 2 <= Record.size() &&
5731 "Invalid data, not enough diag/map pairs");
5733 unsigned DiagID = Record[Idx++];
5736 if (!NewMapping.
isPragma() && !IncludeNonPragmaStates)
5749 Mapping = NewMapping;
5755 DiagState *FirstState;
5760 FirstState = Diag.DiagStatesByLoc.FirstDiagState;
5761 DiagStates.push_back(FirstState);
5764 assert(Record[1] == 0 &&
5765 "Invalid data, unexpected backref in initial state");
5766 Idx = 3 + Record[2] * 2;
5767 assert(Idx < Record.size() &&
5768 "Invalid data, not enough state change pairs in initial state");
5773 unsigned Flags = Record[Idx++];
5775 Initial.SuppressSystemWarnings = Flags & 1; Flags >>= 1;
5776 Initial.ErrorsAsFatal = Flags & 1; Flags >>= 1;
5777 Initial.WarningsAsErrors = Flags & 1; Flags >>= 1;
5778 Initial.EnableAllWarnings = Flags & 1; Flags >>= 1;
5779 Initial.IgnoreAllWarnings = Flags & 1; Flags >>= 1;
5789 .StateTransitions.push_back({FirstState, 0});
5794 FirstState = ReadDiagState(*Diag.DiagStatesByLoc.CurDiagState,
5799 unsigned NumLocations = Record[Idx++];
5800 while (NumLocations--) {
5801 assert(Idx < Record.size() &&
5802 "Invalid data, missing pragma diagnostic states");
5804 auto IDAndOffset = SourceMgr.getDecomposedLoc(Loc);
5805 assert(IDAndOffset.first.isValid() &&
"invalid FileID for transition");
5806 assert(IDAndOffset.second == 0 &&
"not a start location for a FileID");
5807 unsigned Transitions = Record[Idx++];
5813 auto &F = Diag.DiagStatesByLoc.Files[IDAndOffset.first];
5814 F.StateTransitions.reserve(F.StateTransitions.size() + Transitions);
5815 for (
unsigned I = 0; I != Transitions; ++I) {
5816 unsigned Offset = Record[Idx++];
5818 ReadDiagState(*FirstState, Loc.getLocWithOffset(Offset),
false);
5819 F.StateTransitions.push_back({
State, Offset});
5824 assert(Idx < Record.size() &&
5825 "Invalid data, missing final pragma diagnostic state");
5828 auto *CurState = ReadDiagState(*FirstState, CurStateLoc,
false);
5831 Diag.DiagStatesByLoc.CurDiagState = CurState;
5832 Diag.DiagStatesByLoc.CurDiagStateLoc = CurStateLoc;
5837 auto &T = Diag.DiagStatesByLoc.Files[NullFile].StateTransitions;
5839 T.push_back({CurState, 0});
5841 T[0].State = CurState;
5850 ASTReader::RecordLocation ASTReader::TypeCursorForIndex(
unsigned Index) {
5852 assert(I != GlobalTypeMap.end() &&
"Corrupted global type map");
5854 return RecordLocation(M, M->TypeOffsets[Index - M->BaseTypeIndex]);
5863 QualType ASTReader::readTypeRecord(
unsigned Index) {
5864 assert(ContextObj &&
"reading type with no AST context");
5866 RecordLocation Loc = TypeCursorForIndex(Index);
5867 BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
5873 ReadingKindTracker ReadingKind(Read_Type, *
this);
5879 DeclsCursor.JumpToBit(Loc.Offset);
5881 unsigned Code = DeclsCursor.ReadCode();
5882 switch ((
TypeCode)DeclsCursor.readRecord(Code, Record)) {
5884 if (Record.size() != 2) {
5885 Error(
"Incorrect encoding of extended qualifier type");
5894 if (Record.size() != 1) {
5895 Error(
"Incorrect encoding of complex type");
5898 QualType ElemType = readType(*Loc.F, Record, Idx);
5903 if (Record.size() != 1) {
5904 Error(
"Incorrect encoding of pointer type");
5907 QualType PointeeType = readType(*Loc.F, Record, Idx);
5912 if (Record.size() != 1) {
5913 Error(
"Incorrect encoding of decayed type");
5916 QualType OriginalType = readType(*Loc.F, Record, Idx);
5918 if (!isa<DecayedType>(DT))
5919 Error(
"Decayed type does not decay");
5924 if (Record.size() != 2) {
5925 Error(
"Incorrect encoding of adjusted type");
5928 QualType OriginalTy = readType(*Loc.F, Record, Idx);
5929 QualType AdjustedTy = readType(*Loc.F, Record, Idx);
5934 if (Record.size() != 1) {
5935 Error(
"Incorrect encoding of block pointer type");
5938 QualType PointeeType = readType(*Loc.F, Record, Idx);
5943 if (Record.size() != 2) {
5944 Error(
"Incorrect encoding of lvalue reference type");
5947 QualType PointeeType = readType(*Loc.F, Record, Idx);
5952 if (Record.size() != 1) {
5953 Error(
"Incorrect encoding of rvalue reference type");
5956 QualType PointeeType = readType(*Loc.F, Record, Idx);
5961 if (Record.size() != 2) {
5962 Error(
"Incorrect encoding of member pointer type");
5965 QualType PointeeType = readType(*Loc.F, Record, Idx);
5966 QualType ClassType = readType(*Loc.F, Record, Idx);
5974 QualType ElementType = readType(*Loc.F, Record, Idx);
5976 unsigned IndexTypeQuals = Record[2];
5978 llvm::APInt Size = ReadAPInt(Record, Idx);
5980 ASM, IndexTypeQuals);
5984 QualType ElementType = readType(*Loc.F, Record, Idx);
5986 unsigned IndexTypeQuals = Record[2];
5991 QualType ElementType = readType(*Loc.F, Record, Idx);
5993 unsigned IndexTypeQuals = Record[2];
5997 ASM, IndexTypeQuals,
6002 if (Record.size() != 3) {
6003 Error(
"incorrect encoding of vector type in AST file");
6007 QualType ElementType = readType(*Loc.F, Record, Idx);
6008 unsigned NumElements = Record[1];
6009 unsigned VecKind = Record[2];
6015 if (Record.size() != 3) {
6016 Error(
"incorrect encoding of extended vector type in AST file");
6020 QualType ElementType = readType(*Loc.F, Record, Idx);
6021 unsigned NumElements = Record[1];
6026 if (Record.size() != 8) {
6027 Error(
"incorrect encoding of no-proto function type");
6030 QualType ResultType = readType(*Loc.F, Record, Idx);
6038 QualType ResultType = readType(*Loc.F, Record, Idx);
6044 static_cast<CallingConv>(Record[4]),
6056 readExceptionSpec(*Loc.F, ExceptionStorage, EPI.
ExceptionSpec, Record, Idx);
6058 unsigned NumParams = Record[Idx++];
6060 for (
unsigned I = 0; I != NumParams; ++I)
6061 ParamTypes.push_back(readType(*Loc.F, Record, Idx));
6064 if (Idx != Record.size()) {
6065 for (
unsigned I = 0; I != NumParams; ++I)
6066 ExtParameterInfos.push_back(
6068 ::getFromOpaqueValue(Record[Idx++]));
6072 assert(Idx == Record.size());
6080 ReadDeclAs<UnresolvedUsingTypenameDecl>(*Loc.F, Record, Idx));
6084 if (Record.size() != 2) {
6085 Error(
"incorrect encoding of typedef type");
6090 QualType Canonical = readType(*Loc.F, Record, Idx);
6091 if (!Canonical.isNull())
6100 if (Record.size() != 1) {
6101 Error(
"incorrect encoding of typeof(type) in AST file");
6104 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
6109 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
6114 QualType BaseType = readType(*Loc.F, Record, Idx);
6115 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
6121 QualType Deduced = readType(*Loc.F, Record, Idx);
6123 bool IsDependent = Deduced.
isNull() ? Record[Idx++] :
false;
6124 return Context.
getAutoType(Deduced, Keyword, IsDependent);
6128 TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx);
6129 QualType Deduced = readType(*Loc.F, Record, Idx);
6130 bool IsDependent = Deduced.
isNull() ? Record[Idx++] :
false;
6136 if (Record.size() != 2) {
6137 Error(
"incorrect encoding of record type");
6141 bool IsDependent = Record[Idx++];
6142 RecordDecl *RD = ReadDeclAs<RecordDecl>(*Loc.F, Record, Idx);
6143 RD = cast_or_null<RecordDecl>(RD->getCanonicalDecl());
6145 const_cast<Type*
>(T.getTypePtr())->setDependent(IsDependent);
6150 if (Record.size() != 2) {
6151 Error(
"incorrect encoding of enum type");
6155 bool IsDependent = Record[Idx++];
6157 = Context.
getEnumType(ReadDeclAs<EnumDecl>(*Loc.F, Record, Idx));
6163 if (Record.size() != 3) {
6164 Error(
"incorrect encoding of attributed type");
6167 QualType modifiedType = readType(*Loc.F, Record, Idx);
6168 QualType equivalentType = readType(*Loc.F, Record, Idx);
6174 if (Record.size() != 1) {
6175 Error(
"incorrect encoding of paren type");
6178 QualType InnerType = readType(*Loc.F, Record, Idx);
6183 if (Record.size() != 2) {
6184 Error(
"incorrect encoding of pack expansion type");
6187 QualType Pattern = readType(*Loc.F, Record, Idx);
6192 NumExpansions = Record[1] - 1;
6200 QualType NamedType = readType(*Loc.F, Record, Idx);
6201 TagDecl *OwnedTagDecl = ReadDeclAs<TagDecl>(*Loc.F, Record, Idx);
6208 = ReadDeclAs<ObjCInterfaceDecl>(*Loc.F, Record, Idx);
6215 = ReadDeclAs<ObjCTypeParamDecl>(*Loc.F, Record, Idx);
6216 unsigned NumProtos = Record[Idx++];
6218 for (
unsigned I = 0; I != NumProtos; ++I)
6219 Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
6226 unsigned NumTypeArgs = Record[Idx++];
6228 for (
unsigned I = 0; I != NumTypeArgs; ++I)
6229 TypeArgs.push_back(readType(*Loc.F, Record, Idx));
6230 unsigned NumProtos = Record[Idx++];
6232 for (
unsigned I = 0; I != NumProtos; ++I)
6233 Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
6234 bool IsKindOf = Record[Idx++];
6240 QualType Pointee = readType(*Loc.F, Record, Idx);
6246 QualType Parm = readType(*Loc.F, Record, Idx);
6247 QualType Replacement = readType(*Loc.F, Record, Idx);
6249 cast<TemplateTypeParmType>(Parm),
6255 QualType Parm = readType(*Loc.F, Record, Idx);
6258 cast<TemplateTypeParmType>(Parm),
6263 CXXRecordDecl *D = ReadDeclAs<CXXRecordDecl>(*Loc.F, Record, Idx);
6264 QualType TST = readType(*Loc.F, Record, Idx);
6267 const Type *T =
nullptr;
6269 if (
const Type *Existing = DI->getTypeForDecl()) {
6277 DI->setTypeForDecl(T);
6284 unsigned Depth = Record[Idx++];
6285 unsigned Index = Record[Idx++];
6286 bool Pack = Record[Idx++];
6288 = ReadDeclAs<TemplateTypeParmDecl>(*Loc.F, Record, Idx);
6296 const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx);
6297 QualType Canon = readType(*Loc.F, Record, Idx);
6307 const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx);
6308 unsigned NumArgs = Record[Idx++];
6310 Args.reserve(NumArgs);
6312 Args.push_back(ReadTemplateArgument(*Loc.F, Record, Idx));
6321 QualType ElementType = readType(*Loc.F, Record, Idx);
6324 unsigned IndexTypeQuals = Record[Idx++];
6327 Expr *NumElts = ReadExpr(*Loc.F);
6328 SourceRange Brackets = ReadSourceRange(*Loc.F, Record, Idx);
6331 IndexTypeQuals, Brackets);
6336 bool IsDependent = Record[Idx++];
6337 TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx);
6339 ReadTemplateArgumentList(Args, *Loc.F, Record, Idx);
6340 QualType Underlying = readType(*Loc.F, Record, Idx);
6351 if (Record.size() != 1) {
6352 Error(
"Incorrect encoding of atomic type");
6355 QualType ValueType = readType(*Loc.F, Record, Idx);
6360 if (Record.size() != 2) {
6361 Error(
"Incorrect encoding of pipe type");
6366 QualType ElementType = readType(*Loc.F, Record, Idx);
6367 unsigned ReadOnly = Record[1];
6368 return Context.getPipeType(ElementType, ReadOnly);
6373 QualType ElementType = readType(*Loc.F, Record, Idx);
6374 Expr *SizeExpr = ReadExpr(*Loc.F);
6375 SourceLocation AttrLoc = ReadSourceLocation(*Loc.F, Record, Idx);
6376 unsigned VecKind = Record[Idx];
6386 QualType ElementType = readType(*Loc.F, Record, Idx);
6387 Expr *SizeExpr = ReadExpr(*Loc.F);
6388 SourceLocation AttrLoc = ReadSourceLocation(*Loc.F, Record, Idx);
6398 QualType PointeeType = readType(*Loc.F, Record, Idx);
6399 Expr *AddrSpaceExpr = ReadExpr(*Loc.F);
6400 SourceLocation AttrLoc = ReadSourceLocation(*Loc.F, Record, Idx);
6406 llvm_unreachable(
"Invalid TypeCode!");
6417 for (
unsigned I = 0, N = Record[Idx++]; I != N; ++I)
6418 Exceptions.push_back(readType(ModuleFile, Record, Idx));
6423 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6424 ESI.
SourceTemplate = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6426 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6451 return Reader->
ReadAttr(*F, Record, Idx);
6457 : F(&F), Reader(&Reader), Record(Record), Idx(Idx) {}
6462 #define ABSTRACT_TYPELOC(CLASS, PARENT) 6463 #define TYPELOC(CLASS, PARENT) \ 6464 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc); 6465 #include "clang/AST/TypeLocNodes.def" 6530 VisitArrayTypeLoc(TL);
6534 VisitArrayTypeLoc(TL);
6538 VisitArrayTypeLoc(TL);
6541 void TypeLocReader::VisitDependentSizedArrayTypeLoc(
6543 VisitArrayTypeLoc(TL);
6546 void TypeLocReader::VisitDependentAddressSpaceTypeLoc(
6551 range.
setBegin(ReadSourceLocation());
6552 range.
setEnd(ReadSourceLocation());
6557 void TypeLocReader::VisitDependentSizedExtVectorTypeLoc(
6566 void TypeLocReader::VisitDependentVectorTypeLoc(
6580 Reader->ReadSourceLocation(*F, Record, Idx)));
6582 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i) {
6588 VisitFunctionTypeLoc(TL);
6592 VisitFunctionTypeLoc(TL);
6627 void TypeLocReader::VisitAutoTypeLoc(
AutoTypeLoc TL) {
6631 void TypeLocReader::VisitDeducedTemplateSpecializationTypeLoc(
6640 void TypeLocReader::VisitEnumTypeLoc(
EnumTypeLoc TL) {
6652 void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
6657 void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
6662 void TypeLocReader::VisitTemplateSpecializationTypeLoc(
6668 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
6671 Reader->GetTemplateArgumentLocInfo(
6675 void TypeLocReader::VisitParenTypeLoc(
ParenTypeLoc TL) {
6695 void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc(
6703 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I)
6706 Reader->GetTemplateArgumentLocInfo(
6749 void TypeLocReader::VisitPipeTypeLoc(
PipeTypeLoc TL) {
6763 QualType InfoTy = readType(F, Record, Idx);
6767 TypeSourceInfo *TInfo = getContext().CreateTypeSourceInfo(InfoTy);
6768 ReadTypeLoc(F, Record, Idx, TInfo->
getTypeLoc());
6773 assert(ContextObj &&
"reading type with no AST context");
6960 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 6961 case PREDEF_TYPE_##Id##_ID: \ 6962 T = Context.SingletonId; \ 6964 #include "clang/Basic/OpenCLImageTypes.def" 6965 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 6966 case PREDEF_TYPE_##Id##_ID: \ 6967 T = Context.Id##Ty; \ 6969 #include "clang/Basic/OpenCLExtensionTypes.def" 7002 assert(!T.
isNull() &&
"Unknown predefined type");
7007 assert(Index < TypesLoaded.size() &&
"Type index out-of-range");
7008 if (TypesLoaded[Index].isNull()) {
7009 TypesLoaded[Index] = readTypeRecord(Index);
7010 if (TypesLoaded[Index].isNull())
7013 TypesLoaded[Index]->setFromAST();
7014 if (DeserializationListener)
7016 TypesLoaded[Index]);
7019 return TypesLoaded[Index].withFastQualifiers(FastQuals);
7023 return GetType(getGlobalTypeID(F, LocalID));
7035 ReadModuleOffsetMap(F);
7039 assert(I != F.
TypeRemap.
end() &&
"Invalid index into type index remap");
7041 unsigned GlobalIndex = LocalIndex + I->second;
7042 return (GlobalIndex << Qualifiers::FastWidth) | FastQuals;
7054 return GetTypeSourceInfo(F, Record, Index);
7058 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
7065 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
7066 SourceLocation EllipsisLoc = ReadSourceLocation(F, Record, Index);
7078 llvm_unreachable(
"unexpected template argument loc");
7087 if (Record[Index++])
7100 unsigned NumArgsAsWritten = Record[Index++];
7102 for (
unsigned i = 0; i != NumArgsAsWritten; ++i)
7103 TemplArgsInfo.
addArgument(ReadTemplateArgumentLoc(F, Record, Index));
7112 if (NumCurrentElementsDeserializing) {
7117 PendingIncompleteDeclChains.push_back(const_cast<Decl*>(D));
7128 if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC) ||
7129 isa<CXXRecordDecl>(DC) || isa<EnumDecl>(DC)) {
7131 if (!getContext().getLangOpts().
CPlusPlus &&
7132 isa<TranslationUnitDecl>(DC)) {
7136 auto *II = Name.getAsIdentifierInfo();
7137 assert(II &&
"non-identifier name in C?");
7138 if (II->isOutOfDate())
7139 updateOutOfDateIdentifier(*II);
7145 auto *DC = cast<DeclContext>(DCDecl);
7147 FindExternalLexicalDecls(
7153 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D))
7154 CTSD->getSpecializedTemplate()->LoadLazySpecializations();
7155 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D))
7156 VTSD->getSpecializedTemplate()->LoadLazySpecializations();
7157 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
7158 if (
auto *Template = FD->getPrimaryTemplate())
7159 Template->LoadLazySpecializations();
7165 RecordLocation Loc = getLocalBitOffset(Offset);
7166 BitstreamCursor &
Cursor = Loc.F->DeclsCursor;
7168 Cursor.JumpToBit(Loc.Offset);
7169 ReadingKindTracker ReadingKind(Read_Decl, *
this);
7172 unsigned Code = Cursor.ReadCode();
7173 unsigned RecCode = Cursor.readRecord(Code, Record);
7175 Error(
"malformed AST file: missing C++ ctor initializers");
7180 return ReadCXXCtorInitializers(*Loc.F, Record, Idx);
7184 assert(ContextObj &&
"reading base specifiers with no AST context");
7187 RecordLocation Loc = getLocalBitOffset(Offset);
7188 BitstreamCursor &
Cursor = Loc.F->DeclsCursor;
7190 Cursor.JumpToBit(Loc.Offset);
7191 ReadingKindTracker ReadingKind(Read_Decl, *
this);
7193 unsigned Code = Cursor.ReadCode();
7194 unsigned RecCode = Cursor.readRecord(Code, Record);
7196 Error(
"malformed AST file: missing C++ base specifiers");
7201 unsigned NumBases = Record[Idx++];
7204 for (
unsigned I = 0; I != NumBases; ++I)
7205 Bases[I] = ReadCXXBaseSpecifier(*Loc.F, Record, Idx);
7215 ReadModuleOffsetMap(F);
7219 assert(I != F.
DeclRemap.
end() &&
"Invalid index into decl index remap");
7221 return LocalID + I->second;
7225 ModuleFile &M)
const {
7238 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
7248 if (Index > DeclsLoaded.size()) {
7249 Error(
"declaration ID out-of-range for AST file");
7253 if (
Decl *D = DeclsLoaded[Index])
7254 return D->getLocation();
7257 DeclCursorForID(ID, Loc);
7314 llvm_unreachable(
"PredefinedDeclIDs unknown enum value");
7318 assert(ContextObj &&
"reading decl with no AST context");
7326 Merged.push_back(ID);
7333 if (Index >= DeclsLoaded.size()) {
7334 assert(0 &&
"declaration ID out-of-range for AST file");
7335 Error(
"declaration ID out-of-range for AST file");
7339 return DeclsLoaded[Index];
7344 return GetExistingDecl(ID);
7348 if (Index >= DeclsLoaded.size()) {
7349 assert(0 &&
"declaration ID out-of-range for AST file");
7350 Error(
"declaration ID out-of-range for AST file");
7354 if (!DeclsLoaded[Index]) {
7356 if (DeserializationListener)
7357 DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);
7360 return DeclsLoaded[Index];
7369 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
7370 ModuleFile *Owner = I->second;
7372 llvm::DenseMap<ModuleFile *, serialization::DeclID>::iterator Pos
7377 return GlobalID - Owner->BaseDeclID + Pos->second;
7383 if (Idx >= Record.size()) {
7384 Error(
"Corrupted AST file");
7388 return getGlobalDeclID(F, Record[Idx++]);
7398 ClearSwitchCaseIDs();
7401 RecordLocation Loc = getLocalBitOffset(Offset);
7402 Loc.F->DeclsCursor.JumpToBit(Loc.Offset);
7403 assert(NumCurrentElementsDeserializing == 0 &&
7404 "should not be called while already deserializing");
7406 return ReadStmtFromStream(*Loc.F);
7415 assert(LexicalDecls.size() % 2 == 0 &&
"expected an even number of entries");
7416 for (
int I = 0, N = LexicalDecls.size(); I != N; I += 2) {
7418 if (!IsKindWeWant(K))
7426 if (PredefsVisited[
ID])
7429 PredefsVisited[
ID] =
true;
7432 if (
Decl *D = GetLocalDecl(*M,
ID)) {
7433 assert(D->getKind() == K &&
"wrong kind for lexical decl");
7440 if (isa<TranslationUnitDecl>(DC)) {
7441 for (
auto Lexical : TULexicalDecls)
7442 Visit(Lexical.first, Lexical.second);
7444 auto I = LexicalDecls.find(DC);
7445 if (I != LexicalDecls.end())
7446 Visit(I->second.first, I->second.second);
7449 ++NumLexicalDeclContextsRead;
7459 DeclIDComp(
ASTReader &Reader, ModuleFile &M) : Reader(Reader), Mod(M) {}
7486 unsigned Offset,
unsigned Length,
7490 llvm::DenseMap<FileID, FileDeclsInfo>::iterator I = FileDeclIDs.find(File);
7491 if (I == FileDeclIDs.end())
7494 FileDeclsInfo &DInfo = I->second;
7495 if (DInfo.Decls.empty())
7502 DeclIDComp DIDComp(*
this, *DInfo.Mod);
7504 BeginIt = std::lower_bound(DInfo.Decls.begin(), DInfo.Decls.end(),
7506 if (BeginIt != DInfo.Decls.begin())
7512 while (BeginIt != DInfo.Decls.begin() &&
7513 GetDecl(getGlobalDeclID(*DInfo.Mod, *BeginIt))
7514 ->isTopLevelDeclInObjCContainer())
7518 EndIt = std::upper_bound(DInfo.Decls.begin(), DInfo.Decls.end(),
7520 if (EndIt != DInfo.Decls.end())
7524 DIt = BeginIt; DIt != EndIt; ++DIt)
7525 Decls.push_back(GetDecl(getGlobalDeclID(*DInfo.Mod, *DIt)));
7532 "DeclContext has no visible decls in storage");
7536 auto It = Lookups.find(DC);
7537 if (It == Lookups.end())
7544 for (
DeclID ID : It->second.Table.find(Name)) {
7547 Decls.push_back(ND);
7550 ++NumVisibleDeclContextsRead;
7551 SetExternalVisibleDeclsForName(DC, Name, Decls);
7552 return !Decls.empty();
7559 auto It = Lookups.find(DC);
7560 assert(It != Lookups.end() &&
7561 "have external visible storage but no lookup tables");
7565 for (
DeclID ID : It->second.Table.findAll()) {
7570 ++NumVisibleDeclContextsRead;
7572 for (DeclsMap::iterator I = Decls.begin(), E = Decls.end(); I != E; ++I) {
7573 SetExternalVisibleDeclsForName(DC, I->first, I->second);
7575 const_cast<DeclContext *
>(DC)->setHasExternalVisibleStorage(
false);
7580 auto I = Lookups.find(Primary);
7581 return I == Lookups.end() ? nullptr : &I->second;
7590 assert(ImplD && Consumer);
7592 for (
auto *I : ImplD->
methods())
7598 void ASTReader::PassInterestingDeclToConsumer(
Decl *D) {
7606 this->Consumer = Consumer;
7609 PassInterestingDeclsToConsumer();
7611 if (DeserializationListener)
7612 DeserializationListener->ReaderInitialized(
this);
7616 std::fprintf(stderr,
"*** AST File Statistics:\n");
7618 unsigned NumTypesLoaded
7619 = TypesLoaded.size() - std::count(TypesLoaded.begin(), TypesLoaded.end(),
7621 unsigned NumDeclsLoaded
7622 = DeclsLoaded.size() - std::count(DeclsLoaded.begin(), DeclsLoaded.end(),
7624 unsigned NumIdentifiersLoaded
7625 = IdentifiersLoaded.size() - std::count(IdentifiersLoaded.begin(),
7626 IdentifiersLoaded.end(),
7628 unsigned NumMacrosLoaded
7629 = MacrosLoaded.size() - std::count(MacrosLoaded.begin(),
7632 unsigned NumSelectorsLoaded
7633 = SelectorsLoaded.size() - std::count(SelectorsLoaded.begin(),
7634 SelectorsLoaded.end(),
7637 if (
unsigned TotalNumSLocEntries = getTotalNumSLocs())
7638 std::fprintf(stderr,
" %u/%u source location entries read (%f%%)\n",
7639 NumSLocEntriesRead, TotalNumSLocEntries,
7640 ((
float)NumSLocEntriesRead/TotalNumSLocEntries * 100));
7641 if (!TypesLoaded.empty())
7642 std::fprintf(stderr,
" %u/%u types read (%f%%)\n",
7643 NumTypesLoaded, (
unsigned)TypesLoaded.size(),
7644 ((float)NumTypesLoaded/TypesLoaded.size() * 100));
7645 if (!DeclsLoaded.empty())
7646 std::fprintf(stderr,
" %u/%u declarations read (%f%%)\n",
7647 NumDeclsLoaded, (
unsigned)DeclsLoaded.size(),
7648 ((float)NumDeclsLoaded/DeclsLoaded.size() * 100));
7649 if (!IdentifiersLoaded.empty())
7650 std::fprintf(stderr,
" %u/%u identifiers read (%f%%)\n",
7651 NumIdentifiersLoaded, (
unsigned)IdentifiersLoaded.size(),
7652 ((float)NumIdentifiersLoaded/IdentifiersLoaded.size() * 100));
7653 if (!MacrosLoaded.empty())
7654 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
7655 NumMacrosLoaded, (
unsigned)MacrosLoaded.size(),
7656 ((float)NumMacrosLoaded/MacrosLoaded.size() * 100));
7657 if (!SelectorsLoaded.empty())
7658 std::fprintf(stderr,
" %u/%u selectors read (%f%%)\n",
7659 NumSelectorsLoaded, (
unsigned)SelectorsLoaded.size(),
7660 ((float)NumSelectorsLoaded/SelectorsLoaded.size() * 100));
7661 if (TotalNumStatements)
7662 std::fprintf(stderr,
" %u/%u statements read (%f%%)\n",
7663 NumStatementsRead, TotalNumStatements,
7664 ((
float)NumStatementsRead/TotalNumStatements * 100));
7666 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
7667 NumMacrosRead, TotalNumMacros,
7668 ((
float)NumMacrosRead/TotalNumMacros * 100));
7669 if (TotalLexicalDeclContexts)
7670 std::fprintf(stderr,
" %u/%u lexical declcontexts read (%f%%)\n",
7671 NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
7672 ((
float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts
7674 if (TotalVisibleDeclContexts)
7675 std::fprintf(stderr,
" %u/%u visible declcontexts read (%f%%)\n",
7676 NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
7677 ((
float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
7679 if (TotalNumMethodPoolEntries)
7680 std::fprintf(stderr,
" %u/%u method pool entries read (%f%%)\n",
7681 NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
7682 ((
float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
7684 if (NumMethodPoolLookups)
7685 std::fprintf(stderr,
" %u/%u method pool lookups succeeded (%f%%)\n",
7686 NumMethodPoolHits, NumMethodPoolLookups,
7687 ((
float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
7688 if (NumMethodPoolTableLookups)
7689 std::fprintf(stderr,
" %u/%u method pool table lookups succeeded (%f%%)\n",
7690 NumMethodPoolTableHits, NumMethodPoolTableLookups,
7691 ((
float)NumMethodPoolTableHits/NumMethodPoolTableLookups
7693 if (NumIdentifierLookupHits)
7694 std::fprintf(stderr,
7695 " %u / %u identifier table lookups succeeded (%f%%)\n",
7696 NumIdentifierLookupHits, NumIdentifierLookups,
7697 (
double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
7700 std::fprintf(stderr,
"\n");
7701 GlobalIndex->printStats();
7704 std::fprintf(stderr,
"\n");
7706 std::fprintf(stderr,
"\n");
7709 template<
typename Key,
typename ModuleFile,
unsigned InitialCapacity>
7710 LLVM_DUMP_METHOD
static void 7713 InitialCapacity> &Map) {
7714 if (Map.begin() == Map.end())
7719 llvm::errs() << Name <<
":\n";
7720 for (
typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
7722 llvm::errs() <<
" " << I->first <<
" -> " << I->second->FileName
7728 llvm::errs() <<
"*** PCH/ModuleFile Remappings:\n";
7730 dumpModuleIDMap(
"Global source location entry map", GlobalSLocEntryMap);
7738 GlobalPreprocessedEntityMap);
7740 llvm::errs() <<
"\n*** PCH/Modules Loaded:";
7741 for (ModuleFile &M : ModuleMgr)
7748 for (ModuleFile &I : ModuleMgr) {
7749 if (llvm::MemoryBuffer *buf = I.Buffer) {
7750 size_t bytes = buf->getBufferSize();
7751 switch (buf->getBufferKind()) {
7752 case llvm::MemoryBuffer::MemoryBuffer_Malloc:
7755 case llvm::MemoryBuffer::MemoryBuffer_MMap:
7769 for (uint64_t
ID : PreloadedDeclIDs) {
7773 PreloadedDeclIDs.clear();
7776 if (!FPPragmaOptions.empty()) {
7777 assert(FPPragmaOptions.size() == 1 &&
"Wrong number of FP_PRAGMA_OPTIONS");
7778 SemaObj->FPFeatures =
FPOptions(FPPragmaOptions[0]);
7781 SemaObj->OpenCLFeatures.copy(OpenCLExtensions);
7782 SemaObj->OpenCLTypeExtMap = OpenCLTypeExtMap;
7783 SemaObj->OpenCLDeclExtMap = OpenCLDeclExtMap;
7789 assert(SemaObj &&
"no Sema to update");
7793 if (!SemaDeclRefs.empty()) {
7794 assert(SemaDeclRefs.size() % 3 == 0);
7795 for (
unsigned I = 0; I != SemaDeclRefs.size(); I += 3) {
7796 if (!SemaObj->StdNamespace)
7797 SemaObj->StdNamespace = SemaDeclRefs[I];
7798 if (!SemaObj->StdBadAlloc)
7799 SemaObj->StdBadAlloc = SemaDeclRefs[I+1];
7800 if (!SemaObj->StdAlignValT)
7801 SemaObj->StdAlignValT = SemaDeclRefs[I+2];
7803 SemaDeclRefs.clear();
7808 if(OptimizeOffPragmaLocation.isValid())
7809 SemaObj->ActOnPragmaOptimize(
false, OptimizeOffPragmaLocation);
7810 if (PragmaMSStructState != -1)
7812 if (PointersToMembersPragmaLocation.isValid()) {
7813 SemaObj->ActOnPragmaMSPointersToMembers(
7815 PragmaMSPointersToMembersState,
7816 PointersToMembersPragmaLocation);
7818 SemaObj->ForceCUDAHostDeviceDepth = ForceCUDAHostDeviceDepth;
7820 if (PragmaPackCurrentValue) {
7824 bool DropFirst =
false;
7825 if (!PragmaPackStack.empty() &&
7826 PragmaPackStack.front().Location.isInvalid()) {
7827 assert(PragmaPackStack.front().Value == SemaObj->PackStack.DefaultValue &&
7828 "Expected a default alignment value");
7829 SemaObj->PackStack.Stack.emplace_back(
7830 PragmaPackStack.front().SlotLabel, SemaObj->PackStack.CurrentValue,
7831 SemaObj->PackStack.CurrentPragmaLocation,
7832 PragmaPackStack.front().PushLocation);
7835 for (
const auto &Entry :
7836 llvm::makeArrayRef(PragmaPackStack).drop_front(DropFirst ? 1 : 0))
7837 SemaObj->PackStack.Stack.emplace_back(Entry.SlotLabel, Entry.Value,
7838 Entry.Location, Entry.PushLocation);
7839 if (PragmaPackCurrentLocation.isInvalid()) {
7840 assert(*PragmaPackCurrentValue == SemaObj->PackStack.DefaultValue &&
7841 "Expected a default alignment value");
7844 SemaObj->PackStack.CurrentValue = *PragmaPackCurrentValue;
7845 SemaObj->PackStack.CurrentPragmaLocation = PragmaPackCurrentLocation;
7854 IdentifierLookupVisitor Visitor(Name, 0,
7855 NumIdentifierLookups,
7856 NumIdentifierLookupHits);
7862 if (PP.getLangOpts().CPlusPlus) {
7863 for (
auto F : ModuleMgr.pch_modules())
7871 if (!loadGlobalIndex()) {
7872 if (GlobalIndex->lookupIdentifier(Name, Hits)) {
7877 ModuleMgr.visit(Visitor, HitsPtr);
7881 markIdentifierUpToDate(II);
7899 ASTIdentifierLookupTable::key_iterator Current;
7903 ASTIdentifierLookupTable::key_iterator
End;
7910 bool SkipModules =
false);
7912 StringRef Next()
override;
7919 : Reader(Reader), Index(Reader.ModuleMgr.size()), SkipModules(SkipModules) {
7923 while (Current == End) {
7929 ModuleFile &F = Reader.ModuleMgr[Index];
7935 Current = IdTable->key_begin();
7936 End = IdTable->key_end();
7941 StringRef
Result = *Current;
7950 std::unique_ptr<IdentifierIterator> Current;
7951 std::unique_ptr<IdentifierIterator> Queued;
7954 ChainedIdentifierIterator(std::unique_ptr<IdentifierIterator>
First,
7955 std::unique_ptr<IdentifierIterator> Second)
7956 : Current(std::move(First)), Queued(std::move(Second)) {}
7958 StringRef
Next()
override {
7962 StringRef result = Current->Next();
7963 if (!result.empty())
7968 std::swap(Current, Queued);
7976 if (!loadGlobalIndex()) {
7977 std::unique_ptr<IdentifierIterator> ReaderIter(
7979 std::unique_ptr<IdentifierIterator> ModulesIter(
7980 GlobalIndex->createIdentifierIterator());
7981 return new ChainedIdentifierIterator(std::move(ReaderIter),
7982 std::move(ModulesIter));
7989 namespace serialization {
7994 unsigned PriorGeneration;
7995 unsigned InstanceBits = 0;
7996 unsigned FactoryBits = 0;
7997 bool InstanceHasMoreThanOneDecl =
false;
7998 bool FactoryHasMoreThanOneDecl =
false;
8004 unsigned PriorGeneration)
8005 : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) {}
8015 ++Reader.NumMethodPoolTableLookups;
8018 ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel);
8019 if (Pos == PoolTable->end())
8022 ++Reader.NumMethodPoolTableHits;
8023 ++Reader.NumSelectorsRead;
8027 ++Reader.NumMethodPoolEntriesRead;
8029 if (Reader.DeserializationListener)
8043 return InstanceMethods;
8048 return FactoryMethods;
8055 return InstanceHasMoreThanOneDecl;
8067 for (
unsigned I = 0, N = Methods.size(); I != N; ++I) {
8074 unsigned &Generation = SelectorGeneration[Sel];
8075 unsigned PriorGeneration = Generation;
8076 Generation = getGeneration();
8077 SelectorOutOfDate[Sel] =
false;
8080 ++NumMethodPoolLookups;
8082 ModuleMgr.visit(Visitor);
8088 ++NumMethodPoolHits;
8093 Sema &S = *getSema();
8094 Sema::GlobalMethodPool::iterator Pos
8110 if (SelectorOutOfDate[Sel])
8111 ReadMethodPool(Sel);
8118 for (
unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) {
8120 = dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespaces[I])))
8121 Namespaces.push_back(Namespace);
8126 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
8127 for (
unsigned Idx = 0, N = UndefinedButUsed.size(); Idx != N;) {
8128 NamedDecl *D = cast<NamedDecl>(GetDecl(UndefinedButUsed[Idx++]));
8131 Undefined.insert(std::make_pair(D, Loc));
8138 for (
unsigned Idx = 0, N = DelayedDeleteExprs.size(); Idx != N;) {
8139 FieldDecl *FD = cast<FieldDecl>(GetDecl(DelayedDeleteExprs[Idx++]));
8140 uint64_t Count = DelayedDeleteExprs[Idx++];
8141 for (uint64_t
C = 0;
C < Count; ++
C) {
8144 const bool IsArrayForm = DelayedDeleteExprs[Idx++];
8145 Exprs[FD].push_back(std::make_pair(DeleteLoc, IsArrayForm));
8152 for (
unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) {
8153 VarDecl *Var = dyn_cast_or_null<VarDecl>(GetDecl(TentativeDefinitions[I]));
8155 TentativeDefs.push_back(Var);
8157 TentativeDefinitions.clear();
8162 for (
unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++I) {
8164 = dyn_cast_or_null<DeclaratorDecl>(GetDecl(UnusedFileScopedDecls[I]));
8168 UnusedFileScopedDecls.clear();
8173 for (
unsigned I = 0, N = DelegatingCtorDecls.size(); I != N; ++I) {
8175 = dyn_cast_or_null<CXXConstructorDecl>(GetDecl(DelegatingCtorDecls[I]));
8179 DelegatingCtorDecls.clear();
8183 for (
unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++I) {
8185 = dyn_cast_or_null<TypedefNameDecl>(GetDecl(ExtVectorDecls[I]));
8189 ExtVectorDecls.clear();
8194 for (
unsigned I = 0, N = UnusedLocalTypedefNameCandidates.size(); I != N;
8197 GetDecl(UnusedLocalTypedefNameCandidates[I]));
8201 UnusedLocalTypedefNameCandidates.clear();
8206 if (ReferencedSelectorsData.empty())
8211 unsigned int DataSize = ReferencedSelectorsData.size()-1;
8213 while (I < DataSize) {
8214 Selector Sel = DecodeSelector(ReferencedSelectorsData[I++]);
8217 Sels.push_back(std::make_pair(Sel, SelLoc));
8219 ReferencedSelectorsData.clear();
8224 if (WeakUndeclaredIdentifiers.empty())
8227 for (
unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; ) {
8229 = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
8231 = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
8234 bool Used = WeakUndeclaredIdentifiers[I++];
8237 WeakIDs.push_back(std::make_pair(WeakId, WI));
8239 WeakUndeclaredIdentifiers.clear();
8243 for (
unsigned Idx = 0, N = VTableUses.size(); Idx < N; ) {
8245 VT.
Record = dyn_cast_or_null<CXXRecordDecl>(GetDecl(VTableUses[Idx++]));
8248 VTables.push_back(VT);
8256 for (
unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
8257 ValueDecl *D = cast<ValueDecl>(GetDecl(PendingInstantiations[Idx++]));
8261 Pending.push_back(std::make_pair(D, Loc));
8263 PendingInstantiations.clear();
8267 llvm::MapVector<
const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
8269 for (
unsigned Idx = 0, N = LateParsedTemplates.size(); Idx < N;
8271 FunctionDecl *FD = cast<FunctionDecl>(GetDecl(LateParsedTemplates[Idx++]));
8273 auto LT = llvm::make_unique<LateParsedTemplate>();
8274 LT->D = GetDecl(LateParsedTemplates[Idx++]);
8276 ModuleFile *F = getOwningModuleFile(LT->D);
8277 assert(F &&
"No module");
8279 unsigned TokN = LateParsedTemplates[Idx++];
8280 LT->Toks.reserve(TokN);
8281 for (
unsigned T = 0; T < TokN; ++T)
8282 LT->Toks.push_back(ReadToken(*F, LateParsedTemplates, Idx));
8284 LPTMap.insert(std::make_pair(FD, std::move(LT)));
8287 LateParsedTemplates.clear();
8292 ReadMethodPool(Sel);
8296 assert(ID &&
"Non-zero identifier ID required");
8297 assert(ID <= IdentifiersLoaded.size() &&
"identifier ID out of range");
8298 IdentifiersLoaded[ID - 1] = II;
8299 if (DeserializationListener)
8300 DeserializationListener->IdentifierRead(ID, II);
8323 if (NumCurrentElementsDeserializing && !Decls) {
8324 PendingIdentifierInfos[II].append(DeclIDs.begin(), DeclIDs.end());
8328 for (
unsigned I = 0, N = DeclIDs.size(); I != N; ++I) {
8333 PreloadedDeclIDs.push_back(DeclIDs[I]);
8337 NamedDecl *D = cast<NamedDecl>(GetDecl(DeclIDs[I]));
8341 Decls->push_back(D);
8348 pushExternalDeclIntoScope(D, II);
8356 if (IdentifiersLoaded.empty()) {
8357 Error(
"no identifier table in AST file");
8362 if (!IdentifiersLoaded[ID]) {
8364 assert(I != GlobalIdentifierMap.end() &&
"Corrupted global identifier map");
8365 ModuleFile *M = I->second;
8366 unsigned Index = ID - M->BaseIdentifierID;
8367 const char *Str = M->IdentifierTableData + M->IdentifierOffsets[Index];
8374 const unsigned char *StrLenPtr = (
const unsigned char*) Str - 2;
8375 unsigned StrLen = (((unsigned) StrLenPtr[0])
8376 | (((unsigned) StrLenPtr[1]) << 8)) - 1;
8377 auto &II = PP.getIdentifierTable().get(StringRef(Str, StrLen));
8378 IdentifiersLoaded[
ID] = &II;
8380 if (DeserializationListener)
8381 DeserializationListener->IdentifierRead(ID + 1, &II);
8384 return IdentifiersLoaded[
ID];
8388 return DecodeIdentifierInfo(getGlobalIdentifierID(M, LocalID));
8396 ReadModuleOffsetMap(M);
8401 &&
"Invalid index into identifier index remap");
8403 return LocalID + I->second;
8410 if (MacrosLoaded.empty()) {
8411 Error(
"no macro table in AST file");
8416 if (!MacrosLoaded[ID]) {
8419 assert(I != GlobalMacroMap.end() &&
"Corrupted global macro map");
8420 ModuleFile *M = I->second;
8421 unsigned Index = ID - M->BaseMacroID;
8422 MacrosLoaded[
ID] = ReadMacroRecord(*M, M->MacroOffsets[Index]);
8424 if (DeserializationListener)
8429 return MacrosLoaded[
ID];
8437 ReadModuleOffsetMap(M);
8441 assert(I != M.
MacroRemap.
end() &&
"Invalid index into macro index remap");
8443 return LocalID + I->second;
8452 ReadModuleOffsetMap(M);
8457 &&
"Invalid index into submodule index remap");
8459 return LocalID + I->second;
8464 assert(GlobalID == 0 &&
"Unhandled global submodule ID");
8468 if (GlobalID > SubmodulesLoaded.size()) {
8469 Error(
"submodule ID out of range in AST file");
8477 return getSubmodule(ID);
8481 ModuleFile *MF = getOwningModuleFile(D);
8488 auto I = GlobalSubmoduleMap.find(getGlobalSubmoduleID(F, ID >> 1));
8489 return I == GlobalSubmoduleMap.end() ? nullptr : I->second;
8492 unsigned IndexFromEnd = ID >> 1;
8493 assert(IndexFromEnd &&
"got reference to unknown module file");
8494 return getModuleManager().pch_modules().end()[-IndexFromEnd];
8509 auto PCHModules = getModuleManager().pch_modules();
8510 auto I = std::find(PCHModules.begin(), PCHModules.end(), F);
8511 assert(I != PCHModules.end() &&
"emitting reference to unknown file");
8512 return (I - PCHModules.end()) << 1;
8517 if (
const Module *M = getSubmodule(ID))
8522 const auto &PCHChain = ModuleMgr.pch_modules();
8523 if (
std::distance(std::begin(PCHChain), std::end(PCHChain))) {
8524 ModuleFile &MF = ModuleMgr.getPrimaryModule();
8526 StringRef FileName = llvm::sys::path::filename(MF.
FileName);
8534 auto I = DefinitionSource.find(FD);
8535 if (I == DefinitionSource.end())
8536 return EK_ReplyHazy;
8537 return I->second ? EK_Never : EK_Always;
8541 return DecodeSelector(getGlobalSelectorID(M, LocalID));
8548 if (ID > SelectorsLoaded.size()) {
8549 Error(
"selector ID out of range in AST file");
8553 if (SelectorsLoaded[ID - 1].getAsOpaquePtr() ==
nullptr) {
8556 assert(I != GlobalSelectorMap.end() &&
"Corrupted global selector map");
8557 ModuleFile &M = *I->second;
8560 SelectorsLoaded[ID - 1] =
8561 Trait.
ReadKey(M.SelectorLookupTableData + M.SelectorOffsets[Idx], 0);
8562 if (DeserializationListener)
8563 DeserializationListener->SelectorRead(ID, SelectorsLoaded[ID - 1]);
8566 return SelectorsLoaded[ID - 1];
8570 return DecodeSelector(ID);
8575 return getTotalNumSelectors() + 1;
8584 ReadModuleOffsetMap(M);
8589 &&
"Invalid index into selector index remap");
8591 return LocalID + I->second;
8618 ReadDeclAs<TemplateDecl>(F, Record, Idx));
8630 GetIdentifierInfo(F, Record, Idx));
8636 llvm_unreachable(
"Invalid NameKind!");
8652 = ReadSourceLocation(F, Record, Idx).getRawEncoding();
8654 = ReadSourceLocation(F, Record, Idx).getRawEncoding();
8659 = ReadSourceLocation(F, Record, Idx).getRawEncoding();
8675 NameInfo.
setName(ReadDeclarationName(F, Record, Idx));
8676 NameInfo.
setLoc(ReadSourceLocation(F, Record, Idx));
8678 ReadDeclarationNameLoc(F, DNLoc, NameInfo.
getName(), Record, Idx);
8684 Info.
QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
8685 unsigned NumTPLists = Record[Idx++];
8690 for (
unsigned i = 0; i != NumTPLists; ++i)
8702 return TemplateName(ReadDeclAs<TemplateDecl>(F, Record, Idx));
8705 unsigned size = Record[Idx++];
8708 Decls.
addDecl(ReadDeclAs<NamedDecl>(F, Record, Idx));
8715 bool hasTemplKeyword = Record[Idx++];
8716 TemplateDecl *Template = ReadDeclAs<TemplateDecl>(F, Record, Idx);
8724 GetIdentifierInfo(F, Record,
8732 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
8734 TemplateName replacement = ReadTemplateName(F, Record, Idx);
8740 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
8752 llvm_unreachable(
"Unhandled template name kind!");
8758 bool Canonicalize) {
8776 ValueDecl *D = ReadDeclAs<ValueDecl>(F, Record, Idx);
8782 llvm::APSInt
Value = ReadAPSInt(Record, Idx);
8783 QualType T = readType(F, Record, Idx);
8791 if (
unsigned NumExpansions = Record[Idx++])
8792 NumTemplateExpansions = NumExpansions - 1;
8798 unsigned NumArgs = Record[Idx++];
8800 for (
unsigned I = 0; I != NumArgs; ++I)
8801 Args[I] = ReadTemplateArgument(F, Record, Idx);
8806 llvm_unreachable(
"Unhandled template argument kind!");
8816 unsigned NumParams = Record[Idx++];
8818 Params.reserve(NumParams);
8820 Params.push_back(ReadDeclAs<NamedDecl>(F, Record, Idx));
8824 getContext(), TemplateLoc, LAngleLoc, Params, RAngleLoc,
nullptr);
8825 return TemplateParams;
8832 unsigned &Idx,
bool Canonicalize) {
8833 unsigned NumTemplateArgs = Record[Idx++];
8834 TemplArgs.reserve(NumTemplateArgs);
8835 while (NumTemplateArgs--)
8836 TemplArgs.push_back(ReadTemplateArgument(F, Record, Idx, Canonicalize));
8842 unsigned NumDecls = Record[Idx++];
8843 Set.
reserve(getContext(), NumDecls);
8844 while (NumDecls--) {
8845 DeclID ID = ReadDeclID(F, Record, Idx);
8854 bool isVirtual =
static_cast<bool>(Record[Idx++]);
8855 bool isBaseOfClass =
static_cast<bool>(Record[Idx++]);
8857 bool inheritConstructors =
static_cast<bool>(Record[Idx++]);
8859 SourceRange Range = ReadSourceRange(F, Record, Idx);
8871 unsigned NumInitializers = Record[Idx++];
8872 assert(NumInitializers &&
"wrote ctor initializers but have no inits");
8874 for (
unsigned i = 0; i != NumInitializers; ++i) {
8876 bool IsBaseVirtual =
false;
8883 TInfo = GetTypeSourceInfo(F, Record, Idx);
8884 IsBaseVirtual = Record[Idx++];
8888 TInfo = GetTypeSourceInfo(F, Record, Idx);
8892 Member = ReadDeclAs<FieldDecl>(F, Record, Idx);
8896 IndirectMember = ReadDeclAs<IndirectFieldDecl>(F, Record, Idx);
8900 SourceLocation MemberOrEllipsisLoc = ReadSourceLocation(F, Record, Idx);
8901 Expr *Init = ReadExpr(F);
8907 BOMInit =
new (Context)
8909 RParenLoc, MemberOrEllipsisLoc);
8911 BOMInit =
new (Context)
8914 BOMInit =
new (Context)
8918 BOMInit =
new (Context)
8920 LParenLoc, Init, RParenLoc);
8922 if (Record[Idx++]) {
8923 unsigned SourceOrder = Record[Idx++];
8927 CtorInitializers[i] = BOMInit;
8930 return CtorInitializers;
8937 unsigned N = Record[Idx++];
8939 for (
unsigned I = 0; I != N; ++I) {
8950 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
8963 const Type *T = readType(F, Record, Idx).getTypePtrOrNull();
8967 bool Template = Record[Idx++];
8978 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
8992 unsigned N = Record[Idx++];
8994 for (
unsigned I = 0; I != N; ++I) {
9000 SourceRange Range = ReadSourceRange(F, Record, Idx);
9006 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
9007 SourceRange Range = ReadSourceRange(F, Record, Idx);
9008 Builder.
Extend(Context, NS, Range.getBegin(), Range.getEnd());
9014 SourceRange Range = ReadSourceRange(F, Record, Idx);
9015 Builder.
Extend(Context, Alias, Range.getBegin(), Range.getEnd());
9021 bool Template = Record[Idx++];
9025 SourceLocation ColonColonLoc = ReadSourceLocation(F, Record, Idx);
9035 SourceLocation ColonColonLoc = ReadSourceLocation(F, Record, Idx);
9041 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
9042 SourceRange Range = ReadSourceRange(F, Record, Idx);
9043 Builder.
MakeSuper(Context, RD, Range.getBegin(), Range.getEnd());
9062 unsigned BitWidth = Record[Idx++];
9063 unsigned NumWords = llvm::APInt::getNumWords(BitWidth);
9064 llvm::APInt
Result(BitWidth, NumWords, &Record[Idx]);
9071 bool isUnsigned = Record[Idx++];
9072 return llvm::APSInt(ReadAPInt(Record, Idx), isUnsigned);
9077 const llvm::fltSemantics &Sem,
9079 return llvm::APFloat(Sem, ReadAPInt(Record, Idx));
9084 unsigned Len = Record[Idx++];
9085 std::string
Result(Record.data() + Idx, Record.data() + Idx + Len);
9092 std::string
Filename = ReadString(Record, Idx);
9093 ResolveImportedPath(F, Filename);
9099 unsigned Major = Record[Idx++];
9100 unsigned Minor = Record[Idx++];
9101 unsigned Subminor = Record[Idx++];
9103 return VersionTuple(Major);
9105 return VersionTuple(Major, Minor - 1);
9106 return VersionTuple(Major, Minor - 1, Subminor - 1);
9117 return Diag(CurrentImportLoc, DiagID);
9121 return Diags.Report(Loc, DiagID);
9127 return PP.getIdentifierTable();
9133 assert((*CurrSwitchCaseStmts)[ID] ==
nullptr &&
9134 "Already have a SwitchCase with this ID");
9135 (*CurrSwitchCaseStmts)[
ID] = SC;
9140 assert((*CurrSwitchCaseStmts)[ID] !=
nullptr &&
"No SwitchCase with this ID");
9141 return (*CurrSwitchCaseStmts)[
ID];
9145 CurrSwitchCaseStmts->clear();
9150 std::vector<RawComment *> Comments;
9153 I = CommentsCursors.begin(),
9154 E = CommentsCursors.end();
9157 BitstreamCursor &
Cursor = I->first;
9163 llvm::BitstreamEntry Entry =
9164 Cursor.advanceSkippingSubblocks(BitstreamCursor::AF_DontPopBlockAtEnd);
9166 switch (Entry.Kind) {
9167 case llvm::BitstreamEntry::SubBlock:
9169 Error(
"malformed block record in AST file");
9171 case llvm::BitstreamEntry::EndBlock:
9173 case llvm::BitstreamEntry::Record:
9186 bool IsTrailingComment = Record[Idx++];
9187 bool IsAlmostTrailingComment = Record[Idx++];
9189 SR, Kind, IsTrailingComment, IsAlmostTrailingComment));
9198 Context.
Comments.addDeserializedComments(Comments);
9203 bool IncludeSystem,
bool Complain,
9208 assert(NumUserInputs <= NumInputs);
9209 unsigned N = IncludeSystem ? NumInputs : NumUserInputs;
9210 for (
unsigned I = 0; I < N; ++I) {
9211 bool IsSystem = I >= NumUserInputs;
9212 InputFile IF = getInputFile(MF, I+1, Complain);
9213 Visitor(IF, IsSystem);
9219 llvm::function_ref<
void(
const FileEntry *FE)> Visitor) {
9221 for (
unsigned I = 0; I < NumInputs; ++I) {
9222 InputFileInfo IFI = readInputFileInfo(MF, I + 1);
9223 if (IFI.TopLevelModuleMap)
9225 if (
auto *FE = getInputFile(MF, I + 1).getFile())
9233 return M->getFullModuleName();
9236 if (ModuleFile *M = getOwningModuleFile(D))
9243 void ASTReader::finishPendingActions() {
9244 while (!PendingIdentifierInfos.empty() || !PendingFunctionTypes.empty() ||
9245 !PendingIncompleteDeclChains.empty() || !PendingDeclChains.empty() ||
9246 !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
9247 !PendingUpdateRecords.empty()) {
9250 using TopLevelDeclsMap =
9251 llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2>>;
9252 TopLevelDeclsMap TopLevelDecls;
9254 while (!PendingIdentifierInfos.empty()) {
9257 std::move(PendingIdentifierInfos.back().second);
9258 PendingIdentifierInfos.pop_back();
9260 SetGloballyVisibleDecls(II, DeclIDs, &TopLevelDecls[II]);
9265 for (
unsigned I = 0; I != PendingFunctionTypes.size(); ++I) {
9266 auto *FD = PendingFunctionTypes[I].first;
9267 FD->setType(GetType(PendingFunctionTypes[I].second));
9271 auto *DT = FD->getReturnType()->getContainedDeducedType();
9272 if (DT && DT->isDeduced())
9273 PendingDeducedTypeUpdates.insert(
9274 {FD->getCanonicalDecl(), FD->getReturnType()});
9276 PendingFunctionTypes.clear();
9280 for (
unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
9281 markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
9283 PendingIncompleteDeclChains.clear();
9286 for (
unsigned I = 0; I != PendingDeclChains.size(); ++I)
9287 loadPendingDeclChain(PendingDeclChains[I].first,
9288 PendingDeclChains[I].second);
9289 PendingDeclChains.clear();
9292 for (TopLevelDeclsMap::iterator TLD = TopLevelDecls.begin(),
9293 TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) {
9295 for (
unsigned I = 0, N = TLD->second.size(); I != N; ++I) {
9296 pushExternalDeclIntoScope(cast<NamedDecl>(TLD->second[I]), II);
9301 for (
unsigned I = 0; I != PendingMacroIDs.size(); ++I) {
9304 GlobalIDs.swap(PendingMacroIDs.begin()[I].second);
9306 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9308 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9309 if (!Info.M->isModule())
9310 resolvePendingMacro(II, Info);
9313 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9315 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9316 if (Info.M->isModule())
9317 resolvePendingMacro(II, Info);
9320 PendingMacroIDs.clear();
9324 while (!PendingDeclContextInfos.empty()) {
9325 PendingDeclContextInfo Info = PendingDeclContextInfos.front();
9326 PendingDeclContextInfos.pop_front();
9327 DeclContext *SemaDC = cast<DeclContext>(GetDecl(Info.SemaDC));
9328 DeclContext *LexicalDC = cast<DeclContext>(GetDecl(Info.LexicalDC));
9329 Info.D->setDeclContextsImpl(SemaDC, LexicalDC, getContext());
9333 while (!PendingUpdateRecords.empty()) {
9334 auto Update = PendingUpdateRecords.pop_back_val();
9335 ReadingKindTracker ReadingKind(Read_Decl, *
this);
9336 loadDeclUpdateRecords(
Update);
9342 assert(PendingFakeDefinitionData.empty() &&
9343 "faked up a class definition but never saw the real one");
9349 for (
Decl *D : PendingDefinitions) {
9350 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
9351 if (
const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) {
9356 if (
auto RD = dyn_cast<CXXRecordDecl>(D)) {
9357 for (
auto *R = getMostRecentExistingDecl(RD); R;
9358 R = R->getPreviousDecl()) {
9360 cast<CXXRecordDecl>(R)->isThisDeclarationADefinition() &&
9361 "declaration thinks it's the definition but it isn't");
9362 cast<CXXRecordDecl>(R)->DefinitionData = RD->DefinitionData;
9369 if (
auto ID = dyn_cast<ObjCInterfaceDecl>(D)) {
9374 for (
auto *R = getMostRecentExistingDecl(
ID); R; R = R->getPreviousDecl())
9375 cast<ObjCInterfaceDecl>(R)->Data =
ID->Data;
9380 if (
auto PD = dyn_cast<ObjCProtocolDecl>(D)) {
9381 for (
auto *R = getMostRecentExistingDecl(PD); R; R = R->getPreviousDecl())
9382 cast<ObjCProtocolDecl>(R)->Data = PD->Data;
9388 for (
auto *R = getMostRecentExistingDecl(RTD); R; R = R->getPreviousDecl())
9389 cast<RedeclarableTemplateDecl>(R)->Common = RTD->Common;
9391 PendingDefinitions.clear();
9397 for (PendingBodiesMap::iterator PB = PendingBodies.begin(),
9398 PBEnd = PendingBodies.end();
9399 PB != PBEnd; ++PB) {
9400 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
9410 if (
auto *RD = dyn_cast<CXXRecordDecl>(FD->getLexicalParent()))
9411 if (RD->isDependentContext() && !RD->isThisDeclarationADefinition())
9417 if (!getContext().getLangOpts().Modules || !FD->hasBody(Defn)) {
9421 mergeDefinitionVisibility(NonConstDefn, FD);
9423 if (!FD->isLateTemplateParsed() &&
9424 !NonConstDefn->isLateTemplateParsed() &&
9425 FD->getODRHash() != NonConstDefn->getODRHash()) {
9426 if (!isa<CXXMethodDecl>(FD)) {
9427 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
9428 }
else if (FD->getLexicalParent()->isFileContext() &&
9429 NonConstDefn->getLexicalParent()->isFileContext()) {
9433 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
9441 if (!getContext().getLangOpts().Modules || !MD->
hasBody())
9444 PendingBodies.clear();
9447 for (
auto *ND : PendingMergedDefinitionsToDeduplicate)
9448 getContext().deduplicateMergedDefinitonsFor(ND);
9449 PendingMergedDefinitionsToDeduplicate.clear();
9452 void ASTReader::diagnoseOdrViolations() {
9453 if (PendingOdrMergeFailures.empty() && PendingOdrMergeChecks.empty() &&
9454 PendingFunctionOdrMergeFailures.empty() &&
9455 PendingEnumOdrMergeFailures.empty())
9462 auto OdrMergeFailures = std::move(PendingOdrMergeFailures);
9463 PendingOdrMergeFailures.clear();
9464 for (
auto &Merge : OdrMergeFailures) {
9465 Merge.first->buildLookup();
9466 Merge.first->decls_begin();
9467 Merge.first->bases_begin();
9468 Merge.first->vbases_begin();
9469 for (
auto &RecordPair : Merge.second) {
9470 auto *RD = RecordPair.first;
9478 auto FunctionOdrMergeFailures = std::move(PendingFunctionOdrMergeFailures);
9479 PendingFunctionOdrMergeFailures.clear();
9480 for (
auto &Merge : FunctionOdrMergeFailures) {
9481 Merge.first->buildLookup();
9482 Merge.first->decls_begin();
9483 Merge.first->getBody();
9484 for (
auto &FD : Merge.second) {
9492 auto EnumOdrMergeFailures = std::move(PendingEnumOdrMergeFailures);
9493 PendingEnumOdrMergeFailures.clear();
9494 for (
auto &Merge : EnumOdrMergeFailures) {
9495 Merge.first->decls_begin();
9496 for (
auto &Enum : Merge.second) {
9497 Enum->decls_begin();
9507 while (!PendingOdrMergeChecks.empty()) {
9508 NamedDecl *D = PendingOdrMergeChecks.pop_back_val();
9522 for (
auto RI : D->
redecls()) {
9523 if (RI->getLexicalDeclContext() == CanonDef) {
9538 for (
auto *CanonMember : CanonDef->
decls()) {
9539 if (CanonMember->getCanonicalDecl() == DCanon) {
9548 if (
auto *ND = dyn_cast<NamedDecl>(CanonMember))
9550 Candidates.push_back(ND);
9556 if (!isa<TagDecl>(D))
9563 std::string CanonDefModule =
9564 getOwningModuleNameForDiagnostic(cast<Decl>(CanonDef));
9566 << D << getOwningModuleNameForDiagnostic(D)
9567 << CanonDef << CanonDefModule.empty() << CanonDefModule;
9569 if (Candidates.empty())
9570 Diag(cast<Decl>(CanonDef)->getLocation(),
9571 diag::note_module_odr_violation_no_possible_decls) << D;
9573 for (
unsigned I = 0, N = Candidates.size(); I != N; ++I)
9574 Diag(Candidates[I]->getLocation(),
9575 diag::note_module_odr_violation_possible_decl)
9579 DiagnosedOdrMergeFailures.insert(CanonDef);
9583 if (OdrMergeFailures.empty() && FunctionOdrMergeFailures.empty() &&
9584 EnumOdrMergeFailures.empty())
9593 auto ComputeQualTypeODRHash = [&Hash](
QualType Ty) {
9599 auto ComputeODRHash = [&Hash](
const Stmt *S) {
9606 auto ComputeSubDeclODRHash = [&Hash](
const Decl *D) {
9613 auto ComputeTemplateArgumentODRHash = [&Hash](
const TemplateArgument &TA) {
9619 auto ComputeTemplateParameterListODRHash =
9628 for (
auto &Merge : OdrMergeFailures) {
9631 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
9634 bool Diagnosed =
false;
9636 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstRecord);
9637 for (
auto &RecordPair : Merge.second) {
9641 if (FirstRecord == SecondRecord)
9644 std::string SecondModule = getOwningModuleNameForDiagnostic(SecondRecord);
9646 auto *FirstDD = FirstRecord->DefinitionData;
9647 auto *SecondDD = RecordPair.second;
9649 assert(FirstDD && SecondDD &&
"Definitions without DefinitionData");
9652 if (FirstDD != SecondDD) {
9653 enum ODRDefinitionDataDifference {
9660 auto ODRDiagError = [FirstRecord, &FirstModule,
9662 ODRDefinitionDataDifference DiffType) {
9663 return Diag(Loc, diag::err_module_odr_violation_definition_data)
9664 << FirstRecord << FirstModule.empty() << FirstModule << Range
9667 auto ODRDiagNote = [&SecondModule,
9669 ODRDefinitionDataDifference DiffType) {
9670 return Diag(Loc, diag::note_module_odr_violation_definition_data)
9671 << SecondModule << Range << DiffType;
9674 unsigned FirstNumBases = FirstDD->NumBases;
9675 unsigned FirstNumVBases = FirstDD->NumVBases;
9676 unsigned SecondNumBases = SecondDD->NumBases;
9677 unsigned SecondNumVBases = SecondDD->NumVBases;
9679 auto GetSourceRange = [](
struct CXXRecordDecl::DefinitionData *DD) {
9680 unsigned NumBases = DD->NumBases;
9682 auto bases = DD->bases();
9684 bases[NumBases - 1].getEndLoc());
9687 if (FirstNumBases != SecondNumBases) {
9688 ODRDiagError(FirstRecord->
getLocation(), GetSourceRange(FirstDD),
9691 ODRDiagNote(SecondRecord->
getLocation(), GetSourceRange(SecondDD),
9698 if (FirstNumVBases != SecondNumVBases) {
9699 ODRDiagError(FirstRecord->
getLocation(), GetSourceRange(FirstDD),
9702 ODRDiagNote(SecondRecord->
getLocation(), GetSourceRange(SecondDD),
9709 auto FirstBases = FirstDD->bases();
9710 auto SecondBases = SecondDD->bases();
9712 for (i = 0; i < FirstNumBases; ++i) {
9713 auto FirstBase = FirstBases[i];
9714 auto SecondBase = SecondBases[i];
9715 if (ComputeQualTypeODRHash(FirstBase.getType()) !=
9716 ComputeQualTypeODRHash(SecondBase.getType())) {
9717 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
9719 << (i + 1) << FirstBase.getType();
9721 SecondBase.getSourceRange(), BaseType)
9722 << (i + 1) << SecondBase.getType();
9726 if (FirstBase.isVirtual() != SecondBase.isVirtual()) {
9727 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
9729 << (i + 1) << FirstBase.isVirtual() << FirstBase.getType();
9731 SecondBase.getSourceRange(), BaseVirtual)
9732 << (i + 1) << SecondBase.isVirtual() << SecondBase.getType();
9736 if (FirstBase.getAccessSpecifierAsWritten() !=
9737 SecondBase.getAccessSpecifierAsWritten()) {
9738 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
9740 << (i + 1) << FirstBase.getType()
9741 << (int)FirstBase.getAccessSpecifierAsWritten();
9743 SecondBase.getSourceRange(), BaseAccess)
9744 << (i + 1) << SecondBase.getType()
9745 << (int)SecondBase.getAccessSpecifierAsWritten();
9750 if (i != FirstNumBases) {
9763 assert(!FirstTemplate == !SecondTemplate &&
9764 "Both pointers should be null or non-null");
9766 enum ODRTemplateDifference {
9769 ParamSingleDefaultArgument,
9770 ParamDifferentDefaultArgument,
9773 if (FirstTemplate && SecondTemplate) {
9774 DeclHashes FirstTemplateHashes;
9775 DeclHashes SecondTemplateHashes;
9777 auto PopulateTemplateParameterHashs =
9778 [&ComputeSubDeclODRHash](DeclHashes &Hashes,
9780 for (
auto *D : TD->getTemplateParameters()->asArray()) {
9781 Hashes.emplace_back(D, ComputeSubDeclODRHash(D));
9785 PopulateTemplateParameterHashs(FirstTemplateHashes, FirstTemplate);
9786 PopulateTemplateParameterHashs(SecondTemplateHashes, SecondTemplate);
9788 assert(FirstTemplateHashes.size() == SecondTemplateHashes.size() &&
9789 "Number of template parameters should be equal.");
9791 auto FirstIt = FirstTemplateHashes.begin();
9792 auto FirstEnd = FirstTemplateHashes.end();
9793 auto SecondIt = SecondTemplateHashes.begin();
9794 for (; FirstIt != FirstEnd; ++FirstIt, ++SecondIt) {
9795 if (FirstIt->second == SecondIt->second)
9798 auto ODRDiagError = [FirstRecord, &FirstModule,
9800 ODRTemplateDifference DiffType) {
9801 return Diag(Loc, diag::err_module_odr_violation_template_parameter)
9802 << FirstRecord << FirstModule.empty() << FirstModule << Range
9805 auto ODRDiagNote = [&SecondModule,
9807 ODRTemplateDifference DiffType) {
9808 return Diag(Loc, diag::note_module_odr_violation_template_parameter)
9809 << SecondModule << Range << DiffType;
9812 const NamedDecl* FirstDecl = cast<NamedDecl>(FirstIt->first);
9813 const NamedDecl* SecondDecl = cast<NamedDecl>(SecondIt->first);
9815 assert(FirstDecl->
getKind() == SecondDecl->getKind() &&
9816 "Parameter Decl's should be the same kind.");
9821 if (FirstName != SecondName) {
9822 const bool FirstNameEmpty =
9823 FirstName.
isIdentifier() && !FirstName.getAsIdentifierInfo();
9824 const bool SecondNameEmpty =
9826 assert((!FirstNameEmpty || !SecondNameEmpty) &&
9827 "Both template parameters cannot be unnamed.");
9829 FirstNameEmpty ? ParamEmptyName : ParamName)
9831 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9832 SecondNameEmpty ? ParamEmptyName : ParamName)
9837 switch (FirstDecl->
getKind()) {
9839 llvm_unreachable(
"Invalid template parameter type.");
9840 case Decl::TemplateTypeParm: {
9841 const auto *FirstParam = cast<TemplateTypeParmDecl>(FirstDecl);
9842 const auto *SecondParam = cast<TemplateTypeParmDecl>(SecondDecl);
9843 const bool HasFirstDefaultArgument =
9844 FirstParam->hasDefaultArgument() &&
9845 !FirstParam->defaultArgumentWasInherited();
9846 const bool HasSecondDefaultArgument =
9847 SecondParam->hasDefaultArgument() &&
9848 !SecondParam->defaultArgumentWasInherited();
9850 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9853 ParamSingleDefaultArgument)
9854 << HasFirstDefaultArgument;
9855 ODRDiagNote(SecondDecl->getLocation(),
9856 SecondDecl->getSourceRange(),
9857 ParamSingleDefaultArgument)
9858 << HasSecondDefaultArgument;
9862 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9863 "Expecting default arguments.");
9866 ParamDifferentDefaultArgument);
9867 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9868 ParamDifferentDefaultArgument);
9872 case Decl::NonTypeTemplateParm: {
9873 const auto *FirstParam = cast<NonTypeTemplateParmDecl>(FirstDecl);
9874 const auto *SecondParam = cast<NonTypeTemplateParmDecl>(SecondDecl);
9875 const bool HasFirstDefaultArgument =
9876 FirstParam->hasDefaultArgument() &&
9877 !FirstParam->defaultArgumentWasInherited();
9878 const bool HasSecondDefaultArgument =
9879 SecondParam->hasDefaultArgument() &&
9880 !SecondParam->defaultArgumentWasInherited();
9882 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9885 ParamSingleDefaultArgument)
9886 << HasFirstDefaultArgument;
9887 ODRDiagNote(SecondDecl->getLocation(),
9888 SecondDecl->getSourceRange(),
9889 ParamSingleDefaultArgument)
9890 << HasSecondDefaultArgument;
9894 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9895 "Expecting default arguments.");
9898 ParamDifferentDefaultArgument);
9899 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9900 ParamDifferentDefaultArgument);
9904 case Decl::TemplateTemplateParm: {
9905 const auto *FirstParam = cast<TemplateTemplateParmDecl>(FirstDecl);
9906 const auto *SecondParam =
9907 cast<TemplateTemplateParmDecl>(SecondDecl);
9908 const bool HasFirstDefaultArgument =
9909 FirstParam->hasDefaultArgument() &&
9910 !FirstParam->defaultArgumentWasInherited();
9911 const bool HasSecondDefaultArgument =
9912 SecondParam->hasDefaultArgument() &&
9913 !SecondParam->defaultArgumentWasInherited();
9915 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9918 ParamSingleDefaultArgument)
9919 << HasFirstDefaultArgument;
9920 ODRDiagNote(SecondDecl->getLocation(),
9921 SecondDecl->getSourceRange(),
9922 ParamSingleDefaultArgument)
9923 << HasSecondDefaultArgument;
9927 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9928 "Expecting default arguments.");
9931 ParamDifferentDefaultArgument);
9932 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9933 ParamDifferentDefaultArgument);
9942 if (FirstIt != FirstEnd) {
9948 DeclHashes FirstHashes;
9949 DeclHashes SecondHashes;
9951 auto PopulateHashes = [&ComputeSubDeclODRHash, FirstRecord](
9953 for (
auto *D : Record->decls()) {
9958 Hashes.emplace_back(D, ComputeSubDeclODRHash(D));
9961 PopulateHashes(FirstHashes, FirstRecord);
9962 PopulateHashes(SecondHashes, SecondRecord);
9981 } FirstDiffType = Other,
9982 SecondDiffType = Other;
9984 auto DifferenceSelector = [](
Decl *D) {
9985 assert(D &&
"valid Decl required");
9989 case Decl::AccessSpec:
9992 return PublicSpecifer;
9994 return PrivateSpecifer;
9996 return ProtectedSpecifer;
10000 llvm_unreachable(
"Invalid access specifier");
10001 case Decl::StaticAssert:
10002 return StaticAssert;
10005 case Decl::CXXMethod:
10006 case Decl::CXXConstructor:
10007 case Decl::CXXDestructor:
10009 case Decl::TypeAlias:
10011 case Decl::Typedef:
10017 case Decl::FunctionTemplate:
10018 return FunctionTemplate;
10022 Decl *FirstDecl =
nullptr;
10023 Decl *SecondDecl =
nullptr;
10024 auto FirstIt = FirstHashes.begin();
10025 auto SecondIt = SecondHashes.begin();
10030 while (FirstIt != FirstHashes.end() || SecondIt != SecondHashes.end()) {
10031 if (FirstIt != FirstHashes.end() && SecondIt != SecondHashes.end() &&
10032 FirstIt->second == SecondIt->second) {
10038 FirstDecl = FirstIt == FirstHashes.end() ? nullptr : FirstIt->first;
10039 SecondDecl = SecondIt == SecondHashes.end() ? nullptr : SecondIt->first;
10041 FirstDiffType = FirstDecl ? DifferenceSelector(FirstDecl) : EndOfClass;
10043 SecondDecl ? DifferenceSelector(SecondDecl) : EndOfClass;
10048 if (FirstDiffType == Other || SecondDiffType == Other) {
10053 diag::err_module_odr_violation_different_definitions)
10054 << FirstRecord << FirstModule.empty() << FirstModule;
10062 diag::note_module_odr_violation_different_definitions)
10074 if (FirstDiffType != SecondDiffType) {
10077 if (FirstDiffType == EndOfClass) {
10080 FirstLoc = FirstIt->first->getLocation();
10081 FirstRange = FirstIt->first->getSourceRange();
10083 Diag(FirstLoc, diag::err_module_odr_violation_mismatch_decl)
10084 << FirstRecord << FirstModule.empty() << FirstModule << FirstRange
10089 if (SecondDiffType == EndOfClass) {
10095 Diag(SecondLoc, diag::note_module_odr_violation_mismatch_decl)
10096 << SecondModule << SecondRange << SecondDiffType;
10101 assert(FirstDiffType == SecondDiffType);
10105 enum ODRDeclDifference {
10106 StaticAssertCondition,
10107 StaticAssertMessage,
10108 StaticAssertOnlyMessage,
10111 FieldSingleBitField,
10112 FieldDifferentWidthBitField,
10113 FieldSingleMutable,
10114 FieldSingleInitializer,
10115 FieldDifferentInitializers,
10124 MethodNumberParameters,
10125 MethodParameterType,
10126 MethodParameterName,
10127 MethodParameterSingleDefaultArgument,
10128 MethodParameterDifferentDefaultArgument,
10129 MethodNoTemplateArguments,
10130 MethodDifferentNumberTemplateArguments,
10131 MethodDifferentTemplateArgument,
10133 MethodDifferentBody,
10138 VarSingleInitializer,
10139 VarDifferentInitializer,
10141 FriendTypeFunction,
10144 FunctionTemplateDifferentNumberParameters,
10145 FunctionTemplateParameterDifferentKind,
10146 FunctionTemplateParameterName,
10147 FunctionTemplateParameterSingleDefaultArgument,
10148 FunctionTemplateParameterDifferentDefaultArgument,
10149 FunctionTemplateParameterDifferentType,
10150 FunctionTemplatePackParameter,
10156 auto ODRDiagError = [FirstRecord, &FirstModule,
this](
10158 return Diag(Loc, diag::err_module_odr_violation_mismatch_decl_diff)
10159 << FirstRecord << FirstModule.empty() << FirstModule << Range
10162 auto ODRDiagNote = [&SecondModule,
this](
10164 return Diag(Loc, diag::note_module_odr_violation_mismatch_decl_diff)
10165 << SecondModule << Range << DiffType;
10168 switch (FirstDiffType) {
10171 case PublicSpecifer:
10172 case PrivateSpecifer:
10173 case ProtectedSpecifer:
10174 llvm_unreachable(
"Invalid diff type");
10176 case StaticAssert: {
10181 Expr *SecondExpr = SecondSA->getAssertExpr();
10182 unsigned FirstODRHash = ComputeODRHash(FirstExpr);
10183 unsigned SecondODRHash = ComputeODRHash(SecondExpr);
10184 if (FirstODRHash != SecondODRHash) {
10185 ODRDiagError(FirstExpr->getBeginLoc(), FirstExpr->getSourceRange(),
10186 StaticAssertCondition);
10188 StaticAssertCondition);
10195 assert((FirstStr || SecondStr) &&
"Both messages cannot be empty");
10196 if ((FirstStr && !SecondStr) || (!FirstStr && SecondStr)) {
10210 SecondLoc = SecondSA->getBeginLoc();
10211 SecondRange = SecondSA->getSourceRange();
10213 ODRDiagError(FirstLoc, FirstRange, StaticAssertOnlyMessage)
10214 << (FirstStr ==
nullptr);
10215 ODRDiagNote(SecondLoc, SecondRange, StaticAssertOnlyMessage)
10216 << (SecondStr ==
nullptr);
10221 if (FirstStr && SecondStr &&
10224 StaticAssertMessage);
10226 StaticAssertMessage);
10233 FieldDecl *FirstField = cast<FieldDecl>(FirstDecl);
10234 FieldDecl *SecondField = cast<FieldDecl>(SecondDecl);
10237 if (FirstII->getName() != SecondII->
getName()) {
10241 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10249 assert(getContext().hasSameType(FirstField->
getType(),
10250 SecondField->getType()));
10253 QualType SecondType = SecondField->getType();
10254 if (ComputeQualTypeODRHash(FirstType) !=
10255 ComputeQualTypeODRHash(SecondType)) {
10258 << FirstII << FirstType;
10259 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10261 << SecondII << SecondType;
10267 const bool IsFirstBitField = FirstField->
isBitField();
10268 const bool IsSecondBitField = SecondField->isBitField();
10269 if (IsFirstBitField != IsSecondBitField) {
10271 FieldSingleBitField)
10272 << FirstII << IsFirstBitField;
10273 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10274 FieldSingleBitField)
10275 << SecondII << IsSecondBitField;
10280 if (IsFirstBitField && IsSecondBitField) {
10282 FieldDifferentWidthBitField)
10284 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10285 FieldDifferentWidthBitField)
10286 << SecondII << SecondField->getBitWidth()->getSourceRange();
10291 const bool IsFirstMutable = FirstField->
isMutable();
10292 const bool IsSecondMutable = SecondField->isMutable();
10293 if (IsFirstMutable != IsSecondMutable) {
10295 FieldSingleMutable)
10296 << FirstII << IsFirstMutable;
10297 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10298 FieldSingleMutable)
10299 << SecondII << IsSecondMutable;
10305 const Expr *SecondInitializer = SecondField->getInClassInitializer();
10306 if ((!FirstInitializer && SecondInitializer) ||
10307 (FirstInitializer && !SecondInitializer)) {
10309 FieldSingleInitializer)
10310 << FirstII << (FirstInitializer !=
nullptr);
10311 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10312 FieldSingleInitializer)
10313 << SecondII << (SecondInitializer !=
nullptr);
10318 if (FirstInitializer && SecondInitializer) {
10319 unsigned FirstInitHash = ComputeODRHash(FirstInitializer);
10320 unsigned SecondInitHash = ComputeODRHash(SecondInitializer);
10321 if (FirstInitHash != SecondInitHash) {
10324 FieldDifferentInitializers)
10326 ODRDiagNote(SecondField->getLocation(),
10327 SecondField->getSourceRange(),
10328 FieldDifferentInitializers)
10344 auto GetMethodTypeForDiagnostics = [](
const CXXMethodDecl* D) {
10345 if (isa<CXXConstructorDecl>(D))
return DiagConstructor;
10346 if (isa<CXXDestructorDecl>(D))
return DiagDestructor;
10349 const CXXMethodDecl *FirstMethod = cast<CXXMethodDecl>(FirstDecl);
10350 const CXXMethodDecl *SecondMethod = cast<CXXMethodDecl>(SecondDecl);
10351 FirstMethodType = GetMethodTypeForDiagnostics(FirstMethod);
10352 SecondMethodType = GetMethodTypeForDiagnostics(SecondMethod);
10354 auto SecondName = SecondMethod->getDeclName();
10355 if (FirstMethodType != SecondMethodType || FirstName != SecondName) {
10358 << FirstMethodType << FirstName;
10359 ODRDiagNote(SecondMethod->getLocation(),
10360 SecondMethod->getSourceRange(), MethodName)
10361 << SecondMethodType << SecondName;
10368 const bool SecondDeleted = SecondMethod->isDeletedAsWritten();
10369 if (FirstDeleted != SecondDeleted) {
10372 << FirstMethodType << FirstName << FirstDeleted;
10374 ODRDiagNote(SecondMethod->getLocation(),
10375 SecondMethod->getSourceRange(), MethodDeleted)
10376 << SecondMethodType << SecondName << SecondDeleted;
10382 const bool SecondDefaulted = SecondMethod->isExplicitlyDefaulted();
10383 if (FirstDefaulted != SecondDefaulted) {
10386 << FirstMethodType << FirstName << FirstDefaulted;
10388 ODRDiagNote(SecondMethod->getLocation(),
10389 SecondMethod->getSourceRange(), MethodDefaulted)
10390 << SecondMethodType << SecondName << SecondDefaulted;
10396 const bool SecondVirtual = SecondMethod->isVirtualAsWritten();
10397 const bool FirstPure = FirstMethod->
isPure();
10398 const bool SecondPure = SecondMethod->isPure();
10399 if ((FirstVirtual || SecondVirtual) &&
10400 (FirstVirtual != SecondVirtual || FirstPure != SecondPure)) {
10403 << FirstMethodType << FirstName << FirstPure << FirstVirtual;
10404 ODRDiagNote(SecondMethod->getLocation(),
10405 SecondMethod->getSourceRange(), MethodVirtual)
10406 << SecondMethodType << SecondName << SecondPure << SecondVirtual;
10415 const auto SecondStorage = SecondMethod->getStorageClass();
10416 const bool FirstStatic = FirstStorage ==
SC_Static;
10417 const bool SecondStatic = SecondStorage ==
SC_Static;
10418 if (FirstStatic != SecondStatic) {
10421 << FirstMethodType << FirstName << FirstStatic;
10422 ODRDiagNote(SecondMethod->getLocation(),
10423 SecondMethod->getSourceRange(), MethodStatic)
10424 << SecondMethodType << SecondName << SecondStatic;
10429 const bool FirstVolatile = FirstMethod->
isVolatile();
10430 const bool SecondVolatile = SecondMethod->isVolatile();
10431 if (FirstVolatile != SecondVolatile) {
10434 << FirstMethodType << FirstName << FirstVolatile;
10435 ODRDiagNote(SecondMethod->getLocation(),
10436 SecondMethod->getSourceRange(), MethodVolatile)
10437 << SecondMethodType << SecondName << SecondVolatile;
10442 const bool FirstConst = FirstMethod->
isConst();
10443 const bool SecondConst = SecondMethod->isConst();
10444 if (FirstConst != SecondConst) {
10447 << FirstMethodType << FirstName << FirstConst;
10448 ODRDiagNote(SecondMethod->getLocation(),
10449 SecondMethod->getSourceRange(), MethodConst)
10450 << SecondMethodType << SecondName << SecondConst;
10456 const bool SecondInline = SecondMethod->isInlineSpecified();
10457 if (FirstInline != SecondInline) {
10460 << FirstMethodType << FirstName << FirstInline;
10461 ODRDiagNote(SecondMethod->getLocation(),
10462 SecondMethod->getSourceRange(), MethodInline)
10463 << SecondMethodType << SecondName << SecondInline;
10468 const unsigned FirstNumParameters = FirstMethod->
param_size();
10469 const unsigned SecondNumParameters = SecondMethod->param_size();
10470 if (FirstNumParameters != SecondNumParameters) {
10473 << FirstMethodType << FirstName << FirstNumParameters;
10474 ODRDiagNote(SecondMethod->getLocation(),
10475 SecondMethod->getSourceRange(), MethodNumberParameters)
10476 << SecondMethodType << SecondName << SecondNumParameters;
10482 bool ParameterMismatch =
false;
10483 for (
unsigned I = 0; I < FirstNumParameters; ++I) {
10485 const ParmVarDecl *SecondParam = SecondMethod->getParamDecl(I);
10489 if (FirstParamType != SecondParamType &&
10490 ComputeQualTypeODRHash(FirstParamType) !=
10491 ComputeQualTypeODRHash(SecondParamType)) {
10496 << FirstMethodType << FirstName << (I + 1) << FirstParamType
10497 <<
true << ParamDecayedType->getOriginalType();
10501 << FirstMethodType << FirstName << (I + 1) << FirstParamType
10507 ODRDiagNote(SecondMethod->getLocation(),
10508 SecondMethod->getSourceRange(), MethodParameterType)
10509 << SecondMethodType << SecondName << (I + 1)
10510 << SecondParamType <<
true 10511 << ParamDecayedType->getOriginalType();
10513 ODRDiagNote(SecondMethod->getLocation(),
10514 SecondMethod->getSourceRange(), MethodParameterType)
10515 << SecondMethodType << SecondName << (I + 1)
10516 << SecondParamType <<
false;
10518 ParameterMismatch =
true;
10524 if (FirstParamName != SecondParamName) {
10527 << FirstMethodType << FirstName << (I + 1) << FirstParamName;
10528 ODRDiagNote(SecondMethod->getLocation(),
10529 SecondMethod->getSourceRange(), MethodParameterName)
10530 << SecondMethodType << SecondName << (I + 1) << SecondParamName;
10531 ParameterMismatch =
true;
10537 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
10540 MethodParameterSingleDefaultArgument)
10541 << FirstMethodType << FirstName << (I + 1)
10542 << (FirstInit ==
nullptr)
10544 ODRDiagNote(SecondMethod->getLocation(),
10545 SecondMethod->getSourceRange(),
10546 MethodParameterSingleDefaultArgument)
10547 << SecondMethodType << SecondName << (I + 1)
10548 << (SecondInit ==
nullptr)
10550 ParameterMismatch =
true;
10554 if (FirstInit && SecondInit &&
10555 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
10558 MethodParameterDifferentDefaultArgument)
10559 << FirstMethodType << FirstName << (I + 1)
10561 ODRDiagNote(SecondMethod->getLocation(),
10562 SecondMethod->getSourceRange(),
10563 MethodParameterDifferentDefaultArgument)
10564 << SecondMethodType << SecondName << (I + 1)
10566 ParameterMismatch =
true;
10572 if (ParameterMismatch) {
10577 const auto *FirstTemplateArgs =
10579 const auto *SecondTemplateArgs =
10580 SecondMethod->getTemplateSpecializationArgs();
10582 if ((FirstTemplateArgs && !SecondTemplateArgs) ||
10583 (!FirstTemplateArgs && SecondTemplateArgs)) {
10586 << FirstMethodType << FirstName << (FirstTemplateArgs !=
nullptr);
10587 ODRDiagNote(SecondMethod->getLocation(),
10588 SecondMethod->getSourceRange(), MethodNoTemplateArguments)
10589 << SecondMethodType << SecondName
10590 << (SecondTemplateArgs !=
nullptr);
10596 if (FirstTemplateArgs && SecondTemplateArgs) {
10598 auto ExpandTemplateArgumentList =
10603 ExpandedList.push_back(&TA);
10607 ExpandedList.push_back(&PackTA);
10610 return ExpandedList;
10613 ExpandTemplateArgumentList(FirstTemplateArgs);
10615 ExpandTemplateArgumentList(SecondTemplateArgs);
10617 if (FirstExpandedList.size() != SecondExpandedList.size()) {
10620 MethodDifferentNumberTemplateArguments)
10621 << FirstMethodType << FirstName
10622 << (
unsigned)FirstExpandedList.size();
10623 ODRDiagNote(SecondMethod->getLocation(),
10624 SecondMethod->getSourceRange(),
10625 MethodDifferentNumberTemplateArguments)
10626 << SecondMethodType << SecondName
10627 << (
unsigned)SecondExpandedList.size();
10633 bool TemplateArgumentMismatch =
false;
10634 for (
unsigned i = 0, e = FirstExpandedList.size(); i != e; ++i) {
10636 &SecondTA = *SecondExpandedList[i];
10637 if (ComputeTemplateArgumentODRHash(FirstTA) ==
10638 ComputeTemplateArgumentODRHash(SecondTA)) {
10644 MethodDifferentTemplateArgument)
10645 << FirstMethodType << FirstName << FirstTA << i + 1;
10646 ODRDiagNote(SecondMethod->getLocation(),
10647 SecondMethod->getSourceRange(),
10648 MethodDifferentTemplateArgument)
10649 << SecondMethodType << SecondName << SecondTA << i + 1;
10651 TemplateArgumentMismatch =
true;
10655 if (TemplateArgumentMismatch) {
10662 auto ComputeCXXMethodODRHash = [&Hash](
const CXXMethodDecl *D) {
10671 const bool HasFirstBody =
10672 ComputeCXXMethodODRHash(FirstMethod) != FirstMethod->
getODRHash();
10673 const bool HasSecondBody =
10674 ComputeCXXMethodODRHash(SecondMethod) != SecondMethod->getODRHash();
10676 if (HasFirstBody != HasSecondBody) {
10679 << FirstMethodType << FirstName << HasFirstBody;
10680 ODRDiagNote(SecondMethod->getLocation(),
10681 SecondMethod->getSourceRange(), MethodSingleBody)
10682 << SecondMethodType << SecondName << HasSecondBody;
10687 if (HasFirstBody && HasSecondBody) {
10690 << FirstMethodType << FirstName;
10691 ODRDiagNote(SecondMethod->getLocation(),
10692 SecondMethod->getSourceRange(), MethodDifferentBody)
10693 << SecondMethodType << SecondName;
10705 auto SecondName = SecondTD->getDeclName();
10706 if (FirstName != SecondName) {
10709 << (FirstDiffType == TypeAlias) << FirstName;
10710 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
10712 << (FirstDiffType == TypeAlias) << SecondName;
10718 QualType SecondType = SecondTD->getUnderlyingType();
10719 if (ComputeQualTypeODRHash(FirstType) !=
10720 ComputeQualTypeODRHash(SecondType)) {
10723 << (FirstDiffType == TypeAlias) << FirstName << FirstType;
10724 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
10726 << (FirstDiffType == TypeAlias) << SecondName << SecondType;
10733 VarDecl *FirstVD = cast<VarDecl>(FirstDecl);
10734 VarDecl *SecondVD = cast<VarDecl>(SecondDecl);
10736 auto SecondName = SecondVD->getDeclName();
10737 if (FirstName != SecondName) {
10741 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10749 QualType SecondType = SecondVD->getType();
10750 if (ComputeQualTypeODRHash(FirstType) !=
10751 ComputeQualTypeODRHash(SecondType)) {
10754 << FirstName << FirstType;
10755 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10757 << SecondName << SecondType;
10763 const Expr *SecondInit = SecondVD->getInit();
10764 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
10766 VarSingleInitializer)
10767 << FirstName << (FirstInit ==
nullptr)
10769 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10770 VarSingleInitializer)
10771 << SecondName << (SecondInit ==
nullptr)
10777 if (FirstInit && SecondInit &&
10778 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
10780 VarDifferentInitializer)
10782 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10783 VarDifferentInitializer)
10789 const bool FirstIsConstexpr = FirstVD->
isConstexpr();
10790 const bool SecondIsConstexpr = SecondVD->isConstexpr();
10791 if (FirstIsConstexpr != SecondIsConstexpr) {
10794 << FirstName << FirstIsConstexpr;
10795 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10797 << SecondName << SecondIsConstexpr;
10804 FriendDecl *FirstFriend = cast<FriendDecl>(FirstDecl);
10805 FriendDecl *SecondFriend = cast<FriendDecl>(SecondDecl);
10808 NamedDecl *SecondND = SecondFriend->getFriendDecl();
10813 if (FirstND && SecondND) {
10817 ODRDiagNote(SecondFriend->getFriendLoc(),
10818 SecondFriend->getSourceRange(), FriendFunction)
10825 if (FirstTSI && SecondTSI) {
10828 assert(ComputeQualTypeODRHash(FirstFriendType) !=
10829 ComputeQualTypeODRHash(SecondFriendType));
10832 << FirstFriendType;
10833 ODRDiagNote(SecondFriend->getFriendLoc(),
10834 SecondFriend->getSourceRange(), FriendType)
10835 << SecondFriendType;
10841 FriendTypeFunction)
10842 << (FirstTSI ==
nullptr);
10843 ODRDiagNote(SecondFriend->getFriendLoc(),
10844 SecondFriend->getSourceRange(), FriendTypeFunction)
10845 << (SecondTSI ==
nullptr);
10850 case FunctionTemplate: {
10852 cast<FunctionTemplateDecl>(FirstDecl);
10854 cast<FunctionTemplateDecl>(SecondDecl);
10859 SecondTemplate->getTemplateParameters();
10861 if (FirstTPL->size() != SecondTPL->
size()) {
10864 FunctionTemplateDifferentNumberParameters)
10865 << FirstTemplate << FirstTPL->size();
10866 ODRDiagNote(SecondTemplate->getLocation(),
10867 SecondTemplate->getSourceRange(),
10868 FunctionTemplateDifferentNumberParameters)
10869 << SecondTemplate << SecondTPL->
size();
10875 bool ParameterMismatch =
false;
10876 for (
unsigned i = 0, e = FirstTPL->size(); i != e; ++i) {
10877 NamedDecl *FirstParam = FirstTPL->getParam(i);
10882 TemplateTypeParameter,
10883 NonTypeTemplateParameter,
10884 TemplateTemplateParameter,
10889 llvm_unreachable(
"Unexpected template parameter type");
10890 case Decl::TemplateTypeParm:
10891 return TemplateTypeParameter;
10892 case Decl::NonTypeTemplateParm:
10893 return NonTypeTemplateParameter;
10894 case Decl::TemplateTemplateParm:
10895 return TemplateTemplateParameter;
10901 FunctionTemplateParameterDifferentKind)
10902 << FirstTemplate << (i + 1) << GetParamType(FirstParam);
10903 ODRDiagNote(SecondTemplate->getLocation(),
10904 SecondTemplate->getSourceRange(),
10905 FunctionTemplateParameterDifferentKind)
10906 << SecondTemplate << (i + 1) << GetParamType(SecondParam);
10908 ParameterMismatch =
true;
10915 FunctionTemplateParameterName)
10918 ODRDiagNote(SecondTemplate->getLocation(),
10919 SecondTemplate->getSourceRange(),
10920 FunctionTemplateParameterName)
10921 << SecondTemplate << (i + 1)
10923 ParameterMismatch =
true;
10927 if (isa<TemplateTypeParmDecl>(FirstParam) &&
10928 isa<TemplateTypeParmDecl>(SecondParam)) {
10930 cast<TemplateTypeParmDecl>(FirstParam);
10932 cast<TemplateTypeParmDecl>(SecondParam);
10933 bool HasFirstDefaultArgument =
10936 bool HasSecondDefaultArgument =
10937 SecondTTPD->hasDefaultArgument() &&
10938 !SecondTTPD->defaultArgumentWasInherited();
10939 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
10942 FunctionTemplateParameterSingleDefaultArgument)
10943 << FirstTemplate << (i + 1) << HasFirstDefaultArgument;
10944 ODRDiagNote(SecondTemplate->getLocation(),
10945 SecondTemplate->getSourceRange(),
10946 FunctionTemplateParameterSingleDefaultArgument)
10947 << SecondTemplate << (i + 1) << HasSecondDefaultArgument;
10948 ParameterMismatch =
true;
10952 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
10954 QualType SecondType = SecondTTPD->getDefaultArgument();
10955 if (ComputeQualTypeODRHash(FirstType) !=
10956 ComputeQualTypeODRHash(SecondType)) {
10959 FunctionTemplateParameterDifferentDefaultArgument)
10960 << FirstTemplate << (i + 1) << FirstType;
10961 ODRDiagNote(SecondTemplate->getLocation(),
10962 SecondTemplate->getSourceRange(),
10963 FunctionTemplateParameterDifferentDefaultArgument)
10964 << SecondTemplate << (i + 1) << SecondType;
10965 ParameterMismatch =
true;
10971 SecondTTPD->isParameterPack()) {
10974 FunctionTemplatePackParameter)
10976 ODRDiagNote(SecondTemplate->getLocation(),
10977 SecondTemplate->getSourceRange(),
10978 FunctionTemplatePackParameter)
10979 << SecondTemplate << (i + 1) << SecondTTPD->isParameterPack();
10980 ParameterMismatch =
true;
10985 if (isa<TemplateTemplateParmDecl>(FirstParam) &&
10986 isa<TemplateTemplateParmDecl>(SecondParam)) {
10988 cast<TemplateTemplateParmDecl>(FirstParam);
10990 cast<TemplateTemplateParmDecl>(SecondParam);
10995 SecondTTPD->getTemplateParameters();
10997 if (ComputeTemplateParameterListODRHash(FirstTPL) !=
10998 ComputeTemplateParameterListODRHash(SecondTPL)) {
11001 FunctionTemplateParameterDifferentType)
11002 << FirstTemplate << (i + 1);
11003 ODRDiagNote(SecondTemplate->getLocation(),
11004 SecondTemplate->getSourceRange(),
11005 FunctionTemplateParameterDifferentType)
11006 << SecondTemplate << (i + 1);
11007 ParameterMismatch =
true;
11011 bool HasFirstDefaultArgument =
11014 bool HasSecondDefaultArgument =
11015 SecondTTPD->hasDefaultArgument() &&
11016 !SecondTTPD->defaultArgumentWasInherited();
11017 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
11020 FunctionTemplateParameterSingleDefaultArgument)
11021 << FirstTemplate << (i + 1) << HasFirstDefaultArgument;
11022 ODRDiagNote(SecondTemplate->getLocation(),
11023 SecondTemplate->getSourceRange(),
11024 FunctionTemplateParameterSingleDefaultArgument)
11025 << SecondTemplate << (i + 1) << HasSecondDefaultArgument;
11026 ParameterMismatch =
true;
11030 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
11034 SecondTTPD->getDefaultArgument().getArgument();
11035 if (ComputeTemplateArgumentODRHash(FirstTA) !=
11036 ComputeTemplateArgumentODRHash(SecondTA)) {
11039 FunctionTemplateParameterDifferentDefaultArgument)
11040 << FirstTemplate << (i + 1) << FirstTA;
11041 ODRDiagNote(SecondTemplate->getLocation(),
11042 SecondTemplate->getSourceRange(),
11043 FunctionTemplateParameterDifferentDefaultArgument)
11044 << SecondTemplate << (i + 1) << SecondTA;
11045 ParameterMismatch =
true;
11051 SecondTTPD->isParameterPack()) {
11054 FunctionTemplatePackParameter)
11056 ODRDiagNote(SecondTemplate->getLocation(),
11057 SecondTemplate->getSourceRange(),
11058 FunctionTemplatePackParameter)
11059 << SecondTemplate << (i + 1) << SecondTTPD->isParameterPack();
11060 ParameterMismatch =
true;
11065 if (isa<NonTypeTemplateParmDecl>(FirstParam) &&
11066 isa<NonTypeTemplateParmDecl>(SecondParam)) {
11068 cast<NonTypeTemplateParmDecl>(FirstParam);
11070 cast<NonTypeTemplateParmDecl>(SecondParam);
11073 QualType SecondType = SecondNTTPD->getType();
11074 if (ComputeQualTypeODRHash(FirstType) !=
11075 ComputeQualTypeODRHash(SecondType)) {
11078 FunctionTemplateParameterDifferentType)
11079 << FirstTemplate << (i + 1);
11080 ODRDiagNote(SecondTemplate->getLocation(),
11081 SecondTemplate->getSourceRange(),
11082 FunctionTemplateParameterDifferentType)
11083 << SecondTemplate << (i + 1);
11084 ParameterMismatch =
true;
11088 bool HasFirstDefaultArgument =
11091 bool HasSecondDefaultArgument =
11092 SecondNTTPD->hasDefaultArgument() &&
11093 !SecondNTTPD->defaultArgumentWasInherited();
11094 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
11097 FunctionTemplateParameterSingleDefaultArgument)
11098 << FirstTemplate << (i + 1) << HasFirstDefaultArgument;
11099 ODRDiagNote(SecondTemplate->getLocation(),
11100 SecondTemplate->getSourceRange(),
11101 FunctionTemplateParameterSingleDefaultArgument)
11102 << SecondTemplate << (i + 1) << HasSecondDefaultArgument;
11103 ParameterMismatch =
true;
11107 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
11109 Expr *SecondDefaultArgument = SecondNTTPD->getDefaultArgument();
11110 if (ComputeODRHash(FirstDefaultArgument) !=
11111 ComputeODRHash(SecondDefaultArgument)) {
11114 FunctionTemplateParameterDifferentDefaultArgument)
11115 << FirstTemplate << (i + 1) << FirstDefaultArgument;
11116 ODRDiagNote(SecondTemplate->getLocation(),
11117 SecondTemplate->getSourceRange(),
11118 FunctionTemplateParameterDifferentDefaultArgument)
11119 << SecondTemplate << (i + 1) << SecondDefaultArgument;
11120 ParameterMismatch =
true;
11126 SecondNTTPD->isParameterPack()) {
11129 FunctionTemplatePackParameter)
11131 ODRDiagNote(SecondTemplate->getLocation(),
11132 SecondTemplate->getSourceRange(),
11133 FunctionTemplatePackParameter)
11134 << SecondTemplate << (i + 1)
11135 << SecondNTTPD->isParameterPack();
11136 ParameterMismatch =
true;
11142 if (ParameterMismatch) {
11155 diag::err_module_odr_violation_mismatch_decl_unknown)
11156 << FirstRecord << FirstModule.empty() << FirstModule << FirstDiffType
11159 diag::note_module_odr_violation_mismatch_decl_unknown)
11160 << SecondModule << FirstDiffType << SecondDecl->
getSourceRange();
11171 Diag(Merge.first->getLocation(),
11172 diag::err_module_odr_violation_different_instantiations)
11178 for (
auto &Merge : FunctionOdrMergeFailures) {
11179 enum ODRFunctionDifference {
11183 ParameterSingleDefaultArgument,
11184 ParameterDifferentDefaultArgument,
11189 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstFunction);
11191 bool Diagnosed =
false;
11192 for (
auto &SecondFunction : Merge.second) {
11194 if (FirstFunction == SecondFunction)
11197 std::string SecondModule =
11198 getOwningModuleNameForDiagnostic(SecondFunction);
11200 auto ODRDiagError = [FirstFunction, &FirstModule,
11202 ODRFunctionDifference DiffType) {
11203 return Diag(Loc, diag::err_module_odr_violation_function)
11204 << FirstFunction << FirstModule.empty() << FirstModule << Range
11209 ODRFunctionDifference DiffType) {
11210 return Diag(Loc, diag::note_module_odr_violation_function)
11211 << SecondModule << Range << DiffType;
11214 if (ComputeQualTypeODRHash(FirstFunction->
getReturnType()) !=
11215 ComputeQualTypeODRHash(SecondFunction->getReturnType())) {
11219 ODRDiagNote(SecondFunction->getReturnTypeSourceRange().getBegin(),
11220 SecondFunction->getReturnTypeSourceRange(), ReturnType)
11221 << SecondFunction->getReturnType();
11226 assert(FirstFunction->
param_size() == SecondFunction->param_size() &&
11227 "Merged functions with different number of parameters");
11229 auto ParamSize = FirstFunction->
param_size();
11230 bool ParameterMismatch =
false;
11231 for (
unsigned I = 0; I < ParamSize; ++I) {
11233 auto *SecondParam = SecondFunction->getParamDecl(I);
11235 assert(getContext().hasSameType(FirstParam->getType(),
11236 SecondParam->getType()) &&
11237 "Merged function has different parameter types.");
11239 if (FirstParam->getDeclName() != SecondParam->getDeclName()) {
11240 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11242 << I + 1 << FirstParam->getDeclName();
11243 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11245 << I + 1 << SecondParam->getDeclName();
11246 ParameterMismatch =
true;
11250 QualType FirstParamType = FirstParam->getType();
11251 QualType SecondParamType = SecondParam->getType();
11252 if (FirstParamType != SecondParamType &&
11253 ComputeQualTypeODRHash(FirstParamType) !=
11254 ComputeQualTypeODRHash(SecondParamType)) {
11257 ODRDiagError(FirstParam->getLocation(),
11258 FirstParam->getSourceRange(), ParameterType)
11259 << (I + 1) << FirstParamType <<
true 11260 << ParamDecayedType->getOriginalType();
11262 ODRDiagError(FirstParam->getLocation(),
11263 FirstParam->getSourceRange(), ParameterType)
11264 << (I + 1) << FirstParamType <<
false;
11269 ODRDiagNote(SecondParam->getLocation(),
11270 SecondParam->getSourceRange(), ParameterType)
11271 << (I + 1) << SecondParamType <<
true 11272 << ParamDecayedType->getOriginalType();
11274 ODRDiagNote(SecondParam->getLocation(),
11275 SecondParam->getSourceRange(), ParameterType)
11276 << (I + 1) << SecondParamType <<
false;
11278 ParameterMismatch =
true;
11282 const Expr *FirstInit = FirstParam->getInit();
11283 const Expr *SecondInit = SecondParam->getInit();
11284 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
11285 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11286 ParameterSingleDefaultArgument)
11287 << (I + 1) << (FirstInit ==
nullptr)
11289 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11290 ParameterSingleDefaultArgument)
11291 << (I + 1) << (SecondInit ==
nullptr)
11293 ParameterMismatch =
true;
11297 if (FirstInit && SecondInit &&
11298 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
11299 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11300 ParameterDifferentDefaultArgument)
11302 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11303 ParameterDifferentDefaultArgument)
11305 ParameterMismatch =
true;
11309 assert(ComputeSubDeclODRHash(FirstParam) ==
11310 ComputeSubDeclODRHash(SecondParam) &&
11311 "Undiagnosed parameter difference.");
11314 if (ParameterMismatch) {
11323 ODRDiagNote(SecondFunction->getLocation(),
11324 SecondFunction->getSourceRange(), FunctionBody);
11329 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
11333 for (
auto &Merge : EnumOdrMergeFailures) {
11334 enum ODREnumDifference {
11336 EnumTagKeywordMismatch,
11337 SingleSpecifiedType,
11338 DifferentSpecifiedTypes,
11339 DifferentNumberEnumConstants,
11341 EnumConstantSingleInitilizer,
11342 EnumConstantDifferentInitilizer,
11347 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
11350 EnumDecl *FirstEnum = Merge.first;
11351 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstEnum);
11355 auto PopulateHashes = [&ComputeSubDeclODRHash, FirstEnum](
11357 for (
auto *D :
Enum->decls()) {
11362 assert(isa<EnumConstantDecl>(D) &&
"Unexpected Decl kind");
11363 Hashes.emplace_back(cast<EnumConstantDecl>(D),
11364 ComputeSubDeclODRHash(D));
11367 DeclHashes FirstHashes;
11368 PopulateHashes(FirstHashes, FirstEnum);
11369 bool Diagnosed =
false;
11370 for (
auto &SecondEnum : Merge.second) {
11372 if (FirstEnum == SecondEnum)
11375 std::string SecondModule =
11376 getOwningModuleNameForDiagnostic(SecondEnum);
11378 auto ODRDiagError = [FirstEnum, &FirstModule,
11380 ODREnumDifference DiffType) {
11381 return Diag(Loc, diag::err_module_odr_violation_enum)
11382 << FirstEnum << FirstModule.empty() << FirstModule << Range
11387 ODREnumDifference DiffType) {
11388 return Diag(Loc, diag::note_module_odr_violation_enum)
11389 << SecondModule << Range << DiffType;
11392 if (FirstEnum->
isScoped() != SecondEnum->isScoped()) {
11396 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11398 << SecondEnum->isScoped();
11403 if (FirstEnum->
isScoped() && SecondEnum->isScoped()) {
11405 SecondEnum->isScopedUsingClassTag()) {
11407 EnumTagKeywordMismatch)
11409 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11410 EnumTagKeywordMismatch)
11411 << SecondEnum->isScopedUsingClassTag();
11422 SecondEnum->getIntegerTypeSourceInfo()
11423 ? SecondEnum->getIntegerTypeSourceInfo()->getType()
11425 if (FirstUnderlyingType.
isNull() != SecondUnderlyingType.
isNull()) {
11427 SingleSpecifiedType)
11428 << !FirstUnderlyingType.
isNull();
11429 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11430 SingleSpecifiedType)
11431 << !SecondUnderlyingType.
isNull();
11436 if (!FirstUnderlyingType.
isNull() && !SecondUnderlyingType.
isNull()) {
11437 if (ComputeQualTypeODRHash(FirstUnderlyingType) !=
11438 ComputeQualTypeODRHash(SecondUnderlyingType)) {
11440 DifferentSpecifiedTypes)
11441 << FirstUnderlyingType;
11442 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11443 DifferentSpecifiedTypes)
11444 << SecondUnderlyingType;
11450 DeclHashes SecondHashes;
11451 PopulateHashes(SecondHashes, SecondEnum);
11453 if (FirstHashes.size() != SecondHashes.size()) {
11455 DifferentNumberEnumConstants)
11456 << (
int)FirstHashes.size();
11457 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11458 DifferentNumberEnumConstants)
11459 << (
int)SecondHashes.size();
11464 for (
unsigned I = 0; I < FirstHashes.size(); ++I) {
11465 if (FirstHashes[I].second == SecondHashes[I].second)
11475 << I + 1 << FirstEnumConstant;
11478 << I + 1 << SecondEnumConstant;
11485 if (!FirstInit && !SecondInit)
11488 if (!FirstInit || !SecondInit) {
11491 EnumConstantSingleInitilizer)
11492 << I + 1 << FirstEnumConstant << (FirstInit !=
nullptr);
11495 EnumConstantSingleInitilizer)
11496 << I + 1 << SecondEnumConstant << (SecondInit !=
nullptr);
11501 if (ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
11504 EnumConstantDifferentInitilizer)
11505 << I + 1 << FirstEnumConstant;
11508 EnumConstantDifferentInitilizer)
11509 << I + 1 << SecondEnumConstant;
11517 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
11522 if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get())
11523 ReadTimer->startTimer();
11527 assert(NumCurrentElementsDeserializing &&
11528 "FinishedDeserializing not paired with StartedDeserializing");
11529 if (NumCurrentElementsDeserializing == 1) {
11532 finishPendingActions();
11534 --NumCurrentElementsDeserializing;
11536 if (NumCurrentElementsDeserializing == 0) {
11542 while (!PendingExceptionSpecUpdates.empty() ||
11543 !PendingDeducedTypeUpdates.empty()) {
11544 auto ESUpdates = std::move(PendingExceptionSpecUpdates);
11545 PendingExceptionSpecUpdates.clear();
11546 for (
auto Update : ESUpdates) {
11547 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
11549 auto ESI = FPT->getExtProtoInfo().ExceptionSpec;
11550 if (
auto *Listener = getContext().getASTMutationListener())
11551 Listener->ResolvedExceptionSpec(cast<FunctionDecl>(
Update.second));
11552 for (
auto *Redecl :
Update.second->redecls())
11553 getContext().adjustExceptionSpec(cast<FunctionDecl>(Redecl), ESI);
11556 auto DTUpdates = std::move(PendingDeducedTypeUpdates);
11557 PendingDeducedTypeUpdates.clear();
11558 for (
auto Update : DTUpdates) {
11559 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
11561 getContext().adjustDeducedFunctionResultType(
Update.first,
11567 ReadTimer->stopTimer();
11569 diagnoseOdrViolations();
11574 PassInterestingDeclsToConsumer();
11581 auto It = PendingFakeLookupResults.find(II);
11582 if (It != PendingFakeLookupResults.end()) {
11583 for (
auto *ND : It->second)
11584 SemaObj->IdResolver.RemoveDecl(ND);
11588 It->second.clear();
11592 if (SemaObj->IdResolver.tryAddTopLevelDecl(D, Name) && SemaObj->TUScope) {
11593 SemaObj->TUScope->AddDecl(D);
11594 }
else if (SemaObj->TUScope) {
11598 if (std::find(SemaObj->IdResolver.begin(Name),
11599 SemaObj->IdResolver.end(), D) != SemaObj->IdResolver.end())
11600 SemaObj->TUScope->AddDecl(D);
11606 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
11607 StringRef isysroot,
bool DisableValidation,
11608 bool AllowASTWithCompilerErrors,
11609 bool AllowConfigurationMismatch,
bool ValidateSystemInputs,
11610 bool UseGlobalIndex,
11611 std::unique_ptr<llvm::Timer> ReadTimer)
11612 : Listener(DisableValidation
11615 SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()),
11616 PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()), PP(PP),
11617 ContextObj(Context),
11618 ModuleMgr(PP.getFileManager(), PP.getPCMCache(), PCHContainerRdr,
11619 PP.getHeaderSearchInfo()),
11620 PCMCache(PP.getPCMCache()), DummyIdResolver(PP),
11621 ReadTimer(
std::move(ReadTimer)), isysroot(isysroot),
11622 DisableValidation(DisableValidation),
11623 AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
11624 AllowConfigurationMismatch(AllowConfigurationMismatch),
11625 ValidateSystemInputs(ValidateSystemInputs),
11626 UseGlobalIndex(UseGlobalIndex), CurrSwitchCaseStmts(&SwitchCaseStmts) {
11629 for (
const auto &Ext : Extensions) {
11630 auto BlockName = Ext->getExtensionMetadata().BlockName;
11631 auto Known = ModuleFileExtensions.find(BlockName);
11632 if (Known != ModuleFileExtensions.end()) {
11633 Diags.
Report(diag::warn_duplicate_module_file_extension)
11638 ModuleFileExtensions.insert({BlockName, Ext});
11643 if (OwnsDeserializationListener)
11644 delete DeserializationListener;
11648 return SemaObj ? SemaObj->
IdResolver : DummyIdResolver;
11652 unsigned AbbrevID) {
11655 return Cursor.readRecord(AbbrevID, Record);
11663 switch (Record.readInt()) {
11670 case OMPC_num_threads:
11679 case OMPC_collapse:
11685 case OMPC_proc_bind:
11688 case OMPC_schedule:
11700 case OMPC_mergeable:
11727 case OMPC_unified_address:
11730 case OMPC_unified_shared_memory:
11733 case OMPC_reverse_offload:
11736 case OMPC_dynamic_allocators:
11739 case OMPC_atomic_default_mem_order:
11745 case OMPC_firstprivate:
11748 case OMPC_lastprivate:
11754 case OMPC_reduction:
11757 case OMPC_task_reduction:
11760 case OMPC_in_reduction:
11772 case OMPC_copyprivate:
11778 case OMPC_depend: {
11779 unsigned NumVars = Record.readInt();
11780 unsigned NumLoops = Record.readInt();
11788 unsigned NumVars = Record.readInt();
11789 unsigned NumDeclarations = Record.readInt();
11790 unsigned NumLists = Record.readInt();
11791 unsigned NumComponents = Record.readInt();
11796 case OMPC_num_teams:
11799 case OMPC_thread_limit:
11802 case OMPC_priority:
11805 case OMPC_grainsize:
11808 case OMPC_num_tasks:
11814 case OMPC_dist_schedule:
11817 case OMPC_defaultmap:
11821 unsigned NumVars = Record.readInt();
11822 unsigned NumDeclarations = Record.readInt();
11823 unsigned NumLists = Record.readInt();
11824 unsigned NumComponents = Record.readInt();
11830 unsigned NumVars = Record.readInt();
11831 unsigned NumDeclarations = Record.readInt();
11832 unsigned NumLists = Record.readInt();
11833 unsigned NumComponents = Record.readInt();
11838 case OMPC_use_device_ptr: {
11839 unsigned NumVars = Record.readInt();
11840 unsigned NumDeclarations = Record.readInt();
11841 unsigned NumLists = Record.readInt();
11842 unsigned NumComponents = Record.readInt();
11844 NumLists, NumComponents);
11847 case OMPC_is_device_ptr: {
11848 unsigned NumVars = Record.readInt();
11849 unsigned NumDeclarations = Record.readInt();
11850 unsigned NumLists = Record.readInt();
11851 unsigned NumComponents = Record.readInt();
11853 NumLists, NumComponents);
11859 C->
setLocEnd(Record.readSourceLocation());
11870 VisitOMPClauseWithPreInit(C);
11874 void OMPClauseReader::VisitOMPIfClause(
OMPIfClause *
C) {
11875 VisitOMPClauseWithPreInit(C);
11876 C->setNameModifier(static_cast<OpenMPDirectiveKind>(Record.readInt()));
11877 C->setNameModifierLoc(Record.readSourceLocation());
11878 C->setColonLoc(Record.readSourceLocation());
11879 C->setCondition(Record.readSubExpr());
11884 C->setCondition(Record.readSubExpr());
11889 VisitOMPClauseWithPreInit(C);
11890 C->setNumThreads(Record.readSubExpr());
11895 C->setSafelen(Record.readSubExpr());
11900 C->setSimdlen(Record.readSubExpr());
11905 C->setNumForLoops(Record.readSubExpr());
11911 static_cast<OpenMPDefaultClauseKind>(Record.readInt()));
11913 C->setDefaultKindKwLoc(Record.readSourceLocation());
11917 C->setProcBindKind(
11918 static_cast<OpenMPProcBindClauseKind>(Record.readInt()));
11920 C->setProcBindKindKwLoc(Record.readSourceLocation());
11924 VisitOMPClauseWithPreInit(C);
11925 C->setScheduleKind(
11926 static_cast<OpenMPScheduleClauseKind>(Record.readInt()));
11927 C->setFirstScheduleModifier(
11928 static_cast<OpenMPScheduleClauseModifier>(Record.readInt()));
11929 C->setSecondScheduleModifier(
11930 static_cast<OpenMPScheduleClauseModifier>(Record.readInt()));
11931 C->setChunkSize(Record.readSubExpr());
11932 C->setLParenLoc(Record.readSourceLocation());
11933 C->setFirstScheduleModifierLoc(Record.readSourceLocation());
11934 C->setSecondScheduleModifierLoc(Record.readSourceLocation());
11935 C->setScheduleKindLoc(Record.readSourceLocation());
11936 C->setCommaLoc(Record.readSourceLocation());
11940 C->setNumForLoops(Record.readSubExpr());
11941 for (
unsigned I = 0, E = C->NumberOfLoops; I < E; ++I)
11943 for (
unsigned I = 0, E = C->NumberOfLoops; I < E; ++I)
11954 void OMPClauseReader::VisitOMPReadClause(
OMPReadClause *) {}
11966 void OMPClauseReader::VisitOMPSIMDClause(
OMPSIMDClause *) {}
11972 void OMPClauseReader::VisitOMPUnifiedSharedMemoryClause(
11981 void OMPClauseReader::VisitOMPAtomicDefaultMemOrderClause(
11983 C->setAtomicDefaultMemOrderKind(
11984 static_cast<OpenMPAtomicDefaultMemOrderClauseKind>(Record.readInt()));
11986 C->setAtomicDefaultMemOrderKindKwLoc(Record.readSourceLocation());
11993 Vars.reserve(NumVars);
11994 for (
unsigned i = 0; i != NumVars; ++i)
11995 Vars.push_back(Record.readSubExpr());
11998 for (
unsigned i = 0; i != NumVars; ++i)
11999 Vars.push_back(Record.readSubExpr());
12000 C->setPrivateCopies(Vars);
12004 VisitOMPClauseWithPreInit(C);
12008 Vars.reserve(NumVars);
12009 for (
unsigned i = 0; i != NumVars; ++i)
12010 Vars.push_back(Record.readSubExpr());
12013 for (
unsigned i = 0; i != NumVars; ++i)
12014 Vars.push_back(Record.readSubExpr());
12015 C->setPrivateCopies(Vars);
12017 for (
unsigned i = 0; i != NumVars; ++i)
12018 Vars.push_back(Record.readSubExpr());
12023 VisitOMPClauseWithPostUpdate(C);
12027 Vars.reserve(NumVars);
12028 for (
unsigned i = 0; i != NumVars; ++i)
12029 Vars.push_back(Record.readSubExpr());
12032 for (
unsigned i = 0; i != NumVars; ++i)
12033 Vars.push_back(Record.readSubExpr());
12036 for (
unsigned i = 0; i != NumVars; ++i)
12037 Vars.push_back(Record.readSubExpr());
12038 C->setSourceExprs(Vars);
12040 for (
unsigned i = 0; i != NumVars; ++i)
12041 Vars.push_back(Record.readSubExpr());
12042 C->setDestinationExprs(Vars);
12044 for (
unsigned i = 0; i != NumVars; ++i)
12045 Vars.push_back(Record.readSubExpr());
12046 C->setAssignmentOps(Vars);
12053 Vars.reserve(NumVars);
12054 for (
unsigned i = 0; i != NumVars; ++i)
12055 Vars.push_back(Record.readSubExpr());
12060 VisitOMPClauseWithPostUpdate(C);
12062 C->setColonLoc(Record.readSourceLocation());
12065 Record.readDeclarationNameInfo(DNI);
12066 C->setQualifierLoc(NNSL);
12067 C->setNameInfo(DNI);
12071 Vars.reserve(NumVars);
12072 for (
unsigned i = 0; i != NumVars; ++i)
12073 Vars.push_back(Record.readSubExpr());
12076 for (
unsigned i = 0; i != NumVars; ++i)
12077 Vars.push_back(Record.readSubExpr());
12078 C->setPrivates(Vars);
12080 for (
unsigned i = 0; i != NumVars; ++i)
12081 Vars.push_back(Record.readSubExpr());
12082 C->setLHSExprs(Vars);
12084 for (
unsigned i = 0; i != NumVars; ++i)
12085 Vars.push_back(Record.readSubExpr());
12086 C->setRHSExprs(Vars);
12088 for (
unsigned i = 0; i != NumVars; ++i)
12089 Vars.push_back(Record.readSubExpr());
12090 C->setReductionOps(Vars);
12094 VisitOMPClauseWithPostUpdate(C);
12096 C->setColonLoc(Record.readSourceLocation());
12099 Record.readDeclarationNameInfo(DNI);
12100 C->setQualifierLoc(NNSL);
12101 C->setNameInfo(DNI);
12105 Vars.reserve(NumVars);
12106 for (
unsigned I = 0; I != NumVars; ++I)
12107 Vars.push_back(Record.readSubExpr());
12110 for (
unsigned I = 0; I != NumVars; ++I)
12111 Vars.push_back(Record.readSubExpr());
12112 C->setPrivates(Vars);
12114 for (
unsigned I = 0; I != NumVars; ++I)
12115 Vars.push_back(Record.readSubExpr());
12116 C->setLHSExprs(Vars);
12118 for (
unsigned I = 0; I != NumVars; ++I)
12119 Vars.push_back(Record.readSubExpr());
12120 C->setRHSExprs(Vars);
12122 for (
unsigned I = 0; I != NumVars; ++I)
12123 Vars.push_back(Record.readSubExpr());
12124 C->setReductionOps(Vars);
12128 VisitOMPClauseWithPostUpdate(C);
12130 C->setColonLoc(Record.readSourceLocation());
12133 Record.readDeclarationNameInfo(DNI);
12134 C->setQualifierLoc(NNSL);
12135 C->setNameInfo(DNI);
12139 Vars.reserve(NumVars);
12140 for (
unsigned I = 0; I != NumVars; ++I)
12141 Vars.push_back(Record.readSubExpr());
12144 for (
unsigned I = 0; I != NumVars; ++I)
12145 Vars.push_back(Record.readSubExpr());
12146 C->setPrivates(Vars);
12148 for (
unsigned I = 0; I != NumVars; ++I)
12149 Vars.push_back(Record.readSubExpr());
12150 C->setLHSExprs(Vars);
12152 for (
unsigned I = 0; I != NumVars; ++I)
12153 Vars.push_back(Record.readSubExpr());
12154 C->setRHSExprs(Vars);
12156 for (
unsigned I = 0; I != NumVars; ++I)
12157 Vars.push_back(Record.readSubExpr());
12158 C->setReductionOps(Vars);
12160 for (
unsigned I = 0; I != NumVars; ++I)
12161 Vars.push_back(Record.readSubExpr());
12162 C->setTaskgroupDescriptors(Vars);
12166 VisitOMPClauseWithPostUpdate(C);
12168 C->setColonLoc(Record.readSourceLocation());
12169 C->setModifier(static_cast<OpenMPLinearClauseKind>(Record.readInt()));
12170 C->setModifierLoc(Record.readSourceLocation());
12173 Vars.reserve(NumVars);
12174 for (
unsigned i = 0; i != NumVars; ++i)
12175 Vars.push_back(Record.readSubExpr());
12178 for (
unsigned i = 0; i != NumVars; ++i)
12179 Vars.push_back(Record.readSubExpr());
12180 C->setPrivates(Vars);
12182 for (
unsigned i = 0; i != NumVars; ++i)
12183 Vars.push_back(Record.readSubExpr());
12186 for (
unsigned i = 0; i != NumVars; ++i)
12187 Vars.push_back(Record.readSubExpr());
12188 C->setUpdates(Vars);
12190 for (
unsigned i = 0; i != NumVars; ++i)
12191 Vars.push_back(Record.readSubExpr());
12192 C->setFinals(Vars);
12193 C->setStep(Record.readSubExpr());
12194 C->setCalcStep(Record.readSubExpr());
12198 C->setLParenLoc(Record.readSourceLocation());
12200 unsigned NumVars = C->varlist_size();
12202 Vars.reserve(NumVars);
12203 for (
unsigned i = 0; i != NumVars; ++i)
12204 Vars.push_back(Record.readSubExpr());
12205 C->setVarRefs(Vars);
12206 C->setAlignment(Record.readSubExpr());
12210 C->setLParenLoc(Record.readSourceLocation());
12211 unsigned NumVars = C->varlist_size();
12213 Exprs.reserve(NumVars);
12214 for (
unsigned i = 0; i != NumVars; ++i)
12215 Exprs.push_back(Record.readSubExpr());
12216 C->setVarRefs(Exprs);
12218 for (
unsigned i = 0; i != NumVars; ++i)
12219 Exprs.push_back(Record.readSubExpr());
12220 C->setSourceExprs(Exprs);
12222 for (
unsigned i = 0; i != NumVars; ++i)
12223 Exprs.push_back(Record.readSubExpr());
12224 C->setDestinationExprs(Exprs);
12226 for (
unsigned i = 0; i != NumVars; ++i)
12227 Exprs.push_back(Record.readSubExpr());
12228 C->setAssignmentOps(Exprs);
12232 C->setLParenLoc(Record.readSourceLocation());
12233 unsigned NumVars = C->varlist_size();
12235 Exprs.reserve(NumVars);
12236 for (
unsigned i = 0; i != NumVars; ++i)
12237 Exprs.push_back(Record.readSubExpr());
12238 C->setVarRefs(Exprs);
12240 for (
unsigned i = 0; i != NumVars; ++i)
12241 Exprs.push_back(Record.readSubExpr());
12242 C->setSourceExprs(Exprs);
12244 for (
unsigned i = 0; i != NumVars; ++i)
12245 Exprs.push_back(Record.readSubExpr());
12246 C->setDestinationExprs(Exprs);
12248 for (
unsigned i = 0; i != NumVars; ++i)
12249 Exprs.push_back(Record.readSubExpr());
12250 C->setAssignmentOps(Exprs);
12254 C->setLParenLoc(Record.readSourceLocation());
12255 unsigned NumVars = C->varlist_size();
12257 Vars.reserve(NumVars);
12258 for (
unsigned i = 0; i != NumVars; ++i)
12259 Vars.push_back(Record.readSubExpr());
12260 C->setVarRefs(Vars);
12264 C->setLParenLoc(Record.readSourceLocation());
12265 C->setDependencyKind(
12266 static_cast<OpenMPDependClauseKind>(Record.readInt()));
12267 C->setDependencyLoc(Record.readSourceLocation());
12268 C->setColonLoc(Record.readSourceLocation());
12269 unsigned NumVars = C->varlist_size();
12271 Vars.reserve(NumVars);
12272 for (
unsigned I = 0; I != NumVars; ++I)
12273 Vars.push_back(Record.readSubExpr());
12274 C->setVarRefs(Vars);
12275 for (
unsigned I = 0, E = C->
getNumLoops(); I < E; ++I)
12280 VisitOMPClauseWithPreInit(C);
12281 C->setDevice(Record.readSubExpr());
12285 void OMPClauseReader::VisitOMPMapClause(
OMPMapClause *C) {
12286 C->setLParenLoc(Record.readSourceLocation());
12288 C->setMapTypeModifier(
12289 I, static_cast<OpenMPMapModifierKind>(Record.readInt()));
12290 C->setMapTypeModifierLoc(I, Record.readSourceLocation());
12293 static_cast<OpenMPMapClauseKind>(Record.readInt()));
12294 C->setMapLoc(Record.readSourceLocation());
12295 C->setColonLoc(Record.readSourceLocation());
12296 auto NumVars = C->varlist_size();
12302 Vars.reserve(NumVars);
12303 for (
unsigned i = 0; i != NumVars; ++i)
12304 Vars.push_back(Record.readSubExpr());
12305 C->setVarRefs(Vars);
12308 Decls.reserve(UniqueDecls);
12309 for (
unsigned i = 0; i < UniqueDecls; ++i)
12310 Decls.push_back(Record.readDeclAs<
ValueDecl>());
12314 ListsPerDecl.reserve(UniqueDecls);
12315 for (
unsigned i = 0; i < UniqueDecls; ++i)
12316 ListsPerDecl.push_back(Record.readInt());
12320 ListSizes.reserve(TotalLists);
12321 for (
unsigned i = 0; i < TotalLists; ++i)
12322 ListSizes.push_back(Record.readInt());
12326 Components.reserve(TotalComponents);
12327 for (
unsigned i = 0; i < TotalComponents; ++i) {
12328 Expr *AssociatedExpr = Record.readSubExpr();
12329 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
12331 AssociatedExpr, AssociatedDecl));
12337 VisitOMPClauseWithPreInit(C);
12338 C->setNumTeams(Record.readSubExpr());
12343 VisitOMPClauseWithPreInit(C);
12344 C->setThreadLimit(Record.readSubExpr());
12349 C->setPriority(Record.readSubExpr());
12354 C->setGrainsize(Record.readSubExpr());
12359 C->setNumTasks(Record.readSubExpr());
12363 void OMPClauseReader::VisitOMPHintClause(
OMPHintClause *C) {
12364 C->setHint(Record.readSubExpr());
12369 VisitOMPClauseWithPreInit(C);
12370 C->setDistScheduleKind(
12371 static_cast<OpenMPDistScheduleClauseKind>(Record.readInt()));
12372 C->setChunkSize(Record.readSubExpr());
12373 C->setLParenLoc(Record.readSourceLocation());
12374 C->setDistScheduleKindLoc(Record.readSourceLocation());
12375 C->setCommaLoc(Record.readSourceLocation());
12379 C->setDefaultmapKind(
12380 static_cast<OpenMPDefaultmapClauseKind>(Record.readInt()));
12381 C->setDefaultmapModifier(
12382 static_cast<OpenMPDefaultmapClauseModifier>(Record.readInt()));
12383 C->setLParenLoc(Record.readSourceLocation());
12384 C->setDefaultmapModifierLoc(Record.readSourceLocation());
12385 C->setDefaultmapKindLoc(Record.readSourceLocation());
12388 void OMPClauseReader::VisitOMPToClause(
OMPToClause *C) {
12389 C->setLParenLoc(Record.readSourceLocation());
12390 auto NumVars = C->varlist_size();
12396 Vars.reserve(NumVars);
12397 for (
unsigned i = 0; i != NumVars; ++i)
12398 Vars.push_back(Record.readSubExpr());
12399 C->setVarRefs(Vars);
12402 Decls.reserve(UniqueDecls);
12403 for (
unsigned i = 0; i < UniqueDecls; ++i)
12404 Decls.push_back(Record.readDeclAs<
ValueDecl>());
12408 ListsPerDecl.reserve(UniqueDecls);
12409 for (
unsigned i = 0; i < UniqueDecls; ++i)
12410 ListsPerDecl.push_back(Record.readInt());
12414 ListSizes.reserve(TotalLists);
12415 for (
unsigned i = 0; i < TotalLists; ++i)
12416 ListSizes.push_back(Record.readInt());
12420 Components.reserve(TotalComponents);
12421 for (
unsigned i = 0; i < TotalComponents; ++i) {
12422 Expr *AssociatedExpr = Record.readSubExpr();
12423 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
12425 AssociatedExpr, AssociatedDecl));
12430 void OMPClauseReader::VisitOMPFromClause(
OMPFromClause *C) {
12431 C->setLParenLoc(Record.readSourceLocation());
12432 auto NumVars = C->varlist_size();
12438 Vars.reserve(NumVars);
12439 for (
unsigned i = 0; i != NumVars; ++i)
12440 Vars.push_back(Record.readSubExpr());
12441 C->setVarRefs(Vars);
12444 Decls.reserve(UniqueDecls);
12445 for (
unsigned i = 0; i < UniqueDecls; ++i)
12446 Decls.push_back(Record.readDeclAs<
ValueDecl>());
12450 ListsPerDecl.reserve(UniqueDecls);
12451 for (
unsigned i = 0; i < UniqueDecls; ++i)
12452 ListsPerDecl.push_back(Record.readInt());
12456 ListSizes.reserve(TotalLists);
12457 for (
unsigned i = 0; i < TotalLists; ++i)
12458 ListSizes.push_back(Record.readInt());
12462 Components.reserve(TotalComponents);
12463 for (
unsigned i = 0; i < TotalComponents; ++i) {
12464 Expr *AssociatedExpr = Record.readSubExpr();
12465 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
12467 AssociatedExpr, AssociatedDecl));
12473 C->setLParenLoc(Record.readSourceLocation());
12474 auto NumVars = C->varlist_size();
12480 Vars.reserve(NumVars);
12481 for (
unsigned i = 0; i != NumVars; ++i)
12482 Vars.push_back(Record.readSubExpr());
12483 C->setVarRefs(Vars);
12485 for (
unsigned i = 0; i != NumVars; ++i)
12486 Vars.push_back(Record.readSubExpr());
12487 C->setPrivateCopies(Vars);
12489 for (
unsigned i = 0; i != NumVars; ++i)
12490 Vars.push_back(Record.readSubExpr());
12494 Decls.reserve(UniqueDecls);
12495 for (
unsigned i = 0; i < UniqueDecls; ++i)
12496 Decls.push_back(Record.readDeclAs<
ValueDecl>());
12500 ListsPerDecl.reserve(UniqueDecls);
12501 for (
unsigned i = 0; i < UniqueDecls; ++i)
12502 ListsPerDecl.push_back(Record.readInt());
12506 ListSizes.reserve(TotalLists);
12507 for (
unsigned i = 0; i < TotalLists; ++i)
12508 ListSizes.push_back(Record.readInt());
12512 Components.reserve(TotalComponents);
12513 for (
unsigned i = 0; i < TotalComponents; ++i) {
12514 Expr *AssociatedExpr = Record.readSubExpr();
12515 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
12517 AssociatedExpr, AssociatedDecl));
12523 C->setLParenLoc(Record.readSourceLocation());
12524 auto NumVars = C->varlist_size();
12530 Vars.reserve(NumVars);
12531 for (
unsigned i = 0; i != NumVars; ++i)
12532 Vars.push_back(Record.readSubExpr());
12533 C->setVarRefs(Vars);
12537 Decls.reserve(UniqueDecls);
12538 for (
unsigned i = 0; i < UniqueDecls; ++i)
12539 Decls.push_back(Record.readDeclAs<
ValueDecl>());
12543 ListsPerDecl.reserve(UniqueDecls);
12544 for (
unsigned i = 0; i < UniqueDecls; ++i)
12545 ListsPerDecl.push_back(Record.readInt());
12549 ListSizes.reserve(TotalLists);
12550 for (
unsigned i = 0; i < TotalLists; ++i)
12551 ListSizes.push_back(Record.readInt());
12555 Components.reserve(TotalComponents);
12556 for (
unsigned i = 0; i < TotalComponents; ++i) {
12557 Expr *AssociatedExpr = Record.readSubExpr();
12558 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
12560 AssociatedExpr, AssociatedDecl));
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.
This represents 'thread_limit' clause in the '#pragma omp ...' directive.
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 setLParenLoc(SourceLocation Loc)
Sets the location of '('.
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.
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
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.
This represents clause 'copyin' in the '#pragma omp ...' directives.
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)
static OMPUseDevicePtrClause * CreateEmpty(const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
Creates an empty clause with the place for NumVars variables.
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
The kind of the name stored in this DeclarationName.
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...
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.
This represents 'atomic_default_mem_order' clause in the '#pragma omp requires' directive.
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.
void setUniqueDecls(ArrayRef< ValueDecl *> UDs)
Set the unique declarations that are in the trailing objects of the class.
Stmt - This represents one statement.
void setStarLoc(SourceLocation Loc)
This represents clause 'in_reduction' in the '#pragma omp task' directives.
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"...
Class that handles pre-initialization statement for some clauses, like 'shedule', 'firstprivate' etc...
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.
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
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.
This represents 'grainsize' clause in the '#pragma omp ...' directive.
SmallVector< uint64_t, 4 > PreloadSLocEntries
SLocEntries that we're going to preload.
Module * getCurrentModule()
Retrieves the module that we're currently building, if any.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
TagDecl * getDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
CanQualType ObjCBuiltinSelTy
RetTy Visit(TypeLoc TyLoc)
static constexpr unsigned NumberOfModifiers
Number of allowed map-type-modifiers.
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
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.
This represents 'if' clause in the '#pragma omp ...' directive.
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.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
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.
static OMPMapClause * CreateEmpty(const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
Creates an empty clause with the place for NumVars original expressions, NumUniqueDeclarations declar...
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...
This represents 'priority' clause in the '#pragma omp ...' directive.
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
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
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
This represents 'update' clause in the '#pragma omp atomic' directive.
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.
void setComponents(ArrayRef< MappableComponent > Components, ArrayRef< unsigned > CLSs)
Set the components that are in the trailing objects of the class.
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.
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...
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
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.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
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.
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
QualType withFastQualifiers(unsigned TQs) const
unsigned NumPreprocessedEntities
The C++ 'char32_t' type.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
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.
This represents 'read' clause in the '#pragma omp atomic' directive.
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.
This represents clause 'private' in the '#pragma omp ...' directives.
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
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
This represents 'num_threads' clause in the '#pragma omp ...' directive.
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.
This represents 'defaultmap' clause in the '#pragma omp ...' directive.
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)
This represents implicit clause 'flush' for the '#pragma omp flush' directive.
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)
unsigned getTotalComponentsNum() const
Return the total number of components in all lists derived from the clause.
This represents 'reverse_offload' clause in the '#pragma omp requires' directive. ...
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.
static OMPTaskReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
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)
This represents 'nogroup' clause in the '#pragma omp ...' directive.
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.
This represents 'safelen' clause in the '#pragma omp ...' directive.
An UnresolvedSet-like class that might not have been loaded from the external AST source yet...
bool needsExtraLocalData() const
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. ...
static OMPOrderedClause * CreateEmpty(const ASTContext &C, unsigned NumLoops)
Build an empty clause.
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.
unsigned varlist_size() const
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.
void setHasExternalLexicalStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations lexically in this context...
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.
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.
This represents 'simd' clause in the '#pragma omp ...' directive.
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
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
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
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
Represents a member of a struct/union/class.
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
bool isCPlusPlusOperatorKeyword() const
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
The '_Sat unsigned _Accum' type.
The unsigned 128-bit integer type.
void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations)
Set number of iterations for the specified loop.
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.
This represents clause 'map' in the '#pragma omp ...' directives.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
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.
This represents clause 'to' in the '#pragma omp ...' directives.
void setColonLoc(SourceLocation Loc)
Sets the location of ':'.
SanitizerMask Mask
Bitmask of enabled sanitizers.
static std::pair< GlobalModuleIndex *, ErrorCode > readIndex(llvm::StringRef Path)
Read a global index file for the given directory.
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.
void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C)
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)
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Describes a module or submodule.
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.
virtual llvm::StringRef ExtractPCH(llvm::MemoryBufferRef Buffer) const =0
Returns the serialized AST inside the PCH container Buffer.
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.
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
void setLoopCounter(unsigned NumLoop, Expr *Counter)
Set loop counter for the specified loop.
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 setAttr(const Attr *A)
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.
static OMPIsDevicePtrClause * CreateEmpty(const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
Creates an empty clause with the place for NumVars variables.
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
static OMPInReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
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
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
The internal '__make_integer_seq' template.
void setRParenLoc(SourceLocation Loc)
void setLazyBody(uint64_t Offset)
static OMPToClause * CreateEmpty(const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
Creates an empty clause with the place for NumVars variables.
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
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc...
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)
This represents 'default' clause in the '#pragma omp ...' directive.
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...
This represents 'final' clause in the '#pragma omp ...' directive.
This represents 'mergeable' clause in the '#pragma omp ...' directive.
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
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
This represents clause 'reduction' in the '#pragma omp ...' directives.
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
This represents clause 'is_device_ptr' in the '#pragma omp ...' directives.
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.
unsigned getUniqueDeclarationsNum() const
Return the number of unique base declarations in this clause.
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.
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.
This represents clause 'from' in the '#pragma omp ...' directives.
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.
This represents 'dynamic_allocators' clause in the '#pragma omp requires' directive.
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.
This represents 'threads' clause in the '#pragma omp ...' directive.
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.
This represents clause 'aligned' in the '#pragma omp ...' directives.
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.
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
A dependent template name that has not been resolved to a template (or set of templates).
DeclarationNameTable DeclarationNames
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type...
void setLocEnd(SourceLocation Loc)
Sets the ending location of the clause.
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
This represents clause 'task_reduction' in the '#pragma omp taskgroup' directives.
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)
unsigned getNumLoops() const
Get number of loops associated with the clause.
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
This represents implicit clause 'depend' for the '#pragma omp task' directive.
A record containing CXXBaseSpecifiers.
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.
This represents 'proc_bind' clause in the '#pragma omp ...' directive.
This represents 'capture' clause in the '#pragma omp atomic' directive.
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 ...
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.
This represents 'simdlen' clause in the '#pragma omp ...' directive.
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...
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N variables.
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...
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
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.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
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.
void setDeclNumLists(ArrayRef< unsigned > DNLs)
Set the number of lists per declaration that are in the trailing objects of the class.
Defines the clang::TypeLoc interface and its subclasses.
A namespace alias, stored as a NamespaceAliasDecl*.
This represents 'ordered' clause in the '#pragma omp ...' directive.
virtual ~ASTReaderListener()
The 'long double' type.
static OMPFlushClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Record code for the diagnostic options table.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
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
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
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 setLParenLoc(SourceLocation Loc)
Sets the location of '('.
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...
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'collapse' clause in the '#pragma omp ...' directive.
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
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.
This represents 'seq_cst' clause in the '#pragma omp atomic' directive.
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...
This represents 'untied' clause in the '#pragma omp ...' directive.
The placeholder type for bound member functions.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
Attr * ReadAttr(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Reads one attribute from the current stream position.
void setIsUsed(bool Val)
Set the value of the IsUsed flag.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
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.
This represents 'unified_address' clause in the '#pragma omp requires' directive. ...
SpecifierKind
The kind of specifier that completes this nested name specifier.
std::pair< Module *, bool > findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework, bool IsExplicit)
Find a new module or submodule, or create it if it does not already exist.
void setPostUpdateExpr(Expr *S)
Set pre-initialization statement for the clause.
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 ...
This represents 'num_teams' clause in the '#pragma omp ...' directive.
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.
Record code for types associated with OpenCL extensions.
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
unsigned getTotalComponentListNum() const
Return the number of lists derived from the clause expressions.
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...
This represents 'hint' clause in the '#pragma omp ...' directive.
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.
This represents 'schedule' clause in the '#pragma omp ...' directive.
PredefinedTypeIDs
Predefined type IDs.
All of the names in this module are hidden.
File is an implicitly-loaded module.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
unsigned getInstanceBits() const
OpenMPDirectiveKind
OpenMP directives.
This represents clause 'shared' in the '#pragma omp ...' directives.
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
void setPrivateCopies(ArrayRef< Expr *> PrivateCopies)
Set list of helper expressions, required for generation of private copies of original lastprivate var...
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)
This is a basic class for representing single OpenMP clause.
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)
SourceLocation getBeginLoc() const LLVM_READONLY
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.
void setVarRefs(ArrayRef< Expr *> VL)
Sets the list of variables for this clause.
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)
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.
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)
virtual void visitImport(StringRef ModuleName, StringRef Filename)
If needsImportVisitation returns true, this is called for each AST file imported by this AST file...
The width of the "fast" qualifier mask.
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.
void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C)
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.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
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
This represents 'device' clause in the '#pragma omp ...' directive.
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.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
The base class of all kinds of template declarations (e.g., class, function, etc.).
PreprocessorDetailRecordTypes
Record types used within a preprocessor detail block.
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
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
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.
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.
This represents 'unified_shared_memory' clause in the '#pragma omp requires' directive.
llvm::OnDiskChainedHashTable< ASTSelectorLookupTrait > ASTSelectorLookupTable
The on-disk hash table used for the global method pool.
This represents clause 'linear' in the '#pragma omp ...' directives.
void * getFETokenInfo() const
Get and set FETokenInfo.
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)
void setLocStart(SourceLocation Loc)
Sets the starting location of the clause.
A type that was preceded by the 'template' keyword, stored as a Type*.
void ClearSwitchCaseIDs()
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
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)
void setComponentListSizes(ArrayRef< unsigned > CLSs)
Set the cumulative component lists sizes that are in the trailing objects of the class.
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.
Class that represents a component of a mappable expression.
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.
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.
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
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.
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.
Holds information about the various types of exception specification.
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.
This represents 'write' clause in the '#pragma omp atomic' directive.
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.
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data for the depend clauses with 'sink|source' kind of dependency.
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)
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
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.
This represents 'nowait' clause in the '#pragma omp ...' directive.
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.
This represents 'num_tasks' clause in the '#pragma omp ...' directive.
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)
ASTImporterLookupTable & LT
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...
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.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion=OMPD_unknown)
Set pre-initialization statement for the clause.
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.
This represents 'dist_schedule' clause in the '#pragma omp ...' directive.
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)
static OMPFromClause * CreateEmpty(const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
Creates an empty clause with the place for NumVars variables.
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)
static DeclarationName getUsingDirectiveName()
Returns the name for all C++ using-directives.
bool getWarningsAsErrors() const
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
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.
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.
static OMPLastprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
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
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
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.
Attr - This represents one attribute.
bool isDeletedAsWritten() const
SourceLocation getLocation() const
This represents clause 'use_device_ptr' in the '#pragma omp ...' directives.
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.