87 #include "llvm/ADT/APFloat.h" 88 #include "llvm/ADT/APInt.h" 89 #include "llvm/ADT/APSInt.h" 90 #include "llvm/ADT/ArrayRef.h" 91 #include "llvm/ADT/DenseMap.h" 92 #include "llvm/ADT/FoldingSet.h" 93 #include "llvm/ADT/Hashing.h" 94 #include "llvm/ADT/IntrusiveRefCntPtr.h" 95 #include "llvm/ADT/None.h" 96 #include "llvm/ADT/Optional.h" 97 #include "llvm/ADT/STLExtras.h" 98 #include "llvm/ADT/ScopeExit.h" 99 #include "llvm/ADT/SmallPtrSet.h" 100 #include "llvm/ADT/SmallString.h" 101 #include "llvm/ADT/SmallVector.h" 102 #include "llvm/ADT/StringExtras.h" 103 #include "llvm/ADT/StringMap.h" 104 #include "llvm/ADT/StringRef.h" 105 #include "llvm/ADT/Triple.h" 106 #include "llvm/ADT/iterator_range.h" 107 #include "llvm/Bitstream/BitstreamReader.h" 108 #include "llvm/Support/Casting.h" 109 #include "llvm/Support/Compiler.h" 110 #include "llvm/Support/Compression.h" 111 #include "llvm/Support/DJB.h" 112 #include "llvm/Support/Endian.h" 113 #include "llvm/Support/Error.h" 114 #include "llvm/Support/ErrorHandling.h" 115 #include "llvm/Support/FileSystem.h" 116 #include "llvm/Support/MemoryBuffer.h" 117 #include "llvm/Support/Path.h" 118 #include "llvm/Support/SaveAndRestore.h" 119 #include "llvm/Support/Timer.h" 120 #include "llvm/Support/VersionTuple.h" 121 #include "llvm/Support/raw_ostream.h" 133 #include <system_error> 138 using namespace clang;
141 using llvm::BitstreamCursor;
149 return First->ReadFullVersionInformation(FullVersion) ||
150 Second->ReadFullVersionInformation(FullVersion);
154 First->ReadModuleName(ModuleName);
155 Second->ReadModuleName(ModuleName);
159 First->ReadModuleMapFile(ModuleMapPath);
160 Second->ReadModuleMapFile(ModuleMapPath);
166 bool AllowCompatibleDifferences) {
167 return First->ReadLanguageOptions(LangOpts, Complain,
168 AllowCompatibleDifferences) ||
169 Second->ReadLanguageOptions(LangOpts, Complain,
170 AllowCompatibleDifferences);
175 bool AllowCompatibleDifferences) {
176 return First->ReadTargetOptions(TargetOpts, Complain,
177 AllowCompatibleDifferences) ||
178 Second->ReadTargetOptions(TargetOpts, Complain,
179 AllowCompatibleDifferences);
184 return First->ReadDiagnosticOptions(DiagOpts, Complain) ||
185 Second->ReadDiagnosticOptions(DiagOpts, Complain);
191 return First->ReadFileSystemOptions(FSOpts, Complain) ||
192 Second->ReadFileSystemOptions(FSOpts, Complain);
198 return First->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
200 Second->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
206 std::string &SuggestedPredefines) {
207 return First->ReadPreprocessorOptions(PPOpts, Complain,
208 SuggestedPredefines) ||
209 Second->ReadPreprocessorOptions(PPOpts, Complain, SuggestedPredefines);
214 First->ReadCounter(M, Value);
215 Second->ReadCounter(M, Value);
219 return First->needsInputFileVisitation() ||
220 Second->needsInputFileVisitation();
224 return First->needsSystemInputFileVisitation() ||
225 Second->needsSystemInputFileVisitation();
230 First->visitModuleFile(Filename, Kind);
231 Second->visitModuleFile(Filename, Kind);
237 bool isExplicitModule) {
238 bool Continue =
false;
239 if (
First->needsInputFileVisitation() &&
240 (!isSystem ||
First->needsSystemInputFileVisitation()))
241 Continue |=
First->visitInputFile(Filename, isSystem, isOverridden,
243 if (Second->needsInputFileVisitation() &&
244 (!isSystem || Second->needsSystemInputFileVisitation()))
245 Continue |= Second->visitInputFile(Filename, isSystem, isOverridden,
252 First->readModuleFileExtension(Metadata);
253 Second->readModuleFileExtension(Metadata);
273 bool AllowCompatibleDifferences =
true) {
274 #define LANGOPT(Name, Bits, Default, Description) \ 275 if (ExistingLangOpts.Name != LangOpts.Name) { \ 277 Diags->Report(diag::err_pch_langopt_mismatch) \ 278 << Description << LangOpts.Name << ExistingLangOpts.Name; \ 282 #define VALUE_LANGOPT(Name, Bits, Default, Description) \ 283 if (ExistingLangOpts.Name != LangOpts.Name) { \ 285 Diags->Report(diag::err_pch_langopt_value_mismatch) \ 290 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 291 if (ExistingLangOpts.get##Name() != LangOpts.get##Name()) { \ 293 Diags->Report(diag::err_pch_langopt_value_mismatch) \ 298 #define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \ 299 if (!AllowCompatibleDifferences) \ 300 LANGOPT(Name, Bits, Default, Description) 302 #define COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) \ 303 if (!AllowCompatibleDifferences) \ 304 ENUM_LANGOPT(Name, Bits, Default, Description) 306 #define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \ 307 if (!AllowCompatibleDifferences) \ 308 VALUE_LANGOPT(Name, Bits, Default, Description) 310 #define BENIGN_LANGOPT(Name, Bits, Default, Description) 311 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) 312 #define BENIGN_VALUE_LANGOPT(Name, Type, Bits, Default, Description) 313 #include "clang/Basic/LangOptions.def" 317 Diags->
Report(diag::err_pch_langopt_value_mismatch) <<
"module features";
323 Diags->
Report(diag::err_pch_langopt_value_mismatch)
324 <<
"target Objective-C runtime";
331 Diags->
Report(diag::err_pch_langopt_value_mismatch)
332 <<
"block command names";
340 if (!AllowCompatibleDifferences) {
344 ExistingSanitizers.
clear(ModularSanitizers);
345 ImportedSanitizers.
clear(ModularSanitizers);
346 if (ExistingSanitizers.
Mask != ImportedSanitizers.
Mask) {
347 const std::string Flag =
"-fsanitize=";
349 #define SANITIZER(NAME, ID) \ 351 bool InExistingModule = ExistingSanitizers.has(SanitizerKind::ID); \ 352 bool InImportedModule = ImportedSanitizers.has(SanitizerKind::ID); \ 353 if (InExistingModule != InImportedModule) \ 354 Diags->Report(diag::err_pch_targetopt_feature_mismatch) \ 355 << InExistingModule << (Flag + NAME); \ 357 #include "clang/Basic/Sanitizers.def" 375 bool AllowCompatibleDifferences =
true) {
376 #define CHECK_TARGET_OPT(Field, Name) \ 377 if (TargetOpts.Field != ExistingTargetOpts.Field) { \ 379 Diags->Report(diag::err_pch_targetopt_mismatch) \ 380 << Name << TargetOpts.Field << ExistingTargetOpts.Field; \ 391 if (!AllowCompatibleDifferences)
394 #undef CHECK_TARGET_OPT 402 llvm::sort(ExistingFeatures);
403 llvm::sort(ReadFeatures);
409 ExistingFeatures.begin(), ExistingFeatures.end(), ReadFeatures.begin(),
410 ReadFeatures.end(), std::back_inserter(UnmatchedExistingFeatures));
411 std::set_difference(ReadFeatures.begin(), ReadFeatures.end(),
412 ExistingFeatures.begin(), ExistingFeatures.end(),
413 std::back_inserter(UnmatchedReadFeatures));
417 if (AllowCompatibleDifferences && UnmatchedReadFeatures.empty())
421 for (StringRef Feature : UnmatchedReadFeatures)
422 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
424 for (StringRef Feature : UnmatchedExistingFeatures)
425 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
429 return !UnmatchedReadFeatures.empty() || !UnmatchedExistingFeatures.empty();
435 bool AllowCompatibleDifferences) {
436 const LangOptions &ExistingLangOpts = PP.getLangOpts();
438 Complain ? &Reader.Diags :
nullptr,
439 AllowCompatibleDifferences);
444 bool AllowCompatibleDifferences) {
445 const TargetOptions &ExistingTargetOpts = PP.getTargetInfo().getTargetOpts();
447 Complain ? &Reader.Diags :
nullptr,
448 AllowCompatibleDifferences);
453 using MacroDefinitionsMap =
454 llvm::StringMap<std::pair<StringRef,
bool >>;
455 using DeclsMap = llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8>>;
470 for (
auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) {
479 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror=" +
498 bool IsSystem,
bool Complain) {
506 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Wsystem-headers";
513 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror";
520 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Weverything -Werror";
527 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-pedantic-errors";
551 assert(!ModuleName.empty() &&
"diagnostic options read before module name");
554 assert(M &&
"missing module");
569 assert(ModuleMgr.
size() >= 1 &&
"what ASTFile is this then");
585 MacroDefinitionsMap &Macros,
587 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
588 StringRef Macro = PPOpts.
Macros[I].first;
589 bool IsUndef = PPOpts.
Macros[I].second;
591 std::pair<StringRef, StringRef> MacroPair = Macro.split(
'=');
592 StringRef MacroName = MacroPair.first;
593 StringRef MacroBody = MacroPair.second;
597 if (MacroNames && !Macros.count(MacroName))
598 MacroNames->push_back(MacroName);
600 Macros[MacroName] = std::make_pair(
"",
true);
605 if (MacroName.size() == Macro.size())
609 StringRef::size_type
End = MacroBody.find_first_of(
"\n\r");
610 MacroBody = MacroBody.substr(0, End);
613 if (MacroNames && !Macros.count(MacroName))
614 MacroNames->push_back(MacroName);
615 Macros[MacroName] = std::make_pair(MacroBody,
false);
630 std::string &SuggestedPredefines,
632 bool Validate =
true) {
634 MacroDefinitionsMap ASTFileMacros;
636 MacroDefinitionsMap ExistingMacros;
640 for (
unsigned I = 0, N = ExistingMacroNames.size(); I != N; ++I) {
642 StringRef MacroName = ExistingMacroNames[I];
643 std::pair<StringRef, bool> Existing = ExistingMacros[MacroName];
646 llvm::StringMap<std::pair<StringRef,
bool >>::iterator Known =
647 ASTFileMacros.find(MacroName);
648 if (!Validate || Known == ASTFileMacros.end()) {
653 if (Existing.second) {
654 SuggestedPredefines +=
"#undef ";
655 SuggestedPredefines += MacroName.str();
656 SuggestedPredefines +=
'\n';
658 SuggestedPredefines +=
"#define ";
659 SuggestedPredefines += MacroName.str();
660 SuggestedPredefines +=
' ';
661 SuggestedPredefines += Existing.first.str();
662 SuggestedPredefines +=
'\n';
669 if (Existing.second != Known->second.second) {
671 Diags->
Report(diag::err_pch_macro_def_undef)
672 << MacroName << Known->second.second;
679 if (Existing.second || Existing.first == Known->second.first)
684 Diags->
Report(diag::err_pch_macro_def_conflict)
685 << MacroName << Known->second.first << Existing.first;
699 if (LangOpts.Modules &&
708 for (
unsigned I = 0, N = ExistingPPOpts.
Includes.size(); I != N; ++I) {
709 StringRef File = ExistingPPOpts.
Includes[I];
715 SuggestedPredefines +=
"#include \"";
716 SuggestedPredefines += File;
717 SuggestedPredefines +=
"\"\n";
728 SuggestedPredefines +=
"#include \"";
729 SuggestedPredefines += File;
730 SuggestedPredefines +=
"\"\n";
733 for (
unsigned I = 0, N = ExistingPPOpts.
MacroIncludes.size(); I != N; ++I) {
740 SuggestedPredefines +=
"#__include_macros \"";
741 SuggestedPredefines += File;
742 SuggestedPredefines +=
"\"\n##\n";
750 std::string &SuggestedPredefines) {
754 Complain? &Reader.Diags :
nullptr,
763 std::string &SuggestedPredefines) {
765 PP.getPreprocessorOpts(),
778 StringRef SpecificModuleCachePath,
779 StringRef ExistingModuleCachePath,
782 if (LangOpts.Modules) {
783 if (SpecificModuleCachePath != ExistingModuleCachePath) {
785 Diags->
Report(diag::err_pch_modulecache_mismatch)
786 << SpecificModuleCachePath << ExistingModuleCachePath;
795 StringRef SpecificModuleCachePath,
798 PP.getHeaderSearchInfo().getModuleCachePath(),
799 Complain ? &Reader.Diags :
nullptr,
804 PP.setCounterValue(Value);
812 bool TakeOwnership) {
813 DeserializationListener = Listener;
814 OwnsDeserializationListener = TakeOwnership;
821 std::pair<unsigned, unsigned>
823 using namespace llvm::support;
825 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
826 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
827 return std::make_pair(KeyLen, DataLen);
832 using namespace llvm::support;
835 unsigned N = endian::readNext<uint16_t, little, unaligned>(d);
837 F, endian::readNext<uint32_t, little, unaligned>(d));
844 Args.push_back(FirstII);
845 for (
unsigned I = 1; I != N; ++I)
846 Args.push_back(Reader.getLocalIdentifier(
847 F, endian::readNext<uint32_t, little, unaligned>(d)));
855 using namespace llvm::support;
859 Result.
ID = Reader.getGlobalSelectorID(
860 F, endian::readNext<uint32_t, little, unaligned>(d));
861 unsigned FullInstanceBits = endian::readNext<uint16_t, little, unaligned>(d);
862 unsigned FullFactoryBits = endian::readNext<uint16_t, little, unaligned>(d);
867 unsigned NumInstanceMethods = FullInstanceBits >> 3;
868 unsigned NumFactoryMethods = FullFactoryBits >> 3;
871 for (
unsigned I = 0; I != NumInstanceMethods; ++I) {
873 F, endian::readNext<uint32_t, little, unaligned>(d)))
878 for (
unsigned I = 0; I != NumFactoryMethods; ++I) {
880 F, endian::readNext<uint32_t, little, unaligned>(d)))
881 Result.
Factory.push_back(Method);
888 return llvm::djbHash(a);
891 std::pair<unsigned, unsigned>
893 using namespace llvm::support;
895 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
896 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
897 return std::make_pair(KeyLen, DataLen);
902 assert(n >= 2 && d[n-1] ==
'\0');
903 return StringRef((
const char*) d, n-1);
918 bool Value = Bits & 0x1;
924 using namespace llvm::support;
926 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
927 return Reader.getGlobalIdentifierID(F, RawID >> 1);
940 const unsigned char* d,
942 using namespace llvm::support;
944 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
945 bool IsInteresting = RawID & 0x01;
953 II = &Reader.getIdentifierTable().getOwn(k);
957 Reader.markIdentifierUpToDate(II);
959 IdentID ID = Reader.getGlobalIdentifierID(F, RawID);
960 if (!IsInteresting) {
963 Reader.SetIdentifierInfo(ID, II);
967 unsigned ObjCOrBuiltinID = endian::readNext<uint16_t, little, unaligned>(d);
968 unsigned Bits = endian::readNext<uint16_t, little, unaligned>(d);
969 bool CPlusPlusOperatorKeyword =
readBit(Bits);
970 bool HasRevertedTokenIDToIdentifier =
readBit(Bits);
971 bool HasRevertedBuiltin =
readBit(Bits);
973 bool ExtensionToken =
readBit(Bits);
974 bool HadMacroDefinition =
readBit(Bits);
976 assert(Bits == 0 &&
"Extra bits in the identifier?");
981 if (HasRevertedTokenIDToIdentifier && II->
getTokenID() != tok::identifier)
989 "Incorrect ObjC keyword or builtin ID");
992 "Incorrect extension token flag");
993 (void)ExtensionToken;
997 "Incorrect C++ operator keyword flag");
998 (void)CPlusPlusOperatorKeyword;
1002 if (HadMacroDefinition) {
1003 uint32_t MacroDirectivesOffset =
1004 endian::readNext<uint32_t, little, unaligned>(d);
1007 Reader.addPendingMacro(II, &F, MacroDirectivesOffset);
1010 Reader.SetIdentifierInfo(ID, II);
1016 for (; DataLen > 0; DataLen -= 4)
1017 DeclIDs.push_back(Reader.getGlobalDeclID(
1018 F, endian::readNext<uint32_t, little, unaligned>(d)));
1019 Reader.SetGloballyVisibleDecls(II, DeclIDs);
1026 :
Kind(Name.getNameKind()) {
1056 llvm::FoldingSetNodeID
ID;
1057 ID.AddInteger(
Kind);
1080 return ID.ComputeHash();
1084 ASTDeclContextNameLookupTrait::ReadFileRef(
const unsigned char *&d) {
1085 using namespace llvm::support;
1087 uint32_t ModuleFileID = endian::readNext<uint32_t, little, unaligned>(d);
1088 return Reader.getLocalModuleFile(F, ModuleFileID);
1091 std::pair<unsigned, unsigned>
1092 ASTDeclContextNameLookupTrait::ReadKeyDataLength(
const unsigned char *&d) {
1093 using namespace llvm::support;
1095 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
1096 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
1097 return std::make_pair(KeyLen, DataLen);
1101 ASTDeclContextNameLookupTrait::ReadKey(
const unsigned char *d,
unsigned) {
1102 using namespace llvm::support;
1110 Data = (uint64_t)Reader.getLocalIdentifier(
1111 F, endian::readNext<uint32_t, little, unaligned>(d));
1117 (uint64_t)Reader.getLocalSelector(
1118 F, endian::readNext<uint32_t, little, unaligned>(
1119 d)).getAsOpaquePtr();
1136 const unsigned char *d,
1139 using namespace llvm::support;
1141 for (
unsigned NumDecls = DataLen / 4; NumDecls; --NumDecls) {
1142 uint32_t LocalID = endian::readNext<uint32_t, little, unaligned>(d);
1143 Val.
insert(Reader.getGlobalDeclID(F, LocalID));
1147 bool ASTReader::ReadLexicalDeclContextStorage(
ModuleFile &M,
1155 Error(std::move(Err));
1163 Error(MaybeCode.takeError());
1166 unsigned Code = MaybeCode.get();
1169 if (!MaybeRecCode) {
1170 Error(MaybeRecCode.takeError());
1173 unsigned RecCode = MaybeRecCode.get();
1175 Error(
"Expected lexical block");
1179 assert(!isa<TranslationUnitDecl>(DC) &&
1180 "expected a TU_UPDATE_LEXICAL record for TU");
1185 auto &Lex = LexicalDecls[DC];
1187 Lex = std::make_pair(
1188 &M, llvm::makeArrayRef(
1189 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
1197 bool ASTReader::ReadVisibleDeclContextStorage(
ModuleFile &M,
1205 Error(std::move(Err));
1213 Error(MaybeCode.takeError());
1216 unsigned Code = MaybeCode.get();
1219 if (!MaybeRecCode) {
1220 Error(MaybeRecCode.takeError());
1223 unsigned RecCode = MaybeRecCode.get();
1225 Error(
"Expected visible lookup table block");
1231 auto *Data = (
const unsigned char*)Blob.data();
1232 PendingVisibleUpdates[
ID].push_back(PendingVisibleUpdate{&M, Data});
1236 void ASTReader::Error(StringRef Msg)
const {
1237 Error(diag::err_fe_pch_malformed, Msg);
1238 if (PP.getLangOpts().Modules && !Diags.isDiagnosticInFlight() &&
1239 !PP.getHeaderSearchInfo().getModuleCachePath().empty()) {
1240 Diag(diag::note_module_cache_path)
1241 << PP.getHeaderSearchInfo().getModuleCachePath();
1245 void ASTReader::Error(
unsigned DiagID, StringRef Arg1, StringRef Arg2,
1246 StringRef Arg3)
const {
1247 if (Diags.isDiagnosticInFlight())
1248 Diags.SetDelayedDiagnostic(DiagID, Arg1, Arg2, Arg3);
1250 Diag(DiagID) << Arg1 << Arg2 << Arg3;
1253 void ASTReader::Error(
unsigned DiagID, StringRef Arg1, StringRef Arg2,
1254 unsigned Select)
const {
1255 if (!Diags.isDiagnosticInFlight())
1256 Diag(DiagID) << Arg1 << Arg2 << Select;
1269 bool ASTReader::ParseLineTable(
ModuleFile &F,
1270 const RecordData &Record) {
1275 std::map<int, int> FileIDs;
1277 for (
unsigned I = 0; Record[Idx]; ++I) {
1279 auto Filename = ReadPath(F, Record, Idx);
1285 std::vector<LineEntry> Entries;
1286 while (Idx < Record.size()) {
1287 int FID = Record[Idx++];
1288 assert(FID >= 0 &&
"Serialized line entries for non-local file.");
1293 unsigned NumEntries = Record[Idx++];
1294 assert(NumEntries &&
"no line entries for file ID");
1296 Entries.reserve(NumEntries);
1297 for (
unsigned I = 0; I != NumEntries; ++I) {
1298 unsigned FileOffset = Record[Idx++];
1299 unsigned LineNo = Record[Idx++];
1300 int FilenameID = FileIDs[Record[Idx++]];
1303 unsigned IncludeOffset = Record[Idx++];
1305 FileKind, IncludeOffset));
1307 LineTable.
AddEntry(FileID::get(FID), Entries);
1314 bool ASTReader::ReadSourceManagerBlock(
ModuleFile &F) {
1315 using namespace SrcMgr;
1323 SLocEntryCursor = F.
Stream;
1327 Error(std::move(Err));
1334 Error(std::move(Err));
1341 SLocEntryCursor.advanceSkippingSubblocks();
1343 Error(MaybeE.takeError());
1346 llvm::BitstreamEntry E = MaybeE.get();
1349 case llvm::BitstreamEntry::SubBlock:
1351 Error(
"malformed block record in AST file");
1353 case llvm::BitstreamEntry::EndBlock:
1355 case llvm::BitstreamEntry::Record:
1364 SLocEntryCursor.readRecord(E.ID, Record, &Blob);
1366 Error(MaybeRecord.takeError());
1369 switch (MaybeRecord.get()) {
1388 const std::string &OriginalDir,
1389 const std::string &CurrDir) {
1390 assert(OriginalDir != CurrDir &&
1391 "No point trying to resolve the file if the PCH dir didn't change");
1396 fs::make_absolute(filePath);
1397 assert(path::is_absolute(OriginalDir));
1400 path::const_iterator fileDirI = path::begin(path::parent_path(filePath)),
1401 fileDirE = path::end(path::parent_path(filePath));
1402 path::const_iterator origDirI = path::begin(OriginalDir),
1403 origDirE = path::end(OriginalDir);
1405 while (fileDirI != fileDirE && origDirI != origDirE &&
1406 *fileDirI == *origDirI) {
1410 for (; origDirI != origDirE; ++origDirI)
1411 path::append(currPCHPath,
"..");
1412 path::append(currPCHPath, fileDirI, fileDirE);
1413 path::append(currPCHPath, path::filename(Filename));
1414 return currPCHPath.str();
1421 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1422 Error(
"source location entry ID out-of-range for AST file");
1428 auto ReadBuffer = [
this](
1429 BitstreamCursor &SLocEntryCursor,
1430 StringRef Name) -> std::unique_ptr<llvm::MemoryBuffer> {
1435 Error(MaybeCode.takeError());
1438 unsigned Code = MaybeCode.get();
1441 SLocEntryCursor.readRecord(Code, Record, &Blob);
1442 if (!MaybeRecCode) {
1443 Error(MaybeRecCode.takeError());
1446 unsigned RecCode = MaybeRecCode.get();
1449 if (!llvm::zlib::isAvailable()) {
1450 Error(
"zlib is not available");
1455 llvm::zlib::uncompress(Blob, Uncompressed, Record[0])) {
1456 Error(
"could not decompress embedded file contents: " +
1460 return llvm::MemoryBuffer::getMemBufferCopy(Uncompressed, Name);
1462 return llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name,
true);
1464 Error(
"AST record has invalid code");
1469 ModuleFile *F = GlobalSLocEntryMap.find(-ID)->second;
1472 Error(std::move(Err));
1479 ++NumSLocEntriesRead;
1482 Error(MaybeEntry.takeError());
1485 llvm::BitstreamEntry Entry = MaybeEntry.get();
1487 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1488 Error(
"incorrectly-formatted source location entry in AST file");
1495 SLocEntryCursor.readRecord(Entry.ID, Record, &Blob);
1497 Error(MaybeSLOC.takeError());
1500 switch (MaybeSLOC.get()) {
1502 Error(
"incorrectly-formatted source location entry in AST file");
1508 unsigned InputID = Record[4];
1509 InputFile IF = getInputFile(*F, InputID);
1522 IncludeLoc = getImportLocation(F);
1527 FileID FID = SourceMgr.createFileID(File, IncludeLoc, FileCharacter,
1528 ID, BaseOffset + Record[0]);
1531 FileInfo.NumCreatedFIDs = Record[5];
1535 unsigned NumFileDecls = Record[7];
1536 if (NumFileDecls && ContextObj) {
1538 assert(F->
FileSortedDecls &&
"FILE_SORTED_DECLS not encountered yet ?");
1539 FileDeclIDs[FID] = FileDeclsInfo(F, llvm::makeArrayRef(FirstDecl,
1544 = SourceMgr.getOrCreateContentCache(File,
isSystem(FileCharacter));
1548 auto Buffer = ReadBuffer(SLocEntryCursor, File->
getName());
1551 SourceMgr.overrideFileContents(File, std::move(Buffer));
1558 const char *Name = Blob.data();
1559 unsigned Offset = Record[0];
1564 IncludeLoc = getImportLocation(F);
1567 auto Buffer = ReadBuffer(SLocEntryCursor, Name);
1570 SourceMgr.createFileID(std::move(Buffer), FileCharacter, ID,
1571 BaseOffset + Offset, IncludeLoc);
1577 SourceMgr.createExpansionLoc(SpellingLoc,
1578 ReadSourceLocation(*F, Record[2]),
1579 ReadSourceLocation(*F, Record[3]),
1583 BaseOffset + Record[0]);
1595 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1596 Error(
"source location entry ID out-of-range for AST file");
1601 ModuleFile *M = GlobalSLocEntryMap.find(-ID)->second;
1619 assert(SourceMgr.getMainFileID().isValid() &&
"missing main file");
1620 return SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
1629 if (
llvm::Error Err = Cursor.EnterSubBlock(BlockID)) {
1631 consumeError(std::move(Err));
1636 uint64_t
Offset = Cursor.GetCurrentBitNo();
1640 consumeError(MaybeCode.takeError());
1643 unsigned Code = MaybeCode.get();
1646 if (Code != llvm::bitc::DEFINE_ABBREV) {
1649 consumeError(std::move(Err));
1654 if (
llvm::Error Err = Cursor.ReadAbbrevRecord()) {
1656 consumeError(std::move(Err));
1666 Tok.
setLocation(ReadSourceLocation(F, Record, Idx));
1684 consumeError(std::move(Err));
1695 unsigned Flags = BitstreamCursor::AF_DontPopBlockAtEnd;
1697 Stream.advanceSkippingSubblocks(Flags);
1699 Error(MaybeEntry.takeError());
1702 llvm::BitstreamEntry Entry = MaybeEntry.get();
1704 switch (Entry.Kind) {
1705 case llvm::BitstreamEntry::SubBlock:
1707 Error(
"malformed block record in AST file");
1709 case llvm::BitstreamEntry::EndBlock:
1711 case llvm::BitstreamEntry::Record:
1722 Error(MaybeRecType.takeError());
1738 unsigned NextIndex = 1;
1740 MacroInfo *MI = PP.AllocateMacroInfo(Loc);
1747 bool isC99VarArgs = Record[NextIndex++];
1748 bool isGNUVarArgs = Record[NextIndex++];
1749 bool hasCommaPasting = Record[NextIndex++];
1750 MacroParams.clear();
1751 unsigned NumArgs = Record[NextIndex++];
1752 for (
unsigned i = 0; i != NumArgs; ++i)
1753 MacroParams.push_back(getLocalIdentifier(F, Record[NextIndex++]));
1767 if (NextIndex + 1 == Record.size() && PP.getPreprocessingRecord() &&
1768 Record[NextIndex]) {
1771 GlobalID = getGlobalPreprocessedEntityID(F, Record[NextIndex]);
1773 PreprocessingRecord::PPEntityID PPID =
1774 PPRec.getPPEntityID(GlobalID - 1,
true);
1776 PPRec.getPreprocessedEntity(PPID));
1778 PPRec.RegisterMacroDefinition(Macro, PPDef);
1791 Token Tok = ReadToken(F, Record, Idx);
1801 unsigned LocalID)
const {
1803 ReadModuleOffsetMap(M);
1808 &&
"Invalid index into preprocessed entity index remap");
1810 return LocalID + I->second;
1835 if (!Key.Imported) {
1836 if (
auto File = FileMgr.
getFile(Key.Filename))
1841 std::string Resolved = Key.Filename;
1842 Reader.ResolveImportedPath(M, Resolved);
1843 if (
auto File = FileMgr.
getFile(Resolved))
1850 return FEA && FEA == FEB;
1853 std::pair<unsigned, unsigned>
1854 HeaderFileInfoTrait::ReadKeyDataLength(
const unsigned char*& d) {
1855 using namespace llvm::support;
1857 unsigned KeyLen = (unsigned) endian::readNext<uint16_t, little, unaligned>(d);
1858 unsigned DataLen = (unsigned) *d++;
1859 return std::make_pair(KeyLen, DataLen);
1863 HeaderFileInfoTrait::ReadKey(
const unsigned char *d,
unsigned) {
1864 using namespace llvm::support;
1867 ikey.
Size = off_t(endian::readNext<uint64_t, little, unaligned>(d));
1868 ikey.
ModTime = time_t(endian::readNext<uint64_t, little, unaligned>(d));
1877 using namespace llvm::support;
1879 const unsigned char *
End = d + DataLen;
1881 unsigned Flags = *d++;
1883 HFI.
isImport |= (Flags >> 5) & 0x01;
1885 HFI.
DirInfo = (Flags >> 1) & 0x07;
1892 M, endian::readNext<uint32_t, little, unaligned>(d));
1893 if (
unsigned FrameworkOffset =
1894 endian::readNext<uint32_t, little, unaligned>(d)) {
1897 StringRef FrameworkName(FrameworkStrings + FrameworkOffset - 1);
1898 HFI.
Framework = HS->getUniqueFrameworkName(FrameworkName);
1901 assert((End - d) % 4 == 0 &&
1902 "Wrong data length in HeaderFileInfo deserialization");
1904 uint32_t LocalSMID = endian::readNext<uint32_t, little, unaligned>(d);
1910 SubmoduleID GlobalSMID = Reader.getGlobalSubmoduleID(M, LocalSMID);
1911 Module *Mod = Reader.getSubmodule(GlobalSMID);
1914 Reader.getPreprocessor().getHeaderSearchInfo().getModuleMap();
1918 Reader.ResolveImportedPath(M, Filename);
1923 ModMap.
addHeader(Mod, H, HeaderRole,
true);
1935 uint64_t MacroDirectivesOffset) {
1936 assert(NumCurrentElementsDeserializing > 0 &&
"Missing deserialization guard");
1937 PendingMacroIDs[II].push_back(PendingMacroInfo(M, MacroDirectivesOffset));
1944 for (
ModuleFile &I : llvm::reverse(ModuleMgr)) {
1945 BitstreamCursor &MacroCursor = I.MacroCursor;
1948 if (MacroCursor.getBitcodeBytes().empty())
1951 BitstreamCursor
Cursor = MacroCursor;
1952 if (
llvm::Error Err = Cursor.JumpToBit(I.MacroStartOffset)) {
1953 Error(std::move(Err));
1961 Error(MaybeE.takeError());
1964 llvm::BitstreamEntry E = MaybeE.get();
1967 case llvm::BitstreamEntry::SubBlock:
1969 Error(
"malformed block record in AST file");
1971 case llvm::BitstreamEntry::EndBlock:
1974 case llvm::BitstreamEntry::Record: {
1978 Error(MaybeRecord.takeError());
1981 switch (MaybeRecord.get()) {
1989 updateOutOfDateIdentifier(*II);
2008 class IdentifierLookupVisitor {
2011 unsigned PriorGeneration;
2012 unsigned &NumIdentifierLookups;
2013 unsigned &NumIdentifierLookupHits;
2017 IdentifierLookupVisitor(StringRef Name,
unsigned PriorGeneration,
2018 unsigned &NumIdentifierLookups,
2019 unsigned &NumIdentifierLookupHits)
2021 PriorGeneration(PriorGeneration),
2022 NumIdentifierLookups(NumIdentifierLookups),
2023 NumIdentifierLookupHits(NumIdentifierLookupHits) {}
2037 ++NumIdentifierLookups;
2038 ASTIdentifierLookupTable::iterator Pos =
2039 IdTable->find_hashed(Name, NameHash, &Trait);
2040 if (Pos == IdTable->end())
2046 ++NumIdentifierLookupHits;
2062 unsigned PriorGeneration = 0;
2063 if (getContext().getLangOpts().Modules)
2064 PriorGeneration = IdentifierGeneration[&II];
2070 if (!loadGlobalIndex()) {
2071 if (GlobalIndex->lookupIdentifier(II.
getName(), Hits)) {
2076 IdentifierLookupVisitor Visitor(II.
getName(), PriorGeneration,
2077 NumIdentifierLookups,
2078 NumIdentifierLookupHits);
2079 ModuleMgr.visit(Visitor, HitsPtr);
2080 markIdentifierUpToDate(&II);
2090 if (getContext().getLangOpts().Modules)
2091 IdentifierGeneration[II] = getGeneration();
2095 const PendingMacroInfo &PMInfo) {
2100 if (
llvm::Error Err = Cursor.JumpToBit(PMInfo.MacroDirectivesOffset)) {
2101 Error(std::move(Err));
2105 struct ModuleMacroRecord {
2118 Cursor.advance(BitstreamCursor::AF_DontPopBlockAtEnd);
2120 Error(MaybeEntry.takeError());
2123 llvm::BitstreamEntry Entry = MaybeEntry.get();
2125 if (Entry.Kind != llvm::BitstreamEntry::Record) {
2126 Error(
"malformed block record in AST file");
2133 Error(MaybePP.takeError());
2141 ModuleMacros.push_back(ModuleMacroRecord());
2142 auto &Info = ModuleMacros.back();
2143 Info.SubModID = getGlobalSubmoduleID(M, Record[0]);
2144 Info.MI = getMacro(getGlobalMacroID(M, Record[1]));
2145 for (
int I = 2, N = Record.size(); I != N; ++I)
2146 Info.Overrides.push_back(getGlobalSubmoduleID(M, Record[I]));
2151 Error(
"malformed block record in AST file");
2162 std::reverse(ModuleMacros.begin(), ModuleMacros.end());
2164 for (
auto &MMR : ModuleMacros) {
2166 for (
unsigned ModID : MMR.Overrides) {
2167 Module *Mod = getSubmodule(ModID);
2168 auto *Macro = PP.getModuleMacro(Mod, II);
2169 assert(Macro &&
"missing definition for overridden macro");
2170 Overrides.push_back(Macro);
2173 bool Inserted =
false;
2174 Module *Owner = getSubmodule(MMR.SubModID);
2175 PP.addModuleMacro(Owner, II, MMR.MI, Overrides, Inserted);
2186 unsigned Idx = 0, N = Record.size();
2193 MacroInfo *MI = getMacro(getGlobalMacroID(M, Record[Idx++]));
2194 MD = PP.AllocateDefMacroDirective(MI, Loc);
2198 MD = PP.AllocateUndefMacroDirective(Loc);
2201 bool isPublic = Record[Idx++];
2202 MD = PP.AllocateVisibilityMacroDirective(Loc, isPublic);
2214 PP.setLoadedMacroDirective(II, Earliest, Latest);
2217 ASTReader::InputFileInfo
2218 ASTReader::readInputFileInfo(
ModuleFile &F,
unsigned ID) {
2224 consumeError(std::move(Err));
2230 consumeError(MaybeCode.takeError());
2232 unsigned Code = MaybeCode.get();
2237 assert(static_cast<InputFileRecordTypes>(Maybe.get()) ==
INPUT_FILE &&
2238 "invalid record type for input file");
2241 consumeError(Maybe.takeError());
2244 assert(Record[0] == ID &&
"Bogus stored ID or offset");
2246 R.StoredSize =
static_cast<off_t
>(Record[1]);
2247 R.StoredTime =
static_cast<time_t
>(Record[2]);
2248 R.Overridden =
static_cast<bool>(Record[3]);
2249 R.Transient =
static_cast<bool>(Record[4]);
2250 R.TopLevelModuleMap =
static_cast<bool>(Record[5]);
2252 ResolveImportedPath(F, R.Filename);
2256 consumeError(MaybeEntry.takeError());
2257 llvm::BitstreamEntry Entry = MaybeEntry.get();
2258 assert(Entry.Kind == llvm::BitstreamEntry::Record &&
2259 "expected record type for input file hash");
2263 assert(static_cast<InputFileRecordTypes>(Maybe.get()) ==
INPUT_FILE_HASH &&
2264 "invalid record type for input file hash");
2267 consumeError(Maybe.takeError());
2269 R.ContentHash = (
static_cast<uint64_t
>(Record[1]) << 32) |
2270 static_cast<uint64_t
>(Record[0]);
2292 consumeError(std::move(Err));
2295 InputFileInfo FI = readInputFileInfo(F,
ID);
2296 off_t StoredSize = FI.StoredSize;
2297 time_t StoredTime = FI.StoredTime;
2298 bool Overridden = FI.Overridden;
2299 bool Transient = FI.Transient;
2301 uint64_t StoredContentHash = FI.ContentHash;
2304 if (
auto FE = FileMgr.getFile(Filename,
false))
2313 if (!Resolved.empty())
2314 if (
auto FE = FileMgr.getFile(Resolved))
2320 if ((Overridden || Transient) && File ==
nullptr)
2321 File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime);
2323 if (File ==
nullptr) {
2325 std::string ErrorStr =
"could not find file '";
2327 ErrorStr +=
"' referenced by AST file '";
2345 Error(diag::err_fe_pch_file_overridden, Filename);
2356 enum ModificationType {
2362 auto HasInputFileChanged = [&]() {
2363 if (StoredSize != File->
getSize())
2364 return ModificationType::Size;
2365 if (!DisableValidation && StoredTime &&
2369 if (ValidateASTInputFilesContent &&
2370 StoredContentHash != static_cast<uint64_t>(llvm::hash_code(-1))) {
2371 auto MemBuffOrError = FileMgr.getBufferForFile(File);
2372 if (!MemBuffOrError) {
2374 return ModificationType::ModTime;
2375 std::string ErrorStr =
"could not get buffer for file '";
2379 return ModificationType::ModTime;
2382 auto ContentHash =
hash_value(MemBuffOrError.get()->getBuffer());
2383 if (StoredContentHash == static_cast<uint64_t>(ContentHash))
2385 return ModificationType::Content;
2387 return ModificationType::ModTime;
2392 bool IsOutOfDate =
false;
2393 auto FileChange = HasInputFileChanged();
2399 while (!ImportStack.back()->ImportedBy.empty())
2400 ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
2403 StringRef TopLevelPCHName(ImportStack.back()->FileName);
2404 unsigned DiagnosticKind =
2406 if (DiagnosticKind == 0)
2407 Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName,
2408 (
unsigned)FileChange);
2409 else if (DiagnosticKind == 1)
2410 Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName,
2411 (
unsigned)FileChange);
2413 Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName,
2414 (
unsigned)FileChange);
2417 if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
2418 Diag(diag::note_pch_required_by)
2419 << Filename << ImportStack[0]->FileName;
2420 for (
unsigned I = 1; I < ImportStack.size(); ++I)
2421 Diag(diag::note_pch_required_by)
2422 << ImportStack[I-1]->FileName << ImportStack[I]->FileName;
2425 if (!Diags.isDiagnosticInFlight())
2426 Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
2451 if (Filename.empty() || llvm::sys::path::is_absolute(Filename))
2455 llvm::sys::path::append(Buffer, Prefix, Filename);
2456 Filename.assign(Buffer.begin(), Buffer.end());
2471 llvm_unreachable(
"unknown ASTReadResult");
2475 BitstreamCursor &Stream,
unsigned ClientLoadCapabilities,
2477 std::string &SuggestedPredefines) {
2480 consumeError(std::move(Err));
2486 ASTReadResult Result = Success;
2491 consumeError(MaybeEntry.takeError());
2494 llvm::BitstreamEntry Entry = MaybeEntry.get();
2496 switch (Entry.Kind) {
2498 case llvm::BitstreamEntry::SubBlock:
2501 case llvm::BitstreamEntry::EndBlock:
2504 case llvm::BitstreamEntry::Record:
2512 if (!MaybeRecordType) {
2514 consumeError(MaybeRecordType.takeError());
2519 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2520 if (ParseLanguageOptions(Record, Complain, Listener,
2521 AllowCompatibleConfigurationMismatch))
2522 Result = ConfigurationMismatch;
2527 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2528 if (ParseTargetOptions(Record, Complain, Listener,
2529 AllowCompatibleConfigurationMismatch))
2530 Result = ConfigurationMismatch;
2535 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2536 if (!AllowCompatibleConfigurationMismatch &&
2537 ParseFileSystemOptions(Record, Complain, Listener))
2538 Result = ConfigurationMismatch;
2543 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2544 if (!AllowCompatibleConfigurationMismatch &&
2545 ParseHeaderSearchOptions(Record, Complain, Listener))
2546 Result = ConfigurationMismatch;
2551 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2552 if (!AllowCompatibleConfigurationMismatch &&
2553 ParsePreprocessorOptions(Record, Complain, Listener,
2554 SuggestedPredefines))
2555 Result = ConfigurationMismatch;
2565 unsigned ClientLoadCapabilities) {
2566 BitstreamCursor &Stream = F.
Stream;
2569 Error(std::move(Err));
2579 bool HasReadUnhashedControlBlock =
false;
2580 auto readUnhashedControlBlockOnce = [&]() {
2581 if (!HasReadUnhashedControlBlock) {
2582 HasReadUnhashedControlBlock =
true;
2583 if (ASTReadResult Result =
2584 readUnhashedControlBlock(F, ImportedBy, ClientLoadCapabilities))
2592 unsigned NumInputs = 0;
2593 unsigned NumUserInputs = 0;
2594 StringRef BaseDirectoryAsWritten;
2598 Error(MaybeEntry.takeError());
2601 llvm::BitstreamEntry Entry = MaybeEntry.get();
2603 switch (Entry.Kind) {
2605 Error(
"malformed block record in AST file");
2607 case llvm::BitstreamEntry::EndBlock: {
2610 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2615 PP.getHeaderSearchInfo().getHeaderSearchOpts();
2622 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
2628 unsigned N = NumUserInputs;
2629 if (ValidateSystemInputs ||
2635 for (
unsigned I = 0; I < N; ++I) {
2636 InputFile IF = getInputFile(F, I+1, Complain);
2648 for (
unsigned I = 0; I < N; ++I) {
2649 bool IsSystem = I >= NumUserInputs;
2650 InputFileInfo FI = readInputFileInfo(F, I+1);
2660 case llvm::BitstreamEntry::SubBlock:
2665 Error(std::move(Err));
2669 Error(
"malformed block record in AST file");
2678 if (Listener && !ImportedBy) {
2684 bool AllowCompatibleConfigurationMismatch =
2687 ASTReadResult Result =
2688 ReadOptionsBlock(Stream, ClientLoadCapabilities,
2689 AllowCompatibleConfigurationMismatch, *Listener,
2690 SuggestedPredefines);
2691 if (Result == Failure) {
2692 Error(
"malformed block record in AST file");
2696 if (DisableValidation ||
2697 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
2703 if (Result != Success)
2705 }
else if (
llvm::Error Err = Stream.SkipBlock()) {
2706 Error(std::move(Err));
2713 Error(std::move(Err));
2719 case llvm::BitstreamEntry::Record:
2728 Stream.readRecord(Entry.ID, Record, &Blob);
2729 if (!MaybeRecordType) {
2730 Error(MaybeRecordType.takeError());
2736 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2738 : diag::err_pch_version_too_new);
2739 return VersionMismatch;
2742 bool hasErrors = Record[7];
2743 if (hasErrors && !DisableValidation && !AllowASTWithCompilerErrors) {
2744 Diag(diag::err_pch_with_compiler_errors);
2748 Diags.ErrorOccurred =
true;
2749 Diags.UncompilableErrorOccurred =
true;
2750 Diags.UnrecoverableErrorOccurred =
true;
2763 StringRef ASTBranch = Blob;
2764 if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
2765 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2766 Diag(diag::err_pch_different_branch) << ASTBranch << CurBranch;
2767 return VersionMismatch;
2776 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2780 unsigned Idx = 0, N = Record.size();
2788 ReadUntranslatedSourceLocation(Record[Idx++]);
2789 off_t StoredSize = (off_t)Record[Idx++];
2790 time_t StoredModTime = (time_t)Record[Idx++];
2792 {{(uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
2793 (uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
2794 (uint32_t)Record[Idx++]}}};
2796 std::string ImportedName = ReadString(Record, Idx);
2797 std::string ImportedFile;
2805 ImportedFile = PP.getHeaderSearchInfo().getPrebuiltModuleFileName(
2806 ImportedName,
true);
2808 if (ImportedFile.empty())
2811 ImportedFile = ReadPath(BaseDirectoryAsWritten, Record, Idx);
2813 SkipPath(Record, Idx);
2817 unsigned Capabilities = ClientLoadCapabilities;
2818 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2819 Capabilities &= ~ARR_Missing;
2822 auto Result = ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F,
2823 Loaded, StoredSize, StoredModTime,
2824 StoredSignature, Capabilities);
2828 Diag(diag::note_module_file_imported_by)
2832 case Failure:
return Failure;
2835 case OutOfDate:
return OutOfDate;
2836 case VersionMismatch:
return VersionMismatch;
2837 case ConfigurationMismatch:
return ConfigurationMismatch;
2838 case HadErrors:
return HadErrors;
2839 case Success:
break;
2862 Diag(diag::remark_module_import)
2864 << (ImportedBy ? StringRef(ImportedBy->
ModuleName) : StringRef());
2870 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2878 BaseDirectoryAsWritten = Blob;
2880 "MODULE_DIRECTORY found before MODULE_NAME");
2883 Module *M = PP.getHeaderSearchInfo().lookupModule(
2886 if (M && M->Directory) {
2890 if (!PP.getPreprocessorOpts().DisablePCHValidation &&
2892 auto BuildDir = PP.getFileManager().getDirectory(Blob);
2893 if (!BuildDir || *BuildDir != M->Directory) {
2894 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2895 Diag(diag::err_imported_module_relocated)
2896 << F.
ModuleName << Blob << M->Directory->getName();
2908 if (ASTReadResult Result =
2909 ReadModuleMapFileBlock(Record, F, ImportedBy, ClientLoadCapabilities))
2914 NumInputs = Record[0];
2915 NumUserInputs = Record[1];
2917 (
const llvm::support::unaligned_uint64_t *)Blob.data();
2926 ASTReader::ReadASTBlock(
ModuleFile &F,
unsigned ClientLoadCapabilities) {
2927 BitstreamCursor &Stream = F.
Stream;
2930 Error(std::move(Err));
2939 Error(MaybeEntry.takeError());
2942 llvm::BitstreamEntry Entry = MaybeEntry.get();
2944 switch (Entry.Kind) {
2946 Error(
"error at end of module block in AST file");
2948 case llvm::BitstreamEntry::EndBlock:
2961 case llvm::BitstreamEntry::SubBlock:
2970 Error(std::move(Err));
2974 Error(
"malformed block record in AST file");
2981 if (!PP.getExternalSource())
2982 PP.setExternalSource(
this);
2985 Error(std::move(Err));
2989 Error(
"malformed block record in AST file");
2999 Error(std::move(Err));
3004 Error(
"malformed preprocessor detail record in AST file");
3010 if (!PP.getPreprocessingRecord())
3011 PP.createPreprocessingRecord();
3012 if (!PP.getPreprocessingRecord()->getExternalSource())
3013 PP.getPreprocessingRecord()->SetExternalSource(*
this);
3017 if (ReadSourceManagerBlock(F))
3022 if (ASTReadResult Result =
3023 ReadSubmoduleBlock(F, ClientLoadCapabilities))
3028 BitstreamCursor C = Stream;
3031 Error(std::move(Err));
3035 Error(
"malformed comments block in AST file");
3038 CommentsCursors.push_back(std::make_pair(C, &F));
3044 Error(std::move(Err));
3051 case llvm::BitstreamEntry::Record:
3060 Stream.readRecord(Entry.ID, Record, &Blob);
3061 if (!MaybeRecordType) {
3062 Error(MaybeRecordType.takeError());
3069 switch (RecordType) {
3090 switch (RecordType) {
3096 Error(
"duplicate TYPE_OFFSET record in AST file");
3101 unsigned LocalBaseTypeIndex = Record[1];
3106 GlobalTypeMap.insert(std::make_pair(getTotalNumTypes(), &F));
3110 std::make_pair(LocalBaseTypeIndex,
3120 Error(
"duplicate DECL_OFFSET record in AST file");
3125 unsigned LocalBaseDeclID = Record[1];
3131 GlobalDeclMap.insert(
3137 std::make_pair(LocalBaseDeclID, F.
BaseDeclID - LocalBaseDeclID));
3149 DeclContext *TU = ContextObj->getTranslationUnitDecl();
3150 LexicalContents Contents(
3151 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
3153 static_cast<unsigned int>(Blob.size() / 4));
3154 TULexicalDecls.push_back(std::make_pair(&F, Contents));
3162 auto *Data = (
const unsigned char*)Blob.data();
3163 PendingVisibleUpdates[
ID].push_back(PendingVisibleUpdate{&F, Data});
3166 if (
Decl *D = GetExistingDecl(ID))
3167 PendingUpdateRecords.push_back(
3168 PendingUpdateRecord(ID, D,
false));
3181 PP.getIdentifierTable().setExternalIdentifierLookup(
this);
3187 Error(
"duplicate IDENTIFIER_OFFSET record in AST file");
3192 unsigned LocalBaseIdentifierID = Record[1];
3198 GlobalIdentifierMap.insert(std::make_pair(getTotalNumIdentifiers() + 1,
3204 std::make_pair(LocalBaseIdentifierID,
3207 IdentifiersLoaded.resize(IdentifiersLoaded.size()
3220 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3221 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
3228 getContext().getLangOpts().BuildingPCHWithObjectFile)
3229 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3230 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
3234 if (SpecialTypes.empty()) {
3235 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3236 SpecialTypes.push_back(getGlobalTypeID(F, Record[I]));
3240 if (SpecialTypes.size() != Record.size()) {
3241 Error(
"invalid special-types record");
3245 for (
unsigned I = 0, N = Record.size(); I != N; ++I) {
3247 if (!SpecialTypes[I])
3248 SpecialTypes[I] =
ID;
3255 TotalNumStatements += Record[0];
3256 TotalNumMacros += Record[1];
3257 TotalLexicalDeclContexts += Record[2];
3258 TotalVisibleDeclContexts += Record[3];
3262 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3263 UnusedFileScopedDecls.push_back(getGlobalDeclID(F, Record[I]));
3267 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3268 DelegatingCtorDecls.push_back(getGlobalDeclID(F, Record[I]));
3272 if (Record.size() % 4 != 0) {
3273 Error(
"invalid weak identifiers record");
3279 WeakUndeclaredIdentifiers.clear();
3282 for (
unsigned I = 0, N = Record.size(); I < N; ) {
3283 WeakUndeclaredIdentifiers.push_back(
3284 getGlobalIdentifierID(F, Record[I++]));
3285 WeakUndeclaredIdentifiers.push_back(
3286 getGlobalIdentifierID(F, Record[I++]));
3287 WeakUndeclaredIdentifiers.push_back(
3288 ReadSourceLocation(F, Record, I).getRawEncoding());
3289 WeakUndeclaredIdentifiers.push_back(Record[I++]);
3296 unsigned LocalBaseSelectorID = Record[1];
3302 GlobalSelectorMap.insert(std::make_pair(getTotalNumSelectors()+1, &F));
3307 std::make_pair(LocalBaseSelectorID,
3323 TotalNumMethodPoolEntries += Record[1];
3327 if (!Record.empty()) {
3328 for (
unsigned Idx = 0, N = Record.size() - 1; Idx < N; ) {
3329 ReferencedSelectorsData.push_back(getGlobalSelectorID(F,
3331 ReferencedSelectorsData.push_back(ReadSourceLocation(F, Record, Idx).
3338 if (!Record.empty()) {
3339 unsigned Idx = 0,
End = Record.size() - 1;
3340 bool ReachedEOFWhileSkipping = Record[Idx++];
3342 if (ReachedEOFWhileSkipping) {
3345 bool FoundNonSkipPortion = Record[Idx++];
3346 bool FoundElse = Record[Idx++];
3348 SkipInfo.emplace(HashToken, IfTokenLoc, FoundNonSkipPortion,
3349 FoundElse, ElseLoc);
3353 auto Loc = ReadSourceLocation(F, Record, Idx);
3354 bool WasSkipping = Record[Idx++];
3355 bool FoundNonSkip = Record[Idx++];
3356 bool FoundElse = Record[Idx++];
3357 ConditionalStack.push_back(
3358 {Loc, WasSkipping, FoundNonSkip, FoundElse});
3360 PP.setReplayablePreambleConditionalStack(ConditionalStack, SkipInfo);
3365 if (!Record.empty() && Listener)
3377 unsigned SLocSpaceSize = Record[1];
3382 Error(
"ran out of source locations");
3388 unsigned RangeStart =
3390 GlobalSLocEntryMap.insert(std::make_pair(RangeStart, &F));
3395 GlobalSLocOffsetMap.insert(
3397 - SLocSpaceSize,&F));
3415 if (ParseLineTable(F, Record)) {
3416 Error(
"malformed SOURCE_MANAGER_LINE_TABLE in AST file");
3425 Error(
"Multiple SOURCE_LOCATION_PRELOADS records in AST file");
3434 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3435 ExtVectorDecls.push_back(getGlobalDeclID(F, Record[I]));
3439 if (Record.size() % 3 != 0) {
3440 Error(
"Invalid VTABLE_USES record");
3449 for (
unsigned Idx = 0, N = Record.size(); Idx != N; ) {
3450 VTableUses.push_back(getGlobalDeclID(F, Record[Idx++]));
3451 VTableUses.push_back(
3452 ReadSourceLocation(F, Record, Idx).getRawEncoding());
3453 VTableUses.push_back(Record[Idx++]);
3458 if (PendingInstantiations.size() % 2 != 0) {
3459 Error(
"Invalid existing PendingInstantiations");
3463 if (Record.size() % 2 != 0) {
3464 Error(
"Invalid PENDING_IMPLICIT_INSTANTIATIONS block");
3468 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3469 PendingInstantiations.push_back(getGlobalDeclID(F, Record[I++]));
3470 PendingInstantiations.push_back(
3471 ReadSourceLocation(F, Record, I).getRawEncoding());
3476 if (Record.size() != 3) {
3477 Error(
"Invalid SEMA_DECL_REFS block");
3480 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3481 SemaDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
3489 unsigned LocalBasePreprocessedEntityID = Record[0];
3491 unsigned StartingID;
3492 if (!PP.getPreprocessingRecord())
3493 PP.createPreprocessingRecord();
3494 if (!PP.getPreprocessingRecord()->getExternalSource())
3495 PP.getPreprocessingRecord()->SetExternalSource(*
this);
3497 = PP.getPreprocessingRecord()
3504 GlobalPreprocessedEntityMap.insert(std::make_pair(StartingID, &F));
3509 std::make_pair(LocalBasePreprocessedEntityID,
3521 if (!PP.getPreprocessingRecord())
3522 PP.createPreprocessingRecord();
3523 if (!PP.getPreprocessingRecord()->getExternalSource())
3524 PP.getPreprocessingRecord()->SetExternalSource(*
this);
3529 GlobalSkippedRangeMap.insert(
3535 if (Record.size() % 2 != 0) {
3536 Error(
"invalid DECL_UPDATE_OFFSETS block in AST file");
3539 for (
unsigned I = 0, N = Record.size(); I != N; I += 2) {
3541 DeclUpdateOffsets[
ID].push_back(std::make_pair(&F, Record[I + 1]));
3545 if (
Decl *D = GetExistingDecl(ID))
3546 PendingUpdateRecords.push_back(
3547 PendingUpdateRecord(ID, D,
false));
3553 Error(
"duplicate OBJC_CATEGORIES_MAP record in AST file");
3568 CUDASpecialDeclRefs.clear();
3569 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3570 CUDASpecialDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
3582 &PP.getHeaderSearchInfo(),
3583 Blob.data() + Record[2]));
3585 PP.getHeaderSearchInfo().SetExternalSource(
this);
3586 if (!PP.getHeaderSearchInfo().getExternalLookup())
3587 PP.getHeaderSearchInfo().SetExternalLookup(
this);
3593 FPPragmaOptions.swap(Record);
3597 for (
unsigned I = 0, E = Record.size(); I != E; ) {
3598 auto Name = ReadString(Record, I);
3599 auto &Opt = OpenCLExtensions.OptMap[Name];
3600 Opt.Supported = Record[I++] != 0;
3601 Opt.Enabled = Record[I++] != 0;
3602 Opt.Avail = Record[I++];
3603 Opt.Core = Record[I++];
3608 for (
unsigned I = 0, E = Record.size(); I != E;) {
3611 auto NumExt =
static_cast<unsigned>(Record[I++]);
3612 for (
unsigned II = 0; II != NumExt; ++II) {
3613 auto Ext = ReadString(Record, I);
3614 OpenCLTypeExtMap[
Type].insert(Ext);
3620 for (
unsigned I = 0, E = Record.size(); I != E;) {
3623 auto NumExt =
static_cast<unsigned>(Record[I++]);
3624 for (
unsigned II = 0; II != NumExt; ++II) {
3625 auto Ext = ReadString(Record, I);
3626 OpenCLDeclExtMap[
Decl].insert(Ext);
3632 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3633 TentativeDefinitions.push_back(getGlobalDeclID(F, Record[I]));
3637 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3638 KnownNamespaces.push_back(getGlobalDeclID(F, Record[I]));
3642 if (UndefinedButUsed.size() % 2 != 0) {
3643 Error(
"Invalid existing UndefinedButUsed");
3647 if (Record.size() % 2 != 0) {
3648 Error(
"invalid undefined-but-used record");
3651 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3652 UndefinedButUsed.push_back(getGlobalDeclID(F, Record[I++]));
3653 UndefinedButUsed.push_back(
3654 ReadSourceLocation(F, Record, I).getRawEncoding());
3659 for (
unsigned I = 0, N = Record.size(); I != N;) {
3660 DelayedDeleteExprs.push_back(getGlobalDeclID(F, Record[I++]));
3661 const uint64_t Count = Record[I++];
3662 DelayedDeleteExprs.push_back(Count);
3663 for (uint64_t C = 0; C < Count; ++C) {
3664 DelayedDeleteExprs.push_back(ReadSourceLocation(F, Record, I).getRawEncoding());
3665 bool IsArrayForm = Record[I++] == 1;
3666 DelayedDeleteExprs.push_back(IsArrayForm);
3676 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3677 unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
3680 ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
3681 if (DeserializationListener)
3682 DeserializationListener->ModuleImportRead(GlobalID, Loc);
3690 Error(
"duplicate MACRO_OFFSET record in AST file");
3695 unsigned LocalBaseMacroID = Record[1];
3700 GlobalMacroMap.insert(std::make_pair(getTotalNumMacros() + 1, &F));
3704 std::make_pair(LocalBaseMacroID,
3713 LateParsedTemplates.append(Record.begin(), Record.end());
3717 if (Record.size() != 1) {
3718 Error(
"invalid pragma optimize record");
3721 OptimizeOffPragmaLocation = ReadSourceLocation(F, Record[0]);
3725 if (Record.size() != 1) {
3726 Error(
"invalid pragma ms_struct record");
3729 PragmaMSStructState = Record[0];
3733 if (Record.size() != 2) {
3734 Error(
"invalid pragma ms_struct record");
3737 PragmaMSPointersToMembersState = Record[0];
3738 PointersToMembersPragmaLocation = ReadSourceLocation(F, Record[1]);
3742 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3743 UnusedLocalTypedefNameCandidates.push_back(
3744 getGlobalDeclID(F, Record[I]));
3748 if (Record.size() != 1) {
3749 Error(
"invalid cuda pragma options record");
3752 ForceCUDAHostDeviceDepth = Record[0];
3756 if (Record.size() < 3) {
3757 Error(
"invalid pragma pack record");
3760 PragmaPackCurrentValue = Record[0];
3761 PragmaPackCurrentLocation = ReadSourceLocation(F, Record[1]);
3762 unsigned NumStackEntries = Record[2];
3765 PragmaPackStack.clear();
3766 for (
unsigned I = 0; I < NumStackEntries; ++I) {
3767 PragmaPackStackEntry Entry;
3768 Entry.Value = Record[Idx++];
3769 Entry.Location = ReadSourceLocation(F, Record[Idx++]);
3770 Entry.PushLocation = ReadSourceLocation(F, Record[Idx++]);
3771 PragmaPackStrings.push_back(ReadString(Record, Idx));
3772 Entry.SlotLabel = PragmaPackStrings.back();
3773 PragmaPackStack.push_back(Entry);
3781 void ASTReader::ReadModuleOffsetMap(
ModuleFile &F)
const {
3785 const unsigned char *Data = (
const unsigned char*)F.
ModuleOffsetMap.data();
3806 while (Data < DataEnd) {
3810 using namespace llvm::support;
3812 endian::readNext<uint8_t, little, unaligned>(Data));
3813 uint16_t Len = endian::readNext<uint16_t, little, unaligned>(Data);
3814 StringRef Name = StringRef((
const char*)Data, Len);
3817 ? ModuleMgr.lookupByModuleName(Name)
3818 : ModuleMgr.lookupByFileName(Name));
3821 "SourceLocation remap refers to unknown module, cannot find ";
3827 uint32_t SLocOffset =
3828 endian::readNext<uint32_t, little, unaligned>(Data);
3829 uint32_t IdentifierIDOffset =
3830 endian::readNext<uint32_t, little, unaligned>(Data);
3831 uint32_t MacroIDOffset =
3832 endian::readNext<uint32_t, little, unaligned>(Data);
3833 uint32_t PreprocessedEntityIDOffset =
3834 endian::readNext<uint32_t, little, unaligned>(Data);
3835 uint32_t SubmoduleIDOffset =
3836 endian::readNext<uint32_t, little, unaligned>(Data);
3837 uint32_t SelectorIDOffset =
3838 endian::readNext<uint32_t, little, unaligned>(Data);
3839 uint32_t DeclIDOffset =
3840 endian::readNext<uint32_t, little, unaligned>(Data);
3841 uint32_t TypeIndexOffset =
3842 endian::readNext<uint32_t, little, unaligned>(Data);
3846 auto mapOffset = [&](uint32_t
Offset, uint32_t BaseOffset,
3847 RemapBuilder &Remap) {
3849 Remap.insert(std::make_pair(Offset,
3850 static_cast<int>(BaseOffset - Offset)));
3854 mapOffset(MacroIDOffset, OM->
BaseMacroID, MacroRemap);
3856 PreprocessedEntityRemap);
3859 mapOffset(DeclIDOffset, OM->
BaseDeclID, DeclRemap);
3868 ASTReader::ReadModuleMapFileBlock(RecordData &Record,
ModuleFile &F,
3870 unsigned ClientLoadCapabilities) {
3879 "MODULE_NAME should come before MODULE_MAP_FILE");
3884 auto &Map = PP.getHeaderSearchInfo().getModuleMap();
3885 const FileEntry *ModMap = M ? Map.getModuleMapFileForUniquing(M) :
nullptr;
3887 if (!PP.getPreprocessorOpts().DisablePCHValidation && !ModMap) {
3888 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) {
3889 if (
auto *ASTFE = M ? M->
getASTFile() :
nullptr) {
3892 << ASTFE->getName();
3895 Diag(diag::err_imported_module_not_found)
3903 Diag(diag::note_imported_by_pch_module_not_found)
3910 assert(M->
Name == F.
ModuleName &&
"found module with different name");
3914 if (!StoredModMap || *StoredModMap != ModMap) {
3915 assert(ModMap &&
"found module is missing module map file");
3917 "top-level import should be verified");
3919 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3920 Diag(diag::err_imported_module_modmap_changed)
3926 llvm::SmallPtrSet<const FileEntry *, 1> AdditionalStoredMaps;
3927 for (
unsigned I = 0, N = Record[Idx++]; I < N; ++I) {
3929 std::string
Filename = ReadPath(F, Record, Idx);
3930 auto F = FileMgr.getFile(Filename,
false,
false);
3932 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3933 Error(
"could not find file '" + Filename +
"' referenced by AST file");
3936 AdditionalStoredMaps.insert(*F);
3941 if (
auto *AdditionalModuleMaps = Map.getAdditionalModuleMapFiles(M)) {
3942 for (
const FileEntry *ModMap : *AdditionalModuleMaps) {
3945 if (!AdditionalStoredMaps.erase(ModMap)) {
3946 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3947 Diag(diag::err_module_different_modmap)
3956 for (
const FileEntry *ModMap : AdditionalStoredMaps) {
3957 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3958 Diag(diag::err_module_different_modmap)
3972 Sema::GlobalMethodPool::iterator Known
3979 : Known->second.second;
3981 for (
ObjCMethodList *List = &Start; List; List = List->getNext()) {
3983 if (List->getMethod() == Method) {
3991 if (List->getNext())
3992 List->setMethod(List->getNext()->getMethod());
3994 List->setMethod(Method);
4000 for (
Decl *D : Names) {
4001 bool wasHidden = D->isHidden();
4002 D->setVisibleDespiteOwningModule();
4004 if (wasHidden && SemaObj) {
4015 llvm::SmallPtrSet<Module *, 4> Visited;
4017 Stack.push_back(Mod);
4018 while (!Stack.empty()) {
4019 Mod = Stack.pop_back_val();
4021 if (NameVisibility <= Mod->NameVisibility) {
4037 HiddenNamesMapType::iterator Hidden = HiddenNamesMap.find(Mod);
4038 if (Hidden != HiddenNamesMap.end()) {
4040 HiddenNamesMap.erase(Hidden);
4042 assert(HiddenNamesMap.find(Mod) == HiddenNamesMap.end() &&
4043 "making names visible added hidden names");
4050 I = Exports.begin(), E = Exports.end(); I != E; ++I) {
4052 if (Visited.insert(Exported).second)
4053 Stack.push_back(Exported);
4068 getContext().mergeDefinitionIntoModule(
4071 PendingMergedDefinitionsToDeduplicate.insert(Def);
4080 if (TriedLoadingGlobalIndex || !UseGlobalIndex ||
4081 !PP.getLangOpts().Modules)
4085 TriedLoadingGlobalIndex =
true;
4086 StringRef ModuleCachePath
4087 = getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
4088 std::pair<GlobalModuleIndex *, llvm::Error> Result =
4091 assert(!Result.first);
4092 consumeError(std::move(Err));
4096 GlobalIndex.reset(Result.first);
4097 ModuleMgr.setGlobalIndex(GlobalIndex.get());
4102 return PP.getLangOpts().Modules && UseGlobalIndex &&
4103 !hasGlobalIndex() && TriedLoadingGlobalIndex;
4110 llvm::raw_fd_ostream OS(TimestampFilename, EC, llvm::sys::fs::OF_Text);
4113 OS <<
"Timestamp file\n";
4126 consumeError(MaybeEntry.takeError());
4129 llvm::BitstreamEntry Entry = MaybeEntry.get();
4131 switch (Entry.Kind) {
4133 case llvm::BitstreamEntry::EndBlock:
4136 case llvm::BitstreamEntry::Record:
4142 consumeError(Skipped.takeError());
4146 case llvm::BitstreamEntry::SubBlock:
4147 if (Entry.ID == BlockID) {
4148 if (
llvm::Error Err = Cursor.EnterSubBlock(BlockID)) {
4150 consumeError(std::move(Err));
4159 consumeError(std::move(Err));
4169 unsigned ClientLoadCapabilities,
4172 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
4178 unsigned PreviousGeneration = 0;
4180 PreviousGeneration = incrementGeneration(*ContextObj);
4182 unsigned NumModules = ModuleMgr.size();
4183 auto removeModulesAndReturn = [&](
ASTReadResult ReadResult) {
4184 assert(ReadResult &&
"expected to return error");
4185 ModuleMgr.removeModules(ModuleMgr.begin() + NumModules,
4186 PP.getLangOpts().Modules
4187 ? &PP.getHeaderSearchInfo().getModuleMap()
4192 GlobalIndex.reset();
4193 ModuleMgr.setGlobalIndex(
nullptr);
4199 ReadASTCore(FileName, Type, ImportLoc,
4200 nullptr, Loaded, 0, 0,
4205 case VersionMismatch:
4206 case ConfigurationMismatch:
4208 return removeModulesAndReturn(ReadResult);
4217 for (ImportedModule &M : Loaded) {
4221 if (
ASTReadResult Result = ReadASTBlock(F, ClientLoadCapabilities))
4222 return removeModulesAndReturn(Result);
4226 Error(diag::err_module_file_missing_top_level_submodule, F.
FileName);
4227 return removeModulesAndReturn(Failure);
4233 return removeModulesAndReturn(Result);
4244 for (ImportedModule &M : Loaded) {
4254 SourceMgr.getLoadedSLocEntryByID(Index);
4267 const unsigned char *Data =
reinterpret_cast<const unsigned char *
>(
4272 auto Key = Trait.
ReadKey(Data, KeyDataLen.first);
4273 auto &II = PP.getIdentifierTable().getOwn(Key);
4274 II.setOutOfDate(
true);
4282 SetIdentifierInfo(
ID, &II);
4288 for (ImportedModule &M : Loaded) {
4291 ModuleMgr.moduleFileAccepted(&F);
4303 if (!PP.getLangOpts().CPlusPlus ||
4314 IdEnd = PP.getIdentifierTable().end();
4316 Id->second->setOutOfDate(
true);
4319 for (
auto Sel : SelectorGeneration)
4320 SelectorOutOfDate[Sel.first] =
true;
4323 for (
unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I) {
4324 UnresolvedModuleRef &
Unresolved = UnresolvedModuleRefs[I];
4325 SubmoduleID GlobalID = getGlobalSubmoduleID(*Unresolved.File,Unresolved.ID);
4326 Module *ResolvedMod = getSubmodule(GlobalID);
4328 switch (Unresolved.Kind) {
4329 case UnresolvedModuleRef::Conflict:
4332 Conflict.
Other = ResolvedMod;
4333 Conflict.
Message = Unresolved.String.str();
4334 Unresolved.Mod->Conflicts.push_back(Conflict);
4338 case UnresolvedModuleRef::Import:
4340 Unresolved.Mod->Imports.insert(ResolvedMod);
4343 case UnresolvedModuleRef::Export:
4344 if (ResolvedMod || Unresolved.IsWildcard)
4345 Unresolved.Mod->Exports.push_back(
4350 UnresolvedModuleRefs.clear();
4353 Imported->append(ImportedModules.begin(),
4354 ImportedModules.end());
4361 InitializeContext();
4366 if (DeserializationListener)
4367 DeserializationListener->ReaderInitialized(
this);
4369 ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule();
4384 for (
unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++I) {
4385 loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
4386 ObjCClassesLoaded[I],
4387 PreviousGeneration);
4391 if (PP.getHeaderSearchInfo()
4392 .getHeaderSearchOpts()
4393 .ModulesValidateOncePerBuildSession) {
4398 for (
unsigned I = 0, N = Loaded.size(); I != N; ++I) {
4399 ImportedModule &M = Loaded[I];
4416 if (!Stream.canSkipToPos(4))
4417 return llvm::createStringError(std::errc::illegal_byte_sequence,
4418 "file too small to contain AST file magic");
4419 for (
unsigned C : {
'C',
'P',
'C',
'H'})
4422 return llvm::createStringError(
4423 std::errc::illegal_byte_sequence,
4424 "file doesn't start with AST file magic");
4426 return Res.takeError();
4427 return llvm::Error::success();
4442 llvm_unreachable(
"unknown module kind");
4446 ASTReader::ReadASTCore(StringRef FileName,
4451 off_t ExpectedSize, time_t ExpectedModTime,
4453 unsigned ClientLoadCapabilities) {
4455 std::string ErrorStr;
4457 = ModuleMgr.addModule(FileName,
Type, ImportLoc, ImportedBy,
4458 getGeneration(), ExpectedSize, ExpectedModTime,
4459 ExpectedSignature, readASTFileSignature,
4462 switch (AddResult) {
4464 Diag(diag::remark_module_import)
4466 << (ImportedBy ? StringRef(ImportedBy->
ModuleName) : StringRef());
4476 if (ClientLoadCapabilities & ARR_Missing)
4481 << FileName << !ErrorStr.empty()
4488 if (ClientLoadCapabilities & ARR_OutOfDate)
4493 << FileName << !ErrorStr.empty()
4498 assert(M &&
"Missing module file");
4500 bool ShouldFinalizePCM =
false;
4501 auto FinalizeOrDropPCM = llvm::make_scope_exit([&]() {
4502 auto &MC = getModuleManager().getModuleCache();
4503 if (ShouldFinalizePCM)
4504 MC.finalizePCM(FileName);
4506 MC.tryToDropPCM(FileName);
4509 BitstreamCursor &Stream = F.
Stream;
4510 Stream = BitstreamCursor(PCHContainerRdr.ExtractPCH(*F.Buffer));
4511 F.SizeInBits = F.Buffer->getBufferSize() * 8;
4515 Diag(diag::err_module_file_invalid)
4521 bool HaveReadControlBlock =
false;
4525 Error(MaybeEntry.takeError());
4528 llvm::BitstreamEntry Entry = MaybeEntry.get();
4530 switch (Entry.Kind) {
4532 case llvm::BitstreamEntry::Record:
4533 case llvm::BitstreamEntry::EndBlock:
4534 Error(
"invalid record at top-level of AST file");
4537 case llvm::BitstreamEntry::SubBlock:
4543 HaveReadControlBlock =
true;
4544 switch (ReadControlBlock(F, Loaded, ImportedBy, ClientLoadCapabilities)) {
4552 F.ModuleName.empty()) {
4554 if (Result != OutOfDate ||
4555 (ClientLoadCapabilities & ARR_OutOfDate) == 0)
4556 Diag(diag::err_module_file_not_module) << FileName;
4561 case Failure:
return Failure;
4562 case Missing:
return Missing;
4563 case OutOfDate:
return OutOfDate;
4564 case VersionMismatch:
return VersionMismatch;
4565 case ConfigurationMismatch:
return ConfigurationMismatch;
4566 case HadErrors:
return HadErrors;
4571 if (!HaveReadControlBlock) {
4572 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
4573 Diag(diag::err_pch_version_too_old);
4574 return VersionMismatch;
4578 Loaded.push_back(ImportedModule(M, ImportedBy, ImportLoc));
4579 ShouldFinalizePCM =
true;
4585 Error(
"malformed block record in AST file");
4590 Error(std::move(Err));
4597 llvm_unreachable(
"unexpected break; expected return");
4601 ASTReader::readUnhashedControlBlock(
ModuleFile &F,
bool WasImportedBy,
4602 unsigned ClientLoadCapabilities) {
4604 PP.getHeaderSearchInfo().getHeaderSearchOpts();
4605 bool AllowCompatibleConfigurationMismatch =
4608 ASTReadResult Result = readUnhashedControlBlockImpl(
4609 &F, F.
Data, ClientLoadCapabilities, AllowCompatibleConfigurationMismatch,
4615 if (DisableValidation || WasImportedBy ||
4616 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
4619 if (Result == Failure) {
4620 Error(
"malformed block record in AST file");
4643 if (getModuleManager().getModuleCache().isPCMFinal(F.
FileName)) {
4644 Diag(diag::warn_module_system_bit_conflict) << F.
FileName;
4653 ModuleFile *F, llvm::StringRef StreamData,
unsigned ClientLoadCapabilities,
4655 bool ValidateDiagnosticOptions) {
4657 BitstreamCursor Stream(StreamData);
4662 consumeError(std::move(Err));
4672 ASTReadResult Result = Success;
4677 consumeError(MaybeEntry.takeError());
4680 llvm::BitstreamEntry Entry = MaybeEntry.get();
4682 switch (Entry.Kind) {
4684 case llvm::BitstreamEntry::SubBlock:
4687 case llvm::BitstreamEntry::EndBlock:
4690 case llvm::BitstreamEntry::Record:
4698 if (!MaybeRecordType) {
4705 std::copy(Record.begin(), Record.end(), F->
Signature.data());
4708 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
4709 if (Listener && ValidateDiagnosticOptions &&
4710 !AllowCompatibleConfigurationMismatch &&
4711 ParseDiagnosticOptions(Record, Complain, *Listener))
4722 Record.begin(), Record.end());
4733 if (Record.size() < 4)
return true;
4738 unsigned BlockNameLen = Record[2];
4739 unsigned UserInfoLen = Record[3];
4741 if (BlockNameLen + UserInfoLen > Blob.size())
return true;
4743 Metadata.
BlockName = std::string(Blob.data(), Blob.data() + BlockNameLen);
4744 Metadata.
UserInfo = std::string(Blob.data() + BlockNameLen,
4745 Blob.data() + BlockNameLen + UserInfoLen);
4750 BitstreamCursor &Stream = F.
Stream;
4756 Error(MaybeEntry.takeError());
4759 llvm::BitstreamEntry Entry = MaybeEntry.get();
4761 switch (Entry.Kind) {
4762 case llvm::BitstreamEntry::SubBlock:
4764 Error(std::move(Err));
4769 case llvm::BitstreamEntry::EndBlock:
4775 case llvm::BitstreamEntry::Record:
4782 Stream.readRecord(Entry.ID, Record, &Blob);
4783 if (!MaybeRecCode) {
4784 Error(MaybeRecCode.takeError());
4787 switch (MaybeRecCode.get()) {
4791 Error(
"malformed EXTENSION_METADATA in AST file");
4796 auto Known = ModuleFileExtensions.find(Metadata.
BlockName);
4797 if (Known == ModuleFileExtensions.end())
break;
4800 if (
auto Reader = Known->second->createExtensionReader(Metadata, *
this,
4814 assert(ContextObj &&
"no context to initialize");
4818 if (DeserializationListener)
4828 if (!Context.CFConstantStringTypeDecl)
4835 Error(
"FILE type is NULL");
4839 if (!Context.FILEDecl) {
4845 Error(
"Invalid FILE type in AST file");
4854 QualType Jmp_bufType = GetType(Jmp_buf);
4855 if (Jmp_bufType.
isNull()) {
4856 Error(
"jmp_buf type is NULL");
4860 if (!Context.jmp_bufDecl) {
4866 Error(
"Invalid jmp_buf type in AST file");
4875 QualType Sigjmp_bufType = GetType(Sigjmp_buf);
4876 if (Sigjmp_bufType.
isNull()) {
4877 Error(
"sigjmp_buf type is NULL");
4881 if (!Context.sigjmp_bufDecl) {
4886 assert(Tag &&
"Invalid sigjmp_buf type in AST file");
4892 if (
unsigned ObjCIdRedef
4894 if (Context.ObjCIdRedefinitionType.
isNull())
4895 Context.ObjCIdRedefinitionType = GetType(ObjCIdRedef);
4898 if (
unsigned ObjCClassRedef
4900 if (Context.ObjCClassRedefinitionType.
isNull())
4901 Context.ObjCClassRedefinitionType = GetType(ObjCClassRedef);
4904 if (
unsigned ObjCSelRedef
4906 if (Context.ObjCSelRedefinitionType.
isNull())
4907 Context.ObjCSelRedefinitionType = GetType(ObjCSelRedef);
4911 QualType Ucontext_tType = GetType(Ucontext_t);
4912 if (Ucontext_tType.
isNull()) {
4913 Error(
"ucontext_t type is NULL");
4917 if (!Context.ucontext_tDecl) {
4922 assert(Tag &&
"Invalid ucontext_t type in AST file");
4932 if (!CUDASpecialDeclRefs.empty()) {
4933 assert(CUDASpecialDeclRefs.size() == 1 &&
"More decl refs than expected!");
4935 cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
4940 for (
auto &Import : ImportedModules) {
4941 if (
Module *Imported = getSubmodule(Import.ID)) {
4944 if (Import.ImportLoc.isValid())
4945 PP.makeModuleVisible(Imported, Import.ImportLoc);
4949 ImportedModules.clear();
4959 BitstreamCursor Stream(PCH);
4962 consumeError(std::move(Err));
4974 Stream.advanceSkippingSubblocks();
4977 consumeError(MaybeEntry.takeError());
4980 llvm::BitstreamEntry Entry = MaybeEntry.get();
4982 if (Entry.Kind != llvm::BitstreamEntry::Record)
4990 consumeError(MaybeRecord.takeError());
4994 return {{{(uint32_t)Record[0], (uint32_t)Record[1], (uint32_t)Record[2],
4995 (uint32_t)Record[3], (uint32_t)Record[4]}}};
5003 const std::string &ASTFileName,
FileManager &FileMgr,
5008 Diags.
Report(diag::err_fe_unable_to_read_pch_file)
5009 << ASTFileName << Buffer.getError().message();
5010 return std::string();
5014 BitstreamCursor Stream(PCHContainerRdr.
ExtractPCH(**Buffer));
5018 Diags.
Report(diag::err_fe_not_a_pch_file) << ASTFileName << std::move(Err);
5019 return std::string();
5024 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
5025 return std::string();
5032 Stream.advanceSkippingSubblocks();
5035 consumeError(MaybeEntry.takeError());
5036 return std::string();
5038 llvm::BitstreamEntry Entry = MaybeEntry.get();
5040 if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
5041 return std::string();
5043 if (Entry.Kind != llvm::BitstreamEntry::Record) {
5044 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
5045 return std::string();
5053 consumeError(MaybeRecord.takeError());
5054 return std::string();
5067 std::string ExistingModuleCachePath;
5071 SimplePCHValidator(
const LangOptions &ExistingLangOpts,
5074 StringRef ExistingModuleCachePath,
5076 : ExistingLangOpts(ExistingLangOpts),
5077 ExistingTargetOpts(ExistingTargetOpts),
5078 ExistingPPOpts(ExistingPPOpts),
5079 ExistingModuleCachePath(ExistingModuleCachePath),
5082 bool ReadLanguageOptions(
const LangOptions &LangOpts,
bool Complain,
5083 bool AllowCompatibleDifferences)
override {
5085 AllowCompatibleDifferences);
5088 bool ReadTargetOptions(
const TargetOptions &TargetOpts,
bool Complain,
5089 bool AllowCompatibleDifferences)
override {
5091 AllowCompatibleDifferences);
5095 StringRef SpecificModuleCachePath,
5096 bool Complain)
override {
5098 ExistingModuleCachePath,
5099 nullptr, ExistingLangOpts);
5104 std::string &SuggestedPredefines)
override {
5106 SuggestedPredefines, ExistingLangOpts);
5115 bool FindModuleFileExtensions,
5126 StringRef Bytes = PCHContainerRdr.
ExtractPCH(**Buffer);
5127 BitstreamCursor Stream(Bytes);
5131 consumeError(std::move(Err));
5142 BitstreamCursor InputFilesCursor;
5145 std::string ModuleDir;
5146 bool DoneWithControlBlock =
false;
5147 while (!DoneWithControlBlock) {
5151 consumeError(MaybeEntry.takeError());
5154 llvm::BitstreamEntry Entry = MaybeEntry.get();
5156 switch (Entry.Kind) {
5157 case llvm::BitstreamEntry::SubBlock: {
5160 std::string IgnoredSuggestedPredefines;
5161 if (ReadOptionsBlock(Stream, ARR_ConfigurationMismatch | ARR_OutOfDate,
5163 Listener, IgnoredSuggestedPredefines) != Success)
5169 InputFilesCursor = Stream;
5172 consumeError(std::move(Err));
5175 if (NeedsInputFiles &&
5183 consumeError(std::move(Err));
5192 case llvm::BitstreamEntry::EndBlock:
5193 DoneWithControlBlock =
true;
5199 case llvm::BitstreamEntry::Record:
5203 if (DoneWithControlBlock)
break;
5208 Stream.readRecord(Entry.ID, Record, &Blob);
5209 if (!MaybeRecCode) {
5228 auto Path = ReadString(Record, Idx);
5229 ResolveImportedPath(Path, ModuleDir);
5234 if (!NeedsInputFiles)
5237 unsigned NumInputFiles = Record[0];
5238 unsigned NumUserFiles = Record[1];
5239 const llvm::support::unaligned_uint64_t *InputFileOffs =
5240 (
const llvm::support::unaligned_uint64_t *)Blob.data();
5241 for (
unsigned I = 0; I != NumInputFiles; ++I) {
5243 bool isSystemFile = I >= NumUserFiles;
5245 if (isSystemFile && !NeedsSystemInputFiles)
5248 BitstreamCursor &
Cursor = InputFilesCursor;
5250 if (
llvm::Error Err = Cursor.JumpToBit(InputFileOffs[I])) {
5252 consumeError(std::move(Err));
5258 consumeError(MaybeCode.takeError());
5260 unsigned Code = MaybeCode.get();
5264 bool shouldContinue =
false;
5266 Cursor.readRecord(Code, Record, &Blob);
5267 if (!MaybeRecordType) {
5269 consumeError(MaybeRecordType.takeError());
5275 bool Overridden =
static_cast<bool>(Record[3]);
5276 std::string Filename = Blob;
5277 ResolveImportedPath(Filename, ModuleDir);
5279 Filename, isSystemFile, Overridden,
false);
5282 if (!shouldContinue)
5292 unsigned Idx = 0, N = Record.size();
5296 std::string ModuleName = ReadString(Record, Idx);
5297 std::string Filename = ReadString(Record, Idx);
5298 ResolveImportedPath(Filename, ModuleDir);
5311 if (FindModuleFileExtensions) {
5312 BitstreamCursor SavedStream = Stream;
5314 bool DoneWithExtensionBlock =
false;
5315 while (!DoneWithExtensionBlock) {
5321 llvm::BitstreamEntry Entry = MaybeEntry.get();
5323 switch (Entry.Kind) {
5324 case llvm::BitstreamEntry::SubBlock:
5327 consumeError(std::move(Err));
5332 case llvm::BitstreamEntry::EndBlock:
5333 DoneWithExtensionBlock =
true;
5339 case llvm::BitstreamEntry::Record:
5346 Stream.readRecord(Entry.ID, Record, &Blob);
5347 if (!MaybeRecCode) {
5351 switch (MaybeRecCode.get()) {
5363 Stream = SavedStream;
5367 if (readUnhashedControlBlockImpl(
5368 nullptr, Bytes, ARR_ConfigurationMismatch | ARR_OutOfDate,
5370 ValidateDiagnosticOptions) != Success)
5381 StringRef ExistingModuleCachePath) {
5382 SimplePCHValidator validator(LangOpts, TargetOpts, PPOpts,
5383 ExistingModuleCachePath, FileMgr);
5384 return !readASTFileControlBlock(Filename, FileMgr, PCHContainerRdr,
5391 ASTReader::ReadSubmoduleBlock(
ModuleFile &F,
unsigned ClientLoadCapabilities) {
5394 Error(std::move(Err));
5398 ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
5400 Module *CurrentModule =
nullptr;
5404 F.
Stream.advanceSkippingSubblocks();
5406 Error(MaybeEntry.takeError());
5409 llvm::BitstreamEntry Entry = MaybeEntry.get();
5411 switch (Entry.Kind) {
5412 case llvm::BitstreamEntry::SubBlock:
5414 Error(
"malformed block record in AST file");
5416 case llvm::BitstreamEntry::EndBlock:
5418 case llvm::BitstreamEntry::Record:
5428 Error(MaybeKind.takeError());
5431 unsigned Kind = MaybeKind.get();
5434 Error(
"submodule metadata record should be at beginning of block");
5450 if (Record.size() < 12) {
5451 Error(
"malformed module definition");
5455 StringRef Name = Blob;
5457 SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);
5460 bool IsFramework = Record[Idx++];
5461 bool IsExplicit = Record[Idx++];
5462 bool IsSystem = Record[Idx++];
5463 bool IsExternC = Record[Idx++];
5464 bool InferSubmodules = Record[Idx++];
5465 bool InferExplicitSubmodules = Record[Idx++];
5466 bool InferExportWildcard = Record[Idx++];
5467 bool ConfigMacrosExhaustive = Record[Idx++];
5468 bool ModuleMapIsPrivate = Record[Idx++];
5470 Module *ParentModule =
nullptr;
5472 ParentModule = getSubmodule(Parent);
5484 if (GlobalIndex >= SubmodulesLoaded.size() ||
5485 SubmodulesLoaded[GlobalIndex]) {
5486 Error(
"too many submodules");
5490 if (!ParentModule) {
5493 if (!PP.getPreprocessorOpts().DisablePCHValidation &&
5494 CurFile != F.
File) {
5495 Error(diag::err_module_file_conflict,
5507 CurrentModule->
Kind = Kind;
5517 if (DeserializationListener)
5518 DeserializationListener->ModuleRead(GlobalID, CurrentModule);
5520 SubmodulesLoaded[GlobalIndex] = CurrentModule;
5543 ResolveImportedPath(F, Filename);
5544 if (
auto Umbrella = PP.getFileManager().getFile(Filename)) {
5548 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
5549 Error(
"mismatched umbrella headers in submodule");
5575 std::string Dirname = Blob;
5576 ResolveImportedPath(F, Dirname);
5577 if (
auto Umbrella = PP.getFileManager().getDirectory(Dirname)) {
5581 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
5582 Error(
"mismatched umbrella directories in submodule");
5592 unsigned LocalBaseSubmoduleID = Record[1];
5596 GlobalSubmoduleMap.insert(std::make_pair(getTotalNumSubmodules()+1,&F));
5601 std::make_pair(LocalBaseSubmoduleID,
5610 for (
unsigned Idx = 0; Idx != Record.size(); ++Idx) {
5612 Unresolved.File = &F;
5613 Unresolved.Mod = CurrentModule;
5614 Unresolved.ID = Record[Idx];
5615 Unresolved.Kind = UnresolvedModuleRef::Import;
5616 Unresolved.IsWildcard =
false;
5617 UnresolvedModuleRefs.push_back(Unresolved);
5622 for (
unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
5624 Unresolved.File = &F;
5625 Unresolved.Mod = CurrentModule;
5626 Unresolved.ID = Record[Idx];
5627 Unresolved.Kind = UnresolvedModuleRef::Export;
5628 Unresolved.IsWildcard = Record[Idx + 1];
5629 UnresolvedModuleRefs.push_back(Unresolved);
5639 PP.getTargetInfo());
5654 Unresolved.File = &F;
5655 Unresolved.Mod = CurrentModule;
5656 Unresolved.ID = Record[0];
5657 Unresolved.Kind = UnresolvedModuleRef::Conflict;
5658 Unresolved.IsWildcard =
false;
5659 Unresolved.String = Blob;
5660 UnresolvedModuleRefs.push_back(Unresolved);
5668 for (
auto &
ID : Record)
5669 Inits.push_back(getGlobalDeclID(F,
ID));
5670 ContextObj->addLazyModuleInitializers(CurrentModule, Inits);
5689 bool ASTReader::ParseLanguageOptions(
const RecordData &Record,
5692 bool AllowCompatibleDifferences) {
5695 #define LANGOPT(Name, Bits, Default, Description) \ 5696 LangOpts.Name = Record[Idx++]; 5697 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 5698 LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++])); 5699 #include "clang/Basic/LangOptions.def" 5700 #define SANITIZER(NAME, ID) \ 5701 LangOpts.Sanitize.set(SanitizerKind::ID, Record[Idx++]); 5702 #include "clang/Basic/Sanitizers.def" 5704 for (
unsigned N = Record[Idx++]; N; --N)
5708 VersionTuple runtimeVersion = ReadVersionTuple(Record, Idx);
5714 for (
unsigned N = Record[Idx++]; N; --N) {
5716 ReadString(Record, Idx));
5721 for (
unsigned N = Record[Idx++]; N; --N) {
5722 LangOpts.
OMPTargetTriples.push_back(llvm::Triple(ReadString(Record, Idx)));
5728 AllowCompatibleDifferences);
5731 bool ASTReader::ParseTargetOptions(
const RecordData &Record,
bool Complain,
5733 bool AllowCompatibleDifferences) {
5736 TargetOpts.
Triple = ReadString(Record, Idx);
5737 TargetOpts.
CPU = ReadString(Record, Idx);
5738 TargetOpts.
ABI = ReadString(Record, Idx);
5739 for (
unsigned N = Record[Idx++]; N; --N) {
5742 for (
unsigned N = Record[Idx++]; N; --N) {
5743 TargetOpts.
Features.push_back(ReadString(Record, Idx));
5747 AllowCompatibleDifferences);
5750 bool ASTReader::ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
5754 #define DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++]; 5755 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ 5756 DiagOpts->set##Name(static_cast<Type>(Record[Idx++])); 5757 #include "clang/Basic/DiagnosticOptions.def" 5759 for (
unsigned N = Record[Idx++]; N; --N)
5760 DiagOpts->Warnings.push_back(ReadString(Record, Idx));
5761 for (
unsigned N = Record[Idx++]; N; --N)
5762 DiagOpts->Remarks.push_back(ReadString(Record, Idx));
5767 bool ASTReader::ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
5775 bool ASTReader::ParseHeaderSearchOptions(
const RecordData &Record,
5780 HSOpts.
Sysroot = ReadString(Record, Idx);
5783 for (
unsigned N = Record[Idx++]; N; --N) {
5784 std::string Path = ReadString(Record, Idx);
5787 bool IsFramework = Record[Idx++];
5788 bool IgnoreSysRoot = Record[Idx++];
5789 HSOpts.
UserEntries.emplace_back(std::move(Path), Group, IsFramework,
5794 for (
unsigned N = Record[Idx++]; N; --N) {
5795 std::string Prefix = ReadString(Record, Idx);
5796 bool IsSystemHeader = Record[Idx++];
5810 std::string SpecificModuleCachePath = ReadString(Record, Idx);
5816 bool ASTReader::ParsePreprocessorOptions(
const RecordData &Record,
5819 std::string &SuggestedPredefines) {
5824 for (
unsigned N = Record[Idx++]; N; --N) {
5825 std::string Macro = ReadString(Record, Idx);
5826 bool IsUndef = Record[Idx++];
5827 PPOpts.
Macros.push_back(std::make_pair(Macro, IsUndef));
5831 for (
unsigned N = Record[Idx++]; N; --N) {
5832 PPOpts.
Includes.push_back(ReadString(Record, Idx));
5836 for (
unsigned N = Record[Idx++]; N; --N) {
5845 SuggestedPredefines.clear();
5847 SuggestedPredefines);
5850 std::pair<ModuleFile *, unsigned>
5851 ASTReader::getModulePreprocessedEntity(
unsigned GlobalIndex) {
5853 I = GlobalPreprocessedEntityMap.find(GlobalIndex);
5854 assert(I != GlobalPreprocessedEntityMap.end() &&
5855 "Corrupted global preprocessed entity map");
5858 return std::make_pair(M, LocalIndex);
5861 llvm::iterator_range<PreprocessingRecord::iterator>
5862 ASTReader::getModulePreprocessedEntities(
ModuleFile &Mod)
const {
5871 llvm::iterator_range<ASTReader::ModuleDeclIterator>
5873 return llvm::make_range(
5880 auto I = GlobalSkippedRangeMap.find(GlobalIndex);
5881 assert(I != GlobalSkippedRangeMap.end() &&
5882 "Corrupted global skipped range map");
5885 assert(LocalIndex < M->NumPreprocessedSkippedRanges);
5886 PPSkippedRange RawRange = M->PreprocessedSkippedRangeOffsets[LocalIndex];
5888 TranslateSourceLocation(*M, RawRange.
getEnd()));
5895 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
5897 unsigned LocalIndex = PPInfo.second;
5900 if (!PP.getPreprocessingRecord()) {
5901 Error(
"no preprocessing record");
5908 Error(std::move(Err));
5915 Error(MaybeEntry.takeError());
5918 llvm::BitstreamEntry Entry = MaybeEntry.get();
5920 if (Entry.Kind != llvm::BitstreamEntry::Record)
5925 TranslateSourceLocation(M, PPOffs.
getEnd()));
5931 if (!MaybeRecType) {
5932 Error(MaybeRecType.takeError());
5937 bool isBuiltin = Record[0];
5941 Name = getLocalIdentifier(M, Record[1]);
5944 getGlobalPreprocessedEntityID(M, Record[1]);
5945 Def = cast<MacroDefinitionRecord>(
5946 PPRec.getLoadedPreprocessedEntity(GlobalID - 1));
5964 if (DeserializationListener)
5965 DeserializationListener->MacroDefinitionRead(PPID, MD);
5971 const char *FullFileNameStart = Blob.data() + Record[0];
5972 StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]);
5974 if (!FullFileName.empty())
5975 if (
auto FE = PP.getFileManager().getFile(FullFileName))
5983 StringRef(Blob.data(), Record[0]),
5984 Record[1], Record[3],
5991 llvm_unreachable(
"Invalid PreprocessorDetailRecordTypes");
6001 GlobalSLocOffsetMapType::const_iterator SLocMapI)
const {
6003 for (GlobalSLocOffsetMapType::const_iterator
6004 EndI = GlobalSLocOffsetMap.end(); SLocMapI != EndI; ++SLocMapI) {
6010 return getTotalNumPreprocessedEntities();
6015 struct PPEntityComp {
6045 bool EndsAfter)
const {
6046 if (SourceMgr.isLocalSourceLocation(Loc))
6047 return getTotalNumPreprocessedEntities();
6049 GlobalSLocOffsetMapType::const_iterator SLocMapI = GlobalSLocOffsetMap.find(
6050 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
6051 assert(SLocMapI != GlobalSLocOffsetMap.end() &&
6052 "Corrupted global sloc offset map");
6054 if (SLocMapI->second->NumPreprocessedEntities == 0)
6055 return findNextPreprocessedEntity(SLocMapI);
6066 pp_iterator
First = pp_begin;
6070 PPI = std::upper_bound(pp_begin, pp_end, Loc,
6071 PPEntityComp(*
this, M));
6080 std::advance(PPI, Half);
6081 if (SourceMgr.isBeforeInTranslationUnit(
6082 TranslateSourceLocation(M, PPI->getEnd()), Loc)) {
6085 Count = Count - Half - 1;
6092 return findNextPreprocessedEntity(SLocMapI);
6099 std::pair<unsigned, unsigned>
6102 return std::make_pair(0,0);
6103 assert(!SourceMgr.isBeforeInTranslationUnit(Range.
getEnd(),Range.
getBegin()));
6106 findPreprocessedEntity(Range.
getBegin(),
false);
6108 return std::make_pair(BeginID, EndID);
6118 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
6120 unsigned LocalIndex = PPInfo.second;
6127 if (SourceMgr.isInFileID(SourceMgr.getFileLoc(Loc), FID))
6136 class HeaderFileInfoVisitor {
6141 explicit HeaderFileInfoVisitor(
const FileEntry *FE) : FE(FE) {}
6150 HeaderFileInfoLookupTable::iterator Pos = Table->find(FE);
6151 if (Pos == Table->end())
6164 HeaderFileInfoVisitor Visitor(FE);
6165 ModuleMgr.visit(Visitor);
6173 using DiagState = DiagnosticsEngine::DiagState;
6184 auto ReadDiagState =
6186 bool IncludeNonPragmaStates) -> DiagnosticsEngine::DiagState * {
6187 unsigned BackrefID = Record[Idx++];
6189 return DiagStates[BackrefID - 1];
6192 Diag.DiagStates.push_back(BasedOn);
6193 DiagState *NewState = &Diag.DiagStates.back();
6194 DiagStates.push_back(NewState);
6195 unsigned Size = Record[Idx++];
6196 assert(Idx + Size * 2 <= Record.size() &&
6197 "Invalid data, not enough diag/map pairs");
6199 unsigned DiagID = Record[Idx++];
6202 if (!NewMapping.
isPragma() && !IncludeNonPragmaStates)
6215 Mapping = NewMapping;
6221 DiagState *FirstState;
6226 FirstState = Diag.DiagStatesByLoc.FirstDiagState;
6227 DiagStates.push_back(FirstState);
6230 assert(Record[1] == 0 &&
6231 "Invalid data, unexpected backref in initial state");
6232 Idx = 3 + Record[2] * 2;
6233 assert(Idx < Record.size() &&
6234 "Invalid data, not enough state change pairs in initial state");
6239 unsigned Flags = Record[Idx++];
6241 Initial.SuppressSystemWarnings = Flags & 1; Flags >>= 1;
6242 Initial.ErrorsAsFatal = Flags & 1; Flags >>= 1;
6243 Initial.WarningsAsErrors = Flags & 1; Flags >>= 1;
6244 Initial.EnableAllWarnings = Flags & 1; Flags >>= 1;
6245 Initial.IgnoreAllWarnings = Flags & 1; Flags >>= 1;
6255 .StateTransitions.push_back({FirstState, 0});
6260 FirstState = ReadDiagState(*Diag.DiagStatesByLoc.CurDiagState,
6265 unsigned NumLocations = Record[Idx++];
6266 while (NumLocations--) {
6267 assert(Idx < Record.size() &&
6268 "Invalid data, missing pragma diagnostic states");
6270 auto IDAndOffset = SourceMgr.getDecomposedLoc(Loc);
6271 assert(IDAndOffset.first.isValid() &&
"invalid FileID for transition");
6272 assert(IDAndOffset.second == 0 &&
"not a start location for a FileID");
6273 unsigned Transitions = Record[Idx++];
6279 auto &F = Diag.DiagStatesByLoc.Files[IDAndOffset.first];
6280 F.StateTransitions.reserve(F.StateTransitions.size() + Transitions);
6281 for (
unsigned I = 0; I != Transitions; ++I) {
6282 unsigned Offset = Record[Idx++];
6284 ReadDiagState(*FirstState, Loc.getLocWithOffset(Offset),
false);
6285 F.StateTransitions.push_back({
State, Offset});
6290 assert(Idx < Record.size() &&
6291 "Invalid data, missing final pragma diagnostic state");
6294 auto *CurState = ReadDiagState(*FirstState, CurStateLoc,
false);
6297 Diag.DiagStatesByLoc.CurDiagState = CurState;
6298 Diag.DiagStatesByLoc.CurDiagStateLoc = CurStateLoc;
6303 auto &T = Diag.DiagStatesByLoc.Files[NullFile].StateTransitions;
6305 T.push_back({CurState, 0});
6307 T[0].State = CurState;
6316 ASTReader::RecordLocation ASTReader::TypeCursorForIndex(
unsigned Index) {
6318 assert(I != GlobalTypeMap.end() &&
"Corrupted global type map");
6320 return RecordLocation(M, M->TypeOffsets[Index - M->BaseTypeIndex]);
6325 #define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \ 6326 case TYPE_##CODE_ID: return Type::CLASS_ID; 6327 #include "clang/Serialization/TypeBitCodes.def" 6338 QualType ASTReader::readTypeRecord(
unsigned Index) {
6339 assert(ContextObj &&
"reading type with no AST context");
6341 RecordLocation Loc = TypeCursorForIndex(Index);
6342 BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
6348 ReadingKindTracker ReadingKind(Read_Type, *
this);
6351 Deserializing AType(
this);
6353 if (
llvm::Error Err = DeclsCursor.JumpToBit(Loc.Offset)) {
6354 Error(std::move(Err));
6359 Error(RawCode.takeError());
6366 Error(Code.takeError());
6377 Error(
"Unexpected code for type");
6382 return TypeReader.read(*maybeClass);
6412 #define ABSTRACT_TYPELOC(CLASS, PARENT) 6413 #define TYPELOC(CLASS, PARENT) \ 6414 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc); 6415 #include "clang/AST/TypeLocNodes.def" 6477 if (Reader.readBool())
6484 VisitArrayTypeLoc(TL);
6488 VisitArrayTypeLoc(TL);
6492 VisitArrayTypeLoc(TL);
6495 void TypeLocReader::VisitDependentSizedArrayTypeLoc(
6497 VisitArrayTypeLoc(TL);
6500 void TypeLocReader::VisitDependentAddressSpaceTypeLoc(
6508 void TypeLocReader::VisitDependentSizedExtVectorTypeLoc(
6517 void TypeLocReader::VisitDependentVectorTypeLoc(
6532 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i) {
6538 VisitFunctionTypeLoc(TL);
6542 VisitFunctionTypeLoc(TL);
6577 void TypeLocReader::VisitAutoTypeLoc(
AutoTypeLoc TL) {
6579 if (Reader.readBool()) {
6586 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
6592 void TypeLocReader::VisitDeducedTemplateSpecializationTypeLoc(
6601 void TypeLocReader::VisitEnumTypeLoc(
EnumTypeLoc TL) {
6613 void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
6618 void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
6623 void TypeLocReader::VisitTemplateSpecializationTypeLoc(
6629 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
6632 Reader.readTemplateArgumentLocInfo(
6636 void TypeLocReader::VisitParenTypeLoc(
ParenTypeLoc TL) {
6656 void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc(
6664 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I)
6667 Reader.readTemplateArgumentLocInfo(
6710 void TypeLocReader::VisitPipeTypeLoc(
PipeTypeLoc TL) {
6725 TypeSourceInfo *TInfo = getContext().CreateTypeSourceInfo(InfoTy);
6731 assert(ContextObj &&
"reading type with no AST context");
6918 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 6919 case PREDEF_TYPE_##Id##_ID: \ 6920 T = Context.SingletonId; \ 6922 #include "clang/Basic/OpenCLImageTypes.def" 6923 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 6924 case PREDEF_TYPE_##Id##_ID: \ 6925 T = Context.Id##Ty; \ 6927 #include "clang/Basic/OpenCLExtensionTypes.def" 6958 #define SVE_TYPE(Name, Id, SingletonId) \ 6959 case PREDEF_TYPE_##Id##_ID: \ 6960 T = Context.SingletonId; \ 6962 #include "clang/Basic/AArch64SVEACLETypes.def" 6965 assert(!T.
isNull() &&
"Unknown predefined type");
6970 assert(Index < TypesLoaded.size() &&
"Type index out-of-range");
6971 if (TypesLoaded[Index].isNull()) {
6972 TypesLoaded[Index] = readTypeRecord(Index);
6973 if (TypesLoaded[Index].isNull())
6976 TypesLoaded[Index]->setFromAST();
6977 if (DeserializationListener)
6979 TypesLoaded[Index]);
6982 return TypesLoaded[Index].withFastQualifiers(FastQuals);
6986 return GetType(getGlobalTypeID(F, LocalID));
6998 ReadModuleOffsetMap(F);
7002 assert(I != F.
TypeRemap.
end() &&
"Invalid index into type index remap");
7004 unsigned GlobalIndex = LocalIndex + I->second;
7005 return (GlobalIndex << Qualifiers::FastWidth) | FastQuals;
7014 return readTypeSourceInfo();
7017 readNestedNameSpecifierLoc();
7037 llvm_unreachable(
"unexpected template argument loc");
7054 unsigned NumArgsAsWritten = readInt();
7056 for (
unsigned i = 0; i != NumArgsAsWritten; ++i)
7057 TemplArgsInfo.
addArgument(readTemplateArgumentLoc());
7066 if (NumCurrentElementsDeserializing) {
7071 PendingIncompleteDeclChains.push_back(const_cast<Decl*>(D));
7082 if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC) ||
7083 isa<CXXRecordDecl>(DC) || isa<EnumDecl>(DC)) {
7085 if (!getContext().getLangOpts().
CPlusPlus &&
7086 isa<TranslationUnitDecl>(DC)) {
7090 auto *II = Name.getAsIdentifierInfo();
7091 assert(II &&
"non-identifier name in C?");
7092 if (II->isOutOfDate())
7093 updateOutOfDateIdentifier(*II);
7099 auto *DC = cast<DeclContext>(DCDecl);
7101 FindExternalLexicalDecls(
7107 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D))
7108 CTSD->getSpecializedTemplate()->LoadLazySpecializations();
7109 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D))
7110 VTSD->getSpecializedTemplate()->LoadLazySpecializations();
7111 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
7112 if (
auto *Template = FD->getPrimaryTemplate())
7113 Template->LoadLazySpecializations();
7119 RecordLocation Loc = getLocalBitOffset(Offset);
7120 BitstreamCursor &
Cursor = Loc.F->DeclsCursor;
7122 if (
llvm::Error Err = Cursor.JumpToBit(Loc.Offset)) {
7123 Error(std::move(Err));
7126 ReadingKindTracker ReadingKind(Read_Decl, *
this);
7130 Error(MaybeCode.takeError());
7133 unsigned Code = MaybeCode.get();
7137 if (!MaybeRecCode) {
7138 Error(MaybeRecCode.takeError());
7142 Error(
"malformed AST file: missing C++ ctor initializers");
7150 assert(ContextObj &&
"reading base specifiers with no AST context");
7153 RecordLocation Loc = getLocalBitOffset(Offset);
7154 BitstreamCursor &
Cursor = Loc.F->DeclsCursor;
7156 if (
llvm::Error Err = Cursor.JumpToBit(Loc.Offset)) {
7157 Error(std::move(Err));
7160 ReadingKindTracker ReadingKind(Read_Decl, *
this);
7164 Error(MaybeCode.takeError());
7167 unsigned Code = MaybeCode.get();
7171 if (!MaybeRecCode) {
7172 Error(MaybeCode.takeError());
7175 unsigned RecCode = MaybeRecCode.get();
7178 Error(
"malformed AST file: missing C++ base specifiers");
7182 unsigned NumBases = Record.
readInt();
7185 for (
unsigned I = 0; I != NumBases; ++I)
7196 ReadModuleOffsetMap(F);
7200 assert(I != F.
DeclRemap.
end() &&
"Invalid index into decl index remap");
7202 return LocalID + I->second;
7219 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
7229 if (Index > DeclsLoaded.size()) {
7230 Error(
"declaration ID out-of-range for AST file");
7234 if (
Decl *D = DeclsLoaded[Index])
7235 return D->getLocation();
7238 DeclCursorForID(ID, Loc);
7295 llvm_unreachable(
"PredefinedDeclIDs unknown enum value");
7299 assert(ContextObj &&
"reading decl with no AST context");
7307 Merged.push_back(ID);
7314 if (Index >= DeclsLoaded.size()) {
7315 assert(0 &&
"declaration ID out-of-range for AST file");
7316 Error(
"declaration ID out-of-range for AST file");
7320 return DeclsLoaded[Index];
7325 return GetExistingDecl(ID);
7329 if (Index >= DeclsLoaded.size()) {
7330 assert(0 &&
"declaration ID out-of-range for AST file");
7331 Error(
"declaration ID out-of-range for AST file");
7335 if (!DeclsLoaded[Index]) {
7337 if (DeserializationListener)
7338 DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);
7341 return DeclsLoaded[Index];
7350 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
7353 llvm::DenseMap<ModuleFile *, serialization::DeclID>::iterator Pos
7358 return GlobalID - Owner->BaseDeclID + Pos->second;
7364 if (Idx >= Record.size()) {
7365 Error(
"Corrupted AST file");
7369 return getGlobalDeclID(F, Record[Idx++]);
7379 ClearSwitchCaseIDs();
7382 RecordLocation Loc = getLocalBitOffset(Offset);
7383 if (
llvm::Error Err = Loc.F->DeclsCursor.JumpToBit(Loc.Offset)) {
7384 Error(std::move(Err));
7387 assert(NumCurrentElementsDeserializing == 0 &&
7388 "should not be called while already deserializing");
7390 return ReadStmtFromStream(*Loc.F);
7399 assert(LexicalDecls.size() % 2 == 0 &&
"expected an even number of entries");
7400 for (
int I = 0, N = LexicalDecls.size(); I != N; I += 2) {
7402 if (!IsKindWeWant(K))
7410 if (PredefsVisited[
ID])
7413 PredefsVisited[
ID] =
true;
7416 if (
Decl *D = GetLocalDecl(*M,
ID)) {
7417 assert(D->getKind() == K &&
"wrong kind for lexical decl");
7424 if (isa<TranslationUnitDecl>(DC)) {
7425 for (
auto Lexical : TULexicalDecls)
7426 Visit(Lexical.first, Lexical.second);
7428 auto I = LexicalDecls.find(DC);
7429 if (I != LexicalDecls.end())
7430 Visit(I->second.first, I->second.second);
7433 ++NumLexicalDeclContextsRead;
7470 unsigned Offset,
unsigned Length,
7474 llvm::DenseMap<FileID, FileDeclsInfo>::iterator I = FileDeclIDs.find(File);
7475 if (I == FileDeclIDs.end())
7478 FileDeclsInfo &DInfo = I->second;
7479 if (DInfo.Decls.empty())
7486 DeclIDComp DIDComp(*
this, *DInfo.Mod);
7488 llvm::lower_bound(DInfo.Decls, BeginLoc, DIDComp);
7489 if (BeginIt != DInfo.Decls.begin())
7495 while (BeginIt != DInfo.Decls.begin() &&
7496 GetDecl(getGlobalDeclID(*DInfo.Mod, *BeginIt))
7497 ->isTopLevelDeclInObjCContainer())
7501 llvm::upper_bound(DInfo.Decls, EndLoc, DIDComp);
7502 if (EndIt != DInfo.Decls.end())
7506 DIt = BeginIt; DIt != EndIt; ++DIt)
7507 Decls.push_back(GetDecl(getGlobalDeclID(*DInfo.Mod, *DIt)));
7514 "DeclContext has no visible decls in storage");
7518 auto It = Lookups.find(DC);
7519 if (It == Lookups.end())
7526 for (
DeclID ID : It->second.Table.find(Name)) {
7529 Decls.push_back(ND);
7532 ++NumVisibleDeclContextsRead;
7533 SetExternalVisibleDeclsForName(DC, Name, Decls);
7534 return !Decls.empty();
7541 auto It = Lookups.find(DC);
7542 assert(It != Lookups.end() &&
7543 "have external visible storage but no lookup tables");
7547 for (
DeclID ID : It->second.Table.findAll()) {
7552 ++NumVisibleDeclContextsRead;
7554 for (DeclsMap::iterator I = Decls.begin(), E = Decls.end(); I != E; ++I) {
7555 SetExternalVisibleDeclsForName(DC, I->first, I->second);
7557 const_cast<DeclContext *
>(DC)->setHasExternalVisibleStorage(
false);
7562 auto I = Lookups.find(Primary);
7563 return I == Lookups.end() ? nullptr : &I->second;
7572 assert(ImplD && Consumer);
7574 for (
auto *I : ImplD->
methods())
7580 void ASTReader::PassInterestingDeclToConsumer(
Decl *D) {
7588 this->Consumer = Consumer;
7591 PassInterestingDeclsToConsumer();
7593 if (DeserializationListener)
7594 DeserializationListener->ReaderInitialized(
this);
7598 std::fprintf(stderr,
"*** AST File Statistics:\n");
7600 unsigned NumTypesLoaded
7601 = TypesLoaded.size() - std::count(TypesLoaded.begin(), TypesLoaded.end(),
7603 unsigned NumDeclsLoaded
7604 = DeclsLoaded.size() - std::count(DeclsLoaded.begin(), DeclsLoaded.end(),
7606 unsigned NumIdentifiersLoaded
7607 = IdentifiersLoaded.size() - std::count(IdentifiersLoaded.begin(),
7608 IdentifiersLoaded.end(),
7610 unsigned NumMacrosLoaded
7611 = MacrosLoaded.size() - std::count(MacrosLoaded.begin(),
7614 unsigned NumSelectorsLoaded
7615 = SelectorsLoaded.size() - std::count(SelectorsLoaded.begin(),
7616 SelectorsLoaded.end(),
7619 if (
unsigned TotalNumSLocEntries = getTotalNumSLocs())
7620 std::fprintf(stderr,
" %u/%u source location entries read (%f%%)\n",
7621 NumSLocEntriesRead, TotalNumSLocEntries,
7622 ((
float)NumSLocEntriesRead/TotalNumSLocEntries * 100));
7623 if (!TypesLoaded.empty())
7624 std::fprintf(stderr,
" %u/%u types read (%f%%)\n",
7625 NumTypesLoaded, (
unsigned)TypesLoaded.size(),
7626 ((float)NumTypesLoaded/TypesLoaded.size() * 100));
7627 if (!DeclsLoaded.empty())
7628 std::fprintf(stderr,
" %u/%u declarations read (%f%%)\n",
7629 NumDeclsLoaded, (
unsigned)DeclsLoaded.size(),
7630 ((float)NumDeclsLoaded/DeclsLoaded.size() * 100));
7631 if (!IdentifiersLoaded.empty())
7632 std::fprintf(stderr,
" %u/%u identifiers read (%f%%)\n",
7633 NumIdentifiersLoaded, (
unsigned)IdentifiersLoaded.size(),
7634 ((float)NumIdentifiersLoaded/IdentifiersLoaded.size() * 100));
7635 if (!MacrosLoaded.empty())
7636 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
7637 NumMacrosLoaded, (
unsigned)MacrosLoaded.size(),
7638 ((float)NumMacrosLoaded/MacrosLoaded.size() * 100));
7639 if (!SelectorsLoaded.empty())
7640 std::fprintf(stderr,
" %u/%u selectors read (%f%%)\n",
7641 NumSelectorsLoaded, (
unsigned)SelectorsLoaded.size(),
7642 ((float)NumSelectorsLoaded/SelectorsLoaded.size() * 100));
7643 if (TotalNumStatements)
7644 std::fprintf(stderr,
" %u/%u statements read (%f%%)\n",
7645 NumStatementsRead, TotalNumStatements,
7646 ((
float)NumStatementsRead/TotalNumStatements * 100));
7648 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
7649 NumMacrosRead, TotalNumMacros,
7650 ((
float)NumMacrosRead/TotalNumMacros * 100));
7651 if (TotalLexicalDeclContexts)
7652 std::fprintf(stderr,
" %u/%u lexical declcontexts read (%f%%)\n",
7653 NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
7654 ((
float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts
7656 if (TotalVisibleDeclContexts)
7657 std::fprintf(stderr,
" %u/%u visible declcontexts read (%f%%)\n",
7658 NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
7659 ((
float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
7661 if (TotalNumMethodPoolEntries)
7662 std::fprintf(stderr,
" %u/%u method pool entries read (%f%%)\n",
7663 NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
7664 ((
float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
7666 if (NumMethodPoolLookups)
7667 std::fprintf(stderr,
" %u/%u method pool lookups succeeded (%f%%)\n",
7668 NumMethodPoolHits, NumMethodPoolLookups,
7669 ((
float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
7670 if (NumMethodPoolTableLookups)
7671 std::fprintf(stderr,
" %u/%u method pool table lookups succeeded (%f%%)\n",
7672 NumMethodPoolTableHits, NumMethodPoolTableLookups,
7673 ((
float)NumMethodPoolTableHits/NumMethodPoolTableLookups
7675 if (NumIdentifierLookupHits)
7676 std::fprintf(stderr,
7677 " %u / %u identifier table lookups succeeded (%f%%)\n",
7678 NumIdentifierLookupHits, NumIdentifierLookups,
7679 (
double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
7682 std::fprintf(stderr,
"\n");
7683 GlobalIndex->printStats();
7686 std::fprintf(stderr,
"\n");
7688 std::fprintf(stderr,
"\n");
7691 template<
typename Key,
typename ModuleFile,
unsigned InitialCapacity>
7692 LLVM_DUMP_METHOD
static void 7695 InitialCapacity> &Map) {
7696 if (Map.begin() == Map.end())
7701 llvm::errs() << Name <<
":\n";
7702 for (
typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
7704 llvm::errs() <<
" " << I->first <<
" -> " << I->second->FileName
7710 llvm::errs() <<
"*** PCH/ModuleFile Remappings:\n";
7712 dumpModuleIDMap(
"Global source location entry map", GlobalSLocEntryMap);
7720 GlobalPreprocessedEntityMap);
7722 llvm::errs() <<
"\n*** PCH/Modules Loaded:";
7731 if (llvm::MemoryBuffer *buf = I.Buffer) {
7732 size_t bytes = buf->getBufferSize();
7733 switch (buf->getBufferKind()) {
7734 case llvm::MemoryBuffer::MemoryBuffer_Malloc:
7737 case llvm::MemoryBuffer::MemoryBuffer_MMap:
7751 for (uint64_t
ID : PreloadedDeclIDs) {
7755 PreloadedDeclIDs.clear();
7758 if (!FPPragmaOptions.empty()) {
7759 assert(FPPragmaOptions.size() == 1 &&
"Wrong number of FP_PRAGMA_OPTIONS");
7760 SemaObj->FPFeatures =
FPOptions(FPPragmaOptions[0]);
7763 SemaObj->OpenCLFeatures.copy(OpenCLExtensions);
7764 SemaObj->OpenCLTypeExtMap = OpenCLTypeExtMap;
7765 SemaObj->OpenCLDeclExtMap = OpenCLDeclExtMap;
7771 assert(SemaObj &&
"no Sema to update");
7775 if (!SemaDeclRefs.empty()) {
7776 assert(SemaDeclRefs.size() % 3 == 0);
7777 for (
unsigned I = 0; I != SemaDeclRefs.size(); I += 3) {
7778 if (!SemaObj->StdNamespace)
7779 SemaObj->StdNamespace = SemaDeclRefs[I];
7780 if (!SemaObj->StdBadAlloc)
7781 SemaObj->StdBadAlloc = SemaDeclRefs[I+1];
7782 if (!SemaObj->StdAlignValT)
7783 SemaObj->StdAlignValT = SemaDeclRefs[I+2];
7785 SemaDeclRefs.clear();
7790 if(OptimizeOffPragmaLocation.isValid())
7791 SemaObj->ActOnPragmaOptimize(
false, OptimizeOffPragmaLocation);
7792 if (PragmaMSStructState != -1)
7794 if (PointersToMembersPragmaLocation.isValid()) {
7795 SemaObj->ActOnPragmaMSPointersToMembers(
7797 PragmaMSPointersToMembersState,
7798 PointersToMembersPragmaLocation);
7800 SemaObj->ForceCUDAHostDeviceDepth = ForceCUDAHostDeviceDepth;
7802 if (PragmaPackCurrentValue) {
7806 bool DropFirst =
false;
7807 if (!PragmaPackStack.empty() &&
7808 PragmaPackStack.front().Location.isInvalid()) {
7809 assert(PragmaPackStack.front().Value == SemaObj->PackStack.DefaultValue &&
7810 "Expected a default alignment value");
7811 SemaObj->PackStack.Stack.emplace_back(
7812 PragmaPackStack.front().SlotLabel, SemaObj->PackStack.CurrentValue,
7813 SemaObj->PackStack.CurrentPragmaLocation,
7814 PragmaPackStack.front().PushLocation);
7817 for (
const auto &Entry :
7818 llvm::makeArrayRef(PragmaPackStack).drop_front(DropFirst ? 1 : 0))
7819 SemaObj->PackStack.Stack.emplace_back(Entry.SlotLabel, Entry.Value,
7820 Entry.Location, Entry.PushLocation);
7821 if (PragmaPackCurrentLocation.isInvalid()) {
7822 assert(*PragmaPackCurrentValue == SemaObj->PackStack.DefaultValue &&
7823 "Expected a default alignment value");
7826 SemaObj->PackStack.CurrentValue = *PragmaPackCurrentValue;
7827 SemaObj->PackStack.CurrentPragmaLocation = PragmaPackCurrentLocation;
7836 IdentifierLookupVisitor Visitor(Name, 0,
7837 NumIdentifierLookups,
7838 NumIdentifierLookupHits);
7844 if (PP.getLangOpts().CPlusPlus) {
7845 for (
auto F : ModuleMgr.pch_modules())
7853 if (!loadGlobalIndex()) {
7854 if (GlobalIndex->lookupIdentifier(Name, Hits)) {
7859 ModuleMgr.visit(Visitor, HitsPtr);
7863 markIdentifierUpToDate(II);
7881 ASTIdentifierLookupTable::key_iterator Current;
7885 ASTIdentifierLookupTable::key_iterator
End;
7892 bool SkipModules =
false);
7894 StringRef Next()
override;
7901 : Reader(Reader), Index(Reader.ModuleMgr.size()), SkipModules(SkipModules) {
7905 while (Current == End) {
7917 Current = IdTable->key_begin();
7918 End = IdTable->key_end();
7923 StringRef
Result = *Current;
7932 std::unique_ptr<IdentifierIterator> Current;
7933 std::unique_ptr<IdentifierIterator> Queued;
7936 ChainedIdentifierIterator(std::unique_ptr<IdentifierIterator>
First,
7937 std::unique_ptr<IdentifierIterator> Second)
7938 : Current(std::move(First)), Queued(std::move(Second)) {}
7940 StringRef
Next()
override {
7944 StringRef result = Current->Next();
7945 if (!result.empty())
7950 std::swap(Current, Queued);
7958 if (!loadGlobalIndex()) {
7959 std::unique_ptr<IdentifierIterator> ReaderIter(
7961 std::unique_ptr<IdentifierIterator> ModulesIter(
7962 GlobalIndex->createIdentifierIterator());
7963 return new ChainedIdentifierIterator(std::move(ReaderIter),
7964 std::move(ModulesIter));
7971 namespace serialization {
7976 unsigned PriorGeneration;
7977 unsigned InstanceBits = 0;
7978 unsigned FactoryBits = 0;
7979 bool InstanceHasMoreThanOneDecl =
false;
7980 bool FactoryHasMoreThanOneDecl =
false;
7986 unsigned PriorGeneration)
7987 : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) {}
7997 ++Reader.NumMethodPoolTableLookups;
8000 ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel);
8001 if (Pos == PoolTable->end())
8004 ++Reader.NumMethodPoolTableHits;
8005 ++Reader.NumSelectorsRead;
8009 ++Reader.NumMethodPoolEntriesRead;
8011 if (Reader.DeserializationListener)
8025 return InstanceMethods;
8030 return FactoryMethods;
8037 return InstanceHasMoreThanOneDecl;
8049 for (
unsigned I = 0, N = Methods.size(); I != N; ++I) {
8056 unsigned &Generation = SelectorGeneration[Sel];
8057 unsigned PriorGeneration = Generation;
8058 Generation = getGeneration();
8059 SelectorOutOfDate[Sel] =
false;
8062 ++NumMethodPoolLookups;
8064 ModuleMgr.visit(Visitor);
8070 ++NumMethodPoolHits;
8075 Sema &S = *getSema();
8076 Sema::GlobalMethodPool::iterator Pos
8092 if (SelectorOutOfDate[Sel])
8093 ReadMethodPool(Sel);
8100 for (
unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) {
8102 = dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespaces[I])))
8103 Namespaces.push_back(Namespace);
8108 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
8109 for (
unsigned Idx = 0, N = UndefinedButUsed.size(); Idx != N;) {
8110 NamedDecl *D = cast<NamedDecl>(GetDecl(UndefinedButUsed[Idx++]));
8113 Undefined.insert(std::make_pair(D, Loc));
8120 for (
unsigned Idx = 0, N = DelayedDeleteExprs.size(); Idx != N;) {
8121 FieldDecl *FD = cast<FieldDecl>(GetDecl(DelayedDeleteExprs[Idx++]));
8122 uint64_t Count = DelayedDeleteExprs[Idx++];
8123 for (uint64_t
C = 0;
C < Count; ++
C) {
8126 const bool IsArrayForm = DelayedDeleteExprs[Idx++];
8127 Exprs[FD].push_back(std::make_pair(DeleteLoc, IsArrayForm));
8134 for (
unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) {
8135 VarDecl *Var = dyn_cast_or_null<VarDecl>(GetDecl(TentativeDefinitions[I]));
8137 TentativeDefs.push_back(Var);
8139 TentativeDefinitions.clear();
8144 for (
unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++I) {
8146 = dyn_cast_or_null<DeclaratorDecl>(GetDecl(UnusedFileScopedDecls[I]));
8150 UnusedFileScopedDecls.clear();
8155 for (
unsigned I = 0, N = DelegatingCtorDecls.size(); I != N; ++I) {
8157 = dyn_cast_or_null<CXXConstructorDecl>(GetDecl(DelegatingCtorDecls[I]));
8161 DelegatingCtorDecls.clear();
8165 for (
unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++I) {
8167 = dyn_cast_or_null<TypedefNameDecl>(GetDecl(ExtVectorDecls[I]));
8171 ExtVectorDecls.clear();
8176 for (
unsigned I = 0, N = UnusedLocalTypedefNameCandidates.size(); I != N;
8179 GetDecl(UnusedLocalTypedefNameCandidates[I]));
8183 UnusedLocalTypedefNameCandidates.clear();
8188 if (ReferencedSelectorsData.empty())
8193 unsigned int DataSize = ReferencedSelectorsData.size()-1;
8195 while (I < DataSize) {
8196 Selector Sel = DecodeSelector(ReferencedSelectorsData[I++]);
8199 Sels.push_back(std::make_pair(Sel, SelLoc));
8201 ReferencedSelectorsData.clear();
8206 if (WeakUndeclaredIdentifiers.empty())
8209 for (
unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; ) {
8211 = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
8213 = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
8216 bool Used = WeakUndeclaredIdentifiers[I++];
8219 WeakIDs.push_back(std::make_pair(WeakId, WI));
8221 WeakUndeclaredIdentifiers.clear();
8225 for (
unsigned Idx = 0, N = VTableUses.size(); Idx < N; ) {
8227 VT.
Record = dyn_cast_or_null<CXXRecordDecl>(GetDecl(VTableUses[Idx++]));
8230 VTables.push_back(VT);
8238 for (
unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
8239 ValueDecl *D = cast<ValueDecl>(GetDecl(PendingInstantiations[Idx++]));
8243 Pending.push_back(std::make_pair(D, Loc));
8245 PendingInstantiations.clear();
8249 llvm::MapVector<
const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
8251 for (
unsigned Idx = 0, N = LateParsedTemplates.size(); Idx < N;
8253 FunctionDecl *FD = cast<FunctionDecl>(GetDecl(LateParsedTemplates[Idx++]));
8255 auto LT = std::make_unique<LateParsedTemplate>();
8256 LT->D = GetDecl(LateParsedTemplates[Idx++]);
8259 assert(F &&
"No module");
8261 unsigned TokN = LateParsedTemplates[Idx++];
8262 LT->Toks.reserve(TokN);
8263 for (
unsigned T = 0; T < TokN; ++T)
8264 LT->Toks.push_back(ReadToken(*F, LateParsedTemplates, Idx));
8266 LPTMap.insert(std::make_pair(FD, std::move(LT)));
8269 LateParsedTemplates.clear();
8274 ReadMethodPool(Sel);
8278 assert(ID &&
"Non-zero identifier ID required");
8279 assert(ID <= IdentifiersLoaded.size() &&
"identifier ID out of range");
8280 IdentifiersLoaded[ID - 1] = II;
8281 if (DeserializationListener)
8282 DeserializationListener->IdentifierRead(ID, II);
8305 if (NumCurrentElementsDeserializing && !Decls) {
8306 PendingIdentifierInfos[II].append(DeclIDs.begin(), DeclIDs.end());
8310 for (
unsigned I = 0, N = DeclIDs.size(); I != N; ++I) {
8315 PreloadedDeclIDs.push_back(DeclIDs[I]);
8319 NamedDecl *D = cast<NamedDecl>(GetDecl(DeclIDs[I]));
8323 Decls->push_back(D);
8330 pushExternalDeclIntoScope(D, II);
8338 if (IdentifiersLoaded.empty()) {
8339 Error(
"no identifier table in AST file");
8344 if (!IdentifiersLoaded[ID]) {
8346 assert(I != GlobalIdentifierMap.end() &&
"Corrupted global identifier map");
8348 unsigned Index = ID - M->BaseIdentifierID;
8349 const char *Str = M->IdentifierTableData + M->IdentifierOffsets[Index];
8356 const unsigned char *StrLenPtr = (
const unsigned char*) Str - 2;
8357 unsigned StrLen = (((unsigned) StrLenPtr[0])
8358 | (((unsigned) StrLenPtr[1]) << 8)) - 1;
8359 auto &II = PP.getIdentifierTable().get(StringRef(Str, StrLen));
8360 IdentifiersLoaded[
ID] = &II;
8362 if (DeserializationListener)
8363 DeserializationListener->IdentifierRead(ID + 1, &II);
8366 return IdentifiersLoaded[
ID];
8370 return DecodeIdentifierInfo(getGlobalIdentifierID(M, LocalID));
8378 ReadModuleOffsetMap(M);
8383 &&
"Invalid index into identifier index remap");
8385 return LocalID + I->second;
8392 if (MacrosLoaded.empty()) {
8393 Error(
"no macro table in AST file");
8398 if (!MacrosLoaded[ID]) {
8401 assert(I != GlobalMacroMap.end() &&
"Corrupted global macro map");
8403 unsigned Index = ID - M->BaseMacroID;
8404 MacrosLoaded[
ID] = ReadMacroRecord(*M, M->MacroOffsets[Index]);
8406 if (DeserializationListener)
8411 return MacrosLoaded[
ID];
8419 ReadModuleOffsetMap(M);
8423 assert(I != M.
MacroRemap.
end() &&
"Invalid index into macro index remap");
8425 return LocalID + I->second;
8434 ReadModuleOffsetMap(M);
8439 &&
"Invalid index into submodule index remap");
8441 return LocalID + I->second;
8446 assert(GlobalID == 0 &&
"Unhandled global submodule ID");
8450 if (GlobalID > SubmodulesLoaded.size()) {
8451 Error(
"submodule ID out of range in AST file");
8459 return getSubmodule(ID);
8470 auto I = GlobalSubmoduleMap.find(getGlobalSubmoduleID(F, ID >> 1));
8471 return I == GlobalSubmoduleMap.end() ? nullptr : I->second;
8474 unsigned IndexFromEnd = ID >> 1;
8475 assert(IndexFromEnd &&
"got reference to unknown module file");
8476 return getModuleManager().pch_modules().end()[-IndexFromEnd];
8491 auto PCHModules = getModuleManager().pch_modules();
8492 auto I = llvm::find(PCHModules, F);
8493 assert(I != PCHModules.end() &&
"emitting reference to unknown file");
8494 return (I - PCHModules.end()) << 1;
8499 if (
const Module *M = getSubmodule(ID))
8504 const auto &PCHChain = ModuleMgr.pch_modules();
8505 if (
std::distance(std::begin(PCHChain), std::end(PCHChain))) {
8506 ModuleFile &MF = ModuleMgr.getPrimaryModule();
8508 StringRef FileName = llvm::sys::path::filename(MF.
FileName);
8516 auto I = DefinitionSource.find(FD);
8517 if (I == DefinitionSource.end())
8518 return EK_ReplyHazy;
8519 return I->second ? EK_Never : EK_Always;
8523 return DecodeSelector(getGlobalSelectorID(M, LocalID));
8530 if (ID > SelectorsLoaded.size()) {
8531 Error(
"selector ID out of range in AST file");
8535 if (SelectorsLoaded[ID - 1].getAsOpaquePtr() ==
nullptr) {
8538 assert(I != GlobalSelectorMap.end() &&
"Corrupted global selector map");
8542 SelectorsLoaded[ID - 1] =
8543 Trait.
ReadKey(M.SelectorLookupTableData + M.SelectorOffsets[Idx], 0);
8544 if (DeserializationListener)
8545 DeserializationListener->SelectorRead(ID, SelectorsLoaded[ID - 1]);
8548 return SelectorsLoaded[ID - 1];
8552 return DecodeSelector(ID);
8557 return getTotalNumSelectors() + 1;
8566 ReadModuleOffsetMap(M);
8571 &&
"Invalid index into selector index remap");
8573 return LocalID + I->second;
8588 = readSourceLocation().getRawEncoding();
8590 = readSourceLocation().getRawEncoding();
8595 = readSourceLocation().getRawEncoding();
8611 NameInfo.
setName(readDeclarationName());
8612 NameInfo.
setLoc(readSourceLocation());
8619 unsigned NumTPLists = readInt();
8624 for (
unsigned i = 0; i != NumTPLists; ++i)
8635 unsigned NumParams = readInt();
8637 Params.reserve(NumParams);
8639 Params.push_back(readDeclAs<NamedDecl>());
8641 bool HasRequiresClause = readBool();
8642 Expr *RequiresClause = HasRequiresClause ? readExpr() :
nullptr;
8645 getContext(), TemplateLoc, LAngleLoc, Params, RAngleLoc, RequiresClause);
8646 return TemplateParams;
8651 bool Canonicalize) {
8652 unsigned NumTemplateArgs = readInt();
8653 TemplArgs.reserve(NumTemplateArgs);
8654 while (NumTemplateArgs--)
8655 TemplArgs.push_back(readTemplateArgument(Canonicalize));
8660 unsigned NumDecls = readInt();
8661 Set.
reserve(getContext(), NumDecls);
8662 while (NumDecls--) {
8671 bool isVirtual = readBool();
8672 bool isBaseOfClass = readBool();
8674 bool inheritConstructors = readBool();
8687 unsigned NumInitializers = readInt();
8688 assert(NumInitializers &&
"wrote ctor initializers but have no inits");
8690 for (
unsigned i = 0; i != NumInitializers; ++i) {
8692 bool IsBaseVirtual =
false;
8699 TInfo = readTypeSourceInfo();
8700 IsBaseVirtual = readBool();
8704 TInfo = readTypeSourceInfo();
8708 Member = readDeclAs<FieldDecl>();
8712 IndirectMember = readDeclAs<IndirectFieldDecl>();
8717 Expr *Init = readExpr();
8723 BOMInit =
new (Context)
8725 RParenLoc, MemberOrEllipsisLoc);
8727 BOMInit =
new (Context)
8730 BOMInit =
new (Context)
8734 BOMInit =
new (Context)
8736 LParenLoc, Init, RParenLoc);
8739 unsigned SourceOrder = readInt();
8743 CtorInitializers[i] = BOMInit;
8746 return CtorInitializers;
8752 unsigned N = readInt();
8754 for (
unsigned I = 0; I != N; ++I) {
8755 auto Kind = readNestedNameSpecifierKind();
8767 Builder.
Extend(Context, NS, Range.getBegin(), Range.getEnd());
8774 Builder.
Extend(Context, Alias, Range.getBegin(), Range.getEnd());
8780 bool Template = readBool();
8802 Builder.
MakeSuper(Context, RD, Range.getBegin(), Range.getEnd());
8822 unsigned Width = Record[Idx++];
8823 unsigned Scale = Record[Idx++];
8824 uint64_t Tmp = Record[Idx++];
8825 bool IsSigned = Tmp & 0x1;
8826 bool IsSaturated = Tmp & 0x2;
8827 bool HasUnsignedPadding = Tmp & 0x4;
8829 HasUnsignedPadding);
8832 static const llvm::fltSemantics &
8834 return llvm::APFloatBase::EnumToSemantics(
8835 static_cast<llvm::APFloatBase::Semantics>(reader.
readInt()));
8839 unsigned Kind = readInt();
8849 return APValue(readAPFloat(FloatSema));
8857 return APValue(std::move(First), readAPSInt());
8861 llvm::APFloat
First = readAPFloat(FloatSema1);
8863 return APValue(std::move(First), readAPFloat(FloatSema2));
8875 llvm_unreachable(
"Invalid APValue::ValueKind");
8880 return llvm::APFloat(Sem, readAPInt());
8885 unsigned Len = Record[Idx++];
8886 std::string
Result(Record.data() + Idx, Record.data() + Idx + Len);
8893 std::string
Filename = ReadString(Record, Idx);
8894 ResolveImportedPath(F, Filename);
8900 std::string
Filename = ReadString(Record, Idx);
8901 if (!BaseDirectory.empty())
8902 ResolveImportedPath(Filename, BaseDirectory);
8908 unsigned Major = Record[Idx++];
8909 unsigned Minor = Record[Idx++];
8910 unsigned Subminor = Record[Idx++];
8912 return VersionTuple(Major);
8914 return VersionTuple(Major, Minor - 1);
8915 return VersionTuple(Major, Minor - 1, Subminor - 1);
8926 return Diag(CurrentImportLoc, DiagID);
8930 return Diags.Report(Loc, DiagID);
8936 return PP.getIdentifierTable();
8942 assert((*CurrSwitchCaseStmts)[ID] ==
nullptr &&
8943 "Already have a SwitchCase with this ID");
8944 (*CurrSwitchCaseStmts)[
ID] = SC;
8949 assert((*CurrSwitchCaseStmts)[ID] !=
nullptr &&
"No SwitchCase with this ID");
8950 return (*CurrSwitchCaseStmts)[
ID];
8954 CurrSwitchCaseStmts->clear();
8959 std::vector<RawComment *> Comments;
8962 I = CommentsCursors.begin(),
8963 E = CommentsCursors.end();
8966 BitstreamCursor &
Cursor = I->first;
8973 Cursor.advanceSkippingSubblocks(
8974 BitstreamCursor::AF_DontPopBlockAtEnd);
8976 Error(MaybeEntry.takeError());
8979 llvm::BitstreamEntry Entry = MaybeEntry.get();
8981 switch (Entry.Kind) {
8982 case llvm::BitstreamEntry::SubBlock:
8984 Error(
"malformed block record in AST file");
8986 case llvm::BitstreamEntry::EndBlock:
8988 case llvm::BitstreamEntry::Record:
8996 if (!MaybeComment) {
8997 Error(MaybeComment.takeError());
9006 bool IsTrailingComment = Record[Idx++];
9007 bool IsAlmostTrailingComment = Record[Idx++];
9009 SR, Kind, IsTrailingComment, IsAlmostTrailingComment));
9015 llvm::DenseMap<FileID, std::map<unsigned, RawComment *>>
9016 FileToOffsetToComment;
9020 std::pair<FileID, unsigned> Loc =
9021 SourceMgr.getDecomposedLoc(CommentLoc);
9022 if (Loc.first.isValid())
9023 Context.
Comments.OrderedComments[Loc.first].emplace(Loc.second,
C);
9030 bool IncludeSystem,
bool Complain,
9035 assert(NumUserInputs <= NumInputs);
9036 unsigned N = IncludeSystem ? NumInputs : NumUserInputs;
9037 for (
unsigned I = 0; I < N; ++I) {
9038 bool IsSystem = I >= NumUserInputs;
9039 InputFile IF = getInputFile(MF, I+1, Complain);
9040 Visitor(IF, IsSystem);
9046 llvm::function_ref<
void(
const FileEntry *FE)> Visitor) {
9048 for (
unsigned I = 0; I < NumInputs; ++I) {
9049 InputFileInfo IFI = readInputFileInfo(MF, I + 1);
9050 if (IFI.TopLevelModuleMap)
9052 if (
auto *FE = getInputFile(MF, I + 1).getFile())
9060 return M->getFullModuleName();
9070 void ASTReader::finishPendingActions() {
9071 while (!PendingIdentifierInfos.empty() || !PendingFunctionTypes.empty() ||
9072 !PendingIncompleteDeclChains.empty() || !PendingDeclChains.empty() ||
9073 !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
9074 !PendingUpdateRecords.empty()) {
9077 using TopLevelDeclsMap =
9078 llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2>>;
9079 TopLevelDeclsMap TopLevelDecls;
9081 while (!PendingIdentifierInfos.empty()) {
9084 std::move(PendingIdentifierInfos.back().second);
9085 PendingIdentifierInfos.pop_back();
9087 SetGloballyVisibleDecls(II, DeclIDs, &TopLevelDecls[II]);
9092 for (
unsigned I = 0; I != PendingFunctionTypes.size(); ++I) {
9093 auto *FD = PendingFunctionTypes[I].first;
9094 FD->setType(GetType(PendingFunctionTypes[I].second));
9098 auto *DT = FD->getReturnType()->getContainedDeducedType();
9099 if (DT && DT->isDeduced())
9100 PendingDeducedTypeUpdates.insert(
9101 {FD->getCanonicalDecl(), FD->getReturnType()});
9103 PendingFunctionTypes.clear();
9107 for (
unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
9108 markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
9110 PendingIncompleteDeclChains.clear();
9113 for (
unsigned I = 0; I != PendingDeclChains.size(); ++I)
9114 loadPendingDeclChain(PendingDeclChains[I].first,
9115 PendingDeclChains[I].second);
9116 PendingDeclChains.clear();
9119 for (TopLevelDeclsMap::iterator TLD = TopLevelDecls.begin(),
9120 TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) {
9122 for (
unsigned I = 0, N = TLD->second.size(); I != N; ++I) {
9123 pushExternalDeclIntoScope(cast<NamedDecl>(TLD->second[I]), II);
9128 for (
unsigned I = 0; I != PendingMacroIDs.size(); ++I) {
9131 GlobalIDs.swap(PendingMacroIDs.begin()[I].second);
9133 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9135 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9136 if (!Info.M->isModule())
9137 resolvePendingMacro(II, Info);
9140 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9142 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9143 if (Info.M->isModule())
9144 resolvePendingMacro(II, Info);
9147 PendingMacroIDs.clear();
9151 while (!PendingDeclContextInfos.empty()) {
9152 PendingDeclContextInfo Info = PendingDeclContextInfos.front();
9153 PendingDeclContextInfos.pop_front();
9154 DeclContext *SemaDC = cast<DeclContext>(GetDecl(Info.SemaDC));
9155 DeclContext *LexicalDC = cast<DeclContext>(GetDecl(Info.LexicalDC));
9156 Info.D->setDeclContextsImpl(SemaDC, LexicalDC, getContext());
9160 while (!PendingUpdateRecords.empty()) {
9161 auto Update = PendingUpdateRecords.pop_back_val();
9162 ReadingKindTracker ReadingKind(Read_Decl, *
this);
9163 loadDeclUpdateRecords(
Update);
9169 assert(PendingFakeDefinitionData.empty() &&
9170 "faked up a class definition but never saw the real one");
9176 for (
Decl *D : PendingDefinitions) {
9177 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
9178 if (
const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) {
9183 if (
auto RD = dyn_cast<CXXRecordDecl>(D)) {
9184 for (
auto *R = getMostRecentExistingDecl(RD); R;
9185 R = R->getPreviousDecl()) {
9187 cast<CXXRecordDecl>(R)->isThisDeclarationADefinition() &&
9188 "declaration thinks it's the definition but it isn't");
9189 cast<CXXRecordDecl>(R)->DefinitionData = RD->DefinitionData;
9196 if (
auto ID = dyn_cast<ObjCInterfaceDecl>(D)) {
9201 for (
auto *R = getMostRecentExistingDecl(
ID); R; R = R->getPreviousDecl())
9202 cast<ObjCInterfaceDecl>(R)->Data =
ID->Data;
9207 if (
auto PD = dyn_cast<ObjCProtocolDecl>(D)) {
9208 for (
auto *R = getMostRecentExistingDecl(PD); R; R = R->getPreviousDecl())
9209 cast<ObjCProtocolDecl>(R)->Data = PD->Data;
9215 for (
auto *R = getMostRecentExistingDecl(RTD); R; R = R->getPreviousDecl())
9216 cast<RedeclarableTemplateDecl>(R)->Common = RTD->Common;
9218 PendingDefinitions.clear();
9224 for (PendingBodiesMap::iterator PB = PendingBodies.begin(),
9225 PBEnd = PendingBodies.end();
9226 PB != PBEnd; ++PB) {
9227 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
9237 if (
auto *RD = dyn_cast<CXXRecordDecl>(FD->getLexicalParent()))
9238 if (RD->isDependentContext() && !RD->isThisDeclarationADefinition())
9244 if (!getContext().getLangOpts().Modules || !FD->hasBody(Defn)) {
9248 mergeDefinitionVisibility(NonConstDefn, FD);
9250 if (!FD->isLateTemplateParsed() &&
9251 !NonConstDefn->isLateTemplateParsed() &&
9252 FD->getODRHash() != NonConstDefn->getODRHash()) {
9253 if (!isa<CXXMethodDecl>(FD)) {
9254 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
9255 }
else if (FD->getLexicalParent()->isFileContext() &&
9256 NonConstDefn->getLexicalParent()->isFileContext()) {
9260 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
9268 if (!getContext().getLangOpts().Modules || !MD->
hasBody())
9271 PendingBodies.clear();
9274 for (
auto *ND : PendingMergedDefinitionsToDeduplicate)
9275 getContext().deduplicateMergedDefinitonsFor(ND);
9276 PendingMergedDefinitionsToDeduplicate.clear();
9279 void ASTReader::diagnoseOdrViolations() {
9280 if (PendingOdrMergeFailures.empty() && PendingOdrMergeChecks.empty() &&
9281 PendingFunctionOdrMergeFailures.empty() &&
9282 PendingEnumOdrMergeFailures.empty())
9289 auto OdrMergeFailures = std::move(PendingOdrMergeFailures);
9290 PendingOdrMergeFailures.clear();
9291 for (
auto &Merge : OdrMergeFailures) {
9292 Merge.first->buildLookup();
9293 Merge.first->decls_begin();
9294 Merge.first->bases_begin();
9295 Merge.first->vbases_begin();
9296 for (
auto &RecordPair : Merge.second) {
9297 auto *RD = RecordPair.first;
9305 auto FunctionOdrMergeFailures = std::move(PendingFunctionOdrMergeFailures);
9306 PendingFunctionOdrMergeFailures.clear();
9307 for (
auto &Merge : FunctionOdrMergeFailures) {
9308 Merge.first->buildLookup();
9309 Merge.first->decls_begin();
9310 Merge.first->getBody();
9311 for (
auto &FD : Merge.second) {
9319 auto EnumOdrMergeFailures = std::move(PendingEnumOdrMergeFailures);
9320 PendingEnumOdrMergeFailures.clear();
9321 for (
auto &Merge : EnumOdrMergeFailures) {
9322 Merge.first->decls_begin();
9323 for (
auto &Enum : Merge.second) {
9324 Enum->decls_begin();
9334 while (!PendingOdrMergeChecks.empty()) {
9335 NamedDecl *D = PendingOdrMergeChecks.pop_back_val();
9349 for (
auto RI : D->
redecls()) {
9350 if (RI->getLexicalDeclContext() == CanonDef) {
9365 for (
auto *CanonMember : CanonDef->
decls()) {
9366 if (CanonMember->getCanonicalDecl() == DCanon) {
9375 if (
auto *ND = dyn_cast<NamedDecl>(CanonMember))
9377 Candidates.push_back(ND);
9383 if (!isa<TagDecl>(D))
9390 std::string CanonDefModule =
9391 getOwningModuleNameForDiagnostic(cast<Decl>(CanonDef));
9393 << D << getOwningModuleNameForDiagnostic(D)
9394 << CanonDef << CanonDefModule.empty() << CanonDefModule;
9396 if (Candidates.empty())
9397 Diag(cast<Decl>(CanonDef)->getLocation(),
9398 diag::note_module_odr_violation_no_possible_decls) << D;
9400 for (
unsigned I = 0, N = Candidates.size(); I != N; ++I)
9401 Diag(Candidates[I]->getLocation(),
9402 diag::note_module_odr_violation_possible_decl)
9406 DiagnosedOdrMergeFailures.insert(CanonDef);
9410 if (OdrMergeFailures.empty() && FunctionOdrMergeFailures.empty() &&
9411 EnumOdrMergeFailures.empty())
9420 auto ComputeQualTypeODRHash = [&Hash](
QualType Ty) {
9426 auto ComputeODRHash = [&Hash](
const Stmt *S) {
9433 auto ComputeSubDeclODRHash = [&Hash](
const Decl *D) {
9440 auto ComputeTemplateArgumentODRHash = [&Hash](
const TemplateArgument &TA) {
9446 auto ComputeTemplateParameterListODRHash =
9455 for (
auto &Merge : OdrMergeFailures) {
9458 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
9461 bool Diagnosed =
false;
9463 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstRecord);
9464 for (
auto &RecordPair : Merge.second) {
9468 if (FirstRecord == SecondRecord)
9471 std::string SecondModule = getOwningModuleNameForDiagnostic(SecondRecord);
9473 auto *FirstDD = FirstRecord->DefinitionData;
9474 auto *SecondDD = RecordPair.second;
9476 assert(FirstDD && SecondDD &&
"Definitions without DefinitionData");
9479 if (FirstDD != SecondDD) {
9480 enum ODRDefinitionDataDifference {
9487 auto ODRDiagError = [FirstRecord, &FirstModule,
9489 ODRDefinitionDataDifference DiffType) {
9490 return Diag(Loc, diag::err_module_odr_violation_definition_data)
9491 << FirstRecord << FirstModule.empty() << FirstModule << Range
9494 auto ODRDiagNote = [&SecondModule,
9496 ODRDefinitionDataDifference DiffType) {
9497 return Diag(Loc, diag::note_module_odr_violation_definition_data)
9498 << SecondModule << Range << DiffType;
9501 unsigned FirstNumBases = FirstDD->NumBases;
9502 unsigned FirstNumVBases = FirstDD->NumVBases;
9503 unsigned SecondNumBases = SecondDD->NumBases;
9504 unsigned SecondNumVBases = SecondDD->NumVBases;
9506 auto GetSourceRange = [](
struct CXXRecordDecl::DefinitionData *DD) {
9507 unsigned NumBases = DD->NumBases;
9509 auto bases = DD->bases();
9511 bases[NumBases - 1].getEndLoc());
9514 if (FirstNumBases != SecondNumBases) {
9515 ODRDiagError(FirstRecord->
getLocation(), GetSourceRange(FirstDD),
9518 ODRDiagNote(SecondRecord->
getLocation(), GetSourceRange(SecondDD),
9525 if (FirstNumVBases != SecondNumVBases) {
9526 ODRDiagError(FirstRecord->
getLocation(), GetSourceRange(FirstDD),
9529 ODRDiagNote(SecondRecord->
getLocation(), GetSourceRange(SecondDD),
9536 auto FirstBases = FirstDD->bases();
9537 auto SecondBases = SecondDD->bases();
9539 for (i = 0; i < FirstNumBases; ++i) {
9540 auto FirstBase = FirstBases[i];
9541 auto SecondBase = SecondBases[i];
9542 if (ComputeQualTypeODRHash(FirstBase.getType()) !=
9543 ComputeQualTypeODRHash(SecondBase.getType())) {
9544 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
9546 << (i + 1) << FirstBase.getType();
9548 SecondBase.getSourceRange(), BaseType)
9549 << (i + 1) << SecondBase.getType();
9553 if (FirstBase.isVirtual() != SecondBase.isVirtual()) {
9554 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
9556 << (i + 1) << FirstBase.isVirtual() << FirstBase.getType();
9558 SecondBase.getSourceRange(), BaseVirtual)
9559 << (i + 1) << SecondBase.isVirtual() << SecondBase.getType();
9563 if (FirstBase.getAccessSpecifierAsWritten() !=
9564 SecondBase.getAccessSpecifierAsWritten()) {
9565 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
9567 << (i + 1) << FirstBase.getType()
9568 << (int)FirstBase.getAccessSpecifierAsWritten();
9570 SecondBase.getSourceRange(), BaseAccess)
9571 << (i + 1) << SecondBase.getType()
9572 << (int)SecondBase.getAccessSpecifierAsWritten();
9577 if (i != FirstNumBases) {
9590 assert(!FirstTemplate == !SecondTemplate &&
9591 "Both pointers should be null or non-null");
9593 enum ODRTemplateDifference {
9596 ParamSingleDefaultArgument,
9597 ParamDifferentDefaultArgument,
9600 if (FirstTemplate && SecondTemplate) {
9601 DeclHashes FirstTemplateHashes;
9602 DeclHashes SecondTemplateHashes;
9604 auto PopulateTemplateParameterHashs =
9605 [&ComputeSubDeclODRHash](DeclHashes &Hashes,
9607 for (
auto *D : TD->getTemplateParameters()->asArray()) {
9608 Hashes.emplace_back(D, ComputeSubDeclODRHash(D));
9612 PopulateTemplateParameterHashs(FirstTemplateHashes, FirstTemplate);
9613 PopulateTemplateParameterHashs(SecondTemplateHashes, SecondTemplate);
9615 assert(FirstTemplateHashes.size() == SecondTemplateHashes.size() &&
9616 "Number of template parameters should be equal.");
9618 auto FirstIt = FirstTemplateHashes.begin();
9619 auto FirstEnd = FirstTemplateHashes.end();
9620 auto SecondIt = SecondTemplateHashes.begin();
9621 for (; FirstIt != FirstEnd; ++FirstIt, ++SecondIt) {
9622 if (FirstIt->second == SecondIt->second)
9625 auto ODRDiagError = [FirstRecord, &FirstModule,
9627 ODRTemplateDifference DiffType) {
9628 return Diag(Loc, diag::err_module_odr_violation_template_parameter)
9629 << FirstRecord << FirstModule.empty() << FirstModule << Range
9632 auto ODRDiagNote = [&SecondModule,
9634 ODRTemplateDifference DiffType) {
9635 return Diag(Loc, diag::note_module_odr_violation_template_parameter)
9636 << SecondModule << Range << DiffType;
9639 const NamedDecl* FirstDecl = cast<NamedDecl>(FirstIt->first);
9640 const NamedDecl* SecondDecl = cast<NamedDecl>(SecondIt->first);
9642 assert(FirstDecl->
getKind() == SecondDecl->getKind() &&
9643 "Parameter Decl's should be the same kind.");
9648 if (FirstName != SecondName) {
9649 const bool FirstNameEmpty =
9650 FirstName.
isIdentifier() && !FirstName.getAsIdentifierInfo();
9651 const bool SecondNameEmpty =
9653 assert((!FirstNameEmpty || !SecondNameEmpty) &&
9654 "Both template parameters cannot be unnamed.");
9656 FirstNameEmpty ? ParamEmptyName : ParamName)
9658 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9659 SecondNameEmpty ? ParamEmptyName : ParamName)
9664 switch (FirstDecl->
getKind()) {
9666 llvm_unreachable(
"Invalid template parameter type.");
9667 case Decl::TemplateTypeParm: {
9668 const auto *FirstParam = cast<TemplateTypeParmDecl>(FirstDecl);
9669 const auto *SecondParam = cast<TemplateTypeParmDecl>(SecondDecl);
9670 const bool HasFirstDefaultArgument =
9671 FirstParam->hasDefaultArgument() &&
9672 !FirstParam->defaultArgumentWasInherited();
9673 const bool HasSecondDefaultArgument =
9674 SecondParam->hasDefaultArgument() &&
9675 !SecondParam->defaultArgumentWasInherited();
9677 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9680 ParamSingleDefaultArgument)
9681 << HasFirstDefaultArgument;
9682 ODRDiagNote(SecondDecl->getLocation(),
9683 SecondDecl->getSourceRange(),
9684 ParamSingleDefaultArgument)
9685 << HasSecondDefaultArgument;
9689 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9690 "Expecting default arguments.");
9693 ParamDifferentDefaultArgument);
9694 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9695 ParamDifferentDefaultArgument);
9699 case Decl::NonTypeTemplateParm: {
9700 const auto *FirstParam = cast<NonTypeTemplateParmDecl>(FirstDecl);
9701 const auto *SecondParam = cast<NonTypeTemplateParmDecl>(SecondDecl);
9702 const bool HasFirstDefaultArgument =
9703 FirstParam->hasDefaultArgument() &&
9704 !FirstParam->defaultArgumentWasInherited();
9705 const bool HasSecondDefaultArgument =
9706 SecondParam->hasDefaultArgument() &&
9707 !SecondParam->defaultArgumentWasInherited();
9709 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9712 ParamSingleDefaultArgument)
9713 << HasFirstDefaultArgument;
9714 ODRDiagNote(SecondDecl->getLocation(),
9715 SecondDecl->getSourceRange(),
9716 ParamSingleDefaultArgument)
9717 << HasSecondDefaultArgument;
9721 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9722 "Expecting default arguments.");
9725 ParamDifferentDefaultArgument);
9726 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9727 ParamDifferentDefaultArgument);
9731 case Decl::TemplateTemplateParm: {
9732 const auto *FirstParam = cast<TemplateTemplateParmDecl>(FirstDecl);
9733 const auto *SecondParam =
9734 cast<TemplateTemplateParmDecl>(SecondDecl);
9735 const bool HasFirstDefaultArgument =
9736 FirstParam->hasDefaultArgument() &&
9737 !FirstParam->defaultArgumentWasInherited();
9738 const bool HasSecondDefaultArgument =
9739 SecondParam->hasDefaultArgument() &&
9740 !SecondParam->defaultArgumentWasInherited();
9742 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9745 ParamSingleDefaultArgument)
9746 << HasFirstDefaultArgument;
9747 ODRDiagNote(SecondDecl->getLocation(),
9748 SecondDecl->getSourceRange(),
9749 ParamSingleDefaultArgument)
9750 << HasSecondDefaultArgument;
9754 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9755 "Expecting default arguments.");
9758 ParamDifferentDefaultArgument);
9759 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9760 ParamDifferentDefaultArgument);
9769 if (FirstIt != FirstEnd) {
9775 DeclHashes FirstHashes;
9776 DeclHashes SecondHashes;
9778 auto PopulateHashes = [&ComputeSubDeclODRHash, FirstRecord](
9780 for (
auto *D : Record->decls()) {
9785 Hashes.emplace_back(D, ComputeSubDeclODRHash(D));
9788 PopulateHashes(FirstHashes, FirstRecord);
9789 PopulateHashes(SecondHashes, SecondRecord);
9808 } FirstDiffType = Other,
9809 SecondDiffType = Other;
9811 auto DifferenceSelector = [](
Decl *D) {
9812 assert(D &&
"valid Decl required");
9816 case Decl::AccessSpec:
9819 return PublicSpecifer;
9821 return PrivateSpecifer;
9823 return ProtectedSpecifer;
9827 llvm_unreachable(
"Invalid access specifier");
9828 case Decl::StaticAssert:
9829 return StaticAssert;
9832 case Decl::CXXMethod:
9833 case Decl::CXXConstructor:
9834 case Decl::CXXDestructor:
9836 case Decl::TypeAlias:
9844 case Decl::FunctionTemplate:
9845 return FunctionTemplate;
9849 Decl *FirstDecl =
nullptr;
9850 Decl *SecondDecl =
nullptr;
9851 auto FirstIt = FirstHashes.begin();
9852 auto SecondIt = SecondHashes.begin();
9857 while (FirstIt != FirstHashes.end() || SecondIt != SecondHashes.end()) {
9858 if (FirstIt != FirstHashes.end() && SecondIt != SecondHashes.end() &&
9859 FirstIt->second == SecondIt->second) {
9865 FirstDecl = FirstIt == FirstHashes.end() ? nullptr : FirstIt->first;
9866 SecondDecl = SecondIt == SecondHashes.end() ? nullptr : SecondIt->first;
9868 FirstDiffType = FirstDecl ? DifferenceSelector(FirstDecl) : EndOfClass;
9870 SecondDecl ? DifferenceSelector(SecondDecl) : EndOfClass;
9875 if (FirstDiffType == Other || SecondDiffType == Other) {
9880 diag::err_module_odr_violation_different_definitions)
9881 << FirstRecord << FirstModule.empty() << FirstModule;
9889 diag::note_module_odr_violation_different_definitions)
9901 if (FirstDiffType != SecondDiffType) {
9904 if (FirstDiffType == EndOfClass) {
9907 FirstLoc = FirstIt->first->getLocation();
9908 FirstRange = FirstIt->first->getSourceRange();
9910 Diag(FirstLoc, diag::err_module_odr_violation_mismatch_decl)
9911 << FirstRecord << FirstModule.empty() << FirstModule << FirstRange
9916 if (SecondDiffType == EndOfClass) {
9922 Diag(SecondLoc, diag::note_module_odr_violation_mismatch_decl)
9923 << SecondModule << SecondRange << SecondDiffType;
9928 assert(FirstDiffType == SecondDiffType);
9932 enum ODRDeclDifference {
9933 StaticAssertCondition,
9934 StaticAssertMessage,
9935 StaticAssertOnlyMessage,
9938 FieldSingleBitField,
9939 FieldDifferentWidthBitField,
9941 FieldSingleInitializer,
9942 FieldDifferentInitializers,
9951 MethodNumberParameters,
9952 MethodParameterType,
9953 MethodParameterName,
9954 MethodParameterSingleDefaultArgument,
9955 MethodParameterDifferentDefaultArgument,
9956 MethodNoTemplateArguments,
9957 MethodDifferentNumberTemplateArguments,
9958 MethodDifferentTemplateArgument,
9960 MethodDifferentBody,
9965 VarSingleInitializer,
9966 VarDifferentInitializer,
9971 FunctionTemplateDifferentNumberParameters,
9972 FunctionTemplateParameterDifferentKind,
9973 FunctionTemplateParameterName,
9974 FunctionTemplateParameterSingleDefaultArgument,
9975 FunctionTemplateParameterDifferentDefaultArgument,
9976 FunctionTemplateParameterDifferentType,
9977 FunctionTemplatePackParameter,
9983 auto ODRDiagError = [FirstRecord, &FirstModule,
this](
9985 return Diag(Loc, diag::err_module_odr_violation_mismatch_decl_diff)
9986 << FirstRecord << FirstModule.empty() << FirstModule << Range
9989 auto ODRDiagNote = [&SecondModule,
this](
9991 return Diag(Loc, diag::note_module_odr_violation_mismatch_decl_diff)
9992 << SecondModule << Range << DiffType;
9995 switch (FirstDiffType) {
9998 case PublicSpecifer:
9999 case PrivateSpecifer:
10000 case ProtectedSpecifer:
10001 llvm_unreachable(
"Invalid diff type");
10003 case StaticAssert: {
10008 Expr *SecondExpr = SecondSA->getAssertExpr();
10009 unsigned FirstODRHash = ComputeODRHash(FirstExpr);
10010 unsigned SecondODRHash = ComputeODRHash(SecondExpr);
10011 if (FirstODRHash != SecondODRHash) {
10012 ODRDiagError(FirstExpr->getBeginLoc(), FirstExpr->getSourceRange(),
10013 StaticAssertCondition);
10015 StaticAssertCondition);
10022 assert((FirstStr || SecondStr) &&
"Both messages cannot be empty");
10023 if ((FirstStr && !SecondStr) || (!FirstStr && SecondStr)) {
10037 SecondLoc = SecondSA->getBeginLoc();
10038 SecondRange = SecondSA->getSourceRange();
10040 ODRDiagError(FirstLoc, FirstRange, StaticAssertOnlyMessage)
10041 << (FirstStr ==
nullptr);
10042 ODRDiagNote(SecondLoc, SecondRange, StaticAssertOnlyMessage)
10043 << (SecondStr ==
nullptr);
10048 if (FirstStr && SecondStr &&
10051 StaticAssertMessage);
10053 StaticAssertMessage);
10060 FieldDecl *FirstField = cast<FieldDecl>(FirstDecl);
10061 FieldDecl *SecondField = cast<FieldDecl>(SecondDecl);
10064 if (FirstII->getName() != SecondII->
getName()) {
10068 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10076 assert(getContext().hasSameType(FirstField->
getType(),
10077 SecondField->getType()));
10080 QualType SecondType = SecondField->getType();
10081 if (ComputeQualTypeODRHash(FirstType) !=
10082 ComputeQualTypeODRHash(SecondType)) {
10085 << FirstII << FirstType;
10086 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10088 << SecondII << SecondType;
10094 const bool IsFirstBitField = FirstField->
isBitField();
10095 const bool IsSecondBitField = SecondField->isBitField();
10096 if (IsFirstBitField != IsSecondBitField) {
10098 FieldSingleBitField)
10099 << FirstII << IsFirstBitField;
10100 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10101 FieldSingleBitField)
10102 << SecondII << IsSecondBitField;
10107 if (IsFirstBitField && IsSecondBitField) {
10108 unsigned FirstBitWidthHash =
10110 unsigned SecondBitWidthHash =
10111 ComputeODRHash(SecondField->getBitWidth());
10112 if (FirstBitWidthHash != SecondBitWidthHash) {
10115 FieldDifferentWidthBitField)
10117 ODRDiagNote(SecondField->getLocation(),
10118 SecondField->getSourceRange(),
10119 FieldDifferentWidthBitField)
10120 << SecondII << SecondField->getBitWidth()->getSourceRange();
10126 const bool IsFirstMutable = FirstField->
isMutable();
10127 const bool IsSecondMutable = SecondField->isMutable();
10128 if (IsFirstMutable != IsSecondMutable) {
10130 FieldSingleMutable)
10131 << FirstII << IsFirstMutable;
10132 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10133 FieldSingleMutable)
10134 << SecondII << IsSecondMutable;
10140 const Expr *SecondInitializer = SecondField->getInClassInitializer();
10141 if ((!FirstInitializer && SecondInitializer) ||
10142 (FirstInitializer && !SecondInitializer)) {
10144 FieldSingleInitializer)
10145 << FirstII << (FirstInitializer !=
nullptr);
10146 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10147 FieldSingleInitializer)
10148 << SecondII << (SecondInitializer !=
nullptr);
10153 if (FirstInitializer && SecondInitializer) {
10154 unsigned FirstInitHash = ComputeODRHash(FirstInitializer);
10155 unsigned SecondInitHash = ComputeODRHash(SecondInitializer);
10156 if (FirstInitHash != SecondInitHash) {
10159 FieldDifferentInitializers)
10161 ODRDiagNote(SecondField->getLocation(),
10162 SecondField->getSourceRange(),
10163 FieldDifferentInitializers)
10179 auto GetMethodTypeForDiagnostics = [](
const CXXMethodDecl* D) {
10180 if (isa<CXXConstructorDecl>(D))
return DiagConstructor;
10181 if (isa<CXXDestructorDecl>(D))
return DiagDestructor;
10184 const CXXMethodDecl *FirstMethod = cast<CXXMethodDecl>(FirstDecl);
10185 const CXXMethodDecl *SecondMethod = cast<CXXMethodDecl>(SecondDecl);
10186 FirstMethodType = GetMethodTypeForDiagnostics(FirstMethod);
10187 SecondMethodType = GetMethodTypeForDiagnostics(SecondMethod);
10189 auto SecondName = SecondMethod->getDeclName();
10190 if (FirstMethodType != SecondMethodType || FirstName != SecondName) {
10193 << FirstMethodType << FirstName;
10194 ODRDiagNote(SecondMethod->getLocation(),
10195 SecondMethod->getSourceRange(), MethodName)
10196 << SecondMethodType << SecondName;
10203 const bool SecondDeleted = SecondMethod->isDeletedAsWritten();
10204 if (FirstDeleted != SecondDeleted) {
10207 << FirstMethodType << FirstName << FirstDeleted;
10209 ODRDiagNote(SecondMethod->getLocation(),
10210 SecondMethod->getSourceRange(), MethodDeleted)
10211 << SecondMethodType << SecondName << SecondDeleted;
10217 const bool SecondDefaulted = SecondMethod->isExplicitlyDefaulted();
10218 if (FirstDefaulted != SecondDefaulted) {
10221 << FirstMethodType << FirstName << FirstDefaulted;
10223 ODRDiagNote(SecondMethod->getLocation(),
10224 SecondMethod->getSourceRange(), MethodDefaulted)
10225 << SecondMethodType << SecondName << SecondDefaulted;
10231 const bool SecondVirtual = SecondMethod->isVirtualAsWritten();
10232 const bool FirstPure = FirstMethod->
isPure();
10233 const bool SecondPure = SecondMethod->isPure();
10234 if ((FirstVirtual || SecondVirtual) &&
10235 (FirstVirtual != SecondVirtual || FirstPure != SecondPure)) {
10238 << FirstMethodType << FirstName << FirstPure << FirstVirtual;
10239 ODRDiagNote(SecondMethod->getLocation(),
10240 SecondMethod->getSourceRange(), MethodVirtual)
10241 << SecondMethodType << SecondName << SecondPure << SecondVirtual;
10250 const auto SecondStorage = SecondMethod->getStorageClass();
10251 const bool FirstStatic = FirstStorage ==
SC_Static;
10252 const bool SecondStatic = SecondStorage ==
SC_Static;
10253 if (FirstStatic != SecondStatic) {
10256 << FirstMethodType << FirstName << FirstStatic;
10257 ODRDiagNote(SecondMethod->getLocation(),
10258 SecondMethod->getSourceRange(), MethodStatic)
10259 << SecondMethodType << SecondName << SecondStatic;
10264 const bool FirstVolatile = FirstMethod->
isVolatile();
10265 const bool SecondVolatile = SecondMethod->isVolatile();
10266 if (FirstVolatile != SecondVolatile) {
10269 << FirstMethodType << FirstName << FirstVolatile;
10270 ODRDiagNote(SecondMethod->getLocation(),
10271 SecondMethod->getSourceRange(), MethodVolatile)
10272 << SecondMethodType << SecondName << SecondVolatile;
10277 const bool FirstConst = FirstMethod->
isConst();
10278 const bool SecondConst = SecondMethod->isConst();
10279 if (FirstConst != SecondConst) {
10282 << FirstMethodType << FirstName << FirstConst;
10283 ODRDiagNote(SecondMethod->getLocation(),
10284 SecondMethod->getSourceRange(), MethodConst)
10285 << SecondMethodType << SecondName << SecondConst;
10291 const bool SecondInline = SecondMethod->isInlineSpecified();
10292 if (FirstInline != SecondInline) {
10295 << FirstMethodType << FirstName << FirstInline;
10296 ODRDiagNote(SecondMethod->getLocation(),
10297 SecondMethod->getSourceRange(), MethodInline)
10298 << SecondMethodType << SecondName << SecondInline;
10303 const unsigned FirstNumParameters = FirstMethod->
param_size();
10304 const unsigned SecondNumParameters = SecondMethod->param_size();
10305 if (FirstNumParameters != SecondNumParameters) {
10308 << FirstMethodType << FirstName << FirstNumParameters;
10309 ODRDiagNote(SecondMethod->getLocation(),
10310 SecondMethod->getSourceRange(), MethodNumberParameters)
10311 << SecondMethodType << SecondName << SecondNumParameters;
10317 bool ParameterMismatch =
false;
10318 for (
unsigned I = 0; I < FirstNumParameters; ++I) {
10320 const ParmVarDecl *SecondParam = SecondMethod->getParamDecl(I);
10324 if (FirstParamType != SecondParamType &&
10325 ComputeQualTypeODRHash(FirstParamType) !=
10326 ComputeQualTypeODRHash(SecondParamType)) {
10331 << FirstMethodType << FirstName << (I + 1) << FirstParamType
10332 <<
true << ParamDecayedType->getOriginalType();
10336 << FirstMethodType << FirstName << (I + 1) << FirstParamType
10342 ODRDiagNote(SecondMethod->getLocation(),
10343 SecondMethod->getSourceRange(), MethodParameterType)
10344 << SecondMethodType << SecondName << (I + 1)
10345 << SecondParamType <<
true 10346 << ParamDecayedType->getOriginalType();
10348 ODRDiagNote(SecondMethod->getLocation(),
10349 SecondMethod->getSourceRange(), MethodParameterType)
10350 << SecondMethodType << SecondName << (I + 1)
10351 << SecondParamType <<
false;
10353 ParameterMismatch =
true;
10359 if (FirstParamName != SecondParamName) {
10362 << FirstMethodType << FirstName << (I + 1) << FirstParamName;
10363 ODRDiagNote(SecondMethod->getLocation(),
10364 SecondMethod->getSourceRange(), MethodParameterName)
10365 << SecondMethodType << SecondName << (I + 1) << SecondParamName;
10366 ParameterMismatch =
true;
10372 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
10375 MethodParameterSingleDefaultArgument)
10376 << FirstMethodType << FirstName << (I + 1)
10377 << (FirstInit ==
nullptr)
10379 ODRDiagNote(SecondMethod->getLocation(),
10380 SecondMethod->getSourceRange(),
10381 MethodParameterSingleDefaultArgument)
10382 << SecondMethodType << SecondName << (I + 1)
10383 << (SecondInit ==
nullptr)
10385 ParameterMismatch =
true;
10389 if (FirstInit && SecondInit &&
10390 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
10393 MethodParameterDifferentDefaultArgument)
10394 << FirstMethodType << FirstName << (I + 1)
10396 ODRDiagNote(SecondMethod->getLocation(),
10397 SecondMethod->getSourceRange(),
10398 MethodParameterDifferentDefaultArgument)
10399 << SecondMethodType << SecondName << (I + 1)
10401 ParameterMismatch =
true;
10407 if (ParameterMismatch) {
10412 const auto *FirstTemplateArgs =
10414 const auto *SecondTemplateArgs =
10415 SecondMethod->getTemplateSpecializationArgs();
10417 if ((FirstTemplateArgs && !SecondTemplateArgs) ||
10418 (!FirstTemplateArgs && SecondTemplateArgs)) {
10421 << FirstMethodType << FirstName << (FirstTemplateArgs !=
nullptr);
10422 ODRDiagNote(SecondMethod->getLocation(),
10423 SecondMethod->getSourceRange(), MethodNoTemplateArguments)
10424 << SecondMethodType << SecondName
10425 << (SecondTemplateArgs !=
nullptr);
10431 if (FirstTemplateArgs && SecondTemplateArgs) {
10433 auto ExpandTemplateArgumentList =
10438 ExpandedList.push_back(&TA);
10442 ExpandedList.push_back(&PackTA);
10445 return ExpandedList;
10448 ExpandTemplateArgumentList(FirstTemplateArgs);
10450 ExpandTemplateArgumentList(SecondTemplateArgs);
10452 if (FirstExpandedList.size() != SecondExpandedList.size()) {
10455 MethodDifferentNumberTemplateArguments)
10456 << FirstMethodType << FirstName
10457 << (
unsigned)FirstExpandedList.size();
10458 ODRDiagNote(SecondMethod->getLocation(),
10459 SecondMethod->getSourceRange(),
10460 MethodDifferentNumberTemplateArguments)
10461 << SecondMethodType << SecondName
10462 << (
unsigned)SecondExpandedList.size();
10468 bool TemplateArgumentMismatch =
false;
10469 for (
unsigned i = 0, e = FirstExpandedList.size(); i != e; ++i) {
10471 &SecondTA = *SecondExpandedList[i];
10472 if (ComputeTemplateArgumentODRHash(FirstTA) ==
10473 ComputeTemplateArgumentODRHash(SecondTA)) {
10479 MethodDifferentTemplateArgument)
10480 << FirstMethodType << FirstName << FirstTA << i + 1;
10481 ODRDiagNote(SecondMethod->getLocation(),
10482 SecondMethod->getSourceRange(),
10483 MethodDifferentTemplateArgument)
10484 << SecondMethodType << SecondName << SecondTA << i + 1;
10486 TemplateArgumentMismatch =
true;
10490 if (TemplateArgumentMismatch) {
10497 auto ComputeCXXMethodODRHash = [&Hash](
const CXXMethodDecl *D) {
10506 const bool HasFirstBody =
10507 ComputeCXXMethodODRHash(FirstMethod) != FirstMethod->
getODRHash();
10508 const bool HasSecondBody =
10509 ComputeCXXMethodODRHash(SecondMethod) != SecondMethod->getODRHash();
10511 if (HasFirstBody != HasSecondBody) {
10514 << FirstMethodType << FirstName << HasFirstBody;
10515 ODRDiagNote(SecondMethod->getLocation(),
10516 SecondMethod->getSourceRange(), MethodSingleBody)
10517 << SecondMethodType << SecondName << HasSecondBody;
10522 if (HasFirstBody && HasSecondBody) {
10525 << FirstMethodType << FirstName;
10526 ODRDiagNote(SecondMethod->getLocation(),
10527 SecondMethod->getSourceRange(), MethodDifferentBody)
10528 << SecondMethodType << SecondName;
10540 auto SecondName = SecondTD->getDeclName();
10541 if (FirstName != SecondName) {
10544 << (FirstDiffType == TypeAlias) << FirstName;
10545 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
10547 << (FirstDiffType == TypeAlias) << SecondName;
10553 QualType SecondType = SecondTD->getUnderlyingType();
10554 if (ComputeQualTypeODRHash(FirstType) !=
10555 ComputeQualTypeODRHash(SecondType)) {
10558 << (FirstDiffType == TypeAlias) << FirstName << FirstType;
10559 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
10561 << (FirstDiffType == TypeAlias) << SecondName << SecondType;
10568 VarDecl *FirstVD = cast<VarDecl>(FirstDecl);
10569 VarDecl *SecondVD = cast<VarDecl>(SecondDecl);
10571 auto SecondName = SecondVD->getDeclName();
10572 if (FirstName != SecondName) {
10576 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10584 QualType SecondType = SecondVD->getType();
10585 if (ComputeQualTypeODRHash(FirstType) !=
10586 ComputeQualTypeODRHash(SecondType)) {
10589 << FirstName << FirstType;
10590 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10592 << SecondName << SecondType;
10598 const Expr *SecondInit = SecondVD->getInit();
10599 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
10601 VarSingleInitializer)
10602 << FirstName << (FirstInit ==
nullptr)
10604 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10605 VarSingleInitializer)
10606 << SecondName << (SecondInit ==
nullptr)
10612 if (FirstInit && SecondInit &&
10613 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
10615 VarDifferentInitializer)
10617 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10618 VarDifferentInitializer)
10624 const bool FirstIsConstexpr = FirstVD->
isConstexpr();
10625 const bool SecondIsConstexpr = SecondVD->isConstexpr();
10626 if (FirstIsConstexpr != SecondIsConstexpr) {
10629 << FirstName << FirstIsConstexpr;
10630 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10632 << SecondName << SecondIsConstexpr;
10639 FriendDecl *FirstFriend = cast<FriendDecl>(FirstDecl);
10640 FriendDecl *SecondFriend = cast<FriendDecl>(SecondDecl);
10643 NamedDecl *SecondND = SecondFriend->getFriendDecl();
10648 if (FirstND && SecondND) {
10652 ODRDiagNote(SecondFriend->getFriendLoc(),
10653 SecondFriend->getSourceRange(), FriendFunction)
10660 if (FirstTSI && SecondTSI) {
10663 assert(ComputeQualTypeODRHash(FirstFriendType) !=
10664 ComputeQualTypeODRHash(SecondFriendType));
10667 << FirstFriendType;
10668 ODRDiagNote(SecondFriend->getFriendLoc(),
10669 SecondFriend->getSourceRange(), FriendType)
10670 << SecondFriendType;
10676 FriendTypeFunction)
10677 << (FirstTSI ==
nullptr);
10678 ODRDiagNote(SecondFriend->getFriendLoc(),
10679 SecondFriend->getSourceRange(), FriendTypeFunction)
10680 << (SecondTSI ==
nullptr);
10685 case FunctionTemplate: {
10687 cast<FunctionTemplateDecl>(FirstDecl);
10689 cast<FunctionTemplateDecl>(SecondDecl);
10694 SecondTemplate->getTemplateParameters();
10696 if (FirstTPL->size() != SecondTPL->
size()) {
10699 FunctionTemplateDifferentNumberParameters)
10700 << FirstTemplate << FirstTPL->size();
10701 ODRDiagNote(SecondTemplate->getLocation(),
10702 SecondTemplate->getSourceRange(),
10703 FunctionTemplateDifferentNumberParameters)
10704 << SecondTemplate << SecondTPL->
size();
10710 bool ParameterMismatch =
false;
10711 for (
unsigned i = 0, e = FirstTPL->size(); i != e; ++i) {
10712 NamedDecl *FirstParam = FirstTPL->getParam(i);
10717 TemplateTypeParameter,
10718 NonTypeTemplateParameter,
10719 TemplateTemplateParameter,
10724 llvm_unreachable(
"Unexpected template parameter type");
10725 case Decl::TemplateTypeParm:
10726 return TemplateTypeParameter;
10727 case Decl::NonTypeTemplateParm:
10728 return NonTypeTemplateParameter;
10729 case Decl::TemplateTemplateParm:
10730 return TemplateTemplateParameter;
10736 FunctionTemplateParameterDifferentKind)
10737 << FirstTemplate << (i + 1) << GetParamType(FirstParam);
10738 ODRDiagNote(SecondTemplate->getLocation(),
10739 SecondTemplate->getSourceRange(),
10740 FunctionTemplateParameterDifferentKind)
10741 << SecondTemplate << (i + 1) << GetParamType(SecondParam);
10743 ParameterMismatch =
true;
10750 FunctionTemplateParameterName)
10753 ODRDiagNote(SecondTemplate->getLocation(),
10754 SecondTemplate->getSourceRange(),
10755 FunctionTemplateParameterName)
10756 << SecondTemplate << (i + 1)
10758 ParameterMismatch =
true;
10762 if (isa<TemplateTypeParmDecl>(FirstParam) &&
10763 isa<TemplateTypeParmDecl>(SecondParam)) {
10765 cast<TemplateTypeParmDecl>(FirstParam);
10767 cast<TemplateTypeParmDecl>(SecondParam);
10768 bool HasFirstDefaultArgument =
10771 bool HasSecondDefaultArgument =
10772 SecondTTPD->hasDefaultArgument() &&
10773 !SecondTTPD->defaultArgumentWasInherited();
10774 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
10777 FunctionTemplateParameterSingleDefaultArgument)
10778 << FirstTemplate << (i + 1) << HasFirstDefaultArgument;
10779 ODRDiagNote(SecondTemplate->getLocation(),
10780 SecondTemplate->getSourceRange(),
10781 FunctionTemplateParameterSingleDefaultArgument)
10782 << SecondTemplate << (i + 1) << HasSecondDefaultArgument;
10783 ParameterMismatch =
true;
10787 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
10789 QualType SecondType = SecondTTPD->getDefaultArgument();
10790 if (ComputeQualTypeODRHash(FirstType) !=
10791 ComputeQualTypeODRHash(SecondType)) {
10794 FunctionTemplateParameterDifferentDefaultArgument)
10795 << FirstTemplate << (i + 1) << FirstType;
10796 ODRDiagNote(SecondTemplate->getLocation(),
10797 SecondTemplate->getSourceRange(),
10798 FunctionTemplateParameterDifferentDefaultArgument)
10799 << SecondTemplate << (i + 1) << SecondType;
10800 ParameterMismatch =
true;
10806 SecondTTPD->isParameterPack()) {
10809 FunctionTemplatePackParameter)
10811 ODRDiagNote(SecondTemplate->getLocation(),
10812 SecondTemplate->getSourceRange(),
10813 FunctionTemplatePackParameter)
10814 << SecondTemplate << (i + 1) << SecondTTPD->isParameterPack();
10815 ParameterMismatch =
true;
10820 if (isa<TemplateTemplateParmDecl>(FirstParam) &&
10821 isa<TemplateTemplateParmDecl>(SecondParam)) {
10823 cast<TemplateTemplateParmDecl>(FirstParam);
10825 cast<TemplateTemplateParmDecl>(SecondParam);
10830 SecondTTPD->getTemplateParameters();
10832 if (ComputeTemplateParameterListODRHash(FirstTPL) !=
10833 ComputeTemplateParameterListODRHash(SecondTPL)) {
10836 FunctionTemplateParameterDifferentType)
10837 << FirstTemplate << (i + 1);
10838 ODRDiagNote(SecondTemplate->getLocation(),
10839 SecondTemplate->getSourceRange(),
10840 FunctionTemplateParameterDifferentType)
10841 << SecondTemplate << (i + 1);
10842 ParameterMismatch =
true;
10846 bool HasFirstDefaultArgument =
10849 bool HasSecondDefaultArgument =
10850 SecondTTPD->hasDefaultArgument() &&
10851 !SecondTTPD->defaultArgumentWasInherited();
10852 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
10855 FunctionTemplateParameterSingleDefaultArgument)
10856 << FirstTemplate << (i + 1) << HasFirstDefaultArgument;
10857 ODRDiagNote(SecondTemplate->getLocation(),
10858 SecondTemplate->getSourceRange(),
10859 FunctionTemplateParameterSingleDefaultArgument)
10860 << SecondTemplate << (i + 1) << HasSecondDefaultArgument;
10861 ParameterMismatch =
true;
10865 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
10869 SecondTTPD->getDefaultArgument().getArgument();
10870 if (ComputeTemplateArgumentODRHash(FirstTA) !=
10871 ComputeTemplateArgumentODRHash(SecondTA)) {
10874 FunctionTemplateParameterDifferentDefaultArgument)
10875 << FirstTemplate << (i + 1) << FirstTA;
10876 ODRDiagNote(SecondTemplate->getLocation(),
10877 SecondTemplate->getSourceRange(),
10878 FunctionTemplateParameterDifferentDefaultArgument)
10879 << SecondTemplate << (i + 1) << SecondTA;
10880 ParameterMismatch =
true;
10886 SecondTTPD->isParameterPack()) {
10889 FunctionTemplatePackParameter)
10891 ODRDiagNote(SecondTemplate->getLocation(),
10892 SecondTemplate->getSourceRange(),
10893 FunctionTemplatePackParameter)
10894 << SecondTemplate << (i + 1) << SecondTTPD->isParameterPack();
10895 ParameterMismatch =
true;
10900 if (isa<NonTypeTemplateParmDecl>(FirstParam) &&
10901 isa<NonTypeTemplateParmDecl>(SecondParam)) {
10903 cast<NonTypeTemplateParmDecl>(FirstParam);
10905 cast<NonTypeTemplateParmDecl>(SecondParam);
10908 QualType SecondType = SecondNTTPD->getType();
10909 if (ComputeQualTypeODRHash(FirstType) !=
10910 ComputeQualTypeODRHash(SecondType)) {
10913 FunctionTemplateParameterDifferentType)
10914 << FirstTemplate << (i + 1);
10915 ODRDiagNote(SecondTemplate->getLocation(),
10916 SecondTemplate->getSourceRange(),
10917 FunctionTemplateParameterDifferentType)
10918 << SecondTemplate << (i + 1);
10919 ParameterMismatch =
true;
10923 bool HasFirstDefaultArgument =
10926 bool HasSecondDefaultArgument =
10927 SecondNTTPD->hasDefaultArgument() &&
10928 !SecondNTTPD->defaultArgumentWasInherited();
10929 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
10932 FunctionTemplateParameterSingleDefaultArgument)
10933 << FirstTemplate << (i + 1) << HasFirstDefaultArgument;
10934 ODRDiagNote(SecondTemplate->getLocation(),
10935 SecondTemplate->getSourceRange(),
10936 FunctionTemplateParameterSingleDefaultArgument)
10937 << SecondTemplate << (i + 1) << HasSecondDefaultArgument;
10938 ParameterMismatch =
true;
10942 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
10944 Expr *SecondDefaultArgument = SecondNTTPD->getDefaultArgument();
10945 if (ComputeODRHash(FirstDefaultArgument) !=
10946 ComputeODRHash(SecondDefaultArgument)) {
10949 FunctionTemplateParameterDifferentDefaultArgument)
10950 << FirstTemplate << (i + 1) << FirstDefaultArgument;
10951 ODRDiagNote(SecondTemplate->getLocation(),
10952 SecondTemplate->getSourceRange(),
10953 FunctionTemplateParameterDifferentDefaultArgument)
10954 << SecondTemplate << (i + 1) << SecondDefaultArgument;
10955 ParameterMismatch =
true;
10961 SecondNTTPD->isParameterPack()) {
10964 FunctionTemplatePackParameter)
10966 ODRDiagNote(SecondTemplate->getLocation(),
10967 SecondTemplate->getSourceRange(),
10968 FunctionTemplatePackParameter)
10969 << SecondTemplate << (i + 1)
10970 << SecondNTTPD->isParameterPack();
10971 ParameterMismatch =
true;
10977 if (ParameterMismatch) {
10990 diag::err_module_odr_violation_mismatch_decl_unknown)
10991 << FirstRecord << FirstModule.empty() << FirstModule << FirstDiffType
10994 diag::note_module_odr_violation_mismatch_decl_unknown)
10995 << SecondModule << FirstDiffType << SecondDecl->
getSourceRange();
11006 Diag(Merge.first->getLocation(),
11007 diag::err_module_odr_violation_different_instantiations)
11013 for (
auto &Merge : FunctionOdrMergeFailures) {
11014 enum ODRFunctionDifference {
11018 ParameterSingleDefaultArgument,
11019 ParameterDifferentDefaultArgument,
11024 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstFunction);
11026 bool Diagnosed =
false;
11027 for (
auto &SecondFunction : Merge.second) {
11029 if (FirstFunction == SecondFunction)
11032 std::string SecondModule =
11033 getOwningModuleNameForDiagnostic(SecondFunction);
11035 auto ODRDiagError = [FirstFunction, &FirstModule,
11037 ODRFunctionDifference DiffType) {
11038 return Diag(Loc, diag::err_module_odr_violation_function)
11039 << FirstFunction << FirstModule.empty() << FirstModule << Range
11044 ODRFunctionDifference DiffType) {
11045 return Diag(Loc, diag::note_module_odr_violation_function)
11046 << SecondModule << Range << DiffType;
11049 if (ComputeQualTypeODRHash(FirstFunction->
getReturnType()) !=
11050 ComputeQualTypeODRHash(SecondFunction->getReturnType())) {
11054 ODRDiagNote(SecondFunction->getReturnTypeSourceRange().getBegin(),
11055 SecondFunction->getReturnTypeSourceRange(), ReturnType)
11056 << SecondFunction->getReturnType();
11061 assert(FirstFunction->
param_size() == SecondFunction->param_size() &&
11062 "Merged functions with different number of parameters");
11064 auto ParamSize = FirstFunction->
param_size();
11065 bool ParameterMismatch =
false;
11066 for (
unsigned I = 0; I < ParamSize; ++I) {
11068 auto *SecondParam = SecondFunction->getParamDecl(I);
11070 assert(getContext().hasSameType(FirstParam->getType(),
11071 SecondParam->getType()) &&
11072 "Merged function has different parameter types.");
11074 if (FirstParam->getDeclName() != SecondParam->getDeclName()) {
11075 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11077 << I + 1 << FirstParam->getDeclName();
11078 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11080 << I + 1 << SecondParam->getDeclName();
11081 ParameterMismatch =
true;
11085 QualType FirstParamType = FirstParam->getType();
11086 QualType SecondParamType = SecondParam->getType();
11087 if (FirstParamType != SecondParamType &&
11088 ComputeQualTypeODRHash(FirstParamType) !=
11089 ComputeQualTypeODRHash(SecondParamType)) {
11092 ODRDiagError(FirstParam->getLocation(),
11093 FirstParam->getSourceRange(), ParameterType)
11094 << (I + 1) << FirstParamType <<
true 11095 << ParamDecayedType->getOriginalType();
11097 ODRDiagError(FirstParam->getLocation(),
11098 FirstParam->getSourceRange(), ParameterType)
11099 << (I + 1) << FirstParamType <<
false;
11104 ODRDiagNote(SecondParam->getLocation(),
11105 SecondParam->getSourceRange(), ParameterType)
11106 << (I + 1) << SecondParamType <<
true 11107 << ParamDecayedType->getOriginalType();
11109 ODRDiagNote(SecondParam->getLocation(),
11110 SecondParam->getSourceRange(), ParameterType)
11111 << (I + 1) << SecondParamType <<
false;
11113 ParameterMismatch =
true;
11117 const Expr *FirstInit = FirstParam->getInit();
11118 const Expr *SecondInit = SecondParam->getInit();
11119 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
11120 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11121 ParameterSingleDefaultArgument)
11122 << (I + 1) << (FirstInit ==
nullptr)
11124 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11125 ParameterSingleDefaultArgument)
11126 << (I + 1) << (SecondInit ==
nullptr)
11128 ParameterMismatch =
true;
11132 if (FirstInit && SecondInit &&
11133 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
11134 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11135 ParameterDifferentDefaultArgument)
11137 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11138 ParameterDifferentDefaultArgument)
11140 ParameterMismatch =
true;
11144 assert(ComputeSubDeclODRHash(FirstParam) ==
11145 ComputeSubDeclODRHash(SecondParam) &&
11146 "Undiagnosed parameter difference.");
11149 if (ParameterMismatch) {
11158 ODRDiagNote(SecondFunction->getLocation(),
11159 SecondFunction->getSourceRange(), FunctionBody);
11164 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
11168 for (
auto &Merge : EnumOdrMergeFailures) {
11169 enum ODREnumDifference {
11171 EnumTagKeywordMismatch,
11172 SingleSpecifiedType,
11173 DifferentSpecifiedTypes,
11174 DifferentNumberEnumConstants,
11176 EnumConstantSingleInitilizer,
11177 EnumConstantDifferentInitilizer,
11182 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
11185 EnumDecl *FirstEnum = Merge.first;
11186 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstEnum);
11190 auto PopulateHashes = [&ComputeSubDeclODRHash, FirstEnum](
11192 for (
auto *D :
Enum->decls()) {
11197 assert(isa<EnumConstantDecl>(D) &&
"Unexpected Decl kind");
11198 Hashes.emplace_back(cast<EnumConstantDecl>(D),
11199 ComputeSubDeclODRHash(D));
11202 DeclHashes FirstHashes;
11203 PopulateHashes(FirstHashes, FirstEnum);
11204 bool Diagnosed =
false;
11205 for (
auto &SecondEnum : Merge.second) {
11207 if (FirstEnum == SecondEnum)
11210 std::string SecondModule =
11211 getOwningModuleNameForDiagnostic(SecondEnum);
11213 auto ODRDiagError = [FirstEnum, &FirstModule,
11215 ODREnumDifference DiffType) {
11216 return Diag(Loc, diag::err_module_odr_violation_enum)
11217 << FirstEnum << FirstModule.empty() << FirstModule << Range
11222 ODREnumDifference DiffType) {
11223 return Diag(Loc, diag::note_module_odr_violation_enum)
11224 << SecondModule << Range << DiffType;
11227 if (FirstEnum->
isScoped() != SecondEnum->isScoped()) {
11231 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11233 << SecondEnum->isScoped();
11238 if (FirstEnum->
isScoped() && SecondEnum->isScoped()) {
11240 SecondEnum->isScopedUsingClassTag()) {
11242 EnumTagKeywordMismatch)
11244 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11245 EnumTagKeywordMismatch)
11246 << SecondEnum->isScopedUsingClassTag();
11257 SecondEnum->getIntegerTypeSourceInfo()
11258 ? SecondEnum->getIntegerTypeSourceInfo()->getType()
11260 if (FirstUnderlyingType.
isNull() != SecondUnderlyingType.
isNull()) {
11262 SingleSpecifiedType)
11263 << !FirstUnderlyingType.
isNull();
11264 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11265 SingleSpecifiedType)
11266 << !SecondUnderlyingType.
isNull();
11271 if (!FirstUnderlyingType.
isNull() && !SecondUnderlyingType.
isNull()) {
11272 if (ComputeQualTypeODRHash(FirstUnderlyingType) !=
11273 ComputeQualTypeODRHash(SecondUnderlyingType)) {
11275 DifferentSpecifiedTypes)
11276 << FirstUnderlyingType;
11277 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11278 DifferentSpecifiedTypes)
11279 << SecondUnderlyingType;
11285 DeclHashes SecondHashes;
11286 PopulateHashes(SecondHashes, SecondEnum);
11288 if (FirstHashes.size() != SecondHashes.size()) {
11290 DifferentNumberEnumConstants)
11291 << (
int)FirstHashes.size();
11292 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11293 DifferentNumberEnumConstants)
11294 << (
int)SecondHashes.size();
11299 for (
unsigned I = 0; I < FirstHashes.size(); ++I) {
11300 if (FirstHashes[I].second == SecondHashes[I].second)
11310 << I + 1 << FirstEnumConstant;
11313 << I + 1 << SecondEnumConstant;
11320 if (!FirstInit && !SecondInit)
11323 if (!FirstInit || !SecondInit) {
11326 EnumConstantSingleInitilizer)
11327 << I + 1 << FirstEnumConstant << (FirstInit !=
nullptr);
11330 EnumConstantSingleInitilizer)
11331 << I + 1 << SecondEnumConstant << (SecondInit !=
nullptr);
11336 if (ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
11339 EnumConstantDifferentInitilizer)
11340 << I + 1 << FirstEnumConstant;
11343 EnumConstantDifferentInitilizer)
11344 << I + 1 << SecondEnumConstant;
11352 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
11357 if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get())
11358 ReadTimer->startTimer();
11362 assert(NumCurrentElementsDeserializing &&
11363 "FinishedDeserializing not paired with StartedDeserializing");
11364 if (NumCurrentElementsDeserializing == 1) {
11367 finishPendingActions();
11369 --NumCurrentElementsDeserializing;
11371 if (NumCurrentElementsDeserializing == 0) {
11377 while (!PendingExceptionSpecUpdates.empty() ||
11378 !PendingDeducedTypeUpdates.empty()) {
11379 auto ESUpdates = std::move(PendingExceptionSpecUpdates);
11380 PendingExceptionSpecUpdates.clear();
11381 for (
auto Update : ESUpdates) {
11382 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
11385 if (
auto *Listener = getContext().getASTMutationListener())
11386 Listener->ResolvedExceptionSpec(cast<FunctionDecl>(
Update.second));
11387 for (
auto *Redecl :
Update.second->redecls())
11388 getContext().adjustExceptionSpec(cast<FunctionDecl>(Redecl), ESI);
11391 auto DTUpdates = std::move(PendingDeducedTypeUpdates);
11392 PendingDeducedTypeUpdates.clear();
11393 for (
auto Update : DTUpdates) {
11394 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
11396 getContext().adjustDeducedFunctionResultType(
Update.first,
11402 ReadTimer->stopTimer();
11404 diagnoseOdrViolations();
11409 PassInterestingDeclsToConsumer();
11416 auto It = PendingFakeLookupResults.find(II);
11417 if (It != PendingFakeLookupResults.end()) {
11418 for (
auto *ND : It->second)
11419 SemaObj->IdResolver.RemoveDecl(ND);
11423 It->second.clear();
11427 if (SemaObj->IdResolver.tryAddTopLevelDecl(D, Name) && SemaObj->TUScope) {
11428 SemaObj->TUScope->AddDecl(D);
11429 }
else if (SemaObj->TUScope) {
11433 if (std::find(SemaObj->IdResolver.begin(Name),
11434 SemaObj->IdResolver.end(), D) != SemaObj->IdResolver.end())
11435 SemaObj->TUScope->AddDecl(D);
11442 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
11443 StringRef isysroot,
bool DisableValidation,
11444 bool AllowASTWithCompilerErrors,
11445 bool AllowConfigurationMismatch,
bool ValidateSystemInputs,
11446 bool ValidateASTInputFilesContent,
bool UseGlobalIndex,
11447 std::unique_ptr<llvm::Timer> ReadTimer)
11448 : Listener(DisableValidation
11451 SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()),
11452 PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()), PP(PP),
11453 ContextObj(Context), ModuleMgr(PP.getFileManager(), ModuleCache,
11454 PCHContainerRdr, PP.getHeaderSearchInfo()),
11455 DummyIdResolver(PP), ReadTimer(
std::move(ReadTimer)), isysroot(isysroot),
11456 DisableValidation(DisableValidation),
11457 AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
11458 AllowConfigurationMismatch(AllowConfigurationMismatch),
11459 ValidateSystemInputs(ValidateSystemInputs),
11460 ValidateASTInputFilesContent(ValidateASTInputFilesContent),
11461 UseGlobalIndex(UseGlobalIndex), CurrSwitchCaseStmts(&SwitchCaseStmts) {
11464 for (
const auto &Ext : Extensions) {
11465 auto BlockName = Ext->getExtensionMetadata().BlockName;
11466 auto Known = ModuleFileExtensions.find(BlockName);
11467 if (Known != ModuleFileExtensions.end()) {
11468 Diags.
Report(diag::warn_duplicate_module_file_extension)
11473 ModuleFileExtensions.insert({BlockName, Ext});
11478 if (OwnsDeserializationListener)
11479 delete DeserializationListener;
11483 return SemaObj ? SemaObj->
IdResolver : DummyIdResolver;
11487 unsigned AbbrevID) {
11490 return Cursor.readRecord(AbbrevID, Record);
11506 : Record(Record), Context(Record.
getContext()) {}
11508 #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C); 11509 #include "clang/Basic/OpenMPKinds.def" 11523 switch (Record.readInt()) {
11530 case OMPC_num_threads:
11539 case OMPC_allocator:
11542 case OMPC_collapse:
11548 case OMPC_proc_bind:
11551 case OMPC_schedule:
11563 case OMPC_mergeable:
11590 case OMPC_unified_address:
11593 case OMPC_unified_shared_memory:
11596 case OMPC_reverse_offload:
11599 case OMPC_dynamic_allocators:
11602 case OMPC_atomic_default_mem_order:
11608 case OMPC_firstprivate:
11611 case OMPC_lastprivate:
11617 case OMPC_reduction:
11620 case OMPC_task_reduction:
11623 case OMPC_in_reduction:
11635 case OMPC_copyprivate:
11641 case OMPC_depend: {
11642 unsigned NumVars = Record.readInt();
11643 unsigned NumLoops = Record.readInt();
11652 Sizes.
NumVars = Record.readInt();
11659 case OMPC_num_teams:
11662 case OMPC_thread_limit:
11665 case OMPC_priority:
11668 case OMPC_grainsize:
11671 case OMPC_num_tasks:
11677 case OMPC_dist_schedule:
11680 case OMPC_defaultmap:
11685 Sizes.
NumVars = Record.readInt();
11694 Sizes.
NumVars = Record.readInt();
11701 case OMPC_use_device_ptr: {
11703 Sizes.
NumVars = Record.readInt();
11710 case OMPC_is_device_ptr: {
11712 Sizes.
NumVars = Record.readInt();
11719 case OMPC_allocate:
11722 case OMPC_nontemporal:
11726 assert(C &&
"Unknown OMPClause type");
11730 C->
setLocEnd(Record.readSourceLocation());
11741 VisitOMPClauseWithPreInit(C);
11745 void OMPClauseReader::VisitOMPIfClause(
OMPIfClause *
C) {
11746 VisitOMPClauseWithPreInit(C);
11747 C->setNameModifier(static_cast<OpenMPDirectiveKind>(Record.readInt()));
11748 C->setNameModifierLoc(Record.readSourceLocation());
11749 C->setColonLoc(Record.readSourceLocation());
11750 C->setCondition(Record.readSubExpr());
11755 VisitOMPClauseWithPreInit(C);
11756 C->setCondition(Record.readSubExpr());
11761 VisitOMPClauseWithPreInit(C);
11762 C->setNumThreads(Record.readSubExpr());
11767 C->setSafelen(Record.readSubExpr());
11772 C->setSimdlen(Record.readSubExpr());
11777 C->setAllocator(Record.readExpr());
11782 C->setNumForLoops(Record.readSubExpr());
11788 static_cast<OpenMPDefaultClauseKind>(Record.readInt()));
11790 C->setDefaultKindKwLoc(Record.readSourceLocation());
11794 C->setProcBindKind(static_cast<llvm::omp::ProcBindKind>(Record.readInt()));
11796 C->setProcBindKindKwLoc(Record.readSourceLocation());
11800 VisitOMPClauseWithPreInit(C);
11801 C->setScheduleKind(
11802 static_cast<OpenMPScheduleClauseKind>(Record.readInt()));
11803 C->setFirstScheduleModifier(
11804 static_cast<OpenMPScheduleClauseModifier>(Record.readInt()));
11805 C->setSecondScheduleModifier(
11806 static_cast<OpenMPScheduleClauseModifier>(Record.readInt()));
11807 C->setChunkSize(Record.readSubExpr());
11808 C->setLParenLoc(Record.readSourceLocation());
11809 C->setFirstScheduleModifierLoc(Record.readSourceLocation());
11810 C->setSecondScheduleModifierLoc(Record.readSourceLocation());
11811 C->setScheduleKindLoc(Record.readSourceLocation());
11812 C->setCommaLoc(Record.readSourceLocation());
11816 C->setNumForLoops(Record.readSubExpr());
11817 for (
unsigned I = 0, E = C->NumberOfLoops; I < E; ++I)
11819 for (
unsigned I = 0, E = C->NumberOfLoops; I < E; ++I)
11830 void OMPClauseReader::VisitOMPReadClause(
OMPReadClause *) {}
11842 void OMPClauseReader::VisitOMPSIMDClause(
OMPSIMDClause *) {}
11848 void OMPClauseReader::VisitOMPUnifiedSharedMemoryClause(
11857 void OMPClauseReader::VisitOMPAtomicDefaultMemOrderClause(
11859 C->setAtomicDefaultMemOrderKind(
11860 static_cast<OpenMPAtomicDefaultMemOrderClauseKind>(Record.readInt()));
11862 C->setAtomicDefaultMemOrderKindKwLoc(Record.readSourceLocation());
11869 Vars.reserve(NumVars);
11870 for (
unsigned i = 0; i != NumVars; ++i)
11871 Vars.push_back(Record.readSubExpr());
11874 for (
unsigned i = 0; i != NumVars; ++i)
11875 Vars.push_back(Record.readSubExpr());
11876 C->setPrivateCopies(Vars);
11880 VisitOMPClauseWithPreInit(C);
11884 Vars.reserve(NumVars);
11885 for (
unsigned i = 0; i != NumVars; ++i)
11886 Vars.push_back(Record.readSubExpr());
11889 for (
unsigned i = 0; i != NumVars; ++i)
11890 Vars.push_back(Record.readSubExpr());
11891 C->setPrivateCopies(Vars);
11893 for (
unsigned i = 0; i != NumVars; ++i)
11894 Vars.push_back(Record.readSubExpr());
11899 VisitOMPClauseWithPostUpdate(C);
11902 C->setKindLoc(Record.readSourceLocation());
11903 C->setColonLoc(Record.readSourceLocation());
11906 Vars.reserve(NumVars);
11907 for (
unsigned i = 0; i != NumVars; ++i)
11908 Vars.push_back(Record.readSubExpr());
11911 for (
unsigned i = 0; i != NumVars; ++i)
11912 Vars.push_back(Record.readSubExpr());
11915 for (
unsigned i = 0; i != NumVars; ++i)
11916 Vars.push_back(Record.readSubExpr());
11917 C->setSourceExprs(Vars);
11919 for (
unsigned i = 0; i != NumVars; ++i)
11920 Vars.push_back(Record.readSubExpr());
11921 C->setDestinationExprs(Vars);
11923 for (
unsigned i = 0; i != NumVars; ++i)
11924 Vars.push_back(Record.readSubExpr());
11925 C->setAssignmentOps(Vars);
11932 Vars.reserve(NumVars);
11933 for (
unsigned i = 0; i != NumVars; ++i)
11934 Vars.push_back(Record.readSubExpr());
11939 VisitOMPClauseWithPostUpdate(C);
11941 C->setColonLoc(Record.readSourceLocation());
11944 C->setQualifierLoc(NNSL);
11945 C->setNameInfo(DNI);
11949 Vars.reserve(NumVars);
11950 for (
unsigned i = 0; i != NumVars; ++i)
11951 Vars.push_back(Record.readSubExpr());
11954 for (
unsigned i = 0; i != NumVars; ++i)
11955 Vars.push_back(Record.readSubExpr());
11956 C->setPrivates(Vars);
11958 for (
unsigned i = 0; i != NumVars; ++i)
11959 Vars.push_back(Record.readSubExpr());
11960 C->setLHSExprs(Vars);
11962 for (
unsigned i = 0; i != NumVars; ++i)
11963 Vars.push_back(Record.readSubExpr());
11964 C->setRHSExprs(Vars);
11966 for (
unsigned i = 0; i != NumVars; ++i)
11967 Vars.push_back(Record.readSubExpr());
11968 C->setReductionOps(Vars);
11972 VisitOMPClauseWithPostUpdate(C);
11974 C->setColonLoc(Record.readSourceLocation());
11977 C->setQualifierLoc(NNSL);
11978 C->setNameInfo(DNI);
11982 Vars.reserve(NumVars);
11983 for (
unsigned I = 0; I != NumVars; ++I)
11984 Vars.push_back(Record.readSubExpr());
11987 for (
unsigned I = 0; I != NumVars; ++I)
11988 Vars.push_back(Record.readSubExpr());
11989 C->setPrivates(Vars);
11991 for (
unsigned I = 0; I != NumVars; ++I)
11992 Vars.push_back(Record.readSubExpr());
11993 C->setLHSExprs(Vars);
11995 for (
unsigned I = 0; I != NumVars; ++I)
11996 Vars.push_back(Record.readSubExpr());
11997 C->setRHSExprs(Vars);
11999 for (
unsigned I = 0; I != NumVars; ++I)
12000 Vars.push_back(Record.readSubExpr());
12001 C->setReductionOps(Vars);
12005 VisitOMPClauseWithPostUpdate(C);
12007 C->setColonLoc(Record.readSourceLocation());
12010 C->setQualifierLoc(NNSL);
12011 C->setNameInfo(DNI);
12015 Vars.reserve(NumVars);
12016 for (
unsigned I = 0; I != NumVars; ++I)
12017 Vars.push_back(Record.readSubExpr());
12020 for (
unsigned I = 0; I != NumVars; ++I)
12021 Vars.push_back(Record.readSubExpr());
12022 C->setPrivates(Vars);
12024 for (
unsigned I = 0; I != NumVars; ++I)
12025 Vars.push_back(Record.readSubExpr());
12026 C->setLHSExprs(Vars);
12028 for (
unsigned I = 0; I != NumVars; ++I)
12029 Vars.push_back(Record.readSubExpr());
12030 C->setRHSExprs(Vars);
12032 for (
unsigned I = 0; I != NumVars; ++I)
12033 Vars.push_back(Record.readSubExpr());
12034 C->setReductionOps(Vars);
12036 for (
unsigned I = 0; I != NumVars; ++I)
12037 Vars.push_back(Record.readSubExpr());
12038 C->setTaskgroupDescriptors(Vars);
12042 VisitOMPClauseWithPostUpdate(C);
12044 C->setColonLoc(Record.readSourceLocation());
12045 C->setModifier(static_cast<OpenMPLinearClauseKind>(Record.readInt()));
12046 C->setModifierLoc(Record.readSourceLocation());
12049 Vars.reserve(NumVars);
12050 for (
unsigned i = 0; i != NumVars; ++i)
12051 Vars.push_back(Record.readSubExpr());
12054 for (
unsigned i = 0; i != NumVars; ++i)
12055 Vars.push_back(Record.readSubExpr());
12056 C->setPrivates(Vars);
12058 for (
unsigned i = 0; i != NumVars; ++i)
12059 Vars.push_back(Record.readSubExpr());
12062 for (
unsigned i = 0; i != NumVars; ++i)
12063 Vars.push_back(Record.readSubExpr());
12064 C->setUpdates(Vars);
12066 for (
unsigned i = 0; i != NumVars; ++i)
12067 Vars.push_back(Record.readSubExpr());
12068 C->setFinals(Vars);
12069 C->setStep(Record.readSubExpr());
12070 C->setCalcStep(Record.readSubExpr());
12072 for (
unsigned I = 0; I != NumVars + 1; ++I)
12073 Vars.push_back(Record.readSubExpr());
12074 C->setUsedExprs(Vars);
12078 C->setLParenLoc(Record.readSourceLocation());
12080 unsigned NumVars = C->varlist_size();
12082 Vars.reserve(NumVars);
12083 for (
unsigned i = 0; i != NumVars; ++i)
12084 Vars.push_back(Record.readSubExpr());
12085 C->setVarRefs(Vars);
12086 C->setAlignment(Record.readSubExpr());
12090 C->setLParenLoc(Record.readSourceLocation());
12091 unsigned NumVars = C->varlist_size();
12093 Exprs.reserve(NumVars);
12094 for (
unsigned i = 0; i != NumVars; ++i)
12095 Exprs.push_back(Record.readSubExpr());
12096 C->setVarRefs(Exprs);
12098 for (
unsigned i = 0; i != NumVars; ++i)
12099 Exprs.push_back(Record.readSubExpr());
12100 C->setSourceExprs(Exprs);
12102 for (
unsigned i = 0; i != NumVars; ++i)
12103 Exprs.push_back(Record.readSubExpr());
12104 C->setDestinationExprs(Exprs);
12106 for (
unsigned i = 0; i != NumVars; ++i)
12107 Exprs.push_back(Record.readSubExpr());
12108 C->setAssignmentOps(Exprs);
12112 C->setLParenLoc(Record.readSourceLocation());
12113 unsigned NumVars = C->varlist_size();
12115 Exprs.reserve(NumVars);
12116 for (
unsigned i = 0; i != NumVars; ++i)
12117 Exprs.push_back(Record.readSubExpr());
12118 C->setVarRefs(Exprs);
12120 for (
unsigned i = 0; i != NumVars; ++i)
12121 Exprs.push_back(Record.readSubExpr());
12122 C->setSourceExprs(Exprs);
12124 for (
unsigned i = 0; i != NumVars; ++i)
12125 Exprs.push_back(Record.readSubExpr());
12126 C->setDestinationExprs(Exprs);
12128 for (
unsigned i = 0; i != NumVars; ++i)
12129 Exprs.push_back(Record.readSubExpr());
12130 C->setAssignmentOps(Exprs);
12134 C->setLParenLoc(Record.readSourceLocation());
12135 unsigned NumVars = C->varlist_size();
12137 Vars.reserve(NumVars);
12138 for (
unsigned i = 0; i != NumVars; ++i)
12139 Vars.push_back(Record.readSubExpr());
12140 C->setVarRefs(Vars);
12144 C->setLParenLoc(Record.readSourceLocation());
12145 C->setDependencyKind(
12146 static_cast<OpenMPDependClauseKind>(Record.readInt()));
12147 C->setDependencyLoc(Record.readSourceLocation());
12148 C->setColonLoc(Record.readSourceLocation());
12149 unsigned NumVars = C->varlist_size();
12151 Vars.reserve(NumVars);
12152 for (
unsigned I = 0; I != NumVars; ++I)
12153 Vars.push_back(Record.readSubExpr());
12154 C->setVarRefs(Vars);
12155 for (
unsigned I = 0, E = C->
getNumLoops(); I < E; ++I)
12160 VisitOMPClauseWithPreInit(C);
12161 C->setDevice(Record.readSubExpr());
12165 void OMPClauseReader::VisitOMPMapClause(
OMPMapClause *C) {
12166 C->setLParenLoc(Record.readSourceLocation());
12168 C->setMapTypeModifier(
12169 I, static_cast<OpenMPMapModifierKind>(Record.readInt()));
12170 C->setMapTypeModifierLoc(I, Record.readSourceLocation());
12175 static_cast<OpenMPMapClauseKind>(Record.readInt()));
12176 C->setMapLoc(Record.readSourceLocation());
12177 C->setColonLoc(Record.readSourceLocation());
12178 auto NumVars = C->varlist_size();
12184 Vars.reserve(NumVars);
12185 for (
unsigned i = 0; i != NumVars; ++i)
12186 Vars.push_back(Record.readExpr());
12187 C->setVarRefs(Vars);
12190 UDMappers.reserve(NumVars);
12191 for (
unsigned I = 0; I < NumVars; ++I)
12192 UDMappers.push_back(Record.readExpr());
12196 Decls.reserve(UniqueDecls);
12197 for (
unsigned i = 0; i < UniqueDecls; ++i)
12198 Decls.push_back(Record.readDeclAs<
ValueDecl>());
12202 ListsPerDecl.reserve(UniqueDecls);
12203 for (
unsigned i = 0; i < UniqueDecls; ++i)
12204 ListsPerDecl.push_back(Record.readInt());
12208 ListSizes.reserve(TotalLists);
12209 for (
unsigned i = 0; i < TotalLists; ++i)
12210 ListSizes.push_back(Record.readInt());
12214 Components.reserve(TotalComponents);
12215 for (
unsigned i = 0; i < TotalComponents; ++i) {
12216 Expr *AssociatedExpr = Record.readExpr();
12217 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
12219 AssociatedExpr, AssociatedDecl));
12226 C->setColonLoc(Record.readSourceLocation());
12227 C->setAllocator(Record.readSubExpr());
12230 Vars.reserve(NumVars);
12231 for (
unsigned i = 0; i != NumVars; ++i)
12232 Vars.push_back(Record.readSubExpr());
12237 VisitOMPClauseWithPreInit(C);
12238 C->setNumTeams(Record.readSubExpr());
12243 VisitOMPClauseWithPreInit(C);
12244 C->setThreadLimit(Record.readSubExpr());
12249 VisitOMPClauseWithPreInit(C);
12250 C->setPriority(Record.readSubExpr());
12255 VisitOMPClauseWithPreInit(C);
12256 C->setGrainsize(Record.readSubExpr());
12261 VisitOMPClauseWithPreInit(C);
12262 C->setNumTasks(Record.readSubExpr());
12266 void OMPClauseReader::VisitOMPHintClause(
OMPHintClause *C) {
12267 C->setHint(Record.readSubExpr());
12272 VisitOMPClauseWithPreInit(C);
12273 C->setDistScheduleKind(
12274 static_cast<OpenMPDistScheduleClauseKind>(Record.readInt()));
12275 C->setChunkSize(Record.readSubExpr());
12276 C->setLParenLoc(Record.readSourceLocation());
12277 C->setDistScheduleKindLoc(Record.readSourceLocation());
12278 C->setCommaLoc(Record.readSourceLocation());
12282 C->setDefaultmapKind(
12283 static_cast<OpenMPDefaultmapClauseKind>(Record.readInt()));
12284 C->setDefaultmapModifier(
12285 static_cast<OpenMPDefaultmapClauseModifier>(Record.readInt()));
12286 C->setLParenLoc(Record.readSourceLocation());
12287 C->setDefaultmapModifierLoc(Record.readSourceLocation());
12288 C->setDefaultmapKindLoc(Record.readSourceLocation());
12291 void OMPClauseReader::VisitOMPToClause(
OMPToClause *C) {
12292 C->setLParenLoc(Record.readSourceLocation());
12295 auto NumVars = C->varlist_size();
12301 Vars.reserve(NumVars);
12302 for (
unsigned i = 0; i != NumVars; ++i)
12303 Vars.push_back(Record.readSubExpr());
12304 C->setVarRefs(Vars);
12307 UDMappers.reserve(NumVars);
12308 for (
unsigned I = 0; I < NumVars; ++I)
12309 UDMappers.push_back(Record.readSubExpr());
12313 Decls.reserve(UniqueDecls);
12314 for (
unsigned i = 0; i < UniqueDecls; ++i)
12315 Decls.push_back(Record.readDeclAs<
ValueDecl>());
12319 ListsPerDecl.reserve(UniqueDecls);
12320 for (
unsigned i = 0; i < UniqueDecls; ++i)
12321 ListsPerDecl.push_back(Record.readInt());
12325 ListSizes.reserve(TotalLists);
12326 for (
unsigned i = 0; i < TotalLists; ++i)
12327 ListSizes.push_back(Record.readInt());
12331 Components.reserve(TotalComponents);
12332 for (
unsigned i = 0; i < TotalComponents; ++i) {
12333 Expr *AssociatedExpr = Record.readSubExpr();
12334 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
12336 AssociatedExpr, AssociatedDecl));
12341 void OMPClauseReader::VisitOMPFromClause(
OMPFromClause *C) {
12342 C->setLParenLoc(Record.readSourceLocation());
12345 auto NumVars = C->varlist_size();
12351 Vars.reserve(NumVars);
12352 for (
unsigned i = 0; i != NumVars; ++i)
12353 Vars.push_back(Record.readSubExpr());
12354 C->setVarRefs(Vars);
12357 UDMappers.reserve(NumVars);
12358 for (
unsigned I = 0; I < NumVars; ++I)
12359 UDMappers.push_back(Record.readSubExpr());
12363 Decls.reserve(UniqueDecls);
12364 for (
unsigned i = 0; i < UniqueDecls; ++i)
12365 Decls.push_back(Record.readDeclAs<
ValueDecl>());
12369 ListsPerDecl.reserve(UniqueDecls);
12370 for (
unsigned i = 0; i < UniqueDecls; ++i)
12371 ListsPerDecl.push_back(Record.readInt());
12375 ListSizes.reserve(TotalLists);
12376 for (
unsigned i = 0; i < TotalLists; ++i)
12377 ListSizes.push_back(Record.readInt());
12381 Components.reserve(TotalComponents);
12382 for (
unsigned i = 0; i < TotalComponents; ++i) {
12383 Expr *AssociatedExpr = Record.readSubExpr();
12384 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
12386 AssociatedExpr, AssociatedDecl));
12392 C->setLParenLoc(Record.readSourceLocation());
12393 auto NumVars = C->varlist_size();
12399 Vars.reserve(NumVars);
12400 for (
unsigned i = 0; i != NumVars; ++i)
12401 Vars.push_back(Record.readSubExpr());
12402 C->setVarRefs(Vars);
12404 for (
unsigned i = 0; i != NumVars; ++i)
12405 Vars.push_back(Record.readSubExpr());
12406 C->setPrivateCopies(Vars);
12408 for (
unsigned i = 0; i != NumVars; ++i)
12409 Vars.push_back(Record.readSubExpr());
12413 Decls.reserve(UniqueDecls);
12414 for (
unsigned i = 0; i < UniqueDecls; ++i)
12415 Decls.push_back(Record.readDeclAs<
ValueDecl>());
12419 ListsPerDecl.reserve(UniqueDecls);
12420 for (
unsigned i = 0; i < UniqueDecls; ++i)
12421 ListsPerDecl.push_back(Record.readInt());
12425 ListSizes.reserve(TotalLists);
12426 for (
unsigned i = 0; i < TotalLists; ++i)
12427 ListSizes.push_back(Record.readInt());
12431 Components.reserve(TotalComponents);
12432 for (
unsigned i = 0; i < TotalComponents; ++i) {
12433 Expr *AssociatedExpr = Record.readSubExpr();
12434 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
12436 AssociatedExpr, AssociatedDecl));
12442 C->setLParenLoc(Record.readSourceLocation());
12443 auto NumVars = C->varlist_size();
12449 Vars.reserve(NumVars);
12450 for (
unsigned i = 0; i != NumVars; ++i)
12451 Vars.push_back(Record.readSubExpr());
12452 C->setVarRefs(Vars);
12456 Decls.reserve(UniqueDecls);
12457 for (
unsigned i = 0; i < UniqueDecls; ++i)
12458 Decls.push_back(Record.readDeclAs<
ValueDecl>());
12462 ListsPerDecl.reserve(UniqueDecls);
12463 for (
unsigned i = 0; i < UniqueDecls; ++i)
12464 ListsPerDecl.push_back(Record.readInt());
12468 ListSizes.reserve(TotalLists);
12469 for (
unsigned i = 0; i < TotalLists; ++i)
12470 ListSizes.push_back(Record.readInt());
12474 Components.reserve(TotalComponents);
12475 for (
unsigned i = 0; i < TotalComponents; ++i) {
12476 Expr *AssociatedExpr = Record.readSubExpr();
12477 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
12479 AssociatedExpr, AssociatedDecl));
12485 C->setLParenLoc(Record.readSourceLocation());
12486 unsigned NumVars = C->varlist_size();
12488 Vars.reserve(NumVars);
12489 for (
unsigned i = 0; i != NumVars; ++i)
12490 Vars.push_back(Record.readSubExpr());
12491 C->setVarRefs(Vars);
12493 Vars.reserve(NumVars);
12494 for (
unsigned i = 0; i != NumVars; ++i)
12495 Vars.push_back(Record.readSubExpr());
Decl * GetExistingDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration.
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.
SourceLocation readSourceLocation()
Read a source location, advancing Idx.
SmallVector< UnresolvedExportDecl, 2 > UnresolvedExports
The set of export declarations that have yet to be resolved.
The 'unsigned _Accum' type.
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.
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)
This represents clause 'copyin' in the '#pragma omp ...' directives.
TypedefDecl * getCFConstantStringDecl() const
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
void readQualifierInfo(QualifierInfo &Info)
static hash_value_type ComputeHash(Selector Sel)
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system...
static bool checkTargetOptions(const TargetOptions &TargetOpts, const TargetOptions &ExistingTargetOpts, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true)
Compare the given set of target options against an existing set of target options.
A (possibly-)qualified type.
static LLVM_DUMP_METHOD void dumpModuleIDMap(StringRef Name, const ContinuousRangeMap< Key, ModuleFile *, InitialCapacity > &Map)
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines)
Receives the preprocessor options.
static void addMethodsToPool(Sema &S, ArrayRef< ObjCMethodDecl *> Methods, ObjCMethodList &List)
Add the given set of methods to the method list.
void * getAsOpaquePtr() const
CtorInitializerType
The different kinds of data that can occur in a CtorInitializer.
The '_Float16' type.
unsigned BasePreprocessedSkippedRangeID
Base ID for preprocessed skipped ranges local to this module.
void setChangedSinceDeserialization()
Note that this identifier has changed since it was loaded from an AST file.
void AddTokenToBody(const Token &Tok)
Add the specified token to the replacement text for the macro.
void setStarLoc(SourceLocation Loc)
NameKind
The kind of the name stored in this DeclarationName.
The macro directives history for a particular identifier.
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...
unsigned getNumArgs() const
SourceRange getBraceRange() const
CXXBaseSpecifier readCXXBaseSpecifier()
Read a C++ base specifier, advancing Idx.
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...
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)
bool DidReadTopLevelSubmodule
Whether the top-level module has been read from the AST file.
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...
void setConceptNameLoc(SourceLocation Loc)
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.
The fixed point semantics work similarly to llvm::fltSemantics.
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.
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.
const TemplateArgument & getArg(unsigned Idx) const
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 const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
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 readUnresolvedSet(LazyASTUnresolvedSet &Set)
Read a UnresolvedSet structure, advancing Idx.
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.
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.
The placeholder type for builtin functions.
Defines the clang::MacroInfo and clang::MacroDirective classes.
const FileEntry * getASTFile() const
The serialized AST file for this module, if one was created.
Defines types useful for describing an Objective-C runtime.
Specifies the submodules that are imported by this submodule.
std::string ModuleName
The name of the module.
void ReadTentativeDefinitions(SmallVectorImpl< VarDecl *> &TentativeDefs) override
Read the set of tentative definitions known to the external Sema source.
CanQualType ARCUnbridgedCastTy
A record that stores the set of declarations that are lexically stored within a given DeclContext...
This represents 'priority' clause in the '#pragma omp ...' directive.
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)
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 setLAngleLoc(SourceLocation Loc)
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.
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...
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
DeclarationNameInfo readDeclarationNameInfo()
TemplateParameterList * readTemplateParameterList()
Read a template parameter list, advancing Idx.
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 ...
Represents a C++ constructor within a class.
The 'float' type.
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
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.
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
static OMPUseDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
unsigned NumPreprocessedEntities
static llvm::Error doesntStartWithASTFileMagic(BitstreamCursor &Stream)
Whether Stream doesn't start with the AST/PCH file magic number 'CPCH'.
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.
Represents a variable declaration or definition.
This represents clause 'private' in the '#pragma omp ...' directives.
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.
const ASTTemplateArgumentListInfo * readASTTemplateArgumentListInfo()
Represents an empty template argument, e.g., one that has not been deduced.
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)
static APValue IndeterminateValue()
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
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.
This represents implicit clause 'flush' for the '#pragma omp flush' directive.
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.
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)
This represents 'allocator' clause in the '#pragma omp ...' directive.
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.
C ucontext_t typedef type.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
unsigned varlist_size() const
The width of the "fast" qualifier mask.
RecordDecl * getCFConstantStringTagDecl() const
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Selector getUnarySelector(IdentifierInfo *ID)
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.
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.
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.
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.
static OMPAllocateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
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.
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
This represents clause 'allocate' in the '#pragma omp ...' directives.
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 setPrivateRefs(ArrayRef< Expr *> VL)
Sets the list of references to private copies created in private clauses.
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)
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.
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)
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)
Defines some OpenMP-specific enums and functions.
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)
__DEVICE__ int max(int __a, int __b)
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...
DeclarationNameLoc readDeclarationNameLoc(DeclarationName Name)
Read a declaration name, advancing Idx.
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.
const llvm::MemoryBuffer * getRawBuffer() const
Get the underlying buffer, returning NULL if the buffer is not yet available.
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)
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 setExpansionLoc(SourceLocation Loc)
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...
HeaderSearch & getHeaderSearchInfo() const
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
unsigned getNumProtocols() const
const unsigned NumSpecialTypeIDs
The number of special type IDs.
A convenient class for passing around template argument information.
void setcudaConfigureCallDecl(FunctionDecl *FD)
CanQualType SatShortFractTy
Describes a blob that contains the data for a buffer entry.
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Record code for the language options table.
The 'unsigned short _Accum' type.
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
void AddFunctionDecl(const FunctionDecl *Function, bool SkipBody=false)
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.
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.
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)
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
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.
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)...
void setProtocolLoc(unsigned i, SourceLocation Loc)
ContinuousRangeMap< uint32_t, int, 2 > SLocRemap
Remapping table for source locations in this module.
unsigned NumVars
Number of expressions listed.
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.
CXXCtorInitializer ** readCXXCtorInitializers()
Read a CXXCtorInitializer array, advancing Idx.
void setLocalRangeBegin(SourceLocation L)
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
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.
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
void dump()
Dump information about the AST reader to standard error.
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.
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...
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 ...
The APFixedPoint class works similarly to APInt/APSInt in that it is a functional replacement for a s...
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.
This represents 'dynamic_allocators' clause in the '#pragma omp requires' directive.
void setLazyBody(uint64_t Offset)
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.
TypeSourceInfo * readTypeSourceInfo()
Reads a declarator info from the given record, advancing Idx.
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...
friend class OMPClauseReader
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)
APValue readAPValue()
Read an arbitrary constant value, advancing Idx.
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.
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.
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)
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.
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
Specifies some declarations with initializers that must be emitted to initialize the module...
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.
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.
Declaration of a template type parameter.
unsigned NumComponentLists
Number of component lists.
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.
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.
Record code for the table of offsets to entries in the preprocessing record.
void setFoundDecl(NamedDecl *D)
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.
Expected< unsigned > readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID)
Reads a record with id AbbrevID from Cursor, resetting the internal state.
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.
llvm::hash_code hash_value(const clang::SanitizerMask &Arg)
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.
void setTemplateKWLoc(SourceLocation Loc)
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.
OMPClause * readOMPClause()
Read an OpenMP clause, advancing Idx.
virtual ~ASTReaderListener()
The 'long double' type.
OMPClauseReader(ASTRecordReader &Record)
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.
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.
void setMapperIdInfo(DeclarationNameInfo MapperId)
Set the name of associated user-defined mapper.
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.
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 setNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
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.
SourceLocation getEnd() const
bool isInstanceMethod() const
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...
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.
static OMPIsDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
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
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*.
Record code for undefined but used functions and variables that need a definition in this TU...
SmallVector< ObjCMethodDecl *, 2 > Factory
This file defines OpenMP AST classes for clauses.
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...
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion=llvm::omp::OMPD_unknown)
Set pre-initialization statement for the clause.
Record code for the identifier table.
The '_Sat unsigned long _Accum' type.
static const llvm::fltSemantics & readAPFloatSemantics(ASTRecordReader &reader)
The AST file was missing.
This represents 'seq_cst' clause in the '#pragma omp atomic' directive.
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.
void setIsUsed(bool Val)
Set the value of the IsUsed flag.
The "auto" deduction type.
In-memory cache for modules.
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.
void setStarLoc(SourceLocation Loc)
std::vector< std::unique_ptr< ModuleFileExtensionReader > > ExtensionReaders
The list of extension readers that are attached to this module file.
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. ...
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.
Wrapper for source info for arrays.
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.
static llvm::Optional< Type::TypeClass > getTypeClassForCode(TypeCode code)
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.
This object has an indeterminate value (C++ [basic.indet]).
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.
static FixedPointSemantics ReadFixedPointSemantics(const SmallVectorImpl< uint64_t > &Record, unsigned &Idx)
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.
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
void setLAngleLoc(SourceLocation Loc)
ExtProtoInfo getExtProtoInfo() const
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.
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.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
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.
This structure contains all sizes needed for by an OMPMappableExprListClause.
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
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.
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.
Attr * readAttr()
Reads one attribute from the current stream position, advancing Idx.
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.
void setMapperQualifierLoc(NestedNameSpecifierLoc NNSL)
Set the nested name specifier of associated user-defined mapper.
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location...
static std::pair< GlobalModuleIndex *, llvm::Error > readIndex(llvm::StringRef Path)
Read a global index file for the given directory.
const uint32_t * IdentifierOffsets
Offsets into the identifier table data.
Class that performs lookup for a selector's entries in the global method pool stored in an AST file...
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
Record code for late parsed template functions.
The (signed) 'short' type.
Defines the clang::TargetOptions class.
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
const ParmVarDecl * getParamDecl(unsigned i) const
void setDefinitionEndLoc(SourceLocation EndLoc)
Set the location of the last token in the macro.
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.
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.
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
CanQualType SatLongFractTy
Defines the clang::Module class, which describes a module in the source code.
The AST block, which acts as a container around the full AST block.
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)
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.
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...
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.
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.
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.
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.
const FileEntry * bypassFileContentsOverride(const FileEntry &File)
Bypass the overridden contents of a file.
void setTypeArgsLAngleLoc(SourceLocation Loc)
uint64_t InputFilesValidationTimestamp
If non-zero, specifies the time when we last validated input files.
CanQualType UnsignedShortTy
const uint32_t * MacroOffsets
Offsets of macros in the preprocessor block.
The ObjC 'id' type.
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.
The input file content hash.
Describes a macro definition within the preprocessing record.
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.
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...
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
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 '('.
static std::string getName(const CallEvent &Call)
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.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
The '_Sat unsigned short _Accum' type.
static bool SkipCursorToBlock(BitstreamCursor &Cursor, unsigned BlockID)
Given a cursor at the start of an AST file, scan ahead and drop the cursor into the start of the give...
Reads an AST files chain containing the contents of a translation unit.
File is an explicitly-loaded module.
Represents a field injected from an anonymous union/struct into the parent scope. ...
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
QualType getUnderlyingType() const
CanQualType UnsignedLongLongTy
bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule) override
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
const Expr * getInit() const
AccessSpecifier getAccess() const
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.
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.
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.
static OMPNontemporalClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
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...
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 readTypeLoc(TypeLoc TL)
Reads the location information for a type.
void ClearSwitchCaseIDs()
unsigned NumUniqueDeclarations
Number of unique base declarations.
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.
uint64_t readInt()
Returns the current value in this record, and advances to the next value.
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.
TemplateArgumentLocInfo readTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind, advancing Idx...
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)
llvm::ErrorOr< const FileEntry * > getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
bool instanceHasMoreThanOneDecl() const
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
TemplateArgumentLoc readTemplateArgumentLoc()
Reads a TemplateArgumentLoc, advancing Idx.
C sigjmp_buf typedef type.
The 'unsigned _Fract' type.
std::vector< Conflict > Conflicts
The list of conflicts.
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
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 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
void setUDMapperRefs(ArrayRef< Expr *> DMDs)
Set the user-defined mappers that are in the trailing objects of the class.
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)
Wrapper for source info for record types.
std::string BaseDirectory
The base directory of the module.
The template argument is a type.
Wraps an ObjCPointerType with source location information.
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
unsigned getNumArgs() const
ContinuousRangeMap< uint32_t, int, 2 > TypeRemap
Remapping table for type IDs in this module.
Selector DecodeSelector(serialization::SelectorID Idx)
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
The template argument is actually a parameter pack.
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
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.
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)
Qualifiers readQualifiers()
Keeps track of options that affect how file operations are performed.
void setRAngleLoc(SourceLocation Loc)
llvm::OnDiskIterableChainedHashTable< ASTIdentifierLookupTrait > ASTIdentifierLookupTable
The on-disk hash table used to contain information about all of the identifiers in the program...
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)
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...
TranslationUnitDecl * getTranslationUnitDecl() const
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
The C++ 'char16_t' type.
Defines the clang::SourceLocation class and associated facilities.
void readTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, bool Canonicalize=false)
Read a template argument array, advancing Idx.
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.
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.
Represents a C++ struct/union/class.
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
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.
llvm::APFloat readAPFloat(const llvm::fltSemantics &Sem)
Read an integral value, advancing Idx.
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. ...
This represents 'num_tasks' clause in the '#pragma omp ...' directive.
The template argument is a template name that was provided for a template template parameter...
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
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 OMPMapClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars original expressions, NumUniqueDeclarations declar...
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)
There is no such object (it's outside its lifetime).
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.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
NestedNameSpecifierLoc readNestedNameSpecifierLoc()
Return a nested name specifier, advancing Idx.
The block containing the definitions of all of the types and decls used within the AST file...
The internal '__va_list_tag' struct, if any.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
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...
static OMPFromClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
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 '('.
The AST file is out-of-date relative to its input files, and needs to be regenerated.
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.
An object for streaming information from a record.
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
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...
ASTReader(Preprocessor &PP, InMemoryModuleCache &ModuleCache, 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 ValidateASTInputFilesContent=false, bool UseGlobalIndex=true, std::unique_ptr< llvm::Timer > ReadTimer={})
Load the AST file and validate its contents against the given Preprocessor.
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.
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
void StartTranslationUnit(ASTConsumer *Consumer) override
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
QualType getDefaultArgument() const
Retrieve the default argument, if any.
void setLocation(SourceLocation L)
bool getWarningsAsErrors() const
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)
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.
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.
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.
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(const FileEntry *Entry, bool isVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
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.
TypeLocReader(ASTRecordReader &Reader)
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.
unsigned NumComponents
Total number of expression components.
std::string Triple
The name of the target triple to compile for.
void setObjCOrBuiltinID(unsigned ID)
This represents clause 'nontemporal' in the '#pragma omp ...' directives.
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.
static OMPToClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
ExceptionSpecInfo ExceptionSpec
PredefinedDeclIDs
Predefined declaration IDs.
Declaration of a template function.
Record code for an update to the TU's lexically contained declarations.
The '_Sat _Fract' type.
void setElaboratedKeywordLoc(SourceLocation Loc)
Source range/offset of a preprocessed entity.
void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind) override
This is called for each AST file loaded.
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.
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.
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.
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.
CanQualType UnsignedIntTy
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