84 #include "llvm/ADT/APFloat.h" 85 #include "llvm/ADT/APInt.h" 86 #include "llvm/ADT/APSInt.h" 87 #include "llvm/ADT/ArrayRef.h" 88 #include "llvm/ADT/DenseMap.h" 89 #include "llvm/ADT/FoldingSet.h" 90 #include "llvm/ADT/Hashing.h" 91 #include "llvm/ADT/IntrusiveRefCntPtr.h" 92 #include "llvm/ADT/None.h" 93 #include "llvm/ADT/Optional.h" 94 #include "llvm/ADT/STLExtras.h" 95 #include "llvm/ADT/ScopeExit.h" 96 #include "llvm/ADT/SmallPtrSet.h" 97 #include "llvm/ADT/SmallString.h" 98 #include "llvm/ADT/SmallVector.h" 99 #include "llvm/ADT/StringExtras.h" 100 #include "llvm/ADT/StringMap.h" 101 #include "llvm/ADT/StringRef.h" 102 #include "llvm/ADT/Triple.h" 103 #include "llvm/ADT/iterator_range.h" 104 #include "llvm/Bitstream/BitstreamReader.h" 105 #include "llvm/Support/Casting.h" 106 #include "llvm/Support/Compiler.h" 107 #include "llvm/Support/Compression.h" 108 #include "llvm/Support/DJB.h" 109 #include "llvm/Support/Endian.h" 110 #include "llvm/Support/Error.h" 111 #include "llvm/Support/ErrorHandling.h" 112 #include "llvm/Support/FileSystem.h" 113 #include "llvm/Support/MemoryBuffer.h" 114 #include "llvm/Support/Path.h" 115 #include "llvm/Support/SaveAndRestore.h" 116 #include "llvm/Support/Timer.h" 117 #include "llvm/Support/VersionTuple.h" 118 #include "llvm/Support/raw_ostream.h" 130 #include <system_error> 135 using namespace clang;
138 using llvm::BitstreamCursor;
146 return First->ReadFullVersionInformation(FullVersion) ||
147 Second->ReadFullVersionInformation(FullVersion);
151 First->ReadModuleName(ModuleName);
152 Second->ReadModuleName(ModuleName);
156 First->ReadModuleMapFile(ModuleMapPath);
157 Second->ReadModuleMapFile(ModuleMapPath);
163 bool AllowCompatibleDifferences) {
164 return First->ReadLanguageOptions(LangOpts, Complain,
165 AllowCompatibleDifferences) ||
166 Second->ReadLanguageOptions(LangOpts, Complain,
167 AllowCompatibleDifferences);
172 bool AllowCompatibleDifferences) {
173 return First->ReadTargetOptions(TargetOpts, Complain,
174 AllowCompatibleDifferences) ||
175 Second->ReadTargetOptions(TargetOpts, Complain,
176 AllowCompatibleDifferences);
181 return First->ReadDiagnosticOptions(DiagOpts, Complain) ||
182 Second->ReadDiagnosticOptions(DiagOpts, Complain);
188 return First->ReadFileSystemOptions(FSOpts, Complain) ||
189 Second->ReadFileSystemOptions(FSOpts, Complain);
195 return First->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
197 Second->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
203 std::string &SuggestedPredefines) {
204 return First->ReadPreprocessorOptions(PPOpts, Complain,
205 SuggestedPredefines) ||
206 Second->ReadPreprocessorOptions(PPOpts, Complain, SuggestedPredefines);
211 First->ReadCounter(M, Value);
212 Second->ReadCounter(M, Value);
216 return First->needsInputFileVisitation() ||
217 Second->needsInputFileVisitation();
221 return First->needsSystemInputFileVisitation() ||
222 Second->needsSystemInputFileVisitation();
227 First->visitModuleFile(Filename, Kind);
228 Second->visitModuleFile(Filename, Kind);
234 bool isExplicitModule) {
235 bool Continue =
false;
236 if (
First->needsInputFileVisitation() &&
237 (!isSystem ||
First->needsSystemInputFileVisitation()))
238 Continue |=
First->visitInputFile(Filename, isSystem, isOverridden,
240 if (Second->needsInputFileVisitation() &&
241 (!isSystem || Second->needsSystemInputFileVisitation()))
242 Continue |= Second->visitInputFile(Filename, isSystem, isOverridden,
249 First->readModuleFileExtension(Metadata);
250 Second->readModuleFileExtension(Metadata);
270 bool AllowCompatibleDifferences =
true) {
271 #define LANGOPT(Name, Bits, Default, Description) \ 272 if (ExistingLangOpts.Name != LangOpts.Name) { \ 274 Diags->Report(diag::err_pch_langopt_mismatch) \ 275 << Description << LangOpts.Name << ExistingLangOpts.Name; \ 279 #define VALUE_LANGOPT(Name, Bits, Default, Description) \ 280 if (ExistingLangOpts.Name != LangOpts.Name) { \ 282 Diags->Report(diag::err_pch_langopt_value_mismatch) \ 287 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 288 if (ExistingLangOpts.get##Name() != LangOpts.get##Name()) { \ 290 Diags->Report(diag::err_pch_langopt_value_mismatch) \ 295 #define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \ 296 if (!AllowCompatibleDifferences) \ 297 LANGOPT(Name, Bits, Default, Description) 299 #define COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) \ 300 if (!AllowCompatibleDifferences) \ 301 ENUM_LANGOPT(Name, Bits, Default, Description) 303 #define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \ 304 if (!AllowCompatibleDifferences) \ 305 VALUE_LANGOPT(Name, Bits, Default, Description) 307 #define BENIGN_LANGOPT(Name, Bits, Default, Description) 308 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) 309 #define BENIGN_VALUE_LANGOPT(Name, Type, Bits, Default, Description) 310 #include "clang/Basic/LangOptions.def" 314 Diags->
Report(diag::err_pch_langopt_value_mismatch) <<
"module features";
320 Diags->
Report(diag::err_pch_langopt_value_mismatch)
321 <<
"target Objective-C runtime";
328 Diags->
Report(diag::err_pch_langopt_value_mismatch)
329 <<
"block command names";
337 if (!AllowCompatibleDifferences) {
341 ExistingSanitizers.
clear(ModularSanitizers);
342 ImportedSanitizers.
clear(ModularSanitizers);
343 if (ExistingSanitizers.
Mask != ImportedSanitizers.
Mask) {
344 const std::string Flag =
"-fsanitize=";
346 #define SANITIZER(NAME, ID) \ 348 bool InExistingModule = ExistingSanitizers.has(SanitizerKind::ID); \ 349 bool InImportedModule = ImportedSanitizers.has(SanitizerKind::ID); \ 350 if (InExistingModule != InImportedModule) \ 351 Diags->Report(diag::err_pch_targetopt_feature_mismatch) \ 352 << InExistingModule << (Flag + NAME); \ 354 #include "clang/Basic/Sanitizers.def" 372 bool AllowCompatibleDifferences =
true) {
373 #define CHECK_TARGET_OPT(Field, Name) \ 374 if (TargetOpts.Field != ExistingTargetOpts.Field) { \ 376 Diags->Report(diag::err_pch_targetopt_mismatch) \ 377 << Name << TargetOpts.Field << ExistingTargetOpts.Field; \ 388 if (!AllowCompatibleDifferences)
391 #undef CHECK_TARGET_OPT 399 llvm::sort(ExistingFeatures);
400 llvm::sort(ReadFeatures);
406 ExistingFeatures.begin(), ExistingFeatures.end(), ReadFeatures.begin(),
407 ReadFeatures.end(), std::back_inserter(UnmatchedExistingFeatures));
408 std::set_difference(ReadFeatures.begin(), ReadFeatures.end(),
409 ExistingFeatures.begin(), ExistingFeatures.end(),
410 std::back_inserter(UnmatchedReadFeatures));
414 if (AllowCompatibleDifferences && UnmatchedReadFeatures.empty())
418 for (StringRef Feature : UnmatchedReadFeatures)
419 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
421 for (StringRef Feature : UnmatchedExistingFeatures)
422 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
426 return !UnmatchedReadFeatures.empty() || !UnmatchedExistingFeatures.empty();
432 bool AllowCompatibleDifferences) {
433 const LangOptions &ExistingLangOpts = PP.getLangOpts();
435 Complain ? &Reader.Diags :
nullptr,
436 AllowCompatibleDifferences);
441 bool AllowCompatibleDifferences) {
442 const TargetOptions &ExistingTargetOpts = PP.getTargetInfo().getTargetOpts();
444 Complain ? &Reader.Diags :
nullptr,
445 AllowCompatibleDifferences);
450 using MacroDefinitionsMap =
451 llvm::StringMap<std::pair<StringRef,
bool >>;
452 using DeclsMap = llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8>>;
467 for (
auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) {
476 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror=" +
495 bool IsSystem,
bool Complain) {
503 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Wsystem-headers";
510 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror";
517 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Weverything -Werror";
524 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-pedantic-errors";
548 assert(!ModuleName.empty() &&
"diagnostic options read before module name");
551 assert(M &&
"missing module");
566 assert(ModuleMgr.
size() >= 1 &&
"what ASTFile is this then");
582 MacroDefinitionsMap &Macros,
584 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
585 StringRef Macro = PPOpts.
Macros[I].first;
586 bool IsUndef = PPOpts.
Macros[I].second;
588 std::pair<StringRef, StringRef> MacroPair = Macro.split(
'=');
589 StringRef MacroName = MacroPair.first;
590 StringRef MacroBody = MacroPair.second;
594 if (MacroNames && !Macros.count(MacroName))
595 MacroNames->push_back(MacroName);
597 Macros[MacroName] = std::make_pair(
"",
true);
602 if (MacroName.size() == Macro.size())
606 StringRef::size_type
End = MacroBody.find_first_of(
"\n\r");
607 MacroBody = MacroBody.substr(0, End);
610 if (MacroNames && !Macros.count(MacroName))
611 MacroNames->push_back(MacroName);
612 Macros[MacroName] = std::make_pair(MacroBody,
false);
627 std::string &SuggestedPredefines,
629 bool Validate =
true) {
631 MacroDefinitionsMap ASTFileMacros;
633 MacroDefinitionsMap ExistingMacros;
637 for (
unsigned I = 0, N = ExistingMacroNames.size(); I != N; ++I) {
639 StringRef MacroName = ExistingMacroNames[I];
640 std::pair<StringRef, bool> Existing = ExistingMacros[MacroName];
643 llvm::StringMap<std::pair<StringRef,
bool >>::iterator Known =
644 ASTFileMacros.find(MacroName);
645 if (!Validate || Known == ASTFileMacros.end()) {
650 if (Existing.second) {
651 SuggestedPredefines +=
"#undef ";
652 SuggestedPredefines += MacroName.str();
653 SuggestedPredefines +=
'\n';
655 SuggestedPredefines +=
"#define ";
656 SuggestedPredefines += MacroName.str();
657 SuggestedPredefines +=
' ';
658 SuggestedPredefines += Existing.first.str();
659 SuggestedPredefines +=
'\n';
666 if (Existing.second != Known->second.second) {
668 Diags->
Report(diag::err_pch_macro_def_undef)
669 << MacroName << Known->second.second;
676 if (Existing.second || Existing.first == Known->second.first)
681 Diags->
Report(diag::err_pch_macro_def_conflict)
682 << MacroName << Known->second.first << Existing.first;
696 if (LangOpts.Modules &&
705 for (
unsigned I = 0, N = ExistingPPOpts.
Includes.size(); I != N; ++I) {
706 StringRef File = ExistingPPOpts.
Includes[I];
712 SuggestedPredefines +=
"#include \"";
713 SuggestedPredefines += File;
714 SuggestedPredefines +=
"\"\n";
725 SuggestedPredefines +=
"#include \"";
726 SuggestedPredefines += File;
727 SuggestedPredefines +=
"\"\n";
730 for (
unsigned I = 0, N = ExistingPPOpts.
MacroIncludes.size(); I != N; ++I) {
737 SuggestedPredefines +=
"#__include_macros \"";
738 SuggestedPredefines += File;
739 SuggestedPredefines +=
"\"\n##\n";
747 std::string &SuggestedPredefines) {
751 Complain? &Reader.Diags :
nullptr,
760 std::string &SuggestedPredefines) {
762 PP.getPreprocessorOpts(),
775 StringRef SpecificModuleCachePath,
776 StringRef ExistingModuleCachePath,
779 if (LangOpts.Modules) {
780 if (SpecificModuleCachePath != ExistingModuleCachePath) {
782 Diags->
Report(diag::err_pch_modulecache_mismatch)
783 << SpecificModuleCachePath << ExistingModuleCachePath;
792 StringRef SpecificModuleCachePath,
795 PP.getHeaderSearchInfo().getModuleCachePath(),
796 Complain ? &Reader.Diags :
nullptr,
801 PP.setCounterValue(Value);
809 bool TakeOwnership) {
810 DeserializationListener = Listener;
811 OwnsDeserializationListener = TakeOwnership;
818 std::pair<unsigned, unsigned>
820 using namespace llvm::support;
822 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(
d);
823 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(
d);
824 return std::make_pair(KeyLen, DataLen);
829 using namespace llvm::support;
832 unsigned N = endian::readNext<uint16_t, little, unaligned>(
d);
834 F, endian::readNext<uint32_t, little, unaligned>(d));
841 Args.push_back(FirstII);
842 for (
unsigned I = 1; I != N; ++I)
843 Args.push_back(Reader.getLocalIdentifier(
844 F, endian::readNext<uint32_t, little, unaligned>(d)));
852 using namespace llvm::support;
856 Result.
ID = Reader.getGlobalSelectorID(
857 F, endian::readNext<uint32_t, little, unaligned>(d));
858 unsigned FullInstanceBits = endian::readNext<uint16_t, little, unaligned>(
d);
859 unsigned FullFactoryBits = endian::readNext<uint16_t, little, unaligned>(
d);
864 unsigned NumInstanceMethods = FullInstanceBits >> 3;
865 unsigned NumFactoryMethods = FullFactoryBits >> 3;
868 for (
unsigned I = 0; I != NumInstanceMethods; ++I) {
870 F, endian::readNext<uint32_t, little, unaligned>(d)))
875 for (
unsigned I = 0; I != NumFactoryMethods; ++I) {
877 F, endian::readNext<uint32_t, little, unaligned>(d)))
878 Result.
Factory.push_back(Method);
885 return llvm::djbHash(a);
888 std::pair<unsigned, unsigned>
890 using namespace llvm::support;
892 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(
d);
893 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(
d);
894 return std::make_pair(KeyLen, DataLen);
899 assert(n >= 2 && d[n-1] ==
'\0');
900 return StringRef((
const char*) d, n-1);
915 bool Value = Bits & 0x1;
921 using namespace llvm::support;
923 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(
d);
924 return Reader.getGlobalIdentifierID(F, RawID >> 1);
937 const unsigned char*
d,
939 using namespace llvm::support;
941 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(
d);
942 bool IsInteresting = RawID & 0x01;
950 II = &Reader.getIdentifierTable().getOwn(k);
954 Reader.markIdentifierUpToDate(II);
956 IdentID ID = Reader.getGlobalIdentifierID(F, RawID);
957 if (!IsInteresting) {
960 Reader.SetIdentifierInfo(ID, II);
964 unsigned ObjCOrBuiltinID = endian::readNext<uint16_t, little, unaligned>(
d);
965 unsigned Bits = endian::readNext<uint16_t, little, unaligned>(
d);
966 bool CPlusPlusOperatorKeyword =
readBit(Bits);
967 bool HasRevertedTokenIDToIdentifier =
readBit(Bits);
968 bool HasRevertedBuiltin =
readBit(Bits);
970 bool ExtensionToken =
readBit(Bits);
971 bool HadMacroDefinition =
readBit(Bits);
973 assert(Bits == 0 &&
"Extra bits in the identifier?");
978 if (HasRevertedTokenIDToIdentifier && II->
getTokenID() != tok::identifier)
986 "Incorrect ObjC keyword or builtin ID");
989 "Incorrect extension token flag");
990 (void)ExtensionToken;
994 "Incorrect C++ operator keyword flag");
995 (void)CPlusPlusOperatorKeyword;
999 if (HadMacroDefinition) {
1000 uint32_t MacroDirectivesOffset =
1001 endian::readNext<uint32_t, little, unaligned>(
d);
1004 Reader.addPendingMacro(II, &F, MacroDirectivesOffset);
1007 Reader.SetIdentifierInfo(ID, II);
1013 for (; DataLen > 0; DataLen -= 4)
1014 DeclIDs.push_back(Reader.getGlobalDeclID(
1015 F, endian::readNext<uint32_t, little, unaligned>(d)));
1016 Reader.SetGloballyVisibleDecls(II, DeclIDs);
1023 :
Kind(Name.getNameKind()) {
1053 llvm::FoldingSetNodeID
ID;
1054 ID.AddInteger(
Kind);
1077 return ID.ComputeHash();
1081 ASTDeclContextNameLookupTrait::ReadFileRef(
const unsigned char *&
d) {
1082 using namespace llvm::support;
1084 uint32_t ModuleFileID = endian::readNext<uint32_t, little, unaligned>(
d);
1085 return Reader.getLocalModuleFile(F, ModuleFileID);
1088 std::pair<unsigned, unsigned>
1089 ASTDeclContextNameLookupTrait::ReadKeyDataLength(
const unsigned char *&
d) {
1090 using namespace llvm::support;
1092 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(
d);
1093 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(
d);
1094 return std::make_pair(KeyLen, DataLen);
1098 ASTDeclContextNameLookupTrait::ReadKey(
const unsigned char *
d,
unsigned) {
1099 using namespace llvm::support;
1107 Data = (uint64_t)Reader.getLocalIdentifier(
1108 F, endian::readNext<uint32_t, little, unaligned>(d));
1114 (uint64_t)Reader.getLocalSelector(
1115 F, endian::readNext<uint32_t, little, unaligned>(
1116 d)).getAsOpaquePtr();
1133 const unsigned char *
d,
1136 using namespace llvm::support;
1138 for (
unsigned NumDecls = DataLen / 4; NumDecls; --NumDecls) {
1139 uint32_t LocalID = endian::readNext<uint32_t, little, unaligned>(
d);
1140 Val.
insert(Reader.getGlobalDeclID(F, LocalID));
1144 bool ASTReader::ReadLexicalDeclContextStorage(
ModuleFile &M,
1152 Error(std::move(Err));
1160 Error(MaybeCode.takeError());
1163 unsigned Code = MaybeCode.get();
1166 if (!MaybeRecCode) {
1167 Error(MaybeRecCode.takeError());
1170 unsigned RecCode = MaybeRecCode.get();
1172 Error(
"Expected lexical block");
1176 assert(!isa<TranslationUnitDecl>(DC) &&
1177 "expected a TU_UPDATE_LEXICAL record for TU");
1182 auto &Lex = LexicalDecls[DC];
1184 Lex = std::make_pair(
1185 &M, llvm::makeArrayRef(
1186 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
1194 bool ASTReader::ReadVisibleDeclContextStorage(
ModuleFile &M,
1202 Error(std::move(Err));
1210 Error(MaybeCode.takeError());
1213 unsigned Code = MaybeCode.get();
1216 if (!MaybeRecCode) {
1217 Error(MaybeRecCode.takeError());
1220 unsigned RecCode = MaybeRecCode.get();
1222 Error(
"Expected visible lookup table block");
1228 auto *Data = (
const unsigned char*)Blob.data();
1229 PendingVisibleUpdates[
ID].push_back(PendingVisibleUpdate{&M, Data});
1233 void ASTReader::Error(StringRef Msg)
const {
1234 Error(diag::err_fe_pch_malformed, Msg);
1235 if (PP.getLangOpts().Modules && !Diags.isDiagnosticInFlight() &&
1236 !PP.getHeaderSearchInfo().getModuleCachePath().empty()) {
1237 Diag(diag::note_module_cache_path)
1238 << PP.getHeaderSearchInfo().getModuleCachePath();
1242 void ASTReader::Error(
unsigned DiagID,
1243 StringRef Arg1, StringRef Arg2)
const {
1244 if (Diags.isDiagnosticInFlight())
1245 Diags.SetDelayedDiagnostic(DiagID, Arg1, Arg2);
1247 Diag(DiagID) << Arg1 << Arg2;
1260 bool ASTReader::ParseLineTable(
ModuleFile &F,
1261 const RecordData &Record) {
1266 std::map<int, int> FileIDs;
1268 for (
unsigned I = 0; Record[Idx]; ++I) {
1270 auto Filename = ReadPath(F, Record, Idx);
1276 std::vector<LineEntry> Entries;
1277 while (Idx < Record.size()) {
1278 int FID = Record[Idx++];
1279 assert(FID >= 0 &&
"Serialized line entries for non-local file.");
1284 unsigned NumEntries = Record[Idx++];
1285 assert(NumEntries &&
"no line entries for file ID");
1287 Entries.reserve(NumEntries);
1288 for (
unsigned I = 0; I != NumEntries; ++I) {
1289 unsigned FileOffset = Record[Idx++];
1290 unsigned LineNo = Record[Idx++];
1291 int FilenameID = FileIDs[Record[Idx++]];
1294 unsigned IncludeOffset = Record[Idx++];
1296 FileKind, IncludeOffset));
1298 LineTable.
AddEntry(FileID::get(FID), Entries);
1305 bool ASTReader::ReadSourceManagerBlock(
ModuleFile &F) {
1306 using namespace SrcMgr;
1314 SLocEntryCursor = F.
Stream;
1318 Error(std::move(Err));
1325 Error(std::move(Err));
1332 SLocEntryCursor.advanceSkippingSubblocks();
1334 Error(MaybeE.takeError());
1337 llvm::BitstreamEntry E = MaybeE.get();
1340 case llvm::BitstreamEntry::SubBlock:
1342 Error(
"malformed block record in AST file");
1344 case llvm::BitstreamEntry::EndBlock:
1346 case llvm::BitstreamEntry::Record:
1355 SLocEntryCursor.readRecord(E.ID, Record, &Blob);
1357 Error(MaybeRecord.takeError());
1360 switch (MaybeRecord.get()) {
1379 const std::string &OriginalDir,
1380 const std::string &CurrDir) {
1381 assert(OriginalDir != CurrDir &&
1382 "No point trying to resolve the file if the PCH dir didn't change");
1387 fs::make_absolute(filePath);
1388 assert(path::is_absolute(OriginalDir));
1391 path::const_iterator fileDirI = path::begin(path::parent_path(filePath)),
1392 fileDirE = path::end(path::parent_path(filePath));
1393 path::const_iterator origDirI = path::begin(OriginalDir),
1394 origDirE = path::end(OriginalDir);
1396 while (fileDirI != fileDirE && origDirI != origDirE &&
1397 *fileDirI == *origDirI) {
1401 for (; origDirI != origDirE; ++origDirI)
1402 path::append(currPCHPath,
"..");
1403 path::append(currPCHPath, fileDirI, fileDirE);
1404 path::append(currPCHPath, path::filename(Filename));
1405 return currPCHPath.str();
1412 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1413 Error(
"source location entry ID out-of-range for AST file");
1419 auto ReadBuffer = [
this](
1420 BitstreamCursor &SLocEntryCursor,
1421 StringRef Name) -> std::unique_ptr<llvm::MemoryBuffer> {
1426 Error(MaybeCode.takeError());
1429 unsigned Code = MaybeCode.get();
1432 SLocEntryCursor.readRecord(Code, Record, &Blob);
1433 if (!MaybeRecCode) {
1434 Error(MaybeRecCode.takeError());
1437 unsigned RecCode = MaybeRecCode.get();
1440 if (!llvm::zlib::isAvailable()) {
1441 Error(
"zlib is not available");
1446 llvm::zlib::uncompress(Blob, Uncompressed, Record[0])) {
1447 Error(
"could not decompress embedded file contents: " +
1451 return llvm::MemoryBuffer::getMemBufferCopy(Uncompressed, Name);
1453 return llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name,
true);
1455 Error(
"AST record has invalid code");
1460 ModuleFile *F = GlobalSLocEntryMap.find(-ID)->second;
1463 Error(std::move(Err));
1470 ++NumSLocEntriesRead;
1473 Error(MaybeEntry.takeError());
1476 llvm::BitstreamEntry Entry = MaybeEntry.get();
1478 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1479 Error(
"incorrectly-formatted source location entry in AST file");
1486 SLocEntryCursor.readRecord(Entry.ID, Record, &Blob);
1488 Error(MaybeSLOC.takeError());
1491 switch (MaybeSLOC.get()) {
1493 Error(
"incorrectly-formatted source location entry in AST file");
1499 unsigned InputID = Record[4];
1500 InputFile IF = getInputFile(*F, InputID);
1513 IncludeLoc = getImportLocation(F);
1517 FileID FID = SourceMgr.createFileID(File, IncludeLoc, FileCharacter,
1518 ID, BaseOffset + Record[0]);
1521 FileInfo.NumCreatedFIDs = Record[5];
1526 unsigned NumFileDecls = Record[7];
1527 if (NumFileDecls && ContextObj) {
1528 assert(F->
FileSortedDecls &&
"FILE_SORTED_DECLS not encountered yet ?");
1529 FileDeclIDs[FID] = FileDeclsInfo(F, llvm::makeArrayRef(FirstDecl,
1534 = SourceMgr.getOrCreateContentCache(File,
isSystem(FileCharacter));
1538 auto Buffer = ReadBuffer(SLocEntryCursor, File->
getName());
1541 SourceMgr.overrideFileContents(File, std::move(Buffer));
1548 const char *Name = Blob.data();
1549 unsigned Offset = Record[0];
1554 IncludeLoc = getImportLocation(F);
1557 auto Buffer = ReadBuffer(SLocEntryCursor, Name);
1560 SourceMgr.createFileID(std::move(Buffer), FileCharacter, ID,
1561 BaseOffset + Offset, IncludeLoc);
1567 SourceMgr.createExpansionLoc(SpellingLoc,
1568 ReadSourceLocation(*F, Record[2]),
1569 ReadSourceLocation(*F, Record[3]),
1573 BaseOffset + Record[0]);
1585 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1586 Error(
"source location entry ID out-of-range for AST file");
1591 ModuleFile *M = GlobalSLocEntryMap.find(-ID)->second;
1609 assert(SourceMgr.getMainFileID().isValid() &&
"missing main file");
1610 return SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
1619 if (
llvm::Error Err = Cursor.EnterSubBlock(BlockID)) {
1621 consumeError(std::move(Err));
1626 uint64_t
Offset = Cursor.GetCurrentBitNo();
1630 consumeError(MaybeCode.takeError());
1633 unsigned Code = MaybeCode.get();
1636 if (Code != llvm::bitc::DEFINE_ABBREV) {
1639 consumeError(std::move(Err));
1644 if (
llvm::Error Err = Cursor.ReadAbbrevRecord()) {
1646 consumeError(std::move(Err));
1656 Tok.
setLocation(ReadSourceLocation(F, Record, Idx));
1674 consumeError(std::move(Err));
1685 unsigned Flags = BitstreamCursor::AF_DontPopBlockAtEnd;
1687 Stream.advanceSkippingSubblocks(Flags);
1689 Error(MaybeEntry.takeError());
1692 llvm::BitstreamEntry Entry = MaybeEntry.get();
1694 switch (Entry.Kind) {
1695 case llvm::BitstreamEntry::SubBlock:
1697 Error(
"malformed block record in AST file");
1699 case llvm::BitstreamEntry::EndBlock:
1701 case llvm::BitstreamEntry::Record:
1712 Error(MaybeRecType.takeError());
1728 unsigned NextIndex = 1;
1730 MacroInfo *MI = PP.AllocateMacroInfo(Loc);
1737 bool isC99VarArgs = Record[NextIndex++];
1738 bool isGNUVarArgs = Record[NextIndex++];
1739 bool hasCommaPasting = Record[NextIndex++];
1740 MacroParams.clear();
1741 unsigned NumArgs = Record[NextIndex++];
1742 for (
unsigned i = 0;
i != NumArgs; ++
i)
1743 MacroParams.push_back(getLocalIdentifier(F, Record[NextIndex++]));
1757 if (NextIndex + 1 == Record.size() && PP.getPreprocessingRecord() &&
1758 Record[NextIndex]) {
1761 GlobalID = getGlobalPreprocessedEntityID(F, Record[NextIndex]);
1763 PreprocessingRecord::PPEntityID PPID =
1764 PPRec.getPPEntityID(GlobalID - 1,
true);
1766 PPRec.getPreprocessedEntity(PPID));
1768 PPRec.RegisterMacroDefinition(Macro, PPDef);
1781 Token Tok = ReadToken(F, Record, Idx);
1791 unsigned LocalID)
const {
1793 ReadModuleOffsetMap(M);
1798 &&
"Invalid index into preprocessed entity index remap");
1800 return LocalID + I->second;
1826 return FileMgr.
getFile(Key.Filename);
1828 std::string Resolved = Key.Filename;
1829 Reader.ResolveImportedPath(M, Resolved);
1830 return FileMgr.
getFile(Resolved);
1835 return FEA && FEA == FEB;
1838 std::pair<unsigned, unsigned>
1839 HeaderFileInfoTrait::ReadKeyDataLength(
const unsigned char*&
d) {
1840 using namespace llvm::support;
1842 unsigned KeyLen = (unsigned) endian::readNext<uint16_t, little, unaligned>(d);
1843 unsigned DataLen = (unsigned) *d++;
1844 return std::make_pair(KeyLen, DataLen);
1848 HeaderFileInfoTrait::ReadKey(
const unsigned char *
d,
unsigned) {
1849 using namespace llvm::support;
1852 ikey.
Size = off_t(endian::readNext<uint64_t, little, unaligned>(d));
1853 ikey.
ModTime = time_t(endian::readNext<uint64_t, little, unaligned>(d));
1862 using namespace llvm::support;
1864 const unsigned char *
End = d + DataLen;
1866 unsigned Flags = *d++;
1868 HFI.
isImport |= (Flags >> 5) & 0x01;
1870 HFI.
DirInfo = (Flags >> 1) & 0x07;
1877 M, endian::readNext<uint32_t, little, unaligned>(d));
1878 if (
unsigned FrameworkOffset =
1879 endian::readNext<uint32_t, little, unaligned>(d)) {
1882 StringRef FrameworkName(FrameworkStrings + FrameworkOffset - 1);
1883 HFI.
Framework = HS->getUniqueFrameworkName(FrameworkName);
1886 assert((End - d) % 4 == 0 &&
1887 "Wrong data length in HeaderFileInfo deserialization");
1889 uint32_t LocalSMID = endian::readNext<uint32_t, little, unaligned>(
d);
1895 SubmoduleID GlobalSMID = Reader.getGlobalSubmoduleID(M, LocalSMID);
1896 Module *Mod = Reader.getSubmodule(GlobalSMID);
1899 Reader.getPreprocessor().getHeaderSearchInfo().getModuleMap();
1903 Reader.ResolveImportedPath(M, Filename);
1908 ModMap.
addHeader(Mod, H, HeaderRole,
true);
1920 uint64_t MacroDirectivesOffset) {
1921 assert(NumCurrentElementsDeserializing > 0 &&
"Missing deserialization guard");
1922 PendingMacroIDs[II].push_back(PendingMacroInfo(M, MacroDirectivesOffset));
1929 for (
ModuleFile &I : llvm::reverse(ModuleMgr)) {
1930 BitstreamCursor &MacroCursor = I.MacroCursor;
1933 if (MacroCursor.getBitcodeBytes().empty())
1936 BitstreamCursor
Cursor = MacroCursor;
1937 if (
llvm::Error Err = Cursor.JumpToBit(I.MacroStartOffset)) {
1938 Error(std::move(Err));
1946 Error(MaybeE.takeError());
1949 llvm::BitstreamEntry E = MaybeE.get();
1952 case llvm::BitstreamEntry::SubBlock:
1954 Error(
"malformed block record in AST file");
1956 case llvm::BitstreamEntry::EndBlock:
1959 case llvm::BitstreamEntry::Record: {
1963 Error(MaybeRecord.takeError());
1966 switch (MaybeRecord.get()) {
1974 updateOutOfDateIdentifier(*II);
1993 class IdentifierLookupVisitor {
1996 unsigned PriorGeneration;
1997 unsigned &NumIdentifierLookups;
1998 unsigned &NumIdentifierLookupHits;
2002 IdentifierLookupVisitor(StringRef Name,
unsigned PriorGeneration,
2003 unsigned &NumIdentifierLookups,
2004 unsigned &NumIdentifierLookupHits)
2006 PriorGeneration(PriorGeneration),
2007 NumIdentifierLookups(NumIdentifierLookups),
2008 NumIdentifierLookupHits(NumIdentifierLookupHits) {}
2022 ++NumIdentifierLookups;
2023 ASTIdentifierLookupTable::iterator Pos =
2024 IdTable->find_hashed(Name, NameHash, &Trait);
2025 if (Pos == IdTable->end())
2031 ++NumIdentifierLookupHits;
2047 unsigned PriorGeneration = 0;
2048 if (getContext().getLangOpts().Modules)
2049 PriorGeneration = IdentifierGeneration[&II];
2055 if (!loadGlobalIndex()) {
2056 if (GlobalIndex->lookupIdentifier(II.
getName(), Hits)) {
2061 IdentifierLookupVisitor Visitor(II.
getName(), PriorGeneration,
2062 NumIdentifierLookups,
2063 NumIdentifierLookupHits);
2064 ModuleMgr.visit(Visitor, HitsPtr);
2065 markIdentifierUpToDate(&II);
2075 if (getContext().getLangOpts().Modules)
2076 IdentifierGeneration[II] = getGeneration();
2080 const PendingMacroInfo &PMInfo) {
2085 if (
llvm::Error Err = Cursor.JumpToBit(PMInfo.MacroDirectivesOffset)) {
2086 Error(std::move(Err));
2090 struct ModuleMacroRecord {
2103 Cursor.advance(BitstreamCursor::AF_DontPopBlockAtEnd);
2105 Error(MaybeEntry.takeError());
2108 llvm::BitstreamEntry Entry = MaybeEntry.get();
2110 if (Entry.Kind != llvm::BitstreamEntry::Record) {
2111 Error(
"malformed block record in AST file");
2118 Error(MaybePP.takeError());
2126 ModuleMacros.push_back(ModuleMacroRecord());
2127 auto &Info = ModuleMacros.back();
2128 Info.SubModID = getGlobalSubmoduleID(M, Record[0]);
2129 Info.MI = getMacro(getGlobalMacroID(M, Record[1]));
2130 for (
int I = 2, N = Record.size(); I != N; ++I)
2131 Info.Overrides.push_back(getGlobalSubmoduleID(M, Record[I]));
2136 Error(
"malformed block record in AST file");
2147 std::reverse(ModuleMacros.begin(), ModuleMacros.end());
2149 for (
auto &MMR : ModuleMacros) {
2151 for (
unsigned ModID : MMR.Overrides) {
2152 Module *Mod = getSubmodule(ModID);
2153 auto *Macro = PP.getModuleMacro(Mod, II);
2154 assert(Macro &&
"missing definition for overridden macro");
2155 Overrides.push_back(Macro);
2158 bool Inserted =
false;
2159 Module *Owner = getSubmodule(MMR.SubModID);
2160 PP.addModuleMacro(Owner, II, MMR.MI, Overrides, Inserted);
2171 unsigned Idx = 0, N = Record.size();
2178 MacroInfo *MI = getMacro(getGlobalMacroID(M, Record[Idx++]));
2179 MD = PP.AllocateDefMacroDirective(MI, Loc);
2183 MD = PP.AllocateUndefMacroDirective(Loc);
2186 bool isPublic = Record[Idx++];
2187 MD = PP.AllocateVisibilityMacroDirective(Loc, isPublic);
2199 PP.setLoadedMacroDirective(II, Earliest, Latest);
2202 ASTReader::InputFileInfo
2203 ASTReader::readInputFileInfo(
ModuleFile &F,
unsigned ID) {
2209 consumeError(std::move(Err));
2215 consumeError(MaybeCode.takeError());
2217 unsigned Code = MaybeCode.get();
2222 assert(static_cast<InputFileRecordTypes>(Maybe.get()) ==
INPUT_FILE &&
2223 "invalid record type for input file");
2226 consumeError(Maybe.takeError());
2229 assert(Record[0] == ID &&
"Bogus stored ID or offset");
2231 R.StoredSize =
static_cast<off_t
>(Record[1]);
2232 R.StoredTime =
static_cast<time_t
>(Record[2]);
2233 R.Overridden =
static_cast<bool>(Record[3]);
2234 R.Transient =
static_cast<bool>(Record[4]);
2235 R.TopLevelModuleMap =
static_cast<bool>(Record[5]);
2237 ResolveImportedPath(F, R.Filename);
2259 consumeError(std::move(Err));
2262 InputFileInfo FI = readInputFileInfo(F,
ID);
2263 off_t StoredSize = FI.StoredSize;
2264 time_t StoredTime = FI.StoredTime;
2265 bool Overridden = FI.Overridden;
2266 bool Transient = FI.Transient;
2269 const FileEntry *File = FileMgr.getFile(Filename,
false);
2276 if (!Resolved.empty())
2277 File = FileMgr.getFile(Resolved);
2282 if ((Overridden || Transient) && File ==
nullptr)
2283 File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime);
2285 if (File ==
nullptr) {
2287 std::string ErrorStr =
"could not find file '";
2289 ErrorStr +=
"' referenced by AST file '";
2307 Error(diag::err_fe_pch_file_overridden, Filename);
2319 FileMgr.modifyFileEntry(const_cast<FileEntry*>(File),
2320 StoredSize, StoredTime);
2323 bool IsOutOfDate =
false;
2327 (StoredSize != File->
getSize() ||
2334 while (!ImportStack.back()->ImportedBy.empty())
2335 ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
2338 StringRef TopLevelPCHName(ImportStack.back()->FileName);
2340 if (DiagnosticKind == 0)
2341 Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
2342 else if (DiagnosticKind == 1)
2343 Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName);
2345 Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName);
2348 if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
2349 Diag(diag::note_pch_required_by)
2350 << Filename << ImportStack[0]->FileName;
2351 for (
unsigned I = 1; I < ImportStack.size(); ++I)
2352 Diag(diag::note_pch_required_by)
2353 << ImportStack[I-1]->FileName << ImportStack[I]->FileName;
2356 if (!Diags.isDiagnosticInFlight())
2357 Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
2382 if (Filename.empty() || llvm::sys::path::is_absolute(Filename))
2386 llvm::sys::path::append(Buffer, Prefix, Filename);
2387 Filename.assign(Buffer.begin(), Buffer.end());
2402 llvm_unreachable(
"unknown ASTReadResult");
2406 BitstreamCursor &Stream,
unsigned ClientLoadCapabilities,
2408 std::string &SuggestedPredefines) {
2411 consumeError(std::move(Err));
2417 ASTReadResult Result = Success;
2422 consumeError(MaybeEntry.takeError());
2425 llvm::BitstreamEntry Entry = MaybeEntry.get();
2427 switch (Entry.Kind) {
2429 case llvm::BitstreamEntry::SubBlock:
2432 case llvm::BitstreamEntry::EndBlock:
2435 case llvm::BitstreamEntry::Record:
2443 if (!MaybeRecordType) {
2445 consumeError(MaybeRecordType.takeError());
2450 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2451 if (ParseLanguageOptions(Record, Complain, Listener,
2452 AllowCompatibleConfigurationMismatch))
2453 Result = ConfigurationMismatch;
2458 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2459 if (ParseTargetOptions(Record, Complain, Listener,
2460 AllowCompatibleConfigurationMismatch))
2461 Result = ConfigurationMismatch;
2466 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2467 if (!AllowCompatibleConfigurationMismatch &&
2468 ParseFileSystemOptions(Record, Complain, Listener))
2469 Result = ConfigurationMismatch;
2474 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2475 if (!AllowCompatibleConfigurationMismatch &&
2476 ParseHeaderSearchOptions(Record, Complain, Listener))
2477 Result = ConfigurationMismatch;
2482 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2483 if (!AllowCompatibleConfigurationMismatch &&
2484 ParsePreprocessorOptions(Record, Complain, Listener,
2485 SuggestedPredefines))
2486 Result = ConfigurationMismatch;
2496 unsigned ClientLoadCapabilities) {
2497 BitstreamCursor &Stream = F.
Stream;
2498 ASTReadResult Result = Success;
2501 Error(std::move(Err));
2511 bool HasReadUnhashedControlBlock =
false;
2512 auto readUnhashedControlBlockOnce = [&]() {
2513 if (!HasReadUnhashedControlBlock) {
2514 HasReadUnhashedControlBlock =
true;
2515 if (ASTReadResult Result =
2516 readUnhashedControlBlock(F, ImportedBy, ClientLoadCapabilities))
2524 unsigned NumInputs = 0;
2525 unsigned NumUserInputs = 0;
2526 StringRef BaseDirectoryAsWritten;
2530 Error(MaybeEntry.takeError());
2533 llvm::BitstreamEntry Entry = MaybeEntry.get();
2535 switch (Entry.Kind) {
2537 Error(
"malformed block record in AST file");
2539 case llvm::BitstreamEntry::EndBlock: {
2542 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2547 PP.getHeaderSearchInfo().getHeaderSearchOpts();
2554 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
2560 unsigned N = NumUserInputs;
2561 if (ValidateSystemInputs ||
2567 for (
unsigned I = 0; I < N; ++I) {
2568 InputFile IF = getInputFile(F, I+1, Complain);
2580 for (
unsigned I = 0; I < N; ++I) {
2581 bool IsSystem = I >= NumUserInputs;
2582 InputFileInfo FI = readInputFileInfo(F, I+1);
2592 case llvm::BitstreamEntry::SubBlock:
2597 Error(std::move(Err));
2601 Error(
"malformed block record in AST file");
2610 if (Listener && !ImportedBy) {
2616 bool AllowCompatibleConfigurationMismatch =
2619 Result = ReadOptionsBlock(Stream, ClientLoadCapabilities,
2620 AllowCompatibleConfigurationMismatch,
2621 *Listener, SuggestedPredefines);
2622 if (Result == Failure) {
2623 Error(
"malformed block record in AST file");
2627 if (DisableValidation ||
2628 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
2634 if (Result != Success)
2636 }
else if (
llvm::Error Err = Stream.SkipBlock()) {
2637 Error(std::move(Err));
2644 Error(std::move(Err));
2650 case llvm::BitstreamEntry::Record:
2659 Stream.readRecord(Entry.ID, Record, &Blob);
2660 if (!MaybeRecordType) {
2661 Error(MaybeRecordType.takeError());
2667 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2669 : diag::err_pch_version_too_new);
2670 return VersionMismatch;
2673 bool hasErrors = Record[7];
2674 if (hasErrors && !DisableValidation && !AllowASTWithCompilerErrors) {
2675 Diag(diag::err_pch_with_compiler_errors);
2679 Diags.ErrorOccurred =
true;
2680 Diags.UncompilableErrorOccurred =
true;
2681 Diags.UnrecoverableErrorOccurred =
true;
2694 StringRef ASTBranch = Blob;
2695 if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
2696 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2697 Diag(diag::err_pch_different_branch) << ASTBranch << CurBranch;
2698 return VersionMismatch;
2707 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2711 unsigned Idx = 0, N = Record.size();
2719 ReadUntranslatedSourceLocation(Record[Idx++]);
2720 off_t StoredSize = (off_t)Record[Idx++];
2721 time_t StoredModTime = (time_t)Record[Idx++];
2723 {{(uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
2724 (uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
2725 (uint32_t)Record[Idx++]}}};
2727 std::string ImportedName = ReadString(Record, Idx);
2728 std::string ImportedFile;
2736 ImportedFile = PP.getHeaderSearchInfo().getPrebuiltModuleFileName(
2737 ImportedName,
true);
2739 if (ImportedFile.empty())
2742 ImportedFile = ReadPath(BaseDirectoryAsWritten, Record, Idx);
2744 SkipPath(Record, Idx);
2748 unsigned Capabilities = ClientLoadCapabilities;
2749 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2750 Capabilities &= ~ARR_Missing;
2753 auto Result = ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F,
2754 Loaded, StoredSize, StoredModTime,
2755 StoredSignature, Capabilities);
2759 Diag(diag::note_module_file_imported_by)
2763 case Failure:
return Failure;
2766 case OutOfDate:
return OutOfDate;
2767 case VersionMismatch:
return VersionMismatch;
2768 case ConfigurationMismatch:
return ConfigurationMismatch;
2769 case HadErrors:
return HadErrors;
2770 case Success:
break;
2793 Diag(diag::remark_module_import)
2795 << (ImportedBy ? StringRef(ImportedBy->
ModuleName) : StringRef());
2801 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2809 BaseDirectoryAsWritten = Blob;
2811 "MODULE_DIRECTORY found before MODULE_NAME");
2814 Module *M = PP.getHeaderSearchInfo().lookupModule(
2817 if (M && M->Directory) {
2821 if (!PP.getPreprocessorOpts().DisablePCHValidation &&
2824 PP.getFileManager().getDirectory(Blob);
2825 if (!BuildDir || BuildDir != M->Directory) {
2826 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2827 Diag(diag::err_imported_module_relocated)
2828 << F.
ModuleName << Blob << M->Directory->getName();
2840 if (ASTReadResult Result =
2841 ReadModuleMapFileBlock(Record, F, ImportedBy, ClientLoadCapabilities))
2846 NumInputs = Record[0];
2847 NumUserInputs = Record[1];
2849 (
const llvm::support::unaligned_uint64_t *)Blob.data();
2858 ASTReader::ReadASTBlock(
ModuleFile &F,
unsigned ClientLoadCapabilities) {
2859 BitstreamCursor &Stream = F.
Stream;
2862 Error(std::move(Err));
2871 Error(MaybeEntry.takeError());
2874 llvm::BitstreamEntry Entry = MaybeEntry.get();
2876 switch (Entry.Kind) {
2878 Error(
"error at end of module block in AST file");
2880 case llvm::BitstreamEntry::EndBlock:
2893 case llvm::BitstreamEntry::SubBlock:
2902 Error(std::move(Err));
2906 Error(
"malformed block record in AST file");
2913 if (!PP.getExternalSource())
2914 PP.setExternalSource(
this);
2917 Error(std::move(Err));
2921 Error(
"malformed block record in AST file");
2931 Error(std::move(Err));
2936 Error(
"malformed preprocessor detail record in AST file");
2942 if (!PP.getPreprocessingRecord())
2943 PP.createPreprocessingRecord();
2944 if (!PP.getPreprocessingRecord()->getExternalSource())
2945 PP.getPreprocessingRecord()->SetExternalSource(*
this);
2949 if (ReadSourceManagerBlock(F))
2954 if (ASTReadResult Result =
2955 ReadSubmoduleBlock(F, ClientLoadCapabilities))
2960 BitstreamCursor C = Stream;
2963 Error(std::move(Err));
2967 Error(
"malformed comments block in AST file");
2970 CommentsCursors.push_back(std::make_pair(C, &F));
2976 Error(std::move(Err));
2983 case llvm::BitstreamEntry::Record:
2992 Stream.readRecord(Entry.ID, Record, &Blob);
2993 if (!MaybeRecordType) {
2994 Error(MaybeRecordType.takeError());
3001 switch (RecordType) {
3022 switch (RecordType) {
3028 Error(
"duplicate TYPE_OFFSET record in AST file");
3033 unsigned LocalBaseTypeIndex = Record[1];
3038 GlobalTypeMap.insert(std::make_pair(getTotalNumTypes(), &F));
3042 std::make_pair(LocalBaseTypeIndex,
3052 Error(
"duplicate DECL_OFFSET record in AST file");
3057 unsigned LocalBaseDeclID = Record[1];
3063 GlobalDeclMap.insert(
3069 std::make_pair(LocalBaseDeclID, F.
BaseDeclID - LocalBaseDeclID));
3081 DeclContext *TU = ContextObj->getTranslationUnitDecl();
3082 LexicalContents Contents(
3083 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
3085 static_cast<unsigned int>(Blob.size() / 4));
3086 TULexicalDecls.push_back(std::make_pair(&F, Contents));
3094 auto *Data = (
const unsigned char*)Blob.data();
3095 PendingVisibleUpdates[
ID].push_back(PendingVisibleUpdate{&F, Data});
3098 if (
Decl *D = GetExistingDecl(ID))
3099 PendingUpdateRecords.push_back(
3100 PendingUpdateRecord(ID, D,
false));
3113 PP.getIdentifierTable().setExternalIdentifierLookup(
this);
3119 Error(
"duplicate IDENTIFIER_OFFSET record in AST file");
3124 unsigned LocalBaseIdentifierID = Record[1];
3130 GlobalIdentifierMap.insert(std::make_pair(getTotalNumIdentifiers() + 1,
3136 std::make_pair(LocalBaseIdentifierID,
3139 IdentifiersLoaded.resize(IdentifiersLoaded.size()
3152 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3153 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
3160 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3161 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
3165 if (SpecialTypes.empty()) {
3166 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3167 SpecialTypes.push_back(getGlobalTypeID(F, Record[I]));
3171 if (SpecialTypes.size() != Record.size()) {
3172 Error(
"invalid special-types record");
3176 for (
unsigned I = 0, N = Record.size(); I != N; ++I) {
3178 if (!SpecialTypes[I])
3179 SpecialTypes[I] =
ID;
3186 TotalNumStatements += Record[0];
3187 TotalNumMacros += Record[1];
3188 TotalLexicalDeclContexts += Record[2];
3189 TotalVisibleDeclContexts += Record[3];
3193 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3194 UnusedFileScopedDecls.push_back(getGlobalDeclID(F, Record[I]));
3198 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3199 DelegatingCtorDecls.push_back(getGlobalDeclID(F, Record[I]));
3203 if (Record.size() % 4 != 0) {
3204 Error(
"invalid weak identifiers record");
3210 WeakUndeclaredIdentifiers.clear();
3213 for (
unsigned I = 0, N = Record.size(); I < N; ) {
3214 WeakUndeclaredIdentifiers.push_back(
3215 getGlobalIdentifierID(F, Record[I++]));
3216 WeakUndeclaredIdentifiers.push_back(
3217 getGlobalIdentifierID(F, Record[I++]));
3218 WeakUndeclaredIdentifiers.push_back(
3219 ReadSourceLocation(F, Record, I).getRawEncoding());
3220 WeakUndeclaredIdentifiers.push_back(Record[I++]);
3227 unsigned LocalBaseSelectorID = Record[1];
3233 GlobalSelectorMap.insert(std::make_pair(getTotalNumSelectors()+1, &F));
3238 std::make_pair(LocalBaseSelectorID,
3254 TotalNumMethodPoolEntries += Record[1];
3258 if (!Record.empty()) {
3259 for (
unsigned Idx = 0, N = Record.size() - 1; Idx < N; ) {
3260 ReferencedSelectorsData.push_back(getGlobalSelectorID(F,
3262 ReferencedSelectorsData.push_back(ReadSourceLocation(F, Record, Idx).
3269 if (!Record.empty()) {
3270 unsigned Idx = 0,
End = Record.size() - 1;
3271 bool ReachedEOFWhileSkipping = Record[Idx++];
3273 if (ReachedEOFWhileSkipping) {
3276 bool FoundNonSkipPortion = Record[Idx++];
3277 bool FoundElse = Record[Idx++];
3279 SkipInfo.emplace(HashToken, IfTokenLoc, FoundNonSkipPortion,
3280 FoundElse, ElseLoc);
3284 auto Loc = ReadSourceLocation(F, Record, Idx);
3285 bool WasSkipping = Record[Idx++];
3286 bool FoundNonSkip = Record[Idx++];
3287 bool FoundElse = Record[Idx++];
3288 ConditionalStack.push_back(
3289 {Loc, WasSkipping, FoundNonSkip, FoundElse});
3291 PP.setReplayablePreambleConditionalStack(ConditionalStack, SkipInfo);
3296 if (!Record.empty() && Listener)
3308 unsigned SLocSpaceSize = Record[1];
3313 Error(
"ran out of source locations");
3319 unsigned RangeStart =
3321 GlobalSLocEntryMap.insert(std::make_pair(RangeStart, &F));
3326 GlobalSLocOffsetMap.insert(
3328 - SLocSpaceSize,&F));
3346 if (ParseLineTable(F, Record))
3354 Error(
"Multiple SOURCE_LOCATION_PRELOADS records in AST file");
3363 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3364 ExtVectorDecls.push_back(getGlobalDeclID(F, Record[I]));
3368 if (Record.size() % 3 != 0) {
3369 Error(
"Invalid VTABLE_USES record");
3378 for (
unsigned Idx = 0, N = Record.size(); Idx != N; ) {
3379 VTableUses.push_back(getGlobalDeclID(F, Record[Idx++]));
3380 VTableUses.push_back(
3381 ReadSourceLocation(F, Record, Idx).getRawEncoding());
3382 VTableUses.push_back(Record[Idx++]);
3387 if (PendingInstantiations.size() % 2 != 0) {
3388 Error(
"Invalid existing PendingInstantiations");
3392 if (Record.size() % 2 != 0) {
3393 Error(
"Invalid PENDING_IMPLICIT_INSTANTIATIONS block");
3397 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3398 PendingInstantiations.push_back(getGlobalDeclID(F, Record[I++]));
3399 PendingInstantiations.push_back(
3400 ReadSourceLocation(F, Record, I).getRawEncoding());
3405 if (Record.size() != 3) {
3406 Error(
"Invalid SEMA_DECL_REFS block");
3409 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3410 SemaDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
3418 unsigned LocalBasePreprocessedEntityID = Record[0];
3420 unsigned StartingID;
3421 if (!PP.getPreprocessingRecord())
3422 PP.createPreprocessingRecord();
3423 if (!PP.getPreprocessingRecord()->getExternalSource())
3424 PP.getPreprocessingRecord()->SetExternalSource(*
this);
3426 = PP.getPreprocessingRecord()
3433 GlobalPreprocessedEntityMap.insert(std::make_pair(StartingID, &F));
3438 std::make_pair(LocalBasePreprocessedEntityID,
3450 if (!PP.getPreprocessingRecord())
3451 PP.createPreprocessingRecord();
3452 if (!PP.getPreprocessingRecord()->getExternalSource())
3453 PP.getPreprocessingRecord()->SetExternalSource(*
this);
3458 GlobalSkippedRangeMap.insert(
3464 if (Record.size() % 2 != 0) {
3465 Error(
"invalid DECL_UPDATE_OFFSETS block in AST file");
3468 for (
unsigned I = 0, N = Record.size(); I != N; I += 2) {
3470 DeclUpdateOffsets[
ID].push_back(std::make_pair(&F, Record[I + 1]));
3474 if (
Decl *D = GetExistingDecl(ID))
3475 PendingUpdateRecords.push_back(
3476 PendingUpdateRecord(ID, D,
false));
3482 Error(
"duplicate OBJC_CATEGORIES_MAP record in AST file");
3497 CUDASpecialDeclRefs.clear();
3498 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3499 CUDASpecialDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
3511 &PP.getHeaderSearchInfo(),
3512 Blob.data() + Record[2]));
3514 PP.getHeaderSearchInfo().SetExternalSource(
this);
3515 if (!PP.getHeaderSearchInfo().getExternalLookup())
3516 PP.getHeaderSearchInfo().SetExternalLookup(
this);
3522 FPPragmaOptions.swap(Record);
3526 for (
unsigned I = 0, E = Record.size(); I != E; ) {
3527 auto Name = ReadString(Record, I);
3528 auto &Opt = OpenCLExtensions.OptMap[Name];
3529 Opt.Supported = Record[I++] != 0;
3530 Opt.Enabled = Record[I++] != 0;
3531 Opt.Avail = Record[I++];
3532 Opt.Core = Record[I++];
3537 for (
unsigned I = 0, E = Record.size(); I != E;) {
3540 auto NumExt =
static_cast<unsigned>(Record[I++]);
3541 for (
unsigned II = 0; II != NumExt; ++II) {
3542 auto Ext = ReadString(Record, I);
3543 OpenCLTypeExtMap[
Type].insert(Ext);
3549 for (
unsigned I = 0, E = Record.size(); I != E;) {
3552 auto NumExt =
static_cast<unsigned>(Record[I++]);
3553 for (
unsigned II = 0; II != NumExt; ++II) {
3554 auto Ext = ReadString(Record, I);
3555 OpenCLDeclExtMap[
Decl].insert(Ext);
3561 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3562 TentativeDefinitions.push_back(getGlobalDeclID(F, Record[I]));
3566 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3567 KnownNamespaces.push_back(getGlobalDeclID(F, Record[I]));
3571 if (UndefinedButUsed.size() % 2 != 0) {
3572 Error(
"Invalid existing UndefinedButUsed");
3576 if (Record.size() % 2 != 0) {
3577 Error(
"invalid undefined-but-used record");
3580 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3581 UndefinedButUsed.push_back(getGlobalDeclID(F, Record[I++]));
3582 UndefinedButUsed.push_back(
3583 ReadSourceLocation(F, Record, I).getRawEncoding());
3588 for (
unsigned I = 0, N = Record.size(); I != N;) {
3589 DelayedDeleteExprs.push_back(getGlobalDeclID(F, Record[I++]));
3590 const uint64_t Count = Record[I++];
3591 DelayedDeleteExprs.push_back(Count);
3592 for (uint64_t C = 0; C < Count; ++C) {
3593 DelayedDeleteExprs.push_back(ReadSourceLocation(F, Record, I).getRawEncoding());
3594 bool IsArrayForm = Record[I++] == 1;
3595 DelayedDeleteExprs.push_back(IsArrayForm);
3605 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3606 unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
3609 ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
3610 if (DeserializationListener)
3611 DeserializationListener->ModuleImportRead(GlobalID, Loc);
3619 Error(
"duplicate MACRO_OFFSET record in AST file");
3624 unsigned LocalBaseMacroID = Record[1];
3629 GlobalMacroMap.insert(std::make_pair(getTotalNumMacros() + 1, &F));
3633 std::make_pair(LocalBaseMacroID,
3642 LateParsedTemplates.append(Record.begin(), Record.end());
3646 if (Record.size() != 1) {
3647 Error(
"invalid pragma optimize record");
3650 OptimizeOffPragmaLocation = ReadSourceLocation(F, Record[0]);
3654 if (Record.size() != 1) {
3655 Error(
"invalid pragma ms_struct record");
3658 PragmaMSStructState = Record[0];
3662 if (Record.size() != 2) {
3663 Error(
"invalid pragma ms_struct record");
3666 PragmaMSPointersToMembersState = Record[0];
3667 PointersToMembersPragmaLocation = ReadSourceLocation(F, Record[1]);
3671 for (
unsigned I = 0, N = Record.size(); I != N; ++I)
3672 UnusedLocalTypedefNameCandidates.push_back(
3673 getGlobalDeclID(F, Record[I]));
3677 if (Record.size() != 1) {
3678 Error(
"invalid cuda pragma options record");
3681 ForceCUDAHostDeviceDepth = Record[0];
3685 if (Record.size() < 3) {
3686 Error(
"invalid pragma pack record");
3689 PragmaPackCurrentValue = Record[0];
3690 PragmaPackCurrentLocation = ReadSourceLocation(F, Record[1]);
3691 unsigned NumStackEntries = Record[2];
3694 PragmaPackStack.clear();
3695 for (
unsigned I = 0; I < NumStackEntries; ++I) {
3696 PragmaPackStackEntry Entry;
3697 Entry.Value = Record[Idx++];
3698 Entry.Location = ReadSourceLocation(F, Record[Idx++]);
3699 Entry.PushLocation = ReadSourceLocation(F, Record[Idx++]);
3700 PragmaPackStrings.push_back(ReadString(Record, Idx));
3701 Entry.SlotLabel = PragmaPackStrings.back();
3702 PragmaPackStack.push_back(Entry);
3710 void ASTReader::ReadModuleOffsetMap(
ModuleFile &F)
const {
3714 const unsigned char *Data = (
const unsigned char*)F.
ModuleOffsetMap.data();
3735 while (Data < DataEnd) {
3739 using namespace llvm::support;
3741 endian::readNext<uint8_t, little, unaligned>(Data));
3742 uint16_t Len = endian::readNext<uint16_t, little, unaligned>(Data);
3743 StringRef Name = StringRef((
const char*)Data, Len);
3746 ? ModuleMgr.lookupByModuleName(Name)
3747 : ModuleMgr.lookupByFileName(Name));
3750 "SourceLocation remap refers to unknown module, cannot find ";
3756 uint32_t SLocOffset =
3757 endian::readNext<uint32_t, little, unaligned>(Data);
3758 uint32_t IdentifierIDOffset =
3759 endian::readNext<uint32_t, little, unaligned>(Data);
3760 uint32_t MacroIDOffset =
3761 endian::readNext<uint32_t, little, unaligned>(Data);
3762 uint32_t PreprocessedEntityIDOffset =
3763 endian::readNext<uint32_t, little, unaligned>(Data);
3764 uint32_t SubmoduleIDOffset =
3765 endian::readNext<uint32_t, little, unaligned>(Data);
3766 uint32_t SelectorIDOffset =
3767 endian::readNext<uint32_t, little, unaligned>(Data);
3768 uint32_t DeclIDOffset =
3769 endian::readNext<uint32_t, little, unaligned>(Data);
3770 uint32_t TypeIndexOffset =
3771 endian::readNext<uint32_t, little, unaligned>(Data);
3775 auto mapOffset = [&](uint32_t
Offset, uint32_t BaseOffset,
3776 RemapBuilder &Remap) {
3778 Remap.insert(std::make_pair(Offset,
3779 static_cast<int>(BaseOffset - Offset)));
3783 mapOffset(MacroIDOffset, OM->
BaseMacroID, MacroRemap);
3785 PreprocessedEntityRemap);
3788 mapOffset(DeclIDOffset, OM->
BaseDeclID, DeclRemap);
3797 ASTReader::ReadModuleMapFileBlock(RecordData &Record,
ModuleFile &F,
3799 unsigned ClientLoadCapabilities) {
3808 "MODULE_NAME should come before MODULE_MAP_FILE");
3813 auto &Map = PP.getHeaderSearchInfo().getModuleMap();
3814 const FileEntry *ModMap = M ? Map.getModuleMapFileForUniquing(M) :
nullptr;
3816 if (!PP.getPreprocessorOpts().DisablePCHValidation && !ModMap) {
3817 assert(ImportedBy &&
"top-level import should be verified");
3818 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) {
3819 if (
auto *ASTFE = M ? M->
getASTFile() :
nullptr) {
3822 << ASTFE->getName();
3825 Diag(diag::err_imported_module_not_found)
3832 Diag(diag::note_imported_by_pch_module_not_found)
3839 assert(M->
Name == F.
ModuleName &&
"found module with different name");
3843 if (StoredModMap ==
nullptr || StoredModMap != ModMap) {
3844 assert(ModMap &&
"found module is missing module map file");
3845 assert(ImportedBy &&
"top-level import should be verified");
3846 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3847 Diag(diag::err_imported_module_modmap_changed)
3853 llvm::SmallPtrSet<const FileEntry *, 1> AdditionalStoredMaps;
3854 for (
unsigned I = 0, N = Record[Idx++]; I < N; ++I) {
3856 std::string
Filename = ReadPath(F, Record, Idx);
3858 FileMgr.getFile(Filename,
false,
false);
3860 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3861 Error(
"could not find file '" + Filename +
"' referenced by AST file");
3864 AdditionalStoredMaps.insert(F);
3869 if (
auto *AdditionalModuleMaps = Map.getAdditionalModuleMapFiles(M)) {
3870 for (
const FileEntry *ModMap : *AdditionalModuleMaps) {
3873 if (!AdditionalStoredMaps.erase(ModMap)) {
3874 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3875 Diag(diag::err_module_different_modmap)
3884 for (
const FileEntry *ModMap : AdditionalStoredMaps) {
3885 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3886 Diag(diag::err_module_different_modmap)
3900 Sema::GlobalMethodPool::iterator Known
3907 : Known->second.second;
3909 for (
ObjCMethodList *List = &Start; List; List = List->getNext()) {
3911 if (List->getMethod() == Method) {
3919 if (List->getNext())
3920 List->setMethod(List->getNext()->getMethod());
3922 List->setMethod(Method);
3928 for (
Decl *D : Names) {
3929 bool wasHidden = D->isHidden();
3930 D->setVisibleDespiteOwningModule();
3932 if (wasHidden && SemaObj) {
3943 llvm::SmallPtrSet<Module *, 4> Visited;
3945 Stack.push_back(Mod);
3946 while (!Stack.empty()) {
3947 Mod = Stack.pop_back_val();
3949 if (NameVisibility <= Mod->NameVisibility) {
3965 HiddenNamesMapType::iterator Hidden = HiddenNamesMap.find(Mod);
3966 if (Hidden != HiddenNamesMap.end()) {
3968 HiddenNamesMap.erase(Hidden);
3970 assert(HiddenNamesMap.find(Mod) == HiddenNamesMap.end() &&
3971 "making names visible added hidden names");
3978 I = Exports.begin(), E = Exports.end(); I != E; ++I) {
3980 if (Visited.insert(Exported).second)
3981 Stack.push_back(Exported);
3996 getContext().mergeDefinitionIntoModule(
3999 PendingMergedDefinitionsToDeduplicate.insert(Def);
4008 if (TriedLoadingGlobalIndex || !UseGlobalIndex ||
4009 !PP.getLangOpts().Modules)
4013 TriedLoadingGlobalIndex =
true;
4014 StringRef ModuleCachePath
4015 = getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
4016 std::pair<GlobalModuleIndex *, llvm::Error> Result =
4019 assert(!Result.first);
4020 consumeError(std::move(Err));
4024 GlobalIndex.reset(Result.first);
4025 ModuleMgr.setGlobalIndex(GlobalIndex.get());
4030 return PP.getLangOpts().Modules && UseGlobalIndex &&
4031 !hasGlobalIndex() && TriedLoadingGlobalIndex;
4038 llvm::raw_fd_ostream OS(TimestampFilename, EC, llvm::sys::fs::F_Text);
4041 OS <<
"Timestamp file\n";
4054 consumeError(MaybeEntry.takeError());
4057 llvm::BitstreamEntry Entry = MaybeEntry.get();
4059 switch (Entry.Kind) {
4061 case llvm::BitstreamEntry::EndBlock:
4064 case llvm::BitstreamEntry::Record:
4070 consumeError(Skipped.takeError());
4074 case llvm::BitstreamEntry::SubBlock:
4075 if (Entry.ID == BlockID) {
4076 if (
llvm::Error Err = Cursor.EnterSubBlock(BlockID)) {
4078 consumeError(std::move(Err));
4087 consumeError(std::move(Err));
4097 unsigned ClientLoadCapabilities,
4100 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
4106 unsigned PreviousGeneration = 0;
4108 PreviousGeneration = incrementGeneration(*ContextObj);
4110 unsigned NumModules = ModuleMgr.size();
4113 ReadASTCore(FileName, Type, ImportLoc,
4114 nullptr, Loaded, 0, 0,
4119 case VersionMismatch:
4120 case ConfigurationMismatch:
4122 llvm::SmallPtrSet<ModuleFile *, 4> LoadedSet;
4123 for (
const ImportedModule &IM : Loaded)
4124 LoadedSet.insert(IM.Mod);
4126 ModuleMgr.removeModules(ModuleMgr.begin() + NumModules, LoadedSet,
4127 PP.getLangOpts().Modules
4128 ? &PP.getHeaderSearchInfo().getModuleMap()
4133 GlobalIndex.reset();
4134 ModuleMgr.setGlobalIndex(
nullptr);
4145 MEnd = Loaded.end();
4150 if (
ASTReadResult Result = ReadASTBlock(F, ClientLoadCapabilities))
4172 SourceMgr.getLoadedSLocEntryByID(Index);
4185 const unsigned char *Data =
reinterpret_cast<const unsigned char *
>(
4190 auto Key = Trait.
ReadKey(Data, KeyDataLen.first);
4191 auto &II = PP.getIdentifierTable().getOwn(Key);
4192 II.setOutOfDate(
true);
4200 SetIdentifierInfo(
ID, &II);
4207 MEnd = Loaded.end();
4211 ModuleMgr.moduleFileAccepted(&F);
4223 if (!PP.getLangOpts().CPlusPlus ||
4234 IdEnd = PP.getIdentifierTable().end();
4236 Id->second->setOutOfDate(
true);
4239 for (
auto Sel : SelectorGeneration)
4240 SelectorOutOfDate[Sel.first] =
true;
4243 for (
unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I) {
4244 UnresolvedModuleRef &
Unresolved = UnresolvedModuleRefs[I];
4245 SubmoduleID GlobalID = getGlobalSubmoduleID(*Unresolved.File,Unresolved.ID);
4246 Module *ResolvedMod = getSubmodule(GlobalID);
4248 switch (Unresolved.Kind) {
4249 case UnresolvedModuleRef::Conflict:
4252 Conflict.
Other = ResolvedMod;
4253 Conflict.
Message = Unresolved.String.str();
4254 Unresolved.Mod->Conflicts.push_back(Conflict);
4258 case UnresolvedModuleRef::Import:
4260 Unresolved.Mod->Imports.insert(ResolvedMod);
4263 case UnresolvedModuleRef::Export:
4264 if (ResolvedMod || Unresolved.IsWildcard)
4265 Unresolved.Mod->Exports.push_back(
4270 UnresolvedModuleRefs.clear();
4273 Imported->append(ImportedModules.begin(),
4274 ImportedModules.end());
4281 InitializeContext();
4286 if (DeserializationListener)
4287 DeserializationListener->ReaderInitialized(
this);
4289 ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule();
4304 for (
unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++I) {
4305 loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
4306 ObjCClassesLoaded[I],
4307 PreviousGeneration);
4311 if (PP.getHeaderSearchInfo()
4312 .getHeaderSearchOpts()
4313 .ModulesValidateOncePerBuildSession) {
4318 for (
unsigned I = 0, N = Loaded.size(); I != N; ++I) {
4319 ImportedModule &M = Loaded[I];
4336 if (!Stream.canSkipToPos(4))
4337 return llvm::createStringError(std::errc::illegal_byte_sequence,
4338 "file too small to contain AST file magic");
4339 for (
unsigned C : {
'C',
'P',
'C',
'H'})
4342 return llvm::createStringError(
4343 std::errc::illegal_byte_sequence,
4344 "file doesn't start with AST file magic");
4346 return Res.takeError();
4347 return llvm::Error::success();
4362 llvm_unreachable(
"unknown module kind");
4366 ASTReader::ReadASTCore(StringRef FileName,
4371 off_t ExpectedSize, time_t ExpectedModTime,
4373 unsigned ClientLoadCapabilities) {
4375 std::string ErrorStr;
4377 = ModuleMgr.addModule(FileName,
Type, ImportLoc, ImportedBy,
4378 getGeneration(), ExpectedSize, ExpectedModTime,
4379 ExpectedSignature, readASTFileSignature,
4382 switch (AddResult) {
4384 Diag(diag::remark_module_import)
4386 << (ImportedBy ? StringRef(ImportedBy->
ModuleName) : StringRef());
4396 if (ClientLoadCapabilities & ARR_Missing)
4401 << FileName << !ErrorStr.empty()
4408 if (ClientLoadCapabilities & ARR_OutOfDate)
4413 << FileName << !ErrorStr.empty()
4418 assert(M &&
"Missing module file");
4420 bool ShouldFinalizePCM =
false;
4421 auto FinalizeOrDropPCM = llvm::make_scope_exit([&]() {
4422 auto &MC = getModuleManager().getModuleCache();
4423 if (ShouldFinalizePCM)
4424 MC.finalizePCM(FileName);
4426 MC.tryToDropPCM(FileName);
4429 BitstreamCursor &Stream = F.
Stream;
4430 Stream = BitstreamCursor(PCHContainerRdr.ExtractPCH(*F.Buffer));
4431 F.SizeInBits = F.Buffer->getBufferSize() * 8;
4435 Diag(diag::err_module_file_invalid)
4441 bool HaveReadControlBlock =
false;
4445 Error(MaybeEntry.takeError());
4448 llvm::BitstreamEntry Entry = MaybeEntry.get();
4450 switch (Entry.Kind) {
4452 case llvm::BitstreamEntry::Record:
4453 case llvm::BitstreamEntry::EndBlock:
4454 Error(
"invalid record at top-level of AST file");
4457 case llvm::BitstreamEntry::SubBlock:
4463 HaveReadControlBlock =
true;
4464 switch (ReadControlBlock(F, Loaded, ImportedBy, ClientLoadCapabilities)) {
4472 F.ModuleName.empty()) {
4474 if (Result != OutOfDate ||
4475 (ClientLoadCapabilities & ARR_OutOfDate) == 0)
4476 Diag(diag::err_module_file_not_module) << FileName;
4481 case Failure:
return Failure;
4482 case Missing:
return Missing;
4483 case OutOfDate:
return OutOfDate;
4484 case VersionMismatch:
return VersionMismatch;
4485 case ConfigurationMismatch:
return ConfigurationMismatch;
4486 case HadErrors:
return HadErrors;
4491 if (!HaveReadControlBlock) {
4492 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
4493 Diag(diag::err_pch_version_too_old);
4494 return VersionMismatch;
4498 Loaded.push_back(ImportedModule(M, ImportedBy, ImportLoc));
4499 ShouldFinalizePCM =
true;
4505 Error(
"malformed block record in AST file");
4510 Error(std::move(Err));
4517 llvm_unreachable(
"unexpected break; expected return");
4521 ASTReader::readUnhashedControlBlock(
ModuleFile &F,
bool WasImportedBy,
4522 unsigned ClientLoadCapabilities) {
4524 PP.getHeaderSearchInfo().getHeaderSearchOpts();
4525 bool AllowCompatibleConfigurationMismatch =
4528 ASTReadResult Result = readUnhashedControlBlockImpl(
4529 &F, F.
Data, ClientLoadCapabilities, AllowCompatibleConfigurationMismatch,
4535 if (DisableValidation || WasImportedBy ||
4536 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
4539 if (Result == Failure) {
4540 Error(
"malformed block record in AST file");
4563 if (getModuleManager().getModuleCache().isPCMFinal(F.
FileName)) {
4564 Diag(diag::warn_module_system_bit_conflict) << F.
FileName;
4573 ModuleFile *F, llvm::StringRef StreamData,
unsigned ClientLoadCapabilities,
4575 bool ValidateDiagnosticOptions) {
4577 BitstreamCursor Stream(StreamData);
4582 consumeError(std::move(Err));
4592 ASTReadResult Result = Success;
4597 consumeError(MaybeEntry.takeError());
4600 llvm::BitstreamEntry Entry = MaybeEntry.get();
4602 switch (Entry.Kind) {
4604 case llvm::BitstreamEntry::SubBlock:
4607 case llvm::BitstreamEntry::EndBlock:
4610 case llvm::BitstreamEntry::Record:
4618 if (!MaybeRecordType) {
4625 std::copy(Record.begin(), Record.end(), F->
Signature.data());
4628 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
4629 if (Listener && ValidateDiagnosticOptions &&
4630 !AllowCompatibleConfigurationMismatch &&
4631 ParseDiagnosticOptions(Record, Complain, *Listener))
4642 Record.begin(), Record.end());
4653 if (Record.size() < 4)
return true;
4658 unsigned BlockNameLen = Record[2];
4659 unsigned UserInfoLen = Record[3];
4661 if (BlockNameLen + UserInfoLen > Blob.size())
return true;
4663 Metadata.
BlockName = std::string(Blob.data(), Blob.data() + BlockNameLen);
4664 Metadata.
UserInfo = std::string(Blob.data() + BlockNameLen,
4665 Blob.data() + BlockNameLen + UserInfoLen);
4670 BitstreamCursor &Stream = F.
Stream;
4676 Error(MaybeEntry.takeError());
4679 llvm::BitstreamEntry Entry = MaybeEntry.get();
4681 switch (Entry.Kind) {
4682 case llvm::BitstreamEntry::SubBlock:
4684 Error(std::move(Err));
4689 case llvm::BitstreamEntry::EndBlock:
4695 case llvm::BitstreamEntry::Record:
4702 Stream.readRecord(Entry.ID, Record, &Blob);
4703 if (!MaybeRecCode) {
4704 Error(MaybeRecCode.takeError());
4707 switch (MaybeRecCode.get()) {
4714 auto Known = ModuleFileExtensions.find(Metadata.
BlockName);
4715 if (Known == ModuleFileExtensions.end())
break;
4718 if (
auto Reader = Known->second->createExtensionReader(Metadata, *
this,
4732 assert(ContextObj &&
"no context to initialize");
4736 if (DeserializationListener)
4746 if (!Context.CFConstantStringTypeDecl)
4753 Error(
"FILE type is NULL");
4757 if (!Context.FILEDecl) {
4763 Error(
"Invalid FILE type in AST file");
4772 QualType Jmp_bufType = GetType(Jmp_buf);
4773 if (Jmp_bufType.
isNull()) {
4774 Error(
"jmp_buf type is NULL");
4778 if (!Context.jmp_bufDecl) {
4784 Error(
"Invalid jmp_buf type in AST file");
4793 QualType Sigjmp_bufType = GetType(Sigjmp_buf);
4794 if (Sigjmp_bufType.
isNull()) {
4795 Error(
"sigjmp_buf type is NULL");
4799 if (!Context.sigjmp_bufDecl) {
4804 assert(Tag &&
"Invalid sigjmp_buf type in AST file");
4810 if (
unsigned ObjCIdRedef
4812 if (Context.ObjCIdRedefinitionType.
isNull())
4813 Context.ObjCIdRedefinitionType = GetType(ObjCIdRedef);
4816 if (
unsigned ObjCClassRedef
4818 if (Context.ObjCClassRedefinitionType.
isNull())
4819 Context.ObjCClassRedefinitionType = GetType(ObjCClassRedef);
4822 if (
unsigned ObjCSelRedef
4824 if (Context.ObjCSelRedefinitionType.
isNull())
4825 Context.ObjCSelRedefinitionType = GetType(ObjCSelRedef);
4829 QualType Ucontext_tType = GetType(Ucontext_t);
4830 if (Ucontext_tType.
isNull()) {
4831 Error(
"ucontext_t type is NULL");
4835 if (!Context.ucontext_tDecl) {
4840 assert(Tag &&
"Invalid ucontext_t type in AST file");
4850 if (!CUDASpecialDeclRefs.empty()) {
4851 assert(CUDASpecialDeclRefs.size() == 1 &&
"More decl refs than expected!");
4853 cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
4858 for (
auto &Import : ImportedModules) {
4859 if (
Module *Imported = getSubmodule(Import.ID)) {
4862 if (Import.ImportLoc.isValid())
4863 PP.makeModuleVisible(Imported, Import.ImportLoc);
4867 ImportedModules.clear();
4877 BitstreamCursor Stream(PCH);
4880 consumeError(std::move(Err));
4892 Stream.advanceSkippingSubblocks();
4895 consumeError(MaybeEntry.takeError());
4898 llvm::BitstreamEntry Entry = MaybeEntry.get();
4900 if (Entry.Kind != llvm::BitstreamEntry::Record)
4908 consumeError(MaybeRecord.takeError());
4912 return {{{(uint32_t)Record[0], (uint32_t)Record[1], (uint32_t)Record[2],
4913 (uint32_t)Record[3], (uint32_t)Record[4]}}};
4921 const std::string &ASTFileName,
FileManager &FileMgr,
4926 Diags.
Report(diag::err_fe_unable_to_read_pch_file)
4927 << ASTFileName << Buffer.getError().message();
4928 return std::string();
4932 BitstreamCursor Stream(PCHContainerRdr.
ExtractPCH(**Buffer));
4936 Diags.
Report(diag::err_fe_not_a_pch_file) << ASTFileName << std::move(Err);
4937 return std::string();
4942 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
4943 return std::string();
4950 Stream.advanceSkippingSubblocks();
4953 consumeError(MaybeEntry.takeError());
4954 return std::string();
4956 llvm::BitstreamEntry Entry = MaybeEntry.get();
4958 if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
4959 return std::string();
4961 if (Entry.Kind != llvm::BitstreamEntry::Record) {
4962 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
4963 return std::string();
4971 consumeError(MaybeRecord.takeError());
4972 return std::string();
4985 std::string ExistingModuleCachePath;
4989 SimplePCHValidator(
const LangOptions &ExistingLangOpts,
4992 StringRef ExistingModuleCachePath,
4994 : ExistingLangOpts(ExistingLangOpts),
4995 ExistingTargetOpts(ExistingTargetOpts),
4996 ExistingPPOpts(ExistingPPOpts),
4997 ExistingModuleCachePath(ExistingModuleCachePath),
5000 bool ReadLanguageOptions(
const LangOptions &LangOpts,
bool Complain,
5001 bool AllowCompatibleDifferences)
override {
5003 AllowCompatibleDifferences);
5006 bool ReadTargetOptions(
const TargetOptions &TargetOpts,
bool Complain,
5007 bool AllowCompatibleDifferences)
override {
5009 AllowCompatibleDifferences);
5013 StringRef SpecificModuleCachePath,
5014 bool Complain)
override {
5016 ExistingModuleCachePath,
5017 nullptr, ExistingLangOpts);
5022 std::string &SuggestedPredefines)
override {
5024 SuggestedPredefines, ExistingLangOpts);
5033 bool FindModuleFileExtensions,
5044 StringRef Bytes = PCHContainerRdr.
ExtractPCH(**Buffer);
5045 BitstreamCursor Stream(Bytes);
5049 consumeError(std::move(Err));
5060 BitstreamCursor InputFilesCursor;
5063 std::string ModuleDir;
5064 bool DoneWithControlBlock =
false;
5065 while (!DoneWithControlBlock) {
5069 consumeError(MaybeEntry.takeError());
5072 llvm::BitstreamEntry Entry = MaybeEntry.get();
5074 switch (Entry.Kind) {
5075 case llvm::BitstreamEntry::SubBlock: {
5078 std::string IgnoredSuggestedPredefines;
5079 if (ReadOptionsBlock(Stream, ARR_ConfigurationMismatch | ARR_OutOfDate,
5081 Listener, IgnoredSuggestedPredefines) != Success)
5087 InputFilesCursor = Stream;
5090 consumeError(std::move(Err));
5093 if (NeedsInputFiles &&
5101 consumeError(std::move(Err));
5110 case llvm::BitstreamEntry::EndBlock:
5111 DoneWithControlBlock =
true;
5117 case llvm::BitstreamEntry::Record:
5121 if (DoneWithControlBlock)
break;
5126 Stream.readRecord(Entry.ID, Record, &Blob);
5127 if (!MaybeRecCode) {
5146 auto Path = ReadString(Record, Idx);
5147 ResolveImportedPath(Path, ModuleDir);
5152 if (!NeedsInputFiles)
5155 unsigned NumInputFiles = Record[0];
5156 unsigned NumUserFiles = Record[1];
5157 const llvm::support::unaligned_uint64_t *InputFileOffs =
5158 (
const llvm::support::unaligned_uint64_t *)Blob.data();
5159 for (
unsigned I = 0; I != NumInputFiles; ++I) {
5161 bool isSystemFile = I >= NumUserFiles;
5163 if (isSystemFile && !NeedsSystemInputFiles)
5166 BitstreamCursor &
Cursor = InputFilesCursor;
5168 if (
llvm::Error Err = Cursor.JumpToBit(InputFileOffs[I])) {
5170 consumeError(std::move(Err));
5176 consumeError(MaybeCode.takeError());
5178 unsigned Code = MaybeCode.get();
5182 bool shouldContinue =
false;
5184 Cursor.readRecord(Code, Record, &Blob);
5185 if (!MaybeRecordType) {
5187 consumeError(MaybeRecordType.takeError());
5191 bool Overridden =
static_cast<bool>(Record[3]);
5192 std::string Filename = Blob;
5193 ResolveImportedPath(Filename, ModuleDir);
5195 Filename, isSystemFile, Overridden,
false);
5198 if (!shouldContinue)
5208 unsigned Idx = 0, N = Record.size();
5212 std::string ModuleName = ReadString(Record, Idx);
5213 std::string Filename = ReadString(Record, Idx);
5214 ResolveImportedPath(Filename, ModuleDir);
5227 if (FindModuleFileExtensions) {
5228 BitstreamCursor SavedStream = Stream;
5230 bool DoneWithExtensionBlock =
false;
5231 while (!DoneWithExtensionBlock) {
5237 llvm::BitstreamEntry Entry = MaybeEntry.get();
5239 switch (Entry.Kind) {
5240 case llvm::BitstreamEntry::SubBlock:
5243 consumeError(std::move(Err));
5248 case llvm::BitstreamEntry::EndBlock:
5249 DoneWithExtensionBlock =
true;
5255 case llvm::BitstreamEntry::Record:
5262 Stream.readRecord(Entry.ID, Record, &Blob);
5263 if (!MaybeRecCode) {
5267 switch (MaybeRecCode.get()) {
5279 Stream = SavedStream;
5283 if (readUnhashedControlBlockImpl(
5284 nullptr, Bytes, ARR_ConfigurationMismatch | ARR_OutOfDate,
5286 ValidateDiagnosticOptions) != Success)
5297 StringRef ExistingModuleCachePath) {
5298 SimplePCHValidator validator(LangOpts, TargetOpts, PPOpts,
5299 ExistingModuleCachePath, FileMgr);
5300 return !readASTFileControlBlock(Filename, FileMgr, PCHContainerRdr,
5307 ASTReader::ReadSubmoduleBlock(
ModuleFile &F,
unsigned ClientLoadCapabilities) {
5310 Error(std::move(Err));
5314 ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
5316 Module *CurrentModule =
nullptr;
5320 F.
Stream.advanceSkippingSubblocks();
5322 Error(MaybeEntry.takeError());
5325 llvm::BitstreamEntry Entry = MaybeEntry.get();
5327 switch (Entry.Kind) {
5328 case llvm::BitstreamEntry::SubBlock:
5330 Error(
"malformed block record in AST file");
5332 case llvm::BitstreamEntry::EndBlock:
5334 case llvm::BitstreamEntry::Record:
5344 Error(MaybeKind.takeError());
5347 unsigned Kind = MaybeKind.get();
5350 Error(
"submodule metadata record should be at beginning of block");
5366 if (Record.size() < 12) {
5367 Error(
"malformed module definition");
5371 StringRef Name = Blob;
5373 SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);
5376 bool IsFramework = Record[Idx++];
5377 bool IsExplicit = Record[Idx++];
5378 bool IsSystem = Record[Idx++];
5379 bool IsExternC = Record[Idx++];
5380 bool InferSubmodules = Record[Idx++];
5381 bool InferExplicitSubmodules = Record[Idx++];
5382 bool InferExportWildcard = Record[Idx++];
5383 bool ConfigMacrosExhaustive = Record[Idx++];
5384 bool ModuleMapIsPrivate = Record[Idx++];
5386 Module *ParentModule =
nullptr;
5388 ParentModule = getSubmodule(Parent);
5400 if (GlobalIndex >= SubmodulesLoaded.size() ||
5401 SubmodulesLoaded[GlobalIndex]) {
5402 Error(
"too many submodules");
5406 if (!ParentModule) {
5409 if (!PP.getPreprocessorOpts().DisablePCHValidation &&
5410 CurFile != F.
File) {
5411 if (!Diags.isDiagnosticInFlight()) {
5412 Diag(diag::err_module_file_conflict)
5414 << CurFile->getName()
5425 CurrentModule->
Kind = Kind;
5435 if (DeserializationListener)
5436 DeserializationListener->ModuleRead(GlobalID, CurrentModule);
5438 SubmodulesLoaded[GlobalIndex] = CurrentModule;
5461 ResolveImportedPath(F, Filename);
5462 if (
auto *Umbrella = PP.getFileManager().getFile(Filename)) {
5466 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
5467 Error(
"mismatched umbrella headers in submodule");
5493 std::string Dirname = Blob;
5494 ResolveImportedPath(F, Dirname);
5495 if (
auto *Umbrella = PP.getFileManager().getDirectory(Dirname)) {
5499 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
5500 Error(
"mismatched umbrella directories in submodule");
5510 unsigned LocalBaseSubmoduleID = Record[1];
5514 GlobalSubmoduleMap.insert(std::make_pair(getTotalNumSubmodules()+1,&F));
5519 std::make_pair(LocalBaseSubmoduleID,
5528 for (
unsigned Idx = 0; Idx != Record.size(); ++Idx) {
5530 Unresolved.File = &F;
5531 Unresolved.Mod = CurrentModule;
5532 Unresolved.ID = Record[Idx];
5533 Unresolved.Kind = UnresolvedModuleRef::Import;
5534 Unresolved.IsWildcard =
false;
5535 UnresolvedModuleRefs.push_back(Unresolved);
5540 for (
unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
5542 Unresolved.File = &F;
5543 Unresolved.Mod = CurrentModule;
5544 Unresolved.ID = Record[Idx];
5545 Unresolved.Kind = UnresolvedModuleRef::Export;
5546 Unresolved.IsWildcard = Record[Idx + 1];
5547 UnresolvedModuleRefs.push_back(Unresolved);
5557 PP.getTargetInfo());
5572 Unresolved.File = &F;
5573 Unresolved.Mod = CurrentModule;
5574 Unresolved.ID = Record[0];
5575 Unresolved.Kind = UnresolvedModuleRef::Conflict;
5576 Unresolved.IsWildcard =
false;
5577 Unresolved.String = Blob;
5578 UnresolvedModuleRefs.push_back(Unresolved);
5586 for (
auto &
ID : Record)
5587 Inits.push_back(getGlobalDeclID(F,
ID));
5588 ContextObj->addLazyModuleInitializers(CurrentModule, Inits);
5607 bool ASTReader::ParseLanguageOptions(
const RecordData &Record,
5610 bool AllowCompatibleDifferences) {
5613 #define LANGOPT(Name, Bits, Default, Description) \ 5614 LangOpts.Name = Record[Idx++]; 5615 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 5616 LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++])); 5617 #include "clang/Basic/LangOptions.def" 5618 #define SANITIZER(NAME, ID) \ 5619 LangOpts.Sanitize.set(SanitizerKind::ID, Record[Idx++]); 5620 #include "clang/Basic/Sanitizers.def" 5622 for (
unsigned N = Record[Idx++]; N; --N)
5626 VersionTuple runtimeVersion = ReadVersionTuple(Record, Idx);
5632 for (
unsigned N = Record[Idx++]; N; --N) {
5634 ReadString(Record, Idx));
5639 for (
unsigned N = Record[Idx++]; N; --N) {
5640 LangOpts.
OMPTargetTriples.push_back(llvm::Triple(ReadString(Record, Idx)));
5646 AllowCompatibleDifferences);
5649 bool ASTReader::ParseTargetOptions(
const RecordData &Record,
bool Complain,
5651 bool AllowCompatibleDifferences) {
5654 TargetOpts.
Triple = ReadString(Record, Idx);
5655 TargetOpts.
CPU = ReadString(Record, Idx);
5656 TargetOpts.
ABI = ReadString(Record, Idx);
5657 for (
unsigned N = Record[Idx++]; N; --N) {
5660 for (
unsigned N = Record[Idx++]; N; --N) {
5661 TargetOpts.
Features.push_back(ReadString(Record, Idx));
5665 AllowCompatibleDifferences);
5668 bool ASTReader::ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
5672 #define DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++]; 5673 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ 5674 DiagOpts->set##Name(static_cast<Type>(Record[Idx++])); 5675 #include "clang/Basic/DiagnosticOptions.def" 5677 for (
unsigned N = Record[Idx++]; N; --N)
5678 DiagOpts->Warnings.push_back(ReadString(Record, Idx));
5679 for (
unsigned N = Record[Idx++]; N; --N)
5680 DiagOpts->Remarks.push_back(ReadString(Record, Idx));
5685 bool ASTReader::ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
5693 bool ASTReader::ParseHeaderSearchOptions(
const RecordData &Record,
5698 HSOpts.
Sysroot = ReadString(Record, Idx);
5701 for (
unsigned N = Record[Idx++]; N; --N) {
5702 std::string Path = ReadString(Record, Idx);
5705 bool IsFramework = Record[Idx++];
5706 bool IgnoreSysRoot = Record[Idx++];
5707 HSOpts.
UserEntries.emplace_back(std::move(Path), Group, IsFramework,
5712 for (
unsigned N = Record[Idx++]; N; --N) {
5713 std::string Prefix = ReadString(Record, Idx);
5714 bool IsSystemHeader = Record[Idx++];
5728 std::string SpecificModuleCachePath = ReadString(Record, Idx);
5734 bool ASTReader::ParsePreprocessorOptions(
const RecordData &Record,
5737 std::string &SuggestedPredefines) {
5742 for (
unsigned N = Record[Idx++]; N; --N) {
5743 std::string Macro = ReadString(Record, Idx);
5744 bool IsUndef = Record[Idx++];
5745 PPOpts.
Macros.push_back(std::make_pair(Macro, IsUndef));
5749 for (
unsigned N = Record[Idx++]; N; --N) {
5750 PPOpts.
Includes.push_back(ReadString(Record, Idx));
5754 for (
unsigned N = Record[Idx++]; N; --N) {
5763 SuggestedPredefines.clear();
5765 SuggestedPredefines);
5768 std::pair<ModuleFile *, unsigned>
5769 ASTReader::getModulePreprocessedEntity(
unsigned GlobalIndex) {
5771 I = GlobalPreprocessedEntityMap.find(GlobalIndex);
5772 assert(I != GlobalPreprocessedEntityMap.end() &&
5773 "Corrupted global preprocessed entity map");
5776 return std::make_pair(M, LocalIndex);
5779 llvm::iterator_range<PreprocessingRecord::iterator>
5780 ASTReader::getModulePreprocessedEntities(
ModuleFile &Mod)
const {
5789 llvm::iterator_range<ASTReader::ModuleDeclIterator>
5791 return llvm::make_range(
5798 auto I = GlobalSkippedRangeMap.find(GlobalIndex);
5799 assert(I != GlobalSkippedRangeMap.end() &&
5800 "Corrupted global skipped range map");
5803 assert(LocalIndex < M->NumPreprocessedSkippedRanges);
5804 PPSkippedRange RawRange = M->PreprocessedSkippedRangeOffsets[LocalIndex];
5806 TranslateSourceLocation(*M, RawRange.
getEnd()));
5813 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
5815 unsigned LocalIndex = PPInfo.second;
5818 if (!PP.getPreprocessingRecord()) {
5819 Error(
"no preprocessing record");
5826 Error(std::move(Err));
5833 Error(MaybeEntry.takeError());
5836 llvm::BitstreamEntry Entry = MaybeEntry.get();
5838 if (Entry.Kind != llvm::BitstreamEntry::Record)
5843 TranslateSourceLocation(M, PPOffs.
getEnd()));
5849 if (!MaybeRecType) {
5850 Error(MaybeRecType.takeError());
5855 bool isBuiltin = Record[0];
5859 Name = getLocalIdentifier(M, Record[1]);
5862 getGlobalPreprocessedEntityID(M, Record[1]);
5863 Def = cast<MacroDefinitionRecord>(
5864 PPRec.getLoadedPreprocessedEntity(GlobalID - 1));
5882 if (DeserializationListener)
5883 DeserializationListener->MacroDefinitionRead(PPID, MD);
5889 const char *FullFileNameStart = Blob.data() + Record[0];
5890 StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]);
5892 if (!FullFileName.empty())
5893 File = PP.getFileManager().getFile(FullFileName);
5900 StringRef(Blob.data(), Record[0]),
5901 Record[1], Record[3],
5908 llvm_unreachable(
"Invalid PreprocessorDetailRecordTypes");
5918 GlobalSLocOffsetMapType::const_iterator SLocMapI)
const {
5920 for (GlobalSLocOffsetMapType::const_iterator
5921 EndI = GlobalSLocOffsetMap.end(); SLocMapI != EndI; ++SLocMapI) {
5927 return getTotalNumPreprocessedEntities();
5932 struct PPEntityComp {
5962 bool EndsAfter)
const {
5963 if (SourceMgr.isLocalSourceLocation(Loc))
5964 return getTotalNumPreprocessedEntities();
5966 GlobalSLocOffsetMapType::const_iterator SLocMapI = GlobalSLocOffsetMap.find(
5967 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
5968 assert(SLocMapI != GlobalSLocOffsetMap.end() &&
5969 "Corrupted global sloc offset map");
5971 if (SLocMapI->second->NumPreprocessedEntities == 0)
5972 return findNextPreprocessedEntity(SLocMapI);
5983 pp_iterator
First = pp_begin;
5987 PPI = std::upper_bound(pp_begin, pp_end, Loc,
5988 PPEntityComp(*
this, M));
5997 std::advance(PPI, Half);
5998 if (SourceMgr.isBeforeInTranslationUnit(
5999 TranslateSourceLocation(M, PPI->getEnd()), Loc)) {
6002 Count = Count - Half - 1;
6009 return findNextPreprocessedEntity(SLocMapI);
6016 std::pair<unsigned, unsigned>
6019 return std::make_pair(0,0);
6020 assert(!SourceMgr.isBeforeInTranslationUnit(Range.
getEnd(),Range.
getBegin()));
6023 findPreprocessedEntity(Range.
getBegin(),
false);
6025 return std::make_pair(BeginID, EndID);
6035 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
6037 unsigned LocalIndex = PPInfo.second;
6044 if (SourceMgr.isInFileID(SourceMgr.getFileLoc(Loc), FID))
6053 class HeaderFileInfoVisitor {
6058 explicit HeaderFileInfoVisitor(
const FileEntry *FE) : FE(FE) {}
6067 HeaderFileInfoLookupTable::iterator Pos = Table->find(FE);
6068 if (Pos == Table->end())
6081 HeaderFileInfoVisitor Visitor(FE);
6082 ModuleMgr.visit(Visitor);
6090 using DiagState = DiagnosticsEngine::DiagState;
6101 auto ReadDiagState =
6103 bool IncludeNonPragmaStates) -> DiagnosticsEngine::DiagState * {
6104 unsigned BackrefID = Record[Idx++];
6106 return DiagStates[BackrefID - 1];
6109 Diag.DiagStates.push_back(BasedOn);
6110 DiagState *NewState = &Diag.DiagStates.back();
6111 DiagStates.push_back(NewState);
6112 unsigned Size = Record[Idx++];
6113 assert(Idx + Size * 2 <= Record.size() &&
6114 "Invalid data, not enough diag/map pairs");
6116 unsigned DiagID = Record[Idx++];
6119 if (!NewMapping.
isPragma() && !IncludeNonPragmaStates)
6132 Mapping = NewMapping;
6138 DiagState *FirstState;
6143 FirstState = Diag.DiagStatesByLoc.FirstDiagState;
6144 DiagStates.push_back(FirstState);
6147 assert(Record[1] == 0 &&
6148 "Invalid data, unexpected backref in initial state");
6149 Idx = 3 + Record[2] * 2;
6150 assert(Idx < Record.size() &&
6151 "Invalid data, not enough state change pairs in initial state");
6156 unsigned Flags = Record[Idx++];
6158 Initial.SuppressSystemWarnings = Flags & 1; Flags >>= 1;
6159 Initial.ErrorsAsFatal = Flags & 1; Flags >>= 1;
6160 Initial.WarningsAsErrors = Flags & 1; Flags >>= 1;
6161 Initial.EnableAllWarnings = Flags & 1; Flags >>= 1;
6162 Initial.IgnoreAllWarnings = Flags & 1; Flags >>= 1;
6172 .StateTransitions.push_back({FirstState, 0});
6177 FirstState = ReadDiagState(*Diag.DiagStatesByLoc.CurDiagState,
6182 unsigned NumLocations = Record[Idx++];
6183 while (NumLocations--) {
6184 assert(Idx < Record.size() &&
6185 "Invalid data, missing pragma diagnostic states");
6187 auto IDAndOffset = SourceMgr.getDecomposedLoc(Loc);
6188 assert(IDAndOffset.first.isValid() &&
"invalid FileID for transition");
6189 assert(IDAndOffset.second == 0 &&
"not a start location for a FileID");
6190 unsigned Transitions = Record[Idx++];
6196 auto &F = Diag.DiagStatesByLoc.Files[IDAndOffset.first];
6197 F.StateTransitions.reserve(F.StateTransitions.size() + Transitions);
6198 for (
unsigned I = 0; I != Transitions; ++I) {
6199 unsigned Offset = Record[Idx++];
6201 ReadDiagState(*FirstState, Loc.getLocWithOffset(Offset),
false);
6202 F.StateTransitions.push_back({
State, Offset});
6207 assert(Idx < Record.size() &&
6208 "Invalid data, missing final pragma diagnostic state");
6211 auto *CurState = ReadDiagState(*FirstState, CurStateLoc,
false);
6214 Diag.DiagStatesByLoc.CurDiagState = CurState;
6215 Diag.DiagStatesByLoc.CurDiagStateLoc = CurStateLoc;
6220 auto &T = Diag.DiagStatesByLoc.Files[NullFile].StateTransitions;
6222 T.push_back({CurState, 0});
6224 T[0].State = CurState;
6233 ASTReader::RecordLocation ASTReader::TypeCursorForIndex(
unsigned Index) {
6235 assert(I != GlobalTypeMap.end() &&
"Corrupted global type map");
6237 return RecordLocation(M, M->TypeOffsets[Index - M->BaseTypeIndex]);
6246 QualType ASTReader::readTypeRecord(
unsigned Index) {
6247 assert(ContextObj &&
"reading type with no AST context");
6249 RecordLocation Loc = TypeCursorForIndex(Index);
6250 BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
6256 ReadingKindTracker ReadingKind(Read_Type, *
this);
6262 if (
llvm::Error Err = DeclsCursor.JumpToBit(Loc.Offset)) {
6263 Error(std::move(Err));
6269 Error(MaybeCode.takeError());
6272 unsigned Code = MaybeCode.get();
6275 if (!MaybeTypeCode) {
6276 Error(MaybeTypeCode.takeError());
6279 switch ((
TypeCode)MaybeTypeCode.get()) {
6281 if (Record.size() != 2) {
6282 Error(
"Incorrect encoding of extended qualifier type");
6291 if (Record.size() != 1) {
6292 Error(
"Incorrect encoding of complex type");
6295 QualType ElemType = readType(*Loc.F, Record, Idx);
6300 if (Record.size() != 1) {
6301 Error(
"Incorrect encoding of pointer type");
6304 QualType PointeeType = readType(*Loc.F, Record, Idx);
6309 if (Record.size() != 1) {
6310 Error(
"Incorrect encoding of decayed type");
6313 QualType OriginalType = readType(*Loc.F, Record, Idx);
6315 if (!isa<DecayedType>(DT))
6316 Error(
"Decayed type does not decay");
6321 if (Record.size() != 2) {
6322 Error(
"Incorrect encoding of adjusted type");
6325 QualType OriginalTy = readType(*Loc.F, Record, Idx);
6326 QualType AdjustedTy = readType(*Loc.F, Record, Idx);
6331 if (Record.size() != 1) {
6332 Error(
"Incorrect encoding of block pointer type");
6335 QualType PointeeType = readType(*Loc.F, Record, Idx);
6340 if (Record.size() != 2) {
6341 Error(
"Incorrect encoding of lvalue reference type");
6344 QualType PointeeType = readType(*Loc.F, Record, Idx);
6349 if (Record.size() != 1) {
6350 Error(
"Incorrect encoding of rvalue reference type");
6353 QualType PointeeType = readType(*Loc.F, Record, Idx);
6358 if (Record.size() != 2) {
6359 Error(
"Incorrect encoding of member pointer type");
6362 QualType PointeeType = readType(*Loc.F, Record, Idx);
6363 QualType ClassType = readType(*Loc.F, Record, Idx);
6371 QualType ElementType = readType(*Loc.F, Record, Idx);
6373 unsigned IndexTypeQuals = Record[2];
6375 llvm::APInt Size = ReadAPInt(Record, Idx);
6377 ASM, IndexTypeQuals);
6381 QualType ElementType = readType(*Loc.F, Record, Idx);
6383 unsigned IndexTypeQuals = Record[2];
6388 QualType ElementType = readType(*Loc.F, Record, Idx);
6390 unsigned IndexTypeQuals = Record[2];
6394 ASM, IndexTypeQuals,
6399 if (Record.size() != 3) {
6400 Error(
"incorrect encoding of vector type in AST file");
6404 QualType ElementType = readType(*Loc.F, Record, Idx);
6405 unsigned NumElements = Record[1];
6406 unsigned VecKind = Record[2];
6412 if (Record.size() != 3) {
6413 Error(
"incorrect encoding of extended vector type in AST file");
6417 QualType ElementType = readType(*Loc.F, Record, Idx);
6418 unsigned NumElements = Record[1];
6423 if (Record.size() != 8) {
6424 Error(
"incorrect encoding of no-proto function type");
6427 QualType ResultType = readType(*Loc.F, Record, Idx);
6435 QualType ResultType = readType(*Loc.F, Record, Idx);
6441 static_cast<CallingConv>(Record[4]),
6453 readExceptionSpec(*Loc.F, ExceptionStorage, EPI.
ExceptionSpec, Record, Idx);
6455 unsigned NumParams = Record[Idx++];
6457 for (
unsigned I = 0; I != NumParams; ++I)
6458 ParamTypes.push_back(readType(*Loc.F, Record, Idx));
6461 if (Idx != Record.size()) {
6462 for (
unsigned I = 0; I != NumParams; ++I)
6463 ExtParameterInfos.push_back(
6465 ::getFromOpaqueValue(Record[Idx++]));
6469 assert(Idx == Record.size());
6477 ReadDeclAs<UnresolvedUsingTypenameDecl>(*Loc.F, Record, Idx));
6481 if (Record.size() != 2) {
6482 Error(
"incorrect encoding of typedef type");
6487 QualType Canonical = readType(*Loc.F, Record, Idx);
6488 if (!Canonical.isNull())
6497 if (Record.size() != 1) {
6498 Error(
"incorrect encoding of typeof(type) in AST file");
6501 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
6506 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
6511 QualType BaseType = readType(*Loc.F, Record, Idx);
6512 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
6518 QualType Deduced = readType(*Loc.F, Record, Idx);
6520 bool IsDependent =
false, IsPack =
false;
6522 IsDependent = Record[Idx] > 0;
6523 IsPack = Record[Idx] > 1;
6526 return Context.
getAutoType(Deduced, Keyword, IsDependent, IsPack);
6530 TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx);
6531 QualType Deduced = readType(*Loc.F, Record, Idx);
6532 bool IsDependent = Deduced.
isNull() ? Record[Idx++] :
false;
6538 if (Record.size() != 2) {
6539 Error(
"incorrect encoding of record type");
6543 bool IsDependent = Record[Idx++];
6544 RecordDecl *RD = ReadDeclAs<RecordDecl>(*Loc.F, Record, Idx);
6545 RD = cast_or_null<RecordDecl>(RD->getCanonicalDecl());
6547 const_cast<Type*
>(T.getTypePtr())->setDependent(IsDependent);
6552 if (Record.size() != 2) {
6553 Error(
"incorrect encoding of enum type");
6557 bool IsDependent = Record[Idx++];
6559 = Context.
getEnumType(ReadDeclAs<EnumDecl>(*Loc.F, Record, Idx));
6565 if (Record.size() != 3) {
6566 Error(
"incorrect encoding of attributed type");
6569 QualType modifiedType = readType(*Loc.F, Record, Idx);
6570 QualType equivalentType = readType(*Loc.F, Record, Idx);
6576 if (Record.size() != 1) {
6577 Error(
"incorrect encoding of paren type");
6580 QualType InnerType = readType(*Loc.F, Record, Idx);
6585 if (Record.size() != 2) {
6586 Error(
"incorrect encoding of macro defined type");
6589 QualType UnderlyingTy = readType(*Loc.F, Record, Idx);
6590 IdentifierInfo *MacroII = GetIdentifierInfo(*Loc.F, Record, Idx);
6595 if (Record.size() != 2) {
6596 Error(
"incorrect encoding of pack expansion type");
6599 QualType Pattern = readType(*Loc.F, Record, Idx);
6604 NumExpansions = Record[1] - 1;
6612 QualType NamedType = readType(*Loc.F, Record, Idx);
6613 TagDecl *OwnedTagDecl = ReadDeclAs<TagDecl>(*Loc.F, Record, Idx);
6620 = ReadDeclAs<ObjCInterfaceDecl>(*Loc.F, Record, Idx);
6627 = ReadDeclAs<ObjCTypeParamDecl>(*Loc.F, Record, Idx);
6628 unsigned NumProtos = Record[Idx++];
6630 for (
unsigned I = 0; I != NumProtos; ++I)
6631 Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
6638 unsigned NumTypeArgs = Record[Idx++];
6640 for (
unsigned I = 0; I != NumTypeArgs; ++I)
6641 TypeArgs.push_back(readType(*Loc.F, Record, Idx));
6642 unsigned NumProtos = Record[Idx++];
6644 for (
unsigned I = 0; I != NumProtos; ++I)
6645 Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
6646 bool IsKindOf = Record[Idx++];
6652 QualType Pointee = readType(*Loc.F, Record, Idx);
6658 QualType Parm = readType(*Loc.F, Record, Idx);
6659 QualType Replacement = readType(*Loc.F, Record, Idx);
6661 cast<TemplateTypeParmType>(Parm),
6667 QualType Parm = readType(*Loc.F, Record, Idx);
6670 cast<TemplateTypeParmType>(Parm),
6675 CXXRecordDecl *D = ReadDeclAs<CXXRecordDecl>(*Loc.F, Record, Idx);
6676 QualType TST = readType(*Loc.F, Record, Idx);
6679 const Type *T =
nullptr;
6681 if (
const Type *Existing = DI->getTypeForDecl()) {
6689 DI->setTypeForDecl(T);
6696 unsigned Depth = Record[Idx++];
6697 unsigned Index = Record[Idx++];
6698 bool Pack = Record[Idx++];
6700 = ReadDeclAs<TemplateTypeParmDecl>(*Loc.F, Record, Idx);
6708 const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx);
6709 QualType Canon = readType(*Loc.F, Record, Idx);
6719 const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx);
6720 unsigned NumArgs = Record[Idx++];
6722 Args.reserve(NumArgs);
6724 Args.push_back(ReadTemplateArgument(*Loc.F, Record, Idx));
6733 QualType ElementType = readType(*Loc.F, Record, Idx);
6736 unsigned IndexTypeQuals = Record[Idx++];
6739 Expr *NumElts = ReadExpr(*Loc.F);
6740 SourceRange Brackets = ReadSourceRange(*Loc.F, Record, Idx);
6743 IndexTypeQuals, Brackets);
6748 bool IsDependent = Record[Idx++];
6749 TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx);
6751 ReadTemplateArgumentList(Args, *Loc.F, Record, Idx);
6752 QualType Underlying = readType(*Loc.F, Record, Idx);
6763 if (Record.size() != 1) {
6764 Error(
"Incorrect encoding of atomic type");
6767 QualType ValueType = readType(*Loc.F, Record, Idx);
6772 if (Record.size() != 2) {
6773 Error(
"Incorrect encoding of pipe type");
6778 QualType ElementType = readType(*Loc.F, Record, Idx);
6779 unsigned ReadOnly = Record[1];
6780 return Context.getPipeType(ElementType, ReadOnly);
6785 QualType ElementType = readType(*Loc.F, Record, Idx);
6786 Expr *SizeExpr = ReadExpr(*Loc.F);
6787 SourceLocation AttrLoc = ReadSourceLocation(*Loc.F, Record, Idx);
6788 unsigned VecKind = Record[Idx];
6798 QualType ElementType = readType(*Loc.F, Record, Idx);
6799 Expr *SizeExpr = ReadExpr(*Loc.F);
6800 SourceLocation AttrLoc = ReadSourceLocation(*Loc.F, Record, Idx);
6810 QualType PointeeType = readType(*Loc.F, Record, Idx);
6811 Expr *AddrSpaceExpr = ReadExpr(*Loc.F);
6812 SourceLocation AttrLoc = ReadSourceLocation(*Loc.F, Record, Idx);
6818 llvm_unreachable(
"Invalid TypeCode!");
6829 for (
unsigned I = 0, N = Record[Idx++]; I != N; ++I)
6830 Exceptions.push_back(readType(ModuleFile, Record, Idx));
6835 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6836 ESI.
SourceTemplate = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6838 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6863 return Reader->
ReadAttr(*F, Record, Idx);
6869 : F(&F), Reader(&Reader), Record(Record), Idx(Idx) {}
6874 #define ABSTRACT_TYPELOC(CLASS, PARENT) 6875 #define TYPELOC(CLASS, PARENT) \ 6876 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc); 6877 #include "clang/AST/TypeLocNodes.def" 6946 VisitArrayTypeLoc(TL);
6950 VisitArrayTypeLoc(TL);
6954 VisitArrayTypeLoc(TL);
6957 void TypeLocReader::VisitDependentSizedArrayTypeLoc(
6959 VisitArrayTypeLoc(TL);
6962 void TypeLocReader::VisitDependentAddressSpaceTypeLoc(
6967 range.
setBegin(ReadSourceLocation());
6968 range.
setEnd(ReadSourceLocation());
6973 void TypeLocReader::VisitDependentSizedExtVectorTypeLoc(
6982 void TypeLocReader::VisitDependentVectorTypeLoc(
6996 Reader->ReadSourceLocation(*F, Record, Idx)));
7004 VisitFunctionTypeLoc(TL);
7008 VisitFunctionTypeLoc(TL);
7043 void TypeLocReader::VisitAutoTypeLoc(
AutoTypeLoc TL) {
7047 void TypeLocReader::VisitDeducedTemplateSpecializationTypeLoc(
7056 void TypeLocReader::VisitEnumTypeLoc(
EnumTypeLoc TL) {
7068 void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
7073 void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
7078 void TypeLocReader::VisitTemplateSpecializationTypeLoc(
7087 Reader->GetTemplateArgumentLocInfo(
7091 void TypeLocReader::VisitParenTypeLoc(
ParenTypeLoc TL) {
7111 void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc(
7119 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I)
7122 Reader->GetTemplateArgumentLocInfo(
7165 void TypeLocReader::VisitPipeTypeLoc(
PipeTypeLoc TL) {
7179 QualType InfoTy = readType(F, Record, Idx);
7183 TypeSourceInfo *TInfo = getContext().CreateTypeSourceInfo(InfoTy);
7184 ReadTypeLoc(F, Record, Idx, TInfo->
getTypeLoc());
7189 assert(ContextObj &&
"reading type with no AST context");
7376 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 7377 case PREDEF_TYPE_##Id##_ID: \ 7378 T = Context.SingletonId; \ 7380 #include "clang/Basic/OpenCLImageTypes.def" 7381 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 7382 case PREDEF_TYPE_##Id##_ID: \ 7383 T = Context.Id##Ty; \ 7385 #include "clang/Basic/OpenCLExtensionTypes.def" 7418 assert(!T.
isNull() &&
"Unknown predefined type");
7423 assert(Index < TypesLoaded.size() &&
"Type index out-of-range");
7424 if (TypesLoaded[Index].isNull()) {
7425 TypesLoaded[Index] = readTypeRecord(Index);
7426 if (TypesLoaded[Index].isNull())
7429 TypesLoaded[Index]->setFromAST();
7430 if (DeserializationListener)
7432 TypesLoaded[Index]);
7435 return TypesLoaded[Index].withFastQualifiers(FastQuals);
7439 return GetType(getGlobalTypeID(F, LocalID));
7451 ReadModuleOffsetMap(F);
7455 assert(I != F.
TypeRemap.
end() &&
"Invalid index into type index remap");
7457 unsigned GlobalIndex = LocalIndex + I->second;
7458 return (GlobalIndex << Qualifiers::FastWidth) | FastQuals;
7470 return GetTypeSourceInfo(F, Record, Index);
7474 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
7481 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
7482 SourceLocation EllipsisLoc = ReadSourceLocation(F, Record, Index);
7494 llvm_unreachable(
"unexpected template argument loc");
7503 if (Record[Index++])
7516 unsigned NumArgsAsWritten = Record[Index++];
7518 for (
unsigned i = 0;
i != NumArgsAsWritten; ++
i)
7519 TemplArgsInfo.
addArgument(ReadTemplateArgumentLoc(F, Record, Index));
7528 if (NumCurrentElementsDeserializing) {
7533 PendingIncompleteDeclChains.push_back(const_cast<Decl*>(D));
7544 if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC) ||
7545 isa<CXXRecordDecl>(DC) || isa<EnumDecl>(DC)) {
7547 if (!getContext().getLangOpts().
CPlusPlus &&
7548 isa<TranslationUnitDecl>(DC)) {
7552 auto *II = Name.getAsIdentifierInfo();
7553 assert(II &&
"non-identifier name in C?");
7554 if (II->isOutOfDate())
7555 updateOutOfDateIdentifier(*II);
7561 auto *DC = cast<DeclContext>(DCDecl);
7563 FindExternalLexicalDecls(
7569 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D))
7570 CTSD->getSpecializedTemplate()->LoadLazySpecializations();
7571 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D))
7572 VTSD->getSpecializedTemplate()->LoadLazySpecializations();
7573 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
7574 if (
auto *Template = FD->getPrimaryTemplate())
7575 Template->LoadLazySpecializations();
7581 RecordLocation Loc = getLocalBitOffset(Offset);
7582 BitstreamCursor &
Cursor = Loc.F->DeclsCursor;
7584 if (
llvm::Error Err = Cursor.JumpToBit(Loc.Offset)) {
7585 Error(std::move(Err));
7588 ReadingKindTracker ReadingKind(Read_Decl, *
this);
7593 Error(MaybeCode.takeError());
7596 unsigned Code = MaybeCode.get();
7599 if (!MaybeRecCode) {
7600 Error(MaybeRecCode.takeError());
7604 Error(
"malformed AST file: missing C++ ctor initializers");
7609 return ReadCXXCtorInitializers(*Loc.F, Record, Idx);
7613 assert(ContextObj &&
"reading base specifiers with no AST context");
7616 RecordLocation Loc = getLocalBitOffset(Offset);
7617 BitstreamCursor &
Cursor = Loc.F->DeclsCursor;
7619 if (
llvm::Error Err = Cursor.JumpToBit(Loc.Offset)) {
7620 Error(std::move(Err));
7623 ReadingKindTracker ReadingKind(Read_Decl, *
this);
7628 Error(MaybeCode.takeError());
7631 unsigned Code = MaybeCode.get();
7634 if (!MaybeRecCode) {
7635 Error(MaybeCode.takeError());
7638 unsigned RecCode = MaybeRecCode.get();
7641 Error(
"malformed AST file: missing C++ base specifiers");
7646 unsigned NumBases = Record[Idx++];
7649 for (
unsigned I = 0; I != NumBases; ++I)
7650 Bases[I] = ReadCXXBaseSpecifier(*Loc.F, Record, Idx);
7660 ReadModuleOffsetMap(F);
7664 assert(I != F.
DeclRemap.
end() &&
"Invalid index into decl index remap");
7666 return LocalID + I->second;
7670 ModuleFile &M)
const {
7683 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
7693 if (Index > DeclsLoaded.size()) {
7694 Error(
"declaration ID out-of-range for AST file");
7698 if (
Decl *D = DeclsLoaded[Index])
7699 return D->getLocation();
7702 DeclCursorForID(ID, Loc);
7759 llvm_unreachable(
"PredefinedDeclIDs unknown enum value");
7763 assert(ContextObj &&
"reading decl with no AST context");
7771 Merged.push_back(ID);
7778 if (Index >= DeclsLoaded.size()) {
7779 assert(0 &&
"declaration ID out-of-range for AST file");
7780 Error(
"declaration ID out-of-range for AST file");
7784 return DeclsLoaded[Index];
7789 return GetExistingDecl(ID);
7793 if (Index >= DeclsLoaded.size()) {
7794 assert(0 &&
"declaration ID out-of-range for AST file");
7795 Error(
"declaration ID out-of-range for AST file");
7799 if (!DeclsLoaded[Index]) {
7801 if (DeserializationListener)
7802 DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);
7805 return DeclsLoaded[Index];
7814 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
7815 ModuleFile *Owner = I->second;
7817 llvm::DenseMap<ModuleFile *, serialization::DeclID>::iterator Pos
7822 return GlobalID - Owner->BaseDeclID + Pos->second;
7828 if (Idx >= Record.size()) {
7829 Error(
"Corrupted AST file");
7833 return getGlobalDeclID(F, Record[Idx++]);
7843 ClearSwitchCaseIDs();
7846 RecordLocation Loc = getLocalBitOffset(Offset);
7847 if (
llvm::Error Err = Loc.F->DeclsCursor.JumpToBit(Loc.Offset)) {
7848 Error(std::move(Err));
7851 assert(NumCurrentElementsDeserializing == 0 &&
7852 "should not be called while already deserializing");
7854 return ReadStmtFromStream(*Loc.F);
7863 assert(LexicalDecls.size() % 2 == 0 &&
"expected an even number of entries");
7864 for (
int I = 0, N = LexicalDecls.size(); I != N; I += 2) {
7866 if (!IsKindWeWant(K))
7874 if (PredefsVisited[
ID])
7877 PredefsVisited[
ID] =
true;
7880 if (
Decl *D = GetLocalDecl(*M,
ID)) {
7881 assert(D->getKind() == K &&
"wrong kind for lexical decl");
7888 if (isa<TranslationUnitDecl>(DC)) {
7889 for (
auto Lexical : TULexicalDecls)
7890 Visit(Lexical.first, Lexical.second);
7892 auto I = LexicalDecls.find(DC);
7893 if (I != LexicalDecls.end())
7894 Visit(I->second.first, I->second.second);
7897 ++NumLexicalDeclContextsRead;
7907 DeclIDComp(
ASTReader &Reader, ModuleFile &M) : Reader(Reader), Mod(M) {}
7934 unsigned Offset,
unsigned Length,
7938 llvm::DenseMap<FileID, FileDeclsInfo>::iterator I = FileDeclIDs.find(File);
7939 if (I == FileDeclIDs.end())
7942 FileDeclsInfo &DInfo = I->second;
7943 if (DInfo.Decls.empty())
7950 DeclIDComp DIDComp(*
this, *DInfo.Mod);
7952 llvm::lower_bound(DInfo.Decls, BeginLoc, DIDComp);
7953 if (BeginIt != DInfo.Decls.begin())
7959 while (BeginIt != DInfo.Decls.begin() &&
7960 GetDecl(getGlobalDeclID(*DInfo.Mod, *BeginIt))
7961 ->isTopLevelDeclInObjCContainer())
7965 llvm::upper_bound(DInfo.Decls, EndLoc, DIDComp);
7966 if (EndIt != DInfo.Decls.end())
7970 DIt = BeginIt; DIt != EndIt; ++DIt)
7971 Decls.push_back(GetDecl(getGlobalDeclID(*DInfo.Mod, *DIt)));
7978 "DeclContext has no visible decls in storage");
7982 auto It = Lookups.find(DC);
7983 if (It == Lookups.end())
7990 for (
DeclID ID : It->second.Table.find(Name)) {
7993 Decls.push_back(ND);
7996 ++NumVisibleDeclContextsRead;
7997 SetExternalVisibleDeclsForName(DC, Name, Decls);
7998 return !Decls.empty();
8005 auto It = Lookups.find(DC);
8006 assert(It != Lookups.end() &&
8007 "have external visible storage but no lookup tables");
8011 for (
DeclID ID : It->second.Table.findAll()) {
8016 ++NumVisibleDeclContextsRead;
8018 for (DeclsMap::iterator I = Decls.begin(), E = Decls.end(); I != E; ++I) {
8019 SetExternalVisibleDeclsForName(DC, I->first, I->second);
8021 const_cast<DeclContext *
>(DC)->setHasExternalVisibleStorage(
false);
8026 auto I = Lookups.find(Primary);
8027 return I == Lookups.end() ? nullptr : &I->second;
8036 assert(ImplD && Consumer);
8038 for (
auto *I : ImplD->
methods())
8044 void ASTReader::PassInterestingDeclToConsumer(
Decl *D) {
8052 this->Consumer = Consumer;
8055 PassInterestingDeclsToConsumer();
8057 if (DeserializationListener)
8058 DeserializationListener->ReaderInitialized(
this);
8062 std::fprintf(stderr,
"*** AST File Statistics:\n");
8064 unsigned NumTypesLoaded
8065 = TypesLoaded.size() - std::count(TypesLoaded.begin(), TypesLoaded.end(),
8067 unsigned NumDeclsLoaded
8068 = DeclsLoaded.size() - std::count(DeclsLoaded.begin(), DeclsLoaded.end(),
8070 unsigned NumIdentifiersLoaded
8071 = IdentifiersLoaded.size() - std::count(IdentifiersLoaded.begin(),
8072 IdentifiersLoaded.end(),
8074 unsigned NumMacrosLoaded
8075 = MacrosLoaded.size() - std::count(MacrosLoaded.begin(),
8078 unsigned NumSelectorsLoaded
8079 = SelectorsLoaded.size() - std::count(SelectorsLoaded.begin(),
8080 SelectorsLoaded.end(),
8083 if (
unsigned TotalNumSLocEntries = getTotalNumSLocs())
8084 std::fprintf(stderr,
" %u/%u source location entries read (%f%%)\n",
8085 NumSLocEntriesRead, TotalNumSLocEntries,
8086 ((
float)NumSLocEntriesRead/TotalNumSLocEntries * 100));
8087 if (!TypesLoaded.empty())
8088 std::fprintf(stderr,
" %u/%u types read (%f%%)\n",
8089 NumTypesLoaded, (
unsigned)TypesLoaded.size(),
8090 ((float)NumTypesLoaded/TypesLoaded.size() * 100));
8091 if (!DeclsLoaded.empty())
8092 std::fprintf(stderr,
" %u/%u declarations read (%f%%)\n",
8093 NumDeclsLoaded, (
unsigned)DeclsLoaded.size(),
8094 ((float)NumDeclsLoaded/DeclsLoaded.size() * 100));
8095 if (!IdentifiersLoaded.empty())
8096 std::fprintf(stderr,
" %u/%u identifiers read (%f%%)\n",
8097 NumIdentifiersLoaded, (
unsigned)IdentifiersLoaded.size(),
8098 ((float)NumIdentifiersLoaded/IdentifiersLoaded.size() * 100));
8099 if (!MacrosLoaded.empty())
8100 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
8101 NumMacrosLoaded, (
unsigned)MacrosLoaded.size(),
8102 ((float)NumMacrosLoaded/MacrosLoaded.size() * 100));
8103 if (!SelectorsLoaded.empty())
8104 std::fprintf(stderr,
" %u/%u selectors read (%f%%)\n",
8105 NumSelectorsLoaded, (
unsigned)SelectorsLoaded.size(),
8106 ((float)NumSelectorsLoaded/SelectorsLoaded.size() * 100));
8107 if (TotalNumStatements)
8108 std::fprintf(stderr,
" %u/%u statements read (%f%%)\n",
8109 NumStatementsRead, TotalNumStatements,
8110 ((
float)NumStatementsRead/TotalNumStatements * 100));
8112 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
8113 NumMacrosRead, TotalNumMacros,
8114 ((
float)NumMacrosRead/TotalNumMacros * 100));
8115 if (TotalLexicalDeclContexts)
8116 std::fprintf(stderr,
" %u/%u lexical declcontexts read (%f%%)\n",
8117 NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
8118 ((
float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts
8120 if (TotalVisibleDeclContexts)
8121 std::fprintf(stderr,
" %u/%u visible declcontexts read (%f%%)\n",
8122 NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
8123 ((
float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
8125 if (TotalNumMethodPoolEntries)
8126 std::fprintf(stderr,
" %u/%u method pool entries read (%f%%)\n",
8127 NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
8128 ((
float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
8130 if (NumMethodPoolLookups)
8131 std::fprintf(stderr,
" %u/%u method pool lookups succeeded (%f%%)\n",
8132 NumMethodPoolHits, NumMethodPoolLookups,
8133 ((
float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
8134 if (NumMethodPoolTableLookups)
8135 std::fprintf(stderr,
" %u/%u method pool table lookups succeeded (%f%%)\n",
8136 NumMethodPoolTableHits, NumMethodPoolTableLookups,
8137 ((
float)NumMethodPoolTableHits/NumMethodPoolTableLookups
8139 if (NumIdentifierLookupHits)
8140 std::fprintf(stderr,
8141 " %u / %u identifier table lookups succeeded (%f%%)\n",
8142 NumIdentifierLookupHits, NumIdentifierLookups,
8143 (
double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
8146 std::fprintf(stderr,
"\n");
8147 GlobalIndex->printStats();
8150 std::fprintf(stderr,
"\n");
8152 std::fprintf(stderr,
"\n");
8155 template<
typename Key,
typename ModuleFile,
unsigned InitialCapacity>
8156 LLVM_DUMP_METHOD
static void 8159 InitialCapacity> &Map) {
8160 if (Map.begin() == Map.end())
8165 llvm::errs() << Name <<
":\n";
8166 for (
typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
8168 llvm::errs() <<
" " << I->first <<
" -> " << I->second->FileName
8174 llvm::errs() <<
"*** PCH/ModuleFile Remappings:\n";
8176 dumpModuleIDMap(
"Global source location entry map", GlobalSLocEntryMap);
8184 GlobalPreprocessedEntityMap);
8186 llvm::errs() <<
"\n*** PCH/Modules Loaded:";
8187 for (ModuleFile &M : ModuleMgr)
8194 for (ModuleFile &I : ModuleMgr) {
8195 if (llvm::MemoryBuffer *buf = I.Buffer) {
8196 size_t bytes = buf->getBufferSize();
8197 switch (buf->getBufferKind()) {
8198 case llvm::MemoryBuffer::MemoryBuffer_Malloc:
8201 case llvm::MemoryBuffer::MemoryBuffer_MMap:
8215 for (uint64_t
ID : PreloadedDeclIDs) {
8219 PreloadedDeclIDs.clear();
8222 if (!FPPragmaOptions.empty()) {
8223 assert(FPPragmaOptions.size() == 1 &&
"Wrong number of FP_PRAGMA_OPTIONS");
8224 SemaObj->FPFeatures =
FPOptions(FPPragmaOptions[0]);
8227 SemaObj->OpenCLFeatures.copy(OpenCLExtensions);
8228 SemaObj->OpenCLTypeExtMap = OpenCLTypeExtMap;
8229 SemaObj->OpenCLDeclExtMap = OpenCLDeclExtMap;
8235 assert(SemaObj &&
"no Sema to update");
8239 if (!SemaDeclRefs.empty()) {
8240 assert(SemaDeclRefs.size() % 3 == 0);
8241 for (
unsigned I = 0; I != SemaDeclRefs.size(); I += 3) {
8242 if (!SemaObj->StdNamespace)
8243 SemaObj->StdNamespace = SemaDeclRefs[I];
8244 if (!SemaObj->StdBadAlloc)
8245 SemaObj->StdBadAlloc = SemaDeclRefs[I+1];
8246 if (!SemaObj->StdAlignValT)
8247 SemaObj->StdAlignValT = SemaDeclRefs[I+2];
8249 SemaDeclRefs.clear();
8254 if(OptimizeOffPragmaLocation.isValid())
8255 SemaObj->ActOnPragmaOptimize(
false, OptimizeOffPragmaLocation);
8256 if (PragmaMSStructState != -1)
8258 if (PointersToMembersPragmaLocation.isValid()) {
8259 SemaObj->ActOnPragmaMSPointersToMembers(
8261 PragmaMSPointersToMembersState,
8262 PointersToMembersPragmaLocation);
8264 SemaObj->ForceCUDAHostDeviceDepth = ForceCUDAHostDeviceDepth;
8266 if (PragmaPackCurrentValue) {
8270 bool DropFirst =
false;
8271 if (!PragmaPackStack.empty() &&
8272 PragmaPackStack.front().Location.isInvalid()) {
8273 assert(PragmaPackStack.front().Value == SemaObj->PackStack.DefaultValue &&
8274 "Expected a default alignment value");
8275 SemaObj->PackStack.Stack.emplace_back(
8276 PragmaPackStack.front().SlotLabel, SemaObj->PackStack.CurrentValue,
8277 SemaObj->PackStack.CurrentPragmaLocation,
8278 PragmaPackStack.front().PushLocation);
8281 for (
const auto &Entry :
8282 llvm::makeArrayRef(PragmaPackStack).drop_front(DropFirst ? 1 : 0))
8283 SemaObj->PackStack.Stack.emplace_back(Entry.SlotLabel, Entry.Value,
8284 Entry.Location, Entry.PushLocation);
8285 if (PragmaPackCurrentLocation.isInvalid()) {
8286 assert(*PragmaPackCurrentValue == SemaObj->PackStack.DefaultValue &&
8287 "Expected a default alignment value");
8290 SemaObj->PackStack.CurrentValue = *PragmaPackCurrentValue;
8291 SemaObj->PackStack.CurrentPragmaLocation = PragmaPackCurrentLocation;
8300 IdentifierLookupVisitor Visitor(Name, 0,
8301 NumIdentifierLookups,
8302 NumIdentifierLookupHits);
8308 if (PP.getLangOpts().CPlusPlus) {
8309 for (
auto F : ModuleMgr.pch_modules())
8317 if (!loadGlobalIndex()) {
8318 if (GlobalIndex->lookupIdentifier(Name, Hits)) {
8323 ModuleMgr.visit(Visitor, HitsPtr);
8327 markIdentifierUpToDate(II);
8345 ASTIdentifierLookupTable::key_iterator Current;
8349 ASTIdentifierLookupTable::key_iterator
End;
8356 bool SkipModules =
false);
8358 StringRef Next()
override;
8365 : Reader(Reader), Index(Reader.ModuleMgr.size()), SkipModules(SkipModules) {
8369 while (Current == End) {
8375 ModuleFile &F = Reader.ModuleMgr[Index];
8381 Current = IdTable->key_begin();
8382 End = IdTable->key_end();
8387 StringRef
Result = *Current;
8396 std::unique_ptr<IdentifierIterator> Current;
8397 std::unique_ptr<IdentifierIterator> Queued;
8400 ChainedIdentifierIterator(std::unique_ptr<IdentifierIterator>
First,
8401 std::unique_ptr<IdentifierIterator> Second)
8402 : Current(std::move(First)), Queued(std::move(Second)) {}
8404 StringRef
Next()
override {
8408 StringRef
result = Current->Next();
8409 if (!result.empty())
8414 std::swap(Current, Queued);
8422 if (!loadGlobalIndex()) {
8423 std::unique_ptr<IdentifierIterator> ReaderIter(
8425 std::unique_ptr<IdentifierIterator> ModulesIter(
8426 GlobalIndex->createIdentifierIterator());
8427 return new ChainedIdentifierIterator(std::move(ReaderIter),
8428 std::move(ModulesIter));
8435 namespace serialization {
8440 unsigned PriorGeneration;
8441 unsigned InstanceBits = 0;
8442 unsigned FactoryBits = 0;
8443 bool InstanceHasMoreThanOneDecl =
false;
8444 bool FactoryHasMoreThanOneDecl =
false;
8450 unsigned PriorGeneration)
8451 : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) {}
8461 ++Reader.NumMethodPoolTableLookups;
8464 ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel);
8465 if (Pos == PoolTable->end())
8468 ++Reader.NumMethodPoolTableHits;
8469 ++Reader.NumSelectorsRead;
8473 ++Reader.NumMethodPoolEntriesRead;
8475 if (Reader.DeserializationListener)
8489 return InstanceMethods;
8494 return FactoryMethods;
8501 return InstanceHasMoreThanOneDecl;
8513 for (
unsigned I = 0, N = Methods.size(); I != N; ++I) {
8520 unsigned &Generation = SelectorGeneration[Sel];
8521 unsigned PriorGeneration = Generation;
8522 Generation = getGeneration();
8523 SelectorOutOfDate[Sel] =
false;
8526 ++NumMethodPoolLookups;
8528 ModuleMgr.visit(Visitor);
8534 ++NumMethodPoolHits;
8539 Sema &S = *getSema();
8540 Sema::GlobalMethodPool::iterator Pos
8556 if (SelectorOutOfDate[Sel])
8557 ReadMethodPool(Sel);
8564 for (
unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) {
8566 = dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespaces[I])))
8567 Namespaces.push_back(Namespace);
8572 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
8573 for (
unsigned Idx = 0, N = UndefinedButUsed.size(); Idx != N;) {
8574 NamedDecl *D = cast<NamedDecl>(GetDecl(UndefinedButUsed[Idx++]));
8577 Undefined.insert(std::make_pair(D, Loc));
8584 for (
unsigned Idx = 0, N = DelayedDeleteExprs.size(); Idx != N;) {
8585 FieldDecl *FD = cast<FieldDecl>(GetDecl(DelayedDeleteExprs[Idx++]));
8586 uint64_t Count = DelayedDeleteExprs[Idx++];
8587 for (uint64_t
C = 0;
C < Count; ++
C) {
8590 const bool IsArrayForm = DelayedDeleteExprs[Idx++];
8591 Exprs[FD].push_back(std::make_pair(DeleteLoc, IsArrayForm));
8598 for (
unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) {
8599 VarDecl *Var = dyn_cast_or_null<VarDecl>(GetDecl(TentativeDefinitions[I]));
8601 TentativeDefs.push_back(Var);
8603 TentativeDefinitions.clear();
8608 for (
unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++I) {
8610 = dyn_cast_or_null<DeclaratorDecl>(GetDecl(UnusedFileScopedDecls[I]));
8614 UnusedFileScopedDecls.clear();
8619 for (
unsigned I = 0, N = DelegatingCtorDecls.size(); I != N; ++I) {
8621 = dyn_cast_or_null<CXXConstructorDecl>(GetDecl(DelegatingCtorDecls[I]));
8625 DelegatingCtorDecls.clear();
8629 for (
unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++I) {
8631 = dyn_cast_or_null<TypedefNameDecl>(GetDecl(ExtVectorDecls[I]));
8635 ExtVectorDecls.clear();
8640 for (
unsigned I = 0, N = UnusedLocalTypedefNameCandidates.size(); I != N;
8643 GetDecl(UnusedLocalTypedefNameCandidates[I]));
8647 UnusedLocalTypedefNameCandidates.clear();
8652 if (ReferencedSelectorsData.empty())
8657 unsigned int DataSize = ReferencedSelectorsData.size()-1;
8659 while (I < DataSize) {
8660 Selector Sel = DecodeSelector(ReferencedSelectorsData[I++]);
8663 Sels.push_back(std::make_pair(Sel, SelLoc));
8665 ReferencedSelectorsData.clear();
8670 if (WeakUndeclaredIdentifiers.empty())
8673 for (
unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; ) {
8675 = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
8677 = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
8680 bool Used = WeakUndeclaredIdentifiers[I++];
8683 WeakIDs.push_back(std::make_pair(WeakId, WI));
8685 WeakUndeclaredIdentifiers.clear();
8689 for (
unsigned Idx = 0, N = VTableUses.size(); Idx < N; ) {
8691 VT.
Record = dyn_cast_or_null<CXXRecordDecl>(GetDecl(VTableUses[Idx++]));
8694 VTables.push_back(VT);
8702 for (
unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
8703 ValueDecl *D = cast<ValueDecl>(GetDecl(PendingInstantiations[Idx++]));
8707 Pending.push_back(std::make_pair(D, Loc));
8709 PendingInstantiations.clear();
8713 llvm::MapVector<
const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
8715 for (
unsigned Idx = 0, N = LateParsedTemplates.size(); Idx < N;
8717 FunctionDecl *FD = cast<FunctionDecl>(GetDecl(LateParsedTemplates[Idx++]));
8719 auto LT = llvm::make_unique<LateParsedTemplate>();
8720 LT->D = GetDecl(LateParsedTemplates[Idx++]);
8722 ModuleFile *F = getOwningModuleFile(LT->D);
8723 assert(F &&
"No module");
8725 unsigned TokN = LateParsedTemplates[Idx++];
8726 LT->Toks.reserve(TokN);
8727 for (
unsigned T = 0; T < TokN; ++T)
8728 LT->Toks.push_back(ReadToken(*F, LateParsedTemplates, Idx));
8730 LPTMap.insert(std::make_pair(FD, std::move(LT)));
8733 LateParsedTemplates.clear();
8738 ReadMethodPool(Sel);
8742 assert(ID &&
"Non-zero identifier ID required");
8743 assert(ID <= IdentifiersLoaded.size() &&
"identifier ID out of range");
8744 IdentifiersLoaded[ID - 1] = II;
8745 if (DeserializationListener)
8746 DeserializationListener->IdentifierRead(ID, II);
8769 if (NumCurrentElementsDeserializing && !Decls) {
8770 PendingIdentifierInfos[II].append(DeclIDs.begin(), DeclIDs.end());
8774 for (
unsigned I = 0, N = DeclIDs.size(); I != N; ++I) {
8779 PreloadedDeclIDs.push_back(DeclIDs[I]);
8783 NamedDecl *D = cast<NamedDecl>(GetDecl(DeclIDs[I]));
8787 Decls->push_back(D);
8794 pushExternalDeclIntoScope(D, II);
8802 if (IdentifiersLoaded.empty()) {
8803 Error(
"no identifier table in AST file");
8808 if (!IdentifiersLoaded[ID]) {
8810 assert(I != GlobalIdentifierMap.end() &&
"Corrupted global identifier map");
8811 ModuleFile *M = I->second;
8812 unsigned Index = ID - M->BaseIdentifierID;
8813 const char *Str = M->IdentifierTableData + M->IdentifierOffsets[Index];
8820 const unsigned char *StrLenPtr = (
const unsigned char*) Str - 2;
8821 unsigned StrLen = (((unsigned) StrLenPtr[0])
8822 | (((unsigned) StrLenPtr[1]) << 8)) - 1;
8823 auto &II = PP.getIdentifierTable().get(StringRef(Str, StrLen));
8824 IdentifiersLoaded[
ID] = &II;
8826 if (DeserializationListener)
8827 DeserializationListener->IdentifierRead(ID + 1, &II);
8830 return IdentifiersLoaded[
ID];
8834 return DecodeIdentifierInfo(getGlobalIdentifierID(M, LocalID));
8842 ReadModuleOffsetMap(M);
8847 &&
"Invalid index into identifier index remap");
8849 return LocalID + I->second;
8856 if (MacrosLoaded.empty()) {
8857 Error(
"no macro table in AST file");
8862 if (!MacrosLoaded[ID]) {
8865 assert(I != GlobalMacroMap.end() &&
"Corrupted global macro map");
8866 ModuleFile *M = I->second;
8867 unsigned Index = ID - M->BaseMacroID;
8868 MacrosLoaded[
ID] = ReadMacroRecord(*M, M->MacroOffsets[Index]);
8870 if (DeserializationListener)
8875 return MacrosLoaded[
ID];
8883 ReadModuleOffsetMap(M);
8887 assert(I != M.
MacroRemap.
end() &&
"Invalid index into macro index remap");
8889 return LocalID + I->second;
8898 ReadModuleOffsetMap(M);
8903 &&
"Invalid index into submodule index remap");
8905 return LocalID + I->second;
8910 assert(GlobalID == 0 &&
"Unhandled global submodule ID");
8914 if (GlobalID > SubmodulesLoaded.size()) {
8915 Error(
"submodule ID out of range in AST file");
8923 return getSubmodule(ID);
8927 ModuleFile *MF = getOwningModuleFile(D);
8934 auto I = GlobalSubmoduleMap.find(getGlobalSubmoduleID(F, ID >> 1));
8935 return I == GlobalSubmoduleMap.end() ? nullptr : I->second;
8938 unsigned IndexFromEnd = ID >> 1;
8939 assert(IndexFromEnd &&
"got reference to unknown module file");
8940 return getModuleManager().pch_modules().end()[-IndexFromEnd];
8955 auto PCHModules = getModuleManager().pch_modules();
8956 auto I = llvm::find(PCHModules, F);
8957 assert(I != PCHModules.end() &&
"emitting reference to unknown file");
8958 return (I - PCHModules.end()) << 1;
8963 if (
const Module *M = getSubmodule(ID))
8968 const auto &PCHChain = ModuleMgr.pch_modules();
8969 if (
std::distance(std::begin(PCHChain), std::end(PCHChain))) {
8970 ModuleFile &MF = ModuleMgr.getPrimaryModule();
8972 StringRef FileName = llvm::sys::path::filename(MF.
FileName);
8980 auto I = DefinitionSource.find(FD);
8981 if (I == DefinitionSource.end())
8982 return EK_ReplyHazy;
8983 return I->second ? EK_Never : EK_Always;
8987 return DecodeSelector(getGlobalSelectorID(M, LocalID));
8994 if (ID > SelectorsLoaded.size()) {
8995 Error(
"selector ID out of range in AST file");
8999 if (SelectorsLoaded[ID - 1].getAsOpaquePtr() ==
nullptr) {
9002 assert(I != GlobalSelectorMap.end() &&
"Corrupted global selector map");
9003 ModuleFile &M = *I->second;
9006 SelectorsLoaded[ID - 1] =
9007 Trait.
ReadKey(M.SelectorLookupTableData + M.SelectorOffsets[Idx], 0);
9008 if (DeserializationListener)
9009 DeserializationListener->SelectorRead(ID, SelectorsLoaded[ID - 1]);
9012 return SelectorsLoaded[ID - 1];
9016 return DecodeSelector(ID);
9021 return getTotalNumSelectors() + 1;
9030 ReadModuleOffsetMap(M);
9035 &&
"Invalid index into selector index remap");
9037 return LocalID + I->second;
9064 ReadDeclAs<TemplateDecl>(F, Record, Idx));
9076 GetIdentifierInfo(F, Record, Idx));
9082 llvm_unreachable(
"Invalid NameKind!");
9098 = ReadSourceLocation(F, Record, Idx).getRawEncoding();
9100 = ReadSourceLocation(F, Record, Idx).getRawEncoding();
9105 = ReadSourceLocation(F, Record, Idx).getRawEncoding();
9121 NameInfo.
setName(ReadDeclarationName(F, Record, Idx));
9122 NameInfo.
setLoc(ReadSourceLocation(F, Record, Idx));
9124 ReadDeclarationNameLoc(F, DNLoc, NameInfo.
getName(), Record, Idx);
9130 Info.
QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
9131 unsigned NumTPLists = Record[Idx++];
9136 for (
unsigned i = 0;
i != NumTPLists; ++
i)
9148 return TemplateName(ReadDeclAs<TemplateDecl>(F, Record, Idx));
9151 unsigned size = Record[Idx++];
9154 Decls.
addDecl(ReadDeclAs<NamedDecl>(F, Record, Idx));
9166 bool hasTemplKeyword = Record[Idx++];
9167 TemplateDecl *Template = ReadDeclAs<TemplateDecl>(F, Record, Idx);
9175 GetIdentifierInfo(F, Record,
9183 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
9185 TemplateName replacement = ReadTemplateName(F, Record, Idx);
9191 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
9203 llvm_unreachable(
"Unhandled template name kind!");
9209 bool Canonicalize) {
9227 ValueDecl *D = ReadDeclAs<ValueDecl>(F, Record, Idx);
9233 llvm::APSInt
Value = ReadAPSInt(Record, Idx);
9234 QualType T = readType(F, Record, Idx);
9242 if (
unsigned NumExpansions = Record[Idx++])
9243 NumTemplateExpansions = NumExpansions - 1;
9249 unsigned NumArgs = Record[Idx++];
9251 for (
unsigned I = 0; I != NumArgs; ++I)
9252 Args[I] = ReadTemplateArgument(F, Record, Idx);
9257 llvm_unreachable(
"Unhandled template argument kind!");
9267 unsigned NumParams = Record[Idx++];
9269 Params.reserve(NumParams);
9271 Params.push_back(ReadDeclAs<NamedDecl>(F, Record, Idx));
9275 getContext(), TemplateLoc, LAngleLoc, Params, RAngleLoc,
nullptr);
9276 return TemplateParams;
9283 unsigned &Idx,
bool Canonicalize) {
9284 unsigned NumTemplateArgs = Record[Idx++];
9285 TemplArgs.reserve(NumTemplateArgs);
9286 while (NumTemplateArgs--)
9287 TemplArgs.push_back(ReadTemplateArgument(F, Record, Idx, Canonicalize));
9293 unsigned NumDecls = Record[Idx++];
9294 Set.
reserve(getContext(), NumDecls);
9295 while (NumDecls--) {
9296 DeclID ID = ReadDeclID(F, Record, Idx);
9305 bool isVirtual =
static_cast<bool>(Record[Idx++]);
9306 bool isBaseOfClass =
static_cast<bool>(Record[Idx++]);
9308 bool inheritConstructors =
static_cast<bool>(Record[Idx++]);
9310 SourceRange Range = ReadSourceRange(F, Record, Idx);
9322 unsigned NumInitializers = Record[Idx++];
9323 assert(NumInitializers &&
"wrote ctor initializers but have no inits");
9325 for (
unsigned i = 0;
i != NumInitializers; ++
i) {
9327 bool IsBaseVirtual =
false;
9334 TInfo = GetTypeSourceInfo(F, Record, Idx);
9335 IsBaseVirtual = Record[Idx++];
9339 TInfo = GetTypeSourceInfo(F, Record, Idx);
9343 Member = ReadDeclAs<FieldDecl>(F, Record, Idx);
9347 IndirectMember = ReadDeclAs<IndirectFieldDecl>(F, Record, Idx);
9351 SourceLocation MemberOrEllipsisLoc = ReadSourceLocation(F, Record, Idx);
9352 Expr *Init = ReadExpr(F);
9358 BOMInit =
new (Context)
9360 RParenLoc, MemberOrEllipsisLoc);
9362 BOMInit =
new (Context)
9365 BOMInit =
new (Context)
9369 BOMInit =
new (Context)
9371 LParenLoc, Init, RParenLoc);
9373 if (Record[Idx++]) {
9374 unsigned SourceOrder = Record[Idx++];
9378 CtorInitializers[
i] = BOMInit;
9381 return CtorInitializers;
9388 unsigned N = Record[Idx++];
9390 for (
unsigned I = 0; I != N; ++I) {
9401 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
9414 const Type *T = readType(F, Record, Idx).getTypePtrOrNull();
9418 bool Template = Record[Idx++];
9429 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
9443 unsigned N = Record[Idx++];
9445 for (
unsigned I = 0; I != N; ++I) {
9451 SourceRange Range = ReadSourceRange(F, Record, Idx);
9457 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
9458 SourceRange Range = ReadSourceRange(F, Record, Idx);
9459 Builder.
Extend(Context, NS, Range.getBegin(), Range.getEnd());
9465 SourceRange Range = ReadSourceRange(F, Record, Idx);
9466 Builder.
Extend(Context, Alias, Range.getBegin(), Range.getEnd());
9472 bool Template = Record[Idx++];
9476 SourceLocation ColonColonLoc = ReadSourceLocation(F, Record, Idx);
9486 SourceLocation ColonColonLoc = ReadSourceLocation(F, Record, Idx);
9492 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
9493 SourceRange Range = ReadSourceRange(F, Record, Idx);
9494 Builder.
MakeSuper(Context, RD, Range.getBegin(), Range.getEnd());
9514 unsigned Width = Record[Idx++];
9515 unsigned Scale = Record[Idx++];
9516 uint64_t Tmp = Record[Idx++];
9517 bool IsSigned = Tmp & 0x1;
9518 bool IsSaturated = Tmp & 0x2;
9519 bool HasUnsignedPadding = Tmp & 0x4;
9521 HasUnsignedPadding);
9525 unsigned Kind = Record[Idx++];
9532 return APValue(ReadAPSInt(Record, Idx));
9534 const llvm::fltSemantics &FloatSema = llvm::APFloatBase::EnumToSemantics(
9535 static_cast<llvm::APFloatBase::Semantics>(Record[Idx++]));
9536 return APValue(ReadAPFloat(Record, FloatSema, Idx));
9543 llvm::APSInt
First = ReadAPSInt(Record, Idx);
9544 return APValue(std::move(First), ReadAPSInt(Record, Idx));
9547 const llvm::fltSemantics &FloatSema1 = llvm::APFloatBase::EnumToSemantics(
9548 static_cast<llvm::APFloatBase::Semantics>(Record[Idx++]));
9549 llvm::APFloat
First = ReadAPFloat(Record, FloatSema1, Idx);
9550 const llvm::fltSemantics &FloatSema2 = llvm::APFloatBase::EnumToSemantics(
9551 static_cast<llvm::APFloatBase::Semantics>(Record[Idx++]));
9552 return APValue(std::move(First), ReadAPFloat(Record, FloatSema2, Idx));
9564 llvm_unreachable(
"Invalid APValue::ValueKind");
9569 unsigned BitWidth = Record[Idx++];
9570 unsigned NumWords = llvm::APInt::getNumWords(BitWidth);
9571 llvm::APInt
Result(BitWidth, NumWords, &Record[Idx]);
9578 bool isUnsigned = Record[Idx++];
9579 return llvm::APSInt(ReadAPInt(Record, Idx), isUnsigned);
9584 const llvm::fltSemantics &Sem,
9586 return llvm::APFloat(Sem, ReadAPInt(Record, Idx));
9591 unsigned Len = Record[Idx++];
9592 std::string
Result(Record.data() + Idx, Record.data() + Idx + Len);
9599 std::string
Filename = ReadString(Record, Idx);
9600 ResolveImportedPath(F, Filename);
9606 std::string
Filename = ReadString(Record, Idx);
9607 if (!BaseDirectory.empty())
9608 ResolveImportedPath(Filename, BaseDirectory);
9614 unsigned Major = Record[Idx++];
9615 unsigned Minor = Record[Idx++];
9616 unsigned Subminor = Record[Idx++];
9618 return VersionTuple(Major);
9620 return VersionTuple(Major, Minor - 1);
9621 return VersionTuple(Major, Minor - 1, Subminor - 1);
9632 return Diag(CurrentImportLoc, DiagID);
9636 return Diags.Report(Loc, DiagID);
9642 return PP.getIdentifierTable();
9648 assert((*CurrSwitchCaseStmts)[ID] ==
nullptr &&
9649 "Already have a SwitchCase with this ID");
9650 (*CurrSwitchCaseStmts)[
ID] = SC;
9655 assert((*CurrSwitchCaseStmts)[ID] !=
nullptr &&
"No SwitchCase with this ID");
9656 return (*CurrSwitchCaseStmts)[
ID];
9660 CurrSwitchCaseStmts->clear();
9665 std::vector<RawComment *> Comments;
9668 I = CommentsCursors.begin(),
9669 E = CommentsCursors.end();
9672 BitstreamCursor &
Cursor = I->first;
9679 Cursor.advanceSkippingSubblocks(
9680 BitstreamCursor::AF_DontPopBlockAtEnd);
9682 Error(MaybeEntry.takeError());
9685 llvm::BitstreamEntry Entry = MaybeEntry.get();
9687 switch (Entry.Kind) {
9688 case llvm::BitstreamEntry::SubBlock:
9690 Error(
"malformed block record in AST file");
9692 case llvm::BitstreamEntry::EndBlock:
9694 case llvm::BitstreamEntry::Record:
9702 if (!MaybeComment) {
9703 Error(MaybeComment.takeError());
9712 bool IsTrailingComment = Record[Idx++];
9713 bool IsAlmostTrailingComment = Record[Idx++];
9715 SR, Kind, IsTrailingComment, IsAlmostTrailingComment));
9724 Context.
Comments.addDeserializedComments(Comments);
9729 bool IncludeSystem,
bool Complain,
9734 assert(NumUserInputs <= NumInputs);
9735 unsigned N = IncludeSystem ? NumInputs : NumUserInputs;
9736 for (
unsigned I = 0; I < N; ++I) {
9737 bool IsSystem = I >= NumUserInputs;
9738 InputFile IF = getInputFile(MF, I+1, Complain);
9739 Visitor(IF, IsSystem);
9745 llvm::function_ref<
void(
const FileEntry *FE)> Visitor) {
9747 for (
unsigned I = 0; I < NumInputs; ++I) {
9748 InputFileInfo IFI = readInputFileInfo(MF, I + 1);
9749 if (IFI.TopLevelModuleMap)
9751 if (
auto *FE = getInputFile(MF, I + 1).getFile())
9759 return M->getFullModuleName();
9762 if (ModuleFile *M = getOwningModuleFile(D))
9769 void ASTReader::finishPendingActions() {
9770 while (!PendingIdentifierInfos.empty() || !PendingFunctionTypes.empty() ||
9771 !PendingIncompleteDeclChains.empty() || !PendingDeclChains.empty() ||
9772 !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
9773 !PendingUpdateRecords.empty()) {
9776 using TopLevelDeclsMap =
9777 llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2>>;
9778 TopLevelDeclsMap TopLevelDecls;
9780 while (!PendingIdentifierInfos.empty()) {
9783 std::move(PendingIdentifierInfos.back().second);
9784 PendingIdentifierInfos.pop_back();
9786 SetGloballyVisibleDecls(II, DeclIDs, &TopLevelDecls[II]);
9791 for (
unsigned I = 0; I != PendingFunctionTypes.size(); ++I) {
9792 auto *FD = PendingFunctionTypes[I].first;
9793 FD->setType(GetType(PendingFunctionTypes[I].second));
9797 auto *DT = FD->getReturnType()->getContainedDeducedType();
9798 if (DT && DT->isDeduced())
9799 PendingDeducedTypeUpdates.insert(
9800 {FD->getCanonicalDecl(), FD->getReturnType()});
9802 PendingFunctionTypes.clear();
9806 for (
unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
9807 markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
9809 PendingIncompleteDeclChains.clear();
9812 for (
unsigned I = 0; I != PendingDeclChains.size(); ++I)
9813 loadPendingDeclChain(PendingDeclChains[I].first,
9814 PendingDeclChains[I].second);
9815 PendingDeclChains.clear();
9818 for (TopLevelDeclsMap::iterator TLD = TopLevelDecls.begin(),
9819 TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) {
9821 for (
unsigned I = 0, N = TLD->second.size(); I != N; ++I) {
9822 pushExternalDeclIntoScope(cast<NamedDecl>(TLD->second[I]), II);
9827 for (
unsigned I = 0; I != PendingMacroIDs.size(); ++I) {
9830 GlobalIDs.swap(PendingMacroIDs.begin()[I].second);
9832 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9834 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9835 if (!Info.M->isModule())
9836 resolvePendingMacro(II, Info);
9839 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9841 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9842 if (Info.M->isModule())
9843 resolvePendingMacro(II, Info);
9846 PendingMacroIDs.clear();
9850 while (!PendingDeclContextInfos.empty()) {
9851 PendingDeclContextInfo Info = PendingDeclContextInfos.front();
9852 PendingDeclContextInfos.pop_front();
9853 DeclContext *SemaDC = cast<DeclContext>(GetDecl(Info.SemaDC));
9854 DeclContext *LexicalDC = cast<DeclContext>(GetDecl(Info.LexicalDC));
9855 Info.D->setDeclContextsImpl(SemaDC, LexicalDC, getContext());
9859 while (!PendingUpdateRecords.empty()) {
9860 auto Update = PendingUpdateRecords.pop_back_val();
9861 ReadingKindTracker ReadingKind(Read_Decl, *
this);
9862 loadDeclUpdateRecords(
Update);
9868 assert(PendingFakeDefinitionData.empty() &&
9869 "faked up a class definition but never saw the real one");
9875 for (
Decl *D : PendingDefinitions) {
9876 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
9877 if (
const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) {
9882 if (
auto RD = dyn_cast<CXXRecordDecl>(D)) {
9883 for (
auto *R = getMostRecentExistingDecl(RD); R;
9884 R = R->getPreviousDecl()) {
9886 cast<CXXRecordDecl>(R)->isThisDeclarationADefinition() &&
9887 "declaration thinks it's the definition but it isn't");
9888 cast<CXXRecordDecl>(R)->DefinitionData = RD->DefinitionData;
9895 if (
auto ID = dyn_cast<ObjCInterfaceDecl>(D)) {
9900 for (
auto *R = getMostRecentExistingDecl(
ID); R; R = R->getPreviousDecl())
9901 cast<ObjCInterfaceDecl>(R)->Data =
ID->Data;
9906 if (
auto PD = dyn_cast<ObjCProtocolDecl>(D)) {
9907 for (
auto *R = getMostRecentExistingDecl(PD); R; R = R->getPreviousDecl())
9908 cast<ObjCProtocolDecl>(R)->Data = PD->Data;
9914 for (
auto *R = getMostRecentExistingDecl(RTD); R; R = R->getPreviousDecl())
9915 cast<RedeclarableTemplateDecl>(R)->Common = RTD->Common;
9917 PendingDefinitions.clear();
9923 for (PendingBodiesMap::iterator PB = PendingBodies.begin(),
9924 PBEnd = PendingBodies.end();
9925 PB != PBEnd; ++PB) {
9926 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
9936 if (
auto *RD = dyn_cast<CXXRecordDecl>(FD->getLexicalParent()))
9937 if (RD->isDependentContext() && !RD->isThisDeclarationADefinition())
9943 if (!getContext().getLangOpts().Modules || !FD->hasBody(Defn)) {
9947 mergeDefinitionVisibility(NonConstDefn, FD);
9949 if (!FD->isLateTemplateParsed() &&
9950 !NonConstDefn->isLateTemplateParsed() &&
9951 FD->getODRHash() != NonConstDefn->getODRHash()) {
9952 if (!isa<CXXMethodDecl>(FD)) {
9953 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
9954 }
else if (FD->getLexicalParent()->isFileContext() &&
9955 NonConstDefn->getLexicalParent()->isFileContext()) {
9959 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
9967 if (!getContext().getLangOpts().Modules || !MD->
hasBody())
9970 PendingBodies.clear();
9973 for (
auto *ND : PendingMergedDefinitionsToDeduplicate)
9974 getContext().deduplicateMergedDefinitonsFor(ND);
9975 PendingMergedDefinitionsToDeduplicate.clear();
9978 void ASTReader::diagnoseOdrViolations() {
9979 if (PendingOdrMergeFailures.empty() && PendingOdrMergeChecks.empty() &&
9980 PendingFunctionOdrMergeFailures.empty() &&
9981 PendingEnumOdrMergeFailures.empty())
9988 auto OdrMergeFailures = std::move(PendingOdrMergeFailures);
9989 PendingOdrMergeFailures.clear();
9990 for (
auto &Merge : OdrMergeFailures) {
9991 Merge.first->buildLookup();
9992 Merge.first->decls_begin();
9993 Merge.first->bases_begin();
9994 Merge.first->vbases_begin();
9995 for (
auto &RecordPair : Merge.second) {
9996 auto *RD = RecordPair.first;
10004 auto FunctionOdrMergeFailures = std::move(PendingFunctionOdrMergeFailures);
10005 PendingFunctionOdrMergeFailures.clear();
10006 for (
auto &Merge : FunctionOdrMergeFailures) {
10007 Merge.first->buildLookup();
10008 Merge.first->decls_begin();
10009 Merge.first->getBody();
10010 for (
auto &FD : Merge.second) {
10018 auto EnumOdrMergeFailures = std::move(PendingEnumOdrMergeFailures);
10019 PendingEnumOdrMergeFailures.clear();
10020 for (
auto &Merge : EnumOdrMergeFailures) {
10021 Merge.first->decls_begin();
10022 for (
auto &Enum : Merge.second) {
10023 Enum->decls_begin();
10033 while (!PendingOdrMergeChecks.empty()) {
10034 NamedDecl *D = PendingOdrMergeChecks.pop_back_val();
10045 bool Found =
false;
10048 for (
auto RI : D->
redecls()) {
10049 if (RI->getLexicalDeclContext() == CanonDef) {
10064 for (
auto *CanonMember : CanonDef->
decls()) {
10065 if (CanonMember->getCanonicalDecl() == DCanon) {
10074 if (
auto *ND = dyn_cast<NamedDecl>(CanonMember))
10076 Candidates.push_back(ND);
10082 if (!isa<TagDecl>(D))
10089 std::string CanonDefModule =
10090 getOwningModuleNameForDiagnostic(cast<Decl>(CanonDef));
10092 << D << getOwningModuleNameForDiagnostic(D)
10093 << CanonDef << CanonDefModule.empty() << CanonDefModule;
10095 if (Candidates.empty())
10096 Diag(cast<Decl>(CanonDef)->getLocation(),
10097 diag::note_module_odr_violation_no_possible_decls) << D;
10099 for (
unsigned I = 0, N = Candidates.size(); I != N; ++I)
10100 Diag(Candidates[I]->getLocation(),
10101 diag::note_module_odr_violation_possible_decl)
10105 DiagnosedOdrMergeFailures.insert(CanonDef);
10109 if (OdrMergeFailures.empty() && FunctionOdrMergeFailures.empty() &&
10110 EnumOdrMergeFailures.empty())
10119 auto ComputeQualTypeODRHash = [&Hash](
QualType Ty) {
10125 auto ComputeODRHash = [&Hash](
const Stmt *S) {
10132 auto ComputeSubDeclODRHash = [&Hash](
const Decl *D) {
10139 auto ComputeTemplateArgumentODRHash = [&Hash](
const TemplateArgument &TA) {
10145 auto ComputeTemplateParameterListODRHash =
10154 for (
auto &Merge : OdrMergeFailures) {
10157 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
10160 bool Diagnosed =
false;
10162 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstRecord);
10163 for (
auto &RecordPair : Merge.second) {
10167 if (FirstRecord == SecondRecord)
10170 std::string SecondModule = getOwningModuleNameForDiagnostic(SecondRecord);
10172 auto *FirstDD = FirstRecord->DefinitionData;
10173 auto *SecondDD = RecordPair.second;
10175 assert(FirstDD && SecondDD &&
"Definitions without DefinitionData");
10178 if (FirstDD != SecondDD) {
10179 enum ODRDefinitionDataDifference {
10186 auto ODRDiagError = [FirstRecord, &FirstModule,
10188 ODRDefinitionDataDifference DiffType) {
10189 return Diag(Loc, diag::err_module_odr_violation_definition_data)
10190 << FirstRecord << FirstModule.empty() << FirstModule << Range
10193 auto ODRDiagNote = [&SecondModule,
10195 ODRDefinitionDataDifference DiffType) {
10196 return Diag(Loc, diag::note_module_odr_violation_definition_data)
10197 << SecondModule << Range << DiffType;
10200 unsigned FirstNumBases = FirstDD->NumBases;
10201 unsigned FirstNumVBases = FirstDD->NumVBases;
10202 unsigned SecondNumBases = SecondDD->NumBases;
10203 unsigned SecondNumVBases = SecondDD->NumVBases;
10205 auto GetSourceRange = [](
struct CXXRecordDecl::DefinitionData *DD) {
10206 unsigned NumBases = DD->NumBases;
10208 auto bases = DD->bases();
10210 bases[NumBases - 1].getEndLoc());
10213 if (FirstNumBases != SecondNumBases) {
10214 ODRDiagError(FirstRecord->
getLocation(), GetSourceRange(FirstDD),
10217 ODRDiagNote(SecondRecord->
getLocation(), GetSourceRange(SecondDD),
10224 if (FirstNumVBases != SecondNumVBases) {
10225 ODRDiagError(FirstRecord->
getLocation(), GetSourceRange(FirstDD),
10228 ODRDiagNote(SecondRecord->
getLocation(), GetSourceRange(SecondDD),
10230 << SecondNumVBases;
10235 auto FirstBases = FirstDD->bases();
10236 auto SecondBases = SecondDD->bases();
10238 for (i = 0; i < FirstNumBases; ++
i) {
10239 auto FirstBase = FirstBases[
i];
10240 auto SecondBase = SecondBases[
i];
10241 if (ComputeQualTypeODRHash(FirstBase.getType()) !=
10242 ComputeQualTypeODRHash(SecondBase.getType())) {
10243 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
10245 << (i + 1) << FirstBase.getType();
10247 SecondBase.getSourceRange(), BaseType)
10248 << (i + 1) << SecondBase.getType();
10252 if (FirstBase.isVirtual() != SecondBase.isVirtual()) {
10253 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
10255 << (i + 1) << FirstBase.isVirtual() << FirstBase.getType();
10257 SecondBase.getSourceRange(), BaseVirtual)
10258 << (i + 1) << SecondBase.isVirtual() << SecondBase.getType();
10262 if (FirstBase.getAccessSpecifierAsWritten() !=
10263 SecondBase.getAccessSpecifierAsWritten()) {
10264 ODRDiagError(FirstRecord->
getLocation(), FirstBase.getSourceRange(),
10266 << (i + 1) << FirstBase.getType()
10267 << (int)FirstBase.getAccessSpecifierAsWritten();
10269 SecondBase.getSourceRange(), BaseAccess)
10270 << (i + 1) << SecondBase.getType()
10271 << (int)SecondBase.getAccessSpecifierAsWritten();
10276 if (i != FirstNumBases) {
10289 assert(!FirstTemplate == !SecondTemplate &&
10290 "Both pointers should be null or non-null");
10292 enum ODRTemplateDifference {
10295 ParamSingleDefaultArgument,
10296 ParamDifferentDefaultArgument,
10299 if (FirstTemplate && SecondTemplate) {
10300 DeclHashes FirstTemplateHashes;
10301 DeclHashes SecondTemplateHashes;
10303 auto PopulateTemplateParameterHashs =
10304 [&ComputeSubDeclODRHash](DeclHashes &Hashes,
10306 for (
auto *D : TD->getTemplateParameters()->asArray()) {
10307 Hashes.emplace_back(D, ComputeSubDeclODRHash(D));
10311 PopulateTemplateParameterHashs(FirstTemplateHashes, FirstTemplate);
10312 PopulateTemplateParameterHashs(SecondTemplateHashes, SecondTemplate);
10314 assert(FirstTemplateHashes.size() == SecondTemplateHashes.size() &&
10315 "Number of template parameters should be equal.");
10317 auto FirstIt = FirstTemplateHashes.begin();
10318 auto FirstEnd = FirstTemplateHashes.end();
10319 auto SecondIt = SecondTemplateHashes.begin();
10320 for (; FirstIt != FirstEnd; ++FirstIt, ++SecondIt) {
10321 if (FirstIt->second == SecondIt->second)
10324 auto ODRDiagError = [FirstRecord, &FirstModule,
10326 ODRTemplateDifference DiffType) {
10327 return Diag(Loc, diag::err_module_odr_violation_template_parameter)
10328 << FirstRecord << FirstModule.empty() << FirstModule << Range
10331 auto ODRDiagNote = [&SecondModule,
10333 ODRTemplateDifference DiffType) {
10334 return Diag(Loc, diag::note_module_odr_violation_template_parameter)
10335 << SecondModule << Range << DiffType;
10338 const NamedDecl* FirstDecl = cast<NamedDecl>(FirstIt->first);
10339 const NamedDecl* SecondDecl = cast<NamedDecl>(SecondIt->first);
10341 assert(FirstDecl->
getKind() == SecondDecl->getKind() &&
10342 "Parameter Decl's should be the same kind.");
10347 if (FirstName != SecondName) {
10348 const bool FirstNameEmpty =
10349 FirstName.
isIdentifier() && !FirstName.getAsIdentifierInfo();
10350 const bool SecondNameEmpty =
10352 assert((!FirstNameEmpty || !SecondNameEmpty) &&
10353 "Both template parameters cannot be unnamed.");
10355 FirstNameEmpty ? ParamEmptyName : ParamName)
10357 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
10358 SecondNameEmpty ? ParamEmptyName : ParamName)
10363 switch (FirstDecl->
getKind()) {
10365 llvm_unreachable(
"Invalid template parameter type.");
10366 case Decl::TemplateTypeParm: {
10367 const auto *FirstParam = cast<TemplateTypeParmDecl>(FirstDecl);
10368 const auto *SecondParam = cast<TemplateTypeParmDecl>(SecondDecl);
10369 const bool HasFirstDefaultArgument =
10370 FirstParam->hasDefaultArgument() &&
10371 !FirstParam->defaultArgumentWasInherited();
10372 const bool HasSecondDefaultArgument =
10373 SecondParam->hasDefaultArgument() &&
10374 !SecondParam->defaultArgumentWasInherited();
10376 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
10379 ParamSingleDefaultArgument)
10380 << HasFirstDefaultArgument;
10381 ODRDiagNote(SecondDecl->getLocation(),
10382 SecondDecl->getSourceRange(),
10383 ParamSingleDefaultArgument)
10384 << HasSecondDefaultArgument;
10388 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
10389 "Expecting default arguments.");
10392 ParamDifferentDefaultArgument);
10393 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
10394 ParamDifferentDefaultArgument);
10398 case Decl::NonTypeTemplateParm: {
10399 const auto *FirstParam = cast<NonTypeTemplateParmDecl>(FirstDecl);
10400 const auto *SecondParam = cast<NonTypeTemplateParmDecl>(SecondDecl);
10401 const bool HasFirstDefaultArgument =
10402 FirstParam->hasDefaultArgument() &&
10403 !FirstParam->defaultArgumentWasInherited();
10404 const bool HasSecondDefaultArgument =
10405 SecondParam->hasDefaultArgument() &&
10406 !SecondParam->defaultArgumentWasInherited();
10408 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
10411 ParamSingleDefaultArgument)
10412 << HasFirstDefaultArgument;
10413 ODRDiagNote(SecondDecl->getLocation(),
10414 SecondDecl->getSourceRange(),
10415 ParamSingleDefaultArgument)
10416 << HasSecondDefaultArgument;
10420 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
10421 "Expecting default arguments.");
10424 ParamDifferentDefaultArgument);
10425 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
10426 ParamDifferentDefaultArgument);
10430 case Decl::TemplateTemplateParm: {
10431 const auto *FirstParam = cast<TemplateTemplateParmDecl>(FirstDecl);
10432 const auto *SecondParam =
10433 cast<TemplateTemplateParmDecl>(SecondDecl);
10434 const bool HasFirstDefaultArgument =
10435 FirstParam->hasDefaultArgument() &&
10436 !FirstParam->defaultArgumentWasInherited();
10437 const bool HasSecondDefaultArgument =
10438 SecondParam->hasDefaultArgument() &&
10439 !SecondParam->defaultArgumentWasInherited();
10441 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
10444 ParamSingleDefaultArgument)
10445 << HasFirstDefaultArgument;
10446 ODRDiagNote(SecondDecl->getLocation(),
10447 SecondDecl->getSourceRange(),
10448 ParamSingleDefaultArgument)
10449 << HasSecondDefaultArgument;
10453 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
10454 "Expecting default arguments.");
10457 ParamDifferentDefaultArgument);
10458 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
10459 ParamDifferentDefaultArgument);
10468 if (FirstIt != FirstEnd) {
10474 DeclHashes FirstHashes;
10475 DeclHashes SecondHashes;
10477 auto PopulateHashes = [&ComputeSubDeclODRHash, FirstRecord](
10479 for (
auto *D : Record->decls()) {
10484 Hashes.emplace_back(D, ComputeSubDeclODRHash(D));
10487 PopulateHashes(FirstHashes, FirstRecord);
10488 PopulateHashes(SecondHashes, SecondRecord);
10507 } FirstDiffType = Other,
10508 SecondDiffType = Other;
10510 auto DifferenceSelector = [](
Decl *D) {
10511 assert(D &&
"valid Decl required");
10515 case Decl::AccessSpec:
10518 return PublicSpecifer;
10520 return PrivateSpecifer;
10522 return ProtectedSpecifer;
10526 llvm_unreachable(
"Invalid access specifier");
10527 case Decl::StaticAssert:
10528 return StaticAssert;
10531 case Decl::CXXMethod:
10532 case Decl::CXXConstructor:
10533 case Decl::CXXDestructor:
10535 case Decl::TypeAlias:
10537 case Decl::Typedef:
10543 case Decl::FunctionTemplate:
10544 return FunctionTemplate;
10548 Decl *FirstDecl =
nullptr;
10549 Decl *SecondDecl =
nullptr;
10550 auto FirstIt = FirstHashes.begin();
10551 auto SecondIt = SecondHashes.begin();
10556 while (FirstIt != FirstHashes.end() || SecondIt != SecondHashes.end()) {
10557 if (FirstIt != FirstHashes.end() && SecondIt != SecondHashes.end() &&
10558 FirstIt->second == SecondIt->second) {
10564 FirstDecl = FirstIt == FirstHashes.end() ? nullptr : FirstIt->first;
10565 SecondDecl = SecondIt == SecondHashes.end() ? nullptr : SecondIt->first;
10567 FirstDiffType = FirstDecl ? DifferenceSelector(FirstDecl) : EndOfClass;
10569 SecondDecl ? DifferenceSelector(SecondDecl) : EndOfClass;
10574 if (FirstDiffType == Other || SecondDiffType == Other) {
10579 diag::err_module_odr_violation_different_definitions)
10580 << FirstRecord << FirstModule.empty() << FirstModule;
10588 diag::note_module_odr_violation_different_definitions)
10600 if (FirstDiffType != SecondDiffType) {
10603 if (FirstDiffType == EndOfClass) {
10606 FirstLoc = FirstIt->first->getLocation();
10607 FirstRange = FirstIt->first->getSourceRange();
10609 Diag(FirstLoc, diag::err_module_odr_violation_mismatch_decl)
10610 << FirstRecord << FirstModule.empty() << FirstModule << FirstRange
10615 if (SecondDiffType == EndOfClass) {
10621 Diag(SecondLoc, diag::note_module_odr_violation_mismatch_decl)
10622 << SecondModule << SecondRange << SecondDiffType;
10627 assert(FirstDiffType == SecondDiffType);
10631 enum ODRDeclDifference {
10632 StaticAssertCondition,
10633 StaticAssertMessage,
10634 StaticAssertOnlyMessage,
10637 FieldSingleBitField,
10638 FieldDifferentWidthBitField,
10639 FieldSingleMutable,
10640 FieldSingleInitializer,
10641 FieldDifferentInitializers,
10650 MethodNumberParameters,
10651 MethodParameterType,
10652 MethodParameterName,
10653 MethodParameterSingleDefaultArgument,
10654 MethodParameterDifferentDefaultArgument,
10655 MethodNoTemplateArguments,
10656 MethodDifferentNumberTemplateArguments,
10657 MethodDifferentTemplateArgument,
10659 MethodDifferentBody,
10664 VarSingleInitializer,
10665 VarDifferentInitializer,
10667 FriendTypeFunction,
10670 FunctionTemplateDifferentNumberParameters,
10671 FunctionTemplateParameterDifferentKind,
10672 FunctionTemplateParameterName,
10673 FunctionTemplateParameterSingleDefaultArgument,
10674 FunctionTemplateParameterDifferentDefaultArgument,
10675 FunctionTemplateParameterDifferentType,
10676 FunctionTemplatePackParameter,
10682 auto ODRDiagError = [FirstRecord, &FirstModule,
this](
10684 return Diag(Loc, diag::err_module_odr_violation_mismatch_decl_diff)
10685 << FirstRecord << FirstModule.empty() << FirstModule << Range
10688 auto ODRDiagNote = [&SecondModule,
this](
10690 return Diag(Loc, diag::note_module_odr_violation_mismatch_decl_diff)
10691 << SecondModule << Range << DiffType;
10694 switch (FirstDiffType) {
10697 case PublicSpecifer:
10698 case PrivateSpecifer:
10699 case ProtectedSpecifer:
10700 llvm_unreachable(
"Invalid diff type");
10702 case StaticAssert: {
10707 Expr *SecondExpr = SecondSA->getAssertExpr();
10708 unsigned FirstODRHash = ComputeODRHash(FirstExpr);
10709 unsigned SecondODRHash = ComputeODRHash(SecondExpr);
10710 if (FirstODRHash != SecondODRHash) {
10711 ODRDiagError(FirstExpr->getBeginLoc(), FirstExpr->getSourceRange(),
10712 StaticAssertCondition);
10714 StaticAssertCondition);
10721 assert((FirstStr || SecondStr) &&
"Both messages cannot be empty");
10722 if ((FirstStr && !SecondStr) || (!FirstStr && SecondStr)) {
10736 SecondLoc = SecondSA->getBeginLoc();
10737 SecondRange = SecondSA->getSourceRange();
10739 ODRDiagError(FirstLoc, FirstRange, StaticAssertOnlyMessage)
10740 << (FirstStr ==
nullptr);
10741 ODRDiagNote(SecondLoc, SecondRange, StaticAssertOnlyMessage)
10742 << (SecondStr ==
nullptr);
10747 if (FirstStr && SecondStr &&
10750 StaticAssertMessage);
10752 StaticAssertMessage);
10759 FieldDecl *FirstField = cast<FieldDecl>(FirstDecl);
10760 FieldDecl *SecondField = cast<FieldDecl>(SecondDecl);
10763 if (FirstII->getName() != SecondII->
getName()) {
10767 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10775 assert(getContext().hasSameType(FirstField->
getType(),
10776 SecondField->getType()));
10779 QualType SecondType = SecondField->getType();
10780 if (ComputeQualTypeODRHash(FirstType) !=
10781 ComputeQualTypeODRHash(SecondType)) {
10784 << FirstII << FirstType;
10785 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10787 << SecondII << SecondType;
10793 const bool IsFirstBitField = FirstField->
isBitField();
10794 const bool IsSecondBitField = SecondField->isBitField();
10795 if (IsFirstBitField != IsSecondBitField) {
10797 FieldSingleBitField)
10798 << FirstII << IsFirstBitField;
10799 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10800 FieldSingleBitField)
10801 << SecondII << IsSecondBitField;
10806 if (IsFirstBitField && IsSecondBitField) {
10808 FieldDifferentWidthBitField)
10810 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10811 FieldDifferentWidthBitField)
10812 << SecondII << SecondField->getBitWidth()->getSourceRange();
10817 const bool IsFirstMutable = FirstField->
isMutable();
10818 const bool IsSecondMutable = SecondField->isMutable();
10819 if (IsFirstMutable != IsSecondMutable) {
10821 FieldSingleMutable)
10822 << FirstII << IsFirstMutable;
10823 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10824 FieldSingleMutable)
10825 << SecondII << IsSecondMutable;
10831 const Expr *SecondInitializer = SecondField->getInClassInitializer();
10832 if ((!FirstInitializer && SecondInitializer) ||
10833 (FirstInitializer && !SecondInitializer)) {
10835 FieldSingleInitializer)
10836 << FirstII << (FirstInitializer !=
nullptr);
10837 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10838 FieldSingleInitializer)
10839 << SecondII << (SecondInitializer !=
nullptr);
10844 if (FirstInitializer && SecondInitializer) {
10845 unsigned FirstInitHash = ComputeODRHash(FirstInitializer);
10846 unsigned SecondInitHash = ComputeODRHash(SecondInitializer);
10847 if (FirstInitHash != SecondInitHash) {
10850 FieldDifferentInitializers)
10852 ODRDiagNote(SecondField->getLocation(),
10853 SecondField->getSourceRange(),
10854 FieldDifferentInitializers)
10870 auto GetMethodTypeForDiagnostics = [](
const CXXMethodDecl* D) {
10871 if (isa<CXXConstructorDecl>(D))
return DiagConstructor;
10872 if (isa<CXXDestructorDecl>(D))
return DiagDestructor;
10875 const CXXMethodDecl *FirstMethod = cast<CXXMethodDecl>(FirstDecl);
10876 const CXXMethodDecl *SecondMethod = cast<CXXMethodDecl>(SecondDecl);
10877 FirstMethodType = GetMethodTypeForDiagnostics(FirstMethod);
10878 SecondMethodType = GetMethodTypeForDiagnostics(SecondMethod);
10880 auto SecondName = SecondMethod->getDeclName();
10881 if (FirstMethodType != SecondMethodType || FirstName != SecondName) {
10884 << FirstMethodType << FirstName;
10885 ODRDiagNote(SecondMethod->getLocation(),
10886 SecondMethod->getSourceRange(), MethodName)
10887 << SecondMethodType << SecondName;
10894 const bool SecondDeleted = SecondMethod->isDeletedAsWritten();
10895 if (FirstDeleted != SecondDeleted) {
10898 << FirstMethodType << FirstName << FirstDeleted;
10900 ODRDiagNote(SecondMethod->getLocation(),
10901 SecondMethod->getSourceRange(), MethodDeleted)
10902 << SecondMethodType << SecondName << SecondDeleted;
10908 const bool SecondDefaulted = SecondMethod->isExplicitlyDefaulted();
10909 if (FirstDefaulted != SecondDefaulted) {
10912 << FirstMethodType << FirstName << FirstDefaulted;
10914 ODRDiagNote(SecondMethod->getLocation(),
10915 SecondMethod->getSourceRange(), MethodDefaulted)
10916 << SecondMethodType << SecondName << SecondDefaulted;
10922 const bool SecondVirtual = SecondMethod->isVirtualAsWritten();
10923 const bool FirstPure = FirstMethod->
isPure();
10924 const bool SecondPure = SecondMethod->isPure();
10925 if ((FirstVirtual || SecondVirtual) &&
10926 (FirstVirtual != SecondVirtual || FirstPure != SecondPure)) {
10929 << FirstMethodType << FirstName << FirstPure << FirstVirtual;
10930 ODRDiagNote(SecondMethod->getLocation(),
10931 SecondMethod->getSourceRange(), MethodVirtual)
10932 << SecondMethodType << SecondName << SecondPure << SecondVirtual;
10941 const auto SecondStorage = SecondMethod->getStorageClass();
10942 const bool FirstStatic = FirstStorage ==
SC_Static;
10943 const bool SecondStatic = SecondStorage ==
SC_Static;
10944 if (FirstStatic != SecondStatic) {
10947 << FirstMethodType << FirstName << FirstStatic;
10948 ODRDiagNote(SecondMethod->getLocation(),
10949 SecondMethod->getSourceRange(), MethodStatic)
10950 << SecondMethodType << SecondName << SecondStatic;
10955 const bool FirstVolatile = FirstMethod->
isVolatile();
10956 const bool SecondVolatile = SecondMethod->isVolatile();
10957 if (FirstVolatile != SecondVolatile) {
10960 << FirstMethodType << FirstName << FirstVolatile;
10961 ODRDiagNote(SecondMethod->getLocation(),
10962 SecondMethod->getSourceRange(), MethodVolatile)
10963 << SecondMethodType << SecondName << SecondVolatile;
10968 const bool FirstConst = FirstMethod->
isConst();
10969 const bool SecondConst = SecondMethod->isConst();
10970 if (FirstConst != SecondConst) {
10973 << FirstMethodType << FirstName << FirstConst;
10974 ODRDiagNote(SecondMethod->getLocation(),
10975 SecondMethod->getSourceRange(), MethodConst)
10976 << SecondMethodType << SecondName << SecondConst;
10982 const bool SecondInline = SecondMethod->isInlineSpecified();
10983 if (FirstInline != SecondInline) {
10986 << FirstMethodType << FirstName << FirstInline;
10987 ODRDiagNote(SecondMethod->getLocation(),
10988 SecondMethod->getSourceRange(), MethodInline)
10989 << SecondMethodType << SecondName << SecondInline;
10994 const unsigned FirstNumParameters = FirstMethod->
param_size();
10995 const unsigned SecondNumParameters = SecondMethod->param_size();
10996 if (FirstNumParameters != SecondNumParameters) {
10999 << FirstMethodType << FirstName << FirstNumParameters;
11000 ODRDiagNote(SecondMethod->getLocation(),
11001 SecondMethod->getSourceRange(), MethodNumberParameters)
11002 << SecondMethodType << SecondName << SecondNumParameters;
11008 bool ParameterMismatch =
false;
11009 for (
unsigned I = 0; I < FirstNumParameters; ++I) {
11011 const ParmVarDecl *SecondParam = SecondMethod->getParamDecl(I);
11015 if (FirstParamType != SecondParamType &&
11016 ComputeQualTypeODRHash(FirstParamType) !=
11017 ComputeQualTypeODRHash(SecondParamType)) {
11022 << FirstMethodType << FirstName << (I + 1) << FirstParamType
11023 <<
true << ParamDecayedType->getOriginalType();
11027 << FirstMethodType << FirstName << (I + 1) << FirstParamType
11033 ODRDiagNote(SecondMethod->getLocation(),
11034 SecondMethod->getSourceRange(), MethodParameterType)
11035 << SecondMethodType << SecondName << (I + 1)
11036 << SecondParamType <<
true 11037 << ParamDecayedType->getOriginalType();
11039 ODRDiagNote(SecondMethod->getLocation(),
11040 SecondMethod->getSourceRange(), MethodParameterType)
11041 << SecondMethodType << SecondName << (I + 1)
11042 << SecondParamType <<
false;
11044 ParameterMismatch =
true;
11050 if (FirstParamName != SecondParamName) {
11053 << FirstMethodType << FirstName << (I + 1) << FirstParamName;
11054 ODRDiagNote(SecondMethod->getLocation(),
11055 SecondMethod->getSourceRange(), MethodParameterName)
11056 << SecondMethodType << SecondName << (I + 1) << SecondParamName;
11057 ParameterMismatch =
true;
11063 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
11066 MethodParameterSingleDefaultArgument)
11067 << FirstMethodType << FirstName << (I + 1)
11068 << (FirstInit ==
nullptr)
11070 ODRDiagNote(SecondMethod->getLocation(),
11071 SecondMethod->getSourceRange(),
11072 MethodParameterSingleDefaultArgument)
11073 << SecondMethodType << SecondName << (I + 1)
11074 << (SecondInit ==
nullptr)
11076 ParameterMismatch =
true;
11080 if (FirstInit && SecondInit &&
11081 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
11084 MethodParameterDifferentDefaultArgument)
11085 << FirstMethodType << FirstName << (I + 1)
11087 ODRDiagNote(SecondMethod->getLocation(),
11088 SecondMethod->getSourceRange(),
11089 MethodParameterDifferentDefaultArgument)
11090 << SecondMethodType << SecondName << (I + 1)
11092 ParameterMismatch =
true;
11098 if (ParameterMismatch) {
11103 const auto *FirstTemplateArgs =
11105 const auto *SecondTemplateArgs =
11106 SecondMethod->getTemplateSpecializationArgs();
11108 if ((FirstTemplateArgs && !SecondTemplateArgs) ||
11109 (!FirstTemplateArgs && SecondTemplateArgs)) {
11112 << FirstMethodType << FirstName << (FirstTemplateArgs !=
nullptr);
11113 ODRDiagNote(SecondMethod->getLocation(),
11114 SecondMethod->getSourceRange(), MethodNoTemplateArguments)
11115 << SecondMethodType << SecondName
11116 << (SecondTemplateArgs !=
nullptr);
11122 if (FirstTemplateArgs && SecondTemplateArgs) {
11124 auto ExpandTemplateArgumentList =
11129 ExpandedList.push_back(&TA);
11133 ExpandedList.push_back(&PackTA);
11136 return ExpandedList;
11139 ExpandTemplateArgumentList(FirstTemplateArgs);
11141 ExpandTemplateArgumentList(SecondTemplateArgs);
11143 if (FirstExpandedList.size() != SecondExpandedList.size()) {
11146 MethodDifferentNumberTemplateArguments)
11147 << FirstMethodType << FirstName
11148 << (
unsigned)FirstExpandedList.size();
11149 ODRDiagNote(SecondMethod->getLocation(),
11150 SecondMethod->getSourceRange(),
11151 MethodDifferentNumberTemplateArguments)
11152 << SecondMethodType << SecondName
11153 << (
unsigned)SecondExpandedList.size();
11159 bool TemplateArgumentMismatch =
false;
11160 for (
unsigned i = 0, e = FirstExpandedList.size();
i != e; ++
i) {
11162 &SecondTA = *SecondExpandedList[
i];
11163 if (ComputeTemplateArgumentODRHash(FirstTA) ==
11164 ComputeTemplateArgumentODRHash(SecondTA)) {
11170 MethodDifferentTemplateArgument)
11171 << FirstMethodType << FirstName << FirstTA <<
i + 1;
11172 ODRDiagNote(SecondMethod->getLocation(),
11173 SecondMethod->getSourceRange(),
11174 MethodDifferentTemplateArgument)
11175 << SecondMethodType << SecondName << SecondTA <<
i + 1;
11177 TemplateArgumentMismatch =
true;
11181 if (TemplateArgumentMismatch) {
11188 auto ComputeCXXMethodODRHash = [&Hash](
const CXXMethodDecl *D) {
11197 const bool HasFirstBody =
11198 ComputeCXXMethodODRHash(FirstMethod) != FirstMethod->
getODRHash();
11199 const bool HasSecondBody =
11200 ComputeCXXMethodODRHash(SecondMethod) != SecondMethod->getODRHash();
11202 if (HasFirstBody != HasSecondBody) {
11205 << FirstMethodType << FirstName << HasFirstBody;
11206 ODRDiagNote(SecondMethod->getLocation(),
11207 SecondMethod->getSourceRange(), MethodSingleBody)
11208 << SecondMethodType << SecondName << HasSecondBody;
11213 if (HasFirstBody && HasSecondBody) {
11216 << FirstMethodType << FirstName;
11217 ODRDiagNote(SecondMethod->getLocation(),
11218 SecondMethod->getSourceRange(), MethodDifferentBody)
11219 << SecondMethodType << SecondName;
11231 auto SecondName = SecondTD->getDeclName();
11232 if (FirstName != SecondName) {
11235 << (FirstDiffType == TypeAlias) << FirstName;
11236 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
11238 << (FirstDiffType == TypeAlias) << SecondName;
11244 QualType SecondType = SecondTD->getUnderlyingType();
11245 if (ComputeQualTypeODRHash(FirstType) !=
11246 ComputeQualTypeODRHash(SecondType)) {
11249 << (FirstDiffType == TypeAlias) << FirstName << FirstType;
11250 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
11252 << (FirstDiffType == TypeAlias) << SecondName << SecondType;
11259 VarDecl *FirstVD = cast<VarDecl>(FirstDecl);
11260 VarDecl *SecondVD = cast<VarDecl>(SecondDecl);
11262 auto SecondName = SecondVD->getDeclName();
11263 if (FirstName != SecondName) {
11267 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
11275 QualType SecondType = SecondVD->getType();
11276 if (ComputeQualTypeODRHash(FirstType) !=
11277 ComputeQualTypeODRHash(SecondType)) {
11280 << FirstName << FirstType;
11281 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
11283 << SecondName << SecondType;
11289 const Expr *SecondInit = SecondVD->getInit();
11290 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
11292 VarSingleInitializer)
11293 << FirstName << (FirstInit ==
nullptr)
11295 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
11296 VarSingleInitializer)
11297 << SecondName << (SecondInit ==
nullptr)
11303 if (FirstInit && SecondInit &&
11304 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
11306 VarDifferentInitializer)
11308 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
11309 VarDifferentInitializer)
11315 const bool FirstIsConstexpr = FirstVD->
isConstexpr();
11316 const bool SecondIsConstexpr = SecondVD->isConstexpr();
11317 if (FirstIsConstexpr != SecondIsConstexpr) {
11320 << FirstName << FirstIsConstexpr;
11321 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
11323 << SecondName << SecondIsConstexpr;
11330 FriendDecl *FirstFriend = cast<FriendDecl>(FirstDecl);
11331 FriendDecl *SecondFriend = cast<FriendDecl>(SecondDecl);
11334 NamedDecl *SecondND = SecondFriend->getFriendDecl();
11339 if (FirstND && SecondND) {
11343 ODRDiagNote(SecondFriend->getFriendLoc(),
11344 SecondFriend->getSourceRange(), FriendFunction)
11351 if (FirstTSI && SecondTSI) {
11354 assert(ComputeQualTypeODRHash(FirstFriendType) !=
11355 ComputeQualTypeODRHash(SecondFriendType));
11358 << FirstFriendType;
11359 ODRDiagNote(SecondFriend->getFriendLoc(),
11360 SecondFriend->getSourceRange(), FriendType)
11361 << SecondFriendType;
11367 FriendTypeFunction)
11368 << (FirstTSI ==
nullptr);
11369 ODRDiagNote(SecondFriend->getFriendLoc(),
11370 SecondFriend->getSourceRange(), FriendTypeFunction)
11371 << (SecondTSI ==
nullptr);
11376 case FunctionTemplate: {
11378 cast<FunctionTemplateDecl>(FirstDecl);
11380 cast<FunctionTemplateDecl>(SecondDecl);
11385 SecondTemplate->getTemplateParameters();
11387 if (FirstTPL->size() != SecondTPL->
size()) {
11390 FunctionTemplateDifferentNumberParameters)
11391 << FirstTemplate << FirstTPL->size();
11392 ODRDiagNote(SecondTemplate->getLocation(),
11393 SecondTemplate->getSourceRange(),
11394 FunctionTemplateDifferentNumberParameters)
11395 << SecondTemplate << SecondTPL->
size();
11401 bool ParameterMismatch =
false;
11402 for (
unsigned i = 0, e = FirstTPL->size();
i != e; ++
i) {
11403 NamedDecl *FirstParam = FirstTPL->getParam(
i);
11408 TemplateTypeParameter,
11409 NonTypeTemplateParameter,
11410 TemplateTemplateParameter,
11415 llvm_unreachable(
"Unexpected template parameter type");
11416 case Decl::TemplateTypeParm:
11417 return TemplateTypeParameter;
11418 case Decl::NonTypeTemplateParm:
11419 return NonTypeTemplateParameter;
11420 case Decl::TemplateTemplateParm:
11421 return TemplateTemplateParameter;
11427 FunctionTemplateParameterDifferentKind)
11428 << FirstTemplate << (
i + 1) << GetParamType(FirstParam);
11429 ODRDiagNote(SecondTemplate->getLocation(),
11430 SecondTemplate->getSourceRange(),
11431 FunctionTemplateParameterDifferentKind)
11432 << SecondTemplate << (
i + 1) << GetParamType(SecondParam);
11434 ParameterMismatch =
true;
11441 FunctionTemplateParameterName)
11444 ODRDiagNote(SecondTemplate->getLocation(),
11445 SecondTemplate->getSourceRange(),
11446 FunctionTemplateParameterName)
11447 << SecondTemplate << (
i + 1)
11449 ParameterMismatch =
true;
11453 if (isa<TemplateTypeParmDecl>(FirstParam) &&
11454 isa<TemplateTypeParmDecl>(SecondParam)) {
11456 cast<TemplateTypeParmDecl>(FirstParam);
11458 cast<TemplateTypeParmDecl>(SecondParam);
11459 bool HasFirstDefaultArgument =
11462 bool HasSecondDefaultArgument =
11463 SecondTTPD->hasDefaultArgument() &&
11464 !SecondTTPD->defaultArgumentWasInherited();
11465 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
11468 FunctionTemplateParameterSingleDefaultArgument)
11469 << FirstTemplate << (
i + 1) << HasFirstDefaultArgument;
11470 ODRDiagNote(SecondTemplate->getLocation(),
11471 SecondTemplate->getSourceRange(),
11472 FunctionTemplateParameterSingleDefaultArgument)
11473 << SecondTemplate << (
i + 1) << HasSecondDefaultArgument;
11474 ParameterMismatch =
true;
11478 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
11480 QualType SecondType = SecondTTPD->getDefaultArgument();
11481 if (ComputeQualTypeODRHash(FirstType) !=
11482 ComputeQualTypeODRHash(SecondType)) {
11485 FunctionTemplateParameterDifferentDefaultArgument)
11486 << FirstTemplate << (
i + 1) << FirstType;
11487 ODRDiagNote(SecondTemplate->getLocation(),
11488 SecondTemplate->getSourceRange(),
11489 FunctionTemplateParameterDifferentDefaultArgument)
11490 << SecondTemplate << (
i + 1) << SecondType;
11491 ParameterMismatch =
true;
11497 SecondTTPD->isParameterPack()) {
11500 FunctionTemplatePackParameter)
11502 ODRDiagNote(SecondTemplate->getLocation(),
11503 SecondTemplate->getSourceRange(),
11504 FunctionTemplatePackParameter)
11505 << SecondTemplate << (
i + 1) << SecondTTPD->isParameterPack();
11506 ParameterMismatch =
true;
11511 if (isa<TemplateTemplateParmDecl>(FirstParam) &&
11512 isa<TemplateTemplateParmDecl>(SecondParam)) {
11514 cast<TemplateTemplateParmDecl>(FirstParam);
11516 cast<TemplateTemplateParmDecl>(SecondParam);
11521 SecondTTPD->getTemplateParameters();
11523 if (ComputeTemplateParameterListODRHash(FirstTPL) !=
11524 ComputeTemplateParameterListODRHash(SecondTPL)) {
11527 FunctionTemplateParameterDifferentType)
11528 << FirstTemplate << (
i + 1);
11529 ODRDiagNote(SecondTemplate->getLocation(),
11530 SecondTemplate->getSourceRange(),
11531 FunctionTemplateParameterDifferentType)
11532 << SecondTemplate << (
i + 1);
11533 ParameterMismatch =
true;
11537 bool HasFirstDefaultArgument =
11540 bool HasSecondDefaultArgument =
11541 SecondTTPD->hasDefaultArgument() &&
11542 !SecondTTPD->defaultArgumentWasInherited();
11543 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
11546 FunctionTemplateParameterSingleDefaultArgument)
11547 << FirstTemplate << (
i + 1) << HasFirstDefaultArgument;
11548 ODRDiagNote(SecondTemplate->getLocation(),
11549 SecondTemplate->getSourceRange(),
11550 FunctionTemplateParameterSingleDefaultArgument)
11551 << SecondTemplate << (
i + 1) << HasSecondDefaultArgument;
11552 ParameterMismatch =
true;
11556 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
11560 SecondTTPD->getDefaultArgument().getArgument();
11561 if (ComputeTemplateArgumentODRHash(FirstTA) !=
11562 ComputeTemplateArgumentODRHash(SecondTA)) {
11565 FunctionTemplateParameterDifferentDefaultArgument)
11566 << FirstTemplate << (
i + 1) << FirstTA;
11567 ODRDiagNote(SecondTemplate->getLocation(),
11568 SecondTemplate->getSourceRange(),
11569 FunctionTemplateParameterDifferentDefaultArgument)
11570 << SecondTemplate << (
i + 1) << SecondTA;
11571 ParameterMismatch =
true;
11577 SecondTTPD->isParameterPack()) {
11580 FunctionTemplatePackParameter)
11582 ODRDiagNote(SecondTemplate->getLocation(),
11583 SecondTemplate->getSourceRange(),
11584 FunctionTemplatePackParameter)
11585 << SecondTemplate << (
i + 1) << SecondTTPD->isParameterPack();
11586 ParameterMismatch =
true;
11591 if (isa<NonTypeTemplateParmDecl>(FirstParam) &&
11592 isa<NonTypeTemplateParmDecl>(SecondParam)) {
11594 cast<NonTypeTemplateParmDecl>(FirstParam);
11596 cast<NonTypeTemplateParmDecl>(SecondParam);
11599 QualType SecondType = SecondNTTPD->getType();
11600 if (ComputeQualTypeODRHash(FirstType) !=
11601 ComputeQualTypeODRHash(SecondType)) {
11604 FunctionTemplateParameterDifferentType)
11605 << FirstTemplate << (
i + 1);
11606 ODRDiagNote(SecondTemplate->getLocation(),
11607 SecondTemplate->getSourceRange(),
11608 FunctionTemplateParameterDifferentType)
11609 << SecondTemplate << (
i + 1);
11610 ParameterMismatch =
true;
11614 bool HasFirstDefaultArgument =
11617 bool HasSecondDefaultArgument =
11618 SecondNTTPD->hasDefaultArgument() &&
11619 !SecondNTTPD->defaultArgumentWasInherited();
11620 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
11623 FunctionTemplateParameterSingleDefaultArgument)
11624 << FirstTemplate << (
i + 1) << HasFirstDefaultArgument;
11625 ODRDiagNote(SecondTemplate->getLocation(),
11626 SecondTemplate->getSourceRange(),
11627 FunctionTemplateParameterSingleDefaultArgument)
11628 << SecondTemplate << (
i + 1) << HasSecondDefaultArgument;
11629 ParameterMismatch =
true;
11633 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
11635 Expr *SecondDefaultArgument = SecondNTTPD->getDefaultArgument();
11636 if (ComputeODRHash(FirstDefaultArgument) !=
11637 ComputeODRHash(SecondDefaultArgument)) {
11640 FunctionTemplateParameterDifferentDefaultArgument)
11641 << FirstTemplate << (
i + 1) << FirstDefaultArgument;
11642 ODRDiagNote(SecondTemplate->getLocation(),
11643 SecondTemplate->getSourceRange(),
11644 FunctionTemplateParameterDifferentDefaultArgument)
11645 << SecondTemplate << (
i + 1) << SecondDefaultArgument;
11646 ParameterMismatch =
true;
11652 SecondNTTPD->isParameterPack()) {
11655 FunctionTemplatePackParameter)
11657 ODRDiagNote(SecondTemplate->getLocation(),
11658 SecondTemplate->getSourceRange(),
11659 FunctionTemplatePackParameter)
11660 << SecondTemplate << (
i + 1)
11661 << SecondNTTPD->isParameterPack();
11662 ParameterMismatch =
true;
11668 if (ParameterMismatch) {
11681 diag::err_module_odr_violation_mismatch_decl_unknown)
11682 << FirstRecord << FirstModule.empty() << FirstModule << FirstDiffType
11685 diag::note_module_odr_violation_mismatch_decl_unknown)
11686 << SecondModule << FirstDiffType << SecondDecl->
getSourceRange();
11697 Diag(Merge.first->getLocation(),
11698 diag::err_module_odr_violation_different_instantiations)
11704 for (
auto &Merge : FunctionOdrMergeFailures) {
11705 enum ODRFunctionDifference {
11709 ParameterSingleDefaultArgument,
11710 ParameterDifferentDefaultArgument,
11715 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstFunction);
11717 bool Diagnosed =
false;
11718 for (
auto &SecondFunction : Merge.second) {
11720 if (FirstFunction == SecondFunction)
11723 std::string SecondModule =
11724 getOwningModuleNameForDiagnostic(SecondFunction);
11726 auto ODRDiagError = [FirstFunction, &FirstModule,
11728 ODRFunctionDifference DiffType) {
11729 return Diag(Loc, diag::err_module_odr_violation_function)
11730 << FirstFunction << FirstModule.empty() << FirstModule << Range
11735 ODRFunctionDifference DiffType) {
11736 return Diag(Loc, diag::note_module_odr_violation_function)
11737 << SecondModule << Range << DiffType;
11740 if (ComputeQualTypeODRHash(FirstFunction->
getReturnType()) !=
11741 ComputeQualTypeODRHash(SecondFunction->getReturnType())) {
11745 ODRDiagNote(SecondFunction->getReturnTypeSourceRange().getBegin(),
11746 SecondFunction->getReturnTypeSourceRange(), ReturnType)
11747 << SecondFunction->getReturnType();
11752 assert(FirstFunction->
param_size() == SecondFunction->param_size() &&
11753 "Merged functions with different number of parameters");
11755 auto ParamSize = FirstFunction->
param_size();
11756 bool ParameterMismatch =
false;
11757 for (
unsigned I = 0; I < ParamSize; ++I) {
11759 auto *SecondParam = SecondFunction->getParamDecl(I);
11761 assert(getContext().hasSameType(FirstParam->getType(),
11762 SecondParam->getType()) &&
11763 "Merged function has different parameter types.");
11765 if (FirstParam->getDeclName() != SecondParam->getDeclName()) {
11766 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11768 << I + 1 << FirstParam->getDeclName();
11769 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11771 << I + 1 << SecondParam->getDeclName();
11772 ParameterMismatch =
true;
11776 QualType FirstParamType = FirstParam->getType();
11777 QualType SecondParamType = SecondParam->getType();
11778 if (FirstParamType != SecondParamType &&
11779 ComputeQualTypeODRHash(FirstParamType) !=
11780 ComputeQualTypeODRHash(SecondParamType)) {
11783 ODRDiagError(FirstParam->getLocation(),
11784 FirstParam->getSourceRange(), ParameterType)
11785 << (I + 1) << FirstParamType <<
true 11786 << ParamDecayedType->getOriginalType();
11788 ODRDiagError(FirstParam->getLocation(),
11789 FirstParam->getSourceRange(), ParameterType)
11790 << (I + 1) << FirstParamType <<
false;
11795 ODRDiagNote(SecondParam->getLocation(),
11796 SecondParam->getSourceRange(), ParameterType)
11797 << (I + 1) << SecondParamType <<
true 11798 << ParamDecayedType->getOriginalType();
11800 ODRDiagNote(SecondParam->getLocation(),
11801 SecondParam->getSourceRange(), ParameterType)
11802 << (I + 1) << SecondParamType <<
false;
11804 ParameterMismatch =
true;
11808 const Expr *FirstInit = FirstParam->getInit();
11809 const Expr *SecondInit = SecondParam->getInit();
11810 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
11811 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11812 ParameterSingleDefaultArgument)
11813 << (I + 1) << (FirstInit ==
nullptr)
11815 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11816 ParameterSingleDefaultArgument)
11817 << (I + 1) << (SecondInit ==
nullptr)
11819 ParameterMismatch =
true;
11823 if (FirstInit && SecondInit &&
11824 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
11825 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11826 ParameterDifferentDefaultArgument)
11828 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11829 ParameterDifferentDefaultArgument)
11831 ParameterMismatch =
true;
11835 assert(ComputeSubDeclODRHash(FirstParam) ==
11836 ComputeSubDeclODRHash(SecondParam) &&
11837 "Undiagnosed parameter difference.");
11840 if (ParameterMismatch) {
11849 ODRDiagNote(SecondFunction->getLocation(),
11850 SecondFunction->getSourceRange(), FunctionBody);
11855 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
11859 for (
auto &Merge : EnumOdrMergeFailures) {
11860 enum ODREnumDifference {
11862 EnumTagKeywordMismatch,
11863 SingleSpecifiedType,
11864 DifferentSpecifiedTypes,
11865 DifferentNumberEnumConstants,
11867 EnumConstantSingleInitilizer,
11868 EnumConstantDifferentInitilizer,
11873 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
11876 EnumDecl *FirstEnum = Merge.first;
11877 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstEnum);
11881 auto PopulateHashes = [&ComputeSubDeclODRHash, FirstEnum](
11883 for (
auto *D :
Enum->decls()) {
11888 assert(isa<EnumConstantDecl>(D) &&
"Unexpected Decl kind");
11889 Hashes.emplace_back(cast<EnumConstantDecl>(D),
11890 ComputeSubDeclODRHash(D));
11893 DeclHashes FirstHashes;
11894 PopulateHashes(FirstHashes, FirstEnum);
11895 bool Diagnosed =
false;
11896 for (
auto &SecondEnum : Merge.second) {
11898 if (FirstEnum == SecondEnum)
11901 std::string SecondModule =
11902 getOwningModuleNameForDiagnostic(SecondEnum);
11904 auto ODRDiagError = [FirstEnum, &FirstModule,
11906 ODREnumDifference DiffType) {
11907 return Diag(Loc, diag::err_module_odr_violation_enum)
11908 << FirstEnum << FirstModule.empty() << FirstModule << Range
11913 ODREnumDifference DiffType) {
11914 return Diag(Loc, diag::note_module_odr_violation_enum)
11915 << SecondModule << Range << DiffType;
11918 if (FirstEnum->
isScoped() != SecondEnum->isScoped()) {
11922 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11924 << SecondEnum->isScoped();
11929 if (FirstEnum->
isScoped() && SecondEnum->isScoped()) {
11931 SecondEnum->isScopedUsingClassTag()) {
11933 EnumTagKeywordMismatch)
11935 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11936 EnumTagKeywordMismatch)
11937 << SecondEnum->isScopedUsingClassTag();
11948 SecondEnum->getIntegerTypeSourceInfo()
11949 ? SecondEnum->getIntegerTypeSourceInfo()->getType()
11951 if (FirstUnderlyingType.
isNull() != SecondUnderlyingType.
isNull()) {
11953 SingleSpecifiedType)
11954 << !FirstUnderlyingType.
isNull();
11955 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11956 SingleSpecifiedType)
11957 << !SecondUnderlyingType.
isNull();
11962 if (!FirstUnderlyingType.
isNull() && !SecondUnderlyingType.
isNull()) {
11963 if (ComputeQualTypeODRHash(FirstUnderlyingType) !=
11964 ComputeQualTypeODRHash(SecondUnderlyingType)) {
11966 DifferentSpecifiedTypes)
11967 << FirstUnderlyingType;
11968 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11969 DifferentSpecifiedTypes)
11970 << SecondUnderlyingType;
11976 DeclHashes SecondHashes;
11977 PopulateHashes(SecondHashes, SecondEnum);
11979 if (FirstHashes.size() != SecondHashes.size()) {
11981 DifferentNumberEnumConstants)
11982 << (
int)FirstHashes.size();
11983 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11984 DifferentNumberEnumConstants)
11985 << (
int)SecondHashes.size();
11990 for (
unsigned I = 0; I < FirstHashes.size(); ++I) {
11991 if (FirstHashes[I].second == SecondHashes[I].second)
12001 << I + 1 << FirstEnumConstant;
12004 << I + 1 << SecondEnumConstant;
12011 if (!FirstInit && !SecondInit)
12014 if (!FirstInit || !SecondInit) {
12017 EnumConstantSingleInitilizer)
12018 << I + 1 << FirstEnumConstant << (FirstInit !=
nullptr);
12021 EnumConstantSingleInitilizer)
12022 << I + 1 << SecondEnumConstant << (SecondInit !=
nullptr);
12027 if (ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
12030 EnumConstantDifferentInitilizer)
12031 << I + 1 << FirstEnumConstant;
12034 EnumConstantDifferentInitilizer)
12035 << I + 1 << SecondEnumConstant;
12043 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
12048 if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get())
12049 ReadTimer->startTimer();
12053 assert(NumCurrentElementsDeserializing &&
12054 "FinishedDeserializing not paired with StartedDeserializing");
12055 if (NumCurrentElementsDeserializing == 1) {
12058 finishPendingActions();
12060 --NumCurrentElementsDeserializing;
12062 if (NumCurrentElementsDeserializing == 0) {
12068 while (!PendingExceptionSpecUpdates.empty() ||
12069 !PendingDeducedTypeUpdates.empty()) {
12070 auto ESUpdates = std::move(PendingExceptionSpecUpdates);
12071 PendingExceptionSpecUpdates.clear();
12072 for (
auto Update : ESUpdates) {
12073 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
12075 auto ESI = FPT->getExtProtoInfo().ExceptionSpec;
12076 if (
auto *Listener = getContext().getASTMutationListener())
12077 Listener->ResolvedExceptionSpec(cast<FunctionDecl>(
Update.second));
12078 for (
auto *Redecl :
Update.second->redecls())
12079 getContext().adjustExceptionSpec(cast<FunctionDecl>(Redecl), ESI);
12082 auto DTUpdates = std::move(PendingDeducedTypeUpdates);
12083 PendingDeducedTypeUpdates.clear();
12084 for (
auto Update : DTUpdates) {
12085 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
12087 getContext().adjustDeducedFunctionResultType(
Update.first,
12093 ReadTimer->stopTimer();
12095 diagnoseOdrViolations();
12100 PassInterestingDeclsToConsumer();
12107 auto It = PendingFakeLookupResults.find(II);
12108 if (It != PendingFakeLookupResults.end()) {
12109 for (
auto *ND : It->second)
12110 SemaObj->IdResolver.RemoveDecl(ND);
12114 It->second.clear();
12118 if (SemaObj->IdResolver.tryAddTopLevelDecl(D, Name) && SemaObj->TUScope) {
12119 SemaObj->TUScope->AddDecl(D);
12120 }
else if (SemaObj->TUScope) {
12124 if (std::find(SemaObj->IdResolver.begin(Name),
12125 SemaObj->IdResolver.end(), D) != SemaObj->IdResolver.end())
12126 SemaObj->TUScope->AddDecl(D);
12133 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
12134 StringRef isysroot,
bool DisableValidation,
12135 bool AllowASTWithCompilerErrors,
12136 bool AllowConfigurationMismatch,
bool ValidateSystemInputs,
12137 bool UseGlobalIndex,
12138 std::unique_ptr<llvm::Timer> ReadTimer)
12139 : Listener(DisableValidation
12142 SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()),
12143 PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()), PP(PP),
12144 ContextObj(Context), ModuleMgr(PP.getFileManager(), ModuleCache,
12145 PCHContainerRdr, PP.getHeaderSearchInfo()),
12146 DummyIdResolver(PP), ReadTimer(
std::move(ReadTimer)), isysroot(isysroot),
12147 DisableValidation(DisableValidation),
12148 AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
12149 AllowConfigurationMismatch(AllowConfigurationMismatch),
12150 ValidateSystemInputs(ValidateSystemInputs),
12151 UseGlobalIndex(UseGlobalIndex), CurrSwitchCaseStmts(&SwitchCaseStmts) {
12154 for (
const auto &Ext : Extensions) {
12155 auto BlockName = Ext->getExtensionMetadata().BlockName;
12156 auto Known = ModuleFileExtensions.find(BlockName);
12157 if (Known != ModuleFileExtensions.end()) {
12158 Diags.
Report(diag::warn_duplicate_module_file_extension)
12163 ModuleFileExtensions.insert({BlockName, Ext});
12168 if (OwnsDeserializationListener)
12169 delete DeserializationListener;
12173 return SemaObj ? SemaObj->
IdResolver : DummyIdResolver;
12177 unsigned AbbrevID) {
12180 return Cursor.readRecord(AbbrevID, Record);
12188 switch (Record.readInt()) {
12195 case OMPC_num_threads:
12204 case OMPC_allocator:
12207 case OMPC_collapse:
12213 case OMPC_proc_bind:
12216 case OMPC_schedule:
12228 case OMPC_mergeable:
12255 case OMPC_unified_address:
12258 case OMPC_unified_shared_memory:
12261 case OMPC_reverse_offload:
12264 case OMPC_dynamic_allocators:
12267 case OMPC_atomic_default_mem_order:
12273 case OMPC_firstprivate:
12276 case OMPC_lastprivate:
12282 case OMPC_reduction:
12285 case OMPC_task_reduction:
12288 case OMPC_in_reduction:
12300 case OMPC_copyprivate:
12306 case OMPC_depend: {
12307 unsigned NumVars = Record.readInt();
12308 unsigned NumLoops = Record.readInt();
12317 Sizes.
NumVars = Record.readInt();
12324 case OMPC_num_teams:
12327 case OMPC_thread_limit:
12330 case OMPC_priority:
12333 case OMPC_grainsize:
12336 case OMPC_num_tasks:
12342 case OMPC_dist_schedule:
12345 case OMPC_defaultmap:
12350 Sizes.
NumVars = Record.readInt();
12359 Sizes.
NumVars = Record.readInt();
12366 case OMPC_use_device_ptr: {
12368 Sizes.
NumVars = Record.readInt();
12375 case OMPC_is_device_ptr: {
12377 Sizes.
NumVars = Record.readInt();
12384 case OMPC_allocate:
12390 C->
setLocEnd(Record.readSourceLocation());
12401 VisitOMPClauseWithPreInit(C);
12405 void OMPClauseReader::VisitOMPIfClause(
OMPIfClause *
C) {
12406 VisitOMPClauseWithPreInit(C);
12407 C->setNameModifier(static_cast<OpenMPDirectiveKind>(Record.readInt()));
12408 C->setNameModifierLoc(Record.readSourceLocation());
12409 C->setColonLoc(Record.readSourceLocation());
12410 C->setCondition(Record.readSubExpr());
12415 C->setCondition(Record.readSubExpr());
12420 VisitOMPClauseWithPreInit(C);
12421 C->setNumThreads(Record.readSubExpr());
12426 C->setSafelen(Record.readSubExpr());
12431 C->setSimdlen(Record.readSubExpr());
12436 C->setAllocator(Record.readExpr());
12441 C->setNumForLoops(Record.readSubExpr());
12447 static_cast<OpenMPDefaultClauseKind>(Record.readInt()));
12449 C->setDefaultKindKwLoc(Record.readSourceLocation());
12453 C->setProcBindKind(
12454 static_cast<OpenMPProcBindClauseKind>(Record.readInt()));
12456 C->setProcBindKindKwLoc(Record.readSourceLocation());
12460 VisitOMPClauseWithPreInit(C);
12461 C->setScheduleKind(
12462 static_cast<OpenMPScheduleClauseKind>(Record.readInt()));
12463 C->setFirstScheduleModifier(
12464 static_cast<OpenMPScheduleClauseModifier>(Record.readInt()));
12465 C->setSecondScheduleModifier(
12466 static_cast<OpenMPScheduleClauseModifier>(Record.readInt()));
12467 C->setChunkSize(Record.readSubExpr());
12468 C->setLParenLoc(Record.readSourceLocation());
12469 C->setFirstScheduleModifierLoc(Record.readSourceLocation());
12470 C->setSecondScheduleModifierLoc(Record.readSourceLocation());
12471 C->setScheduleKindLoc(Record.readSourceLocation());
12472 C->setCommaLoc(Record.readSourceLocation());
12476 C->setNumForLoops(Record.readSubExpr());
12477 for (
unsigned I = 0, E = C->NumberOfLoops; I < E; ++I)
12479 for (
unsigned I = 0, E = C->NumberOfLoops; I < E; ++I)
12490 void OMPClauseReader::VisitOMPReadClause(
OMPReadClause *) {}
12502 void OMPClauseReader::VisitOMPSIMDClause(
OMPSIMDClause *) {}
12508 void OMPClauseReader::VisitOMPUnifiedSharedMemoryClause(
12517 void OMPClauseReader::VisitOMPAtomicDefaultMemOrderClause(
12519 C->setAtomicDefaultMemOrderKind(
12520 static_cast<OpenMPAtomicDefaultMemOrderClauseKind>(Record.readInt()));
12522 C->setAtomicDefaultMemOrderKindKwLoc(Record.readSourceLocation());
12529 Vars.reserve(NumVars);
12530 for (
unsigned i = 0;
i != NumVars; ++
i)
12531 Vars.push_back(Record.readSubExpr());
12534 for (
unsigned i = 0;
i != NumVars; ++
i)
12535 Vars.push_back(Record.readSubExpr());
12536 C->setPrivateCopies(Vars);
12540 VisitOMPClauseWithPreInit(C);
12544 Vars.reserve(NumVars);
12545 for (
unsigned i = 0;
i != NumVars; ++
i)
12546 Vars.push_back(Record.readSubExpr());
12549 for (
unsigned i = 0;
i != NumVars; ++
i)
12550 Vars.push_back(Record.readSubExpr());
12551 C->setPrivateCopies(Vars);
12553 for (
unsigned i = 0;
i != NumVars; ++
i)
12554 Vars.push_back(Record.readSubExpr());
12559 VisitOMPClauseWithPostUpdate(C);
12563 Vars.reserve(NumVars);
12564 for (
unsigned i = 0;
i != NumVars; ++
i)
12565 Vars.push_back(Record.readSubExpr());
12568 for (
unsigned i = 0;
i != NumVars; ++
i)
12569 Vars.push_back(Record.readSubExpr());
12572 for (
unsigned i = 0;
i != NumVars; ++
i)
12573 Vars.push_back(Record.readSubExpr());
12574 C->setSourceExprs(Vars);
12576 for (
unsigned i = 0;
i != NumVars; ++
i)
12577 Vars.push_back(Record.readSubExpr());
12578 C->setDestinationExprs(Vars);
12580 for (
unsigned i = 0;
i != NumVars; ++
i)
12581 Vars.push_back(Record.readSubExpr());
12582 C->setAssignmentOps(Vars);
12589 Vars.reserve(NumVars);
12590 for (
unsigned i = 0;
i != NumVars; ++
i)
12591 Vars.push_back(Record.readSubExpr());
12596 VisitOMPClauseWithPostUpdate(C);
12598 C->setColonLoc(Record.readSourceLocation());
12601 Record.readDeclarationNameInfo(DNI);
12602 C->setQualifierLoc(NNSL);
12603 C->setNameInfo(DNI);
12607 Vars.reserve(NumVars);
12608 for (
unsigned i = 0;
i != NumVars; ++
i)
12609 Vars.push_back(Record.readSubExpr());
12612 for (
unsigned i = 0;
i != NumVars; ++
i)
12613 Vars.push_back(Record.readSubExpr());
12614 C->setPrivates(Vars);
12616 for (
unsigned i = 0;
i != NumVars; ++
i)
12617 Vars.push_back(Record.readSubExpr());
12618 C->setLHSExprs(Vars);
12620 for (
unsigned i = 0;
i != NumVars; ++
i)
12621 Vars.push_back(Record.readSubExpr());
12622 C->setRHSExprs(Vars);
12624 for (
unsigned i = 0;
i != NumVars; ++
i)
12625 Vars.push_back(Record.readSubExpr());
12626 C->setReductionOps(Vars);
12630 VisitOMPClauseWithPostUpdate(C);
12632 C->setColonLoc(Record.readSourceLocation());
12635 Record.readDeclarationNameInfo(DNI);
12636 C->setQualifierLoc(NNSL);
12637 C->setNameInfo(DNI);
12641 Vars.reserve(NumVars);
12642 for (
unsigned I = 0; I != NumVars; ++I)
12643 Vars.push_back(Record.readSubExpr());
12646 for (
unsigned I = 0; I != NumVars; ++I)
12647 Vars.push_back(Record.readSubExpr());
12648 C->setPrivates(Vars);
12650 for (
unsigned I = 0; I != NumVars; ++I)
12651 Vars.push_back(Record.readSubExpr());
12652 C->setLHSExprs(Vars);
12654 for (
unsigned I = 0; I != NumVars; ++I)
12655 Vars.push_back(Record.readSubExpr());
12656 C->setRHSExprs(Vars);
12658 for (
unsigned I = 0; I != NumVars; ++I)
12659 Vars.push_back(Record.readSubExpr());
12660 C->setReductionOps(Vars);
12664 VisitOMPClauseWithPostUpdate(C);
12666 C->setColonLoc(Record.readSourceLocation());
12669 Record.readDeclarationNameInfo(DNI);
12670 C->setQualifierLoc(NNSL);
12671 C->setNameInfo(DNI);
12675 Vars.reserve(NumVars);
12676 for (
unsigned I = 0; I != NumVars; ++I)
12677 Vars.push_back(Record.readSubExpr());
12680 for (
unsigned I = 0; I != NumVars; ++I)
12681 Vars.push_back(Record.readSubExpr());
12682 C->setPrivates(Vars);
12684 for (
unsigned I = 0; I != NumVars; ++I)
12685 Vars.push_back(Record.readSubExpr());
12686 C->setLHSExprs(Vars);
12688 for (
unsigned I = 0; I != NumVars; ++I)
12689 Vars.push_back(Record.readSubExpr());
12690 C->setRHSExprs(Vars);
12692 for (
unsigned I = 0; I != NumVars; ++I)
12693 Vars.push_back(Record.readSubExpr());
12694 C->setReductionOps(Vars);
12696 for (
unsigned I = 0; I != NumVars; ++I)
12697 Vars.push_back(Record.readSubExpr());
12698 C->setTaskgroupDescriptors(Vars);
12702 VisitOMPClauseWithPostUpdate(C);
12704 C->setColonLoc(Record.readSourceLocation());
12705 C->setModifier(static_cast<OpenMPLinearClauseKind>(Record.readInt()));
12706 C->setModifierLoc(Record.readSourceLocation());
12709 Vars.reserve(NumVars);
12710 for (
unsigned i = 0;
i != NumVars; ++
i)
12711 Vars.push_back(Record.readSubExpr());
12714 for (
unsigned i = 0;
i != NumVars; ++
i)
12715 Vars.push_back(Record.readSubExpr());
12716 C->setPrivates(Vars);
12718 for (
unsigned i = 0;
i != NumVars; ++
i)
12719 Vars.push_back(Record.readSubExpr());
12722 for (
unsigned i = 0;
i != NumVars; ++
i)
12723 Vars.push_back(Record.readSubExpr());
12724 C->setUpdates(Vars);
12726 for (
unsigned i = 0;
i != NumVars; ++
i)
12727 Vars.push_back(Record.readSubExpr());
12728 C->setFinals(Vars);
12729 C->setStep(Record.readSubExpr());
12730 C->setCalcStep(Record.readSubExpr());
12734 C->setLParenLoc(Record.readSourceLocation());
12736 unsigned NumVars = C->varlist_size();
12738 Vars.reserve(NumVars);
12739 for (
unsigned i = 0;
i != NumVars; ++
i)
12740 Vars.push_back(Record.readSubExpr());
12741 C->setVarRefs(Vars);
12742 C->setAlignment(Record.readSubExpr());
12746 C->setLParenLoc(Record.readSourceLocation());
12747 unsigned NumVars = C->varlist_size();
12749 Exprs.reserve(NumVars);
12750 for (
unsigned i = 0;
i != NumVars; ++
i)
12751 Exprs.push_back(Record.readSubExpr());
12752 C->setVarRefs(Exprs);
12754 for (
unsigned i = 0;
i != NumVars; ++
i)
12755 Exprs.push_back(Record.readSubExpr());
12756 C->setSourceExprs(Exprs);
12758 for (
unsigned i = 0;
i != NumVars; ++
i)
12759 Exprs.push_back(Record.readSubExpr());
12760 C->setDestinationExprs(Exprs);
12762 for (
unsigned i = 0;
i != NumVars; ++
i)
12763 Exprs.push_back(Record.readSubExpr());
12764 C->setAssignmentOps(Exprs);
12768 C->setLParenLoc(Record.readSourceLocation());
12769 unsigned NumVars = C->varlist_size();
12771 Exprs.reserve(NumVars);
12772 for (
unsigned i = 0;
i != NumVars; ++
i)
12773 Exprs.push_back(Record.readSubExpr());
12774 C->setVarRefs(Exprs);
12776 for (
unsigned i = 0;
i != NumVars; ++
i)
12777 Exprs.push_back(Record.readSubExpr());
12778 C->setSourceExprs(Exprs);
12780 for (
unsigned i = 0;
i != NumVars; ++
i)
12781 Exprs.push_back(Record.readSubExpr());
12782 C->setDestinationExprs(Exprs);
12784 for (
unsigned i = 0;
i != NumVars; ++
i)
12785 Exprs.push_back(Record.readSubExpr());
12786 C->setAssignmentOps(Exprs);
12790 C->setLParenLoc(Record.readSourceLocation());
12791 unsigned NumVars = C->varlist_size();
12793 Vars.reserve(NumVars);
12794 for (
unsigned i = 0;
i != NumVars; ++
i)
12795 Vars.push_back(Record.readSubExpr());
12796 C->setVarRefs(Vars);
12800 C->setLParenLoc(Record.readSourceLocation());
12801 C->setDependencyKind(
12802 static_cast<OpenMPDependClauseKind>(Record.readInt()));
12803 C->setDependencyLoc(Record.readSourceLocation());
12804 C->setColonLoc(Record.readSourceLocation());
12805 unsigned NumVars = C->varlist_size();
12807 Vars.reserve(NumVars);
12808 for (
unsigned I = 0; I != NumVars; ++I)
12809 Vars.push_back(Record.readSubExpr());
12810 C->setVarRefs(Vars);
12811 for (
unsigned I = 0, E = C->
getNumLoops(); I < E; ++I)
12816 VisitOMPClauseWithPreInit(C);
12817 C->setDevice(Record.readSubExpr());
12821 void OMPClauseReader::VisitOMPMapClause(
OMPMapClause *C) {
12822 C->setLParenLoc(Record.readSourceLocation());
12824 C->setMapTypeModifier(
12825 I, static_cast<OpenMPMapModifierKind>(Record.readInt()));
12826 C->setMapTypeModifierLoc(I, Record.readSourceLocation());
12830 Record.readDeclarationNameInfo(DNI);
12833 static_cast<OpenMPMapClauseKind>(Record.readInt()));
12834 C->setMapLoc(Record.readSourceLocation());
12835 C->setColonLoc(Record.readSourceLocation());
12836 auto NumVars = C->varlist_size();
12842 Vars.reserve(NumVars);
12843 for (
unsigned i = 0;
i != NumVars; ++
i)
12844 Vars.push_back(Record.readExpr());
12845 C->setVarRefs(Vars);
12848 UDMappers.reserve(NumVars);
12849 for (
unsigned I = 0; I < NumVars; ++I)
12850 UDMappers.push_back(Record.readExpr());
12854 Decls.reserve(UniqueDecls);
12855 for (
unsigned i = 0;
i < UniqueDecls; ++
i)
12856 Decls.push_back(Record.readDeclAs<
ValueDecl>());
12860 ListsPerDecl.reserve(UniqueDecls);
12861 for (
unsigned i = 0;
i < UniqueDecls; ++
i)
12862 ListsPerDecl.push_back(Record.readInt());
12866 ListSizes.reserve(TotalLists);
12867 for (
unsigned i = 0;
i < TotalLists; ++
i)
12868 ListSizes.push_back(Record.readInt());
12872 Components.reserve(TotalComponents);
12873 for (
unsigned i = 0;
i < TotalComponents; ++
i) {
12874 Expr *AssociatedExpr = Record.readExpr();
12875 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
12877 AssociatedExpr, AssociatedDecl));
12884 C->setColonLoc(Record.readSourceLocation());
12885 C->setAllocator(Record.readSubExpr());
12888 Vars.reserve(NumVars);
12889 for (
unsigned i = 0;
i != NumVars; ++
i)
12890 Vars.push_back(Record.readSubExpr());
12895 VisitOMPClauseWithPreInit(C);
12896 C->setNumTeams(Record.readSubExpr());
12901 VisitOMPClauseWithPreInit(C);
12902 C->setThreadLimit(Record.readSubExpr());
12907 C->setPriority(Record.readSubExpr());
12912 C->setGrainsize(Record.readSubExpr());
12917 C->setNumTasks(Record.readSubExpr());
12921 void OMPClauseReader::VisitOMPHintClause(
OMPHintClause *C) {
12922 C->setHint(Record.readSubExpr());
12927 VisitOMPClauseWithPreInit(C);
12928 C->setDistScheduleKind(
12929 static_cast<OpenMPDistScheduleClauseKind>(Record.readInt()));
12930 C->setChunkSize(Record.readSubExpr());
12931 C->setLParenLoc(Record.readSourceLocation());
12932 C->setDistScheduleKindLoc(Record.readSourceLocation());
12933 C->setCommaLoc(Record.readSourceLocation());
12937 C->setDefaultmapKind(
12938 static_cast<OpenMPDefaultmapClauseKind>(Record.readInt()));
12939 C->setDefaultmapModifier(
12940 static_cast<OpenMPDefaultmapClauseModifier>(Record.readInt()));
12941 C->setLParenLoc(Record.readSourceLocation());
12942 C->setDefaultmapModifierLoc(Record.readSourceLocation());
12943 C->setDefaultmapKindLoc(Record.readSourceLocation());
12946 void OMPClauseReader::VisitOMPToClause(
OMPToClause *C) {
12947 C->setLParenLoc(Record.readSourceLocation());
12950 Record.readDeclarationNameInfo(DNI);
12952 auto NumVars = C->varlist_size();
12958 Vars.reserve(NumVars);
12959 for (
unsigned i = 0;
i != NumVars; ++
i)
12960 Vars.push_back(Record.readSubExpr());
12961 C->setVarRefs(Vars);
12964 UDMappers.reserve(NumVars);
12965 for (
unsigned I = 0; I < NumVars; ++I)
12966 UDMappers.push_back(Record.readSubExpr());
12970 Decls.reserve(UniqueDecls);
12971 for (
unsigned i = 0;
i < UniqueDecls; ++
i)
12972 Decls.push_back(Record.readDeclAs<
ValueDecl>());
12976 ListsPerDecl.reserve(UniqueDecls);
12977 for (
unsigned i = 0;
i < UniqueDecls; ++
i)
12978 ListsPerDecl.push_back(Record.readInt());
12982 ListSizes.reserve(TotalLists);
12983 for (
unsigned i = 0;
i < TotalLists; ++
i)
12984 ListSizes.push_back(Record.readInt());
12988 Components.reserve(TotalComponents);
12989 for (
unsigned i = 0;
i < TotalComponents; ++
i) {
12990 Expr *AssociatedExpr = Record.readSubExpr();
12991 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
12993 AssociatedExpr, AssociatedDecl));
12998 void OMPClauseReader::VisitOMPFromClause(
OMPFromClause *C) {
12999 C->setLParenLoc(Record.readSourceLocation());
13002 Record.readDeclarationNameInfo(DNI);
13004 auto NumVars = C->varlist_size();
13010 Vars.reserve(NumVars);
13011 for (
unsigned i = 0;
i != NumVars; ++
i)
13012 Vars.push_back(Record.readSubExpr());
13013 C->setVarRefs(Vars);
13016 UDMappers.reserve(NumVars);
13017 for (
unsigned I = 0; I < NumVars; ++I)
13018 UDMappers.push_back(Record.readSubExpr());
13022 Decls.reserve(UniqueDecls);
13023 for (
unsigned i = 0;
i < UniqueDecls; ++
i)
13024 Decls.push_back(Record.readDeclAs<
ValueDecl>());
13028 ListsPerDecl.reserve(UniqueDecls);
13029 for (
unsigned i = 0;
i < UniqueDecls; ++
i)
13030 ListsPerDecl.push_back(Record.readInt());
13034 ListSizes.reserve(TotalLists);
13035 for (
unsigned i = 0;
i < TotalLists; ++
i)
13036 ListSizes.push_back(Record.readInt());
13040 Components.reserve(TotalComponents);
13041 for (
unsigned i = 0;
i < TotalComponents; ++
i) {
13042 Expr *AssociatedExpr = Record.readSubExpr();
13043 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
13045 AssociatedExpr, AssociatedDecl));
13051 C->setLParenLoc(Record.readSourceLocation());
13052 auto NumVars = C->varlist_size();
13058 Vars.reserve(NumVars);
13059 for (
unsigned i = 0;
i != NumVars; ++
i)
13060 Vars.push_back(Record.readSubExpr());
13061 C->setVarRefs(Vars);
13063 for (
unsigned i = 0;
i != NumVars; ++
i)
13064 Vars.push_back(Record.readSubExpr());
13065 C->setPrivateCopies(Vars);
13067 for (
unsigned i = 0;
i != NumVars; ++
i)
13068 Vars.push_back(Record.readSubExpr());
13072 Decls.reserve(UniqueDecls);
13073 for (
unsigned i = 0;
i < UniqueDecls; ++
i)
13074 Decls.push_back(Record.readDeclAs<
ValueDecl>());
13078 ListsPerDecl.reserve(UniqueDecls);
13079 for (
unsigned i = 0;
i < UniqueDecls; ++
i)
13080 ListsPerDecl.push_back(Record.readInt());
13084 ListSizes.reserve(TotalLists);
13085 for (
unsigned i = 0;
i < TotalLists; ++
i)
13086 ListSizes.push_back(Record.readInt());
13090 Components.reserve(TotalComponents);
13091 for (
unsigned i = 0;
i < TotalComponents; ++
i) {
13092 Expr *AssociatedExpr = Record.readSubExpr();
13093 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
13095 AssociatedExpr, AssociatedDecl));
13101 C->setLParenLoc(Record.readSourceLocation());
13102 auto NumVars = C->varlist_size();
13108 Vars.reserve(NumVars);
13109 for (
unsigned i = 0;
i != NumVars; ++
i)
13110 Vars.push_back(Record.readSubExpr());
13111 C->setVarRefs(Vars);
13115 Decls.reserve(UniqueDecls);
13116 for (
unsigned i = 0;
i < UniqueDecls; ++
i)
13117 Decls.push_back(Record.readDeclAs<
ValueDecl>());
13121 ListsPerDecl.reserve(UniqueDecls);
13122 for (
unsigned i = 0;
i < UniqueDecls; ++
i)
13123 ListsPerDecl.push_back(Record.readInt());
13127 ListSizes.reserve(TotalLists);
13128 for (
unsigned i = 0;
i < TotalLists; ++
i)
13129 ListSizes.push_back(Record.readInt());
13133 Components.reserve(TotalComponents);
13134 for (
unsigned i = 0;
i < TotalComponents; ++
i) {
13135 Expr *AssociatedExpr = Record.readSubExpr();
13136 auto *AssociatedDecl = Record.readDeclAs<
ValueDecl>();
13138 AssociatedExpr, AssociatedDecl));
llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx)
Read an integral value.
Decl * GetExistingDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
unsigned IsAvailable
Whether this module is available in the current translation unit.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
CanQualType SatShortAccumTy
void setSourceOrder(int Pos)
Set the source order of this initializer.
CanQualType SatUnsignedLongFractTy
Defines the clang::ASTContext interface.
The ObjC 'SEL' type.
static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts, const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts, StringRef ExistingModuleCachePath)
Determine whether the given AST file is acceptable to load into a translation unit with the given lan...
const FileEntry * OrigEntry
Reference to the file entry representing this ContentCache.
void updateOutOfDateSelector(Selector Sel) override
Load the contents of the global method pool for a given selector if necessary.
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override
Finds all the visible declarations with a given name.
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons...
Record code for the preprocessor options table.
std::vector< unsigned > PreloadIdentifierOffsets
Offsets of identifiers that we're going to preload within IdentifierTableData.
SmallVector< UnresolvedExportDecl, 2 > UnresolvedExports
The set of export declarations that have yet to be resolved.
The 'unsigned _Accum' type.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
static const Decl * getCanonicalDecl(const Decl *D)
The client can handle an AST file that cannot load because it was built with a different version of C...
void setInfo(const DeclarationNameLoc &Info)
Represents a function declaration or definition.
ASTFileSignature Signature
The module signature.
std::string Name
The name of this module.
This represents 'thread_limit' clause in the '#pragma omp ...' directive.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Source range/offset of a preprocessed entity.
serialization::PreprocessedEntityID getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const
Determine the global preprocessed entity ID that corresponds to the given local ID within the given m...
std::vector< std::pair< std::string, bool > > Macros
IdentifierIterator * getIdentifiers() override
Retrieve an iterator into the set of all identifiers in all loaded AST files.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
void * IdentifierLookupTable
A pointer to an on-disk hash table of opaque type IdentifierHashTable.
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
The 'unsigned short _Fract' type.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Record code for potentially unused local typedef names.
Record code for map of Objective-C class definition IDs to the ObjC categories in a module that are a...
Smart pointer class that efficiently represents Objective-C method names.
static void updateModuleTimestamp(ModuleFile &MF)
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
This represents clause 'copyin' in the '#pragma omp ...' directives.
TypedefDecl * getCFConstantStringDecl() const
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
static hash_value_type ComputeHash(Selector Sel)
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system...
static bool checkTargetOptions(const TargetOptions &TargetOpts, const TargetOptions &ExistingTargetOpts, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true)
Compare the given set of target options against an existing set of target options.
A (possibly-)qualified type.
static LLVM_DUMP_METHOD void dumpModuleIDMap(StringRef Name, const ContinuousRangeMap< Key, ModuleFile *, InitialCapacity > &Map)
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...
SourceRange getBraceRange() const
ObjCXXARCStandardLibraryKind
Enumerate the kinds of standard library that.
This header is part of the module (for layering purposes) but should be textually included...
The 'bool' or '_Bool' type.
This represents 'atomic_default_mem_order' clause in the '#pragma omp requires' directive.
void setKWLoc(SourceLocation Loc)
void setRParenLoc(SourceLocation Loc)
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
void setUniqueDecls(ArrayRef< ValueDecl *> UDs)
Set the unique declarations that are in the trailing objects of the class.
Stmt - This represents one statement.
void setStarLoc(SourceLocation Loc)
This represents clause 'in_reduction' in the '#pragma omp task' directives.
Optional< bool > isPreprocessedEntityInFileID(unsigned Index, FileID FID) override
Optionally returns true or false if the preallocated preprocessed entity with index Index came from f...
Expr * getBitWidth() const
void setLAngleLoc(SourceLocation Loc)
bool getEnableAllWarnings() const
void AddQualType(QualType T)
void setExceptionSpecRange(SourceRange R)
SanitizerSet Sanitize
Set of enabled sanitizers.
SourceLocation DirectImportLoc
The source location where the module was explicitly or implicitly imported in the local translation u...
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "C"...
Class that handles pre-initialization statement for some clauses, like 'shedule', 'firstprivate' etc...
ControlRecordTypes
Record types that occur within the control block.
An instance of this object exists for each enum constant that is defined.
void addTopHeaderFilename(StringRef Filename)
Add a top-level header filename associated with this module.
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.
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, uint32_t Raw) const
Read a source location from raw form.
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getEnumType(const EnumDecl *Decl) const
Defines the clang::Module class, which describes a module in the source code.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
Decl - This represents one declaration (or definition), e.g.
This represents 'grainsize' clause in the '#pragma omp ...' directive.
SmallVector< uint64_t, 4 > PreloadSLocEntries
SLocEntries that we're going to preload.
Module * getCurrentModule()
Retrieves the module that we're currently building, if any.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
TagDecl * getDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
CanQualType ObjCBuiltinSelTy
RetTy Visit(TypeLoc TyLoc)
static constexpr unsigned NumberOfModifiers
Number of allowed map-type-modifiers.
void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length, SmallVectorImpl< Decl *> &Decls) override
Get the decls that are contained in a file in the Offset/Length range.
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
void VisitFunctionTypeLoc(FunctionTypeLoc)
ModuleKind Kind
The type of this module.
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
This represents 'if' clause in the '#pragma omp ...' directive.
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
Defines the C++ template declaration subclasses.
Describes a source location entry (SLocEntry) for a macro expansion.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
std::vector< std::string > Includes
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts, const PreprocessorOptions &ExistingPPOpts, DiagnosticsEngine *Diags, FileManager &FileMgr, std::string &SuggestedPredefines, const LangOptions &LangOpts, bool Validate=true)
Check the preprocessor options deserialized from the control block against the preprocessor options i...
void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl *> &Decls) override
Read the set of delegating constructors known to the external Sema source.
An LValueReferenceType record.
The placeholder type for builtin functions.
Defines the clang::MacroInfo and clang::MacroDirective classes.
const FileEntry * getASTFile() const
The serialized AST file for this module, if one was created.
Defines types useful for describing an Objective-C runtime.
Specifies the submodules that are imported by this submodule.
QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc, VectorType::VectorKind VecKind) const
Return the unique reference to the type for a dependently sized vector of the specified element type...
std::string ModuleName
The name of the module.
void ReadTentativeDefinitions(SmallVectorImpl< VarDecl *> &TentativeDefs) override
Read the set of tentative definitions known to the external Sema source.
CanQualType ARCUnbridgedCastTy
A record that stores the set of declarations that are lexically stored within a given DeclContext...
This represents 'priority' clause in the '#pragma omp ...' directive.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
The module file is out-of-date.
Specifies an umbrella directory.
The base class of the type hierarchy.
CanQualType SatUnsignedAccumTy
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
IdentifierInfo * getLocalIdentifier(ModuleFile &M, unsigned LocalID)
DiagnosticsEngine & getDiagnostics() const
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
unsigned LocalNumObjCCategoriesInMap
The number of redeclaration info entries in ObjCCategoriesMap.
void setHasLineDirectives()
Set the flag that indicates that this FileID has line table entries associated with it...
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
#define CHECK_TARGET_OPT(Field, Name)
A SubstTemplateTypeParmType record.
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void setTemplateKeywordLoc(SourceLocation Loc)
void setFlag(TokenFlags Flag)
Set the specified flag.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Represent a C++ namespace.
Wrapper for source info for typedefs.
static void markIdentifierFromAST(ASTReader &Reader, IdentifierInfo &II)
NamedDecl * getParam(unsigned Idx)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
A container of type source information.
RefQualifierKind RefQualifier
This represents 'update' clause in the '#pragma omp atomic' directive.
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
uint64_t GlobalBitOffset
The global bit offset (or base) of this module.
void setComponents(ArrayRef< MappableComponent > Components, ArrayRef< unsigned > CLSs)
Set the components that are in the trailing objects of the class.
bool isDeclInLexicalTraversal(const Decl *D) const
Determine whether the given declaration is stored in the list of declarations lexically within this c...
Record code for enabled OpenCL extensions.
Record code for the module build directory.
SmallVector< ObjCMethodDecl *, 2 > Instance
Floating point control options.
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
void makeModuleVisible(Module *Mod, Module::NameVisibilityKind NameVisibility, SourceLocation ImportLoc)
Make the entities in the given module and any of its (non-explicit) submodules visible to name lookup...
An ElaboratedType record.
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
An UnresolvedUsingType record.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
bool getSuppressSystemWarnings() const
bool factoryHasMoreThanOneDecl() const
Wrapper for source info for pointers decayed from arrays and functions.
The 'short _Fract' type.
ASTFileSignature Signature
The signature of the module file, which may be used instead of the size and modification time to iden...
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
Represents a C++ constructor within a class.
The 'float' type.
An IncompleteArrayType record.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
The internal '__type_pack_element' template.
diag::Severity getExtensionHandlingBehavior() const
A template template parameter that has been substituted for some other template name.
void addPendingMacro(IdentifierInfo *II, ModuleFile *M, uint64_t MacroDirectivesOffset)
Add a macro to deserialize its macro directive history.
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Specifies a header that is part of the module but must be textually included.
const uint32_t * SLocEntryOffsets
Offsets for all of the source location entries in the AST file.
size_t param_size() const
bool RelocatablePCH
Whether this precompiled header is a relocatable PCH file.
CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a C++ base specifier.
ARC's unbridged-cast placeholder type.
The client can handle an AST file that cannot load because it is out-of-date relative to its input fi...
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
The '__int128_t' type.
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
QualType withFastQualifiers(unsigned TQs) const
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.
static Qualifiers fromOpaqueValue(unsigned opaque)
Represents a variable declaration or definition.
This represents clause 'private' in the '#pragma omp ...' directives.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
Record code for #pragma pack options.
A block with unhashed content.
QualType getReturnType() const
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
This represents 'num_threads' clause in the '#pragma omp ...' directive.
Wrapper for source info for member pointers.
void VisitArrayTypeLoc(ArrayTypeLoc)
Options for controlling the target.
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing)...
const T * getAs() const
Member-template getAs<specific type>'.
Record code for declarations associated with OpenCL extensions.
void CompleteRedeclChain(const Decl *D) override
If any redeclarations of D have been imported since it was last checked, this digs out those redeclar...
The width of the "fast" qualifier mask.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
This represents 'defaultmap' clause in the '#pragma omp ...' directive.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
The value of the next COUNTER to dispense.
ObjCMethodDecl - Represents an instance or class method declaration.
unsigned getLineTableFilenameID(StringRef Str)
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
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
Record code for header search information.
data_type ReadData(Selector, const unsigned char *d, unsigned DataLen)
void setAttrOperandParensRange(SourceRange range)
void setProtocolRAngleLoc(SourceLocation Loc)
Stores a list of template parameters for a TemplateDecl and its derived classes.
void setBegin(SourceLocation b)
This represents implicit clause 'flush' for the '#pragma omp flush' directive.
TemplateName getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param, TemplateName replacement) const
Describes a source location entry (SLocEntry) for a buffer.
Used to hold and unique data used to represent #line information.
Record code for the target options table.
static StringRef bytes(const std::vector< T, Allocator > &v)
void AddTemplateArgument(TemplateArgument TA)
unsigned getTotalComponentsNum() const
Return the total number of components in all lists derived from the clause.
This represents 'reverse_offload' clause in the '#pragma omp requires' directive. ...
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
Record code for the array of eagerly deserialized decls.
std::string PresumedModuleMapFile
The presumed file name for the module map defining this module.
Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
int SLocEntryBaseID
The base ID in the source manager's view of this module.
static OMPTaskReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
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.
Represents a struct/union/class.
C ucontext_t typedef type.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
unsigned varlist_size() const
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
RecordDecl * getCFConstantStringTagDecl() const
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Selector getUnarySelector(IdentifierInfo *ID)
QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced, QualType Replacement) const
Retrieve a substitution-result type.
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
FunctionType::ExtInfo ExtInfo
One of these records is kept for each identifier that is lexed.
A macro directive exported by a module.
void setHasExternalLexicalStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations lexically in this context...
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
void setLocalRangeEnd(SourceLocation L)
void addLazyDecl(ASTContext &C, uintptr_t ID, AccessSpecifier AS)
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
void disableFileContentsOverride(const FileEntry *File)
Disable overridding the contents of a file, previously enabled with overrideFileContents.
Specifies a top-level header that falls into this (sub)module.
std::string ActualOriginalSourceFileName
The actual original source file name that was used to build this AST file.
The block containing comments.
This table allows us to fully hide how we implement multi-keyword caching.
AddModuleResult
The result of attempting to add a new module.
The Objective-C 'SEL' type.
StringLiteral * getMessage()
A library or framework to link against when an entity from this module is used.
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
Iteration over the preprocessed entities.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
static Module * getTopImportImplicitModule(ModuleManager &ModuleMgr, Preprocessor &PP)
Return the top import module if it is implicit, nullptr otherwise.
CXXRecordDecl * getPreviousDecl()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
Record the location of a macro definition.
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.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
SourceLocation getBegin() const
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
Represents a member of a struct/union/class.
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
bool isCPlusPlusOperatorKeyword() const
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 setLParenLoc(SourceLocation Loc)
Sets the location of '('.
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
void setElaboratedKeywordLoc(SourceLocation Loc)
TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template name.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
The 'unsigned long _Fract' type.
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
This represents clause 'to' in the '#pragma omp ...' directives.
void setColonLoc(SourceLocation Loc)
Sets the location of ':'.
SanitizerMask Mask
Bitmask of enabled sanitizers.
The 'long _Fract' type.
Token - This structure provides full information about a lexed token.
void setUmbrellaDir(Module *Mod, const DirectoryEntry *UmbrellaDir, Twine NameAsWritten)
Sets the umbrella directory of the given module to the given directory.
void AddTemplateParameterList(const TemplateParameterList *TPL)
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
Wrapper for source info for unresolved typename using decls.
std::string OriginalDir
The directory that the PCH was originally created in.
void setKind(tok::TokenKind K)
An AttributedType record.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
llvm::OnDiskChainedHashTable< HeaderFileInfoTrait > HeaderFileInfoLookupTable
The on-disk hash table used for known header files.
An object-like macro definition.
void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C)
__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...
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
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 UseGlobalIndex=true, std::unique_ptr< llvm::Timer > ReadTimer={})
Load the AST file and validate its contents against the given Preprocessor.
Specifies the submodules that are re-exported from this submodule.
void setProtocolLoc(unsigned i, SourceLocation Loc)
TemplateParameterList ** TemplParamLists
A new-allocated array of size NumTemplParamLists, containing pointers to the "outer" template paramet...
serialization::MacroID BaseMacroID
Base macro ID for macros local to this module.
bool isBitField() const
Determines whether this field is a bitfield.
Selector getNullarySelector(IdentifierInfo *ID)
The Objective-C 'id' type.
void setLParenLoc(SourceLocation Loc)
unsigned InferExportWildcard
Whether, when inferring submodules, the inferr submodules should export all modules they import (e...
void setAttr(const Attr *A)
void setNameLoc(SourceLocation Loc)
A qualified template name, where the qualification is kept to describe the source code as written...
virtual void HandleInterestingDecl(DeclGroupRef D)
HandleInterestingDecl - Handle the specified interesting declaration.
PreprocessedEntity * ReadPreprocessedEntity(unsigned Index) override
Read a preallocated preprocessed entity from the external source.
void 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...
TypeSourceInfo * GetTypeSourceInfo(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declarator info from the given record.
HeaderSearch & getHeaderSearchInfo() const
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
unsigned getNumProtocols() const
const unsigned NumSpecialTypeIDs
The number of special type IDs.
A convenient class for passing around template argument information.
void setcudaConfigureCallDecl(FunctionDecl *FD)
CanQualType SatShortFractTy
Describes a blob that contains the data for a buffer entry.
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Record code for the language options table.
The 'unsigned short _Accum' type.
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
void AddFunctionDecl(const FunctionDecl *Function, bool SkipBody=false)
void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, const RecordData &Record, unsigned &Idx)
CanQualType SatUnsignedShortAccumTy
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...
An unqualified-id that has been assumed to name a function template that will be found by ADL...
std::string Message
The message provided to the user when there is a conflict.
APValue ReadAPValue(const RecordData &Record, unsigned &Idx)
Read an APValue.
serialization::DeclID getGlobalDeclID(ModuleFile &F, serialization::LocalDeclID LocalID) const
Map from a local declaration ID within a given module to a global declaration ID. ...
Wrapper for source info for functions.
Specifies a conflict with another module.
The signed 128-bit integer type.
unsigned getHash() const
Compute a fingerprint of this key for use in on-disk hash table.
CXXCtorInitializer ** ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a CXXCtorInitializer array.
llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx)
Read a signed integral value.
A UnaryTransformType record.
bool isFileOverridden(const FileEntry *File) const
Returns true if the file contents have been overridden.
void FindExternalLexicalDecls(const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl *> &Decls) override
Read all of the declarations lexically stored in a declaration context.
An ObjCObjectType record.
A ConstantArrayType record.
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
llvm::iterator_range< ModuleDeclIterator > getModuleFileLevelDecls(ModuleFile &Mod)
Wrapper for substituted template type parameters.
std::string getOwningModuleNameForDiagnostic(const Decl *D)
Get the best name we know for the module that owns the given declaration, or an empty string if the d...
Concrete class used by the front-end to report problems and issues.
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID)
Retrieve the global submodule ID given a module and its local ID number.
Record code for #pragma optimize options.
uint32_t BitOffset
Offset in the AST file.
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
StringRef Data
The serialized bitstream data for this file.
Specifies a header that is private to this submodule but must be textually included.
Record code for pending implicit instantiations.
Wrapper for substituted template type parameters.
ExtKind hasExternalDefinitions(const Decl *D) override
CanQualType PseudoObjectTy
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
The internal '__make_integer_seq' template.
void setRParenLoc(SourceLocation Loc)
void setLazyBody(uint64_t Offset)
TemplateArgument ReadTemplateArgument(ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument.
const TemplateArgument & getArg(unsigned Idx) const
Record code for floating point #pragma options.
CommentRecordTypes
Record types used within a comments block.
unsigned NumPreprocessedSkippedRanges
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc...
Defines the Diagnostic-related interfaces.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
static internal_key_type ReadKey(const unsigned char *d, unsigned n)
This represents 'default' clause in the '#pragma omp ...' directive.
void setMustBuildLookupTable()
Mark that there are external lexical declarations that we need to include in our lookup table (and th...
The module file is missing.
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
unsigned IsFromModuleFile
Whether this module was loaded from a module file.
std::string OriginalSourceFileName
The original source file name that was used to build the primary AST file, which may have been modifi...
Wrapper for source info for ObjC interfaces.
Record code for the set of known namespaces, which are used for typo correction.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
static bool isDiagnosedResult(ASTReader::ASTReadResult ARR, unsigned Caps)
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
bool hasRevertedBuiltin() const
True if setNotBuiltin() was called.
Record code for an array of all of the (sub)modules that were imported by the AST file...
This represents 'final' clause in the '#pragma omp ...' directive.
This represents 'mergeable' clause in the '#pragma omp ...' directive.
The 'unsigned short' type.
serialization::DeclID BaseDeclID
Base declaration ID for declarations local to this module.
Present this diagnostic as an error.
const Expr * getInitExpr() const
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
This represents clause 'reduction' in the '#pragma omp ...' directives.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
SourceLocation FirstLoc
The first source location in this module.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
A BlockPointerType record.
void setProtocolLoc(unsigned i, SourceLocation Loc)
A MemberPointerType record.
ContinuousRangeMap< uint32_t, int, 2 > SLocRemap
Remapping table for source locations in this module.
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.
void setLocalRangeBegin(SourceLocation L)
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
Represents an ObjC class declaration.
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
void revertBuiltin()
Revert the identifier to a non-builtin identifier.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
The AST file itself appears corrupted.
unsigned getUniqueDeclarationsNum() const
Return the number of unique base declarations in this clause.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
void dump()
Dump information about the AST reader to standard error.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &Exprs) override
unsigned getNumArgs() const
static ASTFileSignature readASTFileSignature(StringRef PCH)
Reads and return the signature record from PCH's control block, or else returns 0.
A DependentSizedExtVectorType record.
The type of 'nullptr'.
uint64_t PreprocessorDetailStartOffset
The offset of the start of the preprocessor detail cursor.
The '_Sat unsigned long _Fract' type.
CanQualType UnsignedCharTy
Record code for the table of offsets into the block of source-location information.
void setAttrNameLoc(SourceLocation loc)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
A SubstTemplateTypeParmPackType record.
This represents clause 'from' in the '#pragma omp ...' directives.
Objective-C "id" redefinition type.
static std::string ReadString(const RecordData &Record, unsigned &Idx)
TypeCode
Record codes for each kind of type.
Records the location of a macro expansion.
virtual void SelectorRead(serialization::SelectorID iD, Selector Sel)
A selector was read from the AST file.
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
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.
A VariableArrayType record.
This represents 'dynamic_allocators' clause in the '#pragma omp requires' directive.
const FileEntry * getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
void setLazyBody(uint64_t Offset)
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
typename Representation::iterator iterator
Sema - This implements semantic analysis and AST building for C.
const unsigned int NUM_PREDEF_PP_ENTITY_IDS
The number of predefined preprocessed entity IDs.
StringRef getString() const
void setUsedForHeaderGuard(bool Val)
ASTRecordTypes
Record types that occur within the AST block itself.
HashTableTy::const_iterator iterator
A little helper class used to produce diagnostics.
static bool parseModuleFileExtensionMetadata(const SmallVectorImpl< uint64_t > &Record, StringRef Blob, ModuleFileExtensionMetadata &Metadata)
Parse a record and blob containing module file extension metadata.
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
unsigned NumTemplParamLists
The number of "outer" template parameter lists.
Represents a prototype with parameter type info, e.g.
Defines the major attributes of a submodule, including its name and parent.
llvm::BitstreamCursor Stream
The main bitstream cursor for the main block.
This represents 'threads' clause in the '#pragma omp ...' directive.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
The '__uint128_t' type.
llvm::DenseMap< ModuleFile *, serialization::DeclID > GlobalToLocalDeclIDs
Mapping from the module files that this module file depends on to the base declaration ID for that mo...
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
virtual bool needsImportVisitation() const
Returns true if this ASTReaderListener wants to receive the imports of the AST file via visitImport...
Represents a ValueDecl that came out of a declarator.
DeclarationNameKey()=default
The "auto &&" deduction type.
ModuleHeaderRole
Flags describing the role of a module header.
This represents clause 'aligned' in the '#pragma omp ...' directives.
ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel, unsigned PriorGeneration)
ModuleKind
Specifies the kind of module that has been loaded.
A table of skipped ranges within the preprocessing record.
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
A dependent template name that has not been resolved to a template (or set of templates).
DeclarationNameTable DeclarationNames
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type...
void setLocEnd(SourceLocation Loc)
Sets the ending location of the clause.
ArraySizeModifier
Capture whether this is a normal array (e.g.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
void ReadModuleMapFile(StringRef ModuleMapPath) override
This represents clause 'task_reduction' in the '#pragma omp taskgroup' directives.
void setSizeExpr(Expr *Size)
unsigned LocalNumSLocEntries
The number of source location entries in this AST file.
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
void setCFConstantStringType(QualType T)
Captures information about a #pragma weak directive.
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
void visitInputFiles(serialization::ModuleFile &MF, bool IncludeSystem, bool Complain, llvm::function_ref< void(const serialization::InputFile &IF, bool isSystem)> Visitor)
Visit all the input files of the given module file.
ArrayRef< ObjCMethodDecl * > getInstanceMethods() const
Retrieve the instance methods found by this visitor.
Record code for the table of offsets of each macro ID.
const DirectoryEntry * Entry
CanQualType UnsignedAccumTy
const uint32_t * TypeOffsets
Offset of each type within the bitstream, indexed by the type ID, or the representation of a Type*...
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo)
unsigned getNumLoops() const
Get number of loops associated with the clause.
void setTemplateNameLoc(SourceLocation Loc)
static NestedNameSpecifier * SuperSpecifier(const ASTContext &Context, CXXRecordDecl *RD)
Returns the nested name specifier representing the __super scope for the given CXXRecordDecl.
CanQualType UnsignedShortFractTy
This represents implicit clause 'depend' for the '#pragma omp task' directive.
A record containing CXXBaseSpecifiers.
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
ASTReaderListener implementation to validate the information of the PCH file against an initialized P...
SourceLocation getBeginLoc() const
Get the begin source location.
CommentOptions CommentOpts
Options for parsing comments.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Specifies some declarations with initializers that must be emitted to initialize the module...
An TemplateSpecializationType record.
An ObjCObjectPointerType record.
File is from a prebuilt module path.
serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const
Map a local type ID within a given AST file into a global type ID.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Type source information for an attributed type.
An ObjCInterfaceType record.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override
Read the header file information for the given file entry.
This represents 'proc_bind' clause in the '#pragma omp ...' directive.
This represents 'capture' clause in the '#pragma omp atomic' directive.
Describes a zlib-compressed blob that contains the data for a buffer entry.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
Defines the clang::LangOptions interface.
SourceLocation getEnd() const
Record code for the array of VTable uses.
IncludeDirGroup
IncludeDirGroup - Identifies the group an include Entry belongs to, representing its relative positiv...
The 'char' type, when it is unsigned.
void setHasCommaPasting()
static bool isInterestingIdentifier(ASTReader &Reader, IdentifierInfo &II, bool IsModule)
Whether the given identifier is "interesting".
void setModeAttr(bool written)
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID)
Retrieve the global macro ID corresponding to the given local ID within the given module file...
The directory that the PCH was originally created in.
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
This represents 'simdlen' clause in the '#pragma omp ...' directive.
The '_Sat long _Fract' type.
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args) const
Declaration of a template type parameter.
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.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
virtual void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata)
Indicates that a particular module file extension has been read.
unsigned ConfigMacrosExhaustive
Whether the set of configuration macros is exhaustive.
QualType getTypeOfExprType(Expr *e) const
GCC extension.
Record code for the table of offsets to entries in the preprocessing record.
Represents a C++ destructor within a class.
ContinuousRangeMap< uint32_t, int, 2 > IdentifierRemap
Remapping table for identifier IDs in this module.
Expected< unsigned > readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID)
Reads a record with id AbbrevID from Cursor, resetting the internal state.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
QualType getParenType(QualType NamedType) const
CanQualType OMPArraySectionTy
llvm::BitstreamCursor SLocEntryCursor
Cursor used to read source location entries.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Defines version macros and version-related utility functions for Clang.
The OpenCL 'half' / ARM NEON __fp16 type.
const FileEntry * ContentsEntry
References the file which the contents were actually loaded from.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N variables.
Defines an enumeration for C++ overloaded operators.
Defines the clang::Preprocessor interface.
ArgKind
The kind of template argument we're storing.
The block containing the detailed preprocessing record.
ASTReaderListenter implementation to set SuggestedPredefines of ASTReader which is required to use a ...
Record code for #pragma diagnostic mappings.
void setIsPoisoned(bool Value=true)
setIsPoisoned - Mark this identifier as poisoned.
std::pair< SourceLocation, StringRef > getModuleImportLoc(int ID) override
Retrieve the module import location and module name for the given source manager entry ID...
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
DeclContext * getDeclContext()
static LineEntry get(unsigned Offs, unsigned Line, int Filename, SrcMgr::CharacteristicKind FileKind, unsigned IncludeOffset)
void setWrittenSignSpec(TypeSpecifierSign written)
llvm::BitstreamCursor InputFilesCursor
The cursor to the start of the input-files block.
unsigned LocalNumMacros
The number of macros in this AST file.
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a source range.
A record containing CXXCtorInitializers.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Record code for the original file that was used to generate the AST file, including both its file ID ...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
void setRParenLoc(SourceLocation Loc)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
llvm::SmallVector< LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used...
void clear(SanitizerMask K=SanitizerKind::All)
Disable the sanitizers specified in K.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
QualType getLocalType(ModuleFile &F, unsigned LocalID)
Resolve a local type ID within a given AST file into a type.
Information about a module that has been loaded by the ASTReader.
void setDeclNumLists(ArrayRef< unsigned > DNLs)
Set the number of lists per declaration that are in the trailing objects of the class.
Defines the clang::TypeLoc interface and its subclasses.
A namespace alias, stored as a NamespaceAliasDecl*.
This represents 'ordered' clause in the '#pragma omp ...' directive.
virtual ~ASTReaderListener()
The 'long double' type.
static OMPFlushClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Record code for the diagnostic options table.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
uint32_t IdentifierID
An ID number that refers to an identifier in an AST file.
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
CanQualType UnsignedInt128Ty
An iterator that walks over all of the known identifiers in the lookup table.
SmallVector< uint64_t, 1 > ObjCCategories
The Objective-C category lists for categories known to this module.
void setNameLoc(SourceLocation Loc)
void setLParenLoc(SourceLocation Loc)
FileID OriginalSourceFileID
The file ID for the original source file that was used to build this AST file.
A FunctionProtoType record.
void setInheritConstructors(bool Inherit=true)
Set that this base class's constructors should be inherited.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool HasTimestamps
Whether timestamps are included in this module file.
Describes a source location entry (SLocEntry) for a file.
Wrapper for source info for enum types.
A block containing a module file extension.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
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.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
void setUmbrellaHeader(Module *Mod, const FileEntry *UmbrellaHeader, Twine NameAsWritten)
Sets the umbrella header of the given module to the given header.
void setEllipsisLoc(SourceLocation Loc)
void setAttrExprOperand(Expr *e)
Record code for an update to a decl context's lookup table.
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
void setHasBaseTypeAsWritten(bool HasBaseType)
Record the location of an inclusion directive, such as an #include or #import statement.
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Record code for #pragma ms_struct options.
InclusionKind
The kind of inclusion directives known to the preprocessor.
QualType getRecordType(const RecordDecl *Decl) const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
SourceLocation getEnd() const
bool isInstanceMethod() const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
struct CXXOpName CXXOperatorName
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation >> &Pending) override
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type...
QualType getSubstTemplateTypeParmPackType(const TemplateTypeParmType *Replaced, const TemplateArgument &ArgPack)
Retrieve a.
CanQualType SatLongAccumTy
void insertOrReplace(const value_type &Val)
void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method)
Add the given method to the list of globally-known methods.
bool isAvailable() const
Determine whether this module is available for use within the current translation unit...
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'collapse' clause in the '#pragma omp ...' directive.
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
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
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
unsigned SLocEntryBaseOffset
The base offset in the source manager's view of this module.
Record code for the table of offsets of each identifier ID.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
Record code for undefined but used functions and variables that need a definition in this TU...
void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, const RecordData &Record, unsigned &Idx)
A DependentNameType record.
SmallVector< ObjCMethodDecl *, 2 > Factory
CallingConv
CallingConv - Specifies the calling convention that a function uses.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
Record code for the identifier table.
The '_Sat unsigned long _Accum' type.
The AST file was missing.
This represents 'seq_cst' clause in the '#pragma omp atomic' directive.
NestedNameSpecifier * ReadNestedNameSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
void AddEntry(FileID FID, const std::vector< LineEntry > &Entries)
Add a new line entry that has already been encoded into the internal representation of the line table...
This represents 'untied' clause in the '#pragma omp ...' directive.
The placeholder type for bound member functions.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
Attr * ReadAttr(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Reads one attribute from the current stream position.
void setIsUsed(bool Val)
Set the value of the IsUsed flag.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
The "auto" deduction type.
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.
QualType getPackExpansionType(QualType Pattern, Optional< unsigned > NumExpansions)
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
void setTypeofLoc(SourceLocation Loc)
SanitizerMask getPPTransparentSanitizers()
Return the sanitizers which do not affect preprocessing.
The Objective-C 'Class' type.
This represents 'unified_address' clause in the '#pragma omp requires' directive. ...
SpecifierKind
The kind of specifier that completes this nested name specifier.
std::pair< Module *, bool > findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework, bool IsExplicit)
Find a new module or submodule, or create it if it does not already exist.
void setPostUpdateExpr(Expr *S)
Set pre-initialization statement for the clause.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
void makeNamesVisible(const HiddenNames &Names, Module *Owner)
Make the names within this set of hidden names visible.
The '_Sat short _Accum' type.
StringRef Next() override
Retrieve the next string in the identifier table and advances the iterator for the following string...
The 'unsigned long long' type.
A template template parameter pack that has been substituted for a template template argument pack...
Wrapper for source info for arrays.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
Record code for the set of source location entries that need to be preloaded by the AST reader...
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
This represents 'num_teams' clause in the '#pragma omp ...' directive.
The control block was read successfully.
The list of delegating constructor declarations.
Information about a FileID, basically just the logical file that it represents and include stack info...
The C++ 'char8_t' type.
Record code for types associated with OpenCL extensions.
static bool readBit(unsigned &Bits)
void setIsFunctionLike()
Function/Object-likeness.
const unsigned char * SelectorLookupTableData
A pointer to the character data that comprises the selector table.
Encapsulates changes to the "macros namespace" (the location where the macro name became active...
bool ReadFullVersionInformation(StringRef FullVersion) override
Receives the full Clang version information.
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)
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply...
std::string ABI
If given, the name of the target ABI to use.
void setASTFile(const FileEntry *File)
Set the serialized AST file for the top-level module of this module.
ExceptionSpecificationType Type
The kind of exception specification this is.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
void setLAngleLoc(SourceLocation Loc)
serialization::IdentID BaseIdentifierID
Base identifier ID for identifiers local to this module.
MacroInfo * ReadMacroRecord(ModuleFile &F, uint64_t Offset)
Reads the macro record located at the given offset.
void ReadKnownNamespaces(SmallVectorImpl< NamespaceDecl *> &Namespaces) override
Load the set of namespaces that are known to the external source, which will be used during typo corr...
File is a PCH file treated as the preamble.
std::string getTimestampFilename() const
unsigned getTotalComponentListNum() const
Return the number of lists derived from the clause expressions.
static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method)
Move the given method to the back of the global list of methods.
const ExtParameterInfo * ExtParameterInfos
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
The '_Sat unsigned _Fract' type.
bool isParameterPack() const
Returns whether this is a parameter pack.
Encodes a location in the source.
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
bool isPure() const
Whether this virtual function is pure, i.e.
static bool checkHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, StringRef ExistingModuleCachePath, DiagnosticsEngine *Diags, const LangOptions &LangOpts)
Check the header search options deserialized from the control block against the header search options...
This represents 'hint' clause in the '#pragma omp ...' directive.
StringRef getName() const
CanQualType UnsignedLongAccumTy
A record that stores the set of declarations that are visible from a given DeclContext.
File is a PCH file treated as such.
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
OpenMPDirectiveKind
OpenMP directives.
This represents clause 'shared' in the '#pragma omp ...' directives.
void setProtocolRAngleLoc(SourceLocation Loc)
The 'unsigned char' type.
Cached information about one file (either on disk or in the virtual file system). ...
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class...
Metadata describing this particular extension.
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
void setIsC99Varargs()
Varargs querying methods. This can only be set for function-like macros.
MacroInfo * getMacro(serialization::MacroID ID)
Retrieve the macro with the given ID.
uint64_t SizeInBits
The size of this file, in bits.
TemplateParameterList * ReadTemplateParameterList(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template parameter list.
An ObjCTypeParamType record.
void ProcessWarningOptions(DiagnosticsEngine &Diags, const DiagnosticOptions &Opts, bool ReportDiags=true)
ProcessWarningOptions - Initialize the diagnostic client and process the warning options specified on...
The (signed) 'long' type.
Represents a static or instance method of a struct/union/class.
ModuleReverseIterator rbegin()
Reverse iterator to traverse all loaded modules.
Record code for the offsets of each decl.
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
void setIdentifierInfo(IdentifierInfo *II)
void ReadMethodPool(Selector Sel) override
Load the contents of the global method pool for a given selector.
void * SelectorLookupTable
A pointer to an on-disk hash table of opaque type ASTSelectorLookupTable.
Metadata for submodules as a whole.
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...
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
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.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Class that performs lookup for a selector's entries in the global method pool stored in an AST file...
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
Record code for late parsed template functions.
A dependentSizedVectorType record.
The (signed) 'short' type.
Defines the clang::TargetOptions class.
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
const ParmVarDecl * getParamDecl(unsigned i) const
void setDefinitionEndLoc(SourceLocation EndLoc)
Set the location of the last token in the macro.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isPoisoned() const
Return true if this token has been poisoned.
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
CanQualType SatUnsignedLongAccumTy
void setPrivateCopies(ArrayRef< Expr *> PrivateCopies)
Set list of helper expressions, required for generation of private copies of original lastprivate var...
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings startin...
The '_Sat _Accum' type.
unsigned LocalNumDecls
The number of declarations in this AST file.
void setUpgradedFromWarning(bool Value)
This is a basic class for representing single OpenMP clause.
unsigned NumFileSortedDecls
SourceRange ReadSkippedRange(unsigned Index) override
Read a preallocated skipped range from the external source.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
The internal 'instancetype' typedef.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
OptionsRecordTypes
Record types that occur within the options block inside the control block.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
void addDecl(NamedDecl *D)
SourceLocation getBeginLoc() const LLVM_READONLY
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Describes the categories of an Objective-C class.
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl *> protocols, QualType Canonical=QualType()) const
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
CanQualType SatLongFractTy
The AST block, which acts as a container around the full AST block.
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
ArrayRef< ObjCMethodDecl * > getFactoryMethods() const
Retrieve the instance methods found by this visitor.
void setVarRefs(ArrayRef< Expr *> VL)
Sets the list of variables for this clause.
IdentID ReadIdentifierID(const unsigned char *d)
A DeducedTemplateSpecializationType record.
void setElaboratedKeywordLoc(SourceLocation Loc)
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
uint32_t TypeID
An ID number that refers to a type in an AST file.
void setWrittenTypeSpec(TypeSpecifierType written)
Objective-C "SEL" redefinition type.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line...
unsigned getODRHash()
Returns ODRHash of the function.
void setAmpLoc(SourceLocation Loc)
UnhashedControlBlockRecordTypes
Record codes for the unhashed control block.
llvm::SetVector< ModuleFile * > ImportedBy
List of modules which depend on this module.
void setLBracketLoc(SourceLocation Loc)
void dump()
Dump debugging output for this module.
static bool checkLanguageOptions(const LangOptions &LangOpts, const LangOptions &ExistingLangOpts, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true)
Compare the given set of language options against an existing set of language options.
An InjectedClassNameType record.
void SetGloballyVisibleDecls(IdentifierInfo *II, const SmallVectorImpl< uint32_t > &DeclIDs, SmallVectorImpl< Decl *> *Decls=nullptr)
Set the globally-visible declarations associated with the given identifier.
const serialization::DeclID * FileSortedDecls
Array of file-level DeclIDs sorted by file.
PragmaMSPointersToMembersKind
Record code for the extra statistics we gather while generating an AST file.
static Decl * getPredefinedDecl(ASTContext &Context, PredefinedDeclIDs ID)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
Represents a C++11 static_assert declaration.
static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags, DiagnosticsEngine &Diags, bool Complain)
virtual void visitImport(StringRef ModuleName, StringRef Filename)
If needsImportVisitation returns true, this is called for each AST file imported by this AST file...
std::vector< InputFile > InputFilesLoaded
The input files that have been loaded from this AST file.
CanQualType SatUnsignedFractTy
std::string PCHThroughHeader
If non-empty, the filename used in an #include directive in the primary source file (or command-line ...
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
The module file was just loaded in response to this call.
DeclarationName ReadDeclarationName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a declaration name.
The 'signed char' type.
unsigned LocalNumSubmodules
The number of submodules in this module.
unsigned ComputeHash(Selector Sel)
The AST file was writtten with a different language/target configuration.
void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C)
CanQualType SatUnsignedShortFractTy
serialization::SelectorID getGlobalSelectorID(ModuleFile &F, unsigned LocalID) const
Retrieve the global selector ID that corresponds to this the local selector ID in a given module...
const char * HeaderFileInfoTableData
Actual data for the on-disk hash table of header file information.
void markIdentifierUpToDate(IdentifierInfo *II)
Note that this identifier is up-to-date.
const llvm::support::unaligned_uint64_t * InputFileOffsets
Offsets for all of the input file entries in the AST file.
void addArgument(const TemplateArgumentLoc &Loc)
Record code for the signature that identifiers this AST file.
void addHeader(Module *Mod, Module::Header Header, ModuleHeaderRole Role, bool Imported=false)
Adds this header to the given module.
File is a PCH file treated as the actual main file.
llvm::APFloat ReadAPFloat(const RecordData &Record, const llvm::fltSemantics &Sem, unsigned &Idx)
Read a floating-point value.
Record code for referenced selector pool.
void AddSubDecl(const Decl *D)
std::vector< std::string > MacroIncludes
Represents a pointer type decayed from an array or function type.
The injected class name of a C++ class template or class template partial specialization.
ModuleFile * getLocalModuleFile(ModuleFile &M, unsigned ID)
Retrieve the module file with a given local ID within the specified ModuleFile.
Record code for the set of non-builtin, special types.
Defines various enumerations that describe declaration and type specifiers.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
void setLParenLoc(SourceLocation Loc)
void * Allocate(size_t Size, unsigned Align=8) const
void setTemplateKeywordLoc(SourceLocation Loc)
SourceLocation getBegin() const
StringRef getName() const
Return the actual identifier string.
void setTypeArgsLAngleLoc(SourceLocation Loc)
uint64_t InputFilesValidationTimestamp
If non-zero, specifies the time when we last validated input files.
CanQualType UnsignedShortTy
const uint32_t * MacroOffsets
Offsets of macros in the preprocessor block.
The ObjC 'id' type.
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Canon=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
Base class for declarations which introduce a typedef-name.
unsigned LocalNumSelectors
The number of selectors new to this file.
unsigned getObjCOrBuiltinID() const
const PPSkippedRange * PreprocessedSkippedRangeOffsets
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a template argument.
Record code for the list of other AST files imported by this AST file.
Selector getLocalSelector(ModuleFile &M, unsigned LocalID)
Retrieve a selector from the given module with its local ID number.
Describes a macro definition within the preprocessing record.
const ASTTemplateArgumentListInfo * ReadASTTemplateArgumentListInfo(ModuleFile &F, const RecordData &Record, unsigned &Index)
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
A conflict between two modules.
void setClassTInfo(TypeSourceInfo *TI)
bool ReadSLocEntry(int ID) override
Read the source location entry with index ID.
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
The internal '__NSConstantString' typedef.
Record code for the module name.
QualType getTypeOfType(QualType t) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
CanQualType ObjCBuiltinIdTy
bool hadMacroDefinition() const
Returns true if this identifier was #defined to some value at any moment.
void ResolveImportedPath(ModuleFile &M, std::string &Filename)
If we are loading a relocatable PCH or module file, and the filename is not an absolute path...
Dataflow Directional Tag Classes.
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
TemplateName getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param, const TemplateArgument &ArgPack) const
This represents 'device' clause in the '#pragma omp ...' directive.
bool isValid() const
Return true if this is a valid SourceLocation object.
void setDeserializationListener(ASTDeserializationListener *Listener, bool TakeOwnership=false)
Set the AST deserialization listener.
Describes an inclusion directive within the preprocessing record.
The internal '__builtin_ms_va_list' typedef.
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.
unsigned IsMissingRequirement
Whether this module is missing a feature from Requirements.
A type defined in a macro.
const TemplateArgument & getArgument() const
not evaluated yet, for special member function
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
The '_Accum' type.
Record code for a file sorted array of DeclIDs in a module.
void setAmpAmpLoc(SourceLocation Loc)
Record code for the array of Objective-C categories (including extensions).
void updateOutOfDateIdentifier(IdentifierInfo &II) override
Update an out-of-date identifier.
void reserve(ASTContext &C, unsigned N)
Specifies a configuration macro for this module.
void ReadDefinedMacros() override
Read the set of macros defined by this external macro source.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
The base class of all kinds of template declarations (e.g., class, function, etc.).
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.
A FunctionNoProtoType record.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
The '_Sat unsigned short _Accum' type.
static bool SkipCursorToBlock(BitstreamCursor &Cursor, unsigned BlockID)
Given a cursor at the start of an AST file, scan ahead and drop the cursor into the start of the give...
Reads an AST files chain containing the contents of a translation unit.
File is an explicitly-loaded module.
Represents a field injected from an anonymous union/struct into the parent scope. ...
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
QualType getUnderlyingType() const
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
CanQualType UnsignedLongLongTy
bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule) override
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
const Expr * getInit() const
AccessSpecifier getAccess() const
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(const FileEntry *Entry, bool isVolatile=false, bool ShouldCloseOpenFile=true)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
The '_Sat long _Accum' type.
void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl *> &Decls) override
Read the set of ext_vector type declarations known to the external Sema source.
The name of a declaration.
Represents the declaration of an Objective-C type parameter.
Record code for the Objective-C method pool,.
llvm::PointerIntPair< Module *, 1, bool > ExportDecl
Describes an exported module.
bool isExtensionToken() const
get/setExtension - Initialize information about whether or not this language token is an extension...
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
Specifies a header that is private to this submodule.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
bool needsInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
U cast(CodeGen::Address addr)
Describes a macro expansion within the preprocessing record.
This represents 'unified_shared_memory' clause in the '#pragma omp requires' directive.
llvm::OnDiskChainedHashTable< ASTSelectorLookupTrait > ASTSelectorLookupTable
The on-disk hash table used for the global method pool.
This represents clause 'linear' in the '#pragma omp ...' directives.
void * getFETokenInfo() const
Get and set FETokenInfo.
bool isGlobalIndexUnavailable() const
Determine whether we tried to load the global index, but failed, e.g., because it is out-of-date or d...
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
IdentifierResolver IdResolver
A map from continuous integer ranges to some value, with a very specialized interface.
Class that performs lookup for an identifier stored in an AST file.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
void setExternalSLocEntrySource(ExternalSLocEntrySource *Source)
ContinuousRangeMap< uint32_t, int, 2 > MacroRemap
Remapping table for macro IDs in this module.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
An RValueReferenceType record.
void ReadDeclarationNameLoc(ModuleFile &F, DeclarationNameLoc &DNLoc, DeclarationName Name, const RecordData &Record, unsigned &Idx)
void setLocStart(SourceLocation Loc)
Sets the starting location of the clause.
A type that was preceded by the 'template' keyword, stored as a Type*.
void ClearSwitchCaseIDs()
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.
unsigned getNumParams() const
void setNameLoc(SourceLocation Loc)
void setComponentListSizes(ArrayRef< unsigned > CLSs)
Set the cumulative component lists sizes that are in the trailing objects of the class.
Number of unmatched #pragma clang cuda_force_host_device begin directives we've seen.
unsigned ModuleMapIsPrivate
Whether this module came from a "private" module map, found next to a regular (public) module map...
Encapsulates the data about a macro definition (e.g.
Decl * GetExternalDecl(uint32_t ID) override
Resolve a declaration ID into a declaration, potentially building a new declaration.
Class that represents a component of a mappable expression.
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope...
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
bool instanceHasMoreThanOneDecl() const
void ReadUnresolvedSet(ModuleFile &F, LazyASTUnresolvedSet &Set, const RecordData &Record, unsigned &Idx)
Read a UnresolvedSet structure.
struct CXXLitOpName CXXLiteralOperatorName
Abstract interface for callback invocations by the ASTReader.
void addLinkAsDependency(Module *Mod)
Make module to use export_as as the link dependency name if enough information is available or add it...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Location wrapper for a TemplateArgument.
BuiltinTemplateDecl * getTypePackElementDecl() const
C sigjmp_buf typedef type.
The 'unsigned _Fract' type.
std::vector< Conflict > Conflicts
The list of conflicts.
NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
std::pair< unsigned, unsigned > findPreprocessedEntitiesInRange(SourceRange Range) override
Returns a pair of [Begin, End) indices of preallocated preprocessed entities that Range encompasses...
Record code for the table of offsets into the Objective-C method pool.
Defines the clang::FileSystemOptions interface.
Represents a C++ base or member initializer.
ContinuousRangeMap< unsigned, int, 2 > SLocRemap
A DependentSizedArrayType record.
CanQualType UnsignedLongTy
Record code for the remapping information used to relate loaded modules to the various offsets and ID...
const TemplateArgument & getArg(unsigned Idx) const
Retrieve a specific template argument as a type.
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
bool InstanceHasMoreThanOneDecl
A key used when looking up entities by DeclarationName.
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata) override
Indicates that a particular module file extension has been read.
Record code for declarations that Sema keeps references of.
void ReadTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument array.
void setTemplateNameLoc(SourceLocation Loc)
void * HeaderFileInfoTable
The on-disk hash table that contains information about each of the header files.
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
void visitTopLevelModuleMaps(serialization::ModuleFile &MF, llvm::function_ref< void(const FileEntry *)> Visitor)
Visit all the top-level module maps loaded when building the given module file.
bool hasBody() const override
Determine whether this method has a body.
Offsets into the input-files block where input files reside.
bool FactoryHasMoreThanOneDecl
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
CanQualType ObjCBuiltinClassTy
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)
void ReadTypeLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx, TypeLoc TL)
Raad the type locations for the given TInfo.
Wrapper for source info for record types.
std::string BaseDirectory
The base directory of the module.
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
The template argument is a type.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
Wraps an ObjCPointerType with source location information.
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
Holds information about the various types of exception specification.
unsigned getNumArgs() const
ContinuousRangeMap< uint32_t, int, 2 > TypeRemap
Remapping table for type IDs in this module.
Selector DecodeSelector(serialization::SelectorID Idx)
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
The template argument is actually a parameter pack.
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
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.
Cached information about one directory (either on disk or in the virtual file system).
uint32_t GetNumExternalSelectors() override
Returns the number of selectors known to the external AST source.
unsigned BufferOverridden
Indicates whether the buffer itself was provided to override the actual file contents.
void PrintStats() override
Print some statistics about AST usage.
void setSeverity(diag::Severity Value)
unsigned size() const
Number of modules loaded.
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data for the depend clauses with 'sink|source' kind of dependency.
Defines the clang::TokenKind enum and support functions.
void insert(const value_type &Val)
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Keeps track of options that affect how file operations are performed.
llvm::OnDiskIterableChainedHashTable< ASTIdentifierLookupTrait > ASTIdentifierLookupTable
The on-disk hash table used to contain information about all of the identifiers in the program...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID)
ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the specified cursor.
QualType GetType(serialization::TypeID ID)
Resolve a type ID into a type, potentially building a new type.
A template argument list.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
ExternCContextDecl * getExternCContextDecl() const
IdentifierInfo * DecodeIdentifierInfo(serialization::IdentifierID ID)
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
NestedNameSpecifierLoc QualifierLoc
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain)
Receives the header search options.
ArgKind getKind() const
Return the kind of stored template argument.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void setKWLoc(SourceLocation Loc)
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
TranslationUnitDecl * getTranslationUnitDecl() const
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
The C++ 'char16_t' type.
Defines the clang::SourceLocation class and associated facilities.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
This represents 'nowait' clause in the '#pragma omp ...' directive.
TemplateArgumentLoc ReadTemplateArgumentLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLoc.
bool isMutable() const
Determines whether this field is mutable (C++ only).
unsigned InferSubmodules
Whether we should infer submodules for this module based on the headers.
void setEnd(SourceLocation e)
TemplateArgumentLocInfo GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind.
Represents a C++ struct/union/class.
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
static const ASTTemplateArgumentListInfo * Create(ASTContext &C, const TemplateArgumentListInfo &List)
serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declaration ID from the given position in a record in the given module.
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl *> &Decls) override
Read the set of unused file-scope declarations known to the external Sema source. ...
An TemplateTypeParmType record.
This represents 'num_tasks' clause in the '#pragma omp ...' directive.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
The template argument is a template name that was provided for a template template parameter...
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
SmallVector< uint64_t, 8 > PragmaDiagMappings
Diagnostic IDs and their mappings that the user changed.
Record code for the filesystem options table.
static 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.
QualType getMacroQualifiedType(QualType UnderlyingTy, const IdentifierInfo *MacroII) const
void setOutOfDate(bool OOD)
Set whether the information for this identifier is out of date with respect to the external source...
unsigned getNumProtocols() const
void setLParenLoc(SourceLocation Loc)
ASTImporterLookupTable & LT
const DeclOffset * DeclOffsets
Offset of each declaration within the bitstream, indexed by the declaration ID (-1).
Location information for a TemplateArgument.
virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the target options.
Declaration of a class template.
Record code for the offsets of each type.
A DependentAddressSpaceType record.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
The block containing the definitions of all of the types and decls used within the AST file...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
The internal '__va_list_tag' struct, if any.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
void revertTokenIDToIdentifier()
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility.
virtual void ReadModuleName(StringRef ModuleName)
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type...
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 '('.
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion=OMPD_unknown)
Set pre-initialization statement for the clause.
The AST file is out-of-date relative to its input files, and needs to be regenerated.
TypeLocReader(ModuleFile &F, ASTReader &Reader, const ASTReader::RecordData &Record, unsigned &Idx)
NameVisibilityKind
Describes the visibility of the various names within a particular module.
void setPrevious(MacroDirective *Prev)
Set previous definition of the macro with the same name.
The (signed) 'int' type.
a linked list of methods with the same selector name but different signatures.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void setRAngleLoc(SourceLocation Loc)
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
std::pair< ObjCMethodList, ObjCMethodList > GlobalMethods
data_type ReadData(const internal_key_type &k, const unsigned char *d, unsigned DataLen)
Kind
Lists the kind of concrete classes of Decl.
Specifies a required feature.
This represents 'dist_schedule' clause in the '#pragma omp ...' directive.
SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID)
Returns the source location for the decl ID.
std::vector< std::string > ConfigMacros
The set of "configuration macros", which are macros that (intentionally) change how this module is bu...
void AddStmt(const Stmt *S)
SourceRange getSourceRange() const override LLVM_READONLY
Retrieves the source range for the friend declaration.
unsigned getNumTypeArgs() const
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...
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false) const
C++11 deduced auto type.
ModuleFile * getOwningModuleFile(const Decl *D)
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
static bool isWhitelistedDecl(const Decl *D, const DeclContext *Parent)
Record code for weak undeclared identifiers.
The block containing information about the preprocessor.
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
void StartTranslationUnit(ASTConsumer *Consumer) override
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
QualType getDefaultArgument() const
Retrieve the default argument, if any.
void setLocation(SourceLocation L)
static DeclarationName getUsingDirectiveName()
Returns the name for all C++ using-directives.
bool getWarningsAsErrors() const
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
Wrapper for source info for builtin types.
void setRParenLoc(SourceLocation Loc)
A set of overloaded template declarations.
Wrapper for template type parameters.
Record code for the headers search options table.
Module * Other
The module that this module conflicts with.
A trivial tuple used to represent a source range.
void setParameterList(ArrayRef< IdentifierInfo *> List, llvm::BumpPtrAllocator &PPAllocator)
Set the specified list of identifiers as the parameter list for this macro.
std::string ModuleMapPath
This represents a decl that may have a name.
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
AST file metadata, including the AST file version number and information about the compiler used to b...
The block of input files, which were used as inputs to create this AST file.
Present this diagnostic as a warning.
llvm::BitstreamCursor MacroCursor
The cursor to the start of the preprocessor block, which stores all of the macro definitions.
const uint32_t * SelectorOffsets
Offsets into the selector lookup table's data array where each selector resides.
void UpdateSema()
Update the state of Sema after loading some additional modules.
unsigned LocalNumTypes
The number of types in this AST file.
Represents a C++ namespace alias.
void setTemplateNameLoc(SourceLocation Loc)
Kind
The basic Objective-C runtimes that we know about.
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type...
The internal '__NSConstantString' tag type.
static TypeIdx fromTypeID(TypeID ID)
serialization::DeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M, serialization::DeclID GlobalID)
Map a global declaration ID into the declaration ID used to refer to this declaration within the give...
InputFileRecordTypes
Record types that occur within the input-files block inside the control block.
void FinishedDeserializing() override
Notify ASTReader that we finished the deserialization of a decl or type.
A function-like macro definition.
The Objective-C 'Protocol' type.
static OMPLastprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
The global specifier '::'. There is no stored value.
The control block, which contains all of the information that needs to be validated prior to committi...
Wrapper for source info for pointers.
SourceLocation getBegin() const
const FileEntry * File
The file entry for the module file.
unsigned NumComponents
Total number of expression components.
std::string Triple
The name of the target triple to compile for.
void setObjCOrBuiltinID(unsigned ID)
StringRef internal_key_type
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Wrapper for source info for block pointers.
void ReadModuleName(StringRef ModuleName) override
The '_Sat unsigned short _Fract' type.
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
This class handles loading and caching of source files into memory.
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.
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
Declaration of a template function.
Record code for an update to the TU's lexically contained declarations.
A class which abstracts out some details necessary for making a call.
The '_Sat _Fract' type.
void setElaboratedKeywordLoc(SourceLocation Loc)
Source range/offset of a preprocessed entity.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind) override
This is called for each AST file loaded.
Attr - This represents one attribute.
bool isDeletedAsWritten() const
SourceLocation getLocation() const
This represents clause 'use_device_ptr' in the '#pragma omp ...' directives.
const serialization::ObjCCategoriesInfo * ObjCCategoriesMap
Array of category list location information within this module file, sorted by the definition ID...
bool loadGlobalIndex()
Attempts to load the global index.
void startToken()
Reset all flags to cleared.
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
Objective-C "Class" redefinition type.
A PackExpansionType record.
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls) override
Read the set of potentially unused typedefs known to the source.
QualType getType() const
Return the type wrapped by this type source info.
A single template declaration.
CanQualType OCLClkEventTy
The pseudo-object placeholder type.
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
virtual bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain)
Receives the diagnostic options.
void setUnderlyingTInfo(TypeSourceInfo *TI) const
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
Record code for #pragma ms_struct options.
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID)
Record that the given ID maps to the given switch-case statement.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
A DependentTemplateSpecializationType record.
CanQualType UnsignedIntTy
QualType getIncompleteArrayType(QualType EltTy, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type...
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, unsigned LocalID)
Record code for the array of tentative definitions.
The '__float128' type.
BuiltinTemplateDecl * getMakeIntegerSeqDecl() const
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.