100#include "llvm/ADT/APFloat.h"
101#include "llvm/ADT/APInt.h"
102#include "llvm/ADT/ArrayRef.h"
103#include "llvm/ADT/DenseMap.h"
104#include "llvm/ADT/FoldingSet.h"
105#include "llvm/ADT/IntrusiveRefCntPtr.h"
106#include "llvm/ADT/STLExtras.h"
107#include "llvm/ADT/ScopeExit.h"
108#include "llvm/ADT/Sequence.h"
109#include "llvm/ADT/SmallPtrSet.h"
110#include "llvm/ADT/SmallVector.h"
111#include "llvm/ADT/StringExtras.h"
112#include "llvm/ADT/StringMap.h"
113#include "llvm/ADT/StringRef.h"
114#include "llvm/ADT/iterator_range.h"
115#include "llvm/Bitstream/BitstreamReader.h"
116#include "llvm/Support/Chrono.h"
117#include "llvm/Support/Compiler.h"
118#include "llvm/Support/Compression.h"
119#include "llvm/Support/DJB.h"
120#include "llvm/Support/Endian.h"
121#include "llvm/Support/Error.h"
122#include "llvm/Support/ErrorHandling.h"
123#include "llvm/Support/LEB128.h"
124#include "llvm/Support/MemoryBuffer.h"
125#include "llvm/Support/Path.h"
126#include "llvm/Support/SaveAndRestore.h"
127#include "llvm/Support/TimeProfiler.h"
128#include "llvm/Support/Timer.h"
129#include "llvm/Support/VersionTuple.h"
130#include "llvm/Support/VirtualFileSystem.h"
131#include "llvm/Support/raw_ostream.h"
132#include "llvm/TargetParser/Triple.h"
145#include <system_error>
150using namespace clang;
153using llvm::BitstreamCursor;
161 return First->ReadFullVersionInformation(FullVersion) ||
162 Second->ReadFullVersionInformation(FullVersion);
166 First->ReadModuleName(ModuleName);
167 Second->ReadModuleName(ModuleName);
171 First->ReadModuleMapFile(ModuleMapPath);
172 Second->ReadModuleMapFile(ModuleMapPath);
176 const LangOptions &LangOpts, StringRef ModuleFilename,
bool Complain,
177 bool AllowCompatibleDifferences) {
178 return First->ReadLanguageOptions(LangOpts, ModuleFilename, Complain,
179 AllowCompatibleDifferences) ||
180 Second->ReadLanguageOptions(LangOpts, ModuleFilename, Complain,
181 AllowCompatibleDifferences);
185 const CodeGenOptions &CGOpts, StringRef ModuleFilename,
bool Complain,
186 bool AllowCompatibleDifferences) {
187 return First->ReadCodeGenOptions(CGOpts, ModuleFilename, Complain,
188 AllowCompatibleDifferences) ||
189 Second->ReadCodeGenOptions(CGOpts, ModuleFilename, Complain,
190 AllowCompatibleDifferences);
194 const TargetOptions &TargetOpts, StringRef ModuleFilename,
bool Complain,
195 bool AllowCompatibleDifferences) {
196 return First->ReadTargetOptions(TargetOpts, ModuleFilename, Complain,
197 AllowCompatibleDifferences) ||
198 Second->ReadTargetOptions(TargetOpts, ModuleFilename, Complain,
199 AllowCompatibleDifferences);
204 return First->ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain) ||
205 Second->ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain);
211 return First->ReadFileSystemOptions(FSOpts, Complain) ||
212 Second->ReadFileSystemOptions(FSOpts, Complain);
217 StringRef ContextHash,
bool Complain) {
218 return First->ReadHeaderSearchOptions(HSOpts, ModuleFilename, ContextHash,
220 Second->ReadHeaderSearchOptions(HSOpts, ModuleFilename, ContextHash,
226 bool ReadMacros,
bool Complain, std::string &SuggestedPredefines) {
227 return First->ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros,
228 Complain, SuggestedPredefines) ||
229 Second->ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros,
230 Complain, SuggestedPredefines);
235 First->ReadCounter(M,
Value);
236 Second->ReadCounter(M,
Value);
240 return First->needsInputFileVisitation() ||
241 Second->needsInputFileVisitation();
245 return First->needsSystemInputFileVisitation() ||
246 Second->needsSystemInputFileVisitation();
251 bool DirectlyImported) {
252 First->visitModuleFile(Filename, Kind, DirectlyImported);
253 Second->visitModuleFile(Filename, Kind, DirectlyImported);
259 bool isExplicitModule) {
260 bool Continue =
false;
261 if (First->needsInputFileVisitation() &&
262 (!isSystem || First->needsSystemInputFileVisitation()))
263 Continue |= First->visitInputFile(Filename, isSystem, isOverridden,
265 if (Second->needsInputFileVisitation() &&
266 (!isSystem || Second->needsSystemInputFileVisitation()))
267 Continue |= Second->visitInputFile(Filename, isSystem, isOverridden,
274 First->readModuleFileExtension(Metadata);
275 Second->readModuleFileExtension(Metadata);
286 bool CurrentValue, StringRef ModuleFilename) {
289 return Diags->
Report(diag::err_ast_file_langopt_mismatch)
290 << Description << SerializedValue << CurrentValue << ModuleFilename;
297 return Diags->
Report(diag::err_ast_file_langopt_value_mismatch)
298 << Description << ModuleFilename;
311 StringRef ModuleFilename,
313 bool AllowCompatibleDifferences =
true) {
317#define LANGOPT(Name, Bits, Default, Compatibility, Description) \
318 if constexpr (CK::Compatibility != CK::Benign) { \
319 if ((CK::Compatibility == CK::NotCompatible) || \
320 (CK::Compatibility == CK::Compatible && \
321 !AllowCompatibleDifferences)) { \
322 if (ExistingLangOpts.Name != LangOpts.Name) { \
324 return diagnoseLanguageOptionFlagMismatch( \
325 Diags, Description, LangOpts.Name, ExistingLangOpts.Name, \
327 return diagnoseLanguageOptionValueMismatch(Diags, Description, \
333#define VALUE_LANGOPT(Name, Bits, Default, Compatibility, Description) \
334 if constexpr (CK::Compatibility != CK::Benign) { \
335 if ((CK::Compatibility == CK::NotCompatible) || \
336 (CK::Compatibility == CK::Compatible && \
337 !AllowCompatibleDifferences)) { \
338 if (ExistingLangOpts.Name != LangOpts.Name) { \
339 return diagnoseLanguageOptionValueMismatch(Diags, Description, \
345#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
346 if constexpr (CK::Compatibility != CK::Benign) { \
347 if ((CK::Compatibility == CK::NotCompatible) || \
348 (CK::Compatibility == CK::Compatible && \
349 !AllowCompatibleDifferences)) { \
350 if (ExistingLangOpts.get##Name() != LangOpts.get##Name()) { \
351 return diagnoseLanguageOptionValueMismatch(Diags, Description, \
357#include "clang/Basic/LangOptions.def"
366 Diags,
"target Objective-C runtime", ModuleFilename);
379 if (!AllowCompatibleDifferences) {
383 ExistingSanitizers.
clear(ModularSanitizers);
384 ImportedSanitizers.
clear(ModularSanitizers);
385 if (ExistingSanitizers.
Mask != ImportedSanitizers.
Mask) {
386 const std::string Flag =
"-fsanitize=";
388#define SANITIZER(NAME, ID) \
390 bool InExistingModule = ExistingSanitizers.has(SanitizerKind::ID); \
391 bool InImportedModule = ImportedSanitizers.has(SanitizerKind::ID); \
392 if (InExistingModule != InImportedModule) \
393 Diags->Report(diag::err_ast_file_targetopt_feature_mismatch) \
394 << InExistingModule << ModuleFilename << (Flag + NAME); \
396#include "clang/Basic/Sanitizers.def"
407 StringRef ModuleFilename,
409 bool AllowCompatibleDifferences =
true) {
413#define CODEGENOPT(Name, Bits, Default, Compatibility) \
414 if constexpr (CK::Compatibility != CK::Benign) { \
415 if ((CK::Compatibility == CK::NotCompatible) || \
416 (CK::Compatibility == CK::Compatible && \
417 !AllowCompatibleDifferences)) { \
418 if (ExistingCGOpts.Name != CGOpts.Name) { \
421 Diags->Report(diag::err_ast_file_codegenopt_mismatch) \
422 << #Name << CGOpts.Name << ExistingCGOpts.Name \
425 Diags->Report(diag::err_ast_file_codegenopt_value_mismatch) \
426 << #Name << ModuleFilename; \
433#define VALUE_CODEGENOPT(Name, Bits, Default, Compatibility) \
434 if constexpr (CK::Compatibility != CK::Benign) { \
435 if ((CK::Compatibility == CK::NotCompatible) || \
436 (CK::Compatibility == CK::Compatible && \
437 !AllowCompatibleDifferences)) { \
438 if (ExistingCGOpts.Name != CGOpts.Name) { \
440 Diags->Report(diag::err_ast_file_codegenopt_value_mismatch) \
441 << #Name << ModuleFilename; \
446#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility) \
447 if constexpr (CK::Compatibility != CK::Benign) { \
448 if ((CK::Compatibility == CK::NotCompatible) || \
449 (CK::Compatibility == CK::Compatible && \
450 !AllowCompatibleDifferences)) { \
451 if (ExistingCGOpts.get##Name() != CGOpts.get##Name()) { \
453 Diags->Report(diag::err_ast_file_codegenopt_value_mismatch) \
454 << #Name << ModuleFilename; \
459#define DEBUGOPT(Name, Bits, Default, Compatibility)
460#define VALUE_DEBUGOPT(Name, Bits, Default, Compatibility)
461#define ENUM_DEBUGOPT(Name, Type, Bits, Default, Compatibility)
462#include "clang/Basic/CodeGenOptions.def"
467static std::vector<std::string>
469 llvm::erase_if(FeaturesAsWritten, [](
const std::string &S) {
470 return S.empty() || (S[0] !=
'+' && S[0] !=
'-');
472 llvm::stable_sort(FeaturesAsWritten,
473 [](
const std::string &A,
const std::string &B) {
474 return A.substr(1) < B.substr(1);
477 std::unique(FeaturesAsWritten.rbegin(), FeaturesAsWritten.rend(),
478 [](
const std::string &A,
const std::string &B) {
479 return A.substr(1) == B.substr(1);
483 FeaturesAsWritten.erase(FeaturesAsWritten.begin(), NewRend.base());
484 return FeaturesAsWritten;
495 StringRef ModuleFilename,
497 bool AllowCompatibleDifferences =
true) {
498#define CHECK_TARGET_OPT(Field, Name) \
499 if (TargetOpts.Field != ExistingTargetOpts.Field) { \
501 Diags->Report(diag::err_ast_file_targetopt_mismatch) \
502 << ModuleFilename << Name << TargetOpts.Field \
503 << ExistingTargetOpts.Field; \
514 if (!AllowCompatibleDifferences) {
519#undef CHECK_TARGET_OPT
524 std::vector<std::string> ExistingFeatures =
526 std::vector<std::string> ReadFeatures =
531 auto FeatureLess = [](StringRef A, StringRef B) {
532 return A.substr(1) < B.substr(1);
536 std::set_difference(ExistingFeatures.begin(), ExistingFeatures.end(),
537 ReadFeatures.begin(), ReadFeatures.end(),
538 std::back_inserter(UnmatchedExistingFeatures),
540 std::set_difference(ReadFeatures.begin(), ReadFeatures.end(),
541 ExistingFeatures.begin(), ExistingFeatures.end(),
542 std::back_inserter(UnmatchedReadFeatures), FeatureLess);
546 if (AllowCompatibleDifferences && UnmatchedReadFeatures.empty())
550 for (StringRef
Feature : UnmatchedReadFeatures)
551 Diags->
Report(diag::err_ast_file_targetopt_feature_mismatch)
552 <<
false << ModuleFilename <<
Feature;
553 for (StringRef
Feature : UnmatchedExistingFeatures)
554 Diags->
Report(diag::err_ast_file_targetopt_feature_mismatch)
555 <<
true << ModuleFilename <<
Feature;
558 return !UnmatchedReadFeatures.empty() || !UnmatchedExistingFeatures.empty();
562 StringRef ModuleFilename,
bool Complain,
563 bool AllowCompatibleDifferences) {
564 const LangOptions &ExistingLangOpts = PP.getLangOpts();
566 Complain ? &Reader.Diags :
nullptr,
567 AllowCompatibleDifferences);
571 StringRef ModuleFilename,
bool Complain,
572 bool AllowCompatibleDifferences) {
575 Complain ? &Reader.Diags :
nullptr,
576 AllowCompatibleDifferences);
580 StringRef ModuleFilename,
bool Complain,
581 bool AllowCompatibleDifferences) {
582 const TargetOptions &ExistingTargetOpts = PP.getTargetInfo().getTargetOpts();
584 Complain ? &Reader.Diags :
nullptr,
585 AllowCompatibleDifferences);
590using MacroDefinitionsMap =
591 llvm::StringMap<std::pair<StringRef,
bool >>;
600 bool empty()
const {
return Decls.empty(); }
602 bool insert(NamedDecl *ND) {
603 auto [_, Inserted] =
Found.insert(ND);
610using DeclsMap = llvm::DenseMap<DeclarationName, DeclsSet>;
616 StringRef ModuleFilename,
626 for (
auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) {
635 Diags.
Report(diag::err_ast_file_diagopt_mismatch)
637 ->getWarningOptionForDiag(DiagID)
657 StringRef ModuleFilename,
bool IsSystem,
658 bool SystemHeaderWarningsInModule,
667 !SystemHeaderWarningsInModule) {
669 Diags.
Report(diag::err_ast_file_diagopt_mismatch)
670 <<
"-Wsystem-headers" << ModuleFilename;
677 Diags.
Report(diag::err_ast_file_diagopt_mismatch)
678 <<
"-Werror" << ModuleFilename;
685 Diags.
Report(diag::err_ast_file_diagopt_mismatch)
686 <<
"-Weverything -Werror" << ModuleFilename;
693 Diags.
Report(diag::err_ast_file_diagopt_mismatch)
694 <<
"-pedantic-errors" << ModuleFilename;
719 assert(!ModuleName.empty() &&
"diagnostic options read before module name");
723 assert(M &&
"missing module");
728 StringRef ModuleFilename,
732 auto Diags = llvm::makeIntrusiveRefCnt<DiagnosticsEngine>(DiagIDs, DiagOpts);
736 PP.getFileManager().getVirtualFileSystem(),
740 assert(ModuleMgr.
size() >= 1 &&
"what ASTFile is this then");
746 Module *Importer = PP.getCurrentModule();
749 bool SystemHeaderWarningsInModule =
756 TopM->
IsSystem, SystemHeaderWarningsInModule,
764 MacroDefinitionsMap &Macros,
766 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
768 bool IsUndef = PPOpts.
Macros[I].second;
770 std::pair<StringRef, StringRef> MacroPair =
Macro.split(
'=');
771 StringRef MacroName = MacroPair.first;
772 StringRef MacroBody = MacroPair.second;
776 auto [It, Inserted] = Macros.try_emplace(MacroName);
777 if (MacroNames && Inserted)
778 MacroNames->push_back(MacroName);
780 It->second = std::make_pair(
"",
true);
785 if (MacroName.size() ==
Macro.size())
789 StringRef::size_type End = MacroBody.find_first_of(
"\n\r");
790 MacroBody = MacroBody.substr(0, End);
793 auto [It, Inserted] = Macros.try_emplace(MacroName);
794 if (MacroNames && Inserted)
795 MacroNames->push_back(MacroName);
796 It->second = std::make_pair(MacroBody,
false);
820 std::string &SuggestedPredefines,
const LangOptions &LangOpts,
824 MacroDefinitionsMap ASTFileMacros;
826 MacroDefinitionsMap ExistingMacros;
829 &ExistingMacroNames);
833 SuggestedPredefines +=
"# 1 \"<command line>\" 1\n";
835 for (
unsigned I = 0, N = ExistingMacroNames.size(); I != N; ++I) {
837 StringRef MacroName = ExistingMacroNames[I];
838 std::pair<StringRef, bool> Existing = ExistingMacros[MacroName];
842 ASTFileMacros.find(MacroName);
848 Diags->
Report(diag::err_ast_file_macro_def_undef)
849 << MacroName <<
true << ModuleFilename;
857 if (Existing.second) {
858 SuggestedPredefines +=
"#undef ";
859 SuggestedPredefines += MacroName.str();
860 SuggestedPredefines +=
'\n';
862 SuggestedPredefines +=
"#define ";
863 SuggestedPredefines += MacroName.str();
864 SuggestedPredefines +=
' ';
865 SuggestedPredefines += Existing.first.str();
866 SuggestedPredefines +=
'\n';
873 if (Existing.second !=
Known->second.second) {
875 Diags->
Report(diag::err_ast_file_macro_def_undef)
876 << MacroName <<
Known->second.second << ModuleFilename;
883 if (Existing.second || Existing.first ==
Known->second.first) {
884 ASTFileMacros.erase(
Known);
890 Diags->
Report(diag::err_ast_file_macro_def_conflict)
891 << MacroName <<
Known->second.first << Existing.first
898 SuggestedPredefines +=
"# 1 \"<built-in>\" 2\n";
903 for (
const auto &MacroName : ASTFileMacros.keys()) {
905 Diags->
Report(diag::err_ast_file_macro_def_undef)
906 << MacroName <<
false << ModuleFilename;
917 Diags->
Report(diag::err_ast_file_undef)
924 if (LangOpts.Modules &&
928 Diags->
Report(diag::err_ast_file_pp_detailed_record)
935 for (
unsigned I = 0, N = ExistingPPOpts.
MacroIncludes.size(); I != N; ++I) {
940 SuggestedPredefines +=
"#__include_macros \"";
941 SuggestedPredefines +=
File;
942 SuggestedPredefines +=
"\"\n##\n";
945 for (
unsigned I = 0, N = ExistingPPOpts.
Includes.size(); I != N; ++I) {
952 SuggestedPredefines +=
"#include \"";
953 SuggestedPredefines +=
File;
954 SuggestedPredefines +=
"\"\n";
964 SuggestedPredefines +=
"#include \"";
965 SuggestedPredefines +=
File;
966 SuggestedPredefines +=
"\"\n";
973 StringRef ModuleFilename,
974 bool ReadMacros,
bool Complain,
975 std::string &SuggestedPredefines) {
979 PPOpts, ExistingPPOpts, ModuleFilename, ReadMacros,
980 Complain ? &Reader.Diags :
nullptr, PP.getFileManager(),
981 SuggestedPredefines, PP.getLangOpts());
986 bool ReadMacros,
bool Complain, std::string &SuggestedPredefines) {
988 ModuleFilename, ReadMacros,
nullptr,
989 PP.getFileManager(), SuggestedPredefines,
998 StringRef ExistingSpecificModuleCachePath,
999 StringRef ASTFilename,
1007 std::string(ContextHash));
1010 SpecificModuleCachePath == ExistingSpecificModuleCachePath)
1012 auto EqualOrErr =
FileMgr.getVirtualFileSystem().equivalent(
1013 SpecificModuleCachePath, ExistingSpecificModuleCachePath);
1014 if (EqualOrErr && *EqualOrErr)
1020 EqualOrErr =
FileMgr.getVirtualFileSystem().equivalent(
1022 if (EqualOrErr && *EqualOrErr)
1023 Diags->
Report(clang::diag::warn_ast_file_config_mismatch) << ASTFilename;
1025 Diags->
Report(diag::err_ast_file_modulecache_mismatch)
1026 << SpecificModuleCachePath << ExistingSpecificModuleCachePath
1033 StringRef ASTFilename,
1034 StringRef ContextHash,
1036 const HeaderSearch &HeaderSearchInfo = PP.getHeaderSearchInfo();
1039 ASTFilename, Complain ? &Reader.Diags :
nullptr,
1040 PP.getLangOpts(), PP.getPreprocessorOpts(),
1045 PP.setCounterValue(
Value);
1053 unsigned Length = 0;
1054 const char *
Error =
nullptr;
1056 uint64_t Val = llvm::decodeULEB128(P, &Length,
nullptr, &
Error);
1058 llvm::report_fatal_error(
Error);
1064static std::pair<unsigned, unsigned>
1067 if ((
unsigned)KeyLen != KeyLen)
1068 llvm::report_fatal_error(
"key too large");
1071 if ((
unsigned)DataLen != DataLen)
1072 llvm::report_fatal_error(
"data too large");
1074 return std::make_pair(KeyLen, DataLen);
1078 bool TakeOwnership) {
1079 DeserializationListener = Listener;
1080 OwnsDeserializationListener = TakeOwnership;
1091 Reader.ReadModuleOffsetMap(MF);
1093 unsigned ModuleFileIndex =
ID.getModuleFileIndex();
1094 unsigned LocalDeclID =
ID.getLocalDeclIndex();
1100 assert(OwningModuleFile);
1104 if (!ModuleFileIndex)
1107 assert(LocalDeclID < LocalNumDecls);
1115 unsigned ModuleFileIndex,
unsigned LocalDeclID) {
1120std::pair<unsigned, unsigned>
1127 using namespace llvm::support;
1130 unsigned N = endian::readNext<uint16_t, llvm::endianness::little>(d);
1132 F, endian::readNext<IdentifierID, llvm::endianness::little>(d));
1139 Args.push_back(FirstII);
1140 for (
unsigned I = 1; I != N; ++I)
1141 Args.push_back(Reader.getLocalIdentifier(
1142 F, endian::readNext<IdentifierID, llvm::endianness::little>(d)));
1150 using namespace llvm::support;
1154 Result.ID = Reader.getGlobalSelectorID(
1155 F, endian::readNext<uint32_t, llvm::endianness::little>(d));
1156 unsigned FullInstanceBits =
1157 endian::readNext<uint16_t, llvm::endianness::little>(d);
1158 unsigned FullFactoryBits =
1159 endian::readNext<uint16_t, llvm::endianness::little>(d);
1160 Result.InstanceBits = FullInstanceBits & 0x3;
1161 Result.InstanceHasMoreThanOneDecl = (FullInstanceBits >> 2) & 0x1;
1162 Result.FactoryBits = FullFactoryBits & 0x3;
1163 Result.FactoryHasMoreThanOneDecl = (FullFactoryBits >> 2) & 0x1;
1164 unsigned NumInstanceMethods = FullInstanceBits >> 3;
1165 unsigned NumFactoryMethods = FullFactoryBits >> 3;
1168 for (
unsigned I = 0; I != NumInstanceMethods; ++I) {
1172 endian::readNext<DeclID, llvm::endianness::little>(d))))
1177 for (
unsigned I = 0; I != NumFactoryMethods; ++I) {
1181 endian::readNext<DeclID, llvm::endianness::little>(d))))
1189 return llvm::djbHash(a);
1192std::pair<unsigned, unsigned>
1199 assert(n >= 2 && d[n-1] ==
'\0');
1200 return StringRef((
const char*) d, n-1);
1206 bool IsInteresting =
1217 bool Value = Bits & 0x1;
1223 using namespace llvm::support;
1226 endian::readNext<IdentifierID, llvm::endianness::little>(d);
1227 return Reader.getGlobalIdentifierID(F, RawID >> 1);
1240 const unsigned char* d,
1242 using namespace llvm::support;
1245 endian::readNext<IdentifierID, llvm::endianness::little>(d);
1246 bool IsInteresting = RawID & 0x01;
1256 II = &Reader.getIdentifierTable().getOwn(k);
1259 bool IsModule = Reader.getPreprocessor().getCurrentModule() !=
nullptr;
1261 Reader.markIdentifierUpToDate(II);
1263 IdentifierID ID = Reader.getGlobalIdentifierID(F, RawID);
1264 if (!IsInteresting) {
1267 Reader.SetIdentifierInfo(ID, II);
1271 unsigned ObjCOrBuiltinID =
1272 endian::readNext<uint16_t, llvm::endianness::little>(d);
1273 unsigned Bits = endian::readNext<uint16_t, llvm::endianness::little>(d);
1274 bool CPlusPlusOperatorKeyword =
readBit(Bits);
1275 bool HasRevertedTokenIDToIdentifier =
readBit(Bits);
1276 bool Poisoned =
readBit(Bits);
1277 bool ExtensionToken =
readBit(Bits);
1278 bool HasMacroDefinition =
readBit(Bits);
1280 assert(Bits == 0 &&
"Extra bits in the identifier?");
1281 DataLen -=
sizeof(uint16_t) * 2;
1285 if (HasRevertedTokenIDToIdentifier && II->
getTokenID() != tok::identifier)
1290 "Incorrect extension token flag");
1291 (void)ExtensionToken;
1295 "Incorrect C++ operator keyword flag");
1296 (void)CPlusPlusOperatorKeyword;
1300 if (HasMacroDefinition) {
1301 uint32_t MacroDirectivesOffset =
1302 endian::readNext<uint32_t, llvm::endianness::little>(d);
1305 if (MacroDirectivesOffset)
1306 Reader.addPendingMacro(II, &F, MacroDirectivesOffset);
1308 hasMacroDefinitionInDependencies =
true;
1311 Reader.SetIdentifierInfo(ID, II);
1317 for (; DataLen > 0; DataLen -=
sizeof(
DeclID))
1318 DeclIDs.push_back(Reader.getGlobalDeclID(
1321 endian::readNext<DeclID, llvm::endianness::little>(d))));
1322 Reader.SetGloballyVisibleDecls(II, DeclIDs);
1329 : Kind(Name.getNameKind()) {
1359 llvm::FoldingSetNodeID ID;
1360 ID.AddInteger(Kind);
1383 return ID.computeStableHash();
1388 using namespace llvm::support;
1390 uint32_t ModuleFileID =
1391 endian::readNext<uint32_t, llvm::endianness::little>(d);
1392 return Reader.getLocalModuleFile(
F, ModuleFileID);
1395std::pair<unsigned, unsigned>
1402 using namespace llvm::support;
1411 F, endian::readNext<IdentifierID, llvm::endianness::little>(d));
1418 F, endian::readNext<uint32_t, llvm::endianness::little>(d))
1442 using namespace llvm::support;
1444 for (
unsigned NumDecls = DataLen /
sizeof(
DeclID); NumDecls; --NumDecls) {
1446 Reader,
F, endian::readNext<DeclID, llvm::endianness::little>(d));
1452 const unsigned char *d,
1460 llvm::FoldingSetNodeID ID;
1461 ID.AddInteger(Key.first.getHash());
1462 ID.AddInteger(Key.second);
1463 return ID.computeStableHash();
1474 return {Name, *ModuleHash};
1480 unsigned PrimaryModuleHash =
1481 llvm::support::endian::readNext<uint32_t, llvm::endianness::little>(d);
1482 return {Name, PrimaryModuleHash};
1486 const unsigned char *d,
1494 using namespace llvm::support;
1496 uint32_t ModuleFileID =
1497 endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d);
1498 return Reader.getLocalModuleFile(F, ModuleFileID);
1503 using namespace llvm::support;
1504 return endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d);
1507std::pair<unsigned, unsigned>
1513 const unsigned char *d,
1516 using namespace llvm::support;
1518 for (
unsigned NumDecls =
1520 NumDecls; --NumDecls) {
1523 endian::readNext<DeclID, llvm::endianness::little, unaligned>(d));
1524 Val.
insert(Reader.getGlobalDeclID(F, LocalID));
1528bool ASTReader::ReadLexicalDeclContextStorage(
ModuleFile &M,
1529 BitstreamCursor &Cursor,
1532 assert(Offset != 0);
1535 if (llvm::Error Err = Cursor.JumpToBit(Offset)) {
1536 Error(std::move(Err));
1544 Error(MaybeCode.takeError());
1547 unsigned Code = MaybeCode.get();
1550 if (!MaybeRecCode) {
1551 Error(MaybeRecCode.takeError());
1554 unsigned RecCode = MaybeRecCode.get();
1556 Error(
"Expected lexical block");
1561 "expected a TU_UPDATE_LEXICAL record for TU");
1566 auto &Lex = LexicalDecls[DC];
1568 Lex = std::make_pair(
1571 Blob.size() /
sizeof(
DeclID)));
1577bool ASTReader::ReadVisibleDeclContextStorage(
1578 ModuleFile &M, BitstreamCursor &Cursor, uint64_t Offset, GlobalDeclID ID,
1579 ASTReader::VisibleDeclContextStorageKind VisibleKind) {
1580 assert(Offset != 0);
1582 SavedStreamPosition SavedPosition(Cursor);
1583 if (llvm::Error Err =
Cursor.JumpToBit(Offset)) {
1584 Error(std::move(Err));
1590 Expected<unsigned> MaybeCode =
Cursor.ReadCode();
1592 Error(MaybeCode.takeError());
1595 unsigned Code = MaybeCode.get();
1597 Expected<unsigned> MaybeRecCode =
Cursor.readRecord(Code,
Record, &Blob);
1598 if (!MaybeRecCode) {
1599 Error(MaybeRecCode.takeError());
1602 unsigned RecCode = MaybeRecCode.get();
1603 switch (VisibleKind) {
1604 case VisibleDeclContextStorageKind::GenerallyVisible:
1606 Error(
"Expected visible lookup table block");
1610 case VisibleDeclContextStorageKind::ModuleLocalVisible:
1612 Error(
"Expected module local visible lookup table block");
1616 case VisibleDeclContextStorageKind::TULocalVisible:
1618 Error(
"Expected TU local lookup table block");
1626 auto *
Data = (
const unsigned char*)Blob.data();
1627 switch (VisibleKind) {
1628 case VisibleDeclContextStorageKind::GenerallyVisible:
1629 PendingVisibleUpdates[
ID].push_back(UpdateData{&M,
Data});
1631 case VisibleDeclContextStorageKind::ModuleLocalVisible:
1632 PendingModuleLocalVisibleUpdates[
ID].push_back(UpdateData{&M,
Data});
1634 case VisibleDeclContextStorageKind::TULocalVisible:
1636 TULocalUpdates[
ID].push_back(UpdateData{&M,
Data});
1642void ASTReader::AddSpecializations(
const Decl *D,
const unsigned char *
Data,
1646 IsPartial ? PartialSpecializationsLookups : SpecializationsLookups;
1647 SpecLookups[D].Table.add(&M,
Data,
1651bool ASTReader::ReadSpecializations(
ModuleFile &M, BitstreamCursor &Cursor,
1652 uint64_t Offset, Decl *D,
bool IsPartial) {
1653 assert(Offset != 0);
1655 SavedStreamPosition SavedPosition(Cursor);
1656 if (llvm::Error Err =
Cursor.JumpToBit(Offset)) {
1657 Error(std::move(Err));
1663 Expected<unsigned> MaybeCode =
Cursor.ReadCode();
1665 Error(MaybeCode.takeError());
1668 unsigned Code = MaybeCode.get();
1670 Expected<unsigned> MaybeRecCode =
Cursor.readRecord(Code,
Record, &Blob);
1671 if (!MaybeRecCode) {
1672 Error(MaybeRecCode.takeError());
1675 unsigned RecCode = MaybeRecCode.get();
1678 Error(
"Expected decl specs block");
1682 auto *
Data = (
const unsigned char *)Blob.data();
1683 AddSpecializations(D,
Data, M, IsPartial);
1687void ASTReader::Error(StringRef Msg)
const {
1688 Error(diag::err_fe_ast_file_malformed, Msg);
1689 if (PP.getLangOpts().Modules &&
1690 !PP.getHeaderSearchInfo().getSpecificModuleCachePath().empty()) {
1691 Diag(diag::note_module_cache_path)
1692 << PP.getHeaderSearchInfo().getSpecificModuleCachePath();
1696void ASTReader::Error(
unsigned DiagID, StringRef Arg1, StringRef Arg2,
1697 StringRef Arg3)
const {
1698 Diag(DiagID) << Arg1 << Arg2 << Arg3;
1702struct AlreadyReportedDiagnosticError
1703 : llvm::ErrorInfo<AlreadyReportedDiagnosticError> {
1706 void log(raw_ostream &OS)
const override {
1707 llvm_unreachable(
"reporting an already-reported diagnostic error");
1710 std::error_code convertToErrorCode()
const override {
1711 return llvm::inconvertibleErrorCode();
1715char AlreadyReportedDiagnosticError::ID = 0;
1718void ASTReader::Error(llvm::Error &&Err)
const {
1720 std::move(Err), [](AlreadyReportedDiagnosticError &) {},
1721 [&](llvm::ErrorInfoBase &E) {
return Error(E.message()); });
1731 LineTableInfo &LineTable = SourceMgr.getLineTable();
1734 std::map<int, int> FileIDs;
1736 for (
unsigned I = 0;
Record[Idx]; ++I) {
1738 auto Filename = ReadPath(F,
Record, Idx);
1744 std::vector<LineEntry> Entries;
1745 while (Idx <
Record.size()) {
1746 FileID FID = ReadFileID(F,
Record, Idx);
1749 unsigned NumEntries =
Record[Idx++];
1750 assert(NumEntries &&
"no line entries for file ID");
1752 Entries.reserve(NumEntries);
1753 for (
unsigned I = 0; I != NumEntries; ++I) {
1754 unsigned FileOffset =
Record[Idx++];
1755 unsigned LineNo =
Record[Idx++];
1756 int FilenameID = FileIDs[
Record[Idx++]];
1759 unsigned IncludeOffset =
Record[Idx++];
1761 FileKind, IncludeOffset));
1768llvm::Error ASTReader::ReadSourceManagerBlock(
ModuleFile &F) {
1769 using namespace SrcMgr;
1777 SLocEntryCursor = F.
Stream;
1780 if (llvm::Error Err = F.
Stream.SkipBlock())
1790 Expected<llvm::BitstreamEntry> MaybeE =
1791 SLocEntryCursor.advanceSkippingSubblocks();
1793 return MaybeE.takeError();
1794 llvm::BitstreamEntry E = MaybeE.get();
1797 case llvm::BitstreamEntry::SubBlock:
1798 case llvm::BitstreamEntry::Error:
1799 return llvm::createStringError(std::errc::illegal_byte_sequence,
1800 "malformed block record in AST file");
1801 case llvm::BitstreamEntry::EndBlock:
1802 return llvm::Error::success();
1803 case llvm::BitstreamEntry::Record:
1811 Expected<unsigned> MaybeRecord =
1812 SLocEntryCursor.readRecord(E.ID,
Record, &Blob);
1814 return MaybeRecord.takeError();
1815 switch (MaybeRecord.get()) {
1823 return llvm::Error::success();
1828llvm::Expected<SourceLocation::UIntTy>
1834 return std::move(Err);
1838 return MaybeEntry.takeError();
1840 llvm::BitstreamEntry Entry = MaybeEntry.get();
1841 if (Entry.Kind != llvm::BitstreamEntry::Record)
1842 return llvm::createStringError(
1843 std::errc::illegal_byte_sequence,
1844 "incorrectly-formatted source location entry in AST file");
1850 return MaybeSLOC.takeError();
1852 switch (MaybeSLOC.get()) {
1854 return llvm::createStringError(
1855 std::errc::illegal_byte_sequence,
1856 "incorrectly-formatted source location entry in AST file");
1866 GlobalSLocOffsetMap.find(SourceManager::MaxLoadedOffset - SLocOffset - 1);
1867 assert(SLocMapI != GlobalSLocOffsetMap.end() &&
1868 "Corrupted global sloc offset map");
1873 auto It = llvm::upper_bound(
1876 int ID = F->SLocEntryBaseID + LocalIndex;
1877 std::size_t Index = -ID - 2;
1878 if (!SourceMgr.SLocEntryOffsetLoaded[Index]) {
1879 assert(!SourceMgr.SLocEntryLoaded[Index]);
1880 auto MaybeEntryOffset = readSLocOffset(F, LocalIndex);
1881 if (!MaybeEntryOffset) {
1882 Error(MaybeEntryOffset.takeError());
1886 SourceMgr.LoadedSLocEntryTable[Index] =
1887 SrcMgr::SLocEntry::getOffsetOnly(*MaybeEntryOffset);
1888 SourceMgr.SLocEntryOffsetLoaded[Index] = true;
1890 return Offset < SourceMgr.LoadedSLocEntryTable[Index].getOffset();
1901std::pair<SourceLocation::UIntTy, SourceLocationEncoding::Chain>
1908std::pair<SourceLocation::UIntTy, SourceLocationEncoding::Chain>
1923 Error(
"source location entry ID out-of-range for AST file");
1929 auto ReadBuffer = [
this](
1930 BitstreamCursor &SLocEntryCursor,
1931 StringRef Name) -> std::unique_ptr<llvm::MemoryBuffer> {
1936 Error(MaybeCode.takeError());
1939 unsigned Code = MaybeCode.get();
1942 SLocEntryCursor.readRecord(Code,
Record, &Blob);
1943 if (!MaybeRecCode) {
1944 Error(MaybeRecCode.takeError());
1947 unsigned RecCode = MaybeRecCode.get();
1951 if (llvm::Error E = llvm::compression::decompress(
1952 llvm::arrayRefFromStringRef(Blob), Decompressed,
Record[0])) {
1953 Error(
"could not decompress embedded file contents: " +
1954 llvm::toString(std::move(E)));
1957 return llvm::MemoryBuffer::getMemBufferCopy(
1958 llvm::toStringRef(Decompressed), Name);
1960 return llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name,
true);
1962 Error(
"AST record has invalid code");
1967 ModuleFile *F = GlobalSLocEntryMap.find(-ID)->second;
1971 Error(std::move(Err));
1978 ++NumSLocEntriesRead;
1981 Error(MaybeEntry.takeError());
1984 llvm::BitstreamEntry Entry = MaybeEntry.get();
1986 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1987 Error(
"incorrectly-formatted source location entry in AST file");
1994 SLocEntryCursor.readRecord(Entry.ID,
Record, &Blob);
1996 Error(MaybeSLOC.takeError());
1999 switch (MaybeSLOC.get()) {
2001 Error(
"incorrectly-formatted source location entry in AST file");
2007 unsigned InputID =
Record[4];
2008 InputFile IF = getInputFile(*F, InputID);
2021 IncludeLoc = getImportLocation(F);
2025 FileID FID = SourceMgr.createFileID(*
File, IncludeLoc, FileCharacter, ID,
2028 FileInfo.NumCreatedFIDs =
Record[5];
2032 unsigned NumFileDecls =
Record[7];
2033 if (NumFileDecls && ContextObj) {
2035 assert(F->
FileSortedDecls &&
"FILE_SORTED_DECLS not encountered yet ?");
2041 SourceMgr.getOrCreateContentCache(*
File, isSystem(FileCharacter));
2045 auto Buffer = ReadBuffer(SLocEntryCursor,
File->getName());
2048 SourceMgr.overrideFileContents(*
File, std::move(Buffer));
2055 const char *Name = Blob.data();
2056 unsigned Offset =
Record[0];
2061 IncludeLoc = getImportLocation(F);
2064 auto Buffer = ReadBuffer(SLocEntryCursor, Name);
2067 FileID FID = SourceMgr.createFileID(std::move(Buffer), FileCharacter, ID,
2068 BaseOffset + Offset, IncludeLoc);
2070 auto &FileInfo = SourceMgr.getSLocEntry(FID).getFile();
2071 FileInfo.setHasLineDirectives();
2083 SourceMgr.createExpansionLoc(SpellingLoc, ExpansionBegin, ExpansionEnd,
2085 BaseOffset + EntryOffset);
2098 Error(
"source location entry ID out-of-range for AST file");
2103 ModuleFile *M = GlobalSLocEntryMap.find(-ID)->second;
2121 assert(SourceMgr.getMainFileID().isValid() &&
"missing main file");
2122 return SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
2132 uint64_t *StartOfBlockOffset) {
2133 if (llvm::Error Err = Cursor.EnterSubBlock(BlockID))
2136 if (StartOfBlockOffset)
2137 *StartOfBlockOffset = Cursor.GetCurrentBitNo();
2140 uint64_t Offset = Cursor.GetCurrentBitNo();
2143 return MaybeCode.takeError();
2144 unsigned Code = MaybeCode.get();
2147 if (Code != llvm::bitc::DEFINE_ABBREV) {
2148 if (llvm::Error Err = Cursor.JumpToBit(Offset))
2150 return llvm::Error::success();
2152 if (llvm::Error Err = Cursor.ReadAbbrevRecord())
2165 if (
Tok.isAnnotation()) {
2167 switch (
Tok.getKind()) {
2168 case tok::annot_pragma_loop_hint: {
2172 unsigned NumTokens =
Record[Idx++];
2174 Toks.reserve(NumTokens);
2175 for (
unsigned I = 0; I < NumTokens; ++I)
2177 Info->Toks =
llvm::ArrayRef(Toks).copy(PP.getPreprocessorAllocator());
2178 Tok.setAnnotationValue(
static_cast<void *
>(Info));
2181 case tok::annot_pragma_pack: {
2186 llvm::StringRef(SlotLabel).copy(PP.getPreprocessorAllocator());
2188 Tok.setAnnotationValue(
static_cast<void *
>(Info));
2192 case tok::annot_pragma_openmp:
2193 case tok::annot_pragma_openmp_end:
2194 case tok::annot_pragma_unused:
2195 case tok::annot_pragma_openacc:
2196 case tok::annot_pragma_openacc_end:
2199 llvm_unreachable(
"missing deserialization code for annotation token");
2204 Tok.setIdentifierInfo(II);
2216 if (llvm::Error Err = Stream.JumpToBit(Offset)) {
2218 consumeError(std::move(Err));
2230 unsigned Flags = BitstreamCursor::AF_DontPopBlockAtEnd;
2232 Stream.advanceSkippingSubblocks(Flags);
2234 Error(MaybeEntry.takeError());
2237 llvm::BitstreamEntry Entry = MaybeEntry.get();
2239 switch (Entry.Kind) {
2240 case llvm::BitstreamEntry::SubBlock:
2241 case llvm::BitstreamEntry::Error:
2242 Error(
"malformed block record in AST file");
2244 case llvm::BitstreamEntry::EndBlock:
2246 case llvm::BitstreamEntry::Record:
2257 Error(MaybeRecType.takeError());
2273 unsigned NextIndex = 1;
2275 MacroInfo *MI = PP.AllocateMacroInfo(Loc);
2280 PP.getPreprocessorAllocator());
2283 bool isC99VarArgs =
Record[NextIndex++];
2284 bool isGNUVarArgs =
Record[NextIndex++];
2285 bool hasCommaPasting =
Record[NextIndex++];
2286 MacroParams.clear();
2287 unsigned NumArgs =
Record[NextIndex++];
2288 for (
unsigned i = 0; i != NumArgs; ++i)
2303 if (NextIndex + 1 ==
Record.size() && PP.getPreprocessingRecord() &&
2308 unsigned Index = translatePreprocessedEntityIDToIndex(GlobalID);
2310 PreprocessingRecord::PPEntityID PPID =
2311 PPRec.getPPEntityID(Index,
true);
2313 PPRec.getPreprocessedEntity(PPID));
2315 PPRec.RegisterMacroDefinition(
Macro, PPDef);
2326 if (MacroTokens.empty()) {
2327 Error(
"unexpected number of macro tokens for a macro in AST file");
2333 MacroTokens = MacroTokens.drop_front();
2344 ReadModuleOffsetMap(M);
2346 unsigned ModuleFileIndex = LocalID >> 32;
2347 LocalID &= llvm::maskTrailingOnes<PreprocessedEntityID>(32);
2350 assert(MF &&
"malformed identifier ID encoding?");
2352 if (!ModuleFileIndex) {
2361HeaderFileInfoTrait::getFile(
const internal_key_type &Key) {
2364 return FileMgr.getOptionalFileRef(Key.Filename);
2368 return FileMgr.getOptionalFileRef(*Resolved);
2372 uint8_t buf[
sizeof(ikey.
Size) +
sizeof(ikey.
ModTime)];
2375 return llvm::xxh3_64bits(buf);
2396 return FEA && FEA == FEB;
2399std::pair<unsigned, unsigned>
2406 using namespace llvm::support;
2409 ikey.
Size = off_t(endian::readNext<uint64_t, llvm::endianness::little>(d));
2411 time_t(endian::readNext<uint64_t, llvm::endianness::little>(d));
2420 using namespace llvm::support;
2422 const unsigned char *End = d + DataLen;
2424 unsigned Flags = *d++;
2427 bool Included = (Flags >> 6) & 0x01;
2429 if ((FE = getFile(key)))
2432 Reader.getPreprocessor().getIncludedFiles().insert(*FE);
2435 HFI.
isImport |= (Flags >> 5) & 0x01;
2437 HFI.
DirInfo = (Flags >> 1) & 0x07;
2439 M, endian::readNext<IdentifierID, llvm::endianness::little>(d));
2441 assert((End - d) % 4 == 0 &&
2442 "Wrong data length in HeaderFileInfo deserialization");
2444 uint32_t LocalSMID =
2445 endian::readNext<uint32_t, llvm::endianness::little>(d);
2451 SubmoduleID GlobalSMID = Reader.getGlobalSubmoduleID(M, LocalSMID);
2452 Module *Mod = Reader.getSubmodule(GlobalSMID);
2454 Reader.getPreprocessor().getHeaderSearchInfo().getModuleMap();
2456 if (FE || (FE = getFile(key))) {
2459 ModMap.
addHeader(Mod, H, HeaderRole,
true);
2471 uint32_t MacroDirectivesOffset) {
2472 assert(NumCurrentElementsDeserializing > 0 &&
"Missing deserialization guard");
2473 PendingMacroIDs[II].push_back(PendingMacroInfo(M, MacroDirectivesOffset));
2480 for (
ModuleFile &I : llvm::reverse(ModuleMgr)) {
2481 BitstreamCursor &MacroCursor = I.MacroCursor;
2484 if (MacroCursor.getBitcodeBytes().empty())
2487 BitstreamCursor Cursor = MacroCursor;
2488 if (llvm::Error Err = Cursor.JumpToBit(I.MacroStartOffset)) {
2489 Error(std::move(Err));
2497 Error(MaybeE.takeError());
2500 llvm::BitstreamEntry E = MaybeE.get();
2503 case llvm::BitstreamEntry::SubBlock:
2504 case llvm::BitstreamEntry::Error:
2505 Error(
"malformed block record in AST file");
2507 case llvm::BitstreamEntry::EndBlock:
2510 case llvm::BitstreamEntry::Record: {
2514 Error(MaybeRecord.takeError());
2517 switch (MaybeRecord.get()) {
2544 class IdentifierLookupVisitor {
2547 unsigned PriorGeneration;
2548 unsigned &NumIdentifierLookups;
2549 unsigned &NumIdentifierLookupHits;
2553 IdentifierLookupVisitor(StringRef Name,
unsigned PriorGeneration,
2554 unsigned &NumIdentifierLookups,
2555 unsigned &NumIdentifierLookupHits)
2557 PriorGeneration(PriorGeneration),
2558 NumIdentifierLookups(NumIdentifierLookups),
2559 NumIdentifierLookupHits(NumIdentifierLookupHits) {}
2573 ++NumIdentifierLookups;
2574 ASTIdentifierLookupTable::iterator Pos =
2575 IdTable->find_hashed(Name, NameHash, &Trait);
2576 if (Pos == IdTable->end())
2582 ++NumIdentifierLookupHits;
2584 if (Trait.hasMoreInformationInDependencies()) {
2593 IdentifierInfo *getIdentifierInfo()
const {
return Found; }
2602 unsigned PriorGeneration = 0;
2604 PriorGeneration = IdentifierGeneration[&II];
2611 if (GlobalIndex->lookupIdentifier(II.
getName(), Hits)) {
2616 IdentifierLookupVisitor Visitor(II.
getName(), PriorGeneration,
2617 NumIdentifierLookups,
2618 NumIdentifierLookupHits);
2619 ModuleMgr.visit(Visitor, HitsPtr);
2636 uint64_t ModuleFileIndex =
Record[Idx++] << 32;
2637 uint64_t LocalIndex =
Record[Idx++];
2642 const PendingMacroInfo &PMInfo) {
2647 if (llvm::Error Err =
2649 Error(std::move(Err));
2653 struct ModuleMacroRecord {
2666 Cursor.advance(BitstreamCursor::AF_DontPopBlockAtEnd);
2668 Error(MaybeEntry.takeError());
2671 llvm::BitstreamEntry Entry = MaybeEntry.get();
2673 if (Entry.Kind != llvm::BitstreamEntry::Record) {
2674 Error(
"malformed block record in AST file");
2681 Error(MaybePP.takeError());
2689 ModuleMacros.push_back(ModuleMacroRecord());
2690 auto &Info = ModuleMacros.back();
2694 for (
int I = Idx, N =
Record.size(); I != N; ++I)
2700 Error(
"malformed block record in AST file");
2711 std::reverse(ModuleMacros.begin(), ModuleMacros.end());
2713 for (
auto &MMR : ModuleMacros) {
2715 for (
unsigned ModID : MMR.Overrides) {
2717 auto *
Macro = PP.getModuleMacro(Mod, II);
2718 assert(
Macro &&
"missing definition for overridden macro");
2719 Overrides.push_back(
Macro);
2722 bool Inserted =
false;
2724 PP.addModuleMacro(Owner, II, MMR.MI, Overrides, Inserted);
2735 unsigned Idx = 0, N =
Record.size();
2743 MD = PP.AllocateDefMacroDirective(MI, Loc);
2747 MD = PP.AllocateUndefMacroDirective(Loc);
2750 bool isPublic =
Record[Idx++];
2751 MD = PP.AllocateVisibilityMacroDirective(Loc, isPublic);
2763 PP.setLoadedMacroDirective(II, Earliest, Latest);
2766bool ASTReader::shouldDisableValidationForFile(
2789static std::pair<StringRef, StringRef>
2791 const StringRef InputBlob) {
2793 return {InputBlob.substr(0, AsRequestedLength),
2794 InputBlob.substr(AsRequestedLength)};
2808 SavedStreamPosition SavedPosition(Cursor);
2812 consumeError(std::move(Err));
2815 Expected<unsigned> MaybeCode =
Cursor.ReadCode();
2818 consumeError(MaybeCode.takeError());
2820 unsigned Code = MaybeCode.get();
2824 if (Expected<unsigned> Maybe =
Cursor.readRecord(Code,
Record, &Blob))
2826 "invalid record type for input file");
2829 consumeError(
Maybe.takeError());
2832 assert(
Record[0] == ID &&
"Bogus stored ID or offset");
2834 R.StoredSize =
static_cast<off_t
>(
Record[1]);
2835 R.StoredTime =
static_cast<time_t
>(
Record[2]);
2836 R.Overridden =
static_cast<bool>(
Record[3]);
2837 R.Transient =
static_cast<bool>(
Record[4]);
2838 R.TopLevel =
static_cast<bool>(
Record[5]);
2839 R.ModuleMap =
static_cast<bool>(
Record[6]);
2840 auto [UnresolvedFilenameAsRequested, UnresolvedFilename] =
2842 R.UnresolvedImportedFilenameAsRequested = UnresolvedFilenameAsRequested;
2843 R.UnresolvedImportedFilename = UnresolvedFilename.empty()
2844 ? UnresolvedFilenameAsRequested
2845 : UnresolvedFilename;
2847 Expected<llvm::BitstreamEntry> MaybeEntry =
Cursor.advance();
2849 consumeError(MaybeEntry.takeError());
2850 llvm::BitstreamEntry Entry = MaybeEntry.get();
2851 assert(Entry.Kind == llvm::BitstreamEntry::Record &&
2852 "expected record type for input file hash");
2855 if (Expected<unsigned> Maybe =
Cursor.readRecord(Entry.ID,
Record))
2857 "invalid record type for input file hash");
2860 consumeError(
Maybe.takeError());
2885 SavedStreamPosition SavedPosition(Cursor);
2889 consumeError(std::move(Err));
2904 const HeaderSearchOptions &HSOpts =
2905 PP.getHeaderSearchInfo().getHeaderSearchOpts();
2918 if ((Overridden || Transient || SkipChecks) && !
File)
2923 std::string ErrorStr =
"could not find file '";
2924 ErrorStr += *Filename;
2925 ErrorStr +=
"' referenced by AST file '";
2939 SourceManager &SM = getSourceManager();
2941 if ((!Overridden && !Transient) && !SkipChecks &&
2944 Error(diag::err_fe_pch_file_overridden, *Filename);
2955 auto HasInputContentChanged = [&](
Change OriginalChange) {
2956 assert(ValidateASTInputFilesContent &&
2957 "We should only check the content of the inputs with "
2958 "ValidateASTInputFilesContent enabled.");
2960 if (StoredContentHash == 0)
2961 return OriginalChange;
2964 if (!MemBuffOrError) {
2966 return OriginalChange;
2967 std::string ErrorStr =
"could not get buffer for file '";
2968 ErrorStr +=
File->getName();
2971 return OriginalChange;
2974 auto ContentHash = xxh3_64bits(MemBuffOrError.get()->getBuffer());
2975 if (StoredContentHash ==
static_cast<uint64_t>(ContentHash))
2980 auto HasInputFileChanged = [&]() {
2981 if (StoredSize !=
File->getSize())
2983 if (!shouldDisableValidationForFile(F) && StoredTime &&
2984 StoredTime !=
File->getModificationTime()) {
2986 File->getModificationTime()};
2990 if (ValidateASTInputFilesContent)
2991 return HasInputContentChanged(MTimeChange);
2998 bool IsOutOfDate =
false;
3005 FileChange = HasInputContentChanged(FileChange);
3011 if (!StoredTime && ValidateASTInputFilesContent &&
3013 FileChange = HasInputContentChanged(FileChange);
3019 SmallVector<ModuleFile *, 4> ImportStack(1, &F);
3020 while (!ImportStack.back()->ImportedBy.empty())
3021 ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
3024 StringRef TopLevelASTFileName(ImportStack.back()->FileName);
3025 Diag(diag::err_fe_ast_file_modified)
3027 << TopLevelASTFileName;
3028 Diag(diag::note_fe_ast_file_modified)
3029 << FileChange.Kind << (FileChange.Old && FileChange.New)
3030 << llvm::itostr(FileChange.Old.value_or(0))
3031 << llvm::itostr(FileChange.New.value_or(0));
3032 if (getModuleManager()
3034 .getInMemoryModuleCache()
3039 if (ImportStack.size() > 1) {
3040 Diag(diag::note_ast_file_required_by)
3041 << *Filename << ImportStack[0]->FileName;
3042 for (
unsigned I = 1; I < ImportStack.size(); ++I)
3043 Diag(diag::note_ast_file_required_by)
3044 << ImportStack[I - 1]->FileName << ImportStack[I]->FileName;
3048 Diag(diag::note_ast_file_rebuild_required) << TopLevelASTFileName;
3049 Diag(diag::note_ast_file_input_files_validation_status)
3065ASTReader::TemporarilyOwnedStringRef
3071ASTReader::TemporarilyOwnedStringRef
3074 assert(Buf.capacity() != 0 &&
"Overlapping ResolveImportedPath calls");
3076 if (Prefix.empty() || Path.empty() || llvm::sys::path::is_absolute(Path) ||
3077 Path ==
"<built-in>" || Path ==
"<command line>")
3082 return {Prefix, Buf};
3085 llvm::sys::path::append(Buf, Prefix, Path);
3086 StringRef ResolvedPath{Buf.data(), Buf.size()};
3087 return {ResolvedPath, Buf};
3100 return ResolvedPath->str();
3115 llvm_unreachable(
"unknown ASTReadResult");
3119 BitstreamCursor &Stream, StringRef Filename,
3120 unsigned ClientLoadCapabilities,
bool AllowCompatibleConfigurationMismatch,
3121 ASTReaderListener &Listener, std::string &SuggestedPredefines) {
3124 consumeError(std::move(Err));
3132 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
3135 consumeError(MaybeEntry.takeError());
3138 llvm::BitstreamEntry Entry = MaybeEntry.get();
3140 switch (Entry.Kind) {
3141 case llvm::BitstreamEntry::Error:
3142 case llvm::BitstreamEntry::SubBlock:
3145 case llvm::BitstreamEntry::EndBlock:
3148 case llvm::BitstreamEntry::Record:
3155 Expected<unsigned> MaybeRecordType = Stream.readRecord(Entry.ID,
Record);
3156 if (!MaybeRecordType) {
3158 consumeError(MaybeRecordType.takeError());
3163 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
3164 if (ParseLanguageOptions(
Record, Filename, Complain, Listener,
3165 AllowCompatibleConfigurationMismatch))
3166 Result = ConfigurationMismatch;
3171 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
3172 if (ParseCodeGenOptions(
Record, Filename, Complain, Listener,
3173 AllowCompatibleConfigurationMismatch))
3174 Result = ConfigurationMismatch;
3179 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
3180 if (ParseTargetOptions(
Record, Filename, Complain, Listener,
3181 AllowCompatibleConfigurationMismatch))
3182 Result = ConfigurationMismatch;
3187 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
3188 if (!AllowCompatibleConfigurationMismatch &&
3189 ParseFileSystemOptions(
Record, Complain, Listener))
3190 Result = ConfigurationMismatch;
3195 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
3196 if (!AllowCompatibleConfigurationMismatch &&
3197 ParseHeaderSearchOptions(
Record, Filename, Complain, Listener))
3198 Result = ConfigurationMismatch;
3203 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
3204 if (!AllowCompatibleConfigurationMismatch &&
3205 ParsePreprocessorOptions(
Record, Filename, Complain, Listener,
3206 SuggestedPredefines))
3207 Result = ConfigurationMismatch;
3214static std::pair<bool, bool>
3217 const bool EnablesBSValidation =
3219 const bool WasValidated =
3220 EnablesBSValidation &&
3222 return {EnablesBSValidation, WasValidated};
3225ASTReader::RelocationResult
3226ASTReader::getModuleForRelocationChecks(
ModuleFile &F,
bool DirectoryCheck) {
3228 const bool IgnoreError =
3229 bool(PP.getPreprocessorOpts().DisablePCHOrModuleValidation &
3232 if (!PP.getPreprocessorOpts().ModulesCheckRelocated)
3233 return {std::nullopt, IgnoreError};
3237 if (!DirectoryCheck &&
3238 (!IsImplicitModule || ModuleMgr.begin()->Kind ==
MK_MainFile))
3239 return {std::nullopt, IgnoreError};
3241 const HeaderSearchOptions &HSOpts =
3242 PP.getHeaderSearchInfo().getHeaderSearchOpts();
3247 auto [EnablesBSValidation, WasValidated] =
3249 const bool SkipModuleLookup =
3250 !PP.getPreprocessorOpts().ModulesForceRedundantLookup &&
3252 (EnablesBSValidation &&
3255 if (SkipModuleLookup)
3256 return {std::nullopt, IgnoreError};
3263 Module *M = PP.getHeaderSearchInfo().lookupModule(
3268 return {M, IgnoreError};
3273 SmallVectorImpl<ImportedModule> &Loaded,
3275 unsigned ClientLoadCapabilities) {
3276 BitstreamCursor &Stream = F.
Stream;
3279 Error(std::move(Err));
3289 bool HasReadUnhashedControlBlock =
false;
3290 auto readUnhashedControlBlockOnce = [&]() {
3291 if (!HasReadUnhashedControlBlock) {
3292 HasReadUnhashedControlBlock =
true;
3293 if (ASTReadResult
Result =
3294 readUnhashedControlBlock(F, ImportedBy, ClientLoadCapabilities))
3300 bool DisableValidation = shouldDisableValidationForFile(F);
3304 unsigned NumInputs = 0;
3305 unsigned NumUserInputs = 0;
3306 StringRef BaseDirectoryAsWritten;
3308 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
3310 Error(MaybeEntry.takeError());
3313 llvm::BitstreamEntry Entry = MaybeEntry.get();
3315 switch (Entry.Kind) {
3316 case llvm::BitstreamEntry::Error:
3317 Error(
"malformed block record in AST file");
3319 case llvm::BitstreamEntry::EndBlock: {
3322 if (ASTReadResult
Result = readUnhashedControlBlockOnce())
3326 const HeaderSearchOptions &HSOpts =
3327 PP.getHeaderSearchInfo().getHeaderSearchOpts();
3335 !canRecoverFromOutOfDate(F.
FileName, ClientLoadCapabilities);
3341 unsigned N = ValidateSystemInputs ? NumInputs : NumUserInputs;
3347 N = ForceValidateUserInputs ? NumUserInputs : 0;
3349 ForceValidateUserInputs
3355 Diag(diag::remark_module_validation)
3358 for (
unsigned I = 0; I < N; ++I) {
3359 InputFile IF = getInputFile(F, I+1, Complain);
3368 isDirectoryDependencyOutOfDate(F, Complain))
3380 for (
unsigned I = 0; I < N; ++I) {
3381 bool IsSystem = I >= NumUserInputs;
3383 auto FilenameAsRequested = ResolveImportedPath(
3386 *FilenameAsRequested, IsSystem, FI.
Overridden,
3394 case llvm::BitstreamEntry::SubBlock:
3398 if (llvm::Error Err = Stream.SkipBlock()) {
3399 Error(std::move(Err));
3403 Error(
"malformed block record in AST file");
3413 if (Listener && !ImportedBy) {
3419 bool AllowCompatibleConfigurationMismatch =
3423 ReadOptionsBlock(Stream, F.
FileName, ClientLoadCapabilities,
3424 AllowCompatibleConfigurationMismatch, *Listener,
3425 SuggestedPredefines);
3427 Error(
"malformed block record in AST file");
3431 if (DisableValidation ||
3432 (AllowConfigurationMismatch &&
Result == ConfigurationMismatch))
3440 }
else if (llvm::Error Err = Stream.SkipBlock()) {
3441 Error(std::move(Err));
3447 if (llvm::Error Err = Stream.SkipBlock()) {
3448 Error(std::move(Err));
3454 case llvm::BitstreamEntry::Record:
3462 Expected<unsigned> MaybeRecordType =
3463 Stream.readRecord(Entry.ID,
Record, &Blob);
3464 if (!MaybeRecordType) {
3465 Error(MaybeRecordType.takeError());
3471 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
3473 : diag::err_ast_file_version_too_new)
3478 bool hasErrors =
Record[7];
3479 if (hasErrors && !DisableValidation) {
3482 if ((ClientLoadCapabilities & ARR_TreatModuleWithErrorsAsOutOfDate) &&
3483 canRecoverFromOutOfDate(F.
FileName, ClientLoadCapabilities))
3486 if (!AllowASTWithCompilerErrors) {
3487 Diag(diag::err_ast_file_with_compiler_errors)
3493 Diags.ErrorOccurred =
true;
3494 Diags.UncompilableErrorOccurred =
true;
3495 Diags.UnrecoverableErrorOccurred =
true;
3508 StringRef ASTBranch = Blob;
3509 if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
3510 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
3511 Diag(diag::err_ast_file_different_branch)
3523 if (ASTReadResult
Result = readUnhashedControlBlockOnce())
3533 auto [ImportLoc, ImportModuleFileIndex] =
3534 ReadUntranslatedSourceLocation(
Record[Idx++]);
3536 assert(ImportModuleFileIndex == 0);
3538 StringRef ImportedName = ReadStringBlob(
Record, Idx, Blob);
3540 bool IsImportingStdCXXModule =
Record[Idx++];
3541 bool IsCXX20ModuleOrPrebuiltHeaderUnit =
Record[Idx++];
3543 off_t StoredSize = 0;
3544 time_t StoredModTime = 0;
3545 unsigned FileNameKind = 0;
3546 ASTFileSignature StoredSignature;
3547 ModuleFileName ImportedFile;
3548 std::string StoredFile;
3549 bool IgnoreImportedByNote =
false;
3558 ImportedFile = PP.getHeaderSearchInfo().getPrebuiltModuleFileName(
3559 ImportedName, !IsImportingStdCXXModule);
3561 if (IsCXX20ModuleOrPrebuiltHeaderUnit && ImportedFile.
empty()) {
3562 Diag(diag::err_failed_to_find_module_file) << ImportedName;
3566 if (!IsCXX20ModuleOrPrebuiltHeaderUnit) {
3567 StoredSize = (off_t)
Record[Idx++];
3568 StoredModTime = (time_t)
Record[Idx++];
3569 FileNameKind = (unsigned)
Record[Idx++];
3573 SignatureBytes.end());
3576 StoredFile = ReadPathBlob(BaseDirectoryAsWritten,
Record, Idx, Blob);
3577 if (ImportedFile.
empty()) {
3579 }
else if (!getDiags().isIgnored(
3580 diag::warn_module_file_mapping_mismatch,
3581 CurrentImportLoc)) {
3582 auto ImportedFileRef =
3583 PP.getFileManager().getOptionalFileRef(ImportedFile);
3584 auto StoredFileRef =
3585 PP.getFileManager().getOptionalFileRef(StoredFile);
3586 if ((ImportedFileRef && StoredFileRef) &&
3587 (*ImportedFileRef != *StoredFileRef)) {
3588 Diag(diag::warn_module_file_mapping_mismatch)
3589 << ImportedFile << StoredFile;
3590 Diag(diag::note_module_file_imported_by)
3592 IgnoreImportedByNote =
true;
3599 unsigned Capabilities = ClientLoadCapabilities;
3600 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3601 Capabilities &= ~ARR_Missing;
3604 auto Result = ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F,
3605 Loaded, StoredSize, StoredModTime,
3606 StoredSignature, Capabilities);
3613 if (IsCXX20ModuleOrPrebuiltHeaderUnit) {
3614 if (
const auto *Imported =
3615 getModuleManager().lookupByFileName(ImportedFile);
3616 Imported !=
nullptr && Imported->ModuleName != ImportedName) {
3617 Diag(diag::err_failed_to_find_module_file) << ImportedName;
3623 bool recompilingFinalized =
Result == OutOfDate &&
3624 (Capabilities & ARR_OutOfDate) &&
3627 .getInMemoryModuleCache()
3629 if (!IgnoreImportedByNote &&
3631 Diag(diag::note_module_file_imported_by)
3638 case OutOfDate:
return OutOfDate;
3640 case ConfigurationMismatch:
return ConfigurationMismatch;
3641 case HadErrors:
return HadErrors;
3660 Diag(diag::remark_module_import)
3662 << (ImportedBy ? StringRef(ImportedBy->
ModuleName) : StringRef());
3668 if (ASTReadResult
Result = readUnhashedControlBlockOnce())
3676 BaseDirectoryAsWritten = Blob;
3678 "MODULE_DIRECTORY found before MODULE_NAME");
3681 auto [MaybeM, IgnoreError] =
3682 getModuleForRelocationChecks(F,
true);
3683 if (!MaybeM.has_value())
3686 Module *M = MaybeM.value();
3698 auto BuildDir = PP.getFileManager().getOptionalDirectoryRef(Blob);
3699 if (BuildDir && (*BuildDir == M->
Directory)) {
3703 Diag(diag::remark_module_relocated)
3706 if (!canRecoverFromOutOfDate(F.
FileName, ClientLoadCapabilities))
3707 Diag(diag::err_imported_module_relocated)
3713 if (ASTReadResult
Result =
3714 ReadModuleMapFileBlock(
Record, F, ImportedBy, ClientLoadCapabilities))
3719 ReadDirectoryDependencies(
Record, F);
3724 NumUserInputs =
Record[1];
3726 (
const llvm::support::unaligned_uint64_t *)Blob.data();
3735llvm::Error ASTReader::ReadASTBlock(
ModuleFile &F,
3736 unsigned ClientLoadCapabilities) {
3737 BitstreamCursor &Stream = F.
Stream;
3739 if (llvm::Error Err = Stream.EnterSubBlock(
AST_BLOCK_ID))
3746 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
3748 return MaybeEntry.takeError();
3749 llvm::BitstreamEntry Entry = MaybeEntry.get();
3751 switch (Entry.Kind) {
3752 case llvm::BitstreamEntry::Error:
3753 return llvm::createStringError(
3754 std::errc::illegal_byte_sequence,
3755 "error at end of module block in AST file");
3756 case llvm::BitstreamEntry::EndBlock:
3762 if (ASTContext *Ctx = ContextObj) {
3763 DeclContext *DC = Ctx->getTranslationUnitDecl();
3768 return llvm::Error::success();
3769 case llvm::BitstreamEntry::SubBlock:
3777 if (llvm::Error Err = Stream.SkipBlock())
3779 if (llvm::Error Err = ReadBlockAbbrevs(
3786 if (!PP.getExternalSource())
3787 PP.setExternalSource(
this);
3789 if (llvm::Error Err = Stream.SkipBlock())
3791 if (llvm::Error Err =
3800 if (llvm::Error Err = Stream.SkipBlock()) {
3809 if (!PP.getPreprocessingRecord())
3810 PP.createPreprocessingRecord();
3811 if (!PP.getPreprocessingRecord()->getExternalSource())
3812 PP.getPreprocessingRecord()->SetExternalSource(*
this);
3816 if (llvm::Error Err = ReadSourceManagerBlock(F))
3822 if (llvm::Error Err = Stream.SkipBlock())
3824 if (llvm::Error Err =
3831 BitstreamCursor
C = Stream;
3833 if (llvm::Error Err = Stream.SkipBlock())
3837 CommentsCursors.push_back(std::make_pair(
C, &F));
3842 if (llvm::Error Err = Stream.SkipBlock())
3848 case llvm::BitstreamEntry::Record:
3856 Expected<unsigned> MaybeRecordType =
3857 Stream.readRecord(Entry.ID,
Record, &Blob);
3858 if (!MaybeRecordType)
3859 return MaybeRecordType.takeError();
3864 switch (RecordType) {
3886 switch (RecordType) {
3896 (
const llvm::support::unaligned_uint64_t *)Blob.data();
3900 GlobalSubmoduleMap.insert(
3901 std::make_pair(getTotalNumSubmodules() + 1, &F));
3912 auto ReadSubmodule = [&](
unsigned LocalID) ->
Module * {
3913 return getSubmodule(getGlobalSubmoduleID(F, LocalID));
3916 if (PP.getHeaderSearchInfo().getModuleMap().findModule(F.
ModuleName)) {
3922 ReadSubmodule(LocalID);
3936 return llvm::createStringError(
3937 std::errc::illegal_byte_sequence,
3938 "duplicate TYPE_OFFSET record in AST file");
3951 return llvm::createStringError(
3952 std::errc::illegal_byte_sequence,
3953 "duplicate DECL_OFFSET record in AST file");
3965 DeclContext *TU = ContextObj->getTranslationUnitDecl();
3966 LexicalContents Contents(
3968 static_cast<unsigned int>(Blob.size() /
sizeof(
DeclID)));
3969 TULexicalDecls.push_back(std::make_pair(&F, Contents));
3976 GlobalDeclID
ID = ReadDeclID(F,
Record, Idx);
3977 auto *
Data = (
const unsigned char*)Blob.data();
3978 PendingVisibleUpdates[
ID].push_back(UpdateData{&F,
Data});
3981 if (Decl *D = GetExistingDecl(ID))
3982 PendingUpdateRecords.push_back(
3983 PendingUpdateRecord(ID, D,
false));
3989 GlobalDeclID
ID = ReadDeclID(F,
Record, Idx);
3990 auto *
Data = (
const unsigned char *)Blob.data();
3991 PendingModuleLocalVisibleUpdates[
ID].push_back(UpdateData{&F,
Data});
3994 if (Decl *D = GetExistingDecl(ID))
3995 PendingUpdateRecords.push_back(
3996 PendingUpdateRecord(ID, D,
false));
4004 GlobalDeclID
ID = ReadDeclID(F,
Record, Idx);
4005 auto *
Data = (
const unsigned char *)Blob.data();
4006 TULocalUpdates[
ID].push_back(UpdateData{&F,
Data});
4009 if (Decl *D = GetExistingDecl(ID))
4010 PendingUpdateRecords.push_back(
4011 PendingUpdateRecord(ID, D,
false));
4017 GlobalDeclID
ID = ReadDeclID(F,
Record, Idx);
4018 auto *
Data = (
const unsigned char *)Blob.data();
4019 PendingSpecializationsUpdates[
ID].push_back(UpdateData{&F,
Data});
4022 if (Decl *D = GetExistingDecl(ID))
4023 PendingUpdateRecords.push_back(
4024 PendingUpdateRecord(ID, D,
false));
4030 GlobalDeclID
ID = ReadDeclID(F,
Record, Idx);
4031 auto *
Data = (
const unsigned char *)Blob.data();
4032 PendingPartialSpecializationsUpdates[
ID].push_back(UpdateData{&F,
Data});
4035 if (Decl *D = GetExistingDecl(ID))
4036 PendingUpdateRecords.push_back(
4037 PendingUpdateRecord(ID, D,
false));
4043 reinterpret_cast<const unsigned char *
>(Blob.data());
4049 ASTIdentifierLookupTrait(*
this, F));
4051 PP.getIdentifierTable().setExternalIdentifierLookup(
this);
4057 return llvm::createStringError(
4058 std::errc::illegal_byte_sequence,
4059 "duplicate IDENTIFIER_OFFSET record in AST file");
4065 IdentifiersLoaded.resize(IdentifiersLoaded.size()
4077 for (
unsigned I = 0, N =
Record.size(); I != N; )
4078 EagerlyDeserializedDecls.push_back(ReadDeclID(F,
Record, I));
4085 getContext().getLangOpts().BuildingPCHWithObjectFile)
4086 for (
unsigned I = 0, N =
Record.size(); I != N; )
4087 EagerlyDeserializedDecls.push_back(ReadDeclID(F,
Record, I));
4091 if (SpecialTypes.empty()) {
4092 for (
unsigned I = 0, N =
Record.size(); I != N; ++I)
4093 SpecialTypes.push_back(getGlobalTypeID(F,
Record[I]));
4100 if (SpecialTypes.size() !=
Record.size())
4101 return llvm::createStringError(std::errc::illegal_byte_sequence,
4102 "invalid special-types record");
4104 for (
unsigned I = 0, N =
Record.size(); I != N; ++I) {
4106 if (!SpecialTypes[I])
4107 SpecialTypes[I] =
ID;
4114 TotalNumStatements +=
Record[0];
4115 TotalNumMacros +=
Record[1];
4116 TotalLexicalDeclContexts +=
Record[2];
4117 TotalVisibleDeclContexts +=
Record[3];
4118 TotalModuleLocalVisibleDeclContexts +=
Record[4];
4119 TotalTULocalVisibleDeclContexts +=
Record[5];
4123 for (
unsigned I = 0, N =
Record.size(); I != N; )
4124 UnusedFileScopedDecls.push_back(ReadDeclID(F,
Record, I));
4128 for (
unsigned I = 0, N =
Record.size(); I != N; )
4129 DelegatingCtorDecls.push_back(ReadDeclID(F,
Record, I));
4133 if (
Record.size() % 3 != 0)
4134 return llvm::createStringError(std::errc::illegal_byte_sequence,
4135 "invalid weak identifiers record");
4139 WeakUndeclaredIdentifiers.clear();
4142 for (
unsigned I = 0, N =
Record.size(); I < N; ) {
4143 WeakUndeclaredIdentifiers.push_back(
4144 getGlobalIdentifierID(F,
Record[I++]));
4145 WeakUndeclaredIdentifiers.push_back(
4146 getGlobalIdentifierID(F,
Record[I++]));
4147 WeakUndeclaredIdentifiers.push_back(
4148 ReadSourceLocation(F,
Record, I).getRawEncoding());
4153 if (
Record.size() % 3 != 0)
4154 return llvm::createStringError(std::errc::illegal_byte_sequence,
4155 "invalid extname identifiers record");
4159 ExtnameUndeclaredIdentifiers.clear();
4163 for (
unsigned I = 0, N =
Record.size(); I < N; ) {
4164 ExtnameUndeclaredIdentifiers.push_back(
4165 getGlobalIdentifierID(F,
Record[I++]));
4166 ExtnameUndeclaredIdentifiers.push_back(
4167 getGlobalIdentifierID(F,
Record[I++]));
4168 ExtnameUndeclaredIdentifiers.push_back(
4169 ReadSourceLocation(F,
Record, I).getRawEncoding());
4176 unsigned LocalBaseSelectorID =
Record[1];
4182 GlobalSelectorMap.insert(std::make_pair(getTotalNumSelectors()+1, &F));
4187 std::make_pair(LocalBaseSelectorID,
4199 = ASTSelectorLookupTable::Create(
4202 ASTSelectorLookupTrait(*
this, F));
4203 TotalNumMethodPoolEntries +=
Record[1];
4208 for (
unsigned Idx = 0, N =
Record.size() - 1; Idx < N; ) {
4209 ReferencedSelectorsData.push_back(getGlobalSelectorID(F,
4211 ReferencedSelectorsData.push_back(ReadSourceLocation(F,
Record, Idx).
4220 PP.setPreambleRecordedPragmaAssumeNonNullLoc(
4221 ReadSourceLocation(F,
Record, Idx));
4227 SmallVector<SourceLocation, 64> SrcLocs;
4229 while (Idx <
Record.size())
4230 SrcLocs.push_back(ReadSourceLocation(F,
Record, Idx));
4231 PP.setDeserializedSafeBufferOptOutMap(SrcLocs);
4238 unsigned Idx = 0, End =
Record.size() - 1;
4239 bool ReachedEOFWhileSkipping =
Record[Idx++];
4240 std::optional<Preprocessor::PreambleSkipInfo> SkipInfo;
4241 if (ReachedEOFWhileSkipping) {
4242 SourceLocation HashToken = ReadSourceLocation(F,
Record, Idx);
4243 SourceLocation IfTokenLoc = ReadSourceLocation(F,
Record, Idx);
4244 bool FoundNonSkipPortion =
Record[Idx++];
4245 bool FoundElse =
Record[Idx++];
4246 SourceLocation ElseLoc = ReadSourceLocation(F,
Record, Idx);
4247 SkipInfo.emplace(HashToken, IfTokenLoc, FoundNonSkipPortion,
4248 FoundElse, ElseLoc);
4250 SmallVector<PPConditionalInfo, 4> ConditionalStack;
4252 auto Loc = ReadSourceLocation(F,
Record, Idx);
4253 bool WasSkipping =
Record[Idx++];
4254 bool FoundNonSkip =
Record[Idx++];
4255 bool FoundElse =
Record[Idx++];
4256 ConditionalStack.push_back(
4257 {Loc, WasSkipping, FoundNonSkip, FoundElse});
4259 PP.setReplayablePreambleConditionalStack(ConditionalStack, SkipInfo);
4264 if (!
Record.empty() && Listener)
4282 Diags.Report(SourceLocation(), diag::remark_sloc_usage);
4283 SourceMgr.noteSLocAddressSpaceUsage(Diags);
4284 return llvm::createStringError(std::errc::invalid_argument,
4285 "ran out of source locations");
4290 unsigned RangeStart =
4292 GlobalSLocEntryMap.insert(std::make_pair(RangeStart, &F));
4297 GlobalSLocOffsetMap.insert(
4299 - SLocSpaceSize,&F));
4310 ParseLineTable(F,
Record);
4314 for (
unsigned I = 0, N =
Record.size(); I != N; )
4315 ExtVectorDecls.push_back(ReadDeclID(F,
Record, I));
4319 if (
Record.size() % 3 != 0)
4320 return llvm::createStringError(std::errc::illegal_byte_sequence,
4321 "Invalid VTABLE_USES record");
4328 for (
unsigned Idx = 0, N =
Record.size(); Idx != N; ) {
4329 VTableUses.push_back(
4330 {ReadDeclID(F,
Record, Idx),
4331 ReadSourceLocation(F,
Record, Idx).getRawEncoding(),
4338 if (
Record.size() % 2 != 0)
4339 return llvm::createStringError(
4340 std::errc::illegal_byte_sequence,
4341 "Invalid PENDING_IMPLICIT_INSTANTIATIONS block");
4346 for (
unsigned I = 0, N =
Record.size(); I != N; ) {
4347 PendingInstantiations.push_back(
4348 {ReadDeclID(F,
Record, I),
4349 ReadSourceLocation(F,
Record, I).getRawEncoding()});
4356 return llvm::createStringError(std::errc::illegal_byte_sequence,
4357 "Invalid SEMA_DECL_REFS block");
4358 for (
unsigned I = 0, N =
Record.size(); I != N; )
4359 SemaDeclRefs.push_back(ReadDeclID(F,
Record, I));
4367 unsigned StartingID;
4368 if (!PP.getPreprocessingRecord())
4369 PP.createPreprocessingRecord();
4370 if (!PP.getPreprocessingRecord()->getExternalSource())
4371 PP.getPreprocessingRecord()->SetExternalSource(*
this);
4373 = PP.getPreprocessingRecord()
4380 GlobalPreprocessedEntityMap.insert(std::make_pair(StartingID, &F));
4391 if (!PP.getPreprocessingRecord())
4392 PP.createPreprocessingRecord();
4393 if (!PP.getPreprocessingRecord()->getExternalSource())
4394 PP.getPreprocessingRecord()->SetExternalSource(*
this);
4399 GlobalSkippedRangeMap.insert(
4405 if (
Record.size() % 2 != 0)
4406 return llvm::createStringError(
4407 std::errc::illegal_byte_sequence,
4408 "invalid DECL_UPDATE_OFFSETS block in AST file");
4409 for (
unsigned I = 0, N =
Record.size(); I != N; ) {
4410 GlobalDeclID
ID = ReadDeclID(F,
Record, I);
4411 DeclUpdateOffsets[
ID].push_back(std::make_pair(&F,
Record[I++]));
4415 if (Decl *D = GetExistingDecl(ID))
4416 PendingUpdateRecords.push_back(
4417 PendingUpdateRecord(ID, D,
false));
4422 if (
Record.size() % 5 != 0)
4423 return llvm::createStringError(
4424 std::errc::illegal_byte_sequence,
4425 "invalid DELAYED_NAMESPACE_LEXICAL_VISIBLE_RECORD block in AST "
4427 for (
unsigned I = 0, N =
Record.size(); I != N; ) {
4428 GlobalDeclID
ID = ReadDeclID(F,
Record, I);
4431 assert(BaseOffset &&
"Invalid DeclsBlockStartOffset for module file!");
4434 LocalLexicalOffset ? BaseOffset + LocalLexicalOffset : 0;
4437 LocalVisibleOffset ? BaseOffset + LocalVisibleOffset : 0;
4440 LocalModuleLocalOffset ? BaseOffset + LocalModuleLocalOffset : 0;
4443 TULocalLocalOffset ? BaseOffset + TULocalLocalOffset : 0;
4445 DelayedNamespaceOffsetMap[
ID] = {
4446 {VisibleOffset, ModuleLocalOffset, TULocalOffset}, LexicalOffset};
4448 assert(!GetExistingDecl(ID) &&
4449 "We shouldn't load the namespace in the front of delayed "
4450 "namespace lexical and visible block");
4456 for (
unsigned I = 0, N =
Record.size(); I != N; ) {
4457 GlobalDeclID
ID = ReadDeclID(F,
Record, I);
4458 auto &RelatedDecls = RelatedDeclsMap[
ID];
4459 unsigned NN =
Record[I++];
4460 RelatedDecls.reserve(NN);
4461 for (
unsigned II = 0; II < NN; II++)
4462 RelatedDecls.push_back(ReadDeclID(F,
Record, I));
4468 return llvm::createStringError(
4469 std::errc::illegal_byte_sequence,
4470 "duplicate OBJC_CATEGORIES_MAP record in AST file");
4483 CUDASpecialDeclRefs.clear();
4484 for (
unsigned I = 0, N =
Record.size(); I != N; )
4485 CUDASpecialDeclRefs.push_back(ReadDeclID(F,
Record, I));
4495 HeaderFileInfoTrait(*
this, F));
4497 PP.getHeaderSearchInfo().SetExternalSource(
this);
4498 if (!PP.getHeaderSearchInfo().getExternalLookup())
4499 PP.getHeaderSearchInfo().SetExternalLookup(
this);
4505 FPPragmaOptions.swap(
Record);
4509 for (
unsigned I = 0, N =
Record.size(); I != N; )
4510 DeclsWithEffectsToVerify.push_back(ReadDeclID(F,
Record, I));
4514 for (
unsigned I = 0, N =
Record.size(); I != N; )
4515 OpenMPRequiresDecls.push_back(ReadDeclID(F,
Record, I));
4519 for (
unsigned I = 0, E =
Record.size(); I != E; ) {
4520 auto Name = ReadString(
Record, I);
4521 auto &OptInfo = OpenCLExtensions.OptMap[Name];
4522 OptInfo.Supported =
Record[I++] != 0;
4523 OptInfo.Enabled =
Record[I++] != 0;
4524 OptInfo.WithPragma =
Record[I++] != 0;
4525 OptInfo.Avail =
Record[I++];
4526 OptInfo.Core =
Record[I++];
4527 OptInfo.Opt =
Record[I++];
4532 for (
unsigned I = 0, N =
Record.size(); I != N; )
4533 TentativeDefinitions.push_back(ReadDeclID(F,
Record, I));
4537 for (
unsigned I = 0, N =
Record.size(); I != N; )
4538 KnownNamespaces.push_back(ReadDeclID(F,
Record, I));
4542 if (
Record.size() % 2 != 0)
4543 return llvm::createStringError(std::errc::illegal_byte_sequence,
4544 "invalid undefined-but-used record");
4545 for (
unsigned I = 0, N =
Record.size(); I != N; ) {
4546 UndefinedButUsed.push_back(
4547 {ReadDeclID(F,
Record, I),
4548 ReadSourceLocation(F,
Record, I).getRawEncoding()});
4553 for (
unsigned I = 0, N =
Record.size(); I != N;) {
4554 DelayedDeleteExprs.push_back(ReadDeclID(F,
Record, I).getRawValue());
4556 DelayedDeleteExprs.push_back(Count);
4557 for (uint64_t
C = 0;
C < Count; ++
C) {
4558 DelayedDeleteExprs.push_back(ReadSourceLocation(F,
Record, I).getRawEncoding());
4559 bool IsArrayForm =
Record[I++] == 1;
4560 DelayedDeleteExprs.push_back(IsArrayForm);
4567 getContext().getLangOpts().BuildingPCHWithObjectFile)
4568 for (
unsigned I = 0, N =
Record.size(); I != N;)
4569 VTablesToEmit.push_back(ReadDeclID(F,
Record, I));
4577 for (
unsigned I = 0, N =
Record.size(); I != N; ) {
4578 unsigned GlobalID = getGlobalSubmoduleID(F,
Record[I++]);
4579 SourceLocation Loc = ReadSourceLocation(F,
Record, I);
4581 PendingImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
4582 if (DeserializationListener)
4583 DeserializationListener->ModuleImportRead(GlobalID, Loc);
4591 return llvm::createStringError(
4592 std::errc::illegal_byte_sequence,
4593 "duplicate MACRO_OFFSET record in AST file");
4605 LateParsedTemplates.emplace_back(
4606 std::piecewise_construct, std::forward_as_tuple(&F),
4612 return llvm::createStringError(std::errc::illegal_byte_sequence,
4613 "invalid pragma optimize record");
4614 OptimizeOffPragmaLocation = ReadSourceLocation(F,
Record[0]);
4619 return llvm::createStringError(std::errc::illegal_byte_sequence,
4620 "invalid pragma ms_struct record");
4621 PragmaMSStructState =
Record[0];
4626 return llvm::createStringError(
4627 std::errc::illegal_byte_sequence,
4628 "invalid pragma pointers to members record");
4629 PragmaMSPointersToMembersState =
Record[0];
4630 PointersToMembersPragmaLocation = ReadSourceLocation(F,
Record[1]);
4634 for (
unsigned I = 0, N =
Record.size(); I != N; )
4635 UnusedLocalTypedefNameCandidates.push_back(ReadDeclID(F,
Record, I));
4640 return llvm::createStringError(std::errc::illegal_byte_sequence,
4641 "invalid cuda pragma options record");
4642 ForceHostDeviceDepth =
Record[0];
4647 return llvm::createStringError(std::errc::illegal_byte_sequence,
4648 "invalid pragma pack record");
4649 PragmaAlignPackCurrentValue = ReadAlignPackInfo(
Record[0]);
4650 PragmaAlignPackCurrentLocation = ReadSourceLocation(F,
Record[1]);
4651 unsigned NumStackEntries =
Record[2];
4654 PragmaAlignPackStack.clear();
4655 for (
unsigned I = 0; I < NumStackEntries; ++I) {
4656 PragmaAlignPackStackEntry Entry;
4657 Entry.Value = ReadAlignPackInfo(
Record[Idx++]);
4658 Entry.Location = ReadSourceLocation(F,
Record[Idx++]);
4659 Entry.PushLocation = ReadSourceLocation(F,
Record[Idx++]);
4660 PragmaAlignPackStrings.push_back(ReadString(
Record, Idx));
4661 Entry.SlotLabel = PragmaAlignPackStrings.back();
4662 PragmaAlignPackStack.push_back(Entry);
4669 return llvm::createStringError(std::errc::illegal_byte_sequence,
4670 "invalid pragma float control record");
4672 FpPragmaCurrentLocation = ReadSourceLocation(F,
Record[1]);
4673 unsigned NumStackEntries =
Record[2];
4676 FpPragmaStack.clear();
4677 for (
unsigned I = 0; I < NumStackEntries; ++I) {
4678 FpPragmaStackEntry Entry;
4680 Entry.Location = ReadSourceLocation(F,
Record[Idx++]);
4681 Entry.PushLocation = ReadSourceLocation(F,
Record[Idx++]);
4682 FpPragmaStrings.push_back(ReadString(
Record, Idx));
4683 Entry.SlotLabel = FpPragmaStrings.back();
4684 FpPragmaStack.push_back(Entry);
4690 for (
unsigned I = 0, N =
Record.size(); I != N; )
4691 DeclsToCheckForDeferredDiags.insert(ReadDeclID(F,
Record, I));
4695 unsigned NumRecords =
Record.front();
4697 if (
Record.size() - 1 != NumRecords)
4698 return llvm::createStringError(std::errc::illegal_byte_sequence,
4699 "invalid rvv intrinsic pragma record");
4701 if (RISCVVecIntrinsicPragma.empty())
4702 RISCVVecIntrinsicPragma.append(NumRecords, 0);
4705 for (
unsigned i = 0; i < NumRecords; ++i)
4706 RISCVVecIntrinsicPragma[i] |=
Record[i + 1];
4713void ASTReader::ReadModuleOffsetMap(
ModuleFile &F)
const {
4726 assert(ImportedModuleVector.empty());
4728 while (
Data < DataEnd) {
4732 using namespace llvm::support;
4734 endian::readNext<uint8_t, llvm::endianness::little>(
Data));
4735 uint16_t Len = endian::readNext<uint16_t, llvm::endianness::little>(
Data);
4736 StringRef Name = StringRef((
const char*)
Data, Len);
4741 ? ModuleMgr.lookupByModuleName(Name)
4746 std::string Msg =
"refers to unknown module, cannot find ";
4747 Msg.append(std::string(Name));
4752 ImportedModuleVector.push_back(OM);
4755 endian::readNext<uint32_t, llvm::endianness::little>(
Data);
4757 endian::readNext<uint32_t, llvm::endianness::little>(
Data);
4760 RemapBuilder &Remap) {
4761 constexpr uint32_t None = std::numeric_limits<uint32_t>::max();
4763 Remap.insert(std::make_pair(Offset,
4764 static_cast<int>(BaseOffset - Offset)));
4775 unsigned ClientLoadCapabilities) {
4784 "MODULE_NAME should come before MODULE_MAP_FILE");
4785 auto [MaybeM, IgnoreError] =
4786 getModuleForRelocationChecks(F,
false);
4787 if (MaybeM.has_value()) {
4790 Module *M = MaybeM.value();
4791 auto &Map = PP.getHeaderSearchInfo().getModuleMap();
4793 M ? Map.getModuleMapFileForUniquing(M) : std::nullopt;
4794 if (!IgnoreError && !ModMap) {
4796 Diag(diag::remark_module_relocated)
4799 if (!canRecoverFromOutOfDate(F.
FileName, ClientLoadCapabilities)) {
4802 Diag(diag::err_module_file_conflict)
4807 Diag(diag::err_imported_module_not_found)
4814 if (ImportedBy && ImportedBy->
Kind ==
MK_PCH)
4815 Diag(diag::note_imported_by_pch_module_not_found)
4822 assert(M && M->
Name == F.
ModuleName &&
"found module with different name");
4826 if (!StoredModMap || *StoredModMap != ModMap) {
4827 assert(ModMap &&
"found module is missing module map file");
4829 "top-level import should be verified");
4831 if (!canRecoverFromOutOfDate(F.
FileName, ClientLoadCapabilities))
4832 Diag(diag::err_imported_module_modmap_changed)
4839 for (
unsigned I = 0, N =
Record[Idx++]; I < N; ++I) {
4841 std::string Filename = ReadPath(F,
Record, Idx);
4844 if (!canRecoverFromOutOfDate(F.
FileName, ClientLoadCapabilities))
4845 Error(
"could not find file '" + Filename +
"' referenced by AST file");
4848 AdditionalStoredMaps.insert(*SF);
4853 if (
auto *AdditionalModuleMaps = Map.getAdditionalModuleMapFiles(M)) {
4854 for (FileEntryRef ModMap : *AdditionalModuleMaps) {
4857 if (!AdditionalStoredMaps.erase(ModMap)) {
4858 if (!canRecoverFromOutOfDate(F.
FileName, ClientLoadCapabilities))
4859 Diag(diag::err_module_different_modmap)
4868 for (FileEntryRef ModMap : AdditionalStoredMaps) {
4869 if (!canRecoverFromOutOfDate(F.
FileName, ClientLoadCapabilities))
4870 Diag(diag::err_module_different_modmap)
4881void ASTReader::ReadDirectoryDependencies(
const RecordData &
Record,
4884 unsigned N =
Record[Idx++];
4886 for (
unsigned I = 0; I != N; ++I) {
4889 SmallString<256> Dir(ReadPath(F,
Record, Idx));
4895bool ASTReader::isDirectoryDependencyOutOfDate(
ModuleFile &F,
bool Complain) {
4896 llvm::vfs::FileSystem &FS = PP.getFileManager().getVirtualFileSystem();
4901 auto IsNewer = [&](StringRef Dir) {
4902 llvm::ErrorOr<llvm::vfs::Status> Status = FS.status(Dir);
4903 return Status && Status->isDirectory() &&
4904 llvm::sys::toTimeT(Status->getLastModificationTime()) > F.
ModTime;
4907 ModuleCache &ModCache = getModuleManager().getModuleCache();
4908 const HeaderSearchOptions &HSOpts =
4909 PP.getHeaderSearchInfo().getHeaderSearchOpts();
4911 if (std::optional<bool> Invalidated =
4915 if (!*Invalidated ||
4918 Diag(diag::remark_module_path_invalidated) << F.
ModuleName << Dir;
4924 std::optional<std::string>
Changed;
4929 for (llvm::vfs::recursive_directory_iterator I(FS, Dir, EC), E;
4930 I != E && !EC; I.increment(EC)) {
4931 if (I->type() == llvm::sys::fs::file_type::directory_file &&
4932 IsNewer(I->path())) {
4951 SemaObjC::GlobalMethodPool::iterator
Known =
4958 :
Known->second.second;
4962 if (List->getMethod() == Method) {
4970 if (List->getNext())
4971 List->setMethod(List->getNext()->getMethod());
4973 List->setMethod(Method);
4979 for (
Decl *D : Names) {
4983 if (wasHidden && SemaObj) {
4996 Stack.push_back(Mod);
4997 while (!Stack.empty()) {
4998 Mod = Stack.pop_back_val();
5000 if (NameVisibility <= Mod->NameVisibility) {
5016 HiddenNamesMapType::iterator Hidden = HiddenNamesMap.find(Mod);
5017 if (Hidden != HiddenNamesMap.end()) {
5018 auto HiddenNames = std::move(*Hidden);
5019 HiddenNamesMap.erase(Hidden);
5021 assert(!HiddenNamesMap.contains(Mod) &&
5022 "making names visible added hidden names");
5029 I = Exports.begin(), E = Exports.end(); I != E; ++I) {
5031 if (Visited.insert(Exported).second)
5032 Stack.push_back(Exported);
5050 PendingMergedDefinitionsToDeduplicate.insert(Def);
5059 if (TriedLoadingGlobalIndex || !UseGlobalIndex ||
5060 !PP.getLangOpts().Modules)
5064 TriedLoadingGlobalIndex =
true;
5065 StringRef SpecificModuleCachePath =
5067 std::pair<GlobalModuleIndex *, llvm::Error>
Result =
5069 if (llvm::Error Err = std::move(
Result.second)) {
5071 consumeError(std::move(Err));
5075 GlobalIndex.reset(
Result.first);
5076 ModuleMgr.setGlobalIndex(GlobalIndex.get());
5081 return PP.getLangOpts().Modules && UseGlobalIndex &&
5093 consumeError(MaybeEntry.takeError());
5096 llvm::BitstreamEntry Entry = MaybeEntry.get();
5098 switch (Entry.Kind) {
5099 case llvm::BitstreamEntry::Error:
5100 case llvm::BitstreamEntry::EndBlock:
5103 case llvm::BitstreamEntry::Record:
5109 consumeError(Skipped.takeError());
5113 case llvm::BitstreamEntry::SubBlock:
5114 if (Entry.ID == BlockID) {
5115 if (llvm::Error Err = Cursor.EnterSubBlock(BlockID)) {
5117 consumeError(std::move(Err));
5124 if (llvm::Error Err = Cursor.SkipBlock()) {
5126 consumeError(std::move(Err));
5136 unsigned ClientLoadCapabilities,
5138 llvm::TimeTraceScope scope(
"ReadAST",
FileName);
5142 CurrentDeserializingModuleKind,
Type);
5148 unsigned PreviousGeneration = 0;
5152 unsigned NumModules = ModuleMgr.size();
5157 ClientLoadCapabilities)) {
5158 ModuleMgr.removeModules(ModuleMgr.begin() + NumModules);
5162 GlobalIndex.reset();
5163 ModuleMgr.setGlobalIndex(
nullptr);
5167 if (NewLoadedModuleFile && !Loaded.empty())
5168 *NewLoadedModuleFile = Loaded.back().Mod;
5181 llvm::TimeTraceScope Scope2(
"Read Loaded AST", F.
ModuleName);
5184 if (llvm::Error Err = ReadASTBlock(F, ClientLoadCapabilities)) {
5185 Error(std::move(Err));
5191 Error(diag::err_module_file_missing_top_level_submodule, F.
FileName);
5197 if (llvm::Error Err = ReadExtensionBlock(F)) {
5198 Error(std::move(Err));
5227 if (!PP.getLangOpts().CPlusPlus) {
5234 auto It = PP.getIdentifierTable().find(Key);
5235 if (It == PP.getIdentifierTable().end())
5244 II = &PP.getIdentifierTable().getOwn(Key);
5262 for (
auto &Id : PP.getIdentifierTable())
5263 Id.second->setOutOfDate(
true);
5266 for (
const auto &Sel : SelectorGeneration)
5267 SelectorOutOfDate[Sel.first] =
true;
5274 ModuleMgr.moduleFileAccepted(&F);
5296 if (DeserializationListener)
5297 DeserializationListener->ReaderInitialized(
this);
5299 ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule();
5314 for (
unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++I) {
5315 loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
5316 ObjCClassesLoaded[I], PreviousGeneration);
5321 PP.getHeaderSearchInfo().getHeaderSearchOpts();
5326 for (
unsigned I = 0, N = Loaded.size(); I != N; ++I) {
5345 if (!Stream.canSkipToPos(4))
5346 return llvm::createStringError(
5347 std::errc::illegal_byte_sequence,
5348 "file too small to contain precompiled file magic");
5349 for (
unsigned C : {
'C',
'P',
'C',
'H'})
5352 return llvm::createStringError(
5353 std::errc::illegal_byte_sequence,
5354 "file doesn't start with precompiled file magic");
5356 return Res.takeError();
5357 return llvm::Error::success();
5372 llvm_unreachable(
"unknown module kind");
5378 off_t ExpectedSize, time_t ExpectedModTime,
5380 auto Result = ModuleMgr.addModule(
5385 switch (
Result.getKind()) {
5387 Diag(diag::remark_module_import)
5389 << (ImportedBy ? StringRef(ImportedBy->
ModuleName) : StringRef());
5404 Diag(diag::err_ast_file_not_found)
5406 if (!
Result.getBufferError().empty())
5407 Diag(diag::note_ast_file_buffer_failed) <<
Result.getBufferError();
5417 Diag(diag::err_ast_file_out_of_date)
5419 for (
const auto &
C :
Result.getChanges()) {
5420 Diag(diag::note_fe_ast_file_modified)
5421 <<
C.Kind << (
C.Old &&
C.New) << llvm::itostr(
C.Old.value_or(0))
5422 << llvm::itostr(
C.New.value_or(0));
5424 Diag(diag::note_ast_file_input_files_validation_status)
5425 <<
Result.getValidationStatus();
5426 if (!
Result.getSignatureError().empty())
5427 Diag(diag::note_ast_file_signature_failed) <<
Result.getSignatureError();
5431 llvm_unreachable(
"Unexpected value from adding module.");
5434 assert(M &&
"Missing module file");
5436 bool ShouldFinalizePCM =
false;
5437 llvm::scope_exit FinalizeOrDropPCM([&]() {
5439 if (ShouldFinalizePCM)
5445 BitstreamCursor &Stream = F.
Stream;
5446 Stream = BitstreamCursor(PCHContainerRdr.ExtractPCH(*F.Buffer));
5447 F.SizeInBits = F.Buffer->getBufferSize() * 8;
5451 Diag(diag::err_ast_file_invalid)
5457 bool HaveReadControlBlock =
false;
5461 Error(MaybeEntry.takeError());
5464 llvm::BitstreamEntry Entry = MaybeEntry.get();
5466 switch (Entry.Kind) {
5467 case llvm::BitstreamEntry::Error:
5468 case llvm::BitstreamEntry::Record:
5469 case llvm::BitstreamEntry::EndBlock:
5470 Error(
"invalid record at top-level of AST file");
5473 case llvm::BitstreamEntry::SubBlock:
5479 HaveReadControlBlock =
true;
5480 switch (ReadControlBlock(F, Loaded, ImportedBy, ClientLoadCapabilities)) {
5488 F.ModuleName.empty()) {
5507 if (!HaveReadControlBlock) {
5509 Diag(diag::err_ast_file_version_too_old)
5516 ShouldFinalizePCM =
true;
5520 if (llvm::Error Err = Stream.SkipBlock()) {
5521 Error(std::move(Err));
5528 llvm_unreachable(
"unexpected break; expected return");
5532ASTReader::readUnhashedControlBlock(
ModuleFile &F,
bool WasImportedBy,
5533 unsigned ClientLoadCapabilities) {
5535 PP.getHeaderSearchInfo().getHeaderSearchOpts();
5536 bool AllowCompatibleConfigurationMismatch =
5538 bool DisableValidation = shouldDisableValidationForFile(F);
5540 ASTReadResult
Result = readUnhashedControlBlockImpl(
5542 AllowCompatibleConfigurationMismatch, Listener.get(),
5547 if (DisableValidation || WasImportedBy ||
5548 (AllowConfigurationMismatch &&
Result == ConfigurationMismatch))
5552 Error(
"malformed block record in AST file");
5575 if (getModuleManager().getModuleCache().getInMemoryModuleCache().isPCMFinal(
5577 Diag(diag::warn_module_system_bit_conflict) << F.
FileName;
5586 ModuleFile *F, llvm::StringRef StreamData, StringRef Filename,
5587 unsigned ClientLoadCapabilities,
bool AllowCompatibleConfigurationMismatch,
5588 ASTReaderListener *Listener,
bool ValidateDiagnosticOptions) {
5590 BitstreamCursor Stream(StreamData);
5595 consumeError(std::move(Err));
5607 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
5610 consumeError(MaybeEntry.takeError());
5613 llvm::BitstreamEntry Entry = MaybeEntry.get();
5615 switch (Entry.Kind) {
5616 case llvm::BitstreamEntry::Error:
5617 case llvm::BitstreamEntry::SubBlock:
5620 case llvm::BitstreamEntry::EndBlock:
5623 case llvm::BitstreamEntry::Record:
5631 Expected<unsigned> MaybeRecordType =
5632 Stream.readRecord(Entry.ID,
Record, &Blob);
5633 if (!MaybeRecordType) {
5642 "Dummy AST file signature not backpatched in ASTWriter.");
5649 "Dummy AST block hash not backpatched in ASTWriter.");
5653 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
5654 if (Listener && ValidateDiagnosticOptions &&
5655 !AllowCompatibleConfigurationMismatch &&
5656 ParseDiagnosticOptions(
Record, Filename, Complain, *Listener))
5661 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
5662 if (Listener && !AllowCompatibleConfigurationMismatch &&
5663 ParseHeaderSearchPaths(
Record, Complain, *Listener))
5664 Result = ConfigurationMismatch;
5693 if (
Record.size() < 4)
return true;
5698 unsigned BlockNameLen =
Record[2];
5699 unsigned UserInfoLen =
Record[3];
5701 if (BlockNameLen + UserInfoLen > Blob.size())
return true;
5703 Metadata.
BlockName = std::string(Blob.data(), Blob.data() + BlockNameLen);
5704 Metadata.
UserInfo = std::string(Blob.data() + BlockNameLen,
5705 Blob.data() + BlockNameLen + UserInfoLen);
5709llvm::Error ASTReader::ReadExtensionBlock(
ModuleFile &F) {
5710 BitstreamCursor &Stream = F.
Stream;
5714 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
5716 return MaybeEntry.takeError();
5717 llvm::BitstreamEntry Entry = MaybeEntry.get();
5719 switch (Entry.Kind) {
5720 case llvm::BitstreamEntry::SubBlock:
5721 if (llvm::Error Err = Stream.SkipBlock())
5724 case llvm::BitstreamEntry::EndBlock:
5725 return llvm::Error::success();
5726 case llvm::BitstreamEntry::Error:
5727 return llvm::createStringError(std::errc::illegal_byte_sequence,
5728 "malformed block record in AST file");
5729 case llvm::BitstreamEntry::Record:
5735 Expected<unsigned> MaybeRecCode =
5736 Stream.readRecord(Entry.ID,
Record, &Blob);
5738 return MaybeRecCode.takeError();
5739 switch (MaybeRecCode.get()) {
5741 ModuleFileExtensionMetadata Metadata;
5743 return llvm::createStringError(
5744 std::errc::illegal_byte_sequence,
5745 "malformed EXTENSION_METADATA in AST file");
5749 if (
Known == ModuleFileExtensions.end())
break;
5752 if (
auto Reader =
Known->second->createExtensionReader(Metadata, *
this,
5762 llvm_unreachable(
"ReadExtensionBlock should return from while loop");
5766 assert(ContextObj &&
"no context to initialize");
5770 if (DeserializationListener)
5771 DeserializationListener->DeclRead(
5773 Context.getTranslationUnitDecl());
5781 if (!Context.CFConstantStringTypeDecl)
5782 Context.setCFConstantStringType(
GetType(String));
5787 if (FileType.isNull()) {
5788 Error(
"FILE type is NULL");
5792 if (!Context.FILEDecl) {
5794 Context.setFILEDecl(
Typedef->getDecl());
5796 const TagType *Tag = FileType->getAs<TagType>();
5798 Error(
"Invalid FILE type in AST file");
5801 Context.setFILEDecl(Tag->getDecl());
5808 if (Jmp_bufType.
isNull()) {
5809 Error(
"jmp_buf type is NULL");
5813 if (!Context.jmp_bufDecl) {
5815 Context.setjmp_bufDecl(
Typedef->getDecl());
5817 const TagType *Tag = Jmp_bufType->
getAs<TagType>();
5819 Error(
"Invalid jmp_buf type in AST file");
5822 Context.setjmp_bufDecl(Tag->getDecl());
5829 if (Sigjmp_bufType.
isNull()) {
5830 Error(
"sigjmp_buf type is NULL");
5834 if (!Context.sigjmp_bufDecl) {
5836 Context.setsigjmp_bufDecl(
Typedef->getDecl());
5838 const TagType *Tag = Sigjmp_bufType->
getAs<TagType>();
5839 assert(Tag &&
"Invalid sigjmp_buf type in AST file");
5840 Context.setsigjmp_bufDecl(Tag->getDecl());
5846 if (Context.ObjCIdRedefinitionType.isNull())
5847 Context.ObjCIdRedefinitionType =
GetType(ObjCIdRedef);
5850 if (
TypeID ObjCClassRedef =
5852 if (Context.ObjCClassRedefinitionType.isNull())
5853 Context.ObjCClassRedefinitionType =
GetType(ObjCClassRedef);
5856 if (
TypeID ObjCSelRedef =
5858 if (Context.ObjCSelRedefinitionType.isNull())
5859 Context.ObjCSelRedefinitionType =
GetType(ObjCSelRedef);
5864 if (Ucontext_tType.
isNull()) {
5865 Error(
"ucontext_t type is NULL");
5869 if (!Context.ucontext_tDecl) {
5871 Context.setucontext_tDecl(
Typedef->getDecl());
5873 const TagType *Tag = Ucontext_tType->
getAs<TagType>();
5874 assert(Tag &&
"Invalid ucontext_t type in AST file");
5875 Context.setucontext_tDecl(Tag->getDecl());
5884 if (!CUDASpecialDeclRefs.empty()) {
5885 assert(CUDASpecialDeclRefs.size() == 3 &&
"More decl refs than expected!");
5886 Context.setcudaConfigureCallDecl(
5887 cast_or_null<FunctionDecl>(
GetDecl(CUDASpecialDeclRefs[0])));
5888 Context.setcudaGetParameterBufferDecl(
5889 cast_or_null<FunctionDecl>(
GetDecl(CUDASpecialDeclRefs[1])));
5890 Context.setcudaLaunchDeviceDecl(
5891 cast_or_null<FunctionDecl>(
GetDecl(CUDASpecialDeclRefs[2])));
5896 for (
auto &Import : PendingImportedModules) {
5900 if (Import.ImportLoc.isValid())
5901 PP.makeModuleVisible(Imported, Import.ImportLoc);
5908 PendingImportedModulesSema.append(PendingImportedModules);
5909 PendingImportedModules.clear();
5919 BitstreamCursor Stream(
PCH);
5922 consumeError(std::move(Err));
5934 Stream.advanceSkippingSubblocks();
5937 consumeError(MaybeEntry.takeError());
5940 llvm::BitstreamEntry Entry = MaybeEntry.get();
5942 if (Entry.Kind != llvm::BitstreamEntry::Record)
5950 consumeError(MaybeRecord.takeError());
5956 "Dummy AST file signature not backpatched in ASTWriter.");
5966 const std::string &ASTFileName,
FileManager &FileMgr,
5969 auto Buffer = FileMgr.getBufferForFile(ASTFileName,
false,
5974 Diags.Report(diag::err_fe_unable_to_read_pch_file)
5975 << ASTFileName << Buffer.getError().message();
5976 return std::string();
5980 BitstreamCursor Stream(PCHContainerRdr.ExtractPCH(**Buffer));
5984 Diags.Report(diag::err_fe_not_a_pch_file) << ASTFileName << std::move(Err);
5985 return std::string();
5990 Diags.Report(diag::err_fe_pch_malformed_block) << ASTFileName;
5991 return std::string();
5998 Stream.advanceSkippingSubblocks();
6001 consumeError(MaybeEntry.takeError());
6002 return std::string();
6004 llvm::BitstreamEntry Entry = MaybeEntry.get();
6006 if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
6007 return std::string();
6009 if (Entry.Kind != llvm::BitstreamEntry::Record) {
6010 Diags.Report(diag::err_fe_pch_malformed_block) << ASTFileName;
6011 return std::string();
6019 consumeError(MaybeRecord.takeError());
6020 return std::string();
6035 std::string ExistingSpecificModuleCachePath;
6037 bool StrictOptionMatches;
6040 SimplePCHValidator(
const LangOptions &ExistingLangOpts,
6045 StringRef ExistingSpecificModuleCachePath,
6047 : ExistingLangOpts(ExistingLangOpts), ExistingCGOpts(ExistingCGOpts),
6048 ExistingTargetOpts(ExistingTargetOpts),
6049 ExistingPPOpts(ExistingPPOpts), ExistingHSOpts(ExistingHSOpts),
6050 ExistingSpecificModuleCachePath(ExistingSpecificModuleCachePath),
6053 bool ReadLanguageOptions(
const LangOptions &LangOpts,
6054 StringRef ModuleFilename,
bool Complain,
6055 bool AllowCompatibleDifferences)
override {
6057 nullptr, AllowCompatibleDifferences);
6060 bool ReadCodeGenOptions(
const CodeGenOptions &CGOpts,
6061 StringRef ModuleFilename,
bool Complain,
6062 bool AllowCompatibleDifferences)
override {
6064 nullptr, AllowCompatibleDifferences);
6067 bool ReadTargetOptions(
const TargetOptions &TargetOpts,
6068 StringRef ModuleFilename,
bool Complain,
6069 bool AllowCompatibleDifferences)
override {
6071 nullptr, AllowCompatibleDifferences);
6074 bool ReadHeaderSearchOptions(
const HeaderSearchOptions &HSOpts,
6075 StringRef ASTFilename, StringRef ContextHash,
6076 bool Complain)
override {
6078 FileMgr, ContextHash, ExistingSpecificModuleCachePath, ASTFilename,
6079 nullptr, ExistingLangOpts, ExistingPPOpts, ExistingHSOpts, HSOpts);
6082 bool ReadPreprocessorOptions(
const PreprocessorOptions &PPOpts,
6083 StringRef ModuleFilename,
bool ReadMacros,
6085 std::string &SuggestedPredefines)
override {
6087 PPOpts, ExistingPPOpts, ModuleFilename, ReadMacros,
nullptr,
6088 FileMgr, SuggestedPredefines, ExistingLangOpts,
6100 unsigned ClientLoadCapabilities) {
6104 std::unique_ptr<llvm::MemoryBuffer> OwnedBuffer;
6105 llvm::MemoryBuffer *Buffer =
6114 auto Entry = Filename ==
"-" ? FileMgr.getSTDIN()
6115 : FileMgr.getFileRef(Filename,
6120 llvm::consumeError(Entry.takeError());
6124 FileMgr.getBufferForFile(*Entry,
6131 OwnedBuffer = std::move(*BufferOrErr);
6132 Buffer = OwnedBuffer.get();
6136 StringRef Bytes = PCHContainerRdr.ExtractPCH(*Buffer);
6137 BitstreamCursor Stream(Bytes);
6141 consumeError(std::move(Err));
6149 bool NeedsInputFiles = Listener.needsInputFileVisitation();
6150 bool NeedsSystemInputFiles = Listener.needsSystemInputFileVisitation();
6151 bool NeedsImports = Listener.needsImportVisitation();
6152 BitstreamCursor InputFilesCursor;
6153 uint64_t InputFilesOffsetBase = 0;
6156 std::string ModuleDir;
6157 bool DoneWithControlBlock =
false;
6159 PathBuf.reserve(256);
6164 AdditionalPathBuf.reserve(256);
6165 while (!DoneWithControlBlock) {
6169 consumeError(MaybeEntry.takeError());
6172 llvm::BitstreamEntry Entry = MaybeEntry.get();
6174 switch (Entry.Kind) {
6175 case llvm::BitstreamEntry::SubBlock: {
6178 std::string IgnoredSuggestedPredefines;
6179 if (ReadOptionsBlock(Stream, Filename, ClientLoadCapabilities,
6181 Listener, IgnoredSuggestedPredefines) !=
Success)
6187 InputFilesCursor = Stream;
6188 if (llvm::Error Err = Stream.SkipBlock()) {
6190 consumeError(std::move(Err));
6193 if (NeedsInputFiles &&
6196 InputFilesOffsetBase = InputFilesCursor.GetCurrentBitNo();
6200 if (llvm::Error Err = Stream.SkipBlock()) {
6202 consumeError(std::move(Err));
6211 case llvm::BitstreamEntry::EndBlock:
6212 DoneWithControlBlock =
true;
6215 case llvm::BitstreamEntry::Error:
6218 case llvm::BitstreamEntry::Record:
6222 if (DoneWithControlBlock)
break;
6227 Stream.readRecord(Entry.ID,
Record, &Blob);
6228 if (!MaybeRecCode) {
6236 if (Listener.ReadFullVersionInformation(Blob))
6240 Listener.ReadModuleName(Blob);
6243 ModuleDir = std::string(Blob);
6249 Listener.ReadModuleMapFile(*Path);
6253 if (!NeedsInputFiles)
6256 unsigned NumInputFiles =
Record[0];
6257 unsigned NumUserFiles =
Record[1];
6258 const llvm::support::unaligned_uint64_t *InputFileOffs =
6259 (
const llvm::support::unaligned_uint64_t *)Blob.data();
6260 for (
unsigned I = 0; I != NumInputFiles; ++I) {
6262 bool isSystemFile = I >= NumUserFiles;
6264 if (isSystemFile && !NeedsSystemInputFiles)
6267 BitstreamCursor &Cursor = InputFilesCursor;
6269 if (llvm::Error Err =
6270 Cursor.JumpToBit(InputFilesOffsetBase + InputFileOffs[I])) {
6272 consumeError(std::move(Err));
6278 consumeError(MaybeCode.takeError());
6280 unsigned Code = MaybeCode.get();
6284 bool shouldContinue =
false;
6286 Cursor.readRecord(Code,
Record, &Blob);
6287 if (!MaybeRecordType) {
6289 consumeError(MaybeRecordType.takeError());
6295 time_t StoredTime =
static_cast<time_t
>(
Record[2]);
6296 bool Overridden =
static_cast<bool>(
Record[3]);
6297 auto [UnresolvedFilenameAsRequested, UnresolvedFilename] =
6300 PathBuf, UnresolvedFilenameAsRequested, ModuleDir);
6302 if (UnresolvedFilename.empty())
6303 Filename = *FilenameAsRequestedBuf;
6306 AdditionalPathBuf, UnresolvedFilename, ModuleDir);
6307 Filename = *FilenameBuf;
6309 shouldContinue = Listener.visitInputFileAsRequested(
6310 *FilenameAsRequestedBuf, Filename, isSystemFile, Overridden,
6314 if (!shouldContinue)
6336 bool IsCXX20ModuleOrPrebuiltHeaderUnit =
Record[Idx++];
6340 if (IsCXX20ModuleOrPrebuiltHeaderUnit) {
6341 Listener.visitImport(ModuleName,
"");
6352 Listener.visitImport(ModuleName, *Filename);
6363 if (FindModuleFileExtensions) {
6364 BitstreamCursor SavedStream = Stream;
6366 bool DoneWithExtensionBlock =
false;
6367 while (!DoneWithExtensionBlock) {
6373 llvm::BitstreamEntry Entry = MaybeEntry.get();
6375 switch (Entry.Kind) {
6376 case llvm::BitstreamEntry::SubBlock:
6377 if (llvm::Error Err = Stream.SkipBlock()) {
6379 consumeError(std::move(Err));
6384 case llvm::BitstreamEntry::EndBlock:
6385 DoneWithExtensionBlock =
true;
6388 case llvm::BitstreamEntry::Error:
6391 case llvm::BitstreamEntry::Record:
6398 Stream.readRecord(Entry.ID,
Record, &Blob);
6399 if (!MaybeRecCode) {
6403 switch (MaybeRecCode.get()) {
6409 Listener.readModuleFileExtension(Metadata);
6415 Stream = std::move(SavedStream);
6419 if (readUnhashedControlBlockImpl(
6420 nullptr, Bytes, Filename, ClientLoadCapabilities,
6422 ValidateDiagnosticOptions) !=
Success)
6433 StringRef SpecificModuleCachePath,
bool RequireStrictOptionMatches) {
6434 SimplePCHValidator validator(LangOpts, CGOpts, TargetOpts, PPOpts, HSOpts,
6435 SpecificModuleCachePath, FileMgr,
6436 RequireStrictOptionMatches);
6444 assert(GlobalID == 0 &&
"Unhandled global submodule ID");
6449 if (GlobalIndex >= SubmodulesLoaded.size()) {
6450 Error(
"submodule ID out of range in AST file");
6454 if (SubmodulesLoaded[GlobalIndex])
6455 return SubmodulesLoaded[GlobalIndex];
6458 assert(It != GlobalSubmoduleMap.end());
6461 [[maybe_unused]]
unsigned LocalID =
6468 Error(std::move(Err));
6472 ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
6477 auto CreateModule = !KnowsTopLevelModule
6481 Module *CurrentModule =
nullptr;
6486 Error(MaybeEntry.takeError());
6489 llvm::BitstreamEntry Entry = MaybeEntry.get();
6491 switch (Entry.Kind) {
6492 case llvm::BitstreamEntry::SubBlock:
6493 case llvm::BitstreamEntry::Error:
6494 case llvm::BitstreamEntry::EndBlock: {
6495 Error(llvm::createStringError(std::errc::illegal_byte_sequence,
6496 "malformed block record in AST file"));
6499 case llvm::BitstreamEntry::Record:
6509 Error(MaybeKind.takeError());
6516 if (!CurrentModule) {
6517 Error(llvm::createStringError(std::errc::illegal_byte_sequence,
6518 "malformed module definition"));
6521 return CurrentModule;
6524 if (
Record.size() < 13) {
6525 Error(llvm::createStringError(std::errc::illegal_byte_sequence,
6526 "malformed module definition"));
6530 StringRef Name = Blob;
6532 [[maybe_unused]]
unsigned ReadLocalID =
Record[Idx++];
6533 assert(LocalID == ReadLocalID);
6539 bool IsFramework =
Record[Idx++];
6540 bool IsExplicit =
Record[Idx++];
6541 bool IsSystem =
Record[Idx++];
6542 bool IsExternC =
Record[Idx++];
6543 bool InferSubmodules =
Record[Idx++];
6544 bool InferExplicitSubmodules =
Record[Idx++];
6545 bool InferExportWildcard =
Record[Idx++];
6546 bool ConfigMacrosExhaustive =
Record[Idx++];
6547 bool ModuleMapIsPrivate =
Record[Idx++];
6548 bool NamedModuleHasInit =
Record[Idx++];
6550 Module *ParentModule =
nullptr;
6557 CurrentModule = std::invoke(CreateModule, &ModMap, Name, ParentModule,
6558 IsFramework, IsExplicit);
6560 if (!ParentModule) {
6564 if (!
bool(PP.getPreprocessorOpts().DisablePCHOrModuleValidation &
6566 assert(*CurFileKey != F.
FileKey &&
6567 "ModuleManager did not de-duplicate");
6569 Diag(diag::err_module_file_conflict)
6573 auto CurModMapFile =
6575 auto ModMapFile = FileMgr.getOptionalFileRef(F.
ModuleMapPath);
6576 if (CurModMapFile && ModMapFile && CurModMapFile != ModMapFile)
6577 Diag(diag::note_module_file_conflict)
6578 << CurModMapFile->getName() << ModMapFile->getName();
6589 CurrentModule->
Kind = Kind;
6599 if (InferredAllowedBy.
isValid())
6611 if (
auto Dir = FileMgr.getOptionalDirectoryRef(F.
BaseDirectory))
6613 }
else if (ParentModule && ParentModule->
Directory) {
6618 if (DeserializationListener)
6619 DeserializationListener->ModuleRead(GlobalID, CurrentModule);
6621 SubmodulesLoaded[GlobalIndex] = CurrentModule;
6645 CurrentModule, Blob.str(), RelativePathName)) {
6681 PP.getFileManager().getOptionalDirectoryRef(*Dirname)) {
6691 for (
unsigned Idx = 0; Idx !=
Record.size(); ++Idx) {
6698 for (
unsigned Idx = 0; Idx !=
Record.size(); ++Idx) {
6706 for (
unsigned Idx = 0; Idx + 1 <
Record.size(); Idx += 2) {
6708 bool IsWildcard =
Record[Idx + 1];
6711 if (ExportedMod || IsWildcard)
6712 CurrentModule->
Exports.push_back({ExportedMod, IsWildcard});
6722 PP.getTargetInfo());
6739 Conflict.
Message = Blob.str();
6740 CurrentModule->
Conflicts.push_back(Conflict);
6750 for (
unsigned I = 0; I <
Record.size(); )
6752 ContextObj->addLazyModuleInitializers(CurrentModule,
Inits);
6779bool ASTReader::ParseLanguageOptions(
const RecordData &
Record,
6780 StringRef ModuleFilename,
bool Complain,
6782 bool AllowCompatibleDifferences) {
6786#define LANGOPT(Name, Bits, Default, Compatibility, Description) \
6787 LangOpts.Name = Record[Idx++];
6788#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
6789 LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++]));
6790#include "clang/Basic/LangOptions.def"
6791#define SANITIZER(NAME, ID) \
6792 LangOpts.Sanitize.set(SanitizerKind::ID, Record[Idx++]);
6793#include "clang/Basic/Sanitizers.def"
6795 for (
unsigned N =
Record[Idx++]; N; --N)
6799 VersionTuple runtimeVersion = ReadVersionTuple(
Record, Idx);
6805 for (
unsigned N =
Record[Idx++]; N; --N) {
6807 ReadString(
Record, Idx));
6812 for (
unsigned N =
Record[Idx++]; N; --N) {
6819 AllowCompatibleDifferences);
6822bool ASTReader::ParseCodeGenOptions(
const RecordData &
Record,
6823 StringRef ModuleFilename,
bool Complain,
6824 ASTReaderListener &Listener,
6825 bool AllowCompatibleDifferences) {
6827 CodeGenOptions CGOpts;
6829#define CODEGENOPT(Name, Bits, Default, Compatibility) \
6830 if constexpr (CK::Compatibility != CK::Benign) \
6831 CGOpts.Name = static_cast<unsigned>(Record[Idx++]);
6832#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility) \
6833 if constexpr (CK::Compatibility != CK::Benign) \
6834 CGOpts.set##Name(static_cast<clang::CodeGenOptions::Type>(Record[Idx++]));
6835#define DEBUGOPT(Name, Bits, Default, Compatibility)
6836#define VALUE_DEBUGOPT(Name, Bits, Default, Compatibility)
6837#define ENUM_DEBUGOPT(Name, Type, Bits, Default, Compatibility)
6838#include "clang/Basic/CodeGenOptions.def"
6841 AllowCompatibleDifferences);
6844bool ASTReader::ParseTargetOptions(
const RecordData &
Record,
6845 StringRef ModuleFilename,
bool Complain,
6846 ASTReaderListener &Listener,
6847 bool AllowCompatibleDifferences) {
6849 TargetOptions TargetOpts;
6851 TargetOpts.
CPU = ReadString(
Record, Idx);
6853 TargetOpts.
ABI = ReadString(
Record, Idx);
6854 for (
unsigned N =
Record[Idx++]; N; --N) {
6857 for (
unsigned N =
Record[Idx++]; N; --N) {
6862 AllowCompatibleDifferences);
6865bool ASTReader::ParseDiagnosticOptions(
const RecordData &
Record,
6866 StringRef ModuleFilename,
bool Complain,
6867 ASTReaderListener &Listener) {
6868 DiagnosticOptions DiagOpts;
6870#define DIAGOPT(Name, Bits, Default) DiagOpts.Name = Record[Idx++];
6871#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
6872 DiagOpts.set##Name(static_cast<Type>(Record[Idx++]));
6873#include "clang/Basic/DiagnosticOptions.def"
6875 for (
unsigned N =
Record[Idx++]; N; --N)
6877 for (
unsigned N =
Record[Idx++]; N; --N)
6883bool ASTReader::ParseFileSystemOptions(
const RecordData &
Record,
bool Complain,
6884 ASTReaderListener &Listener) {
6885 FileSystemOptions FSOpts;
6891bool ASTReader::ParseHeaderSearchOptions(
const RecordData &
Record,
6892 StringRef ModuleFilename,
6894 ASTReaderListener &Listener) {
6895 HeaderSearchOptions HSOpts;
6910 std::string ContextHash = ReadString(
Record, Idx);
6916bool ASTReader::ParseHeaderSearchPaths(
const RecordData &
Record,
bool Complain,
6917 ASTReaderListener &Listener) {
6918 HeaderSearchOptions HSOpts;
6922 for (
unsigned N =
Record[Idx++]; N; --N) {
6923 std::string Path = ReadString(
Record, Idx);
6926 bool IsFramework =
Record[Idx++];
6927 bool IgnoreSysRoot =
Record[Idx++];
6928 HSOpts.
UserEntries.emplace_back(std::move(Path), Group, IsFramework,
6933 for (
unsigned N =
Record[Idx++]; N; --N) {
6934 std::string Prefix = ReadString(
Record, Idx);
6935 bool IsSystemHeader =
Record[Idx++];
6940 for (
unsigned N =
Record[Idx++]; N; --N) {
6941 std::string VFSOverlayFile = ReadString(
Record, Idx);
6948bool ASTReader::ParsePreprocessorOptions(
const RecordData &
Record,
6949 StringRef ModuleFilename,
6951 ASTReaderListener &Listener,
6952 std::string &SuggestedPredefines) {
6953 PreprocessorOptions PPOpts;
6957 bool ReadMacros =
Record[Idx++];
6959 for (
unsigned N =
Record[Idx++]; N; --N) {
6961 bool IsUndef =
Record[Idx++];
6962 PPOpts.
Macros.push_back(std::make_pair(
Macro, IsUndef));
6967 for (
unsigned N =
Record[Idx++]; N; --N) {
6972 for (
unsigned N =
Record[Idx++]; N; --N) {
6981 SuggestedPredefines.clear();
6983 Complain, SuggestedPredefines);
6986std::pair<ModuleFile *, unsigned>
6987ASTReader::getModulePreprocessedEntity(
unsigned GlobalIndex) {
6988 GlobalPreprocessedEntityMapType::iterator
6989 I = GlobalPreprocessedEntityMap.find(GlobalIndex);
6990 assert(I != GlobalPreprocessedEntityMap.end() &&
6991 "Corrupted global preprocessed entity map");
6994 return std::make_pair(M, LocalIndex);
6997llvm::iterator_range<PreprocessingRecord::iterator>
6998ASTReader::getModulePreprocessedEntities(
ModuleFile &Mod)
const {
6999 if (PreprocessingRecord *PPRec = PP.getPreprocessingRecord())
7003 return llvm::make_range(PreprocessingRecord::iterator(),
7004 PreprocessingRecord::iterator());
7007bool ASTReader::canRecoverFromOutOfDate(StringRef ModuleFileName,
7008 unsigned int ClientLoadCapabilities) {
7009 return ClientLoadCapabilities & ARR_OutOfDate &&
7012 .getInMemoryModuleCache()
7013 .isPCMFinal(ModuleFileName);
7016llvm::iterator_range<ASTReader::ModuleDeclIterator>
7018 return llvm::make_range(
7025 auto I = GlobalSkippedRangeMap.find(GlobalIndex);
7026 assert(I != GlobalSkippedRangeMap.end() &&
7027 "Corrupted global skipped range map");
7030 assert(LocalIndex < M->NumPreprocessedSkippedRanges);
7034 assert(Range.isValid());
7040 unsigned ModuleFileIndex = ID >> 32;
7041 assert(ModuleFileIndex &&
"not translating loaded MacroID?");
7042 assert(getModuleManager().size() > ModuleFileIndex - 1);
7043 ModuleFile &MF = getModuleManager()[ModuleFileIndex - 1];
7045 ID &= llvm::maskTrailingOnes<PreprocessedEntityID>(32);
7050 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
7052 unsigned LocalIndex = PPInfo.second;
7057 if (!PP.getPreprocessingRecord()) {
7058 Error(
"no preprocessing record");
7065 Error(std::move(Err));
7072 Error(MaybeEntry.takeError());
7075 llvm::BitstreamEntry Entry = MaybeEntry.get();
7077 if (Entry.Kind != llvm::BitstreamEntry::Record)
7088 if (!MaybeRecType) {
7089 Error(MaybeRecType.takeError());
7094 bool isBuiltin =
Record[0];
7102 unsigned Index = translatePreprocessedEntityIDToIndex(GlobalID);
7122 if (DeserializationListener)
7123 DeserializationListener->MacroDefinitionRead(PPID, MD);
7129 const char *FullFileNameStart = Blob.data() +
Record[0];
7130 StringRef FullFileName(FullFileNameStart, Blob.size() -
Record[0]);
7132 if (!FullFileName.empty())
7133 File = PP.getFileManager().getOptionalFileRef(FullFileName);
7140 StringRef(Blob.data(),
Record[0]),
7148 llvm_unreachable(
"Invalid PreprocessorDetailRecordTypes");
7157unsigned ASTReader::findNextPreprocessedEntity(
7158 GlobalSLocOffsetMapType::const_iterator SLocMapI)
const {
7160 for (GlobalSLocOffsetMapType::const_iterator
7161 EndI = GlobalSLocOffsetMap.end(); SLocMapI != EndI; ++SLocMapI) {
7167 return getTotalNumPreprocessedEntities();
7172struct PPEntityComp {
7173 const ASTReader &Reader;
7176 PPEntityComp(
const ASTReader &Reader, ModuleFile &M) : Reader(Reader), M(M) {}
7178 bool operator()(
const PPEntityOffset &L,
const PPEntityOffset &R)
const {
7179 SourceLocation LHS = getLoc(L);
7180 SourceLocation RHS = getLoc(R);
7184 bool operator()(
const PPEntityOffset &L, SourceLocation RHS)
const {
7185 SourceLocation LHS = getLoc(L);
7189 bool operator()(SourceLocation LHS,
const PPEntityOffset &R)
const {
7190 SourceLocation RHS = getLoc(R);
7194 SourceLocation getLoc(
const PPEntityOffset &PPE)
const {
7201unsigned ASTReader::findPreprocessedEntity(SourceLocation Loc,
7202 bool EndsAfter)
const {
7203 if (SourceMgr.isLocalSourceLocation(Loc))
7204 return getTotalNumPreprocessedEntities();
7206 GlobalSLocOffsetMapType::const_iterator SLocMapI = GlobalSLocOffsetMap.find(
7207 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
7208 assert(SLocMapI != GlobalSLocOffsetMap.end() &&
7209 "Corrupted global sloc offset map");
7211 if (SLocMapI->second->NumPreprocessedEntities == 0)
7212 return findNextPreprocessedEntity(SLocMapI);
7223 pp_iterator
First = pp_begin;
7227 PPI = std::upper_bound(pp_begin, pp_end, Loc,
7228 PPEntityComp(*
this, M));
7237 std::advance(PPI,
Half);
7238 if (SourceMgr.isBeforeInTranslationUnit(
7239 ReadSourceLocation(M, PPI->getEnd()), Loc)) {
7242 Count = Count -
Half - 1;
7249 return findNextPreprocessedEntity(SLocMapI);
7256std::pair<unsigned, unsigned>
7258 if (Range.isInvalid())
7259 return std::make_pair(0,0);
7260 assert(!SourceMgr.isBeforeInTranslationUnit(Range.getEnd(),Range.getBegin()));
7262 unsigned BeginID = findPreprocessedEntity(Range.getBegin(),
false);
7263 unsigned EndID = findPreprocessedEntity(Range.getEnd(),
true);
7264 return std::make_pair(BeginID, EndID);
7274 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
7276 unsigned LocalIndex = PPInfo.second;
7283 if (SourceMgr.isInFileID(SourceMgr.getFileLoc(Loc), FID))
7292 class HeaderFileInfoVisitor {
7294 std::optional<HeaderFileInfo> HFI;
7297 explicit HeaderFileInfoVisitor(
FileEntryRef FE) : FE(FE) {}
7306 HeaderFileInfoLookupTable::iterator Pos = Table->find(FE);
7307 if (Pos == Table->end())
7314 std::optional<HeaderFileInfo> getHeaderFileInfo()
const {
return HFI; }
7320 HeaderFileInfoVisitor Visitor(FE);
7321 ModuleMgr.visit(Visitor);
7322 if (std::optional<HeaderFileInfo> HFI = Visitor.getHeaderFileInfo())
7329 using DiagState = DiagnosticsEngine::DiagState;
7340 auto ReadDiagState = [&](
const DiagState &BasedOn,
7341 bool IncludeNonPragmaStates) {
7342 unsigned BackrefID =
Record[Idx++];
7344 return DiagStates[BackrefID - 1];
7347 Diag.DiagStates.push_back(BasedOn);
7348 DiagState *NewState = &
Diag.DiagStates.back();
7349 DiagStates.push_back(NewState);
7350 unsigned Size =
Record[Idx++];
7351 assert(Idx + Size * 2 <=
Record.size() &&
7352 "Invalid data, not enough diag/map pairs");
7354 unsigned DiagID =
Record[Idx++];
7357 if (!NewMapping.
isPragma() && !IncludeNonPragmaStates)
7370 Mapping = NewMapping;
7376 DiagState *FirstState;
7381 FirstState =
Diag.DiagStatesByLoc.FirstDiagState;
7382 DiagStates.push_back(FirstState);
7386 "Invalid data, unexpected backref in initial state");
7388 assert(Idx <
Record.size() &&
7389 "Invalid data, not enough state change pairs in initial state");
7394 unsigned Flags =
Record[Idx++];
7395 DiagState Initial(*
Diag.getDiagnosticIDs());
7396 Initial.SuppressSystemWarnings = Flags & 1; Flags >>= 1;
7397 Initial.ErrorsAsFatal = Flags & 1; Flags >>= 1;
7398 Initial.WarningsAsErrors = Flags & 1; Flags >>= 1;
7399 Initial.EnableAllWarnings = Flags & 1; Flags >>= 1;
7400 Initial.IgnoreAllWarnings = Flags & 1; Flags >>= 1;
7402 FirstState = ReadDiagState(Initial,
true);
7410 .StateTransitions.push_back({FirstState, 0});
7415 FirstState = ReadDiagState(*
Diag.DiagStatesByLoc.CurDiagState,
false);
7419 unsigned NumLocations =
Record[Idx++];
7420 while (NumLocations--) {
7421 assert(Idx <
Record.size() &&
7422 "Invalid data, missing pragma diagnostic states");
7424 assert(FID.
isValid() &&
"invalid FileID for transition");
7425 unsigned Transitions =
Record[Idx++];
7431 auto &F =
Diag.DiagStatesByLoc.Files[FID];
7432 F.StateTransitions.reserve(F.StateTransitions.size() + Transitions);
7433 for (
unsigned I = 0; I != Transitions; ++I) {
7434 unsigned Offset =
Record[Idx++];
7435 auto *State = ReadDiagState(*FirstState,
false);
7436 F.StateTransitions.push_back({State, Offset});
7441 assert(Idx <
Record.size() &&
7442 "Invalid data, missing final pragma diagnostic state");
7444 auto *CurState = ReadDiagState(*FirstState,
false);
7447 Diag.DiagStatesByLoc.CurDiagState = CurState;
7448 Diag.DiagStatesByLoc.CurDiagStateLoc = CurStateLoc;
7453 auto &
T =
Diag.DiagStatesByLoc.Files[NullFile].StateTransitions;
7455 T.push_back({CurState, 0});
7457 T[0].State = CurState;
7463 assert(Idx <
Record.size() &&
7464 "Invalid data, missing diagnostic push stack");
7465 unsigned NumPushes =
Record[Idx++];
7466 for (
unsigned I = 0; I != NumPushes; ++I) {
7467 auto *State = ReadDiagState(*FirstState,
false);
7469 Diag.DiagStateOnPushStack.push_back(State);
7478ASTReader::RecordLocation ASTReader::TypeCursorForIndex(
TypeID ID) {
7479 auto [M, Index] = translateTypeIDToIndex(ID);
7486#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
7487 case TYPE_##CODE_ID: return Type::CLASS_ID;
7488#include "clang/Serialization/TypeBitCodes.def"
7490 return std::nullopt;
7500QualType ASTReader::readTypeRecord(
TypeID ID) {
7501 assert(ContextObj &&
"reading type with no AST context");
7502 ASTContext &Context = *ContextObj;
7503 RecordLocation Loc = TypeCursorForIndex(ID);
7504 BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
7508 SavedStreamPosition SavedPosition(DeclsCursor);
7510 ReadingKindTracker ReadingKind(Read_Type, *
this);
7513 Deserializing AType(
this);
7515 if (llvm::Error Err = DeclsCursor.JumpToBit(Loc.Offset)) {
7516 Error(std::move(Err));
7519 Expected<unsigned> RawCode = DeclsCursor.ReadCode();
7521 Error(RawCode.takeError());
7525 ASTRecordReader
Record(*
this, *Loc.F);
7526 Expected<unsigned> Code =
Record.readRecord(DeclsCursor, RawCode.get());
7528 Error(Code.takeError());
7532 QualType baseType =
Record.readQualType();
7533 Qualifiers quals =
Record.readQualifiers();
7539 Error(
"Unexpected code for type");
7543 serialization::AbstractTypeReader<ASTRecordReader> TypeReader(
Record);
7544 return TypeReader.read(*maybeClass);
7552 SourceLocation readSourceLocation() {
return Reader.readSourceLocation(); }
7553 SourceRange readSourceRange() {
return Reader.readSourceRange(); }
7556 return Reader.readTypeSourceInfo();
7560 return Reader.readNestedNameSpecifierLoc();
7564 return Reader.readAttr();
7573#define ABSTRACT_TYPELOC(CLASS, PARENT)
7574#define TYPELOC(CLASS, PARENT) \
7575 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
7576#include "clang/AST/TypeLocNodes.def"
7585void TypeLocReader::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
7589void TypeLocReader::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
7599void TypeLocReader::VisitComplexTypeLoc(ComplexTypeLoc TL) {
7603void TypeLocReader::VisitPointerTypeLoc(PointerTypeLoc TL) {
7607void TypeLocReader::VisitDecayedTypeLoc(DecayedTypeLoc TL) {
7611void TypeLocReader::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
7615void TypeLocReader::VisitArrayParameterTypeLoc(ArrayParameterTypeLoc TL) {
7619void TypeLocReader::VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
7623void TypeLocReader::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
7627void TypeLocReader::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
7631void TypeLocReader::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
7635void TypeLocReader::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
7643 if (Reader.readBool())
7650 VisitArrayTypeLoc(TL);
7654 VisitArrayTypeLoc(TL);
7657void TypeLocReader::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
7658 VisitArrayTypeLoc(TL);
7661void TypeLocReader::VisitDependentSizedArrayTypeLoc(
7662 DependentSizedArrayTypeLoc TL) {
7663 VisitArrayTypeLoc(TL);
7666void TypeLocReader::VisitDependentAddressSpaceTypeLoc(
7667 DependentAddressSpaceTypeLoc TL) {
7674void TypeLocReader::VisitDependentSizedExtVectorTypeLoc(
7675 DependentSizedExtVectorTypeLoc TL) {
7679void TypeLocReader::VisitVectorTypeLoc(VectorTypeLoc TL) {
7683void TypeLocReader::VisitDependentVectorTypeLoc(
7684 DependentVectorTypeLoc TL) {
7688void TypeLocReader::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
7692void TypeLocReader::VisitConstantMatrixTypeLoc(ConstantMatrixTypeLoc TL) {
7699void TypeLocReader::VisitDependentSizedMatrixTypeLoc(
7700 DependentSizedMatrixTypeLoc TL) {
7713 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i) {
7719 VisitFunctionTypeLoc(TL);
7723 VisitFunctionTypeLoc(TL);
7726void TypeLocReader::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
7727 SourceLocation ElaboratedKeywordLoc = readSourceLocation();
7728 NestedNameSpecifierLoc QualifierLoc = ReadNestedNameSpecifierLoc();
7729 SourceLocation NameLoc = readSourceLocation();
7730 TL.
set(ElaboratedKeywordLoc, QualifierLoc, NameLoc);
7733void TypeLocReader::VisitUsingTypeLoc(UsingTypeLoc TL) {
7734 SourceLocation ElaboratedKeywordLoc = readSourceLocation();
7735 NestedNameSpecifierLoc QualifierLoc = ReadNestedNameSpecifierLoc();
7736 SourceLocation NameLoc = readSourceLocation();
7737 TL.
set(ElaboratedKeywordLoc, QualifierLoc, NameLoc);
7740void TypeLocReader::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
7741 SourceLocation ElaboratedKeywordLoc = readSourceLocation();
7742 NestedNameSpecifierLoc QualifierLoc = ReadNestedNameSpecifierLoc();
7743 SourceLocation NameLoc = readSourceLocation();
7744 TL.
set(ElaboratedKeywordLoc, QualifierLoc, NameLoc);
7747void TypeLocReader::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
7753void TypeLocReader::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
7760void TypeLocReader::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
7765void TypeLocReader::VisitPackIndexingTypeLoc(PackIndexingTypeLoc TL) {
7769void TypeLocReader::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
7781 auto NamedConcept = readTemplateName();
7783 getContext(), NNS, TemplateKWLoc, ConceptNameLoc, FoundDecl, NamedConcept,
7788void TypeLocReader::VisitAutoTypeLoc(
AutoTypeLoc TL) {
7790 if (Reader.readBool())
7792 if (Reader.readBool())
7796void TypeLocReader::VisitDeducedTemplateSpecializationTypeLoc(
7810 VisitTagTypeLoc(TL);
7814 VisitTagTypeLoc(TL);
7817void TypeLocReader::VisitEnumTypeLoc(EnumTypeLoc TL) { VisitTagTypeLoc(TL); }
7819void TypeLocReader::VisitAttributedTypeLoc(AttributedTypeLoc TL) {
7823void TypeLocReader::VisitCountAttributedTypeLoc(CountAttributedTypeLoc TL) {
7827void TypeLocReader::VisitLateParsedAttrTypeLoc(LateParsedAttrTypeLoc TL) {
7829 "should be replaced with a concrete type before serialization");
7832void TypeLocReader::VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
7836void TypeLocReader::VisitOverflowBehaviorTypeLoc(OverflowBehaviorTypeLoc TL) {
7840void TypeLocReader::VisitHLSLAttributedResourceTypeLoc(
7841 HLSLAttributedResourceTypeLoc TL) {
7845void TypeLocReader::VisitHLSLInlineSpirvTypeLoc(HLSLInlineSpirvTypeLoc TL) {
7849void TypeLocReader::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
7853void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
7854 SubstTemplateTypeParmTypeLoc TL) {
7858void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
7859 SubstTemplateTypeParmPackTypeLoc TL) {
7863void TypeLocReader::VisitSubstBuiltinTemplatePackTypeLoc(
7864 SubstBuiltinTemplatePackTypeLoc TL) {
7868void TypeLocReader::VisitTemplateSpecializationTypeLoc(
7869 TemplateSpecializationTypeLoc TL) {
7870 SourceLocation ElaboratedKeywordLoc = readSourceLocation();
7871 NestedNameSpecifierLoc QualifierLoc = ReadNestedNameSpecifierLoc();
7872 SourceLocation TemplateKeywordLoc = readSourceLocation();
7873 SourceLocation NameLoc = readSourceLocation();
7874 SourceLocation LAngleLoc = readSourceLocation();
7875 SourceLocation RAngleLoc = readSourceLocation();
7876 TL.
set(ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
7877 LAngleLoc, RAngleLoc);
7878 MutableArrayRef<TemplateArgumentLocInfo> Args = TL.
getArgLocInfos();
7879 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I)
7880 Args[I] = Reader.readTemplateArgumentLocInfo(
7881 TL.
getTypePtr()->template_arguments()[I].getKind());
7884void TypeLocReader::VisitParenTypeLoc(ParenTypeLoc TL) {
7889void TypeLocReader::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
7895void TypeLocReader::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) {
7899void TypeLocReader::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
7904void TypeLocReader::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
7913void TypeLocReader::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
7925void TypeLocReader::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
7929void TypeLocReader::VisitAtomicTypeLoc(AtomicTypeLoc TL) {
7935void TypeLocReader::VisitPipeTypeLoc(PipeTypeLoc TL) {
7939void TypeLocReader::VisitBitIntTypeLoc(clang::BitIntTypeLoc TL) {
7943void TypeLocReader::VisitDependentBitIntTypeLoc(
7944 clang::DependentBitIntTypeLoc TL) {
7948void TypeLocReader::VisitPredefinedSugarTypeLoc(PredefinedSugarTypeLoc TL) {
7982std::pair<ModuleFile *, unsigned>
7985 "Predefined type shouldn't be in TypesLoaded");
7987 assert(ModuleFileIndex &&
"Untranslated Local Decl?");
7989 ModuleFile *OwningModuleFile = &getModuleManager()[ModuleFileIndex - 1];
7990 assert(OwningModuleFile &&
7991 "untranslated type ID or local type ID shouldn't be in TypesLoaded");
7993 return {OwningModuleFile,
7998 assert(ContextObj &&
"reading type with no AST context");
8009 llvm_unreachable(
"Invalid predefined type");
8025 T = Context.UnsignedCharTy;
8028 T = Context.UnsignedShortTy;
8031 T = Context.UnsignedIntTy;
8034 T = Context.UnsignedLongTy;
8037 T = Context.UnsignedLongLongTy;
8040 T = Context.UnsignedInt128Ty;
8043 T = Context.SignedCharTy;
8046 T = Context.WCharTy;
8049 T = Context.ShortTy;
8058 T = Context.LongLongTy;
8061 T = Context.Int128Ty;
8064 T = Context.BFloat16Ty;
8070 T = Context.FloatTy;
8073 T = Context.DoubleTy;
8076 T = Context.LongDoubleTy;
8079 T = Context.ShortAccumTy;
8082 T = Context.AccumTy;
8085 T = Context.LongAccumTy;
8088 T = Context.UnsignedShortAccumTy;
8091 T = Context.UnsignedAccumTy;
8094 T = Context.UnsignedLongAccumTy;
8097 T = Context.ShortFractTy;
8100 T = Context.FractTy;
8103 T = Context.LongFractTy;
8106 T = Context.UnsignedShortFractTy;
8109 T = Context.UnsignedFractTy;
8112 T = Context.UnsignedLongFractTy;
8115 T = Context.SatShortAccumTy;
8118 T = Context.SatAccumTy;
8121 T = Context.SatLongAccumTy;
8124 T = Context.SatUnsignedShortAccumTy;
8127 T = Context.SatUnsignedAccumTy;
8130 T = Context.SatUnsignedLongAccumTy;
8133 T = Context.SatShortFractTy;
8136 T = Context.SatFractTy;
8139 T = Context.SatLongFractTy;
8142 T = Context.SatUnsignedShortFractTy;
8145 T = Context.SatUnsignedFractTy;
8148 T = Context.SatUnsignedLongFractTy;
8151 T = Context.Float16Ty;
8154 T = Context.Float128Ty;
8157 T = Context.Ibm128Ty;
8160 T = Context.OverloadTy;
8163 T = Context.UnresolvedTemplateTy;
8166 T = Context.BoundMemberTy;
8169 T = Context.PseudoObjectTy;
8172 T = Context.DependentTy;
8175 T = Context.UnknownAnyTy;
8178 T = Context.NullPtrTy;
8181 T = Context.MetaInfoTy;
8184 T = Context.Char8Ty;
8187 T = Context.Char16Ty;
8190 T = Context.Char32Ty;
8193 T = Context.ObjCBuiltinIdTy;
8196 T = Context.ObjCBuiltinClassTy;
8199 T = Context.ObjCBuiltinSelTy;
8201#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8202 case PREDEF_TYPE_##Id##_ID: \
8203 T = Context.SingletonId; \
8205#include "clang/Basic/OpenCLImageTypes.def"
8206#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
8207 case PREDEF_TYPE_##Id##_ID: \
8208 T = Context.Id##Ty; \
8210#include "clang/Basic/OpenCLExtensionTypes.def"
8212 T = Context.OCLSamplerTy;
8215 T = Context.OCLEventTy;
8218 T = Context.OCLClkEventTy;
8221 T = Context.OCLQueueTy;
8224 T = Context.OCLReserveIDTy;
8227 T = Context.getAutoDeductType();
8230 T = Context.getAutoRRefDeductType();
8233 T = Context.ARCUnbridgedCastTy;
8236 T = Context.BuiltinFnTy;
8239 T = Context.IncompleteMatrixIdxTy;
8242 T = Context.ArraySectionTy;
8245 T = Context.OMPArrayShapingTy;
8248 T = Context.OMPIteratorTy;
8250#define SVE_TYPE(Name, Id, SingletonId) \
8251 case PREDEF_TYPE_##Id##_ID: \
8252 T = Context.SingletonId; \
8254#include "clang/Basic/AArch64ACLETypes.def"
8255#define PPC_VECTOR_TYPE(Name, Id, Size) \
8256 case PREDEF_TYPE_##Id##_ID: \
8257 T = Context.Id##Ty; \
8259#include "clang/Basic/PPCTypes.def"
8260#define RVV_TYPE(Name, Id, SingletonId) \
8261 case PREDEF_TYPE_##Id##_ID: \
8262 T = Context.SingletonId; \
8264#include "clang/Basic/RISCVVTypes.def"
8265#define WASM_TYPE(Name, Id, SingletonId) \
8266 case PREDEF_TYPE_##Id##_ID: \
8267 T = Context.SingletonId; \
8269#include "clang/Basic/WebAssemblyReferenceTypes.def"
8270#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
8271 case PREDEF_TYPE_##Id##_ID: \
8272 T = Context.SingletonId; \
8274#include "clang/Basic/AMDGPUTypes.def"
8275#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
8276 case PREDEF_TYPE_##Id##_ID: \
8277 T = Context.SingletonId; \
8279#include "clang/Basic/HLSLIntangibleTypes.def"
8280#define HLSL_PACKED_TYPE(Name, Id, SingletonId) \
8281 case PREDEF_TYPE_##Id##_ID: \
8282 T = Context.SingletonId; \
8284#include "clang/Basic/HLSLPackedTypes.def"
8285#define SPIRV_TYPE(Name, Id, SingletonId) \
8286 case PREDEF_TYPE_##Id##_ID: \
8287 T = Context.SingletonId; \
8289#include "clang/Basic/SPIRVTypes.def"
8292 assert(!
T.isNull() &&
"Unknown predefined type");
8293 return T.withFastQualifiers(FastQuals);
8296 unsigned Index = translateTypeIDToIndex(ID).second;
8298 assert(Index < TypesLoaded.size() &&
"Type index out-of-range");
8299 if (TypesLoaded[Index].isNull()) {
8300 TypesLoaded[Index] = readTypeRecord(ID);
8301 if (TypesLoaded[Index].isNull())
8304 TypesLoaded[Index]->setFromAST();
8305 if (DeserializationListener)
8307 TypesLoaded[Index]);
8310 return TypesLoaded[Index].withFastQualifiers(FastQuals);
8323 ReadModuleOffsetMap(F);
8326 LocalID &= llvm::maskTrailingOnes<TypeID>(32);
8328 if (ModuleFileIndex == 0)
8333 ModuleFileIndex = MF.
Index + 1;
8334 return ((uint64_t)ModuleFileIndex << 32) | LocalID;
8353 TemplateNameLoc, EllipsisLoc);
8364 llvm_unreachable(
"unexpected template argument loc");
8381 unsigned NumArgsAsWritten =
readInt();
8382 for (
unsigned i = 0; i != NumArgsAsWritten; ++i)
8396 if (NumCurrentElementsDeserializing) {
8401 PendingIncompleteDeclChains.push_back(
const_cast<Decl*
>(D));
8424 auto *II = Name.getAsIdentifierInfo();
8425 assert(II &&
"non-identifier name in C?");
8426 if (II->isOutOfDate())
8443 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
8444 Template = CTSD->getSpecializedTemplate();
8445 Args = CTSD->getTemplateArgs().asArray();
8446 }
else if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D)) {
8447 Template = VTSD->getSpecializedTemplate();
8448 Args = VTSD->getTemplateArgs().asArray();
8449 }
else if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
8450 if (
auto *Tmplt = FD->getPrimaryTemplate()) {
8452 Args = FD->getTemplateSpecializationArgs()->asArray();
8457 Template->loadLazySpecializationsImpl(Args);
8462 RecordLocation Loc = getLocalBitOffset(Offset);
8465 if (llvm::Error Err = Cursor.JumpToBit(Loc.Offset)) {
8466 Error(std::move(Err));
8469 ReadingKindTracker ReadingKind(Read_Decl, *
this);
8474 Error(MaybeCode.takeError());
8477 unsigned Code = MaybeCode.get();
8481 if (!MaybeRecCode) {
8482 Error(MaybeRecCode.takeError());
8486 Error(
"malformed AST file: missing C++ ctor initializers");
8490 return Record.readCXXCtorInitializers();
8494 assert(ContextObj &&
"reading base specifiers with no AST context");
8497 RecordLocation Loc = getLocalBitOffset(Offset);
8500 if (llvm::Error Err = Cursor.JumpToBit(Loc.Offset)) {
8501 Error(std::move(Err));
8504 ReadingKindTracker ReadingKind(Read_Decl, *
this);
8509 Error(MaybeCode.takeError());
8512 unsigned Code = MaybeCode.get();
8516 if (!MaybeRecCode) {
8517 Error(MaybeCode.takeError());
8520 unsigned RecCode = MaybeRecCode.get();
8523 Error(
"malformed AST file: missing C++ base specifiers");
8527 unsigned NumBases =
Record.readInt();
8530 for (
unsigned I = 0; I != NumBases; ++I)
8531 Bases[I] =
Record.readCXXBaseSpecifier();
8544 ReadModuleOffsetMap(F);
8547 OwningModuleFileIndex == 0
8551 if (OwningModuleFileIndex == 0)
8554 uint64_t NewModuleFileIndex = OwningModuleFile->
Index + 1;
8563 unsigned ModuleFileIndex = ID.getModuleFileIndex();
8564 return M.
Index == ModuleFileIndex - 1;
8572 uint64_t ModuleFileIndex = ID.getModuleFileIndex();
8573 assert(ModuleFileIndex &&
"Untranslated Local Decl?");
8593 DeclCursorForID(ID, Loc);
8598 assert(ContextObj &&
"reading predefined decl without AST context");
8600 Decl *NewLoaded =
nullptr;
8606 return Context.getTranslationUnitDecl();
8609 if (Context.ObjCIdDecl)
8610 return Context.ObjCIdDecl;
8611 NewLoaded = Context.getObjCIdDecl();
8615 if (Context.ObjCSelDecl)
8616 return Context.ObjCSelDecl;
8617 NewLoaded = Context.getObjCSelDecl();
8621 if (Context.ObjCClassDecl)
8622 return Context.ObjCClassDecl;
8623 NewLoaded = Context.getObjCClassDecl();
8627 if (Context.ObjCProtocolClassDecl)
8628 return Context.ObjCProtocolClassDecl;
8629 NewLoaded = Context.getObjCProtocolDecl();
8633 if (Context.Int128Decl)
8634 return Context.Int128Decl;
8635 NewLoaded = Context.getInt128Decl();
8639 if (Context.UInt128Decl)
8640 return Context.UInt128Decl;
8641 NewLoaded = Context.getUInt128Decl();
8645 if (Context.ObjCInstanceTypeDecl)
8646 return Context.ObjCInstanceTypeDecl;
8647 NewLoaded = Context.getObjCInstanceTypeDecl();
8651 if (Context.BuiltinVaListDecl)
8652 return Context.BuiltinVaListDecl;
8653 NewLoaded = Context.getBuiltinVaListDecl();
8657 if (Context.VaListTagDecl)
8658 return Context.VaListTagDecl;
8659 NewLoaded = Context.getVaListTagDecl();
8663 if (Context.BuiltinMSVaListDecl)
8664 return Context.BuiltinMSVaListDecl;
8665 NewLoaded = Context.getBuiltinMSVaListDecl();
8669 if (Context.BuiltinZOSVaListDecl)
8670 return Context.BuiltinZOSVaListDecl;
8671 NewLoaded = Context.getBuiltinZOSVaListDecl();
8676 return Context.getMSGuidTagDecl();
8679 if (Context.ExternCContext)
8680 return Context.ExternCContext;
8681 NewLoaded = Context.getExternCContextDecl();
8685 if (Context.CFConstantStringTypeDecl)
8686 return Context.CFConstantStringTypeDecl;
8687 NewLoaded = Context.getCFConstantStringDecl();
8691 if (Context.CFConstantStringTagDecl)
8692 return Context.CFConstantStringTagDecl;
8693 NewLoaded = Context.getCFConstantStringTagDecl();
8697 return Context.getMSTypeInfoTagDecl();
8699#define BuiltinTemplate(BTName) \
8700 case PREDEF_DECL##BTName##_ID: \
8701 if (Context.Decl##BTName) \
8702 return Context.Decl##BTName; \
8703 NewLoaded = Context.get##BTName##Decl(); \
8705#include "clang/Basic/BuiltinTemplates.inc"
8708 llvm_unreachable(
"Invalid decl ID");
8712 assert(NewLoaded &&
"Failed to load predefined decl?");
8714 if (DeserializationListener)
8715 DeserializationListener->PredefinedDeclBuilt(ID, NewLoaded);
8720unsigned ASTReader::translateGlobalDeclIDToIndex(GlobalDeclID GlobalID)
const {
8721 ModuleFile *OwningModuleFile = getOwningModuleFile(GlobalID);
8722 if (!OwningModuleFile) {
8731 assert(ContextObj &&
"reading decl with no AST context");
8740 Merged.push_back(ID);
8745 unsigned Index = translateGlobalDeclIDToIndex(ID);
8747 if (Index >= DeclsLoaded.size()) {
8748 assert(0 &&
"declaration ID out-of-range for AST file");
8749 Error(
"declaration ID out-of-range for AST file");
8753 return DeclsLoaded[Index];
8760 unsigned Index = translateGlobalDeclIDToIndex(ID);
8762 if (Index >= DeclsLoaded.size()) {
8763 assert(0 &&
"declaration ID out-of-range for AST file");
8764 Error(
"declaration ID out-of-range for AST file");
8768 if (!DeclsLoaded[Index]) {
8770 if (DeserializationListener)
8771 DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);
8774 return DeclsLoaded[Index];
8783 ReadModuleOffsetMap(M);
8793 uint64_t OrignalModuleFileIndex = 0;
8796 OrignalModuleFileIndex = I + 1;
8800 if (!OrignalModuleFileIndex)
8808 if (Idx >=
Record.size()) {
8809 Error(
"Corrupted AST file");
8826 RecordLocation Loc = getLocalBitOffset(Offset);
8827 if (llvm::Error Err = Loc.F->
DeclsCursor.JumpToBit(Loc.Offset)) {
8828 Error(std::move(Err));
8831 assert(NumCurrentElementsDeserializing == 0 &&
8832 "should not be called while already deserializing");
8834 return ReadStmtFromStream(*Loc.F);
8837bool ASTReader::LoadExternalSpecializationsImpl(SpecLookupTableTy &SpecLookups,
8841 auto It = SpecLookups.find(D);
8842 if (It == SpecLookups.end())
8848 It->second.Table.findAll();
8852 SpecLookups.erase(It);
8854 bool NewSpecsFound =
false;
8855 Deserializing LookupResults(
this);
8856 for (
auto &Info : Infos) {
8857 if (GetExistingDecl(Info))
8859 NewSpecsFound =
true;
8863 return NewSpecsFound;
8870 bool NewSpecsFound =
8871 LoadExternalSpecializationsImpl(PartialSpecializationsLookups, D);
8873 return NewSpecsFound;
8875 NewSpecsFound |= LoadExternalSpecializationsImpl(SpecializationsLookups, D);
8876 return NewSpecsFound;
8879bool ASTReader::LoadExternalSpecializationsImpl(
8880 SpecLookupTableTy &SpecLookups,
const Decl *D,
8884 auto It = SpecLookups.find(D);
8885 if (It == SpecLookups.end())
8888 Deserializing LookupResults(
this);
8892 It->second.Table.find(HashValue);
8894 llvm::TimeTraceScope TimeScope(
"Load External Specializations for ", [&] {
8896 llvm::raw_string_ostream OS(Name);
8903 bool NewSpecsFound =
false;
8904 for (
auto &Info : Infos) {
8905 if (GetExistingDecl(Info))
8907 NewSpecsFound =
true;
8911 return NewSpecsFound;
8918 bool NewDeclsFound = LoadExternalSpecializationsImpl(
8919 PartialSpecializationsLookups, D, TemplateArgs);
8921 LoadExternalSpecializationsImpl(SpecializationsLookups, D, TemplateArgs);
8923 return NewDeclsFound;
8931 auto Visit = [&] (
ModuleFile *M, LexicalContents LexicalDecls) {
8932 assert(LexicalDecls.size() % 2 == 0 &&
"expected an even number of entries");
8933 for (
int I = 0, N = LexicalDecls.size(); I != N; I += 2) {
8935 if (!IsKindWeWant(K))
8938 auto ID = (
DeclID) + LexicalDecls[I + 1];
8943 if (PredefsVisited[ID])
8946 PredefsVisited[ID] =
true;
8950 assert(D->
getKind() == K &&
"wrong kind for lexical decl");
8958 for (
const auto &Lexical : TULexicalDecls)
8959 Visit(Lexical.first, Lexical.second);
8961 auto I = LexicalDecls.find(DC);
8962 if (I != LexicalDecls.end())
8963 Visit(I->second.first, I->second.second);
8966 ++NumLexicalDeclContextsRead;
8971class UnalignedDeclIDComp {
8977 : Reader(Reader), Mod(M) {}
8986 SourceLocation RHS = getLocation(R);
8991 SourceLocation LHS = getLocation(L);
9005 unsigned Offset,
unsigned Length,
9009 llvm::DenseMap<FileID, FileDeclsInfo>::iterator I = FileDeclIDs.find(
File);
9010 if (I == FileDeclIDs.end())
9013 FileDeclsInfo &DInfo = I->second;
9014 if (DInfo.Decls.empty())
9021 UnalignedDeclIDComp DIDComp(*
this, *DInfo.Mod);
9023 llvm::lower_bound(DInfo.Decls, BeginLoc, DIDComp);
9024 if (BeginIt != DInfo.Decls.begin())
9030 while (BeginIt != DInfo.Decls.begin() &&
9033 ->isTopLevelDeclInObjCContainer())
9037 llvm::upper_bound(DInfo.Decls, EndLoc, DIDComp);
9038 if (EndIt != DInfo.Decls.end())
9051 "DeclContext has no visible decls in storage");
9058 auto Find = [&,
this](
auto &&Table,
auto &&Key) {
9080 if (
auto It = Lookups.find(DC); It != Lookups.end()) {
9081 ++NumVisibleDeclContextsRead;
9082 Find(It->second.Table, Name);
9085 auto FindModuleLocalLookup = [&,
this](
Module *NamedModule) {
9086 if (
auto It = ModuleLocalLookups.find(DC); It != ModuleLocalLookups.end()) {
9087 ++NumModuleLocalVisibleDeclContexts;
9088 Find(It->second.Table, std::make_pair(Name, NamedModule));
9091 if (
auto *NamedModule =
9092 OriginalDC ?
cast<Decl>(OriginalDC)->getTopLevelOwningNamedModule()
9094 FindModuleLocalLookup(NamedModule);
9099 if (ContextObj && ContextObj->getCurrentNamedModule())
9100 FindModuleLocalLookup(ContextObj->getCurrentNamedModule());
9102 if (
auto It = TULocalLookups.find(DC); It != TULocalLookups.end()) {
9103 ++NumTULocalVisibleDeclContexts;
9104 Find(It->second.Table, Name);
9117 auto findAll = [&](
auto &LookupTables,
unsigned &NumRead) {
9118 auto It = LookupTables.find(DC);
9119 if (It == LookupTables.end())
9141 findAll(Lookups, NumVisibleDeclContextsRead);
9142 findAll(ModuleLocalLookups, NumModuleLocalVisibleDeclContexts);
9143 findAll(TULocalLookups, NumTULocalVisibleDeclContexts);
9145 for (
auto &[Name, DS] : Decls)
9148 const_cast<DeclContext *
>(DC)->setHasExternalVisibleStorage(
false);
9153 auto I = Lookups.find(Primary);
9154 return I == Lookups.end() ?
nullptr : &I->second;
9159 auto I = ModuleLocalLookups.find(Primary);
9160 return I == ModuleLocalLookups.end() ?
nullptr : &I->second;
9165 auto I = TULocalLookups.find(Primary);
9166 return I == TULocalLookups.end() ?
nullptr : &I->second;
9173 IsPartial ? PartialSpecializationsLookups : SpecializationsLookups;
9174 auto I = LookupTable.find(D);
9175 return I == LookupTable.end() ?
nullptr : &I->second;
9180 return PartialSpecializationsLookups.contains(D) ||
9181 SpecializationsLookups.contains(D);
9190 assert(ImplD && Consumer);
9192 for (
auto *I : ImplD->
methods())
9198void ASTReader::PassInterestingDeclToConsumer(Decl *D) {
9199 if (ObjCImplDecl *ImplD = dyn_cast<ObjCImplDecl>(D))
9202 Consumer->HandleInterestingDecl(DeclGroupRef(D));
9205void ASTReader::PassVTableToConsumer(CXXRecordDecl *RD) {
9206 Consumer->HandleVTable(RD);
9210 this->Consumer = Consumer;
9213 PassInterestingDeclsToConsumer();
9215 if (DeserializationListener)
9216 DeserializationListener->ReaderInitialized(
this);
9220 std::fprintf(
stderr,
"*** AST File Statistics:\n");
9222 unsigned NumTypesLoaded =
9223 TypesLoaded.size() - llvm::count(TypesLoaded.materialized(),
QualType());
9224 unsigned NumDeclsLoaded =
9225 DeclsLoaded.size() -
9226 llvm::count(DeclsLoaded.materialized(), (
Decl *)
nullptr);
9227 unsigned NumIdentifiersLoaded =
9228 IdentifiersLoaded.size() -
9230 unsigned NumMacrosLoaded =
9231 MacrosLoaded.size() - llvm::count(MacrosLoaded, (
MacroInfo *)
nullptr);
9232 unsigned NumSelectorsLoaded =
9233 SelectorsLoaded.size() - llvm::count(SelectorsLoaded,
Selector());
9236 std::fprintf(
stderr,
" %u/%u source location entries read (%f%%)\n",
9237 NumSLocEntriesRead, TotalNumSLocEntries,
9238 ((
float)NumSLocEntriesRead/TotalNumSLocEntries * 100));
9239 if (!TypesLoaded.empty())
9240 std::fprintf(
stderr,
" %u/%u types read (%f%%)\n",
9241 NumTypesLoaded, (
unsigned)TypesLoaded.size(),
9242 ((
float)NumTypesLoaded/TypesLoaded.size() * 100));
9243 if (!DeclsLoaded.empty())
9244 std::fprintf(
stderr,
" %u/%u declarations read (%f%%)\n",
9245 NumDeclsLoaded, (
unsigned)DeclsLoaded.size(),
9246 ((
float)NumDeclsLoaded/DeclsLoaded.size() * 100));
9247 if (!IdentifiersLoaded.empty())
9248 std::fprintf(
stderr,
" %u/%u identifiers read (%f%%)\n",
9249 NumIdentifiersLoaded, (
unsigned)IdentifiersLoaded.size(),
9250 ((
float)NumIdentifiersLoaded/IdentifiersLoaded.size() * 100));
9251 if (!MacrosLoaded.empty())
9252 std::fprintf(
stderr,
" %u/%u macros read (%f%%)\n",
9253 NumMacrosLoaded, (
unsigned)MacrosLoaded.size(),
9254 ((
float)NumMacrosLoaded/MacrosLoaded.size() * 100));
9255 if (!SelectorsLoaded.empty())
9256 std::fprintf(
stderr,
" %u/%u selectors read (%f%%)\n",
9257 NumSelectorsLoaded, (
unsigned)SelectorsLoaded.size(),
9258 ((
float)NumSelectorsLoaded/SelectorsLoaded.size() * 100));
9259 if (TotalNumStatements)
9260 std::fprintf(
stderr,
" %u/%u statements read (%f%%)\n",
9261 NumStatementsRead, TotalNumStatements,
9262 ((
float)NumStatementsRead/TotalNumStatements * 100));
9264 std::fprintf(
stderr,
" %u/%u macros read (%f%%)\n",
9265 NumMacrosRead, TotalNumMacros,
9266 ((
float)NumMacrosRead/TotalNumMacros * 100));
9267 if (TotalLexicalDeclContexts)
9268 std::fprintf(
stderr,
" %u/%u lexical declcontexts read (%f%%)\n",
9269 NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
9270 ((
float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts
9272 if (TotalVisibleDeclContexts)
9273 std::fprintf(
stderr,
" %u/%u visible declcontexts read (%f%%)\n",
9274 NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
9275 ((
float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
9277 if (TotalModuleLocalVisibleDeclContexts)
9279 stderr,
" %u/%u module local visible declcontexts read (%f%%)\n",
9280 NumModuleLocalVisibleDeclContexts, TotalModuleLocalVisibleDeclContexts,
9281 ((
float)NumModuleLocalVisibleDeclContexts /
9282 TotalModuleLocalVisibleDeclContexts * 100));
9283 if (TotalTULocalVisibleDeclContexts)
9284 std::fprintf(
stderr,
" %u/%u visible declcontexts in GMF read (%f%%)\n",
9285 NumTULocalVisibleDeclContexts, TotalTULocalVisibleDeclContexts,
9286 ((
float)NumTULocalVisibleDeclContexts /
9287 TotalTULocalVisibleDeclContexts * 100));
9288 if (TotalNumMethodPoolEntries)
9289 std::fprintf(
stderr,
" %u/%u method pool entries read (%f%%)\n",
9290 NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
9291 ((
float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
9293 if (NumMethodPoolLookups)
9294 std::fprintf(
stderr,
" %u/%u method pool lookups succeeded (%f%%)\n",
9295 NumMethodPoolHits, NumMethodPoolLookups,
9296 ((
float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
9297 if (NumMethodPoolTableLookups)
9298 std::fprintf(
stderr,
" %u/%u method pool table lookups succeeded (%f%%)\n",
9299 NumMethodPoolTableHits, NumMethodPoolTableLookups,
9300 ((
float)NumMethodPoolTableHits/NumMethodPoolTableLookups
9302 if (NumIdentifierLookupHits)
9304 " %u / %u identifier table lookups succeeded (%f%%)\n",
9305 NumIdentifierLookupHits, NumIdentifierLookups,
9306 (
double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
9309 std::fprintf(
stderr,
"\n");
9310 GlobalIndex->printStats();
9313 std::fprintf(
stderr,
"\n");
9315 std::fprintf(
stderr,
"\n");
9318template<
typename Key,
typename ModuleFile,
unsigned InitialCapacity>
9319LLVM_DUMP_METHOD
static void
9322 InitialCapacity> &Map) {
9323 if (Map.begin() == Map.end())
9328 llvm::errs() << Name <<
":\n";
9329 for (
typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
9331 llvm::errs() <<
" " << (
DeclID)I->first <<
" -> " << I->second->FileName
9336 llvm::errs() <<
"*** PCH/ModuleFile Remappings:\n";
9338 dumpModuleIDMap(
"Global source location entry map", GlobalSLocEntryMap);
9342 GlobalPreprocessedEntityMap);
9344 llvm::errs() <<
"\n*** PCH/Modules Loaded:";
9353 if (llvm::MemoryBuffer *buf = I.Buffer) {
9354 size_t bytes = buf->getBufferSize();
9355 switch (buf->getBufferKind()) {
9356 case llvm::MemoryBuffer::MemoryBuffer_Malloc:
9359 case llvm::MemoryBuffer::MemoryBuffer_MMap:
9380 if (!FPPragmaOptions.empty()) {
9381 assert(FPPragmaOptions.size() == 1 &&
"Wrong number of FP_PRAGMA_OPTIONS");
9384 SemaObj->CurFPFeatures =
9390 if (
auto *FD = dyn_cast<FunctionDecl>(D))
9391 SemaObj->addDeclWithEffects(FD, FD->getFunctionEffects());
9392 else if (
auto *BD = dyn_cast<BlockDecl>(D))
9393 SemaObj->addDeclWithEffects(BD, BD->getFunctionEffects());
9395 llvm_unreachable(
"unexpected Decl type in DeclsWithEffectsToVerify");
9397 DeclsWithEffectsToVerify.clear();
9399 SemaObj->OpenCLFeatures = OpenCLExtensions;
9405 assert(SemaObj &&
"no Sema to update");
9411 OpenMPRequiresDecls.clear();
9415 if (!SemaDeclRefs.empty()) {
9416 assert(SemaDeclRefs.size() % 3 == 0);
9417 for (
unsigned I = 0; I != SemaDeclRefs.size(); I += 3) {
9418 if (!SemaObj->StdNamespace)
9419 SemaObj->StdNamespace = SemaDeclRefs[I].getRawValue();
9420 if (!SemaObj->StdBadAlloc)
9421 SemaObj->StdBadAlloc = SemaDeclRefs[I + 1].getRawValue();
9422 if (!SemaObj->StdAlignValT)
9423 SemaObj->StdAlignValT = SemaDeclRefs[I + 2].getRawValue();
9425 SemaDeclRefs.clear();
9430 if(OptimizeOffPragmaLocation.isValid())
9431 SemaObj->ActOnPragmaOptimize(
false, OptimizeOffPragmaLocation);
9432 if (PragmaMSStructState != -1)
9434 if (PointersToMembersPragmaLocation.isValid()) {
9435 SemaObj->ActOnPragmaMSPointersToMembers(
9437 PragmaMSPointersToMembersState,
9438 PointersToMembersPragmaLocation);
9440 SemaObj->CUDA().ForceHostDeviceDepth = ForceHostDeviceDepth;
9441 if (!RISCVVecIntrinsicPragma.empty()) {
9442 assert(RISCVVecIntrinsicPragma.size() == 3 &&
9443 "Wrong number of RISCVVecIntrinsicPragma");
9444 SemaObj->RISCV().DeclareRVVBuiltins = RISCVVecIntrinsicPragma[0];
9445 SemaObj->RISCV().DeclareSiFiveVectorBuiltins = RISCVVecIntrinsicPragma[1];
9446 SemaObj->RISCV().DeclareAndesVectorBuiltins = RISCVVecIntrinsicPragma[2];
9449 if (PragmaAlignPackCurrentValue) {
9453 bool DropFirst =
false;
9454 if (!PragmaAlignPackStack.empty() &&
9455 PragmaAlignPackStack.front().Location.isInvalid()) {
9456 assert(PragmaAlignPackStack.front().Value ==
9457 SemaObj->AlignPackStack.DefaultValue &&
9458 "Expected a default alignment value");
9459 SemaObj->AlignPackStack.Stack.emplace_back(
9460 PragmaAlignPackStack.front().SlotLabel,
9461 SemaObj->AlignPackStack.CurrentValue,
9462 SemaObj->AlignPackStack.CurrentPragmaLocation,
9463 PragmaAlignPackStack.front().PushLocation);
9466 for (
const auto &Entry :
9467 llvm::ArrayRef(PragmaAlignPackStack).drop_front(DropFirst ? 1 : 0)) {
9468 SemaObj->AlignPackStack.Stack.emplace_back(
9469 Entry.SlotLabel, Entry.Value, Entry.Location, Entry.PushLocation);
9471 if (PragmaAlignPackCurrentLocation.isInvalid()) {
9472 assert(*PragmaAlignPackCurrentValue ==
9473 SemaObj->AlignPackStack.DefaultValue &&
9474 "Expected a default align and pack value");
9477 SemaObj->AlignPackStack.CurrentValue = *PragmaAlignPackCurrentValue;
9478 SemaObj->AlignPackStack.CurrentPragmaLocation =
9479 PragmaAlignPackCurrentLocation;
9482 if (FpPragmaCurrentValue) {
9486 bool DropFirst =
false;
9487 if (!FpPragmaStack.empty() && FpPragmaStack.front().Location.isInvalid()) {
9488 assert(FpPragmaStack.front().Value ==
9489 SemaObj->FpPragmaStack.DefaultValue &&
9490 "Expected a default pragma float_control value");
9491 SemaObj->FpPragmaStack.Stack.emplace_back(
9492 FpPragmaStack.front().SlotLabel, SemaObj->FpPragmaStack.CurrentValue,
9493 SemaObj->FpPragmaStack.CurrentPragmaLocation,
9494 FpPragmaStack.front().PushLocation);
9497 for (
const auto &Entry :
9499 SemaObj->FpPragmaStack.Stack.emplace_back(
9500 Entry.SlotLabel, Entry.Value, Entry.Location, Entry.PushLocation);
9501 if (FpPragmaCurrentLocation.isInvalid()) {
9502 assert(*FpPragmaCurrentValue == SemaObj->FpPragmaStack.DefaultValue &&
9503 "Expected a default pragma float_control value");
9506 SemaObj->FpPragmaStack.CurrentValue = *FpPragmaCurrentValue;
9507 SemaObj->FpPragmaStack.CurrentPragmaLocation = FpPragmaCurrentLocation;
9512 for (
auto &Import : PendingImportedModulesSema) {
9513 if (Import.ImportLoc.isInvalid())
9516 SemaObj->makeModuleVisible(Imported, Import.ImportLoc);
9519 PendingImportedModulesSema.clear();
9526 IdentifierLookupVisitor Visitor(Name, 0,
9527 NumIdentifierLookups,
9528 NumIdentifierLookupHits);
9534 if (PP.getLangOpts().CPlusPlus) {
9535 for (
auto *F : ModuleMgr.pch_modules())
9544 if (GlobalIndex->lookupIdentifier(Name, Hits)) {
9549 ModuleMgr.visit(Visitor, HitsPtr);
9571 ASTIdentifierLookupTable::key_iterator Current;
9575 ASTIdentifierLookupTable::key_iterator End;
9582 bool SkipModules =
false);
9584 StringRef
Next()
override;
9591 : Reader(Reader), Index(Reader.ModuleMgr.size()), SkipModules(SkipModules) {
9595 while (Current == End) {
9607 Current = IdTable->key_begin();
9608 End = IdTable->key_end();
9613 StringRef
Result = *Current;
9622 std::unique_ptr<IdentifierIterator> Current;
9623 std::unique_ptr<IdentifierIterator> Queued;
9626 ChainedIdentifierIterator(std::unique_ptr<IdentifierIterator>
First,
9627 std::unique_ptr<IdentifierIterator> Second)
9628 : Current(
std::move(
First)), Queued(
std::move(Second)) {}
9630 StringRef
Next()
override {
9634 StringRef result = Current->Next();
9635 if (!result.empty())
9640 std::swap(Current, Queued);
9649 std::unique_ptr<IdentifierIterator> ReaderIter(
9651 std::unique_ptr<IdentifierIterator> ModulesIter(
9652 GlobalIndex->createIdentifierIterator());
9653 return new ChainedIdentifierIterator(std::move(ReaderIter),
9654 std::move(ModulesIter));
9666 unsigned PriorGeneration;
9667 unsigned InstanceBits = 0;
9668 unsigned FactoryBits = 0;
9669 bool InstanceHasMoreThanOneDecl =
false;
9670 bool FactoryHasMoreThanOneDecl =
false;
9676 unsigned PriorGeneration)
9677 : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) {}
9687 ++Reader.NumMethodPoolTableLookups;
9690 ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel);
9691 if (Pos == PoolTable->end())
9694 ++Reader.NumMethodPoolTableHits;
9695 ++Reader.NumSelectorsRead;
9699 ++Reader.NumMethodPoolEntriesRead;
9701 if (Reader.DeserializationListener)
9702 Reader.DeserializationListener->SelectorRead(
Data.ID, Sel);
9707 InstanceMethods.append(
Data.Instance.rbegin(),
Data.Instance.rend());
9708 FactoryMethods.append(
Data.Factory.rbegin(),
Data.Factory.rend());
9709 InstanceBits =
Data.InstanceBits;
9710 FactoryBits =
Data.FactoryBits;
9711 InstanceHasMoreThanOneDecl =
Data.InstanceHasMoreThanOneDecl;
9712 FactoryHasMoreThanOneDecl =
Data.FactoryHasMoreThanOneDecl;
9718 return InstanceMethods;
9723 return FactoryMethods;
9730 return InstanceHasMoreThanOneDecl;
9748 unsigned &Generation = SelectorGeneration[Sel];
9749 unsigned PriorGeneration = Generation;
9751 SelectorOutOfDate[Sel] =
false;
9754 ++NumMethodPoolLookups;
9756 ModuleMgr.visit(Visitor);
9762 ++NumMethodPoolHits;
9783 if (SelectorOutOfDate[Sel])
9791 for (
unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) {
9793 = dyn_cast_or_null<NamespaceDecl>(
GetDecl(KnownNamespaces[I])))
9794 Namespaces.push_back(Namespace);
9799 llvm::MapVector<NamedDecl *, SourceLocation> &
Undefined) {
9800 for (
unsigned Idx = 0, N = UndefinedButUsed.size(); Idx != N;) {
9801 UndefinedButUsedDecl &
U = UndefinedButUsed[Idx++];
9804 Undefined.insert(std::make_pair(D, Loc));
9806 UndefinedButUsed.clear();
9812 for (
unsigned Idx = 0, N = DelayedDeleteExprs.size(); Idx != N;) {
9815 uint64_t Count = DelayedDeleteExprs[Idx++];
9816 for (uint64_t
C = 0;
C < Count; ++
C) {
9819 const bool IsArrayForm = DelayedDeleteExprs[Idx++];
9820 Exprs[FD].push_back(std::make_pair(DeleteLoc, IsArrayForm));
9827 for (
unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) {
9828 VarDecl *Var = dyn_cast_or_null<VarDecl>(
GetDecl(TentativeDefinitions[I]));
9830 TentativeDefs.push_back(Var);
9832 TentativeDefinitions.clear();
9837 for (
unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++I) {
9839 = dyn_cast_or_null<DeclaratorDecl>(
GetDecl(UnusedFileScopedDecls[I]));
9843 UnusedFileScopedDecls.clear();
9848 for (
unsigned I = 0, N = DelegatingCtorDecls.size(); I != N; ++I) {
9850 = dyn_cast_or_null<CXXConstructorDecl>(
GetDecl(DelegatingCtorDecls[I]));
9854 DelegatingCtorDecls.clear();
9858 for (
unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++I) {
9860 = dyn_cast_or_null<TypedefNameDecl>(
GetDecl(ExtVectorDecls[I]));
9864 ExtVectorDecls.clear();
9868 llvm::SmallPtrSetImpl<const TypedefNameDecl *> &Decls) {
9869 for (
unsigned I = 0, N = UnusedLocalTypedefNameCandidates.size(); I != N;
9872 GetDecl(UnusedLocalTypedefNameCandidates[I]));
9876 UnusedLocalTypedefNameCandidates.clear();
9881 for (
auto I : DeclsToCheckForDeferredDiags) {
9882 auto *D = dyn_cast_or_null<Decl>(
GetDecl(I));
9886 DeclsToCheckForDeferredDiags.clear();
9891 if (ReferencedSelectorsData.empty())
9896 unsigned int DataSize = ReferencedSelectorsData.size()-1;
9898 while (I < DataSize) {
9902 Sels.push_back(std::make_pair(Sel, SelLoc));
9904 ReferencedSelectorsData.clear();
9909 if (WeakUndeclaredIdentifiers.empty())
9912 for (
unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; ) {
9920 WeakIDs.push_back(std::make_pair(WeakId, WI));
9922 WeakUndeclaredIdentifiers.clear();
9926 SmallVectorImpl<std::pair<IdentifierInfo *, AsmLabelAttr *>> &ExtnameIDs) {
9927 if (ExtnameUndeclaredIdentifiers.empty())
9930 for (
unsigned I = 0, N = ExtnameUndeclaredIdentifiers.size(); I < N; I += 3) {
9937 AsmLabelAttr *
Attr = AsmLabelAttr::CreateImplicit(
9941 ExtnameIDs.push_back(std::make_pair(NameId,
Attr));
9943 ExtnameUndeclaredIdentifiers.clear();
9947 for (
unsigned Idx = 0, N = VTableUses.size(); Idx < N; ) {
9949 VTableUse &TableInfo = VTableUses[Idx++];
9950 VT.
Record = dyn_cast_or_null<CXXRecordDecl>(
GetDecl(TableInfo.ID));
9953 VTables.push_back(VT);
9961 for (
unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
9962 PendingInstantiation &Inst = PendingInstantiations[Idx++];
9966 Pending.push_back(std::make_pair(D, Loc));
9968 PendingInstantiations.clear();
9972 llvm::MapVector<
const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
9974 for (
auto &LPT : LateParsedTemplates) {
9977 for (
unsigned Idx = 0, N = LateParsed.size(); Idx < N;
9981 auto LT = std::make_unique<LateParsedTemplate>();
9982 LT->D =
ReadDecl(*FMod, LateParsed, Idx);
9986 assert(F &&
"No module");
9988 unsigned TokN = LateParsed[Idx++];
9989 LT->Toks.reserve(TokN);
9990 for (
unsigned T = 0;
T < TokN; ++
T)
9991 LT->Toks.push_back(
ReadToken(*F, LateParsed, Idx));
9993 LPTMap.insert(std::make_pair(FD, std::move(LT)));
9997 LateParsedTemplates.clear();
10006 assert(ID &&
"Non-zero identifier ID required");
10007 unsigned Index = translateIdentifierIDToIndex(ID).second;
10008 assert(Index < IdentifiersLoaded.size() &&
"identifier ID out of range");
10009 IdentifiersLoaded[Index] = II;
10010 if (DeserializationListener)
10011 DeserializationListener->IdentifierRead(ID, II);
10033 if (NumCurrentElementsDeserializing && !Decls) {
10034 PendingIdentifierInfos[II].append(DeclIDs.begin(), DeclIDs.end());
10038 for (
unsigned I = 0, N = DeclIDs.size(); I != N; ++I) {
10051 Decls->push_back(D);
10058 pushExternalDeclIntoScope(D, II);
10062std::pair<ModuleFile *, unsigned>
10063ASTReader::translateIdentifierIDToIndex(
IdentifierID ID)
const {
10065 return {
nullptr, 0};
10067 unsigned ModuleFileIndex = ID >> 32;
10068 unsigned LocalID = ID & llvm::maskTrailingOnes<IdentifierID>(32);
10070 assert(ModuleFileIndex &&
"not translating loaded IdentifierID?");
10082 if (IdentifiersLoaded.empty()) {
10083 Error(
"no identifier table in AST file");
10087 auto [M, Index] = translateIdentifierIDToIndex(ID);
10088 if (!IdentifiersLoaded[Index]) {
10089 assert(M !=
nullptr &&
"Untranslated Identifier ID?");
10092 const unsigned char *
Data =
10097 auto Key = Trait.
ReadKey(
Data, KeyDataLen.first);
10098 auto &II = PP.getIdentifierTable().get(Key);
10099 IdentifiersLoaded[Index] = &II;
10102 if (DeserializationListener)
10103 DeserializationListener->IdentifierRead(ID, &II);
10106 return IdentifiersLoaded[Index];
10118 ReadModuleOffsetMap(M);
10120 unsigned ModuleFileIndex = LocalID >> 32;
10121 LocalID &= llvm::maskTrailingOnes<IdentifierID>(32);
10124 assert(MF &&
"malformed identifier ID encoding?");
10126 if (!ModuleFileIndex)
10132std::pair<ModuleFile *, unsigned>
10133ASTReader::translateMacroIDToIndex(
MacroID ID)
const {
10135 return {
nullptr, 0};
10137 unsigned ModuleFileIndex = ID >> 32;
10138 assert(ModuleFileIndex &&
"not translating loaded MacroID?");
10142 unsigned LocalID = ID & llvm::maskTrailingOnes<MacroID>(32);
10151 if (MacrosLoaded.empty()) {
10152 Error(
"no macro table in AST file");
10156 auto [M, Index] = translateMacroIDToIndex(ID);
10157 if (!MacrosLoaded[Index]) {
10158 assert(M !=
nullptr &&
"Untranslated Macro ID?");
10164 if (DeserializationListener)
10165 DeserializationListener->MacroRead(ID, MacrosLoaded[Index]);
10168 return MacrosLoaded[Index];
10176 ReadModuleOffsetMap(M);
10178 unsigned ModuleFileIndex = LocalID >> 32;
10179 LocalID &= llvm::maskTrailingOnes<MacroID>(32);
10182 assert(MF &&
"malformed identifier ID encoding?");
10184 if (!ModuleFileIndex) {
10189 return (
static_cast<MacroID>(MF->
Index + 1) << 32) | LocalID;
10198 ReadModuleOffsetMap(M);
10203 &&
"Invalid index into submodule index remap");
10205 return LocalID + I->second;
10216 return I == GlobalSubmoduleMap.end() ?
nullptr : I->second;
10219 int IndexFromEnd =
static_cast<int>(ID >> 1);
10220 assert(IndexFromEnd &&
"got reference to unknown module file");
10237 auto I = llvm::find(PCHModules, M);
10238 assert(I != PCHModules.end() &&
"emitting reference to unknown file");
10239 return std::distance(I, PCHModules.end()) << 1;
10248 const auto &PCHChain = ModuleMgr.pch_modules();
10249 if (std::distance(std::begin(PCHChain), std::end(PCHChain))) {
10250 ModuleFile &MF = ModuleMgr.getPrimaryModule();
10254 llvm::sys::path::parent_path(MF.
FileName),
10257 return std::nullopt;
10261 auto I = DefinitionSource.find(FD);
10262 if (I == DefinitionSource.end())
10268 return ThisDeclarationWasADefinitionSet.contains(FD);
10279 if (ID > SelectorsLoaded.size()) {
10280 Error(
"selector ID out of range in AST file");
10284 if (SelectorsLoaded[ID - 1].getAsOpaquePtr() ==
nullptr) {
10287 assert(I != GlobalSelectorMap.end() &&
"Corrupted global selector map");
10291 SelectorsLoaded[ID - 1] =
10293 if (DeserializationListener)
10294 DeserializationListener->SelectorRead(ID, SelectorsLoaded[ID - 1]);
10297 return SelectorsLoaded[ID - 1];
10315 ReadModuleOffsetMap(M);
10320 &&
"Invalid index into selector index remap");
10322 return LocalID + I->second;
10353 NameInfo.
setName(readDeclarationName());
10367 SpirvOperand Op(SpirvOperand::SpirvOperandKind(Kind), ResultType,
Value);
10368 assert(Op.isValid());
10374 unsigned NumTPLists =
readInt();
10379 for (
unsigned i = 0; i != NumTPLists; ++i)
10390 unsigned NumParams =
readInt();
10392 Params.reserve(NumParams);
10393 while (NumParams--)
10396 bool HasRequiresClause =
readBool();
10397 Expr *RequiresClause = HasRequiresClause ?
readExpr() :
nullptr;
10400 getContext(), TemplateLoc, LAngleLoc, Params, RAngleLoc, RequiresClause);
10401 return TemplateParams;
10406 bool Canonicalize) {
10407 unsigned NumTemplateArgs =
readInt();
10408 TemplArgs.reserve(NumTemplateArgs);
10409 while (NumTemplateArgs--)
10415 unsigned NumDecls =
readInt();
10417 while (NumDecls--) {
10429 bool inheritConstructors =
readBool();
10435 Result.setInheritConstructors(inheritConstructors);
10442 unsigned NumInitializers =
readInt();
10443 assert(NumInitializers &&
"wrote ctor initializers but have no inits");
10445 for (
unsigned i = 0; i != NumInitializers; ++i) {
10447 bool IsBaseVirtual =
false;
10478 BOMInit =
new (Context)
10480 RParenLoc, MemberOrEllipsisLoc);
10482 BOMInit =
new (Context)
10485 BOMInit =
new (Context)
10489 BOMInit =
new (Context)
10491 LParenLoc,
Init, RParenLoc);
10494 unsigned SourceOrder =
readInt();
10498 CtorInitializers[i] = BOMInit;
10501 return CtorInitializers;
10509 for (
unsigned I = 0; I != N; ++I) {
10510 auto Kind = readNestedNameSpecifierKind();
10515 Builder.Extend(Context, NS, Range.getBegin(), Range.getEnd());
10524 Builder.Make(Context,
T->getTypeLoc(), ColonColonLoc);
10530 Builder.MakeGlobal(Context, ColonColonLoc);
10537 Builder.MakeMicrosoftSuper(Context, RD, Range.getBegin(), Range.getEnd());
10542 llvm_unreachable(
"unexpected null nested name specifier");
10557 const StringRef Blob) {
10558 unsigned Count =
Record[0];
10559 const char *Byte = Blob.data();
10560 llvm::BitVector Ret = llvm::BitVector(Count,
false);
10561 for (
unsigned I = 0; I < Count; ++Byte)
10562 for (
unsigned Bit = 0; Bit < 8 && I < Count; ++Bit, ++I)
10563 if (*Byte & (1 << Bit))
10570 return llvm::APFloat(Sem,
readAPInt());
10575 unsigned Len =
Record[Idx++];
10583 unsigned Len =
Record[Idx++];
10584 StringRef
Result = Blob.substr(0, Len);
10585 Blob = Blob.substr(Len);
10609 unsigned Major =
Record[Idx++];
10610 unsigned Minor =
Record[Idx++];
10611 unsigned Subminor =
Record[Idx++];
10613 return VersionTuple(Major);
10615 return VersionTuple(Major, Minor - 1);
10616 return VersionTuple(Major, Minor - 1, Subminor - 1);
10627 return Diag(CurrentImportLoc, DiagID);
10631 return Diags.Report(Loc, DiagID);
10635 llvm::function_ref<
void()> Fn) {
10638 SemaObj->runWithSufficientStackSpace(Loc, Fn);
10642 StackHandler.runWithSufficientStackSpace(Loc, Fn);
10648 return PP.getIdentifierTable();
10654 assert((*CurrSwitchCaseStmts)[ID] ==
nullptr &&
10655 "Already have a SwitchCase with this ID");
10656 (*CurrSwitchCaseStmts)[ID] = SC;
10661 assert((*CurrSwitchCaseStmts)[ID] !=
nullptr &&
"No SwitchCase with this ID");
10662 return (*CurrSwitchCaseStmts)[ID];
10666 CurrSwitchCaseStmts->clear();
10671 std::vector<RawComment *> Comments;
10678 BitstreamCursor &Cursor = I->first;
10685 Cursor.advanceSkippingSubblocks(
10686 BitstreamCursor::AF_DontPopBlockAtEnd);
10688 Error(MaybeEntry.takeError());
10691 llvm::BitstreamEntry Entry = MaybeEntry.get();
10693 switch (Entry.Kind) {
10694 case llvm::BitstreamEntry::SubBlock:
10695 case llvm::BitstreamEntry::Error:
10696 Error(
"malformed block record in AST file");
10698 case llvm::BitstreamEntry::EndBlock:
10700 case llvm::BitstreamEntry::Record:
10708 if (!MaybeComment) {
10709 Error(MaybeComment.takeError());
10718 bool IsTrailingComment =
Record[Idx++];
10719 bool IsAlmostTrailingComment =
Record[Idx++];
10720 Comments.push_back(
new (Context)
RawComment(
10721 SR, Kind, IsTrailingComment, IsAlmostTrailingComment));
10731 if (Loc.first.isValid())
10732 Context.Comments.OrderedComments[Loc.first].emplace(Loc.second,
C);
10745 assert(NumUserInputs <= NumInputs);
10746 unsigned N = IncludeSystem ? NumInputs : NumUserInputs;
10747 for (
unsigned I = 0; I < N; ++I) {
10748 bool IsSystem = I >= NumUserInputs;
10750 Visitor(IFI, IsSystem);
10755 bool IncludeSystem,
bool Complain,
10757 bool isSystem)> Visitor) {
10760 assert(NumUserInputs <= NumInputs);
10761 unsigned N = IncludeSystem ? NumInputs : NumUserInputs;
10762 for (
unsigned I = 0; I < N; ++I) {
10763 bool IsSystem = I >= NumUserInputs;
10764 InputFile IF = getInputFile(MF, I+1, Complain);
10765 Visitor(IF, IsSystem);
10773 for (
unsigned I = 0; I < NumInputs; ++I) {
10776 if (
auto FE = getInputFile(MF, I + 1).getFile())
10781void ASTReader::finishPendingActions() {
10782 while (!PendingIdentifierInfos.empty() ||
10783 !PendingDeducedFunctionTypes.empty() ||
10784 !PendingDeducedVarTypes.empty() || !PendingDeclChains.empty() ||
10785 !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
10786 !PendingUpdateRecords.empty() ||
10787 !PendingObjCExtensionIvarRedeclarations.empty()) {
10790 using TopLevelDeclsMap =
10791 llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2>>;
10792 TopLevelDeclsMap TopLevelDecls;
10794 while (!PendingIdentifierInfos.empty()) {
10797 std::move(PendingIdentifierInfos.back().second);
10798 PendingIdentifierInfos.pop_back();
10805 for (
unsigned I = 0; I != PendingDeducedFunctionTypes.size(); ++I) {
10806 auto *FD = PendingDeducedFunctionTypes[I].first;
10807 FD->setType(
GetType(PendingDeducedFunctionTypes[I].second));
10809 if (
auto *DT = FD->getReturnType()->getContainedDeducedType()) {
10812 if (DT->isDeduced()) {
10813 PendingDeducedTypeUpdates.insert(
10814 {FD->getCanonicalDecl(), FD->getReturnType()});
10821 PendingUndeducedFunctionDecls.push_back(FD);
10825 PendingDeducedFunctionTypes.clear();
10829 for (
unsigned I = 0; I != PendingDeducedVarTypes.size(); ++I) {
10830 auto *VD = PendingDeducedVarTypes[I].first;
10831 VD->setType(
GetType(PendingDeducedVarTypes[I].second));
10833 PendingDeducedVarTypes.clear();
10836 for (
unsigned I = 0; I != PendingDeclChains.size(); ++I)
10837 loadPendingDeclChain(PendingDeclChains[I].first,
10838 PendingDeclChains[I].second);
10839 PendingDeclChains.clear();
10842 for (TopLevelDeclsMap::iterator TLD = TopLevelDecls.begin(),
10843 TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) {
10844 IdentifierInfo *II = TLD->first;
10845 for (
unsigned I = 0, N = TLD->second.size(); I != N; ++I) {
10851 for (
unsigned I = 0; I != PendingMacroIDs.size(); ++I) {
10852 IdentifierInfo *II = PendingMacroIDs.begin()[I].first;
10853 SmallVector<PendingMacroInfo, 2> GlobalIDs;
10854 GlobalIDs.swap(PendingMacroIDs.begin()[I].second);
10856 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
10858 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
10859 if (!Info.M->isModule())
10863 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
10865 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
10866 if (Info.M->isModule())
10870 PendingMacroIDs.clear();
10874 while (!PendingDeclContextInfos.empty()) {
10875 PendingDeclContextInfo Info = PendingDeclContextInfos.front();
10876 PendingDeclContextInfos.pop_front();
10879 Info.D->setDeclContextsImpl(SemaDC, LexicalDC,
getContext());
10883 while (!PendingUpdateRecords.empty()) {
10884 auto Update = PendingUpdateRecords.pop_back_val();
10885 ReadingKindTracker ReadingKind(Read_Decl, *
this);
10886 loadDeclUpdateRecords(
Update);
10889 while (!PendingObjCExtensionIvarRedeclarations.empty()) {
10890 auto ExtensionsPair = PendingObjCExtensionIvarRedeclarations.back().first;
10891 auto DuplicateIvars =
10892 PendingObjCExtensionIvarRedeclarations.back().second;
10894 StructuralEquivalenceContext Ctx(
10895 ContextObj->getLangOpts(), ExtensionsPair.first->getASTContext(),
10896 ExtensionsPair.second->getASTContext(), NonEquivalentDecls,
10900 if (Ctx.IsEquivalent(ExtensionsPair.first, ExtensionsPair.second)) {
10902 for (
auto IvarPair : DuplicateIvars) {
10903 ObjCIvarDecl *Ivar = IvarPair.first, *PrevIvar = IvarPair.second;
10905 Ivar->setDeclContextsImpl(PrevIvar->getDeclContext(),
10911 ExtensionsPair.first->setInvalidDecl();
10912 ExtensionsPair.second->getClassInterface()
10914 ->setIvarList(
nullptr);
10916 for (
auto IvarPair : DuplicateIvars) {
10917 Diag(IvarPair.first->getLocation(),
10918 diag::err_duplicate_ivar_declaration)
10919 << IvarPair.first->getIdentifier();
10920 Diag(IvarPair.second->getLocation(), diag::note_previous_definition);
10923 PendingObjCExtensionIvarRedeclarations.pop_back();
10929 assert(PendingFakeDefinitionData.empty() &&
10930 "faked up a class definition but never saw the real one");
10936 for (Decl *D : PendingDefinitions) {
10937 if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
10938 if (
auto *RD = dyn_cast<CXXRecordDecl>(TD)) {
10939 for (
auto *R = getMostRecentExistingDecl(RD);
R;
10940 R =
R->getPreviousDecl()) {
10943 "declaration thinks it's the definition but it isn't");
10951 if (
auto ID = dyn_cast<ObjCInterfaceDecl>(D)) {
10956 for (
auto *R = getMostRecentExistingDecl(ID);
R;
R =
R->getPreviousDecl())
10962 if (
auto PD = dyn_cast<ObjCProtocolDecl>(D)) {
10963 for (
auto *R = getMostRecentExistingDecl(PD);
R;
R =
R->getPreviousDecl())
10970 for (
auto *R = getMostRecentExistingDecl(RTD);
R;
R =
R->getPreviousDecl())
10973 PendingDefinitions.clear();
10975 for (
auto [D,
Previous] : PendingWarningForDuplicatedDefsInModuleUnits) {
10976 auto hasDefinitionImpl = [
this](
Decl *D,
auto hasDefinitionImpl) {
10977 if (
auto *VD = dyn_cast<VarDecl>(D))
10978 return VD->isThisDeclarationADefinition() ||
10979 VD->isThisDeclarationADemotedDefinition();
10981 if (
auto *TD = dyn_cast<TagDecl>(D))
10982 return TD->isThisDeclarationADefinition() ||
10983 TD->isThisDeclarationADemotedDefinition();
10985 if (
auto *FD = dyn_cast<FunctionDecl>(D))
10986 return FD->isThisDeclarationADefinition() || PendingBodies.count(FD);
10988 if (
auto *RTD = dyn_cast<RedeclarableTemplateDecl>(D))
10989 return hasDefinitionImpl(RTD->getTemplatedDecl(), hasDefinitionImpl);
10996 return hasDefinitionImpl(D, hasDefinitionImpl);
11012 PendingWarningForDuplicatedDefsInModuleUnits.clear();
11018 for (PendingBodiesMap::iterator PB = PendingBodies.begin(),
11019 PBEnd = PendingBodies.end();
11020 PB != PBEnd; ++PB) {
11021 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
11023 const FunctionDecl *Defn =
nullptr;
11024 if (!
getContext().getLangOpts().Modules || !FD->hasBody(Defn)) {
11025 FD->setLazyBody(PB->second);
11027 auto *NonConstDefn =
const_cast<FunctionDecl*
>(Defn);
11030 if (!FD->isLateTemplateParsed() &&
11031 !NonConstDefn->isLateTemplateParsed() &&
11036 FD->getODRHash() != NonConstDefn->getODRHash()) {
11038 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
11039 }
else if (FD->getLexicalParent()->isFileContext() &&
11040 NonConstDefn->getLexicalParent()->isFileContext()) {
11044 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
11055 PendingBodies.clear();
11058 for (
auto [RD, MD] : PendingAddedClassMembers) {
11066 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(MD)) {
11067 if (!Ctor->isInheritingConstructor()) {
11068 if (Ctor->isDefaultConstructor()) {
11073 if (Ctor->isCopyConstructor()) {
11078 if (Ctor->isMoveConstructor()) {
11084 }
else if (
const auto *Mthd = dyn_cast<CXXMethodDecl>(MD)) {
11090 if (Mthd->isCopyAssignmentOperator()) {
11095 if (Mthd->isMoveAssignmentOperator()) {
11102 if (
auto *FD = dyn_cast<FunctionDecl>(MD)) {
11106 auto needToAddMD =
true;
11108 if (
auto *RDFD = dyn_cast<FunctionDecl>(RDD)) {
11109 if (FD->getODRHash() == RDFD->getODRHash()) {
11110 needToAddMD =
false;
11123 RD->addedMember(MD);
11125 PendingAddedClassMembers.clear();
11128 for (
auto *ND : PendingMergedDefinitionsToDeduplicate)
11130 PendingMergedDefinitionsToDeduplicate.clear();
11134 for (Decl *D : PendingIncompleteDeclChains)
11135 markIncompleteDeclChain(D);
11136 PendingIncompleteDeclChains.clear();
11138 assert(PendingIdentifierInfos.empty() &&
11139 "Should be empty at the end of finishPendingActions");
11140 assert(PendingDeducedFunctionTypes.empty() &&
11141 "Should be empty at the end of finishPendingActions");
11142 assert(PendingDeducedVarTypes.empty() &&
11143 "Should be empty at the end of finishPendingActions");
11144 assert(PendingDeclChains.empty() &&
11145 "Should be empty at the end of finishPendingActions");
11146 assert(PendingMacroIDs.empty() &&
11147 "Should be empty at the end of finishPendingActions");
11148 assert(PendingDeclContextInfos.empty() &&
11149 "Should be empty at the end of finishPendingActions");
11150 assert(PendingUpdateRecords.empty() &&
11151 "Should be empty at the end of finishPendingActions");
11152 assert(PendingObjCExtensionIvarRedeclarations.empty() &&
11153 "Should be empty at the end of finishPendingActions");
11154 assert(PendingFakeDefinitionData.empty() &&
11155 "Should be empty at the end of finishPendingActions");
11156 assert(PendingDefinitions.empty() &&
11157 "Should be empty at the end of finishPendingActions");
11158 assert(PendingWarningForDuplicatedDefsInModuleUnits.empty() &&
11159 "Should be empty at the end of finishPendingActions");
11160 assert(PendingBodies.empty() &&
11161 "Should be empty at the end of finishPendingActions");
11162 assert(PendingAddedClassMembers.empty() &&
11163 "Should be empty at the end of finishPendingActions");
11164 assert(PendingMergedDefinitionsToDeduplicate.empty() &&
11165 "Should be empty at the end of finishPendingActions");
11166 assert(PendingIncompleteDeclChains.empty() &&
11167 "Should be empty at the end of finishPendingActions");
11170void ASTReader::diagnoseOdrViolations() {
11171 if (PendingOdrMergeFailures.empty() && PendingOdrMergeChecks.empty() &&
11172 PendingRecordOdrMergeFailures.empty() &&
11173 PendingFunctionOdrMergeFailures.empty() &&
11174 PendingEnumOdrMergeFailures.empty() &&
11175 PendingObjCInterfaceOdrMergeFailures.empty() &&
11176 PendingObjCProtocolOdrMergeFailures.empty())
11183 auto OdrMergeFailures = std::move(PendingOdrMergeFailures);
11184 PendingOdrMergeFailures.clear();
11185 for (
auto &Merge : OdrMergeFailures) {
11186 Merge.first->buildLookup();
11187 Merge.first->decls_begin();
11188 Merge.first->bases_begin();
11189 Merge.first->vbases_begin();
11190 for (
auto &RecordPair : Merge.second) {
11191 auto *RD = RecordPair.first;
11199 auto RecordOdrMergeFailures = std::move(PendingRecordOdrMergeFailures);
11200 PendingRecordOdrMergeFailures.clear();
11201 for (
auto &Merge : RecordOdrMergeFailures) {
11202 Merge.first->decls_begin();
11203 for (
auto &D : Merge.second)
11208 auto ObjCInterfaceOdrMergeFailures =
11209 std::move(PendingObjCInterfaceOdrMergeFailures);
11210 PendingObjCInterfaceOdrMergeFailures.clear();
11211 for (
auto &Merge : ObjCInterfaceOdrMergeFailures) {
11212 Merge.first->decls_begin();
11213 for (
auto &InterfacePair : Merge.second)
11214 InterfacePair.first->decls_begin();
11218 auto FunctionOdrMergeFailures = std::move(PendingFunctionOdrMergeFailures);
11219 PendingFunctionOdrMergeFailures.clear();
11220 for (
auto &Merge : FunctionOdrMergeFailures) {
11221 Merge.first->buildLookup();
11222 Merge.first->decls_begin();
11223 Merge.first->getBody();
11224 for (
auto &FD : Merge.second) {
11232 auto EnumOdrMergeFailures = std::move(PendingEnumOdrMergeFailures);
11233 PendingEnumOdrMergeFailures.clear();
11234 for (
auto &Merge : EnumOdrMergeFailures) {
11235 Merge.first->decls_begin();
11236 for (
auto &
Enum : Merge.second) {
11237 Enum->decls_begin();
11242 auto ObjCProtocolOdrMergeFailures =
11243 std::move(PendingObjCProtocolOdrMergeFailures);
11244 PendingObjCProtocolOdrMergeFailures.clear();
11245 for (
auto &Merge : ObjCProtocolOdrMergeFailures) {
11246 Merge.first->decls_begin();
11247 for (
auto &ProtocolPair : Merge.second)
11248 ProtocolPair.first->decls_begin();
11257 while (!PendingOdrMergeChecks.empty()) {
11258 NamedDecl *D = PendingOdrMergeChecks.pop_back_val();
11269 bool Found =
false;
11272 for (
auto *RI : D->
redecls()) {
11273 if (RI->getLexicalDeclContext() == CanonDef) {
11287 llvm::SmallVector<const NamedDecl*, 4> Candidates;
11288 for (
auto *CanonMember : CanonDef->
decls()) {
11289 if (CanonMember->getCanonicalDecl() == DCanon) {
11298 if (
auto *ND = dyn_cast<NamedDecl>(CanonMember))
11300 Candidates.push_back(ND);
11313 std::string CanonDefModule =
11318 << CanonDef << CanonDefModule.empty() << CanonDefModule;
11320 if (Candidates.empty())
11322 diag::note_module_odr_violation_no_possible_decls) << D;
11324 for (
unsigned I = 0, N = Candidates.size(); I != N; ++I)
11325 Diag(Candidates[I]->getLocation(),
11326 diag::note_module_odr_violation_possible_decl)
11330 DiagnosedOdrMergeFailures.insert(CanonDef);
11334 if (OdrMergeFailures.empty() && RecordOdrMergeFailures.empty() &&
11335 FunctionOdrMergeFailures.empty() && EnumOdrMergeFailures.empty() &&
11336 ObjCInterfaceOdrMergeFailures.empty() &&
11337 ObjCProtocolOdrMergeFailures.empty())
11340 ODRDiagsEmitter DiagsEmitter(Diags,
getContext(),
11344 for (
auto &Merge : OdrMergeFailures) {
11347 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
11350 bool Diagnosed =
false;
11351 CXXRecordDecl *FirstRecord = Merge.first;
11352 for (
auto &RecordPair : Merge.second) {
11353 if (DiagsEmitter.diagnoseMismatch(FirstRecord, RecordPair.first,
11354 RecordPair.second)) {
11367 Diag(Merge.first->getLocation(),
11368 diag::err_module_odr_violation_different_instantiations)
11375 for (
auto &Merge : RecordOdrMergeFailures) {
11378 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
11381 RecordDecl *FirstRecord = Merge.first;
11382 bool Diagnosed =
false;
11383 for (
auto *SecondRecord : Merge.second) {
11384 if (DiagsEmitter.diagnoseMismatch(FirstRecord, SecondRecord)) {
11390 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
11394 for (
auto &Merge : FunctionOdrMergeFailures) {
11395 FunctionDecl *FirstFunction = Merge.first;
11396 bool Diagnosed =
false;
11397 for (
auto &SecondFunction : Merge.second) {
11398 if (DiagsEmitter.diagnoseMismatch(FirstFunction, SecondFunction)) {
11404 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
11408 for (
auto &Merge : EnumOdrMergeFailures) {
11411 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
11414 EnumDecl *FirstEnum = Merge.first;
11415 bool Diagnosed =
false;
11416 for (
auto &SecondEnum : Merge.second) {
11417 if (DiagsEmitter.diagnoseMismatch(FirstEnum, SecondEnum)) {
11423 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
11426 for (
auto &Merge : ObjCInterfaceOdrMergeFailures) {
11429 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
11432 bool Diagnosed =
false;
11433 ObjCInterfaceDecl *FirstID = Merge.first;
11434 for (
auto &InterfacePair : Merge.second) {
11435 if (DiagsEmitter.diagnoseMismatch(FirstID, InterfacePair.first,
11436 InterfacePair.second)) {
11442 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
11445 for (
auto &Merge : ObjCProtocolOdrMergeFailures) {
11448 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
11451 ObjCProtocolDecl *FirstProtocol = Merge.first;
11452 bool Diagnosed =
false;
11453 for (
auto &ProtocolPair : Merge.second) {
11454 if (DiagsEmitter.diagnoseMismatch(FirstProtocol, ProtocolPair.first,
11455 ProtocolPair.second)) {
11461 assert(Diagnosed &&
"Unable to emit ODR diagnostic.");
11466 if (llvm::Timer *
T = ReadTimer.get();
11467 ++NumCurrentElementsDeserializing == 1 &&
T)
11468 ReadTimeRegion.emplace(
T);
11472 assert(NumCurrentElementsDeserializing &&
11473 "FinishedDeserializing not paired with StartedDeserializing");
11474 if (NumCurrentElementsDeserializing == 1) {
11477 finishPendingActions();
11479 --NumCurrentElementsDeserializing;
11481 if (NumCurrentElementsDeserializing == 0) {
11485 SaveAndRestore GuardPassingDeclsToConsumer(CanPassDeclsToConsumer,
11493 while (!PendingExceptionSpecUpdates.empty() ||
11494 !PendingDeducedTypeUpdates.empty() ||
11495 !PendingUndeducedFunctionDecls.empty()) {
11496 auto ESUpdates = std::move(PendingExceptionSpecUpdates);
11497 PendingExceptionSpecUpdates.clear();
11498 for (
auto Update : ESUpdates) {
11499 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
11502 if (
auto *Listener =
getContext().getASTMutationListener())
11504 for (
auto *Redecl :
Update.second->redecls())
11508 auto DTUpdates = std::move(PendingDeducedTypeUpdates);
11509 PendingDeducedTypeUpdates.clear();
11510 for (
auto Update : DTUpdates) {
11511 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
11518 auto UDTUpdates = std::move(PendingUndeducedFunctionDecls);
11519 PendingUndeducedFunctionDecls.clear();
11523 (void)UndeducedFD->getMostRecentDecl();
11526 ReadTimeRegion.reset();
11528 diagnoseOdrViolations();
11534 PassInterestingDeclsToConsumer();
11541 auto It = PendingFakeLookupResults.find(II);
11542 if (It != PendingFakeLookupResults.end()) {
11543 for (
auto *ND : It->second)
11548 It->second.clear();
11552 if (SemaObj->IdResolver.tryAddTopLevelDecl(D, Name) && SemaObj->TUScope) {
11553 SemaObj->TUScope->AddDecl(D);
11554 }
else if (SemaObj->TUScope) {
11558 if (llvm::is_contained(SemaObj->IdResolver.decls(Name), D))
11559 SemaObj->TUScope->AddDecl(D);
11567 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
11568 StringRef isysroot,
11570 bool AllowASTWithCompilerErrors,
11571 bool AllowConfigurationMismatch,
bool ValidateSystemInputs,
11572 bool ForceValidateUserInputs,
11573 bool ValidateASTInputFilesContent,
bool UseGlobalIndex,
11574 std::unique_ptr<llvm::Timer> ReadTimer)
11579 PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()),
11580 StackHandler(Diags), PP(PP), ContextObj(Context),
11581 CodeGenOpts(CodeGenOpts),
11583 PP.getHeaderSearchInfo()),
11584 DummyIdResolver(PP), ReadTimer(
std::move(ReadTimer)), isysroot(isysroot),
11585 DisableValidationKind(DisableValidationKind),
11586 AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
11587 AllowConfigurationMismatch(AllowConfigurationMismatch),
11588 ValidateSystemInputs(ValidateSystemInputs),
11589 ForceValidateUserInputs(ForceValidateUserInputs),
11590 ValidateASTInputFilesContent(ValidateASTInputFilesContent),
11591 UseGlobalIndex(UseGlobalIndex), CurrSwitchCaseStmts(&SwitchCaseStmts) {
11592 SourceMgr.setExternalSLocEntrySource(
this);
11594 PathBuf.reserve(256);
11596 for (
const auto &Ext : Extensions) {
11597 auto BlockName = Ext->getExtensionMetadata().BlockName;
11598 auto Known = ModuleFileExtensions.find(BlockName);
11599 if (
Known != ModuleFileExtensions.end()) {
11600 Diags.Report(diag::warn_duplicate_module_file_extension)
11605 ModuleFileExtensions.insert({BlockName, Ext});
11610 if (OwnsDeserializationListener)
11611 delete DeserializationListener;
11615 return SemaObj ? SemaObj->IdResolver : DummyIdResolver;
11619 unsigned AbbrevID) {
11622 return Cursor.readRecord(AbbrevID, Record);
11638 : Record(Record), Context(Record.getContext()) {}
11639#define GEN_CLANG_CLAUSE_CLASS
11640#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *C);
11641#include "llvm/Frontend/OpenMP/OMP.inc"
11655 switch (llvm::omp::Clause(Record.readInt())) {
11656 case llvm::omp::OMPC_if:
11659 case llvm::omp::OMPC_final:
11662 case llvm::omp::OMPC_num_threads:
11665 case llvm::omp::OMPC_safelen:
11668 case llvm::omp::OMPC_simdlen:
11671 case llvm::omp::OMPC_sizes: {
11672 unsigned NumSizes = Record.readInt();
11676 case llvm::omp::OMPC_counts: {
11677 unsigned NumCounts = Record.readInt();
11681 case llvm::omp::OMPC_permutation: {
11682 unsigned NumLoops = Record.readInt();
11686 case llvm::omp::OMPC_full:
11689 case llvm::omp::OMPC_partial:
11692 case llvm::omp::OMPC_depth:
11695 case llvm::omp::OMPC_looprange:
11698 case llvm::omp::OMPC_allocator:
11701 case llvm::omp::OMPC_collapse:
11704 case llvm::omp::OMPC_default:
11707 case llvm::omp::OMPC_proc_bind:
11708 C =
new (Context) OMPProcBindClause();
11710 case llvm::omp::OMPC_schedule:
11711 C =
new (Context) OMPScheduleClause();
11713 case llvm::omp::OMPC_ordered:
11714 C = OMPOrderedClause::CreateEmpty(Context, Record.readInt());
11716 case llvm::omp::OMPC_nowait:
11717 C =
new (Context) OMPNowaitClause();
11719 case llvm::omp::OMPC_untied:
11720 C =
new (Context) OMPUntiedClause();
11722 case llvm::omp::OMPC_mergeable:
11723 C =
new (Context) OMPMergeableClause();
11725 case llvm::omp::OMPC_threadset:
11728 case llvm::omp::OMPC_transparent:
11729 C =
new (Context) OMPTransparentClause();
11731 case llvm::omp::OMPC_read:
11732 C =
new (Context) OMPReadClause();
11734 case llvm::omp::OMPC_write:
11735 C =
new (Context) OMPWriteClause();
11737 case llvm::omp::OMPC_update:
11738 C =
new (Context) OMPUpdateClause();
11740 case llvm::omp::OMPC_update_depend_objects:
11741 C = OMPUpdateDependObjectsClause::CreateEmpty(Context);
11743 case llvm::omp::OMPC_capture:
11744 C =
new (Context) OMPCaptureClause();
11746 case llvm::omp::OMPC_compare:
11747 C =
new (Context) OMPCompareClause();
11749 case llvm::omp::OMPC_fail:
11750 C =
new (Context) OMPFailClause();
11752 case llvm::omp::OMPC_seq_cst:
11753 C =
new (Context) OMPSeqCstClause();
11755 case llvm::omp::OMPC_acq_rel:
11756 C =
new (Context) OMPAcqRelClause();
11758 case llvm::omp::OMPC_absent: {
11759 unsigned NumKinds = Record.readInt();
11760 C = OMPAbsentClause::CreateEmpty(Context, NumKinds);
11763 case llvm::omp::OMPC_holds:
11764 C =
new (Context) OMPHoldsClause();
11766 case llvm::omp::OMPC_contains: {
11767 unsigned NumKinds = Record.readInt();
11768 C = OMPContainsClause::CreateEmpty(Context, NumKinds);
11771 case llvm::omp::OMPC_no_openmp:
11772 C =
new (Context) OMPNoOpenMPClause();
11774 case llvm::omp::OMPC_no_openmp_routines:
11775 C =
new (Context) OMPNoOpenMPRoutinesClause();
11777 case llvm::omp::OMPC_no_openmp_constructs:
11778 C =
new (Context) OMPNoOpenMPConstructsClause();
11780 case llvm::omp::OMPC_no_parallelism:
11781 C =
new (Context) OMPNoParallelismClause();
11783 case llvm::omp::OMPC_acquire:
11784 C =
new (Context) OMPAcquireClause();
11786 case llvm::omp::OMPC_release:
11787 C =
new (Context) OMPReleaseClause();
11789 case llvm::omp::OMPC_relaxed:
11790 C =
new (Context) OMPRelaxedClause();
11792 case llvm::omp::OMPC_weak:
11793 C =
new (Context) OMPWeakClause();
11795 case llvm::omp::OMPC_threads:
11798 case llvm::omp::OMPC_simd:
11801 case llvm::omp::OMPC_nogroup:
11804 case llvm::omp::OMPC_unified_address:
11805 C =
new (Context) OMPUnifiedAddressClause();
11807 case llvm::omp::OMPC_unified_shared_memory:
11808 C =
new (Context) OMPUnifiedSharedMemoryClause();
11810 case llvm::omp::OMPC_reverse_offload:
11811 C =
new (Context) OMPReverseOffloadClause();
11813 case llvm::omp::OMPC_dynamic_allocators:
11814 C =
new (Context) OMPDynamicAllocatorsClause();
11816 case llvm::omp::OMPC_atomic_default_mem_order:
11817 C =
new (Context) OMPAtomicDefaultMemOrderClause();
11819 case llvm::omp::OMPC_self_maps:
11820 C =
new (Context) OMPSelfMapsClause();
11822 case llvm::omp::OMPC_at:
11823 C =
new (Context) OMPAtClause();
11825 case llvm::omp::OMPC_severity:
11826 C =
new (Context) OMPSeverityClause();
11828 case llvm::omp::OMPC_message:
11829 C =
new (Context) OMPMessageClause();
11831 case llvm::omp::OMPC_private:
11832 C = OMPPrivateClause::CreateEmpty(Context, Record.readInt());
11834 case llvm::omp::OMPC_firstprivate:
11835 C = OMPFirstprivateClause::CreateEmpty(Context, Record.readInt());
11837 case llvm::omp::OMPC_lastprivate:
11838 C = OMPLastprivateClause::CreateEmpty(Context, Record.readInt());
11840 case llvm::omp::OMPC_shared:
11841 C = OMPSharedClause::CreateEmpty(Context, Record.readInt());
11843 case llvm::omp::OMPC_reduction: {
11844 unsigned N = Record.readInt();
11846 C = OMPReductionClause::CreateEmpty(Context, N, Modifier);
11849 case llvm::omp::OMPC_task_reduction:
11850 C = OMPTaskReductionClause::CreateEmpty(Context, Record.readInt());
11852 case llvm::omp::OMPC_in_reduction:
11853 C = OMPInReductionClause::CreateEmpty(Context, Record.readInt());
11855 case llvm::omp::OMPC_linear:
11856 C = OMPLinearClause::CreateEmpty(Context, Record.readInt());
11858 case llvm::omp::OMPC_aligned:
11861 case llvm::omp::OMPC_copyin:
11864 case llvm::omp::OMPC_copyprivate:
11867 case llvm::omp::OMPC_flush:
11870 case llvm::omp::OMPC_depobj:
11873 case llvm::omp::OMPC_depend: {
11874 unsigned NumVars = Record.readInt();
11875 unsigned NumLoops = Record.readInt();
11879 case llvm::omp::OMPC_device:
11882 case llvm::omp::OMPC_map: {
11884 Sizes.
NumVars = Record.readInt();
11891 case llvm::omp::OMPC_num_teams:
11894 case llvm::omp::OMPC_thread_limit:
11897 case llvm::omp::OMPC_priority:
11900 case llvm::omp::OMPC_grainsize:
11903 case llvm::omp::OMPC_num_tasks:
11906 case llvm::omp::OMPC_hint:
11909 case llvm::omp::OMPC_dist_schedule:
11912 case llvm::omp::OMPC_defaultmap:
11915 case llvm::omp::OMPC_to: {
11917 Sizes.
NumVars = Record.readInt();
11924 case llvm::omp::OMPC_from: {
11926 Sizes.
NumVars = Record.readInt();
11933 case llvm::omp::OMPC_use_device_ptr: {
11935 Sizes.
NumVars = Record.readInt();
11942 case llvm::omp::OMPC_use_device_addr: {
11944 Sizes.
NumVars = Record.readInt();
11951 case llvm::omp::OMPC_is_device_ptr: {
11953 Sizes.
NumVars = Record.readInt();
11960 case llvm::omp::OMPC_has_device_addr: {
11962 Sizes.
NumVars = Record.readInt();
11969 case llvm::omp::OMPC_allocate:
11972 case llvm::omp::OMPC_nontemporal:
11975 case llvm::omp::OMPC_inclusive:
11978 case llvm::omp::OMPC_exclusive:
11981 case llvm::omp::OMPC_order:
11984 case llvm::omp::OMPC_init: {
11985 unsigned VarListSize = Record.readInt();
11986 unsigned NumAttrs = Record.readInt();
11991 case llvm::omp::OMPC_use:
11994 case llvm::omp::OMPC_destroy:
11997 case llvm::omp::OMPC_novariants:
12000 case llvm::omp::OMPC_nocontext:
12003 case llvm::omp::OMPC_detach:
12006 case llvm::omp::OMPC_uses_allocators:
12009 case llvm::omp::OMPC_affinity:
12012 case llvm::omp::OMPC_filter:
12015 case llvm::omp::OMPC_bind:
12018 case llvm::omp::OMPC_align:
12021 case llvm::omp::OMPC_ompx_dyn_cgroup_mem:
12024 case llvm::omp::OMPC_dyn_groupprivate:
12027 case llvm::omp::OMPC_doacross: {
12028 unsigned NumVars = Record.readInt();
12029 unsigned NumLoops = Record.readInt();
12033 case llvm::omp::OMPC_ompx_attribute:
12036 case llvm::omp::OMPC_ompx_bare:
12039#define OMP_CLAUSE_NO_CLASS(Enum, Str) \
12040 case llvm::omp::Enum: \
12042#include "llvm/Frontend/OpenMP/OMPKinds.def"
12046 assert(
C &&
"Unknown OMPClause type");
12049 C->setLocStart(Record.readSourceLocation());
12050 C->setLocEnd(Record.readSourceLocation());
12056 C->setPreInitStmt(Record.readSubStmt(),
12062 C->setPostUpdateExpr(Record.readSubExpr());
12065void OMPClauseReader::VisitOMPIfClause(
OMPIfClause *
C) {
12068 C->setNameModifierLoc(
Record.readSourceLocation());
12069 C->setColonLoc(
Record.readSourceLocation());
12070 C->setCondition(
Record.readSubExpr());
12071 C->setLParenLoc(
Record.readSourceLocation());
12076 C->setCondition(
Record.readSubExpr());
12077 C->setLParenLoc(
Record.readSourceLocation());
12081 C->setPrescriptivenessModifier(
12083 C->setPrescriptivenessModifierLoc(Record.readSourceLocation());
12085 C->setDimsModifierLoc(Record.readSourceLocation());
12086 C->setDimsModifierExpr(Record.readSubExpr());
12088 C->setLParenLoc(Record.readSourceLocation());
12089 unsigned NumVars =
C->varlist_size();
12090 SmallVector<Expr *, 16> Vars;
12091 Vars.reserve(NumVars);
12092 for (
unsigned I = 0; I != NumVars; ++I)
12093 Vars.push_back(Record.readSubExpr());
12094 C->setVarRefs(Vars);
12098 C->setSafelen(Record.readSubExpr());
12099 C->setLParenLoc(Record.readSourceLocation());
12103 C->setSimdlen(Record.readSubExpr());
12104 C->setLParenLoc(Record.readSourceLocation());
12108 for (Expr *&E :
C->getSizesRefs())
12109 E = Record.readSubExpr();
12110 C->setLParenLoc(Record.readSourceLocation());
12114 bool HasFill = Record.readBool();
12116 C->setOmpFillIndex(Record.readInt());
12117 C->setOmpFillLoc(Record.readSourceLocation());
12118 for (Expr *&E :
C->getCountsRefs())
12119 E = Record.readSubExpr();
12120 C->setLParenLoc(Record.readSourceLocation());
12124 for (Expr *&E :
C->getArgsRefs())
12125 E = Record.readSubExpr();
12126 C->setLParenLoc(Record.readSourceLocation());
12132 C->setFactor(Record.readSubExpr());
12133 C->setLParenLoc(Record.readSourceLocation());
12137 C->setDepth(Record.readSubExpr());
12138 C->setLParenLoc(Record.readSourceLocation());
12142 C->setFirst(Record.readSubExpr());
12143 C->setCount(Record.readSubExpr());
12144 C->setLParenLoc(Record.readSourceLocation());
12145 C->setFirstLoc(Record.readSourceLocation());
12146 C->setCountLoc(Record.readSourceLocation());
12150 C->setAllocator(Record.readExpr());
12151 C->setLParenLoc(Record.readSourceLocation());
12155 C->setNumForLoops(Record.readSubExpr());
12156 C->setLParenLoc(Record.readSourceLocation());
12160 C->setDefaultKind(
static_cast<llvm::omp::DefaultKind
>(Record.readInt()));
12161 C->setLParenLoc(Record.readSourceLocation());
12162 C->setDefaultKindKwLoc(Record.readSourceLocation());
12163 C->setDefaultVariableCategory(
12165 C->setDefaultVariableCategoryLocation(Record.readSourceLocation());
12171 C->setLParenLoc(Record.readSourceLocation());
12172 SourceLocation ThreadsetKindLoc = Record.readSourceLocation();
12173 C->setThreadsetKindLoc(ThreadsetKindLoc);
12176 C->setThreadsetKind(TKind);
12179void OMPClauseReader::VisitOMPTransparentClause(OMPTransparentClause *
C) {
12180 C->setLParenLoc(Record.readSourceLocation());
12181 C->setImpexTypeKind(Record.readSubExpr());
12184void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *
C) {
12185 C->setProcBindKind(
static_cast<llvm::omp::ProcBindKind
>(Record.readInt()));
12186 C->setLParenLoc(Record.readSourceLocation());
12187 C->setProcBindKindKwLoc(Record.readSourceLocation());
12190void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *
C) {
12192 C->setScheduleKind(
12194 C->setFirstScheduleModifier(
12196 C->setSecondScheduleModifier(
12198 C->setChunkSize(Record.readSubExpr());
12199 C->setLParenLoc(Record.readSourceLocation());
12200 C->setFirstScheduleModifierLoc(Record.readSourceLocation());
12201 C->setSecondScheduleModifierLoc(Record.readSourceLocation());
12202 C->setScheduleKindLoc(Record.readSourceLocation());
12203 C->setCommaLoc(Record.readSourceLocation());
12206void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *
C) {
12207 C->setNumForLoops(Record.readSubExpr());
12208 for (
unsigned I = 0, E =
C->NumberOfLoops; I < E; ++I)
12209 C->setLoopNumIterations(I, Record.readSubExpr());
12210 for (
unsigned I = 0, E =
C->NumberOfLoops; I < E; ++I)
12211 C->setLoopCounter(I, Record.readSubExpr());
12212 C->setLParenLoc(Record.readSourceLocation());
12215void OMPClauseReader::VisitOMPDetachClause(OMPDetachClause *
C) {
12216 C->setEventHandler(Record.readSubExpr());
12217 C->setLParenLoc(Record.readSourceLocation());
12220void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *
C) {
12221 C->setCondition(Record.readSubExpr());
12222 C->setLParenLoc(Record.readSourceLocation());
12225void OMPClauseReader::VisitOMPUntiedClause(OMPUntiedClause *) {}
12227void OMPClauseReader::VisitOMPMergeableClause(OMPMergeableClause *) {}
12229void OMPClauseReader::VisitOMPReadClause(OMPReadClause *) {}
12231void OMPClauseReader::VisitOMPWriteClause(OMPWriteClause *) {}
12233void OMPClauseReader::VisitOMPUpdateClause(OMPUpdateClause *) {}
12235void OMPClauseReader::VisitOMPUpdateDependObjectsClause(
12236 OMPUpdateDependObjectsClause *
C) {
12237 C->setLParenLoc(Record.readSourceLocation());
12238 C->setArgumentLoc(Record.readSourceLocation());
12242void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}
12244void OMPClauseReader::VisitOMPCompareClause(OMPCompareClause *) {}
12248void OMPClauseReader::VisitOMPFailClause(OMPFailClause *
C) {
12249 C->setLParenLoc(Record.readSourceLocation());
12250 SourceLocation FailParameterLoc = Record.readSourceLocation();
12251 C->setFailParameterLoc(FailParameterLoc);
12253 C->setFailParameter(CKind);
12256void OMPClauseReader::VisitOMPAbsentClause(OMPAbsentClause *
C) {
12257 unsigned Count =
C->getDirectiveKinds().size();
12258 C->setLParenLoc(Record.readSourceLocation());
12259 llvm::SmallVector<OpenMPDirectiveKind, 4> DKVec;
12260 DKVec.reserve(Count);
12261 for (
unsigned I = 0; I < Count; I++) {
12264 C->setDirectiveKinds(DKVec);
12267void OMPClauseReader::VisitOMPHoldsClause(OMPHoldsClause *
C) {
12268 C->setExpr(Record.readExpr());
12269 C->setLParenLoc(Record.readSourceLocation());
12272void OMPClauseReader::VisitOMPContainsClause(OMPContainsClause *
C) {
12273 unsigned Count =
C->getDirectiveKinds().size();
12274 C->setLParenLoc(Record.readSourceLocation());
12275 llvm::SmallVector<OpenMPDirectiveKind, 4> DKVec;
12276 DKVec.reserve(Count);
12277 for (
unsigned I = 0; I < Count; I++) {
12280 C->setDirectiveKinds(DKVec);
12283void OMPClauseReader::VisitOMPNoOpenMPClause(OMPNoOpenMPClause *) {}
12285void OMPClauseReader::VisitOMPNoOpenMPRoutinesClause(
12286 OMPNoOpenMPRoutinesClause *) {}
12288void OMPClauseReader::VisitOMPNoOpenMPConstructsClause(
12289 OMPNoOpenMPConstructsClause *) {}
12291void OMPClauseReader::VisitOMPNoParallelismClause(OMPNoParallelismClause *) {}
12293void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
12295void OMPClauseReader::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
12297void OMPClauseReader::VisitOMPAcquireClause(OMPAcquireClause *) {}
12299void OMPClauseReader::VisitOMPReleaseClause(OMPReleaseClause *) {}
12301void OMPClauseReader::VisitOMPRelaxedClause(OMPRelaxedClause *) {}
12303void OMPClauseReader::VisitOMPWeakClause(OMPWeakClause *) {}
12305void OMPClauseReader::VisitOMPThreadsClause(OMPThreadsClause *) {}
12307void OMPClauseReader::VisitOMPSIMDClause(OMPSIMDClause *) {}
12309void OMPClauseReader::VisitOMPNogroupClause(OMPNogroupClause *) {}
12311void OMPClauseReader::VisitOMPInitClause(OMPInitClause *
C) {
12312 unsigned NumVars =
C->varlist_size();
12313 SmallVector<Expr *, 16> Vars;
12314 Vars.reserve(NumVars);
12315 for (
unsigned I = 0; I != NumVars; ++I)
12316 Vars.push_back(Record.readSubExpr());
12317 C->setVarRefs(Vars);
12318 C->setIsTarget(Record.readBool());
12319 C->setIsTargetSync(Record.readBool());
12320 C->setHasPreferAttrs(Record.readBool());
12322 unsigned NumPrefs =
C->varlist_size() - 1;
12323 SmallVector<unsigned, 4> Counts;
12324 SmallVector<Expr *, 8> Attrs;
12325 Counts.reserve(NumPrefs);
12326 for (
unsigned I = 0; I < NumPrefs; ++I) {
12327 unsigned NA = Record.readInt();
12328 Counts.push_back(NA);
12329 for (
unsigned J = 0; J < NA; ++J)
12330 Attrs.push_back(Record.readSubExpr());
12332 C->setAttrs(Counts, Attrs);
12334 C->setLParenLoc(Record.readSourceLocation());
12335 C->setVarLoc(Record.readSourceLocation());
12338void OMPClauseReader::VisitOMPUseClause(OMPUseClause *
C) {
12339 C->setInteropVar(Record.readSubExpr());
12340 C->setLParenLoc(Record.readSourceLocation());
12341 C->setVarLoc(Record.readSourceLocation());
12344void OMPClauseReader::VisitOMPDestroyClause(OMPDestroyClause *
C) {
12345 C->setInteropVar(Record.readSubExpr());
12346 C->setLParenLoc(Record.readSourceLocation());
12347 C->setVarLoc(Record.readSourceLocation());
12350void OMPClauseReader::VisitOMPNovariantsClause(OMPNovariantsClause *
C) {
12352 C->setCondition(Record.readSubExpr());
12353 C->setLParenLoc(Record.readSourceLocation());
12356void OMPClauseReader::VisitOMPNocontextClause(OMPNocontextClause *
C) {
12358 C->setCondition(Record.readSubExpr());
12359 C->setLParenLoc(Record.readSourceLocation());
12362void OMPClauseReader::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {}
12364void OMPClauseReader::VisitOMPUnifiedSharedMemoryClause(
12365 OMPUnifiedSharedMemoryClause *) {}
12367void OMPClauseReader::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
12370OMPClauseReader::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
12373void OMPClauseReader::VisitOMPAtomicDefaultMemOrderClause(
12374 OMPAtomicDefaultMemOrderClause *
C) {
12375 C->setAtomicDefaultMemOrderKind(
12377 C->setLParenLoc(Record.readSourceLocation());
12378 C->setAtomicDefaultMemOrderKindKwLoc(Record.readSourceLocation());
12381void OMPClauseReader::VisitOMPSelfMapsClause(OMPSelfMapsClause *) {}
12383void OMPClauseReader::VisitOMPAtClause(OMPAtClause *
C) {
12385 C->setLParenLoc(Record.readSourceLocation());
12386 C->setAtKindKwLoc(Record.readSourceLocation());
12389void OMPClauseReader::VisitOMPSeverityClause(OMPSeverityClause *
C) {
12391 C->setLParenLoc(Record.readSourceLocation());
12392 C->setSeverityKindKwLoc(Record.readSourceLocation());
12395void OMPClauseReader::VisitOMPMessageClause(OMPMessageClause *
C) {
12397 C->setMessageString(Record.readSubExpr());
12398 C->setLParenLoc(Record.readSourceLocation());
12401void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *
C) {
12402 C->setLParenLoc(Record.readSourceLocation());
12403 unsigned NumVars =
C->varlist_size();
12404 SmallVector<Expr *, 16> Vars;
12405 Vars.reserve(NumVars);
12406 for (
unsigned i = 0; i != NumVars; ++i)
12407 Vars.push_back(Record.readSubExpr());
12408 C->setVarRefs(Vars);
12410 for (
unsigned i = 0; i != NumVars; ++i)
12411 Vars.push_back(Record.readSubExpr());
12412 C->setPrivateCopies(Vars);
12415void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *
C) {
12417 C->setLParenLoc(Record.readSourceLocation());
12418 unsigned NumVars =
C->varlist_size();
12419 SmallVector<Expr *, 16> Vars;
12420 Vars.reserve(NumVars);
12421 for (
unsigned i = 0; i != NumVars; ++i)
12422 Vars.push_back(Record.readSubExpr());
12423 C->setVarRefs(Vars);
12425 for (
unsigned i = 0; i != NumVars; ++i)
12426 Vars.push_back(Record.readSubExpr());
12427 C->setPrivateCopies(Vars);
12429 for (
unsigned i = 0; i != NumVars; ++i)
12430 Vars.push_back(Record.readSubExpr());
12434void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *
C) {
12436 C->setLParenLoc(Record.readSourceLocation());
12438 C->setKindLoc(Record.readSourceLocation());
12439 C->setColonLoc(Record.readSourceLocation());
12440 unsigned NumVars =
C->varlist_size();
12441 SmallVector<Expr *, 16> Vars;
12442 Vars.reserve(NumVars);
12443 for (
unsigned i = 0; i != NumVars; ++i)
12444 Vars.push_back(Record.readSubExpr());
12445 C->setVarRefs(Vars);
12447 for (
unsigned i = 0; i != NumVars; ++i)
12448 Vars.push_back(Record.readSubExpr());
12449 C->setPrivateCopies(Vars);
12451 for (
unsigned i = 0; i != NumVars; ++i)
12452 Vars.push_back(Record.readSubExpr());
12453 C->setSourceExprs(Vars);
12455 for (
unsigned i = 0; i != NumVars; ++i)
12456 Vars.push_back(Record.readSubExpr());
12457 C->setDestinationExprs(Vars);
12459 for (
unsigned i = 0; i != NumVars; ++i)
12460 Vars.push_back(Record.readSubExpr());
12461 C->setAssignmentOps(Vars);
12464void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *
C) {
12465 C->setLParenLoc(Record.readSourceLocation());
12466 unsigned NumVars =
C->varlist_size();
12467 SmallVector<Expr *, 16> Vars;
12468 Vars.reserve(NumVars);
12469 for (
unsigned i = 0; i != NumVars; ++i)
12470 Vars.push_back(Record.readSubExpr());
12471 C->setVarRefs(Vars);
12474void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *
C) {
12476 C->setLParenLoc(Record.readSourceLocation());
12477 C->setModifierLoc(Record.readSourceLocation());
12478 C->setColonLoc(Record.readSourceLocation());
12479 NestedNameSpecifierLoc NNSL = Record.readNestedNameSpecifierLoc();
12480 DeclarationNameInfo DNI = Record.readDeclarationNameInfo();
12481 C->setQualifierLoc(NNSL);
12482 C->setNameInfo(DNI);
12484 unsigned NumVars =
C->varlist_size();
12485 SmallVector<Expr *, 16> Vars;
12486 Vars.reserve(NumVars);
12487 for (
unsigned i = 0; i != NumVars; ++i)
12488 Vars.push_back(Record.readSubExpr());
12489 C->setVarRefs(Vars);
12491 for (
unsigned i = 0; i != NumVars; ++i)
12492 Vars.push_back(Record.readSubExpr());
12493 C->setPrivates(Vars);
12495 for (
unsigned i = 0; i != NumVars; ++i)
12496 Vars.push_back(Record.readSubExpr());
12497 C->setLHSExprs(Vars);
12499 for (
unsigned i = 0; i != NumVars; ++i)
12500 Vars.push_back(Record.readSubExpr());
12501 C->setRHSExprs(Vars);
12503 for (
unsigned i = 0; i != NumVars; ++i)
12504 Vars.push_back(Record.readSubExpr());
12505 C->setReductionOps(Vars);
12506 if (
C->getModifier() == OMPC_REDUCTION_inscan) {
12508 for (
unsigned i = 0; i != NumVars; ++i)
12509 Vars.push_back(Record.readSubExpr());
12510 C->setInscanCopyOps(Vars);
12512 for (
unsigned i = 0; i != NumVars; ++i)
12513 Vars.push_back(Record.readSubExpr());
12514 C->setInscanCopyArrayTemps(Vars);
12516 for (
unsigned i = 0; i != NumVars; ++i)
12517 Vars.push_back(Record.readSubExpr());
12518 C->setInscanCopyArrayElems(Vars);
12520 unsigned NumFlags = Record.readInt();
12521 SmallVector<bool, 16> Flags;
12522 Flags.reserve(NumFlags);
12523 for ([[maybe_unused]]
unsigned I : llvm::seq<unsigned>(NumFlags))
12524 Flags.push_back(Record.readInt());
12525 C->setPrivateVariableReductionFlags(Flags);
12528void OMPClauseReader::VisitOMPTaskReductionClause(OMPTaskReductionClause *
C) {
12530 C->setLParenLoc(Record.readSourceLocation());
12531 C->setColonLoc(Record.readSourceLocation());
12532 NestedNameSpecifierLoc NNSL = Record.readNestedNameSpecifierLoc();
12533 DeclarationNameInfo DNI = Record.readDeclarationNameInfo();
12534 C->setQualifierLoc(NNSL);
12535 C->setNameInfo(DNI);
12537 unsigned NumVars =
C->varlist_size();
12538 SmallVector<Expr *, 16> Vars;
12539 Vars.reserve(NumVars);
12540 for (
unsigned I = 0; I != NumVars; ++I)
12541 Vars.push_back(Record.readSubExpr());
12542 C->setVarRefs(Vars);
12544 for (
unsigned I = 0; I != NumVars; ++I)
12545 Vars.push_back(Record.readSubExpr());
12546 C->setPrivates(Vars);
12548 for (
unsigned I = 0; I != NumVars; ++I)
12549 Vars.push_back(Record.readSubExpr());
12550 C->setLHSExprs(Vars);
12552 for (
unsigned I = 0; I != NumVars; ++I)
12553 Vars.push_back(Record.readSubExpr());
12554 C->setRHSExprs(Vars);
12556 for (
unsigned I = 0; I != NumVars; ++I)
12557 Vars.push_back(Record.readSubExpr());
12558 C->setReductionOps(Vars);
12561void OMPClauseReader::VisitOMPInReductionClause(OMPInReductionClause *
C) {
12563 C->setLParenLoc(Record.readSourceLocation());
12564 C->setColonLoc(Record.readSourceLocation());
12565 NestedNameSpecifierLoc NNSL = Record.readNestedNameSpecifierLoc();
12566 DeclarationNameInfo DNI = Record.readDeclarationNameInfo();
12567 C->setQualifierLoc(NNSL);
12568 C->setNameInfo(DNI);
12570 unsigned NumVars =
C->varlist_size();
12571 SmallVector<Expr *, 16> Vars;
12572 Vars.reserve(NumVars);
12573 for (
unsigned I = 0; I != NumVars; ++I)
12574 Vars.push_back(Record.readSubExpr());
12575 C->setVarRefs(Vars);
12577 for (
unsigned I = 0; I != NumVars; ++I)
12578 Vars.push_back(Record.readSubExpr());
12579 C->setPrivates(Vars);
12581 for (
unsigned I = 0; I != NumVars; ++I)
12582 Vars.push_back(Record.readSubExpr());
12583 C->setLHSExprs(Vars);
12585 for (
unsigned I = 0; I != NumVars; ++I)
12586 Vars.push_back(Record.readSubExpr());
12587 C->setRHSExprs(Vars);
12589 for (
unsigned I = 0; I != NumVars; ++I)
12590 Vars.push_back(Record.readSubExpr());
12591 C->setReductionOps(Vars);
12593 for (
unsigned I = 0; I != NumVars; ++I)
12594 Vars.push_back(Record.readSubExpr());
12595 C->setTaskgroupDescriptors(Vars);
12598void OMPClauseReader::VisitOMPLinearClause(OMPLinearClause *
C) {
12600 C->setLParenLoc(Record.readSourceLocation());
12601 C->setColonLoc(Record.readSourceLocation());
12603 C->setModifierLoc(Record.readSourceLocation());
12604 unsigned NumVars =
C->varlist_size();
12605 SmallVector<Expr *, 16> Vars;
12606 Vars.reserve(NumVars);
12607 for (
unsigned i = 0; i != NumVars; ++i)
12608 Vars.push_back(Record.readSubExpr());
12609 C->setVarRefs(Vars);
12611 for (
unsigned i = 0; i != NumVars; ++i)
12612 Vars.push_back(Record.readSubExpr());
12613 C->setPrivates(Vars);
12615 for (
unsigned i = 0; i != NumVars; ++i)
12616 Vars.push_back(Record.readSubExpr());
12619 for (
unsigned i = 0; i != NumVars; ++i)
12620 Vars.push_back(Record.readSubExpr());
12621 C->setUpdates(Vars);
12623 for (
unsigned i = 0; i != NumVars; ++i)
12624 Vars.push_back(Record.readSubExpr());
12625 C->setFinals(Vars);
12626 C->setStep(Record.readSubExpr());
12627 C->setCalcStep(Record.readSubExpr());
12629 for (
unsigned I = 0; I != NumVars + 1; ++I)
12630 Vars.push_back(Record.readSubExpr());
12631 C->setUsedExprs(Vars);
12634void OMPClauseReader::VisitOMPAlignedClause(OMPAlignedClause *
C) {
12635 C->setLParenLoc(Record.readSourceLocation());
12636 C->setColonLoc(Record.readSourceLocation());
12637 unsigned NumVars =
C->varlist_size();
12638 SmallVector<Expr *, 16> Vars;
12639 Vars.reserve(NumVars);
12640 for (
unsigned i = 0; i != NumVars; ++i)
12641 Vars.push_back(Record.readSubExpr());
12642 C->setVarRefs(Vars);
12643 C->setAlignment(Record.readSubExpr());
12646void OMPClauseReader::VisitOMPCopyinClause(OMPCopyinClause *
C) {
12647 C->setLParenLoc(Record.readSourceLocation());
12648 unsigned NumVars =
C->varlist_size();
12649 SmallVector<Expr *, 16> Exprs;
12650 Exprs.reserve(NumVars);
12651 for (
unsigned i = 0; i != NumVars; ++i)
12652 Exprs.push_back(Record.readSubExpr());
12653 C->setVarRefs(Exprs);
12655 for (
unsigned i = 0; i != NumVars; ++i)
12656 Exprs.push_back(Record.readSubExpr());
12657 C->setSourceExprs(Exprs);
12659 for (
unsigned i = 0; i != NumVars; ++i)
12660 Exprs.push_back(Record.readSubExpr());
12661 C->setDestinationExprs(Exprs);
12663 for (
unsigned i = 0; i != NumVars; ++i)
12664 Exprs.push_back(Record.readSubExpr());
12665 C->setAssignmentOps(Exprs);
12668void OMPClauseReader::VisitOMPCopyprivateClause(OMPCopyprivateClause *
C) {
12669 C->setLParenLoc(Record.readSourceLocation());
12670 unsigned NumVars =
C->varlist_size();
12671 SmallVector<Expr *, 16> Exprs;
12672 Exprs.reserve(NumVars);
12673 for (
unsigned i = 0; i != NumVars; ++i)
12674 Exprs.push_back(Record.readSubExpr());
12675 C->setVarRefs(Exprs);
12677 for (
unsigned i = 0; i != NumVars; ++i)
12678 Exprs.push_back(Record.readSubExpr());
12679 C->setSourceExprs(Exprs);
12681 for (
unsigned i = 0; i != NumVars; ++i)
12682 Exprs.push_back(Record.readSubExpr());
12683 C->setDestinationExprs(Exprs);
12685 for (
unsigned i = 0; i != NumVars; ++i)
12686 Exprs.push_back(Record.readSubExpr());
12687 C->setAssignmentOps(Exprs);
12690void OMPClauseReader::VisitOMPFlushClause(OMPFlushClause *
C) {
12691 C->setLParenLoc(Record.readSourceLocation());
12692 unsigned NumVars =
C->varlist_size();
12693 SmallVector<Expr *, 16> Vars;
12694 Vars.reserve(NumVars);
12695 for (
unsigned i = 0; i != NumVars; ++i)
12696 Vars.push_back(Record.readSubExpr());
12697 C->setVarRefs(Vars);
12700void OMPClauseReader::VisitOMPDepobjClause(OMPDepobjClause *
C) {
12701 C->setDepobj(Record.readSubExpr());
12702 C->setLParenLoc(Record.readSourceLocation());
12705void OMPClauseReader::VisitOMPDependClause(OMPDependClause *
C) {
12706 C->setLParenLoc(Record.readSourceLocation());
12707 C->setModifier(Record.readSubExpr());
12708 C->setDependencyKind(
12710 C->setDependencyLoc(Record.readSourceLocation());
12711 C->setColonLoc(Record.readSourceLocation());
12712 C->setOmpAllMemoryLoc(Record.readSourceLocation());
12713 unsigned NumVars =
C->varlist_size();
12714 SmallVector<Expr *, 16> Vars;
12715 Vars.reserve(NumVars);
12716 for (
unsigned I = 0; I != NumVars; ++I)
12717 Vars.push_back(Record.readSubExpr());
12718 C->setVarRefs(Vars);
12719 for (
unsigned I = 0, E =
C->getNumLoops(); I < E; ++I)
12720 C->setLoopData(I, Record.readSubExpr());
12723void OMPClauseReader::VisitOMPDeviceClause(OMPDeviceClause *
C) {
12726 C->setDevice(Record.readSubExpr());
12727 C->setModifierLoc(Record.readSourceLocation());
12728 C->setLParenLoc(Record.readSourceLocation());
12731void OMPClauseReader::VisitOMPMapClause(OMPMapClause *
C) {
12732 C->setLParenLoc(Record.readSourceLocation());
12733 bool HasIteratorModifier =
false;
12735 C->setMapTypeModifier(
12737 C->setMapTypeModifierLoc(I, Record.readSourceLocation());
12738 if (
C->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator)
12739 HasIteratorModifier =
true;
12741 C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
12742 C->setMapperIdInfo(Record.readDeclarationNameInfo());
12745 C->setMapLoc(Record.readSourceLocation());
12746 C->setColonLoc(Record.readSourceLocation());
12747 auto NumVars =
C->varlist_size();
12748 auto UniqueDecls =
C->getUniqueDeclarationsNum();
12749 auto TotalLists =
C->getTotalComponentListNum();
12750 auto TotalComponents =
C->getTotalComponentsNum();
12752 SmallVector<Expr *, 16> Vars;
12753 Vars.reserve(NumVars);
12754 for (
unsigned i = 0; i != NumVars; ++i)
12755 Vars.push_back(Record.readExpr());
12756 C->setVarRefs(Vars);
12758 SmallVector<Expr *, 16> UDMappers;
12759 UDMappers.reserve(NumVars);
12760 for (
unsigned I = 0; I < NumVars; ++I)
12761 UDMappers.push_back(Record.readExpr());
12762 C->setUDMapperRefs(UDMappers);
12764 if (HasIteratorModifier)
12765 C->setIteratorModifier(Record.readExpr());
12767 SmallVector<ValueDecl *, 16> Decls;
12768 Decls.reserve(UniqueDecls);
12769 for (
unsigned i = 0; i < UniqueDecls; ++i)
12770 Decls.push_back(Record.readDeclAs<ValueDecl>());
12771 C->setUniqueDecls(Decls);
12773 SmallVector<unsigned, 16> ListsPerDecl;
12774 ListsPerDecl.reserve(UniqueDecls);
12775 for (
unsigned i = 0; i < UniqueDecls; ++i)
12776 ListsPerDecl.push_back(Record.readInt());
12777 C->setDeclNumLists(ListsPerDecl);
12779 SmallVector<unsigned, 32> ListSizes;
12780 ListSizes.reserve(TotalLists);
12781 for (
unsigned i = 0; i < TotalLists; ++i)
12782 ListSizes.push_back(Record.readInt());
12783 C->setComponentListSizes(ListSizes);
12785 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
12786 Components.reserve(TotalComponents);
12787 for (
unsigned i = 0; i < TotalComponents; ++i) {
12788 Expr *AssociatedExprPr = Record.readExpr();
12789 auto *AssociatedDecl = Record.readDeclAs<ValueDecl>();
12790 Components.emplace_back(AssociatedExprPr, AssociatedDecl,
12793 C->setComponents(Components, ListSizes);
12799 C->setLParenLoc(Record.readSourceLocation());
12800 C->setColonLoc(Record.readSourceLocation());
12801 C->setAllocator(Record.readSubExpr());
12802 C->setAlignment(Record.readSubExpr());
12803 unsigned NumVars =
C->varlist_size();
12804 SmallVector<Expr *, 16> Vars;
12805 Vars.reserve(NumVars);
12806 for (
unsigned i = 0; i != NumVars; ++i)
12807 Vars.push_back(Record.readSubExpr());
12808 C->setVarRefs(Vars);
12811void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *
C) {
12813 C->setModifierLoc(Record.readSourceLocation());
12814 C->setModifierExpr(Record.readSubExpr());
12816 C->setLParenLoc(Record.readSourceLocation());
12817 unsigned NumVars =
C->varlist_size();
12818 SmallVector<Expr *, 16> Vars;
12819 Vars.reserve(NumVars);
12820 for (
unsigned I = 0; I != NumVars; ++I)
12821 Vars.push_back(Record.readSubExpr());
12822 C->setVarRefs(Vars);
12825void OMPClauseReader::VisitOMPThreadLimitClause(OMPThreadLimitClause *
C) {
12827 C->setModifierLoc(Record.readSourceLocation());
12828 C->setModifierExpr(Record.readSubExpr());
12830 C->setLParenLoc(Record.readSourceLocation());
12831 unsigned NumVars =
C->varlist_size();
12832 SmallVector<Expr *, 16> Vars;
12833 Vars.reserve(NumVars);
12834 for (
unsigned I = 0; I != NumVars; ++I)
12835 Vars.push_back(Record.readSubExpr());
12836 C->setVarRefs(Vars);
12839void OMPClauseReader::VisitOMPPriorityClause(OMPPriorityClause *
C) {
12841 C->setPriority(Record.readSubExpr());
12842 C->setLParenLoc(Record.readSourceLocation());
12845void OMPClauseReader::VisitOMPGrainsizeClause(OMPGrainsizeClause *
C) {
12848 C->setGrainsize(Record.readSubExpr());
12849 C->setModifierLoc(Record.readSourceLocation());
12850 C->setLParenLoc(Record.readSourceLocation());
12853void OMPClauseReader::VisitOMPNumTasksClause(OMPNumTasksClause *
C) {
12856 C->setNumTasks(Record.readSubExpr());
12857 C->setModifierLoc(Record.readSourceLocation());
12858 C->setLParenLoc(Record.readSourceLocation());
12861void OMPClauseReader::VisitOMPHintClause(OMPHintClause *
C) {
12862 C->setHint(Record.readSubExpr());
12863 C->setLParenLoc(Record.readSourceLocation());
12866void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *
C) {
12868 C->setDistScheduleKind(
12870 C->setChunkSize(Record.readSubExpr());
12871 C->setLParenLoc(Record.readSourceLocation());
12872 C->setDistScheduleKindLoc(Record.readSourceLocation());
12873 C->setCommaLoc(Record.readSourceLocation());
12876void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *
C) {
12877 C->setDefaultmapKind(
12879 C->setDefaultmapModifier(
12881 C->setLParenLoc(Record.readSourceLocation());
12882 C->setDefaultmapModifierLoc(Record.readSourceLocation());
12883 C->setDefaultmapKindLoc(Record.readSourceLocation());
12886void OMPClauseReader::VisitOMPToClause(OMPToClause *
C) {
12887 C->setLParenLoc(Record.readSourceLocation());
12889 C->setMotionModifier(
12891 C->setMotionModifierLoc(I, Record.readSourceLocation());
12892 if (
C->getMotionModifier(I) == OMPC_MOTION_MODIFIER_iterator)
12893 C->setIteratorModifier(Record.readExpr());
12895 C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
12896 C->setMapperIdInfo(Record.readDeclarationNameInfo());
12897 C->setColonLoc(Record.readSourceLocation());
12898 auto NumVars =
C->varlist_size();
12899 auto UniqueDecls =
C->getUniqueDeclarationsNum();
12900 auto TotalLists =
C->getTotalComponentListNum();
12901 auto TotalComponents =
C->getTotalComponentsNum();
12903 SmallVector<Expr *, 16> Vars;
12904 Vars.reserve(NumVars);
12905 for (
unsigned i = 0; i != NumVars; ++i)
12906 Vars.push_back(Record.readSubExpr());
12907 C->setVarRefs(Vars);
12909 SmallVector<Expr *, 16> UDMappers;
12910 UDMappers.reserve(NumVars);
12911 for (
unsigned I = 0; I < NumVars; ++I)
12912 UDMappers.push_back(Record.readSubExpr());
12913 C->setUDMapperRefs(UDMappers);
12915 SmallVector<ValueDecl *, 16> Decls;
12916 Decls.reserve(UniqueDecls);
12917 for (
unsigned i = 0; i < UniqueDecls; ++i)
12918 Decls.push_back(Record.readDeclAs<ValueDecl>());
12919 C->setUniqueDecls(Decls);
12921 SmallVector<unsigned, 16> ListsPerDecl;
12922 ListsPerDecl.reserve(UniqueDecls);
12923 for (
unsigned i = 0; i < UniqueDecls; ++i)
12924 ListsPerDecl.push_back(Record.readInt());
12925 C->setDeclNumLists(ListsPerDecl);
12927 SmallVector<unsigned, 32> ListSizes;
12928 ListSizes.reserve(TotalLists);
12929 for (
unsigned i = 0; i < TotalLists; ++i)
12930 ListSizes.push_back(Record.readInt());
12931 C->setComponentListSizes(ListSizes);
12933 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
12934 Components.reserve(TotalComponents);
12935 for (
unsigned i = 0; i < TotalComponents; ++i) {
12936 Expr *AssociatedExprPr = Record.readSubExpr();
12937 bool IsNonContiguous = Record.readBool();
12938 auto *AssociatedDecl = Record.readDeclAs<ValueDecl>();
12939 Components.emplace_back(AssociatedExprPr, AssociatedDecl, IsNonContiguous);
12941 C->setComponents(Components, ListSizes);
12944void OMPClauseReader::VisitOMPFromClause(OMPFromClause *
C) {
12945 C->setLParenLoc(Record.readSourceLocation());
12947 C->setMotionModifier(
12949 C->setMotionModifierLoc(I, Record.readSourceLocation());
12950 if (
C->getMotionModifier(I) == OMPC_MOTION_MODIFIER_iterator)
12951 C->setIteratorModifier(Record.readExpr());
12953 C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
12954 C->setMapperIdInfo(Record.readDeclarationNameInfo());
12955 C->setColonLoc(Record.readSourceLocation());
12956 auto NumVars =
C->varlist_size();
12957 auto UniqueDecls =
C->getUniqueDeclarationsNum();
12958 auto TotalLists =
C->getTotalComponentListNum();
12959 auto TotalComponents =
C->getTotalComponentsNum();
12961 SmallVector<Expr *, 16> Vars;
12962 Vars.reserve(NumVars);
12963 for (
unsigned i = 0; i != NumVars; ++i)
12964 Vars.push_back(Record.readSubExpr());
12965 C->setVarRefs(Vars);
12967 SmallVector<Expr *, 16> UDMappers;
12968 UDMappers.reserve(NumVars);
12969 for (
unsigned I = 0; I < NumVars; ++I)
12970 UDMappers.push_back(Record.readSubExpr());
12971 C->setUDMapperRefs(UDMappers);
12973 SmallVector<ValueDecl *, 16> Decls;
12974 Decls.reserve(UniqueDecls);
12975 for (
unsigned i = 0; i < UniqueDecls; ++i)
12976 Decls.push_back(Record.readDeclAs<ValueDecl>());
12977 C->setUniqueDecls(Decls);
12979 SmallVector<unsigned, 16> ListsPerDecl;
12980 ListsPerDecl.reserve(UniqueDecls);
12981 for (
unsigned i = 0; i < UniqueDecls; ++i)
12982 ListsPerDecl.push_back(Record.readInt());
12983 C->setDeclNumLists(ListsPerDecl);
12985 SmallVector<unsigned, 32> ListSizes;
12986 ListSizes.reserve(TotalLists);
12987 for (
unsigned i = 0; i < TotalLists; ++i)
12988 ListSizes.push_back(Record.readInt());
12989 C->setComponentListSizes(ListSizes);
12991 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
12992 Components.reserve(TotalComponents);
12993 for (
unsigned i = 0; i < TotalComponents; ++i) {
12994 Expr *AssociatedExprPr = Record.readSubExpr();
12995 bool IsNonContiguous = Record.readBool();
12996 auto *AssociatedDecl = Record.readDeclAs<ValueDecl>();
12997 Components.emplace_back(AssociatedExprPr, AssociatedDecl, IsNonContiguous);
12999 C->setComponents(Components, ListSizes);
13002void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *
C) {
13003 C->setLParenLoc(Record.readSourceLocation());
13005 C->setFallbackModifierLoc(Record.readSourceLocation());
13006 auto NumVars =
C->varlist_size();
13007 auto UniqueDecls =
C->getUniqueDeclarationsNum();
13008 auto TotalLists =
C->getTotalComponentListNum();
13009 auto TotalComponents =
C->getTotalComponentsNum();
13011 SmallVector<Expr *, 16> Vars;
13012 Vars.reserve(NumVars);
13013 for (
unsigned i = 0; i != NumVars; ++i)
13014 Vars.push_back(Record.readSubExpr());
13015 C->setVarRefs(Vars);
13017 for (
unsigned i = 0; i != NumVars; ++i)
13018 Vars.push_back(Record.readSubExpr());
13019 C->setPrivateCopies(Vars);
13021 for (
unsigned i = 0; i != NumVars; ++i)
13022 Vars.push_back(Record.readSubExpr());
13025 SmallVector<ValueDecl *, 16> Decls;
13026 Decls.reserve(UniqueDecls);
13027 for (
unsigned i = 0; i < UniqueDecls; ++i)
13028 Decls.push_back(Record.readDeclAs<ValueDecl>());
13029 C->setUniqueDecls(Decls);
13031 SmallVector<unsigned, 16> ListsPerDecl;
13032 ListsPerDecl.reserve(UniqueDecls);
13033 for (
unsigned i = 0; i < UniqueDecls; ++i)
13034 ListsPerDecl.push_back(Record.readInt());
13035 C->setDeclNumLists(ListsPerDecl);
13037 SmallVector<unsigned, 32> ListSizes;
13038 ListSizes.reserve(TotalLists);
13039 for (
unsigned i = 0; i < TotalLists; ++i)
13040 ListSizes.push_back(Record.readInt());
13041 C->setComponentListSizes(ListSizes);
13043 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
13044 Components.reserve(TotalComponents);
13045 for (
unsigned i = 0; i < TotalComponents; ++i) {
13046 auto *AssociatedExprPr = Record.readSubExpr();
13047 auto *AssociatedDecl = Record.readDeclAs<ValueDecl>();
13048 Components.emplace_back(AssociatedExprPr, AssociatedDecl,
13051 C->setComponents(Components, ListSizes);
13054void OMPClauseReader::VisitOMPUseDeviceAddrClause(OMPUseDeviceAddrClause *
C) {
13055 C->setLParenLoc(Record.readSourceLocation());
13056 auto NumVars =
C->varlist_size();
13057 auto UniqueDecls =
C->getUniqueDeclarationsNum();
13058 auto TotalLists =
C->getTotalComponentListNum();
13059 auto TotalComponents =
C->getTotalComponentsNum();
13061 SmallVector<Expr *, 16> Vars;
13062 Vars.reserve(NumVars);
13063 for (
unsigned i = 0; i != NumVars; ++i)
13064 Vars.push_back(Record.readSubExpr());
13065 C->setVarRefs(Vars);
13067 SmallVector<ValueDecl *, 16> Decls;
13068 Decls.reserve(UniqueDecls);
13069 for (
unsigned i = 0; i < UniqueDecls; ++i)
13070 Decls.push_back(Record.readDeclAs<ValueDecl>());
13071 C->setUniqueDecls(Decls);
13073 SmallVector<unsigned, 16> ListsPerDecl;
13074 ListsPerDecl.reserve(UniqueDecls);
13075 for (
unsigned i = 0; i < UniqueDecls; ++i)
13076 ListsPerDecl.push_back(Record.readInt());
13077 C->setDeclNumLists(ListsPerDecl);
13079 SmallVector<unsigned, 32> ListSizes;
13080 ListSizes.reserve(TotalLists);
13081 for (
unsigned i = 0; i < TotalLists; ++i)
13082 ListSizes.push_back(Record.readInt());
13083 C->setComponentListSizes(ListSizes);
13085 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
13086 Components.reserve(TotalComponents);
13087 for (
unsigned i = 0; i < TotalComponents; ++i) {
13088 Expr *AssociatedExpr = Record.readSubExpr();
13089 auto *AssociatedDecl = Record.readDeclAs<ValueDecl>();
13090 Components.emplace_back(AssociatedExpr, AssociatedDecl,
13093 C->setComponents(Components, ListSizes);
13096void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *
C) {
13097 C->setLParenLoc(Record.readSourceLocation());
13098 auto NumVars =
C->varlist_size();
13099 auto UniqueDecls =
C->getUniqueDeclarationsNum();
13100 auto TotalLists =
C->getTotalComponentListNum();
13101 auto TotalComponents =
C->getTotalComponentsNum();
13103 SmallVector<Expr *, 16> Vars;
13104 Vars.reserve(NumVars);
13105 for (
unsigned i = 0; i != NumVars; ++i)
13106 Vars.push_back(Record.readSubExpr());
13107 C->setVarRefs(Vars);
13110 SmallVector<ValueDecl *, 16> Decls;
13111 Decls.reserve(UniqueDecls);
13112 for (
unsigned i = 0; i < UniqueDecls; ++i)
13113 Decls.push_back(Record.readDeclAs<ValueDecl>());
13114 C->setUniqueDecls(Decls);
13116 SmallVector<unsigned, 16> ListsPerDecl;
13117 ListsPerDecl.reserve(UniqueDecls);
13118 for (
unsigned i = 0; i < UniqueDecls; ++i)
13119 ListsPerDecl.push_back(Record.readInt());
13120 C->setDeclNumLists(ListsPerDecl);
13122 SmallVector<unsigned, 32> ListSizes;
13123 ListSizes.reserve(TotalLists);
13124 for (
unsigned i = 0; i < TotalLists; ++i)
13125 ListSizes.push_back(Record.readInt());
13126 C->setComponentListSizes(ListSizes);
13128 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
13129 Components.reserve(TotalComponents);
13130 for (
unsigned i = 0; i < TotalComponents; ++i) {
13131 Expr *AssociatedExpr = Record.readSubExpr();
13132 auto *AssociatedDecl = Record.readDeclAs<ValueDecl>();
13133 Components.emplace_back(AssociatedExpr, AssociatedDecl,
13136 C->setComponents(Components, ListSizes);
13139void OMPClauseReader::VisitOMPHasDeviceAddrClause(OMPHasDeviceAddrClause *
C) {
13140 C->setLParenLoc(Record.readSourceLocation());
13141 auto NumVars =
C->varlist_size();
13142 auto UniqueDecls =
C->getUniqueDeclarationsNum();
13143 auto TotalLists =
C->getTotalComponentListNum();
13144 auto TotalComponents =
C->getTotalComponentsNum();
13146 SmallVector<Expr *, 16> Vars;
13147 Vars.reserve(NumVars);
13148 for (
unsigned I = 0; I != NumVars; ++I)
13149 Vars.push_back(Record.readSubExpr());
13150 C->setVarRefs(Vars);
13153 SmallVector<ValueDecl *, 16> Decls;
13154 Decls.reserve(UniqueDecls);
13155 for (
unsigned I = 0; I < UniqueDecls; ++I)
13156 Decls.push_back(Record.readDeclAs<ValueDecl>());
13157 C->setUniqueDecls(Decls);
13159 SmallVector<unsigned, 16> ListsPerDecl;
13160 ListsPerDecl.reserve(UniqueDecls);
13161 for (
unsigned I = 0; I < UniqueDecls; ++I)
13162 ListsPerDecl.push_back(Record.readInt());
13163 C->setDeclNumLists(ListsPerDecl);
13165 SmallVector<unsigned, 32> ListSizes;
13166 ListSizes.reserve(TotalLists);
13167 for (
unsigned i = 0; i < TotalLists; ++i)
13168 ListSizes.push_back(Record.readInt());
13169 C->setComponentListSizes(ListSizes);
13171 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
13172 Components.reserve(TotalComponents);
13173 for (
unsigned I = 0; I < TotalComponents; ++I) {
13174 Expr *AssociatedExpr = Record.readSubExpr();
13175 auto *AssociatedDecl = Record.readDeclAs<ValueDecl>();
13176 Components.emplace_back(AssociatedExpr, AssociatedDecl,
13179 C->setComponents(Components, ListSizes);
13182void OMPClauseReader::VisitOMPNontemporalClause(OMPNontemporalClause *
C) {
13183 C->setLParenLoc(Record.readSourceLocation());
13184 unsigned NumVars =
C->varlist_size();
13185 SmallVector<Expr *, 16> Vars;
13186 Vars.reserve(NumVars);
13187 for (
unsigned i = 0; i != NumVars; ++i)
13188 Vars.push_back(Record.readSubExpr());
13189 C->setVarRefs(Vars);
13191 Vars.reserve(NumVars);
13192 for (
unsigned i = 0; i != NumVars; ++i)
13193 Vars.push_back(Record.readSubExpr());
13194 C->setPrivateRefs(Vars);
13197void OMPClauseReader::VisitOMPInclusiveClause(OMPInclusiveClause *
C) {
13198 C->setLParenLoc(Record.readSourceLocation());
13199 unsigned NumVars =
C->varlist_size();
13200 SmallVector<Expr *, 16> Vars;
13201 Vars.reserve(NumVars);
13202 for (
unsigned i = 0; i != NumVars; ++i)
13203 Vars.push_back(Record.readSubExpr());
13204 C->setVarRefs(Vars);
13207void OMPClauseReader::VisitOMPExclusiveClause(OMPExclusiveClause *
C) {
13208 C->setLParenLoc(Record.readSourceLocation());
13209 unsigned NumVars =
C->varlist_size();
13210 SmallVector<Expr *, 16> Vars;
13211 Vars.reserve(NumVars);
13212 for (
unsigned i = 0; i != NumVars; ++i)
13213 Vars.push_back(Record.readSubExpr());
13214 C->setVarRefs(Vars);
13217void OMPClauseReader::VisitOMPUsesAllocatorsClause(OMPUsesAllocatorsClause *
C) {
13218 C->setLParenLoc(Record.readSourceLocation());
13219 unsigned NumOfAllocators =
C->getNumberOfAllocators();
13220 SmallVector<OMPUsesAllocatorsClause::Data, 4>
Data;
13221 Data.reserve(NumOfAllocators);
13222 for (
unsigned I = 0; I != NumOfAllocators; ++I) {
13223 OMPUsesAllocatorsClause::Data &D =
Data.emplace_back();
13226 D.
LParenLoc = Record.readSourceLocation();
13227 D.
RParenLoc = Record.readSourceLocation();
13229 C->setAllocatorsData(
Data);
13232void OMPClauseReader::VisitOMPAffinityClause(OMPAffinityClause *
C) {
13233 C->setLParenLoc(Record.readSourceLocation());
13234 C->setModifier(Record.readSubExpr());
13235 C->setColonLoc(Record.readSourceLocation());
13236 unsigned NumOfLocators =
C->varlist_size();
13237 SmallVector<Expr *, 4> Locators;
13238 Locators.reserve(NumOfLocators);
13239 for (
unsigned I = 0; I != NumOfLocators; ++I)
13240 Locators.push_back(Record.readSubExpr());
13241 C->setVarRefs(Locators);
13244void OMPClauseReader::VisitOMPOrderClause(OMPOrderClause *
C) {
13247 C->setLParenLoc(Record.readSourceLocation());
13248 C->setKindKwLoc(Record.readSourceLocation());
13249 C->setModifierKwLoc(Record.readSourceLocation());
13252void OMPClauseReader::VisitOMPFilterClause(OMPFilterClause *
C) {
13254 C->setThreadID(Record.readSubExpr());
13255 C->setLParenLoc(Record.readSourceLocation());
13258void OMPClauseReader::VisitOMPBindClause(OMPBindClause *
C) {
13260 C->setLParenLoc(Record.readSourceLocation());
13261 C->setBindKindLoc(Record.readSourceLocation());
13265 C->setAlignment(Record.readExpr());
13266 C->setLParenLoc(Record.readSourceLocation());
13269void OMPClauseReader::VisitOMPXDynCGroupMemClause(OMPXDynCGroupMemClause *
C) {
13271 C->setSize(Record.readSubExpr());
13272 C->setLParenLoc(Record.readSourceLocation());
13275void OMPClauseReader::VisitOMPDynGroupprivateClause(
13276 OMPDynGroupprivateClause *
C) {
13278 C->setDynGroupprivateModifier(
13280 C->setDynGroupprivateFallbackModifier(
13282 C->setSize(Record.readSubExpr());
13283 C->setLParenLoc(Record.readSourceLocation());
13284 C->setDynGroupprivateModifierLoc(Record.readSourceLocation());
13285 C->setDynGroupprivateFallbackModifierLoc(Record.readSourceLocation());
13288void OMPClauseReader::VisitOMPDoacrossClause(OMPDoacrossClause *
C) {
13289 C->setLParenLoc(Record.readSourceLocation());
13290 C->setDependenceType(
13292 C->setDependenceLoc(Record.readSourceLocation());
13293 C->setColonLoc(Record.readSourceLocation());
13294 unsigned NumVars =
C->varlist_size();
13295 SmallVector<Expr *, 16> Vars;
13296 Vars.reserve(NumVars);
13297 for (
unsigned I = 0; I != NumVars; ++I)
13298 Vars.push_back(Record.readSubExpr());
13299 C->setVarRefs(Vars);
13300 for (
unsigned I = 0, E =
C->getNumLoops(); I < E; ++I)
13301 C->setLoopData(I, Record.readSubExpr());
13304void OMPClauseReader::VisitOMPXAttributeClause(OMPXAttributeClause *
C) {
13306 Record.readAttributes(Attrs);
13307 C->setAttrs(Attrs);
13308 C->setLocStart(Record.readSourceLocation());
13309 C->setLParenLoc(Record.readSourceLocation());
13310 C->setLocEnd(Record.readSourceLocation());
13313void OMPClauseReader::VisitOMPXBareClause(OMPXBareClause *
C) {}
13323 Selector.ScoreOrCondition =
nullptr;
13325 Selector.ScoreOrCondition = readExprRef();
13337 if (Reader->ReadingKind == ASTReader::Read_Stmt) {
13342 for (
unsigned I = 0, E =
Data->getNumClauses(); I < E; ++I)
13344 Data->setClauses(Clauses);
13345 if (
Data->hasAssociatedStmt())
13347 for (
unsigned I = 0, E =
Data->getNumChildren(); I < E; ++I)
13352 unsigned NumVars =
readInt();
13354 for (
unsigned I = 0; I < NumVars; ++I)
13360 unsigned NumExprs =
readInt();
13362 for (
unsigned I = 0; I < NumExprs; ++I)
13372 switch (ClauseKind) {
13387 bool isConditionExprClause =
readBool();
13388 if (isConditionExprClause) {
13393 unsigned NumVars =
readInt();
13395 for (
unsigned I = 0; I < NumVars; ++I)
13402 unsigned NumClauses =
readInt();
13404 for (
unsigned I = 0; I < NumClauses; ++I)
13438 for (
unsigned I = 0; I < VarList.size(); ++I) {
13441 RecipeList.push_back({Alloca});
13445 VarList, RecipeList, EndLoc);
13463 for (
unsigned I = 0; I < VarList.size(); ++I) {
13467 RecipeList.push_back({Recipe, RecipeTemp});
13471 VarList, RecipeList, EndLoc);
13522 LParenLoc, ModList, VarList, EndLoc);
13531 LParenLoc, ModList, VarList, EndLoc);
13540 LParenLoc, ModList, VarList, EndLoc);
13549 LParenLoc, ModList, VarList, EndLoc);
13555 AsyncExpr, EndLoc);
13563 DevNumExpr, QueuesLoc, QueueIdExprs,
13570 unsigned NumArchs =
readInt();
13572 for (
unsigned I = 0; I < NumArchs; ++I) {
13575 Archs.emplace_back(Loc, Ident);
13579 LParenLoc, Archs, EndLoc);
13587 for (
unsigned I = 0; I < VarList.size(); ++I) {
13591 3 *
sizeof(
int *));
13594 unsigned NumCombiners =
readInt();
13595 for (
unsigned I = 0; I < NumCombiners; ++I) {
13600 Combiners.push_back({LHS, RHS, Op});
13603 RecipeList.push_back({Recipe, Combiners});
13607 VarList, RecipeList, EndLoc);
13626 HasForce, LoopCount, EndLoc);
13630 unsigned NumClauses =
readInt();
13632 for (
unsigned I = 0; I < NumClauses; ++I)
13635 SizeExprs, EndLoc);
13639 unsigned NumExprs =
readInt();
13642 for (
unsigned I = 0; I < NumExprs; ++I) {
13648 GangKinds, Exprs, EndLoc);
13654 WorkerExpr, EndLoc);
13660 VectorExpr, EndLoc);
13672 LParenLoc, VarList, EndLoc);
13686 llvm_unreachable(
"Clause serialization not yet implemented");
13688 llvm_unreachable(
"Invalid Clause Kind");
13693 for (
unsigned I = 0; I < Clauses.size(); ++I)
13698 unsigned NumVars =
readInt();
13699 A->Clauses.resize(NumVars);
13706 llvm::FoldingSetNodeID ID;
13707 ID.AddString(PrimaryModuleName);
13708 return ID.computeStableHash();
13713 return std::nullopt;
13716 return std::nullopt;
13719 return std::nullopt;
Defines the clang::ASTContext interface.
static unsigned moduleKindForDiagnostic(ModuleKind Kind)
static void PassObjCImplDeclToConsumer(ObjCImplDecl *ImplD, ASTConsumer *Consumer)
Under non-PCH compilation the consumer receives the objc methods before receiving the implementation,...
static bool checkCodegenOptions(const CodeGenOptions &CGOpts, const CodeGenOptions &ExistingCGOpts, StringRef ModuleFilename, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true)
static llvm::Error doesntStartWithASTFileMagic(BitstreamCursor &Stream)
Whether Stream doesn't start with the AST file magic number 'CPCH'.
static std::vector< std::string > accumulateFeaturesAsWritten(std::vector< std::string > FeaturesAsWritten)
static LLVM_ATTRIBUTE_NOINLINE bool diagnoseLanguageOptionValueMismatch(DiagnosticsEngine *Diags, StringRef Description, StringRef ModuleFilename)
static bool isExtHandlingFromDiagsError(DiagnosticsEngine &Diags)
static std::pair< bool, bool > wasValidatedInBuildSession(const ModuleFile &MF, const HeaderSearchOptions &HSOpts)
Returns {build-session validation applies, MF was validated this session}.
static unsigned getModuleFileIndexForTypeID(serialization::TypeID ID)
static void collectMacroDefinitions(const PreprocessorOptions &PPOpts, MacroDefinitionsMap &Macros, SmallVectorImpl< StringRef > *MacroNames=nullptr)
Collect the macro definitions provided by the given preprocessor options.
static void markIdentifierFromAST(ASTReader &Reader, IdentifierInfo &II, bool IsModule)
static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method)
Move the given method to the back of the global list of methods.
static bool isDiagnosedResult(ASTReader::ASTReadResult ARR, unsigned Caps)
static bool isInterestingIdentifier(ASTReader &Reader, const IdentifierInfo &II, bool IsModule)
Whether the given identifier is "interesting".
static bool parseModuleFileExtensionMetadata(const SmallVectorImpl< uint64_t > &Record, StringRef Blob, ModuleFileExtensionMetadata &Metadata)
Parse a record and blob containing module file extension metadata.
static Module * getTopImportImplicitModule(ModuleManager &ModuleMgr, Preprocessor &PP)
Return the top import module if it is implicit, nullptr otherwise.
static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts, const PreprocessorOptions &ExistingPPOpts, StringRef ModuleFilename, bool ReadMacros, DiagnosticsEngine *Diags, FileManager &FileMgr, std::string &SuggestedPredefines, const LangOptions &LangOpts, OptionValidation Validation=OptionValidateContradictions)
Check the preprocessor options deserialized from the control block against the preprocessor options i...
static LLVM_ATTRIBUTE_NOINLINE bool diagnoseLanguageOptionFlagMismatch(DiagnosticsEngine *Diags, StringRef Description, bool SerializedValue, bool CurrentValue, StringRef ModuleFilename)
static void addMethodsToPool(Sema &S, ArrayRef< ObjCMethodDecl * > Methods, ObjCMethodList &List)
Add the given set of methods to the method list.
static bool checkDiagnosticMappings(DiagnosticsEngine &StoredDiags, DiagnosticsEngine &Diags, StringRef ModuleFilename, bool IsSystem, bool SystemHeaderWarningsInModule, bool Complain)
static bool isPredefinedType(serialization::TypeID ID)
static bool readBit(unsigned &Bits)
static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags, DiagnosticsEngine &Diags, StringRef ModuleFilename, bool Complain)
static std::optional< Type::TypeClass > getTypeClassForCode(TypeCode code)
static std::pair< unsigned, unsigned > readULEBKeyDataLength(const unsigned char *&P)
Read ULEB-encoded key length and data length.
static unsigned getStableHashForModuleName(StringRef PrimaryModuleName)
static LLVM_DUMP_METHOD void dumpModuleIDMap(StringRef Name, const ContinuousRangeMap< Key, ModuleFile *, InitialCapacity > &Map)
@ OptionValidateStrictMatches
@ OptionValidateContradictions
static bool checkTargetOptions(const TargetOptions &TargetOpts, const TargetOptions &ExistingTargetOpts, StringRef ModuleFilename, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true)
Compare the given set of target options against an existing set of target options.
static bool checkLanguageOptions(const LangOptions &LangOpts, const LangOptions &ExistingLangOpts, StringRef ModuleFilename, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true)
Compare the given set of language options against an existing set of language options.
static std::pair< StringRef, StringRef > getUnresolvedInputFilenames(const ASTReader::RecordData &Record, const StringRef InputBlob)
#define CHECK_TARGET_OPT(Field, Name)
static ASTFileSignature readASTFileSignature(StringRef PCH)
Reads and return the signature record from PCH's control block, or else returns 0.
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...
static unsigned getIndexForTypeID(serialization::TypeID ID)
static uint64_t readULEB(const unsigned char *&P)
static bool checkModuleCachePath(FileManager &FileMgr, StringRef ContextHash, StringRef ExistingSpecificModuleCachePath, StringRef ASTFilename, DiagnosticsEngine *Diags, const LangOptions &LangOpts, const PreprocessorOptions &PPOpts, const HeaderSearchOptions &HSOpts, const HeaderSearchOptions &ASTFileHSOpts)
Check that the specified and the existing module cache paths are equivalent.
Defines the clang::ASTSourceDescriptor class, which abstracts clang modules and precompiled header fi...
static StringRef bytes(const std::vector< T, Allocator > &v)
Defines the Diagnostic-related interfaces.
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
Defines the Diagnostic IDs-related interfaces.
static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::FileManager interface and associated types.
Defines the clang::FileSystemOptions interface.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Result
Implement __builtin_bit_cast and related operations.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
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.
llvm::MachO::Record Record
Defines the clang::MacroInfo and clang::MacroDirective classes.
Defines the clang::Module class, which describes a module in the source code.
Defines types useful for describing an Objective-C runtime.
Defines some OpenACC-specific enums and functions.
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
Defines an enumeration for C++ overloaded operators.
Defines the clang::Preprocessor interface.
Defines the clang::SanitizerKind enum.
This file declares semantic analysis for CUDA constructs.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis functions specific to RISC-V.
Defines the clang::SourceLocation class and associated facilities.
Defines implementation details of the clang::SourceManager class.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TargetOptions class.
#define IMPORT(DERIVED, BASE)
Defines the clang::TokenKind enum and support functions.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
Defines version macros and version-related utility functions for Clang.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
static OMPAffinityClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N locator items.
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
This represents 'bind' clause in the 'pragma omp ...' directives.
Contains data for OpenMP directives: clauses, children expressions/statements (helpers for codegen) a...
void Visit(PTR(OMPClause) S)
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents 'defaultmap' clause in the 'pragma omp ...' directive.
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N variables.
This represents implicit clause 'depobj' for the 'pragma omp depobj' directive. This clause does not ...
This represents 'destroy' clause in the 'pragma omp depobj' directive or the 'pragma omp interop' dir...
This represents 'detach' clause in the 'pragma omp task' directive.
This represents 'device' clause in the 'pragma omp ...' directive.
This represents 'dist_schedule' clause in the 'pragma omp ...' directive.
static OMPDoacrossClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N expressions.
This represents 'dyn_groupprivate' clause in 'pragma omp target ...' and 'pragma omp teams ....
static OMPExclusiveClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'filter' clause in the 'pragma omp ...' directive.
static OMPFlushClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static OMPFromClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents 'grainsize' clause in the 'pragma omp ...' directive.
static OMPHasDeviceAddrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents 'hint' clause in the 'pragma omp ...' directive.
static OMPInclusiveClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static OMPInitClause * CreateEmpty(const ASTContext &C, unsigned NumPrefs, unsigned NumAttrs)
Creates an empty clause sized for NumPrefs pref-specs and NumAttrs total attr() exprs across them.
static OMPIsDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
static OMPMapClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars original expressions, NumUniqueDeclarations declar...
This represents 'nocontext' clause in the 'pragma omp ...' directive.
This represents 'nogroup' clause in the 'pragma omp ...' directive.
static OMPNontemporalClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'novariants' clause in the 'pragma omp ...' directive.
This represents 'num_tasks' clause in the 'pragma omp ...' directive.
static OMPNumTeamsClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents 'order' clause in the 'pragma omp ...' directive.
This represents 'priority' clause in the 'pragma omp ...' directive.
This represents 'simd' clause in the 'pragma omp ...' directive.
static OMPThreadLimitClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents 'threads' clause in the 'pragma omp ...' directive.
static OMPToClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
llvm::SmallVector< OMPTraitSet, 2 > Sets
The outermost level of selector sets.
This represents the 'use' clause in 'pragma omp ...' directives.
static OMPUseDeviceAddrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
static OMPUseDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
static OMPUsesAllocatorsClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N allocators.
This represents 'ompx_attribute' clause in a directive that might generate an outlined function.
This represents 'ompx_bare' clause in the 'pragma omp target teams ...' directive.
This represents 'ompx_dyn_cgroup_mem' clause in the 'pragma omp target ...' directive.
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
virtual void HandleInterestingDecl(DeclGroupRef D)
HandleInterestingDecl - Handle the specified interesting declaration.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated,...
const clang::PrintingPolicy & getPrintingPolicy() const
void deduplicateMergedDefinitionsFor(NamedDecl *ND)
Clean up the merged definition list.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
void setPrimaryMergedDecl(Decl *D, Decl *Primary)
ASTIdentifierIterator(const ASTReader &Reader, bool SkipModules=false)
StringRef Next() override
Retrieve the next string in the identifier table and advances the iterator for the following string.
Abstract interface for callback invocations by the ASTReader.
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef ModuleFilename, StringRef ContextHash, bool Complain)
Receives the header search options.
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
virtual bool ReadDiagnosticOptions(DiagnosticOptions &DiagOpts, StringRef ModuleFilename, bool Complain)
Receives the diagnostic options.
virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences)
Receives the target options.
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...
virtual bool ReadHeaderSearchPaths(const HeaderSearchOptions &HSOpts, bool Complain)
Receives the header search paths.
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
virtual void visitModuleFile(ModuleFileName Filename, serialization::ModuleKind Kind, bool DirectlyImported)
This is called for each AST file loaded.
virtual ~ASTReaderListener()
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, StringRef ModuleFilename, bool ReadMacros, bool Complain, std::string &SuggestedPredefines)
Receives the preprocessor options.
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
virtual void ReadModuleName(StringRef ModuleName)
virtual void ReadCounter(const serialization::ModuleFile &M, uint32_t Value)
Receives COUNTER value.
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
virtual bool ReadCodeGenOptions(const CodeGenOptions &CGOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences)
Receives the codegen options.
Reads an AST files chain containing the contents of a translation unit.
std::optional< bool > isPreprocessedEntityInFileID(unsigned Index, FileID FID) override
Optionally returns true or false if the preallocated preprocessed entity with index Index came from f...
PreprocessedEntity * ReadPreprocessedEntity(unsigned Index) override
Read a preallocated preprocessed entity from the external source.
void markIdentifierUpToDate(const IdentifierInfo *II)
Note that this identifier is up-to-date.
void visitTopLevelModuleMaps(serialization::ModuleFile &MF, llvm::function_ref< void(FileEntryRef)> Visitor)
Visit all the top-level module maps loaded when building the given module file.
void setDeserializationListener(ASTDeserializationListener *Listener, bool TakeOwnership=false)
Set the AST deserialization listener.
SmallVectorImpl< uint64_t > RecordDataImpl
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID) const
Retrieve the global submodule ID given a module and its local ID number.
ExtKind hasExternalDefinitions(const Decl *D) override
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
ModuleManager & getModuleManager()
Retrieve the module manager.
bool isDeclIDFromModule(GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
friend class ASTIdentifierIterator
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallPtrSetImpl< const TypedefNameDecl * > &Decls) override
Read the set of potentially unused typedefs known to the source.
bool ReadSLocEntry(int ID) override
Read the source location entry with index ID.
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID)
Record that the given ID maps to the given switch-case statement.
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
Decl * ReadDecl(ModuleFile &F, const RecordDataImpl &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
static std::string ReadString(const RecordDataImpl &Record, unsigned &Idx)
void ReadDeclsToCheckForDeferredDiags(llvm::SmallSetVector< Decl *, 4 > &Decls) override
Read the set of decls to be checked for deferred diags.
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
@ ARR_Missing
The client can handle an AST file that cannot load because it is missing.
@ ARR_ConfigurationMismatch
The client can handle an AST file that cannot load because it's compiled configuration doesn't match ...
@ ARR_OutOfDate
The client can handle an AST file that cannot load because it is out-of-date relative to its input fi...
@ ARR_VersionMismatch
The client can handle an AST file that cannot load because it was built with a different version of C...
void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 > > &Exprs) override
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.
std::string ReadPathBlob(StringRef BaseDirectory, const RecordData &Record, unsigned &Idx, StringRef &Blob)
SourceRange ReadSkippedRange(unsigned Index) override
Read a preallocated skipped range from the external source.
serialization::TypeID getGlobalTypeID(ModuleFile &F, serialization::LocalTypeID LocalID) const
Map a local type ID within a given AST file into a global type ID.
void dump()
Dump information about the AST reader to standard error.
MacroInfo * ReadMacroRecord(ModuleFile &F, uint64_t Offset)
Reads the macro record located at the given offset.
SmallVector< std::pair< llvm::BitstreamCursor, serialization::ModuleFile * >, 8 > CommentsCursors
Cursors for comments blocks.
Selector getLocalSelector(ModuleFile &M, unsigned LocalID)
Retrieve a selector from the given module with its local ID number.
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.
ModuleFile * getOwningModuleFile(const Decl *D) const
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
std::optional< ASTSourceDescriptor > getSourceDescriptor(unsigned ID) override
Return a descriptor for the corresponding module.
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
T * ReadDeclAs(ModuleFile &F, const RecordDataImpl &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
QualType getLocalType(ModuleFile &F, serialization::LocalTypeID LocalID)
Resolve a local type ID within a given AST file into a type.
void ReadExtnameUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, AsmLabelAttr * > > &ExtnameIDs) override
Read the set of pragma redefine_extname'd, undeclared identifiers known to the external Sema source.
void ClearSwitchCaseIDs()
void SetGloballyVisibleDecls(IdentifierInfo *II, const SmallVectorImpl< GlobalDeclID > &DeclIDs, SmallVectorImpl< Decl * > *Decls=nullptr)
Set the globally-visible declarations associated with the given identifier.
serialization::ModuleKind ModuleKind
bool loadGlobalIndex()
Attempts to load the global index.
void ReadComments() override
Loads comments ranges.
SourceManager & getSourceManager() const
const serialization::reader::ModuleLocalLookupTable * getModuleLocalLookupTables(DeclContext *Primary) const
SourceLocation getSourceLocationForDeclID(GlobalDeclID ID)
Returns the source location for the decl ID.
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...
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a source range.
bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial) override
Load all the external specializations for the Decl.
ASTReadResult ReadASTCore(ModuleFileName FileName, ModuleKind Type, SourceLocation ImportLoc, ModuleFile *ImportedBy, SmallVectorImpl< ImportedModule > &Loaded, off_t ExpectedSize, time_t ExpectedModTime, ASTFileSignature ExpectedSignature, unsigned ClientLoadCapabilities)
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
Sema * getSema()
Retrieve the semantic analysis object used to analyze the translation unit in which the precompiled h...
static std::string ResolveImportedPathAndAllocate(SmallString< 0 > &Buf, StringRef Path, ModuleFile &ModF)
Resolve Path in the context of module file M.
static StringRef ReadStringBlob(const RecordDataImpl &Record, unsigned &Idx, StringRef &Blob)
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
void visitInputFileInfos(serialization::ModuleFile &MF, bool IncludeSystem, llvm::function_ref< void(const serialization::InputFileInfo &IFI, bool IsSystem)> Visitor)
Visit all the input file infos of the given module file.
unsigned getTotalNumSLocs() const
Returns the number of source locations found in the chain.
void StartTranslationUnit(ASTConsumer *Consumer) override
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
LocalDeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M, GlobalDeclID GlobalID)
Map a global declaration ID into the declaration ID used to refer to this declaration within the give...
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo)
void ReadTentativeDefinitions(SmallVectorImpl< VarDecl * > &TentativeDefs) override
Read the set of tentative definitions known to the external Sema source.
Decl * GetExternalDecl(GlobalDeclID ID) override
Resolve a declaration ID into a declaration, potentially building a new declaration.
serialization::MacroID ReadMacroID(ModuleFile &F, const RecordDataImpl &Record, unsigned &Idx)
Reads a macro ID from the given position in a record in the given module.
GlobalDeclID ReadDeclID(ModuleFile &F, const RecordDataImpl &Record, unsigned &Idx)
Reads a declaration ID from the given position in a record in the given module.
llvm::Expected< SourceLocation::UIntTy > readSLocOffset(ModuleFile *F, unsigned Index)
Try to read the offset of the SLocEntry at the given index in the given module file.
bool haveUnloadedSpecializations(const Decl *D) const
If we have any unloaded specialization for D.
friend class PCHValidator
friend class serialization::ReadMethodPoolVisitor
void CompleteRedeclChain(const Decl *D) override
If any redeclarations of D have been imported since it was last checked, this digs out those redeclar...
SourceLocation TranslateSourceLocation(ModuleFile &ModuleFile, SourceLocation Loc) const
Translate a source location from another module file's source location space into ours.
static llvm::Error ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID, uint64_t *StartOfBlockOffset=nullptr)
ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the specified cursor.
void SetIdentifierInfo(serialization::IdentifierID ID, IdentifierInfo *II)
std::pair< unsigned, unsigned > findPreprocessedEntitiesInRange(SourceRange Range) override
Returns a pair of [Begin, End) indices of preallocated preprocessed entities that Range encompasses.
IdentifierInfo * get(StringRef Name) override
Retrieve the IdentifierInfo for the named identifier.
IdentifierInfo * getLocalIdentifier(ModuleFile &M, uint64_t LocalID)
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.
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
llvm::iterator_range< ModuleDeclIterator > getModuleFileLevelDecls(ModuleFile &Mod)
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
MacroInfo * getMacro(serialization::MacroID ID)
Retrieve the macro with the given ID.
void ReadUndefinedButUsed(llvm::MapVector< NamedDecl *, SourceLocation > &Undefined) override
Load the set of used but not defined functions or variables with internal linkage,...
void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl * > &Decls) override
Read the set of delegating constructors known to the external Sema source.
QualType GetType(serialization::TypeID ID)
Resolve a type ID into a type, potentially building a new type.
void addPendingMacro(IdentifierInfo *II, ModuleFile *M, uint32_t MacroDirectivesOffset)
Add a macro to deserialize its macro directive history.
static std::pair< SourceLocation::UIntTy, SourceLocationEncoding::Chain > ReadSourceLocationOffset(const RecordDataImpl &Record, unsigned Idx, SourceLocation::UIntTy InitialDelta)
Read a source location offset from Record at Idx, returning it together with a chain anchored at that...
GlobalDeclID getGlobalDeclID(ModuleFile &F, LocalDeclID LocalID) const
Map from a local declaration ID within a given module to a global declaration ID.
void ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo > > &WeakIDs) override
Read the set of weak, undeclared identifiers known to the external Sema source.
void completeVisibleDeclsMap(const DeclContext *DC) override
Load all external visible decls in the given DeclContext.
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope.
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const ModuleCache &ModCache, const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions, ASTReaderListener &Listener, bool ValidateDiagnosticOptions, unsigned ClientLoadCapabilities=ARR_ConfigurationMismatch|ARR_OutOfDate)
Read the control block for the named AST file.
Module * getSubmodule(uint32_t GlobalID) override
Retrieve the submodule that corresponds to a global submodule ID.
void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl * > &Decls) override
Read the set of ext_vector type declarations known to the external Sema source.
SmallVector< GlobalDeclID, 16 > PreloadedDeclIDs
std::pair< SourceLocation, StringRef > getModuleImportLoc(int ID) override
Retrieve the module import location and module name for the given source manager entry ID.
void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl * > &Decls) override
Read the set of unused file-scope declarations known to the external Sema source.
void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation > > &Sels) override
Read the set of referenced selectors known to the external Sema source.
Selector DecodeSelector(serialization::SelectorID Idx)
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
friend class serialization::reader::ASTIdentifierLookupTrait
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
Decl * getKeyDeclaration(Decl *D)
Returns the first key declaration for the given declaration.
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name, const DeclContext *OriginalDC) override
Finds all the visible declarations with a given name.
static std::pair< SourceLocation::UIntTy, SourceLocationEncoding::Chain > ReadEntryOffset(const RecordDataImpl &Record)
Read an SLocEntry record's first field, returning it together with a chain anchored at that entry.
IdentifierInfo * DecodeIdentifierInfo(serialization::IdentifierID ID)
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons.
@ Success
The control block was read successfully.
@ ConfigurationMismatch
The AST file was written with a different language/target configuration.
@ OutOfDate
The AST file is out-of-date relative to its input files, and needs to be regenerated.
@ Failure
The AST file itself appears corrupted.
@ VersionMismatch
The AST file was written by a different version of Clang.
@ HadErrors
The AST file has errors.
@ Missing
The AST file was missing.
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx)
Reads a token out of a record.
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, uint64_t LocalID)
FileID TranslateFileID(ModuleFile &F, FileID FID) const
Translate a FileID from another module file's FileID space into ours.
void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate > > &LPTMap) override
Read the set of late parsed template functions for this source.
IdentifierIterator * getIdentifiers() override
Retrieve an iterator into the set of all identifiers in all loaded AST files.
void ReadUsedVTables(SmallVectorImpl< ExternalVTableUse > &VTables) override
Read the set of used vtables known to the external Sema source.
bool isGlobalIndexUnavailable() const
Determine whether we tried to load the global index, but failed, e.g., because it is out-of-date or d...
uint32_t GetNumExternalSelectors() override
Returns the number of selectors known to the external AST source.
static TemporarilyOwnedStringRef ResolveImportedPath(SmallString< 0 > &Buf, StringRef Path, ModuleFile &ModF)
Resolve Path in the context of module file M.
void updateOutOfDateSelector(Selector Sel) override
Load the contents of the global method pool for a given selector if necessary.
Decl * GetExistingDecl(GlobalDeclID ID)
Resolve a declaration ID into a declaration.
static llvm::BitVector ReadBitVector(const RecordData &Record, const StringRef Blob)
ModuleFile * getLocalModuleFile(ModuleFile &M, unsigned ID) const
Retrieve the module file with a given local ID within the specified ModuleFile.
ASTReader(Preprocessor &PP, ModuleCache &ModCache, ASTContext *Context, const PCHContainerReader &PCHContainerRdr, const CodeGenOptions &CodeGenOpts, ArrayRef< std::shared_ptr< ModuleFileExtension > > Extensions, StringRef isysroot="", DisableValidationForModuleKind DisableValidationKind=DisableValidationForModuleKind::None, bool AllowASTWithCompilerErrors=false, bool AllowConfigurationMismatch=false, bool ValidateSystemInputs=false, bool ForceValidateUserInputs=true, bool ValidateASTInputFilesContent=false, bool UseGlobalIndex=true, std::unique_ptr< llvm::Timer > ReadTimer={})
Load the AST file and validate its contents against the given Preprocessor.
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
void makeNamesVisible(const HiddenNames &Names, Module *Owner)
Make the names within this set of hidden names visible.
void UpdateSema()
Update the state of Sema after loading some additional modules.
Decl * GetDecl(GlobalDeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
Decl * GetLocalDecl(ModuleFile &F, LocalDeclID LocalID)
Reads a declaration with the given local ID in the given module.
int getSLocEntryID(SourceLocation::UIntTy SLocOffset) override
Get the index ID for the loaded SourceLocation offset.
SourceLocation ReadSourceLocation(ModuleFile &MF, RawLocEncoding Raw) const
Read a source location from raw form.
void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation > > &Pending) override
Read the set of pending instantiations known to the external Sema source.
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
serialization::reader::LazySpecializationInfoLookupTable * getLoadedSpecializationsLookupTables(const Decl *D, bool IsPartial)
Get the loaded specializations lookup tables for D, if any.
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
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...
void PrintStats() override
Print some statistics about AST usage.
static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, const ModuleCache &ModCache, const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts, const CodeGenOptions &CGOpts, const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts, const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool RequireStrictOptionMatches=false)
Determine whether the given AST file is acceptable to load into a translation unit with the given lan...
void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef)
Note that MergedDef is a redefinition of the canonical definition Def, so Def should be visible whene...
serialization::SelectorID getGlobalSelectorID(ModuleFile &M, unsigned LocalID) const
Retrieve the global selector ID that corresponds to this the local selector ID in a given module.
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
friend class ASTRecordReader
SmallVector< uint64_t, 64 > RecordData
FileID ReadFileID(ModuleFile &F, const RecordDataImpl &Record, unsigned &Idx) const
Read a FileID.
void StartedDeserializing() override
Notify ASTReader that we started deserialization of a decl or type so until FinishedDeserializing is ...
serialization::MacroID getGlobalMacroID(ModuleFile &M, serialization::MacroID LocalID)
Retrieve the global macro ID corresponding to the given local ID within the given module file.
void ReadMethodPool(Selector Sel) override
Load the contents of the global method pool for a given selector.
void InitializeContext()
Initializes the ASTContext.
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.
const serialization::reader::DeclContextLookupTable * getTULocalLookupTables(DeclContext *Primary) const
FileManager & getFileManager() const
bool wasThisDeclarationADefinition(const FunctionDecl *FD) override
True if this function declaration was a definition before in its own module.
void FinishedDeserializing() override
Notify ASTReader that we finished the deserialization of a decl or type.
void updateOutOfDateIdentifier(const IdentifierInfo &II) override
Update an out-of-date identifier.
ASTReadResult ReadAST(ModuleFileName FileName, ModuleKind Type, SourceLocation ImportLoc, unsigned ClientLoadCapabilities, ModuleFile **NewLoadedModuleFile=nullptr)
Load the AST file designated by the given file name.
void ReadDefinedMacros() override
Read the set of macros defined by this external macro source.
HeaderFileInfo GetHeaderFileInfo(FileEntryRef FE) override
Read the header file information for the given file entry.
void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
serialization::ModuleFile ModuleFile
bool hasGlobalIndex() const
Determine whether this AST reader has a global index.
serialization::PreprocessedEntityID getGlobalPreprocessedEntityID(ModuleFile &M, serialization::PreprocessedEntityID LocalID) const
Determine the global preprocessed entity ID that corresponds to the given local ID within the given m...
An object for streaming information from a record.
bool readBool()
Read a boolean value, advancing Idx.
uint32_t readUInt32()
Read a 32-bit unsigned value; required to satisfy BasicReader.
llvm::APFloat readAPFloat(const llvm::fltSemantics &Sem)
Read an arbitrary constant value, advancing Idx.
TemplateArgumentLoc readTemplateArgumentLoc()
Reads a TemplateArgumentLoc, advancing Idx.
SourceRange readSourceRange()
Read a source range, advancing Idx.
SourceLocation readSourceLocation()
Read a source location, advancing Idx.
void readUnresolvedSet(LazyASTUnresolvedSet &Set)
Read a UnresolvedSet structure, advancing Idx.
void readTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, bool Canonicalize=false)
Read a template argument array, advancing Idx.
void readQualifierInfo(QualifierInfo &Info)
DeclarationNameLoc readDeclarationNameLoc(DeclarationName Name)
Read a declaration name, advancing Idx.
CXXBaseSpecifier readCXXBaseSpecifier()
Read a C++ base specifier, advancing Idx.
QualType readType()
Read a type from the current position in the record.
T * readDeclAs()
Reads a declaration from the given position in the record, advancing Idx.
Expected< unsigned > readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID)
Reads a record with id AbbrevID from Cursor, resetting the internal state.
DeclarationNameInfo readDeclarationNameInfo()
void readTypeLoc(TypeLoc TL)
Reads the location information for a type.
IdentifierInfo * readIdentifier()
TemplateArgumentLocInfo readTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind, advancing Idx.
TemplateArgument readTemplateArgument(bool Canonicalize)
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
TypeSourceInfo * readTypeSourceInfo()
Reads a declarator info from the given record, advancing Idx.
void readTemplateArgumentListInfo(TemplateArgumentListInfo &Result)
TypeCoupledDeclRefInfo readTypeCoupledDeclRefInfo()
void skipInts(unsigned N)
Skips the specified number of values.
GlobalDeclID readDeclID()
Reads a declaration ID from the given position in this record.
NestedNameSpecifierLoc readNestedNameSpecifierLoc()
Return a nested name specifier, advancing Idx.
ConceptReference * readConceptReference()
void readOMPChildren(OMPChildren *Data)
Read an OpenMP children, advancing Idx.
OMPClause * readOMPClause()
Read an OpenMP clause, advancing Idx.
void readOpenACCClauseList(MutableArrayRef< const OpenACCClause * > Clauses)
Read a list of OpenACC clauses into the passed SmallVector, during statement reading.
OMPTraitInfo * readOMPTraitInfo()
Read an OMPTraitInfo object, advancing Idx.
TemplateParameterList * readTemplateParameterList()
Read a template parameter list, advancing Idx.
OpenACCClause * readOpenACCClause()
Read an OpenACC clause, advancing Idx.
llvm::SmallVector< Expr * > readOpenACCVarList()
Read a list of Exprs used for a var-list.
CXXCtorInitializer ** readCXXCtorInitializers()
Read a CXXCtorInitializer array, advancing Idx.
SpirvOperand readHLSLSpirvOperand()
Stmt * readStmt()
Reads a statement.
const ASTTemplateArgumentListInfo * readASTTemplateArgumentListInfo()
uint64_t readInt()
Returns the current value in this record, and advances to the next value.
Expr * readExpr()
Reads an expression.
void readOpenACCRoutineDeclAttr(OpenACCRoutineDeclAttr *A)
llvm::SmallVector< Expr * > readOpenACCIntExprList()
Read a list of Exprs used for a int-expr-list.
Expr * readSubExpr()
Reads a sub-expression operand during statement reading.
Abstracts clang modules and precompiled header files and holds everything needed to generate debug in...
Wrapper for source info for arrays.
void setLBracketLoc(SourceLocation Loc)
void setRBracketLoc(SourceLocation Loc)
void setSizeExpr(Expr *Size)
void setRParenLoc(SourceLocation Loc)
void setLParenLoc(SourceLocation Loc)
void setKWLoc(SourceLocation Loc)
Attr - This represents one attribute.
void setAttr(const Attr *A)
void setConceptReference(ConceptReference *CR)
void setRParenLoc(SourceLocation Loc)
void setCaretLoc(SourceLocation Loc)
void setWrittenTypeSpec(TypeSpecifierType written)
bool needsExtraLocalData() const
void setModeAttr(bool written)
void setBuiltinLoc(SourceLocation Loc)
void setWrittenWidthSpec(TypeSpecifierWidth written)
void setWrittenSignSpec(TypeSpecifierSign written)
Represents a base class of a C++ class.
Represents a C++ constructor within a class.
Represents a C++ base or member initializer.
void setSourceOrder(int Pos)
Set the source order of this initializer.
Represents a C++ destructor within a class.
Represents a C++ struct/union/class.
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
base_class_iterator bases_begin()
base_class_iterator vbases_begin()
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared.
Represents a C++ temporary.
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
void ReadCounter(const serialization::ModuleFile &M, uint32_t Value) override
Receives COUNTER value.
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...
bool ReadCodeGenOptions(const CodeGenOptions &CGOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences) override
Receives the codegen options.
bool ReadFullVersionInformation(StringRef FullVersion) override
Receives the full Clang version information.
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef ModuleFilename, StringRef ContextHash, bool Complain) override
Receives the header search options.
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain) override
Receives the file system options.
void ReadModuleMapFile(StringRef ModuleMapPath) override
bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
void visitModuleFile(ModuleFileName Filename, serialization::ModuleKind Kind, bool DirectlyImported) override
This is called for each AST file loaded.
bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
void ReadModuleName(StringRef ModuleName) override
bool needsInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, StringRef ModuleFilename, bool ReadMacros, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata) override
Indicates that a particular module file extension has been read.
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
bool ReadDiagnosticOptions(DiagnosticOptions &DiagOpts, StringRef ModuleFilename, bool Complain) override
Receives the diagnostic options.
CompatibilityKind
For ASTs produced with different option value, signifies their level of compatibility.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
A reference to a concept and its template args, as it appears in the code.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateName NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
const TypeClass * getTypePtr() const
A map from continuous integer ranges to some value, with a very specialized interface.
void insertOrReplace(const value_type &Val)
typename Representation::iterator iterator
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void setMustBuildLookupTable()
Mark that there are external lexical declarations that we need to include in our lookup table (and th...
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
void setHasExternalLexicalStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations lexically in this context.
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
bool isDeclInLexicalTraversal(const Decl *D) const
Determine whether the given declaration is stored in the list of declarations lexically within this c...
decl_iterator decls_begin() const
unsigned getModuleFileIndex() const
DeclID getRawValue() const
unsigned getLocalDeclIndex() const
uint64_t DeclID
An ID number that refers to a declaration in an AST file.
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
Kind
Lists the kind of concrete classes of Decl.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
SourceLocation getLocation() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
DeclContext * getDeclContext()
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
GlobalDeclID getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
DeclarationNameLoc - Additional source/type location info for a declaration name.
static DeclarationNameLoc makeNamedTypeLoc(TypeSourceInfo *TInfo)
Construct location information for a constructor, destructor or conversion operator.
static DeclarationNameLoc makeCXXLiteralOperatorNameLoc(SourceLocation Loc)
Construct location information for a literal C++ operator.
static DeclarationNameLoc makeCXXOperatorNameLoc(SourceLocation BeginLoc, SourceLocation EndLoc)
Construct location information for a non-literal C++ operator.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
const IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
NameKind
The kind of the name stored in this DeclarationName.
@ CXXConversionFunctionName
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
NameKind getNameKind() const
Determine what kind of name this is.
Represents a ValueDecl that came out of a declarator.
void setRParenLoc(SourceLocation Loc)
void setDecltypeLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setTemplateNameLoc(SourceLocation Loc)
void setAttrNameLoc(SourceLocation loc)
void setAttrOperandParensRange(SourceRange range)
void setAttrExprOperand(Expr *e)
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void setNameLoc(SourceLocation Loc)
void setNameLoc(SourceLocation Loc)
A little helper class used to produce diagnostics.
bool wasUpgradedFromWarning() const
Whether this mapping attempted to map the diagnostic to a warning, but was overruled because the diag...
bool isErrorOrFatal() const
void setSeverity(diag::Severity Value)
static DiagnosticMapping deserialize(unsigned Bits)
Deserialize a mapping.
void setUpgradedFromWarning(bool Value)
Options for controlling the compiler diagnostics engine.
std::vector< std::string > Remarks
The list of -R... options used to alter the diagnostic mappings, with the prefixes removed.
std::vector< std::string > Warnings
The list of -W... options used to alter the diagnostic mappings, with the prefixes removed.
std::vector< std::string > SystemHeaderWarningsModules
The list of -Wsystem-headers-in-module=... options used to override whether -Wsystem-headers is enabl...
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
DiagnosticOptions & getDiagnosticOptions() const
Retrieve the diagnostic options.
bool getEnableAllWarnings() const
Level
The level of the diagnostic, after it has been through mapping.
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
bool getSuppressSystemWarnings() const
bool getWarningsAsErrors() const
diag::Severity getExtensionHandlingBehavior() const
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
StringRef getName() const
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc)
This represents one expression.
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
static DeclContextLookupResult SetExternalVisibleDeclsForName(const DeclContext *DC, DeclarationName Name, ArrayRef< NamedDecl * > Decls)
uint32_t incrementGeneration(ASTContext &C)
Increment the current generation.
uint32_t getGeneration() const
Get the current generation of this AST source.
Represents difference between two FPOptions values.
static FPOptionsOverride getFromOpaqueInt(storage_type I)
FPOptions applyOverrides(FPOptions Base)
static FPOptions getFromOpaqueInt(storage_type Value)
Represents a member of a struct/union/class.
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
time_t getModificationTime() const
StringRef getName() const
The name of this FileEntry.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Implements support for file system lookup, file system caching, and directory search management.
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(FileEntryRef Entry, bool isVolatile=false, bool RequiresNullTerminator=true, std::optional< int64_t > MaybeLimit=std::nullopt, bool IsText=true)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
FileEntryRef getVirtualFileRef(StringRef Filename, off_t Size, time_t ModificationTime)
Retrieve a file entry for a "virtual" file that acts as if there were a file with the given name on d...
OptionalFileEntryRef getOptionalFileRef(StringRef Filename, bool OpenFile=false, bool CacheFailure=true, bool IsText=true)
Get a FileEntryRef if it exists, without doing anything on error.
Keeps track of options that affect how file operations are performed.
std::string WorkingDir
If set, paths are resolved as if the working directory was set to the value of WorkingDir.
Represents a function declaration or definition.
Represents a prototype with parameter type info, e.g.
ExtProtoInfo getExtProtoInfo() const
Wrapper for source info for functions.
unsigned getNumParams() const
void setLocalRangeBegin(SourceLocation L)
void setLParenLoc(SourceLocation Loc)
void setParam(unsigned i, ParmVarDecl *VD)
void setRParenLoc(SourceLocation Loc)
void setLocalRangeEnd(SourceLocation L)
void setExceptionSpecRange(SourceRange R)
llvm::SmallPtrSet< ModuleFile *, 4 > HitSet
A set of module files in which we found a result.
static std::pair< GlobalModuleIndex *, llvm::Error > readIndex(llvm::StringRef Path)
Read a global index file for the given directory.
One of these records is kept for each identifier that is lexed.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
bool isCPlusPlusOperatorKeyword() const
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
bool hadMacroDefinition() const
Returns true if this identifier was #defined to some value at any moment.
void setIsPoisoned(bool Value=true)
setIsPoisoned - Mark this identifier as poisoned.
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
bool isPoisoned() const
Return true if this token has been poisoned.
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
tok::NotableIdentifierKind getNotableIdentifierID() const
void setOutOfDate(bool OOD)
Set whether the information for this identifier is out of date with respect to the external source.
tok::ObjCKeywordKind getObjCKeywordID() const
Return the Objective-C keyword ID for the this identifier.
void setObjCOrBuiltinID(unsigned ID)
void revertTokenIDToIdentifier()
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility.
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
void setChangedSinceDeserialization()
Note that this identifier has changed since it was loaded from an AST file.
void * getFETokenInfo() const
Get and set FETokenInfo.
StringRef getName() const
Return the actual identifier string.
bool isExtensionToken() const
get/setExtension - Initialize information about whether or not this language token is an extension.
An iterator that walks over all of the known identifiers in the lookup table.
IdentifierIterator()=default
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
Implements an efficient mapping from strings to IdentifierInfo nodes.
llvm::MemoryBuffer * lookupPCM(llvm::StringRef Filename, off_t &Size, time_t &ModTime) const
Get a pointer to the PCM if it exists and set Size and ModTime to its on-disk size and modification t...
Record the location of an inclusion directive, such as an #include or #import statement.
InclusionKind
The kind of inclusion directives known to the preprocessor.
Represents a field injected from an anonymous union/struct into the parent scope.
Wrapper for source info for injected class names of class templates.
void setAmpLoc(SourceLocation Loc)
PragmaMSPointersToMembersKind
CompatibilityKind
For ASTs produced with different option value, signifies their level of compatibility.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
clang::ObjCRuntime ObjCRuntime
SanitizerSet Sanitize
Set of enabled sanitizers.
CommentOptions CommentOpts
Options for parsing comments.
std::string OMPHostIRFile
Name of the IR file that contains the result of the OpenMP target host code generation.
LangStandard::Kind LangStd
The used language standard.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
std::string CurrentModule
The name of the current module, of which the main source file is a part.
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
An UnresolvedSet-like class that might not have been loaded from the external AST source yet.
unsigned getLineTableFilenameID(StringRef Str)
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...
static LocalDeclID get(ASTReader &Reader, serialization::ModuleFile &MF, DeclID ID)
Record the location of a macro definition.
Encapsulates changes to the "macros namespace" (the location where the macro name became active,...
void setPrevious(MacroDirective *Prev)
Set previous definition of the macro with the same name.
Records the location of a macro expansion.
Encapsulates the data about a macro definition (e.g.
void setUsedForHeaderGuard(bool Val)
void setHasCommaPasting()
void setDefinitionEndLoc(SourceLocation EndLoc)
Set the location of the last token in the macro.
void setParameterList(ArrayRef< IdentifierInfo * > List, llvm::BumpPtrAllocator &PPAllocator)
Set the specified list of identifiers as the parameter list for this macro.
llvm::MutableArrayRef< Token > allocateTokens(unsigned NumTokens, llvm::BumpPtrAllocator &PPAllocator)
void setIsFunctionLike()
Function/Object-likeness.
void setIsC99Varargs()
Varargs querying methods. This can only be set for function-like macros.
void setIsUsed(bool Val)
Set the value of the IsUsed flag.
void setExpansionLoc(SourceLocation Loc)
void setAttrRowOperand(Expr *e)
void setAttrColumnOperand(Expr *e)
void setAttrOperandParensRange(SourceRange range)
void setAttrNameLoc(SourceLocation loc)
void setStarLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
The module cache used for compiling modules implicitly.
virtual std::optional< bool > isDirectoryInvalidated(StringRef Directory)
Whether the build system reported that Directory changed before the build session started,...
virtual InMemoryModuleCache & getInMemoryModuleCache()=0
Returns this process's view of the module cache.
Deduplication key for a loaded module file in ModuleManager.
Identifies a module file to be loaded.
bool empty() const
Checks whether the module file name is empty.
static ModuleFileName makeExplicit(std::string Name)
Creates a file name for an explicit module.
static ModuleFileName makeInMemory(StringRef Name)
Creates a file name for an in-memory module.
StringRef str() const
Returns the plain module file name.
static ModuleFileName makeFromRaw(StringRef Name, unsigned RawKind)
Creates a file name from the raw kind value.
void addLinkAsDependency(Module *Mod)
Make module to use export_as as the link dependency name if enough information is available or add it...
OptionalFileEntryRef getContainingModuleMapFile(const Module *Module) const
Module * findModule(StringRef Name) const
Retrieve an already loaded module with the given name.
void setUmbrellaHeaderAsWritten(Module *Mod, FileEntryRef UmbrellaHeader, const Twine &NameAsWritten, const Twine &PathRelativeToRootModuleDirectory, SourceLocation Loc=SourceLocation())
Sets the umbrella header of the given module to the given header.
void addHeader(Module *Mod, Module::Header Header, ModuleHeaderRole Role, bool Imported=false, SourceLocation Loc=SourceLocation())
Adds this header to the given module.
OptionalFileEntryRef findUmbrellaHeaderForModule(Module *M, std::string NameAsWritten, SmallVectorImpl< char > &RelativePathName)
Find the FileEntry for an umbrella header in a module as if it was written in the module map as a hea...
void setInferredModuleAllowedBy(Module *M, FileID ModMapFID)
void setUmbrellaDirAsWritten(Module *Mod, DirectoryEntryRef UmbrellaDir, const Twine &NameAsWritten, const Twine &PathRelativeToRootModuleDirectory, SourceLocation Loc=SourceLocation())
Sets the umbrella directory of the given module to the given directory.
llvm::DenseSet< FileEntryRef > AdditionalModMapsSet
Module * findOrCreateModuleFirst(StringRef Name, Module *Parent, bool IsFramework, bool IsExplicit)
Call ModuleMap::findOrCreateModule and throw away the information whether the module was found or cre...
Module * createModule(StringRef Name, Module *Parent, bool IsFramework, bool IsExplicit)
Create new submodule, assuming it does not exist.
static void canonicalizeDirectoryDependency(const FileManager &FileMgr, SmallVectorImpl< char > &Path)
Spell Path the way directory dependencies are recorded: absolute, with dots removed.
void resolveLinkAsDependencies(Module *Mod)
Use PendingLinkAsModule information to mark top level link names that are going to be replaced by exp...
ModuleHeaderRole
Flags describing the role of a module header.
Reference to a module that consists of either an existing/materialized Module object,...
Describes a module or submodule.
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
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.
SmallVector< ExportDecl, 2 > Exports
The set of export declarations.
unsigned InferSubmodules
Whether we should infer submodules for this module based on the headers.
std::vector< std::string > ConfigMacros
The set of "configuration macros", which are macros that (intentionally) change how this module is bu...
unsigned IsUnimportable
Whether this module has declared itself unimportable, either because it's missing a requirement from ...
NameVisibilityKind NameVisibility
The visibility of names within this particular module.
NameVisibilityKind
Describes the visibility of the various names within a particular module.
@ Hidden
All of the names in this module are hidden.
@ AllVisible
All of the names in this module are visible.
const ModuleFileKey * getASTFileKey() const
The serialized AST file key for this module, if one was created.
SourceLocation DefinitionLoc
The location of the module definition.
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system.
ModuleKind Kind
The kind of this module.
void addTopHeaderFilename(StringRef Filename)
Add a top-level header filename associated with this module.
bool isUnimportable() const
Determine whether this module has been declared unimportable.
void setASTFileNameAndKey(ModuleFileName NewName, ModuleFileKey NewKey)
Set the serialized module file for the top-level module of this module.
unsigned IsSystem
Whether this is a "system" module (which assumes that all headers in it are system headers).
std::string Name
The name of this module.
const ModuleFileName * getASTFileName() const
The serialized AST file name for this module, if one was created.
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "C"...
unsigned ModuleMapIsPrivate
Whether this module came from a "private" module map, found next to a regular (public) module map.
llvm::SmallVector< LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used.
SmallVector< UnresolvedExportDecl, 2 > UnresolvedExports
The set of export declarations that have yet to be resolved.
std::optional< Header > getUmbrellaHeaderAsWritten() const
Retrieve the umbrella header as written.
SmallVector< Requirement, 2 > Requirements
The set of language features required to use this module.
bool isHeaderLikeModule() const
Is this module have similar semantics as headers.
OptionalDirectoryEntryRef Directory
The build directory of this module.
llvm::SmallVector< ModuleRef, 2 > AffectingClangModules
The set of top-level modules that affected the compilation of this module, but were not imported.
unsigned NamedModuleHasInit
Whether this C++20 named modules doesn't need an initializer.
StringRef getPrimaryModuleInterfaceName() const
Get the primary module interface name from a partition.
unsigned ConfigMacrosExhaustive
Whether the set of configuration macros is exhaustive.
std::string PresumedModuleMapFile
The presumed file name for the module map defining this module.
ASTFileSignature Signature
The module signature.
bool isGlobalModule() const
Does this Module scope describe a fragment of the global module within some C++ module.
unsigned InferExportWildcard
Whether, when inferring submodules, the inferr submodules should export all modules they import (e....
void getExportedModules(SmallVectorImpl< Module * > &Exported) const
Appends this module's list of exported modules to Exported.
std::vector< UnresolvedConflict > UnresolvedConflicts
The list of conflicts for which the module-id has not yet been resolved.
unsigned IsFromModuleFile
Whether this module was loaded from a module file.
std::optional< DirectoryName > getUmbrellaDirAsWritten() const
Retrieve the umbrella directory as written.
std::string ExportAsModule
The module through which entities defined in this module will eventually be exposed,...
unsigned IsAvailable
Whether this module is available in the current translation unit.
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.
void addSubmodule(StringRef Name, Module *Submodule)
Add a child submodule.
llvm::SmallVector< ModuleRef, 2 > Imports
The set of modules imported by this module, and on which this module depends.
std::vector< Conflict > Conflicts
The list of conflicts.
This represents a decl that may have a name.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Appends a human-readable name for this declaration into the given stream.
Represent a C++ namespace.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
A C++ nested-name-specifier augmented with source location information.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
static 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...
This represents the 'align' clause in the 'pragma omp allocate' directive.
This represents clause 'allocate' in the 'pragma omp ...' directives.
static OMPAllocateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'allocator' clause in the 'pragma omp ...' directive.
void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C)
OMPClauseReader(ASTRecordReader &Record)
void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C)
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc.
Class that handles pre-initialization statement for some clauses, like 'schedule',...
This is a basic class for representing single OpenMP clause.
This represents 'collapse' clause in the 'pragma omp ...' directive.
This represents the 'counts' clause in the 'pragma omp split' directive.
static OMPCountsClause * CreateEmpty(const ASTContext &C, unsigned NumCounts)
Build an empty 'counts' AST node for deserialization.
This represents 'default' clause in the 'pragma omp ...' directive.
This represents the 'depth' clause on the 'pragma omp flatten' (and 'pragma omp fuse') loop-transform...
This represents 'final' clause in the 'pragma omp ...' directive.
Representation of the 'full' clause of the 'pragma omp unroll' directive.
This represents 'if' clause in the 'pragma omp ...' directive.
This class represents the 'looprange' clause in the 'pragma omp fuse' directive.
This represents 'num_threads' clause in the 'pragma omp ...' directive.
static OMPNumThreadsClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N expressions.
Representation of the 'partial' clause of the 'pragma omp unroll' directive.
This class represents the 'permutation' clause in the 'pragma omp interchange' directive.
static OMPPermutationClause * CreateEmpty(const ASTContext &C, unsigned NumLoops)
Build an empty 'permutation' AST node for deserialization.
This represents 'safelen' clause in the 'pragma omp ...' directive.
This represents 'simdlen' clause in the 'pragma omp ...' directive.
This represents the 'sizes' clause in the 'pragma omp tile' directive.
static OMPSizesClause * CreateEmpty(const ASTContext &C, unsigned NumSizes)
Build an empty 'sizes' AST node for deserialization.
This represents 'threadset' clause in the 'pragma omp task ...' directive.
method_range methods() const
void setNameLoc(SourceLocation Loc)
void setNameEndLoc(SourceLocation Loc)
ObjCMethodDecl - Represents an instance or class method declaration.
bool hasBody() const override
Determine whether this method has a body.
void setLazyBody(uint64_t Offset)
void setStarLoc(SourceLocation Loc)
void setTypeArgsRAngleLoc(SourceLocation Loc)
unsigned getNumTypeArgs() const
unsigned getNumProtocols() const
void setTypeArgsLAngleLoc(SourceLocation Loc)
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
void setProtocolLAngleLoc(SourceLocation Loc)
void setProtocolRAngleLoc(SourceLocation Loc)
void setHasBaseTypeAsWritten(bool HasBaseType)
void setProtocolLoc(unsigned i, SourceLocation Loc)
The basic abstraction for the target Objective-C runtime.
Kind
The basic Objective-C runtimes that we know about.
unsigned getNumProtocols() const
void setProtocolLoc(unsigned i, SourceLocation Loc)
void setProtocolLAngleLoc(SourceLocation Loc)
void setProtocolRAngleLoc(SourceLocation Loc)
static OpenACCAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCAttachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCAutoClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCBindClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, const IdentifierInfo *ID, SourceLocation EndLoc)
This is the base type for all OpenACC Clauses.
static OpenACCCollapseClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, bool HasForce, Expr *LoopCount, SourceLocation EndLoc)
static OpenACCCopyClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyInClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyOutClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCreateClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDefaultAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCDefaultClause * Create(const ASTContext &C, OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static OpenACCDeleteClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDetachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceNumClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCDevicePtrClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceResidentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceTypeClause * Create(const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< DeviceTypeArgument > Archs, SourceLocation EndLoc)
static OpenACCFinalizeClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCFirstPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCFirstPrivateRecipe > InitRecipes, SourceLocation EndLoc)
static OpenACCGangClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< OpenACCGangKind > GangKinds, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static OpenACCHostClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCIfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCIfPresentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCIndependentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCLinkClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNoCreateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNoHostClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCNumGangsClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static OpenACCNumWorkersClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCPresentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCPrivateRecipe > InitRecipes, SourceLocation EndLoc)
static OpenACCReductionClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCReductionOperator Operator, ArrayRef< Expr * > VarList, ArrayRef< OpenACCReductionRecipeWithStorage > Recipes, SourceLocation EndLoc)
static OpenACCSelfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCSeqClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCTileClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > SizeExprs, SourceLocation EndLoc)
static OpenACCUseDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCVectorClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCVectorLengthClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCWaitClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation EndLoc)
static OpenACCWorkerClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
void setAttrLoc(SourceLocation loc)
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
bool ReadDiagnosticOptions(DiagnosticOptions &DiagOpts, StringRef ModuleFilename, bool Complain) override
Receives the diagnostic options.
bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
void ReadCounter(const serialization::ModuleFile &M, uint32_t Value) override
Receives COUNTER value.
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, StringRef ModuleFilename, bool ReadMacros, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef ModuleFilename, StringRef ContextHash, bool Complain) override
Receives the header search options.
bool ReadCodeGenOptions(const CodeGenOptions &CGOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences) override
Receives the codegen options.
bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
void setEllipsisLoc(SourceLocation Loc)
void setEllipsisLoc(SourceLocation Loc)
void setRParenLoc(SourceLocation Loc)
void setLParenLoc(SourceLocation Loc)
Represents a parameter to a function.
void setKWLoc(SourceLocation Loc)
void setStarLoc(SourceLocation Loc)
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
std::vector< std::string > MacroIncludes
std::vector< std::string > Includes
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
std::string PCHThroughHeader
If non-empty, the filename used in an include directive in the primary source file (or command-line p...
bool DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
bool AllowPCHWithDifferentModulesCachePath
When true, a PCH with modules cache path different to the current compilation will not be rejected.
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
std::vector< std::pair< std::string, bool > > Macros
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Module * getCurrentModule()
Retrieves the module that we're currently building, if any.
HeaderSearch & getHeaderSearchInfo() const
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
@ FastWidth
The width of the "fast" qualifier mask.
@ FastMask
The fast qualifier mask.
void setAmpAmpLoc(SourceLocation Loc)
Wrapper for source info for record types.
Declaration of a redeclarable template.
This table allows us to fully hide how we implement multi-keyword caching.
Selector getNullarySelector(const IdentifierInfo *ID)
Selector getSelector(unsigned NumArgs, const IdentifierInfo **IIV)
Can create any sort of selector.
Selector getUnarySelector(const IdentifierInfo *ID)
Smart pointer class that efficiently represents Objective-C method names.
void * getAsOpaquePtr() const
void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method)
Add the given method to the list of globally-known methods.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
Sema - This implements semantic analysis and AST building for C.
void addExternalSource(IntrusiveRefCntPtr< ExternalSemaSource > E)
Registers an external source.
IdentifierResolver IdResolver
ASTReaderListenter implementation to set SuggestedPredefines of ASTReader which is required to use a ...
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, StringRef ModuleFilename, bool ReadMacros, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
A delta encoder for a run of source locations.
Encodes a location in the source.
static SourceLocation getFromRawEncoding(UIntTy Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
bool isFileOverridden(const FileEntry *File) const
Returns true if the file contents have been overridden.
OptionalFileEntryRef bypassFileContentsOverride(FileEntryRef File)
Bypass the overridden contents of a file.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
SourceLocation getFileLoc(SourceLocation Loc, unsigned MaxDepth=std::numeric_limits< unsigned >::max()) const
Given Loc, if it is a macro location return the expansion location or the spelling location,...
A trivial tuple used to represent a source range.
One instance of this struct is kept for every file loaded or used.
OptionalFileEntryRef ContentsEntry
References the file which the contents were actually loaded from.
std::optional< llvm::MemoryBufferRef > getBufferIfLoaded() const
Return the buffer, only if it has been loaded.
unsigned BufferOverridden
Indicates whether the buffer itself was provided to override the actual file contents.
OptionalFileEntryRef OrigEntry
Reference to the file entry representing this ContentCache.
Information about a FileID, basically just the logical file that it represents and include stack info...
void setHasLineDirectives()
Set the flag that indicates that this FileID has line table entries associated with it.
Stmt - This represents one statement.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
Options for controlling the target.
std::string Triple
The name of the target triple to compile for.
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings starting...
std::string ABI
If given, the name of the target ABI to use.
std::string TuneCPU
If given, the name of the target CPU to tune code for.
std::string CPU
If given, the name of the target CPU to generate code for.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line.
A convenient class for passing around template argument information.
Location wrapper for a TemplateArgument.
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
ArgKind
The kind of template argument we're storing.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
Stores a list of template parameters for a TemplateDecl and its derived classes.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
unsigned getNumArgs() const
MutableArrayRef< TemplateArgumentLocInfo > getArgLocInfos()
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc, SourceLocation NameLoc, SourceLocation LAngleLoc, SourceLocation RAngleLoc)
Token - This structure provides full information about a lexed token.
[BoundsSafety] Represents information of declarations referenced by the arguments of the counted_by a...
TypeLocReader(ASTRecordReader &Reader)
void VisitArrayTypeLoc(ArrayTypeLoc)
void VisitFunctionTypeLoc(FunctionTypeLoc)
void VisitTagTypeLoc(TagTypeLoc TL)
RetTy Visit(TypeLoc TyLoc)
Base wrapper for a particular "section" of type source info.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
void setUnmodifiedTInfo(TypeSourceInfo *TI) const
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
void setNameLoc(SourceLocation Loc)
The base class of the type hierarchy.
const T * getAs() const
Member-template getAs<specific type>'.
Base class for declarations which introduce a typedef-name.
void setLParenLoc(SourceLocation Loc)
void setTypeofLoc(SourceLocation Loc)
void setRParenLoc(SourceLocation Loc)
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
void setNameLoc(SourceLocation Loc)
Captures information about a #pragma weak directive.
@ Missing
The module file is missing.
@ OutOfDate
The module file is out-of-date.
@ NewlyLoaded
The module file was just loaded in response to this call.
@ None
State at construction.
@ AlreadyLoaded
The module file had already been loaded.
Source location and bit offset of a declaration.
A key used when looking up entities by DeclarationName.
unsigned getHash() const
Compute a fingerprint of this key for use in on-disk hash table.
DeclarationNameKey()=default
Information about a module that has been loaded by the ASTReader.
const PPEntityOffset * PreprocessedEntityOffsets
void * IdentifierLookupTable
A pointer to an on-disk hash table of opaque type IdentifierHashTable.
void * SelectorLookupTable
A pointer to an on-disk hash table of opaque type ASTSelectorLookupTable.
std::vector< std::unique_ptr< ModuleFileExtensionReader > > ExtensionReaders
The list of extension readers that are attached to this module file.
SourceLocation DirectImportLoc
The source location where the module was explicitly or implicitly imported in the local translation u...
StringRef Data
The serialized bitstream data for this file.
const serialization::ObjCCategoriesInfo * ObjCCategoriesMap
Array of category list location information within this module file, sorted by the definition ID.
uint64_t SubmodulesOffsetBase
Absolute offset of the start of the submodules block.
int SLocEntryBaseID
The base ID in the source manager's view of this module.
std::vector< std::string > DirectoryDependencies
Directories this module file depends on the listing of.
ModuleFileKey FileKey
The key ModuleManager used for the module file.
serialization::IdentifierID BaseIdentifierID
Base identifier ID for identifiers local to this module.
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
serialization::TypeID BaseTypeIndex
Base type ID for types local to this module as represented in the global type ID space.
unsigned LocalNumObjCCategoriesInMap
The number of redeclaration info entries in ObjCCategoriesMap.
uint64_t MacroOffsetsBase
Base file offset for the offsets in MacroOffsets.
const llvm::support::unaligned_uint64_t * InputFileOffsets
Relative offsets for all of the input file entries in the AST file.
std::vector< unsigned > PreloadIdentifierOffsets
Offsets of identifiers that we're going to preload within IdentifierTableData.
unsigned LocalNumIdentifiers
The number of identifiers in this AST file.
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLTYPES_BLOCK block.
const llvm::support::unaligned_uint64_t * SubmoduleOffsets
Relative offsets for all submodule entries in the AST file.
const unsigned char * IdentifierTableData
Actual data for the on-disk hash table of identifiers.
llvm::BitstreamCursor SubmodulesCursor
The cursor to the start of the submodules block.
uint64_t SLocEntryOffsetsBase
Base file offset for the offsets in SLocEntryOffsets.
llvm::BitstreamCursor InputFilesCursor
The cursor to the start of the input-files block.
std::vector< InputFile > InputFilesLoaded
The input files that have been loaded from this AST file.
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
llvm::SetVector< ModuleFile * > ImportedBy
List of modules which depend on this module.
const char * HeaderFileInfoTableData
Actual data for the on-disk hash table of header file information.
SourceLocation ImportLoc
The source location where this module was first imported.
const serialization::unaligned_decl_id_t * FileSortedDecls
Array of file-level DeclIDs sorted by file.
const uint32_t * SLocEntryOffsets
Offsets for all of the source location entries in the AST file.
llvm::BitstreamCursor MacroCursor
The cursor to the start of the preprocessor block, which stores all of the macro definitions.
FileID OriginalSourceFileID
The file ID for the original source file that was used to build this AST file.
time_t ModTime
Modification of the module file.
std::string ActualOriginalSourceFileName
The actual original source file name that was used to build this AST file.
uint64_t PreprocessorDetailStartOffset
The offset of the start of the preprocessor detail cursor.
std::vector< InputFileInfo > InputFileInfosLoaded
The input file infos that have been loaded from this AST file.
unsigned LocalNumSubmodules
The number of submodules in this module.
SourceLocation FirstLoc
The first source location in this module.
unsigned LocalTopLevelSubmoduleID
Local submodule ID of the top-level module.
ASTFileSignature ASTBlockHash
The signature of the AST block of the module file, this can be used to unique module files based on A...
uint64_t SourceManagerBlockStartOffset
The bit offset to the start of the SOURCE_MANAGER_BLOCK.
bool DidReadTopLevelSubmodule
Whether the top-level module has been read from the AST file.
std::string OriginalSourceFileName
The original source file name that was used to build the primary AST file, which may have been modifi...
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
bool HasTimestamps
Whether timestamps are included in this module file.
uint64_t InputFilesOffsetBase
Absolute offset of the start of the input-files block.
llvm::BitstreamCursor SLocEntryCursor
Cursor used to read source location entries.
unsigned NumPreprocessedEntities
bool RelocatablePCH
Whether this precompiled header is a relocatable PCH file.
const uint32_t * SelectorOffsets
Offsets into the selector lookup table's data array where each selector resides.
unsigned BaseDeclIndex
Base declaration index in ASTReader for declarations local to this module.
unsigned NumFileSortedDecls
unsigned LocalNumSLocEntries
The number of source location entries in this AST file.
void * HeaderFileInfoTable
The on-disk hash table that contains information about each of the header files.
unsigned Index
The index of this module in the list of modules.
unsigned NumUserInputFiles
llvm::BitstreamCursor Stream
The main bitstream cursor for the main block.
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
uint64_t SizeInBits
The size of this file, in bits.
const UnalignedUInt64 * TypeOffsets
Offset of each type within the bitstream, indexed by the type ID, or the representation of a Type*.
uint64_t GlobalBitOffset
The global bit offset (or base) of this module.
bool StandardCXXModule
Whether this module file is a standard C++ module.
unsigned LocalNumTypes
The number of types in this AST file.
StringRef ModuleOffsetMap
The module offset map data for this file.
const PPSkippedRange * PreprocessedSkippedRangeOffsets
uint64_t InputFilesValidationTimestamp
If non-zero, specifies the time when we last validated input files.
llvm::BitstreamCursor PreprocessorDetailCursor
The cursor to the start of the (optional) detailed preprocessing record block.
SourceLocation::UIntTy SLocEntryBaseOffset
The base offset in the source manager's view of this module.
bool isDirectlyImported() const
Determine whether this module was directly imported at any point during translation.
std::string ModuleMapPath
unsigned LocalBaseSubmoduleID
Base submodule ID for submodules local to this module within its own address space.
const DeclOffset * DeclOffsets
Offset of each declaration within the bitstream, indexed by the declaration ID (-1).
uint64_t MacroStartOffset
The offset of the start of the set of defined macros.
ASTFileSignature Signature
The signature of the module file, which may be used instead of the size and modification time to iden...
unsigned LocalNumMacros
The number of macros in this AST file.
unsigned NumPreprocessedSkippedRanges
const unsigned char * SelectorLookupTableData
A pointer to the character data that comprises the selector table.
void dump()
Dump debugging output for this module.
unsigned LocalNumDecls
The number of declarations in this AST file.
unsigned LocalNumHeaderFileInfos
The number of local HeaderFileInfo structures.
llvm::BitVector SearchPathUsage
The bit vector denoting usage of each header search entry (true = used).
InputFilesValidation InputFilesValidationStatus
Captures the high-level result of validating input files.
unsigned Generation
The generation of which this module file is a part.
const uint32_t * IdentifierOffsets
Offsets into the identifier table data.
ContinuousRangeMap< uint32_t, int, 2 > SelectorRemap
Remapping table for selector IDs in this module.
const uint32_t * MacroOffsets
Offsets of macros in the preprocessor block.
uint64_t ASTBlockStartOffset
The bit offset of the AST block of this module.
ModuleFileName FileName
The file name of the module file.
ContinuousRangeMap< uint32_t, int, 2 > SubmoduleRemap
Remapping table for submodule IDs in this module.
llvm::BitVector VFSUsage
The bit vector denoting usage of each VFS entry (true = used).
uint64_t DeclsBlockStartOffset
The offset to the start of the DECLTYPES_BLOCK block.
SmallVector< uint64_t, 8 > PragmaDiagMappings
Diagnostic IDs and their mappings that the user changed.
unsigned BasePreprocessedSkippedRangeID
Base ID for preprocessed skipped ranges local to this module.
unsigned LocalNumSelectors
The number of selectors new to this file.
ModuleKind Kind
The type of this module.
std::string ModuleName
The name of the module.
serialization::MacroID BaseMacroID
Base macro ID for macros local to this module.
SmallVector< uint64_t, 1 > ObjCCategories
The Objective-C category lists for categories known to this module.
std::string BaseDirectory
The base directory of the module.
llvm::SmallVector< ModuleFile *, 16 > TransitiveImports
List of modules which this modules dependent on.
Manages the set of modules loaded by an AST reader.
llvm::iterator_range< SmallVectorImpl< ModuleFile * >::const_iterator > pch_modules() const
A range covering the PCH and preamble module files loaded.
ModuleReverseIterator rbegin()
Reverse iterator to traverse all loaded modules.
unsigned size() const
Number of modules loaded.
Source range/offset of a preprocessed entity.
uint32_t getOffset() const
RawLocEncoding getBegin() const
RawLocEncoding getEnd() const
Source range of a skipped preprocessor region.
RawLocEncoding getBegin() const
RawLocEncoding getEnd() const
unsigned getFactoryBits() const
ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel, unsigned PriorGeneration)
ArrayRef< ObjCMethodDecl * > getInstanceMethods() const
Retrieve the instance methods found by this visitor.
ArrayRef< ObjCMethodDecl * > getFactoryMethods() const
Retrieve the instance methods found by this visitor.
bool instanceHasMoreThanOneDecl() const
bool operator()(ModuleFile &M)
bool factoryHasMoreThanOneDecl() const
unsigned getInstanceBits() const
static TypeIdx fromTypeID(TypeID ID)
32 aligned uint64_t in the AST file.
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
void ReadDataIntoImpl(const unsigned char *d, unsigned DataLen, data_type_builder &Val)
file_type ReadFileRef(const unsigned char *&d)
DeclarationNameKey ReadKeyBase(const unsigned char *&d)
internal_key_type ReadKey(const unsigned char *d, unsigned)
DeclarationNameKey internal_key_type
void ReadDataInto(internal_key_type, const unsigned char *d, unsigned DataLen, data_type_builder &Val)
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
static hash_value_type ComputeHash(const internal_key_type &a)
StringRef internal_key_type
static internal_key_type ReadKey(const unsigned char *d, unsigned n)
Class that performs lookup for an identifier stored in an AST file.
IdentifierID ReadIdentifierID(const unsigned char *d)
data_type ReadData(const internal_key_type &k, const unsigned char *d, unsigned DataLen)
Class that performs lookup for a selector's entries in the global method pool stored in an AST file.
internal_key_type ReadKey(const unsigned char *d, unsigned)
data_type ReadData(Selector, const unsigned char *d, unsigned DataLen)
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
static hash_value_type ComputeHash(Selector Sel)
external_key_type internal_key_type
Class that performs lookup to specialized decls.
file_type ReadFileRef(const unsigned char *&d)
void ReadDataInto(internal_key_type, const unsigned char *d, unsigned DataLen, data_type_builder &Val)
unsigned internal_key_type
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
internal_key_type ReadKey(const unsigned char *d, unsigned)
std::pair< DeclarationName, const Module * > external_key_type
void ReadDataInto(internal_key_type, const unsigned char *d, unsigned DataLen, data_type_builder &Val)
std::pair< DeclarationNameKey, unsigned > internal_key_type
internal_key_type ReadKey(const unsigned char *d, unsigned)
static hash_value_type ComputeHash(const internal_key_type &Key)
static internal_key_type GetInternalKey(const external_key_type &Key)
PredefinedTypeIDs
Predefined type IDs.
CtorInitializerType
The different kinds of data that can occur in a CtorInitializer.
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
const unsigned NumSpecialTypeIDs
The number of special type IDs.
TypeCode
Record codes for each kind of type.
@ PREDEF_TYPE_LONG_ACCUM_ID
The 'long _Accum' type.
@ PREDEF_TYPE_SAMPLER_ID
OpenCL sampler type.
@ PREDEF_TYPE_INT128_ID
The '__int128_t' type.
@ PREDEF_TYPE_CHAR32_ID
The C++ 'char32_t' type.
@ PREDEF_TYPE_SAT_SHORT_ACCUM_ID
The '_Sat short _Accum' type.
@ PREDEF_TYPE_IBM128_ID
The '__ibm128' type.
@ PREDEF_TYPE_SHORT_FRACT_ID
The 'short _Fract' type.
@ PREDEF_TYPE_AUTO_RREF_DEDUCT
The "auto &&" deduction type.
@ PREDEF_TYPE_BOUND_MEMBER
The placeholder type for bound member functions.
@ PREDEF_TYPE_LONGLONG_ID
The (signed) 'long long' type.
@ PREDEF_TYPE_FRACT_ID
The '_Fract' type.
@ PREDEF_TYPE_ARC_UNBRIDGED_CAST
ARC's unbridged-cast placeholder type.
@ PREDEF_TYPE_USHORT_FRACT_ID
The 'unsigned short _Fract' type.
@ PREDEF_TYPE_SAT_ULONG_FRACT_ID
The '_Sat unsigned long _Fract' type.
@ PREDEF_TYPE_BOOL_ID
The 'bool' or '_Bool' type.
@ PREDEF_TYPE_SAT_LONG_ACCUM_ID
The '_Sat long _Accum' type.
@ PREDEF_TYPE_SAT_LONG_FRACT_ID
The '_Sat long _Fract' type.
@ PREDEF_TYPE_SAT_SHORT_FRACT_ID
The '_Sat short _Fract' type.
@ PREDEF_TYPE_CHAR_U_ID
The 'char' type, when it is unsigned.
@ PREDEF_TYPE_RESERVE_ID_ID
OpenCL reserve_id type.
@ PREDEF_TYPE_SAT_ACCUM_ID
The '_Sat _Accum' type.
@ PREDEF_TYPE_BUILTIN_FN
The placeholder type for builtin functions.
@ PREDEF_TYPE_SHORT_ACCUM_ID
The 'short _Accum' type.
@ PREDEF_TYPE_FLOAT_ID
The 'float' type.
@ PREDEF_TYPE_QUEUE_ID
OpenCL queue type.
@ PREDEF_TYPE_INT_ID
The (signed) 'int' type.
@ PREDEF_TYPE_OBJC_SEL
The ObjC 'SEL' type.
@ PREDEF_TYPE_BFLOAT16_ID
The '__bf16' type.
@ PREDEF_TYPE_WCHAR_ID
The C++ 'wchar_t' type.
@ PREDEF_TYPE_UCHAR_ID
The 'unsigned char' type.
@ PREDEF_TYPE_UACCUM_ID
The 'unsigned _Accum' type.
@ PREDEF_TYPE_SCHAR_ID
The 'signed char' type.
@ PREDEF_TYPE_CHAR_S_ID
The 'char' type, when it is signed.
@ PREDEF_TYPE_NULLPTR_ID
The type of 'nullptr'.
@ PREDEF_TYPE_ULONG_FRACT_ID
The 'unsigned long _Fract' type.
@ PREDEF_TYPE_FLOAT16_ID
The '_Float16' type.
@ PREDEF_TYPE_UINT_ID
The 'unsigned int' type.
@ PREDEF_TYPE_FLOAT128_ID
The '__float128' type.
@ PREDEF_TYPE_OBJC_ID
The ObjC 'id' type.
@ PREDEF_TYPE_CHAR16_ID
The C++ 'char16_t' type.
@ PREDEF_TYPE_ARRAY_SECTION
The placeholder type for an array section.
@ PREDEF_TYPE_ULONGLONG_ID
The 'unsigned long long' type.
@ PREDEF_TYPE_SAT_UFRACT_ID
The '_Sat unsigned _Fract' type.
@ PREDEF_TYPE_USHORT_ID
The 'unsigned short' type.
@ PREDEF_TYPE_SHORT_ID
The (signed) 'short' type.
@ PREDEF_TYPE_OMP_ARRAY_SHAPING
The placeholder type for OpenMP array shaping operation.
@ PREDEF_TYPE_DEPENDENT_ID
The placeholder type for dependent types.
@ PREDEF_TYPE_LONGDOUBLE_ID
The 'long double' type.
@ PREDEF_TYPE_DOUBLE_ID
The 'double' type.
@ PREDEF_TYPE_UINT128_ID
The '__uint128_t' type.
@ PREDEF_TYPE_HALF_ID
The OpenCL 'half' / ARM NEON __fp16 type.
@ PREDEF_TYPE_VOID_ID
The void type.
@ PREDEF_TYPE_SAT_USHORT_FRACT_ID
The '_Sat unsigned short _Fract' type.
@ PREDEF_TYPE_META_INFO_ID
C++26 std::meta::info type.
@ PREDEF_TYPE_ACCUM_ID
The '_Accum' type.
@ PREDEF_TYPE_SAT_FRACT_ID
The '_Sat _Fract' type.
@ PREDEF_TYPE_NULL_ID
The NULL type.
@ PREDEF_TYPE_USHORT_ACCUM_ID
The 'unsigned short _Accum' type.
@ PREDEF_TYPE_CHAR8_ID
The C++ 'char8_t' type.
@ PREDEF_TYPE_UFRACT_ID
The 'unsigned _Fract' type.
@ PREDEF_TYPE_OVERLOAD_ID
The placeholder type for overloaded function sets.
@ PREDEF_TYPE_INCOMPLETE_MATRIX_IDX
A placeholder type for incomplete matrix index operations.
@ PREDEF_TYPE_UNRESOLVED_TEMPLATE
The placeholder type for unresolved templates.
@ PREDEF_TYPE_SAT_USHORT_ACCUM_ID
The '_Sat unsigned short _Accum' type.
@ PREDEF_TYPE_LONG_ID
The (signed) 'long' type.
@ PREDEF_TYPE_SAT_ULONG_ACCUM_ID
The '_Sat unsigned long _Accum' type.
@ PREDEF_TYPE_LONG_FRACT_ID
The 'long _Fract' type.
@ PREDEF_TYPE_UNKNOWN_ANY
The 'unknown any' placeholder type.
@ PREDEF_TYPE_OMP_ITERATOR
The placeholder type for OpenMP iterator expression.
@ PREDEF_TYPE_PSEUDO_OBJECT
The pseudo-object placeholder type.
@ PREDEF_TYPE_OBJC_CLASS
The ObjC 'Class' type.
@ PREDEF_TYPE_ULONG_ID
The 'unsigned long' type.
@ PREDEF_TYPE_SAT_UACCUM_ID
The '_Sat unsigned _Accum' type.
@ PREDEF_TYPE_CLK_EVENT_ID
OpenCL clk event type.
@ PREDEF_TYPE_EVENT_ID
OpenCL event type.
@ PREDEF_TYPE_ULONG_ACCUM_ID
The 'unsigned long _Accum' type.
@ PREDEF_TYPE_AUTO_DEDUCT
The "auto" deduction type.
@ CTOR_INITIALIZER_MEMBER
@ CTOR_INITIALIZER_DELEGATING
@ CTOR_INITIALIZER_INDIRECT_MEMBER
@ DECL_CXX_BASE_SPECIFIERS
A record containing CXXBaseSpecifiers.
@ DECL_PARTIAL_SPECIALIZATIONS
@ DECL_CONTEXT_TU_LOCAL_VISIBLE
A record that stores the set of declarations that are only visible to the TU.
@ DECL_CONTEXT_LEXICAL
A record that stores the set of declarations that are lexically stored within a given DeclContext.
@ DECL_CXX_CTOR_INITIALIZERS
A record containing CXXCtorInitializers.
@ DECL_CONTEXT_MODULE_LOCAL_VISIBLE
A record containing the set of declarations that are only visible from DeclContext in the same module...
@ DECL_CONTEXT_VISIBLE
A record that stores the set of declarations that are visible from a given DeclContext.
@ TYPE_EXT_QUAL
An ExtQualType record.
@ SPECIAL_TYPE_OBJC_SEL_REDEFINITION
Objective-C "SEL" redefinition type.
@ SPECIAL_TYPE_UCONTEXT_T
C ucontext_t typedef type.
@ SPECIAL_TYPE_JMP_BUF
C jmp_buf typedef type.
@ SPECIAL_TYPE_FILE
C FILE typedef type.
@ SPECIAL_TYPE_SIGJMP_BUF
C sigjmp_buf typedef type.
@ SPECIAL_TYPE_OBJC_CLASS_REDEFINITION
Objective-C "Class" redefinition type.
@ SPECIAL_TYPE_CF_CONSTANT_STRING
CFConstantString type.
@ SPECIAL_TYPE_OBJC_ID_REDEFINITION
Objective-C "id" redefinition type.
Defines the clang::TargetInfo interface.
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
internal::Matcher< T > findAll(const internal::Matcher< T > &Matcher)
Matches if the node or any descendant matches.
@ ModuleFile
The module file (.pcm). Required.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing),...
@ Warning
Present this diagnostic as a warning.
@ Error
Present this diagnostic as an error.
IncludeDirGroup
IncludeDirGroup - Identifies the group an include Entry belongs to, representing its relative positiv...
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
llvm::OnDiskChainedHashTable< ASTSelectorLookupTrait > ASTSelectorLookupTable
The on-disk hash table used for the global method pool.
llvm::OnDiskChainedHashTable< HeaderFileInfoTrait > HeaderFileInfoLookupTable
The on-disk hash table used for known header files.
llvm::OnDiskIterableChainedHashTable< ASTIdentifierLookupTrait > ASTIdentifierLookupTable
The on-disk hash table used to contain information about all of the identifiers in the program.
GlobalDeclID LazySpecializationInfo
@ EXTENSION_METADATA
Metadata describing this particular extension.
SubmoduleRecordTypes
Record types used within a submodule description block.
@ SUBMODULE_EXCLUDED_HEADER
Specifies a header that has been explicitly excluded from this submodule.
@ SUBMODULE_TOPHEADER
Specifies a top-level header that falls into this (sub)module.
@ SUBMODULE_PRIVATE_TEXTUAL_HEADER
Specifies a header that is private to this submodule but must be textually included.
@ SUBMODULE_HEADER
Specifies a header that falls into this (sub)module.
@ SUBMODULE_EXPORT_AS
Specifies the name of the module that will eventually re-export the entities in this module.
@ SUBMODULE_UMBRELLA_DIR
Specifies an umbrella directory.
@ SUBMODULE_UMBRELLA_HEADER
Specifies the umbrella header used to create this module, if any.
@ SUBMODULE_REQUIRES
Specifies a required feature.
@ SUBMODULE_PRIVATE_HEADER
Specifies a header that is private to this submodule.
@ SUBMODULE_IMPORTS
Specifies the submodules that are imported by this submodule.
@ SUBMODULE_CONFLICT
Specifies a conflict with another module.
@ SUBMODULE_CHILD
Specifies a direct submodule by name and ID, enabling on-demand deserialization of children without l...
@ SUBMODULE_INITIALIZERS
Specifies some declarations with initializers that must be emitted to initialize the module.
@ SUBMODULE_END
Defines the end of a single submodule. Sentinel record without any data.
@ SUBMODULE_DEFINITION
Defines the major attributes of a submodule, including its name and parent.
@ SUBMODULE_LINK_LIBRARY
Specifies a library or framework to link against.
@ SUBMODULE_CONFIG_MACRO
Specifies a configuration macro for this module.
@ SUBMODULE_EXPORTS
Specifies the submodules that are re-exported from this submodule.
@ SUBMODULE_TEXTUAL_HEADER
Specifies a header that is part of the module but must be textually included.
@ SUBMODULE_AFFECTING_MODULES
Specifies affecting modules that were not imported.
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
@ SkippedInBuildSession
When the validation is skipped because it was already done in the current build session.
@ AllFiles
When the validation is done both for user files and system files.
@ Disabled
When the validation is disabled. For example, for a precompiled header.
@ UserFiles
When the validation is done only for user files as an optimization.
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
OptionsRecordTypes
Record types that occur within the options block inside the control block.
@ FILE_SYSTEM_OPTIONS
Record code for the filesystem options table.
@ TARGET_OPTIONS
Record code for the target options table.
@ PREPROCESSOR_OPTIONS
Record code for the preprocessor options table.
@ HEADER_SEARCH_OPTIONS
Record code for the headers search options table.
@ CODEGEN_OPTIONS
Record code for the codegen options table.
@ LANGUAGE_OPTIONS
Record code for the language options table.
const unsigned int NUM_PREDEF_PP_ENTITY_IDS
The number of predefined preprocessed entity IDs.
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
@ SUBMODULE_BLOCK_ID
The block containing the submodule structure.
@ PREPROCESSOR_DETAIL_BLOCK_ID
The block containing the detailed preprocessing record.
@ AST_BLOCK_ID
The AST block, which acts as a container around the full AST block.
@ SOURCE_MANAGER_BLOCK_ID
The block containing information about the source manager.
@ CONTROL_BLOCK_ID
The control block, which contains all of the information that needs to be validated prior to committi...
@ DECLTYPES_BLOCK_ID
The block containing the definitions of all of the types and decls used within the AST file.
@ PREPROCESSOR_BLOCK_ID
The block containing information about the preprocessor.
@ COMMENTS_BLOCK_ID
The block containing comments.
@ UNHASHED_CONTROL_BLOCK_ID
A block with unhashed content.
@ EXTENSION_BLOCK_ID
A block containing a module file extension.
@ OPTIONS_BLOCK_ID
The block of configuration options, used to check that a module is being used in a configuration comp...
@ INPUT_FILES_BLOCK_ID
The block of input files, which were used as inputs to create this AST file.
unsigned StableHashForTemplateArguments(llvm::ArrayRef< TemplateArgument > Args)
Calculate a stable hash value for template arguments.
CommentRecordTypes
Record types used within a comments block.
DeclIDBase::DeclID DeclID
An ID number that refers to a declaration in an AST file.
@ SM_SLOC_FILE_ENTRY
Describes a source location entry (SLocEntry) for a file.
@ SM_SLOC_BUFFER_BLOB_COMPRESSED
Describes a zlib-compressed blob that contains the data for a buffer entry.
@ SM_SLOC_BUFFER_ENTRY
Describes a source location entry (SLocEntry) for a buffer.
@ SM_SLOC_BUFFER_BLOB
Describes a blob that contains the data for a buffer entry.
@ SM_SLOC_EXPANSION_ENTRY
Describes a source location entry (SLocEntry) for a macro expansion.
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
uint64_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
llvm::support::detail::packed_endian_specific_integral< serialization::DeclID, llvm::endianness::native, llvm::support::unaligned > unaligned_decl_id_t
PreprocessorRecordTypes
Record types used within a preprocessor block.
@ PP_TOKEN
Describes one token.
@ PP_MACRO_FUNCTION_LIKE
A function-like macro definition.
@ PP_MACRO_OBJECT_LIKE
An object-like macro definition.
@ PP_MACRO_DIRECTIVE_HISTORY
The macro directives history for a particular identifier.
@ PP_MODULE_MACRO
A macro directive exported by a module.
ControlRecordTypes
Record types that occur within the control block.
@ MODULE_DIRECTORY_DEPENDENCIES
Record code for the directories this AST file depends on the listing of.
@ MODULE_MAP_FILE
Record code for the module map file that was used to build this AST file.
@ MODULE_DIRECTORY
Record code for the module build directory.
@ ORIGINAL_FILE_ID
Record code for file ID of the file or buffer that was used to generate the AST file.
@ MODULE_NAME
Record code for the module name.
@ ORIGINAL_FILE
Record code for the original file that was used to generate the AST file, including both its file ID ...
@ IMPORT
Record code for another AST file imported by this AST file.
@ INPUT_FILE_OFFSETS
Offsets into the input-files block where input files reside.
@ METADATA
AST file metadata, including the AST file version number and information about the compiler used to b...
UnhashedControlBlockRecordTypes
Record codes for the unhashed control block.
@ DIAGNOSTIC_OPTIONS
Record code for the diagnostic options table.
@ HEADER_SEARCH_ENTRY_USAGE
Record code for the indices of used header search entries.
@ AST_BLOCK_HASH
Record code for the content hash of the AST block.
@ DIAG_PRAGMA_MAPPINGS
Record code for #pragma diagnostic mappings.
@ SIGNATURE
Record code for the signature that identifiers this AST file.
@ HEADER_SEARCH_PATHS
Record code for the headers search paths.
@ VFS_USAGE
Record code for the indices of used VFSs.
uint64_t MacroID
An ID number that refers to a macro in an AST file.
InputFileRecordTypes
Record types that occur within the input-files block inside the control block.
@ INPUT_FILE_HASH
The input file content hash.
@ INPUT_FILE
An input file.
uint64_t TypeID
An ID number that refers to a type in an AST file.
PreprocessorDetailRecordTypes
Record types used within a preprocessor detail block.
@ PPD_INCLUSION_DIRECTIVE
Describes an inclusion directive within the preprocessing record.
@ PPD_MACRO_EXPANSION
Describes a macro expansion within the preprocessing record.
@ PPD_MACRO_DEFINITION
Describes a macro definition within the preprocessing record.
ModuleKind
Specifies the kind of module that has been loaded.
@ MK_PCH
File is a PCH file treated as such.
@ MK_Preamble
File is a PCH file treated as the preamble.
@ MK_MainFile
File is a PCH file treated as the actual main file.
@ MK_ExplicitModule
File is an explicitly-loaded module.
@ MK_ImplicitModule
File is an implicitly-loaded module.
@ MK_PrebuiltModule
File is from a prebuilt module path.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
ASTRecordTypes
Record types that occur within the AST block itself.
@ DECL_UPDATE_OFFSETS
Record for offsets of DECL_UPDATES records for declarations that were modified after being deserializ...
@ STATISTICS
Record code for the extra statistics we gather while generating an AST file.
@ FLOAT_CONTROL_PRAGMA_OPTIONS
Record code for #pragma float_control options.
@ KNOWN_NAMESPACES
Record code for the set of known namespaces, which are used for typo correction.
@ SPECIAL_TYPES
Record code for the set of non-builtin, special types.
@ PENDING_IMPLICIT_INSTANTIATIONS
Record code for pending implicit instantiations.
@ CXX_ADDED_TEMPLATE_SPECIALIZATION
@ TYPE_OFFSET
Record code for the offsets of each type.
@ DELEGATING_CTORS
The list of delegating constructor declarations.
@ PP_ASSUME_NONNULL_LOC
ID 66 used to be the list of included files.
@ EXT_VECTOR_DECLS
Record code for the set of ext_vector type names.
@ OPENCL_EXTENSIONS
Record code for enabled OpenCL extensions.
@ FP_PRAGMA_OPTIONS
Record code for floating point #pragma options.
@ PP_UNSAFE_BUFFER_USAGE
Record code for #pragma clang unsafe_buffer_usage begin/end.
@ CXX_ADDED_TEMPLATE_PARTIAL_SPECIALIZATION
@ DECLS_WITH_EFFECTS_TO_VERIFY
Record code for Sema's vector of functions/blocks with effects to be verified.
@ VTABLE_USES
Record code for the array of VTable uses.
@ LATE_PARSED_TEMPLATE
Record code for late parsed template functions.
@ DECLS_TO_CHECK_FOR_DEFERRED_DIAGS
Record code for the Decls to be checked for deferred diags.
@ SUBMODULE_METADATA
Record that encodes the number of submodules, their base ID in the AST file, and for each module the ...
@ DECL_OFFSET
Record code for the offsets of each decl.
@ SOURCE_MANAGER_LINE_TABLE
Record code for the source manager line table information, which stores information about #line direc...
@ PP_COUNTER_VALUE
The value of the next COUNTER to dispense.
@ OMP_REQUIRES_DECLS
Record code for the OpenMP 'requires' directives seen in the TU.
@ DELETE_EXPRS_TO_ANALYZE
Delete expressions that will be analyzed later.
@ EXTNAME_UNDECLARED_IDENTIFIERS
Record code for extname-redefined undeclared identifiers.
@ RELATED_DECLS_MAP
Record code for related declarations that have to be deserialized together from the same module.
@ UPDATE_VISIBLE
Record code for an update to a decl context's lookup table.
@ CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH
Number of unmatched pragma clang cuda_force_host_device begin directives we've seen.
@ MACRO_OFFSET
Record code for the table of offsets of each macro ID.
@ PPD_ENTITIES_OFFSETS
Record code for the table of offsets to entries in the preprocessing record.
@ RISCV_VECTOR_INTRINSICS_PRAGMA
Record code for pragma clang riscv intrinsic vector.
@ VTABLES_TO_EMIT
Record code for vtables to emit.
@ UPDATE_MODULE_LOCAL_VISIBLE
@ IDENTIFIER_OFFSET
Record code for the table of offsets of each identifier ID.
@ OBJC_CATEGORIES
Record code for the array of Objective-C categories (including extensions).
@ METHOD_POOL
Record code for the Objective-C method pool,.
@ DELAYED_NAMESPACE_LEXICAL_VISIBLE_RECORD
Record code for lexical and visible block for delayed namespace in reduced BMI.
@ PP_CONDITIONAL_STACK
The stack of open ifs/ifdefs recorded in a preamble.
@ REFERENCED_SELECTOR_POOL
Record code for referenced selector pool.
@ SOURCE_LOCATION_OFFSETS
Record code for the table of offsets into the block of source-location information.
@ WEAK_UNDECLARED_IDENTIFIERS
Record code for weak undeclared identifiers.
@ UNDEFINED_BUT_USED
Record code for undefined but used functions and variables that need a definition in this TU.
@ FILE_SORTED_DECLS
Record code for a file sorted array of DeclIDs in a module.
@ MSSTRUCT_PRAGMA_OPTIONS
Record code for #pragma ms_struct options.
@ TENTATIVE_DEFINITIONS
Record code for the array of tentative definitions.
@ UPDATE_TU_LOCAL_VISIBLE
@ UNUSED_FILESCOPED_DECLS
Record code for the array of unused file scoped decls.
@ ALIGN_PACK_PRAGMA_OPTIONS
Record code for #pragma align/pack options.
@ IMPORTED_MODULES
Record code for an array of all of the (sub)modules that were imported by the AST file.
@ SELECTOR_OFFSETS
Record code for the table of offsets into the Objective-C method pool.
@ UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES
Record code for potentially unused local typedef names.
@ EAGERLY_DESERIALIZED_DECLS
Record code for the array of eagerly deserialized decls.
@ INTERESTING_IDENTIFIERS
A list of "interesting" identifiers.
@ HEADER_SEARCH_TABLE
Record code for header search information.
@ OBJC_CATEGORIES_MAP
Record code for map of Objective-C class definition IDs to the ObjC categories in a module that are a...
@ CUDA_SPECIAL_DECL_REFS
Record code for special CUDA declarations.
@ TU_UPDATE_LEXICAL
Record code for an update to the TU's lexically contained declarations.
@ PPD_SKIPPED_RANGES
A table of skipped ranges within the preprocessing record.
@ IDENTIFIER_TABLE
Record code for the identifier table.
@ SEMA_DECL_REFS
Record code for declarations that Sema keeps references of.
@ OPTIMIZE_PRAGMA_OPTIONS
Record code for #pragma optimize options.
@ MODULE_OFFSET_MAP
Record code for the remapping information used to relate loaded modules to the various offsets and ID...
@ POINTERS_TO_MEMBERS_PRAGMA_OPTIONS
Record code for #pragma ms_struct options.
unsigned ComputeHash(Selector Sel)
TypeID LocalTypeID
Same with TypeID except that the LocalTypeID is only meaningful with the corresponding ModuleFile.
uint64_t IdentifierID
An ID number that refers to an identifier in an AST file.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Top level wrappers for InstallAPI frontend operations.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
bool isa(CodeGen::Address addr)
CustomizableOptional< FileEntryRef > OptionalFileEntryRef
SanitizerMask getPPTransparentSanitizers()
Return the sanitizers which do not affect preprocessing.
OpenMPDefaultClauseVariableCategory
OpenMP variable-category for 'default' clause.
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
OpenMPOrderClauseModifier
OpenMP modifiers for 'order' clause.
@ Success
Annotation was successful.
std::pair< FileID, unsigned > FileIDAndOffset
OpenMPAtClauseKind
OpenMP attributes for 'at' clause.
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
OpenACCClauseKind
Represents the kind of an OpenACC clause.
@ Auto
'auto' clause, allowed on 'loop' directives.
@ Bind
'bind' clause, allowed on routine constructs.
@ Gang
'gang' clause, allowed on 'loop' and Combined constructs.
@ Wait
'wait' clause, allowed on Compute, Data, 'update', and Combined constructs.
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ PCopyOut
'copyout' clause alias 'pcopyout'. Preserved for diagnostic purposes.
@ VectorLength
'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop', and 'kernels loop' constru...
@ Async
'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined constructs.
@ PresentOrCreate
'create' clause alias 'present_or_create'.
@ Collapse
'collapse' clause, allowed on 'loop' and Combined constructs.
@ NoHost
'nohost' clause, allowed on 'routine' directives.
@ PresentOrCopy
'copy' clause alias 'present_or_copy'. Preserved for diagnostic purposes.
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Copy
'copy' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ Worker
'worker' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ DeviceType
'device_type' clause, allowed on Compute, 'data', 'init', 'shutdown', 'set', update',...
@ DefaultAsync
'default_async' clause, allowed on 'set' construct.
@ Attach
'attach' clause, allowed on Compute and Combined constructs, plus 'data' and 'enter data'.
@ Shortloop
'shortloop' is represented in the ACC.td file, but isn't present in the standard.
@ NumGangs
'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs.
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...
@ Default
'default' clause, allowed on parallel, serial, kernel (and compound) constructs.
@ UseDevice
'use_device' clause, allowed on 'host_data' construct.
@ NoCreate
'no_create' clause, allowed on allowed on Compute and Combined constructs, plus 'data'.
@ PresentOrCopyOut
'copyout' clause alias 'present_or_copyout'.
@ Link
'link' clause, allowed on 'declare' construct.
@ Reduction
'reduction' clause, allowed on Parallel, Serial, Loop, and the combined constructs.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ CopyOut
'copyout' clause, allowed on Compute and Combined constructs, plus 'data', 'exit data',...
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
@ FirstPrivate
'firstprivate' clause, allowed on 'parallel', 'serial', 'parallel loop', and 'serial loop' constructs...
@ Host
'host' clause, allowed on 'update' construct.
@ PCopy
'copy' clause alias 'pcopy'. Preserved for diagnostic purposes.
@ Tile
'tile' clause, allowed on 'loop' and Combined constructs.
@ PCopyIn
'copyin' clause alias 'pcopyin'. Preserved for diagnostic purposes.
@ DeviceResident
'device_resident' clause, allowed on the 'declare' construct.
@ PCreate
'create' clause alias 'pcreate'. Preserved for diagnostic purposes.
@ Present
'present' clause, allowed on Compute and Combined constructs, plus 'data' and 'declare'.
@ DType
'dtype' clause, an alias for 'device_type', stored separately for diagnostic purposes.
@ CopyIn
'copyin' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ Device
'device' clause, allowed on the 'update' construct.
@ Independent
'independent' clause, allowed on 'loop' directives.
@ NumWorkers
'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs...
@ IfPresent
'if_present' clause, allowed on 'host_data' and 'update' directives.
@ Detach
'detach' clause, allowed on the 'exit data' construct.
@ Delete
'delete' clause, allowed on the 'exit data' construct.
@ PresentOrCopyIn
'copyin' clause alias 'present_or_copyin'.
@ Finalize
'finalize' clause, allowed on 'exit data' directive.
OpenMPScheduleClauseModifier
OpenMP modifiers for 'schedule' clause.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
OpenMPNumTeamsClauseModifier
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
OpenMPDoacrossClauseModifier
OpenMP dependence types for 'doacross' clause.
static constexpr unsigned NumberOfOMPMapClauseModifiers
Number of allowed map-type-modifiers.
OpenMPDynGroupprivateClauseFallbackModifier
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
ObjCXXARCStandardLibraryKind
Enumerate the kinds of standard library that.
@ Undefined
Keep undefined.
PredefinedDeclIDs
Predefined declaration IDs.
@ PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID
The internal '__NSConstantString' tag type.
@ PREDEF_DECL_TRANSLATION_UNIT_ID
The translation unit.
@ PREDEF_DECL_OBJC_CLASS_ID
The Objective-C 'Class' type.
@ PREDEF_DECL_BUILTIN_MS_GUID_ID
The predeclared '_GUID' struct.
@ PREDEF_DECL_BUILTIN_MS_TYPE_INFO_TAG_ID
The predeclared 'type_info' struct.
@ PREDEF_DECL_OBJC_INSTANCETYPE_ID
The internal 'instancetype' typedef.
@ PREDEF_DECL_OBJC_PROTOCOL_ID
The Objective-C 'Protocol' type.
@ PREDEF_DECL_UNSIGNED_INT_128_ID
The unsigned 128-bit integer type.
@ PREDEF_DECL_OBJC_SEL_ID
The Objective-C 'SEL' type.
@ NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
@ PREDEF_DECL_INT_128_ID
The signed 128-bit integer type.
@ PREDEF_DECL_VA_LIST_TAG
The internal '__va_list_tag' struct, if any.
@ PREDEF_DECL_BUILTIN_MS_VA_LIST_ID
The internal '__builtin_ms_va_list' typedef.
@ PREDEF_DECL_CF_CONSTANT_STRING_ID
The internal '__NSConstantString' typedef.
@ PREDEF_DECL_NULL_ID
The NULL declaration.
@ PREDEF_DECL_BUILTIN_VA_LIST_ID
The internal '__builtin_va_list' typedef.
@ PREDEF_DECL_EXTERN_C_CONTEXT_ID
The extern "C" context.
@ PREDEF_DECL_OBJC_ID_ID
The Objective-C 'id' type.
@ PREDEF_DECL_BUILTIN_ZOS_VA_LIST_ID
The internal '__builtin_zos_va_list' typedef.
@ Property
The type of a property.
@ Result
The result type of a method or function.
OpenMPBindClauseKind
OpenMP bindings for the 'bind' clause.
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
std::string createSpecificModuleCachePath(FileManager &FileMgr, StringRef ModuleCachePath, bool DisableModuleHash, std::string ContextHash)
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
@ Template
We are parsing a template declaration.
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
OpenMPGrainsizeClauseModifier
OpenMPNumTasksClauseModifier
OpenMPUseDevicePtrFallbackModifier
OpenMP 6.1 use_device_ptr fallback modifier.
OpenMPSeverityClauseKind
OpenMP attributes for 'severity' clause.
void ProcessWarningOptions(DiagnosticsEngine &Diags, const DiagnosticOptions &Opts, llvm::vfs::FileSystem &VFS, bool ReportDiags=true)
ProcessWarningOptions - Initialize the diagnostic client and process the warning options specified on...
static constexpr unsigned NumberOfOMPMotionModifiers
Number of allowed motion-modifiers.
TypeSpecifierWidth
Specifies the width of a type, e.g., short, long, or long long.
OpenMPMotionModifierKind
OpenMP modifier kind for 'to' or 'from' clause.
OpenMPDefaultmapClauseKind
OpenMP attributes for 'defaultmap' clause.
OpenMPAllocateClauseModifier
OpenMP modifiers for 'allocate' clause.
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
TypeSpecifierSign
Specifies the signedness of a type, e.g., signed or unsigned.
OpenMPDynGroupprivateClauseModifier
OpenMPThreadLimitClauseModifier
DisableValidationForModuleKind
Whether to disable the normal validation performed on precompiled headers and module files when they ...
@ None
Perform validation, don't disable it.
@ PCH
Disable validation for a precompiled header and the modules it depends on.
@ Module
Disable validation for module files.
bool shouldSkipCheckingODR(const Decl *D)
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
OpenMPNumThreadsClauseModifier
OpenMPAtomicDefaultMemOrderClauseKind
OpenMP attributes for 'atomic_default_mem_order' clause.
U cast(CodeGen::Address addr)
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
OpenMPMapModifierKind
OpenMP modifier kind for 'map' clause.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
OpenMPOrderClauseKind
OpenMP attributes for 'order' clause.
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
OpenMPThreadsetKind
OpenMP modifiers for 'threadset' clause.
UnsignedOrNone getPrimaryModuleHash(const Module *M)
Calculate a hash value for the primary module name of the given module.
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 __builtin_riscv_mqwacc_i64 __packed_splat4 uint16_t
__LIBC_ATTRS FILE * stderr
This structure contains all sizes needed for by an OMPMappableExprListClause.
unsigned NumComponents
Total number of expression components.
unsigned NumUniqueDeclarations
Number of unique base declarations.
unsigned NumVars
Number of expressions listed.
unsigned NumComponentLists
Number of component lists.
Expr * AllocatorTraits
Allocator traits.
Expr * Allocator
Allocator.
SourceLocation LParenLoc
Locations of '(' and ')' symbols.
The signature of a module, which is a hash of the AST content.
static constexpr size_t size
static ASTFileSignature create(std::array< uint8_t, 20 > Bytes)
static ASTFileSignature createDummy()
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
void setInfo(const DeclarationNameLoc &Info)
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
A simple structure that captures a vtable use for the purposes of the ExternalSemaSource.
ExceptionSpecInfo ExceptionSpec
static LineEntry get(unsigned Offs, unsigned Line, int Filename, SrcMgr::CharacteristicKind FileKind, unsigned IncludeOffset)
A conflict between two modules.
std::string Message
The message provided to the user when there is a conflict.
ModuleRef Other
The module that this module conflicts with.
A library or framework to link against when an entity from this module is used.
a linked list of methods with the same selector name but different signatures.
ObjCMethodList * getNext() const
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
TemplateParameterList ** TemplParamLists
A new-allocated array of size NumTemplParamLists, containing pointers to the "outer" template paramet...
NestedNameSpecifierLoc QualifierLoc
unsigned NumTemplParamLists
The number of "outer" template parameter lists.
void clear(SanitizerMask K=SanitizerKind::All)
Disable the sanitizers specified in K.
SanitizerMask Mask
Bitmask of enabled sanitizers.
Helper class that saves the current stream position and then restores it when destroyed.
PragmaMsStackAction Action
llvm::DenseSet< std::tuple< Decl *, Decl *, int > > NonEquivalentDeclSet
Store declaration pairs already found to be non-equivalent.
Location information for a TemplateArgument.
Describes a single change detected in a module file or input file.
Describes the categories of an Objective-C class.
void insert(GlobalDeclID ID)
void insert(LazySpecializationInfo Info)