67 #include "llvm/ADT/APFloat.h"
68 #include "llvm/ADT/APInt.h"
69 #include "llvm/ADT/APSInt.h"
70 #include "llvm/ADT/Hashing.h"
71 #include "llvm/ADT/SmallString.h"
72 #include "llvm/ADT/StringExtras.h"
73 #include "llvm/ADT/Triple.h"
74 #include "llvm/Bitcode/BitstreamReader.h"
75 #include "llvm/Support/Compression.h"
76 #include "llvm/Support/Compiler.h"
77 #include "llvm/Support/Error.h"
78 #include "llvm/Support/ErrorHandling.h"
79 #include "llvm/Support/FileSystem.h"
80 #include "llvm/Support/MemoryBuffer.h"
81 #include "llvm/Support/Path.h"
82 #include "llvm/Support/SaveAndRestore.h"
83 #include "llvm/Support/raw_ostream.h"
96 #include <system_error>
101 using namespace clang;
102 using namespace clang::serialization;
103 using namespace clang::serialization::reader;
104 using llvm::BitstreamCursor;
112 return First->ReadFullVersionInformation(FullVersion) ||
113 Second->ReadFullVersionInformation(FullVersion);
117 First->ReadModuleName(ModuleName);
118 Second->ReadModuleName(ModuleName);
122 First->ReadModuleMapFile(ModuleMapPath);
123 Second->ReadModuleMapFile(ModuleMapPath);
129 bool AllowCompatibleDifferences) {
130 return First->ReadLanguageOptions(LangOpts, Complain,
131 AllowCompatibleDifferences) ||
132 Second->ReadLanguageOptions(LangOpts, Complain,
133 AllowCompatibleDifferences);
138 bool AllowCompatibleDifferences) {
139 return First->ReadTargetOptions(TargetOpts, Complain,
140 AllowCompatibleDifferences) ||
141 Second->ReadTargetOptions(TargetOpts, Complain,
142 AllowCompatibleDifferences);
147 return First->ReadDiagnosticOptions(DiagOpts, Complain) ||
148 Second->ReadDiagnosticOptions(DiagOpts, Complain);
154 return First->ReadFileSystemOptions(FSOpts, Complain) ||
155 Second->ReadFileSystemOptions(FSOpts, Complain);
161 return First->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
163 Second->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
169 std::string &SuggestedPredefines) {
170 return First->ReadPreprocessorOptions(PPOpts, Complain,
171 SuggestedPredefines) ||
172 Second->ReadPreprocessorOptions(PPOpts, Complain, SuggestedPredefines);
176 First->ReadCounter(M, Value);
177 Second->ReadCounter(M, Value);
180 return First->needsInputFileVisitation() ||
181 Second->needsInputFileVisitation();
184 return First->needsSystemInputFileVisitation() ||
185 Second->needsSystemInputFileVisitation();
189 First->visitModuleFile(Filename, Kind);
190 Second->visitModuleFile(Filename, Kind);
196 bool isExplicitModule) {
197 bool Continue =
false;
198 if (First->needsInputFileVisitation() &&
199 (!isSystem || First->needsSystemInputFileVisitation()))
200 Continue |= First->visitInputFile(Filename, isSystem, isOverridden,
202 if (Second->needsInputFileVisitation() &&
203 (!isSystem || Second->needsSystemInputFileVisitation()))
204 Continue |= Second->visitInputFile(Filename, isSystem, isOverridden,
211 First->readModuleFileExtension(Metadata);
212 Second->readModuleFileExtension(Metadata);
232 bool AllowCompatibleDifferences =
true) {
233 #define LANGOPT(Name, Bits, Default, Description) \
234 if (ExistingLangOpts.Name != LangOpts.Name) { \
236 Diags->Report(diag::err_pch_langopt_mismatch) \
237 << Description << LangOpts.Name << ExistingLangOpts.Name; \
241 #define VALUE_LANGOPT(Name, Bits, Default, Description) \
242 if (ExistingLangOpts.Name != LangOpts.Name) { \
244 Diags->Report(diag::err_pch_langopt_value_mismatch) \
249 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
250 if (ExistingLangOpts.get##Name() != LangOpts.get##Name()) { \
252 Diags->Report(diag::err_pch_langopt_value_mismatch) \
257 #define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
258 if (!AllowCompatibleDifferences) \
259 LANGOPT(Name, Bits, Default, Description)
261 #define COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) \
262 if (!AllowCompatibleDifferences) \
263 ENUM_LANGOPT(Name, Bits, Default, Description)
265 #define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \
266 if (!AllowCompatibleDifferences) \
267 VALUE_LANGOPT(Name, Bits, Default, Description)
269 #define BENIGN_LANGOPT(Name, Bits, Default, Description)
270 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
271 #define BENIGN_VALUE_LANGOPT(Name, Type, Bits, Default, Description)
272 #include "clang/Basic/LangOptions.def"
276 Diags->
Report(diag::err_pch_langopt_value_mismatch) <<
"module features";
282 Diags->
Report(diag::err_pch_langopt_value_mismatch)
283 <<
"target Objective-C runtime";
290 Diags->
Report(diag::err_pch_langopt_value_mismatch)
291 <<
"block command names";
299 if (!AllowCompatibleDifferences) {
303 ExistingSanitizers.
clear(ModularSanitizers);
304 ImportedSanitizers.
clear(ModularSanitizers);
305 if (ExistingSanitizers.
Mask != ImportedSanitizers.
Mask) {
306 const std::string Flag =
"-fsanitize=";
308 #define SANITIZER(NAME, ID) \
310 bool InExistingModule = ExistingSanitizers.has(SanitizerKind::ID); \
311 bool InImportedModule = ImportedSanitizers.has(SanitizerKind::ID); \
312 if (InExistingModule != InImportedModule) \
313 Diags->Report(diag::err_pch_targetopt_feature_mismatch) \
314 << InExistingModule << (Flag + NAME); \
316 #include "clang/Basic/Sanitizers.def"
334 bool AllowCompatibleDifferences =
true) {
335 #define CHECK_TARGET_OPT(Field, Name) \
336 if (TargetOpts.Field != ExistingTargetOpts.Field) { \
338 Diags->Report(diag::err_pch_targetopt_mismatch) \
339 << Name << TargetOpts.Field << ExistingTargetOpts.Field; \
350 if (!AllowCompatibleDifferences)
353 #undef CHECK_TARGET_OPT
361 std::sort(ExistingFeatures.begin(), ExistingFeatures.end());
362 std::sort(ReadFeatures.begin(), ReadFeatures.end());
368 ExistingFeatures.begin(), ExistingFeatures.end(), ReadFeatures.begin(),
369 ReadFeatures.end(), std::back_inserter(UnmatchedExistingFeatures));
370 std::set_difference(ReadFeatures.begin(), ReadFeatures.end(),
371 ExistingFeatures.begin(), ExistingFeatures.end(),
372 std::back_inserter(UnmatchedReadFeatures));
376 if (AllowCompatibleDifferences && UnmatchedReadFeatures.empty())
380 for (StringRef Feature : UnmatchedReadFeatures)
381 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
383 for (StringRef Feature : UnmatchedExistingFeatures)
384 Diags->
Report(diag::err_pch_targetopt_feature_mismatch)
388 return !UnmatchedReadFeatures.empty() || !UnmatchedExistingFeatures.empty();
394 bool AllowCompatibleDifferences) {
395 const LangOptions &ExistingLangOpts = PP.getLangOpts();
397 Complain ? &Reader.Diags :
nullptr,
398 AllowCompatibleDifferences);
403 bool AllowCompatibleDifferences) {
404 const TargetOptions &ExistingTargetOpts = PP.getTargetInfo().getTargetOpts();
406 Complain ? &Reader.Diags :
nullptr,
407 AllowCompatibleDifferences);
412 typedef llvm::StringMap<std::pair<StringRef,
bool > >
414 typedef llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8> >
430 for (
auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) {
439 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror=" +
458 bool IsSystem,
bool Complain) {
466 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Wsystem-headers";
473 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Werror";
480 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-Weverything -Werror";
487 Diags.
Report(diag::err_pch_diagopt_mismatch) <<
"-pedantic-errors";
511 assert(!ModuleName.empty() &&
"diagnostic options read before module name");
514 assert(M &&
"missing module");
529 assert(ModuleMgr.
size() >= 1 &&
"what ASTFile is this then");
545 MacroDefinitionsMap &Macros,
547 for (
unsigned I = 0, N = PPOpts.
Macros.size();
I != N; ++
I) {
548 StringRef Macro = PPOpts.
Macros[
I].first;
549 bool IsUndef = PPOpts.
Macros[
I].second;
551 std::pair<StringRef, StringRef> MacroPair = Macro.split(
'=');
552 StringRef MacroName = MacroPair.first;
553 StringRef MacroBody = MacroPair.second;
557 if (MacroNames && !Macros.count(MacroName))
558 MacroNames->push_back(MacroName);
560 Macros[MacroName] = std::make_pair(
"",
true);
565 if (MacroName.size() == Macro.size())
569 StringRef::size_type
End = MacroBody.find_first_of(
"\n\r");
570 MacroBody = MacroBody.substr(0, End);
573 if (MacroNames && !Macros.count(MacroName))
574 MacroNames->push_back(MacroName);
575 Macros[MacroName] = std::make_pair(MacroBody,
false);
590 std::string &SuggestedPredefines,
592 bool Validate =
true) {
594 MacroDefinitionsMap ASTFileMacros;
596 MacroDefinitionsMap ExistingMacros;
600 for (
unsigned I = 0, N = ExistingMacroNames.size();
I != N; ++
I) {
602 StringRef MacroName = ExistingMacroNames[
I];
603 std::pair<StringRef, bool> Existing = ExistingMacros[MacroName];
606 llvm::StringMap<std::pair<StringRef,
bool > >::iterator Known
607 = ASTFileMacros.find(MacroName);
608 if (!Validate || Known == ASTFileMacros.end()) {
613 if (Existing.second) {
614 SuggestedPredefines +=
"#undef ";
615 SuggestedPredefines += MacroName.str();
616 SuggestedPredefines +=
'\n';
618 SuggestedPredefines +=
"#define ";
619 SuggestedPredefines += MacroName.str();
620 SuggestedPredefines +=
' ';
621 SuggestedPredefines += Existing.first.str();
622 SuggestedPredefines +=
'\n';
629 if (Existing.second != Known->second.second) {
631 Diags->
Report(diag::err_pch_macro_def_undef)
632 << MacroName << Known->second.second;
639 if (Existing.second || Existing.first == Known->second.first)
644 Diags->
Report(diag::err_pch_macro_def_conflict)
645 << MacroName << Known->second.first << Existing.first;
659 if (LangOpts.Modules &&
668 for (
unsigned I = 0, N = ExistingPPOpts.
Includes.size();
I != N; ++
I) {
669 StringRef File = ExistingPPOpts.
Includes[
I];
677 SuggestedPredefines +=
"#include \"";
678 SuggestedPredefines += File;
679 SuggestedPredefines +=
"\"\n";
682 for (
unsigned I = 0, N = ExistingPPOpts.
MacroIncludes.size();
I != N; ++
I) {
689 SuggestedPredefines +=
"#__include_macros \"";
690 SuggestedPredefines += File;
691 SuggestedPredefines +=
"\"\n##\n";
699 std::string &SuggestedPredefines) {
703 Complain? &Reader.Diags :
nullptr,
712 std::string &SuggestedPredefines) {
714 PP.getPreprocessorOpts(),
727 StringRef SpecificModuleCachePath,
728 StringRef ExistingModuleCachePath,
731 if (LangOpts.Modules) {
732 if (SpecificModuleCachePath != ExistingModuleCachePath) {
734 Diags->
Report(diag::err_pch_modulecache_mismatch)
735 << SpecificModuleCachePath << ExistingModuleCachePath;
744 StringRef SpecificModuleCachePath,
747 PP.getHeaderSearchInfo().getModuleCachePath(),
748 Complain ? &Reader.Diags :
nullptr,
753 PP.setCounterValue(Value);
761 bool TakeOwnership) {
762 DeserializationListener = Listener;
763 OwnsDeserializationListener = TakeOwnership;
770 std::pair<unsigned, unsigned>
772 using namespace llvm::support;
773 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
774 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
775 return std::make_pair(KeyLen, DataLen);
780 using namespace llvm::support;
782 unsigned N = endian::readNext<uint16_t, little, unaligned>(d);
784 F, endian::readNext<uint32_t, little, unaligned>(d));
786 return SelTable.getNullarySelector(FirstII);
788 return SelTable.getUnarySelector(FirstII);
791 Args.push_back(FirstII);
792 for (
unsigned I = 1;
I != N; ++
I)
793 Args.push_back(Reader.getLocalIdentifier(
794 F, endian::readNext<uint32_t, little, unaligned>(d)));
796 return SelTable.getSelector(N, Args.data());
802 using namespace llvm::support;
806 Result.ID = Reader.getGlobalSelectorID(
807 F, endian::readNext<uint32_t, little, unaligned>(d));
808 unsigned FullInstanceBits = endian::readNext<uint16_t, little, unaligned>(d);
809 unsigned FullFactoryBits = endian::readNext<uint16_t, little, unaligned>(d);
810 Result.InstanceBits = FullInstanceBits & 0x3;
811 Result.InstanceHasMoreThanOneDecl = (FullInstanceBits >> 2) & 0x1;
812 Result.FactoryBits = FullFactoryBits & 0x3;
813 Result.FactoryHasMoreThanOneDecl = (FullFactoryBits >> 2) & 0x1;
814 unsigned NumInstanceMethods = FullInstanceBits >> 3;
815 unsigned NumFactoryMethods = FullFactoryBits >> 3;
818 for (
unsigned I = 0;
I != NumInstanceMethods; ++
I) {
820 F, endian::readNext<uint32_t, little, unaligned>(d)))
821 Result.Instance.push_back(Method);
825 for (
unsigned I = 0;
I != NumFactoryMethods; ++
I) {
827 F, endian::readNext<uint32_t, little, unaligned>(d)))
828 Result.Factory.push_back(Method);
835 return llvm::HashString(a);
838 std::pair<unsigned, unsigned>
840 using namespace llvm::support;
841 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
842 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
843 return std::make_pair(KeyLen, DataLen);
848 assert(n >= 2 && d[n-1] ==
'\0');
849 return StringRef((
const char*) d, n-1);
864 bool Value = Bits & 0x1;
870 using namespace llvm::support;
871 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
872 return Reader.getGlobalIdentifierID(F, RawID >> 1);
885 const unsigned char* d,
887 using namespace llvm::support;
888 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
889 bool IsInteresting = RawID & 0x01;
897 II = &Reader.getIdentifierTable().getOwn(k);
901 Reader.markIdentifierUpToDate(II);
903 IdentID ID = Reader.getGlobalIdentifierID(F, RawID);
904 if (!IsInteresting) {
907 Reader.SetIdentifierInfo(
ID, II);
911 unsigned ObjCOrBuiltinID = endian::readNext<uint16_t, little, unaligned>(d);
912 unsigned Bits = endian::readNext<uint16_t, little, unaligned>(d);
913 bool CPlusPlusOperatorKeyword =
readBit(Bits);
914 bool HasRevertedTokenIDToIdentifier =
readBit(Bits);
915 bool HasRevertedBuiltin =
readBit(Bits);
917 bool ExtensionToken =
readBit(Bits);
918 bool HadMacroDefinition =
readBit(Bits);
920 assert(Bits == 0 &&
"Extra bits in the identifier?");
925 if (HasRevertedTokenIDToIdentifier && II->getTokenID() != tok::identifier)
926 II->revertTokenIDToIdentifier();
928 II->setObjCOrBuiltinID(ObjCOrBuiltinID);
929 else if (HasRevertedBuiltin && II->getBuiltinID()) {
931 assert((II->hasRevertedBuiltin() ||
932 II->getObjCOrBuiltinID() == ObjCOrBuiltinID) &&
933 "Incorrect ObjC keyword or builtin ID");
935 assert(II->isExtensionToken() == ExtensionToken &&
936 "Incorrect extension token flag");
937 (void)ExtensionToken;
939 II->setIsPoisoned(
true);
940 assert(II->isCPlusPlusOperatorKeyword() == CPlusPlusOperatorKeyword &&
941 "Incorrect C++ operator keyword flag");
942 (void)CPlusPlusOperatorKeyword;
946 if (HadMacroDefinition) {
947 uint32_t MacroDirectivesOffset =
948 endian::readNext<uint32_t, little, unaligned>(d);
951 Reader.addPendingMacro(II, &F, MacroDirectivesOffset);
954 Reader.SetIdentifierInfo(
ID, II);
960 for (; DataLen > 0; DataLen -= 4)
961 DeclIDs.push_back(Reader.getGlobalDeclID(
962 F, endian::readNext<uint32_t, little, unaligned>(d)));
963 Reader.SetGloballyVisibleDecls(II, DeclIDs);
970 :
Kind(Name.getNameKind()) {
1000 llvm::FoldingSetNodeID
ID;
1001 ID.AddInteger(
Kind);
1024 return ID.ComputeHash();
1028 ASTDeclContextNameLookupTrait::ReadFileRef(
const unsigned char *&d) {
1029 using namespace llvm::support;
1030 uint32_t ModuleFileID = endian::readNext<uint32_t, little, unaligned>(d);
1031 return Reader.getLocalModuleFile(F, ModuleFileID);
1034 std::pair<unsigned, unsigned>
1035 ASTDeclContextNameLookupTrait::ReadKeyDataLength(
const unsigned char *&d) {
1036 using namespace llvm::support;
1037 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
1038 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
1039 return std::make_pair(KeyLen, DataLen);
1043 ASTDeclContextNameLookupTrait::ReadKey(
const unsigned char *d,
unsigned) {
1044 using namespace llvm::support;
1052 Data = (uint64_t)Reader.getLocalIdentifier(
1053 F, endian::readNext<uint32_t, little, unaligned>(d));
1059 (uint64_t)Reader.getLocalSelector(
1060 F, endian::readNext<uint32_t, little, unaligned>(
1061 d)).getAsOpaquePtr();
1078 const unsigned char *d,
1081 using namespace llvm::support;
1082 for (
unsigned NumDecls = DataLen / 4; NumDecls; --NumDecls) {
1083 uint32_t LocalID = endian::readNext<uint32_t, little, unaligned>(d);
1084 Val.
insert(Reader.getGlobalDeclID(F, LocalID));
1088 bool ASTReader::ReadLexicalDeclContextStorage(
ModuleFile &M,
1092 assert(Offset != 0);
1095 Cursor.JumpToBit(Offset);
1099 unsigned Code = Cursor.ReadCode();
1100 unsigned RecCode = Cursor.readRecord(Code, Record, &Blob);
1102 Error(
"Expected lexical block");
1106 assert(!isa<TranslationUnitDecl>(DC) &&
1107 "expected a TU_UPDATE_LEXICAL record for TU");
1112 auto &Lex = LexicalDecls[DC];
1114 Lex = std::make_pair(
1115 &M, llvm::makeArrayRef(
1116 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
1124 bool ASTReader::ReadVisibleDeclContextStorage(
ModuleFile &M,
1125 BitstreamCursor &Cursor,
1128 assert(Offset != 0);
1131 Cursor.JumpToBit(Offset);
1135 unsigned Code = Cursor.ReadCode();
1136 unsigned RecCode = Cursor.readRecord(Code, Record, &Blob);
1138 Error(
"Expected visible lookup table block");
1144 auto *Data = (
const unsigned char*)Blob.data();
1145 PendingVisibleUpdates[
ID].push_back(PendingVisibleUpdate{&M, Data});
1149 void ASTReader::Error(StringRef Msg)
const {
1150 Error(diag::err_fe_pch_malformed, Msg);
1151 if (PP.getLangOpts().Modules && !Diags.isDiagnosticInFlight() &&
1152 !PP.getHeaderSearchInfo().getModuleCachePath().empty()) {
1153 Diag(diag::note_module_cache_path)
1154 << PP.getHeaderSearchInfo().getModuleCachePath();
1158 void ASTReader::Error(
unsigned DiagID,
1159 StringRef Arg1, StringRef Arg2)
const {
1160 if (Diags.isDiagnosticInFlight())
1161 Diags.SetDelayedDiagnostic(DiagID, Arg1, Arg2);
1163 Diag(DiagID) << Arg1 << Arg2;
1172 bool ASTReader::ParseLineTable(
ModuleFile &F,
1173 const RecordData &Record) {
1178 std::map<int, int> FileIDs;
1179 for (
unsigned I = 0; Record[Idx]; ++
I) {
1181 auto Filename = ReadPath(F, Record, Idx);
1187 std::vector<LineEntry> Entries;
1188 while (Idx < Record.size()) {
1189 int FID = Record[Idx++];
1190 assert(FID >= 0 &&
"Serialized line entries for non-local file.");
1195 unsigned NumEntries = Record[Idx++];
1196 assert(NumEntries &&
"no line entries for file ID");
1198 Entries.reserve(NumEntries);
1199 for (
unsigned I = 0;
I != NumEntries; ++
I) {
1200 unsigned FileOffset = Record[Idx++];
1201 unsigned LineNo = Record[Idx++];
1202 int FilenameID = FileIDs[Record[Idx++]];
1205 unsigned IncludeOffset = Record[Idx++];
1207 FileKind, IncludeOffset));
1209 LineTable.
AddEntry(FileID::get(FID), Entries);
1216 bool ASTReader::ReadSourceManagerBlock(
ModuleFile &F) {
1217 using namespace SrcMgr;
1225 SLocEntryCursor = F.
Stream;
1228 if (F.
Stream.SkipBlock()) {
1229 Error(
"malformed block record in AST file");
1235 Error(
"malformed source manager block record in AST file");
1241 llvm::BitstreamEntry
E = SLocEntryCursor.advanceSkippingSubblocks();
1244 case llvm::BitstreamEntry::SubBlock:
1246 Error(
"malformed block record in AST file");
1248 case llvm::BitstreamEntry::EndBlock:
1250 case llvm::BitstreamEntry::Record:
1258 switch (SLocEntryCursor.readRecord(E.ID, Record, &Blob)) {
1277 const std::string &OriginalDir,
1278 const std::string &CurrDir) {
1279 assert(OriginalDir != CurrDir &&
1280 "No point trying to resolve the file if the PCH dir didn't change");
1281 using namespace llvm::sys;
1283 fs::make_absolute(filePath);
1284 assert(path::is_absolute(OriginalDir));
1287 path::const_iterator fileDirI = path::begin(path::parent_path(filePath)),
1288 fileDirE = path::end(path::parent_path(filePath));
1289 path::const_iterator origDirI = path::begin(OriginalDir),
1290 origDirE = path::end(OriginalDir);
1292 while (fileDirI != fileDirE && origDirI != origDirE &&
1293 *fileDirI == *origDirI) {
1297 for (; origDirI != origDirE; ++origDirI)
1298 path::append(currPCHPath,
"..");
1299 path::append(currPCHPath, fileDirI, fileDirE);
1300 path::append(currPCHPath, path::filename(Filename));
1301 return currPCHPath.str();
1308 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1309 Error(
"source location entry ID out-of-range for AST file");
1315 auto ReadBuffer = [
this](
1316 BitstreamCursor &SLocEntryCursor,
1317 StringRef
Name) -> std::unique_ptr<llvm::MemoryBuffer> {
1320 unsigned Code = SLocEntryCursor.ReadCode();
1321 unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, &Blob);
1324 if (!llvm::zlib::isAvailable()) {
1325 Error(
"zlib is not available");
1330 llvm::zlib::uncompress(Blob, Uncompressed, Record[0])) {
1331 Error(
"could not decompress embedded file contents: " +
1335 return llvm::MemoryBuffer::getMemBufferCopy(Uncompressed,
Name);
1337 return llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1),
Name,
true);
1339 Error(
"AST record has invalid code");
1344 ModuleFile *F = GlobalSLocEntryMap.find(-ID)->second;
1349 ++NumSLocEntriesRead;
1350 llvm::BitstreamEntry Entry = SLocEntryCursor.advance();
1351 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1352 Error(
"incorrectly-formatted source location entry in AST file");
1358 switch (SLocEntryCursor.readRecord(Entry.ID, Record, &Blob)) {
1360 Error(
"incorrectly-formatted source location entry in AST file");
1366 unsigned InputID = Record[4];
1367 InputFile IF = getInputFile(*F, InputID);
1380 IncludeLoc = getImportLocation(F);
1385 ID, BaseOffset + Record[0]);
1388 FileInfo.NumCreatedFIDs = Record[5];
1393 unsigned NumFileDecls = Record[7];
1394 if (NumFileDecls && ContextObj) {
1395 assert(F->
FileSortedDecls &&
"FILE_SORTED_DECLS not encountered yet ?");
1396 FileDeclIDs[FID] = FileDeclsInfo(F, llvm::makeArrayRef(FirstDecl,
1415 const char *
Name = Blob.data();
1416 unsigned Offset = Record[0];
1421 IncludeLoc = getImportLocation(F);
1424 auto Buffer = ReadBuffer(SLocEntryCursor, Name);
1428 BaseOffset + Offset, IncludeLoc);
1434 SourceMgr.createExpansionLoc(SpellingLoc,
1435 ReadSourceLocation(*F, Record[2]),
1436 ReadSourceLocation(*F, Record[3]),
1439 BaseOffset + Record[0]);
1451 if (
unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1452 Error(
"source location entry ID out-of-range for AST file");
1457 ModuleFile *M = GlobalSLocEntryMap.find(-ID)->second;
1468 if (F->ImportLoc.isValid())
1469 return F->ImportLoc;
1473 if (F->ImportedBy.empty() || !F->ImportedBy[0]) {
1475 assert(
SourceMgr.getMainFileID().isValid() &&
"missing main file");
1478 return F->ImportedBy[0]->FirstLoc;
1485 if (Cursor.EnterSubBlock(BlockID))
1489 uint64_t Offset = Cursor.GetCurrentBitNo();
1490 unsigned Code = Cursor.ReadCode();
1493 if (Code != llvm::bitc::DEFINE_ABBREV) {
1494 Cursor.JumpToBit(Offset);
1497 Cursor.ReadAbbrevRecord();
1505 Tok.
setLocation(ReadSourceLocation(F, Record, Idx));
1521 Stream.JumpToBit(Offset);
1530 unsigned Flags = BitstreamCursor::AF_DontPopBlockAtEnd;
1531 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks(Flags);
1533 switch (Entry.Kind) {
1534 case llvm::BitstreamEntry::SubBlock:
1536 Error(
"malformed block record in AST file");
1538 case llvm::BitstreamEntry::EndBlock:
1540 case llvm::BitstreamEntry::Record:
1564 MacroInfo *MI = PP.AllocateMacroInfo(Loc);
1571 bool isC99VarArgs = Record[NextIndex++];
1572 bool isGNUVarArgs = Record[NextIndex++];
1573 bool hasCommaPasting = Record[NextIndex++];
1574 MacroParams.clear();
1575 unsigned NumArgs = Record[NextIndex++];
1576 for (
unsigned i = 0; i != NumArgs; ++i)
1577 MacroParams.push_back(getLocalIdentifier(F, Record[NextIndex++]));
1591 if (NextIndex + 1 == Record.size() && PP.getPreprocessingRecord() &&
1595 GlobalID = getGlobalPreprocessedEntityID(F, Record[NextIndex]);
1597 PreprocessingRecord::PPEntityID PPID =
1598 PPRec.getPPEntityID(GlobalID - 1,
true);
1600 PPRec.getPreprocessedEntity(PPID));
1602 PPRec.RegisterMacroDefinition(Macro, PPDef);
1615 Token Tok = ReadToken(F, Record, Idx);
1625 unsigned LocalID)
const {
1627 ReadModuleOffsetMap(M);
1632 &&
"Invalid index into preprocessed entity index remap");
1634 return LocalID + I->second;
1638 return llvm::hash_combine(ikey.
Size, ikey.
ModTime);
1660 return FileMgr.
getFile(Key.Filename);
1662 std::string Resolved = Key.Filename;
1663 Reader.ResolveImportedPath(M, Resolved);
1664 return FileMgr.
getFile(Resolved);
1669 return FEA && FEA == FEB;
1672 std::pair<unsigned, unsigned>
1673 HeaderFileInfoTrait::ReadKeyDataLength(
const unsigned char*& d) {
1674 using namespace llvm::support;
1675 unsigned KeyLen = (
unsigned) endian::readNext<uint16_t, little, unaligned>(d);
1676 unsigned DataLen = (
unsigned) *d++;
1677 return std::make_pair(KeyLen, DataLen);
1681 HeaderFileInfoTrait::ReadKey(
const unsigned char *d,
unsigned) {
1682 using namespace llvm::support;
1684 ikey.
Size = off_t(endian::readNext<uint64_t, little, unaligned>(d));
1685 ikey.ModTime = time_t(endian::readNext<uint64_t, little, unaligned>(d));
1686 ikey.Filename = (
const char *)d;
1687 ikey.Imported =
true;
1694 const unsigned char *
End = d + DataLen;
1695 using namespace llvm::support;
1697 unsigned Flags = *d++;
1699 HFI.
isImport |= (Flags >> 5) & 0x01;
1700 HFI.isPragmaOnce |= (Flags >> 4) & 0x01;
1701 HFI.DirInfo = (Flags >> 1) & 0x07;
1702 HFI.IndexHeaderMapHeader = Flags & 0x01;
1705 HFI.NumIncludes =
std::max(endian::readNext<uint16_t, little, unaligned>(d),
1707 HFI.ControllingMacroID = Reader.getGlobalIdentifierID(
1708 M, endian::readNext<uint32_t, little, unaligned>(d));
1709 if (
unsigned FrameworkOffset =
1710 endian::readNext<uint32_t, little, unaligned>(d)) {
1713 StringRef FrameworkName(FrameworkStrings + FrameworkOffset - 1);
1714 HFI.Framework = HS->getUniqueFrameworkName(FrameworkName);
1717 assert((End - d) % 4 == 0 &&
1718 "Wrong data length in HeaderFileInfo deserialization");
1720 uint32_t LocalSMID = endian::readNext<uint32_t, little, unaligned>(d);
1726 SubmoduleID GlobalSMID = Reader.getGlobalSubmoduleID(M, LocalSMID);
1727 Module *Mod = Reader.getSubmodule(GlobalSMID);
1730 Reader.getPreprocessor().getHeaderSearchInfo().getModuleMap();
1734 Reader.ResolveImportedPath(M, Filename);
1739 ModMap.
addHeader(Mod, H, HeaderRole,
true);
1744 HFI.External =
true;
1751 uint64_t MacroDirectivesOffset) {
1752 assert(NumCurrentElementsDeserializing > 0 &&
"Missing deserialization guard");
1753 PendingMacroIDs[II].push_back(PendingMacroInfo(M, MacroDirectivesOffset));
1761 BitstreamCursor &MacroCursor =
I.MacroCursor;
1764 if (MacroCursor.getBitcodeBytes().empty())
1767 BitstreamCursor Cursor = MacroCursor;
1768 Cursor.JumpToBit(
I.MacroStartOffset);
1772 llvm::BitstreamEntry E = Cursor.advanceSkippingSubblocks();
1775 case llvm::BitstreamEntry::SubBlock:
1777 Error(
"malformed block record in AST file");
1779 case llvm::BitstreamEntry::EndBlock:
1782 case llvm::BitstreamEntry::Record:
1784 switch (Cursor.readRecord(E.ID, Record)) {
1792 updateOutOfDateIdentifier(*II);
1810 class IdentifierLookupVisitor {
1813 unsigned PriorGeneration;
1814 unsigned &NumIdentifierLookups;
1815 unsigned &NumIdentifierLookupHits;
1819 IdentifierLookupVisitor(StringRef
Name,
unsigned PriorGeneration,
1820 unsigned &NumIdentifierLookups,
1821 unsigned &NumIdentifierLookupHits)
1823 PriorGeneration(PriorGeneration),
1824 NumIdentifierLookups(NumIdentifierLookups),
1825 NumIdentifierLookupHits(NumIdentifierLookupHits),
1842 ++NumIdentifierLookups;
1843 ASTIdentifierLookupTable::iterator Pos =
1844 IdTable->find_hashed(
Name, NameHash, &Trait);
1845 if (Pos == IdTable->end())
1851 ++NumIdentifierLookupHits;
1867 unsigned PriorGeneration = 0;
1868 if (getContext().getLangOpts().Modules)
1869 PriorGeneration = IdentifierGeneration[&II];
1875 if (!loadGlobalIndex()) {
1876 if (GlobalIndex->lookupIdentifier(II.
getName(), Hits)) {
1881 IdentifierLookupVisitor Visitor(II.
getName(), PriorGeneration,
1882 NumIdentifierLookups,
1883 NumIdentifierLookupHits);
1884 ModuleMgr.visit(Visitor, HitsPtr);
1885 markIdentifierUpToDate(&II);
1895 if (getContext().getLangOpts().Modules)
1896 IdentifierGeneration[II] = getGeneration();
1900 const PendingMacroInfo &PMInfo) {
1905 Cursor.JumpToBit(PMInfo.MacroDirectivesOffset);
1907 struct ModuleMacroRecord {
1919 llvm::BitstreamEntry Entry =
1920 Cursor.advance(BitstreamCursor::AF_DontPopBlockAtEnd);
1921 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1922 Error(
"malformed block record in AST file");
1932 ModuleMacros.push_back(ModuleMacroRecord());
1933 auto &Info = ModuleMacros.back();
1934 Info.SubModID = getGlobalSubmoduleID(M, Record[0]);
1935 Info.MI = getMacro(getGlobalMacroID(M, Record[1]));
1936 for (
int I = 2, N = Record.size();
I != N; ++
I)
1937 Info.Overrides.push_back(getGlobalSubmoduleID(M, Record[
I]));
1942 Error(
"malformed block record in AST file");
1953 std::reverse(ModuleMacros.begin(), ModuleMacros.end());
1955 for (
auto &MMR : ModuleMacros) {
1957 for (
unsigned ModID : MMR.Overrides) {
1958 Module *Mod = getSubmodule(ModID);
1959 auto *Macro = PP.getModuleMacro(Mod, II);
1960 assert(Macro &&
"missing definition for overridden macro");
1961 Overrides.push_back(Macro);
1964 bool Inserted =
false;
1965 Module *Owner = getSubmodule(MMR.SubModID);
1966 PP.addModuleMacro(Owner, II, MMR.MI, Overrides, Inserted);
1977 unsigned Idx = 0, N = Record.size();
1984 MacroInfo *MI = getMacro(getGlobalMacroID(M, Record[Idx++]));
1985 MD = PP.AllocateDefMacroDirective(MI, Loc);
1989 MD = PP.AllocateUndefMacroDirective(Loc);
1993 bool isPublic = Record[Idx++];
1994 MD = PP.AllocateVisibilityMacroDirective(Loc, isPublic);
2006 PP.setLoadedMacroDirective(II, Earliest, Latest);
2009 ASTReader::InputFileInfo
2010 ASTReader::readInputFileInfo(ModuleFile &F,
unsigned ID) {
2012 BitstreamCursor &Cursor = F.InputFilesCursor;
2014 Cursor.JumpToBit(F.InputFileOffsets[ID-1]);
2016 unsigned Code = Cursor.ReadCode();
2020 unsigned Result = Cursor.readRecord(Code, Record, &Blob);
2021 assert(static_cast<InputFileRecordTypes>(Result) ==
INPUT_FILE &&
2022 "invalid record type for input file");
2025 assert(Record[0] == ID &&
"Bogus stored ID or offset");
2027 R.StoredSize =
static_cast<off_t
>(Record[1]);
2028 R.StoredTime =
static_cast<time_t
>(Record[2]);
2029 R.Overridden =
static_cast<bool>(Record[3]);
2030 R.Transient =
static_cast<bool>(Record[4]);
2031 R.TopLevelModuleMap =
static_cast<bool>(Record[5]);
2033 ResolveImportedPath(F, R.Filename);
2055 InputFileInfo FI = readInputFileInfo(F, ID);
2056 off_t StoredSize = FI.StoredSize;
2057 time_t StoredTime = FI.StoredTime;
2058 bool Overridden = FI.Overridden;
2059 bool Transient = FI.Transient;
2062 const FileEntry *File = FileMgr.getFile(Filename,
false);
2066 if (File ==
nullptr && !F.
OriginalDir.empty() && !CurrentDir.empty() &&
2071 if (!Resolved.empty())
2072 File = FileMgr.getFile(Resolved);
2077 if ((Overridden || Transient) && File ==
nullptr)
2078 File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime);
2080 if (File ==
nullptr) {
2082 std::string ErrorStr =
"could not find file '";
2084 ErrorStr +=
"' referenced by AST file '";
2102 Error(diag::err_fe_pch_file_overridden, Filename);
2114 FileMgr.modifyFileEntry(const_cast<FileEntry*>(File),
2115 StoredSize, StoredTime);
2118 bool IsOutOfDate =
false;
2122 (StoredSize != File->
getSize() ||
2129 while (ImportStack.back()->ImportedBy.size() > 0)
2130 ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
2133 StringRef TopLevelPCHName(ImportStack.back()->FileName);
2135 if (DiagnosticKind == 0)
2136 Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
2137 else if (DiagnosticKind == 1)
2138 Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName);
2140 Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName);
2143 if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
2144 Diag(diag::note_pch_required_by)
2145 << Filename << ImportStack[0]->FileName;
2146 for (
unsigned I = 1;
I < ImportStack.size(); ++
I)
2147 Diag(diag::note_pch_required_by)
2148 << ImportStack[
I-1]->FileName << ImportStack[
I]->FileName;
2151 if (!Diags.isDiagnosticInFlight())
2152 Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
2177 if (Filename.empty() || llvm::sys::path::is_absolute(Filename))
2181 llvm::sys::path::append(Buffer, Prefix, Filename);
2182 Filename.assign(Buffer.begin(), Buffer.end());
2197 llvm_unreachable(
"unknown ASTReadResult");
2201 BitstreamCursor &Stream,
unsigned ClientLoadCapabilities,
2203 std::string &SuggestedPredefines) {
2209 ASTReadResult Result =
Success;
2211 llvm::BitstreamEntry Entry = Stream.advance();
2213 switch (Entry.Kind) {
2215 case llvm::BitstreamEntry::SubBlock:
2218 case llvm::BitstreamEntry::EndBlock:
2221 case llvm::BitstreamEntry::Record:
2230 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2231 if (ParseLanguageOptions(Record, Complain, Listener,
2232 AllowCompatibleConfigurationMismatch))
2233 Result = ConfigurationMismatch;
2238 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2239 if (ParseTargetOptions(Record, Complain, Listener,
2240 AllowCompatibleConfigurationMismatch))
2241 Result = ConfigurationMismatch;
2246 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2247 if (!AllowCompatibleConfigurationMismatch &&
2248 ParseFileSystemOptions(Record, Complain, Listener))
2249 Result = ConfigurationMismatch;
2254 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2255 if (!AllowCompatibleConfigurationMismatch &&
2256 ParseHeaderSearchOptions(Record, Complain, Listener))
2257 Result = ConfigurationMismatch;
2262 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2263 if (!AllowCompatibleConfigurationMismatch &&
2264 ParsePreprocessorOptions(Record, Complain, Listener,
2265 SuggestedPredefines))
2266 Result = ConfigurationMismatch;
2276 unsigned ClientLoadCapabilities) {
2277 BitstreamCursor &Stream = F.
Stream;
2278 ASTReadResult Result =
Success;
2281 Error(
"malformed block record in AST file");
2291 bool HasReadUnhashedControlBlock =
false;
2292 auto readUnhashedControlBlockOnce = [&]() {
2293 if (!HasReadUnhashedControlBlock) {
2294 HasReadUnhashedControlBlock =
true;
2295 if (ASTReadResult Result =
2296 readUnhashedControlBlock(F, ImportedBy, ClientLoadCapabilities))
2304 unsigned NumInputs = 0;
2305 unsigned NumUserInputs = 0;
2307 llvm::BitstreamEntry Entry = Stream.advance();
2309 switch (Entry.Kind) {
2311 Error(
"malformed block record in AST file");
2313 case llvm::BitstreamEntry::EndBlock: {
2316 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2321 PP.getHeaderSearchInfo().getHeaderSearchOpts();
2328 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
2334 unsigned N = NumUserInputs;
2335 if (ValidateSystemInputs ||
2341 for (
unsigned I = 0;
I < N; ++
I) {
2342 InputFile IF = getInputFile(F,
I+1, Complain);
2354 for (
unsigned I = 0;
I < N; ++
I) {
2355 bool IsSystem =
I >= NumUserInputs;
2356 InputFileInfo FI = readInputFileInfo(F,
I+1);
2366 case llvm::BitstreamEntry::SubBlock:
2370 if (Stream.SkipBlock() ||
2373 Error(
"malformed block record in AST file");
2382 if (Listener && !ImportedBy) {
2388 bool AllowCompatibleConfigurationMismatch =
2391 Result = ReadOptionsBlock(Stream, ClientLoadCapabilities,
2392 AllowCompatibleConfigurationMismatch,
2393 *Listener, SuggestedPredefines);
2394 if (Result == Failure) {
2395 Error(
"malformed block record in AST file");
2399 if (DisableValidation ||
2400 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
2406 if (Result != Success)
2408 }
else if (Stream.SkipBlock()) {
2409 Error(
"malformed block record in AST file");
2415 if (Stream.SkipBlock()) {
2416 Error(
"malformed block record in AST file");
2422 case llvm::BitstreamEntry::Record:
2433 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2435 : diag::err_pch_version_too_new);
2439 bool hasErrors = Record[6];
2440 if (hasErrors && !DisableValidation && !AllowASTWithCompilerErrors) {
2441 Diag(diag::err_pch_with_compiler_errors);
2445 Diags.ErrorOccurred =
true;
2446 Diags.UncompilableErrorOccurred =
true;
2447 Diags.UnrecoverableErrorOccurred =
true;
2458 StringRef ASTBranch = Blob;
2459 if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
2460 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2461 Diag(diag::err_pch_different_branch) << ASTBranch << CurBranch;
2471 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2475 unsigned Idx = 0, N = Record.size();
2483 ReadUntranslatedSourceLocation(Record[Idx++]);
2484 off_t StoredSize = (off_t)Record[Idx++];
2485 time_t StoredModTime = (time_t)Record[Idx++];
2487 {{(uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
2488 (uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
2489 (uint32_t)Record[Idx++]}}};
2490 auto ImportedFile = ReadPath(F, Record, Idx);
2494 unsigned Capabilities = ClientLoadCapabilities;
2495 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2496 Capabilities &= ~ARR_Missing;
2499 auto Result = ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F,
2500 Loaded, StoredSize, StoredModTime,
2501 StoredSignature, Capabilities);
2505 Diag(diag::note_module_file_imported_by)
2506 << F.
FileName << !F.ModuleName.empty() << F.ModuleName;
2509 case Failure:
return Failure;
2512 case OutOfDate:
return OutOfDate;
2514 case ConfigurationMismatch:
return ConfigurationMismatch;
2515 case HadErrors:
return HadErrors;
2544 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2551 "MODULE_DIRECTORY found before MODULE_NAME");
2555 if (M && M->Directory) {
2560 PP.getFileManager().getDirectory(Blob);
2561 if (!BuildDir || BuildDir != M->Directory) {
2562 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2563 Diag(diag::err_imported_module_relocated)
2564 << F.
ModuleName << Blob << M->Directory->getName();
2576 if (ASTReadResult Result =
2577 ReadModuleMapFileBlock(Record, F, ImportedBy, ClientLoadCapabilities))
2582 NumInputs = Record[0];
2583 NumUserInputs = Record[1];
2585 (
const llvm::support::unaligned_uint64_t *)Blob.data();
2594 ASTReader::ReadASTBlock(
ModuleFile &F,
unsigned ClientLoadCapabilities) {
2595 BitstreamCursor &Stream = F.
Stream;
2598 Error(
"malformed block record in AST file");
2605 llvm::BitstreamEntry Entry = Stream.advance();
2607 switch (Entry.Kind) {
2609 Error(
"error at end of module block in AST file");
2611 case llvm::BitstreamEntry::EndBlock: {
2625 case llvm::BitstreamEntry::SubBlock:
2633 if (Stream.SkipBlock() ||
2636 Error(
"malformed block record in AST file");
2643 if (!PP.getExternalSource())
2644 PP.setExternalSource(
this);
2646 if (Stream.SkipBlock() ||
2648 Error(
"malformed block record in AST file");
2656 if (Stream.SkipBlock() ||
2659 Error(
"malformed preprocessor detail record in AST file");
2665 if (!PP.getPreprocessingRecord())
2666 PP.createPreprocessingRecord();
2667 if (!PP.getPreprocessingRecord()->getExternalSource())
2668 PP.getPreprocessingRecord()->SetExternalSource(*
this);
2672 if (ReadSourceManagerBlock(F))
2677 if (ASTReadResult Result =
2678 ReadSubmoduleBlock(F, ClientLoadCapabilities))
2683 BitstreamCursor
C = Stream;
2684 if (Stream.SkipBlock() ||
2686 Error(
"malformed comments block in AST file");
2689 CommentsCursors.push_back(std::make_pair(C, &F));
2694 if (Stream.SkipBlock()) {
2695 Error(
"malformed block record in AST file");
2702 case llvm::BitstreamEntry::Record:
2742 Error(
"duplicate TYPE_OFFSET record in AST file");
2747 unsigned LocalBaseTypeIndex = Record[1];
2752 GlobalTypeMap.insert(std::make_pair(getTotalNumTypes(), &F));
2756 std::make_pair(LocalBaseTypeIndex,
2766 Error(
"duplicate DECL_OFFSET record in AST file");
2771 unsigned LocalBaseDeclID = Record[1];
2777 GlobalDeclMap.insert(
2783 std::make_pair(LocalBaseDeclID, F.
BaseDeclID - LocalBaseDeclID));
2795 DeclContext *TU = ContextObj->getTranslationUnitDecl();
2796 LexicalContents Contents(
2797 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
2799 static_cast<unsigned int>(Blob.size() / 4));
2800 TULexicalDecls.push_back(std::make_pair(&F, Contents));
2808 auto *Data = (
const unsigned char*)Blob.data();
2809 PendingVisibleUpdates[
ID].push_back(PendingVisibleUpdate{&F, Data});
2812 if (
Decl *D = GetExistingDecl(ID))
2813 PendingUpdateRecords.push_back(
2814 PendingUpdateRecord(ID, D,
false));
2827 PP.getIdentifierTable().setExternalIdentifierLookup(
this);
2833 Error(
"duplicate IDENTIFIER_OFFSET record in AST file");
2838 unsigned LocalBaseIdentifierID = Record[1];
2844 GlobalIdentifierMap.insert(std::make_pair(getTotalNumIdentifiers() + 1,
2850 std::make_pair(LocalBaseIdentifierID,
2853 IdentifiersLoaded.resize(IdentifiersLoaded.size()
2866 for (
unsigned I = 0, N = Record.size();
I != N; ++
I)
2867 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[
I]));
2874 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
2875 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
2879 if (SpecialTypes.empty()) {
2880 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
2881 SpecialTypes.push_back(getGlobalTypeID(F, Record[I]));
2885 if (SpecialTypes.size() != Record.size()) {
2886 Error(
"invalid special-types record");
2890 for (
unsigned I = 0, N = Record.size(); I != N; ++
I) {
2892 if (!SpecialTypes[I])
2893 SpecialTypes[
I] =
ID;
2900 TotalNumStatements += Record[0];
2901 TotalNumMacros += Record[1];
2902 TotalLexicalDeclContexts += Record[2];
2903 TotalVisibleDeclContexts += Record[3];
2907 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
2908 UnusedFileScopedDecls.push_back(getGlobalDeclID(F, Record[I]));
2912 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
2913 DelegatingCtorDecls.push_back(getGlobalDeclID(F, Record[I]));
2917 if (Record.size() % 4 != 0) {
2918 Error(
"invalid weak identifiers record");
2924 WeakUndeclaredIdentifiers.clear();
2927 for (
unsigned I = 0, N = Record.size(); I < N; ) {
2928 WeakUndeclaredIdentifiers.push_back(
2929 getGlobalIdentifierID(F, Record[I++]));
2930 WeakUndeclaredIdentifiers.push_back(
2931 getGlobalIdentifierID(F, Record[I++]));
2932 WeakUndeclaredIdentifiers.push_back(
2933 ReadSourceLocation(F, Record, I).getRawEncoding());
2934 WeakUndeclaredIdentifiers.push_back(Record[I++]);
2941 unsigned LocalBaseSelectorID = Record[1];
2947 GlobalSelectorMap.insert(std::make_pair(getTotalNumSelectors()+1, &F));
2952 std::make_pair(LocalBaseSelectorID,
2968 TotalNumMethodPoolEntries += Record[1];
2972 if (!Record.empty()) {
2973 for (
unsigned Idx = 0, N = Record.size() - 1; Idx < N; ) {
2974 ReferencedSelectorsData.push_back(getGlobalSelectorID(F,
2976 ReferencedSelectorsData.push_back(ReadSourceLocation(F, Record, Idx).
2983 if (!Record.empty()) {
2985 for (
unsigned Idx = 0, N = Record.size() - 1; Idx < N; ) {
2986 auto Loc = ReadSourceLocation(F, Record, Idx);
2987 bool WasSkipping = Record[Idx++];
2988 bool FoundNonSkip = Record[Idx++];
2989 bool FoundElse = Record[Idx++];
2990 ConditionalStack.push_back(
2991 {Loc, WasSkipping, FoundNonSkip, FoundElse});
2993 PP.setReplayablePreambleConditionalStack(ConditionalStack);
2998 if (!Record.empty() && Listener)
3010 unsigned SLocSpaceSize = Record[1];
3015 Error(
"ran out of source locations");
3021 unsigned RangeStart =
3023 GlobalSLocEntryMap.insert(std::make_pair(RangeStart, &F));
3028 GlobalSLocOffsetMap.insert(
3030 - SLocSpaceSize,&F));
3048 if (ParseLineTable(F, Record))
3056 Error(
"Multiple SOURCE_LOCATION_PRELOADS records in AST file");
3065 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
3066 ExtVectorDecls.push_back(getGlobalDeclID(F, Record[I]));
3070 if (Record.size() % 3 != 0) {
3071 Error(
"Invalid VTABLE_USES record");
3080 for (
unsigned Idx = 0, N = Record.size(); Idx != N; ) {
3081 VTableUses.push_back(getGlobalDeclID(F, Record[Idx++]));
3082 VTableUses.push_back(
3083 ReadSourceLocation(F, Record, Idx).getRawEncoding());
3084 VTableUses.push_back(Record[Idx++]);
3089 if (PendingInstantiations.size() % 2 != 0) {
3090 Error(
"Invalid existing PendingInstantiations");
3094 if (Record.size() % 2 != 0) {
3095 Error(
"Invalid PENDING_IMPLICIT_INSTANTIATIONS block");
3099 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3100 PendingInstantiations.push_back(getGlobalDeclID(F, Record[I++]));
3101 PendingInstantiations.push_back(
3102 ReadSourceLocation(F, Record, I).getRawEncoding());
3107 if (Record.size() != 3) {
3108 Error(
"Invalid SEMA_DECL_REFS block");
3111 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
3112 SemaDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
3120 unsigned LocalBasePreprocessedEntityID = Record[0];
3122 unsigned StartingID;
3123 if (!PP.getPreprocessingRecord())
3124 PP.createPreprocessingRecord();
3125 if (!PP.getPreprocessingRecord()->getExternalSource())
3126 PP.getPreprocessingRecord()->SetExternalSource(*
this);
3128 = PP.getPreprocessingRecord()
3135 GlobalPreprocessedEntityMap.insert(std::make_pair(StartingID, &F));
3140 std::make_pair(LocalBasePreprocessedEntityID,
3148 if (Record.size() % 2 != 0) {
3149 Error(
"invalid DECL_UPDATE_OFFSETS block in AST file");
3152 for (
unsigned I = 0, N = Record.size(); I != N; I += 2) {
3154 DeclUpdateOffsets[
ID].push_back(std::make_pair(&F, Record[I + 1]));
3158 if (
Decl *D = GetExistingDecl(ID))
3159 PendingUpdateRecords.push_back(
3160 PendingUpdateRecord(ID, D,
false));
3167 Error(
"duplicate OBJC_CATEGORIES_MAP record in AST file");
3183 CUDASpecialDeclRefs.clear();
3184 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
3185 CUDASpecialDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
3197 &PP.getHeaderSearchInfo(),
3198 Blob.data() + Record[2]));
3200 PP.getHeaderSearchInfo().SetExternalSource(
this);
3201 if (!PP.getHeaderSearchInfo().getExternalLookup())
3202 PP.getHeaderSearchInfo().SetExternalLookup(
this);
3209 FPPragmaOptions.swap(Record);
3213 for (
unsigned I = 0, E = Record.size(); I !=
E; ) {
3214 auto Name = ReadString(Record, I);
3215 auto &Opt = OpenCLExtensions.OptMap[
Name];
3216 Opt.Supported = Record[I++] != 0;
3217 Opt.Enabled = Record[I++] != 0;
3218 Opt.Avail = Record[I++];
3219 Opt.Core = Record[I++];
3224 for (
unsigned I = 0, E = Record.size(); I !=
E;) {
3227 auto NumExt =
static_cast<unsigned>(Record[I++]);
3228 for (
unsigned II = 0; II != NumExt; ++II) {
3229 auto Ext = ReadString(Record, I);
3230 OpenCLTypeExtMap[
Type].insert(Ext);
3236 for (
unsigned I = 0, E = Record.size(); I !=
E;) {
3239 auto NumExt =
static_cast<unsigned>(Record[I++]);
3240 for (
unsigned II = 0; II != NumExt; ++II) {
3241 auto Ext = ReadString(Record, I);
3242 OpenCLDeclExtMap[
Decl].insert(Ext);
3248 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
3249 TentativeDefinitions.push_back(getGlobalDeclID(F, Record[I]));
3253 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
3254 KnownNamespaces.push_back(getGlobalDeclID(F, Record[I]));
3258 if (UndefinedButUsed.size() % 2 != 0) {
3259 Error(
"Invalid existing UndefinedButUsed");
3263 if (Record.size() % 2 != 0) {
3264 Error(
"invalid undefined-but-used record");
3267 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3268 UndefinedButUsed.push_back(getGlobalDeclID(F, Record[I++]));
3269 UndefinedButUsed.push_back(
3270 ReadSourceLocation(F, Record, I).getRawEncoding());
3274 for (
unsigned I = 0, N = Record.size(); I != N;) {
3275 DelayedDeleteExprs.push_back(getGlobalDeclID(F, Record[I++]));
3276 const uint64_t Count = Record[I++];
3277 DelayedDeleteExprs.push_back(Count);
3278 for (uint64_t C = 0; C < Count; ++C) {
3279 DelayedDeleteExprs.push_back(ReadSourceLocation(F, Record, I).getRawEncoding());
3280 bool IsArrayForm = Record[I++] == 1;
3281 DelayedDeleteExprs.push_back(IsArrayForm);
3291 for (
unsigned I = 0, N = Record.size(); I != N; ) {
3292 unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
3295 ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
3296 if (DeserializationListener)
3297 DeserializationListener->ModuleImportRead(GlobalID, Loc);
3306 Error(
"duplicate MACRO_OFFSET record in AST file");
3311 unsigned LocalBaseMacroID = Record[1];
3316 GlobalMacroMap.insert(std::make_pair(getTotalNumMacros() + 1, &F));
3320 std::make_pair(LocalBaseMacroID,
3329 LateParsedTemplates.append(Record.begin(), Record.end());
3334 if (Record.size() != 1) {
3335 Error(
"invalid pragma optimize record");
3338 OptimizeOffPragmaLocation = ReadSourceLocation(F, Record[0]);
3342 if (Record.size() != 1) {
3343 Error(
"invalid pragma ms_struct record");
3346 PragmaMSStructState = Record[0];
3350 if (Record.size() != 2) {
3351 Error(
"invalid pragma ms_struct record");
3354 PragmaMSPointersToMembersState = Record[0];
3355 PointersToMembersPragmaLocation = ReadSourceLocation(F, Record[1]);
3359 for (
unsigned I = 0, N = Record.size(); I != N; ++
I)
3360 UnusedLocalTypedefNameCandidates.push_back(
3361 getGlobalDeclID(F, Record[I]));
3365 if (Record.size() != 1) {
3366 Error(
"invalid cuda pragma options record");
3369 ForceCUDAHostDeviceDepth = Record[0];
3373 if (Record.size() < 3) {
3374 Error(
"invalid pragma pack record");
3377 PragmaPackCurrentValue = Record[0];
3378 PragmaPackCurrentLocation = ReadSourceLocation(F, Record[1]);
3379 unsigned NumStackEntries = Record[2];
3382 PragmaPackStack.clear();
3383 for (
unsigned I = 0; I < NumStackEntries; ++
I) {
3384 PragmaPackStackEntry Entry;
3385 Entry.Value = Record[Idx++];
3386 Entry.Location = ReadSourceLocation(F, Record[Idx++]);
3387 PragmaPackStrings.push_back(ReadString(Record, Idx));
3388 Entry.SlotLabel = PragmaPackStrings.back();
3389 PragmaPackStack.push_back(Entry);
3397 void ASTReader::ReadModuleOffsetMap(
ModuleFile &F)
const {
3401 const unsigned char *Data = (
const unsigned char*)F.
ModuleOffsetMap.data();
3423 while (Data < DataEnd) {
3425 using namespace llvm::support;
3426 uint16_t Len = endian::readNext<uint16_t, little, unaligned>(Data);
3427 StringRef
Name = StringRef((
const char*)Data, Len);
3432 "SourceLocation remap refers to unknown module, cannot find ";
3438 uint32_t SLocOffset =
3439 endian::readNext<uint32_t, little, unaligned>(Data);
3440 uint32_t IdentifierIDOffset =
3441 endian::readNext<uint32_t, little, unaligned>(Data);
3442 uint32_t MacroIDOffset =
3443 endian::readNext<uint32_t, little, unaligned>(Data);
3444 uint32_t PreprocessedEntityIDOffset =
3445 endian::readNext<uint32_t, little, unaligned>(Data);
3446 uint32_t SubmoduleIDOffset =
3447 endian::readNext<uint32_t, little, unaligned>(Data);
3448 uint32_t SelectorIDOffset =
3449 endian::readNext<uint32_t, little, unaligned>(Data);
3450 uint32_t DeclIDOffset =
3451 endian::readNext<uint32_t, little, unaligned>(Data);
3452 uint32_t TypeIndexOffset =
3453 endian::readNext<uint32_t, little, unaligned>(Data);
3457 auto mapOffset = [&](uint32_t
Offset, uint32_t BaseOffset,
3458 RemapBuilder &Remap) {
3460 Remap.insert(std::make_pair(Offset,
3461 static_cast<int>(BaseOffset - Offset)));
3463 mapOffset(SLocOffset, OM->SLocEntryBaseOffset,
SLocRemap);
3464 mapOffset(IdentifierIDOffset, OM->BaseIdentifierID, IdentifierRemap);
3465 mapOffset(MacroIDOffset, OM->BaseMacroID, MacroRemap);
3466 mapOffset(PreprocessedEntityIDOffset, OM->BasePreprocessedEntityID,
3467 PreprocessedEntityRemap);
3468 mapOffset(SubmoduleIDOffset, OM->BaseSubmoduleID, SubmoduleRemap);
3469 mapOffset(SelectorIDOffset, OM->BaseSelectorID, SelectorRemap);
3470 mapOffset(DeclIDOffset, OM->BaseDeclID, DeclRemap);
3471 mapOffset(TypeIndexOffset, OM->BaseTypeIndex, TypeRemap);
3479 ASTReader::ReadModuleMapFileBlock(RecordData &Record,
ModuleFile &F,
3481 unsigned ClientLoadCapabilities) {
3490 "MODULE_NAME should come before MODULE_MAP_FILE");
3495 auto &
Map = PP.getHeaderSearchInfo().getModuleMap();
3496 const FileEntry *ModMap = M ?
Map.getModuleMapFileForUniquing(M) :
nullptr;
3498 assert(ImportedBy &&
"top-level import should be verified");
3499 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) {
3500 if (
auto *ASTFE = M ? M->
getASTFile() :
nullptr)
3503 << ASTFE->getName();
3506 Diag(diag::err_imported_module_not_found)
3513 assert(M->
Name == F.
ModuleName &&
"found module with different name");
3517 if (StoredModMap ==
nullptr || StoredModMap != ModMap) {
3518 assert(ModMap &&
"found module is missing module map file");
3519 assert(ImportedBy &&
"top-level import should be verified");
3520 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3521 Diag(diag::err_imported_module_modmap_changed)
3527 llvm::SmallPtrSet<const FileEntry *, 1> AdditionalStoredMaps;
3528 for (
unsigned I = 0, N = Record[Idx++]; I < N; ++
I) {
3530 std::string Filename = ReadPath(F, Record, Idx);
3532 FileMgr.getFile(Filename,
false,
false);
3534 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3535 Error(
"could not find file '" + Filename +
"' referenced by AST file");
3538 AdditionalStoredMaps.insert(F);
3543 if (
auto *AdditionalModuleMaps =
Map.getAdditionalModuleMapFiles(M)) {
3544 for (
const FileEntry *ModMap : *AdditionalModuleMaps) {
3547 if (!AdditionalStoredMaps.erase(ModMap)) {
3548 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3549 Diag(diag::err_module_different_modmap)
3550 << F.ModuleName << 0 << ModMap->
getName();
3558 for (
const FileEntry *ModMap : AdditionalStoredMaps) {
3559 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3560 Diag(diag::err_module_different_modmap)
3561 << F.ModuleName << 1 << ModMap->
getName();
3575 Sema::GlobalMethodPool::iterator Known
3582 : Known->second.second;
3586 if (List->getMethod() == Method) {
3594 if (List->getNext())
3595 List->setMethod(List->getNext()->getMethod());
3597 List->setMethod(Method);
3603 for (
Decl *D : Names) {
3604 bool wasHidden = D->isHidden();
3605 D->setVisibleDespiteOwningModule();
3607 if (wasHidden && SemaObj) {
3618 llvm::SmallPtrSet<Module *, 4> Visited;
3620 Stack.push_back(Mod);
3621 while (!Stack.empty()) {
3622 Mod = Stack.pop_back_val();
3624 if (NameVisibility <= Mod->NameVisibility) {
3640 HiddenNamesMapType::iterator Hidden = HiddenNamesMap.find(Mod);
3641 if (Hidden != HiddenNamesMap.end()) {
3643 HiddenNamesMap.erase(Hidden);
3645 assert(HiddenNamesMap.find(Mod) == HiddenNamesMap.end() &&
3646 "making names visible added hidden names");
3653 I = Exports.begin(), E = Exports.end(); I !=
E; ++
I) {
3655 if (Visited.insert(Exported).second)
3656 Stack.push_back(Exported);
3673 else if (getContext().getLangOpts().ModulesLocalVisibility) {
3674 getContext().mergeDefinitionIntoModule(
3677 PendingMergedDefinitionsToDeduplicate.insert(Def);
3680 assert(
SubmoduleID &&
"hidden definition in no module");
3681 HiddenNamesMap[getSubmodule(
SubmoduleID)].push_back(Def);
3690 if (TriedLoadingGlobalIndex || !UseGlobalIndex ||
3691 !PP.getLangOpts().Modules)
3695 TriedLoadingGlobalIndex =
true;
3696 StringRef ModuleCachePath
3697 = getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
3698 std::pair<GlobalModuleIndex *, GlobalModuleIndex::ErrorCode> Result
3703 GlobalIndex.reset(Result.first);
3704 ModuleMgr.setGlobalIndex(GlobalIndex.get());
3709 return PP.getLangOpts().Modules && UseGlobalIndex &&
3710 !hasGlobalIndex() && TriedLoadingGlobalIndex;
3717 llvm::raw_fd_ostream OS(TimestampFilename, EC, llvm::sys::fs::F_Text);
3720 OS <<
"Timestamp file\n";
3730 llvm::BitstreamEntry Entry = Cursor.advance();
3731 switch (Entry.Kind) {
3733 case llvm::BitstreamEntry::EndBlock:
3736 case llvm::BitstreamEntry::Record:
3738 Cursor.skipRecord(Entry.ID);
3741 case llvm::BitstreamEntry::SubBlock:
3742 if (Entry.ID == BlockID) {
3743 if (Cursor.EnterSubBlock(BlockID))
3749 if (Cursor.SkipBlock())
3758 unsigned ClientLoadCapabilities,
3761 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
3767 unsigned PreviousGeneration = 0;
3769 PreviousGeneration = incrementGeneration(*ContextObj);
3771 unsigned NumModules = ModuleMgr.size();
3774 ReadASTCore(FileName, Type, ImportLoc,
3775 nullptr, Loaded, 0, 0,
3780 case VersionMismatch:
3781 case ConfigurationMismatch:
3783 llvm::SmallPtrSet<ModuleFile *, 4> LoadedSet;
3784 for (
const ImportedModule &IM : Loaded)
3785 LoadedSet.insert(IM.Mod);
3787 ModuleMgr.removeModules(ModuleMgr.begin() + NumModules, LoadedSet,
3788 PP.getLangOpts().Modules
3789 ? &PP.getHeaderSearchInfo().getModuleMap()
3794 GlobalIndex.reset();
3795 ModuleMgr.setGlobalIndex(
nullptr);
3806 MEnd = Loaded.end();
3811 if (
ASTReadResult Result = ReadASTBlock(F, ClientLoadCapabilities))
3833 SourceMgr.getLoadedSLocEntryByID(Index);
3846 const unsigned char *Data =
reinterpret_cast<const unsigned char *
>(
3851 auto Key = Trait.
ReadKey(Data, KeyDataLen.first);
3852 auto &II = PP.getIdentifierTable().getOwn(Key);
3853 II.setOutOfDate(
true);
3861 SetIdentifierInfo(ID, &II);
3868 MEnd = Loaded.end();
3872 ModuleMgr.moduleFileAccepted(&F);
3881 F.
ImportLoc = TranslateSourceLocation(*M->ImportedBy, M->ImportLoc);
3884 if (!PP.getLangOpts().CPlusPlus ||
3895 IdEnd = PP.getIdentifierTable().end();
3897 Id->second->setOutOfDate(
true);
3900 for (
auto Sel : SelectorGeneration)
3901 SelectorOutOfDate[Sel.first] =
true;
3904 for (
unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++
I) {
3905 UnresolvedModuleRef &Unresolved = UnresolvedModuleRefs[
I];
3906 SubmoduleID GlobalID = getGlobalSubmoduleID(*Unresolved.File,Unresolved.ID);
3907 Module *ResolvedMod = getSubmodule(GlobalID);
3909 switch (Unresolved.Kind) {
3910 case UnresolvedModuleRef::Conflict:
3913 Conflict.
Other = ResolvedMod;
3914 Conflict.
Message = Unresolved.String.str();
3915 Unresolved.Mod->Conflicts.push_back(Conflict);
3919 case UnresolvedModuleRef::Import:
3921 Unresolved.Mod->Imports.insert(ResolvedMod);
3924 case UnresolvedModuleRef::Export:
3925 if (ResolvedMod || Unresolved.IsWildcard)
3926 Unresolved.Mod->Exports.push_back(
3931 UnresolvedModuleRefs.clear();
3934 Imported->append(ImportedModules.begin(),
3935 ImportedModules.end());
3942 InitializeContext();
3947 if (DeserializationListener)
3948 DeserializationListener->ReaderInitialized(
this);
3950 ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule();
3965 for (
unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++
I) {
3966 loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
3967 ObjCClassesLoaded[I],
3968 PreviousGeneration);
3972 if (PP.getHeaderSearchInfo()
3973 .getHeaderSearchOpts()
3974 .ModulesValidateOncePerBuildSession) {
3979 for (
unsigned I = 0, N = Loaded.size(); I != N; ++
I) {
3980 ImportedModule &M = Loaded[
I];
3994 return Stream.canSkipToPos(4) &&
3995 Stream.Read(8) ==
'C' &&
3996 Stream.Read(8) ==
'P' &&
3997 Stream.Read(8) ==
'C' &&
3998 Stream.Read(8) ==
'H';
4013 llvm_unreachable(
"unknown module kind");
4017 ASTReader::ReadASTCore(StringRef
FileName,
4022 off_t ExpectedSize, time_t ExpectedModTime,
4024 unsigned ClientLoadCapabilities) {
4026 std::string ErrorStr;
4028 = ModuleMgr.addModule(FileName, Type, ImportLoc, ImportedBy,
4029 getGeneration(), ExpectedSize, ExpectedModTime,
4033 switch (AddResult) {
4044 if (ClientLoadCapabilities & ARR_Missing)
4049 << FileName << !ErrorStr.empty()
4056 if (ClientLoadCapabilities & ARR_OutOfDate)
4061 << FileName << !ErrorStr.empty()
4066 assert(M &&
"Missing module file");
4070 if (FileName !=
"-") {
4071 CurrentDir = llvm::sys::path::parent_path(FileName);
4072 if (CurrentDir.empty()) CurrentDir =
".";
4076 BitstreamCursor &Stream = F.
Stream;
4077 Stream = BitstreamCursor(PCHContainerRdr.ExtractPCH(*F.
Buffer));
4088 bool HaveReadControlBlock =
false;
4090 llvm::BitstreamEntry Entry = Stream.advance();
4092 switch (Entry.Kind) {
4094 case llvm::BitstreamEntry::Record:
4095 case llvm::BitstreamEntry::EndBlock:
4096 Error(
"invalid record at top-level of AST file");
4099 case llvm::BitstreamEntry::SubBlock:
4105 HaveReadControlBlock =
true;
4106 switch (ReadControlBlock(F, Loaded, ImportedBy, ClientLoadCapabilities)) {
4116 if (Result != OutOfDate ||
4117 (ClientLoadCapabilities & ARR_OutOfDate) == 0)
4123 case Failure:
return Failure;
4124 case Missing:
return Missing;
4125 case OutOfDate:
return OutOfDate;
4127 case ConfigurationMismatch:
return ConfigurationMismatch;
4128 case HadErrors:
return HadErrors;
4133 if (!HaveReadControlBlock) {
4134 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
4135 Diag(diag::err_pch_version_too_old);
4140 Loaded.push_back(ImportedModule(M, ImportedBy, ImportLoc));
4146 Error(
"malformed block record in AST file");
4150 if (Stream.SkipBlock()) {
4151 Error(
"malformed block record in AST file");
4162 ASTReader::readUnhashedControlBlock(
ModuleFile &F,
bool WasImportedBy,
4163 unsigned ClientLoadCapabilities) {
4165 PP.getHeaderSearchInfo().getHeaderSearchOpts();
4166 bool AllowCompatibleConfigurationMismatch =
4169 ASTReadResult Result = readUnhashedControlBlockImpl(
4170 &F, F.
Data, ClientLoadCapabilities, AllowCompatibleConfigurationMismatch,
4176 if (DisableValidation || WasImportedBy ||
4177 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
4180 if (Result == Failure) {
4181 Error(
"malformed block record in AST file");
4204 if (PCMCache.isBufferFinal(F.
FileName)) {
4205 Diag(diag::warn_module_system_bit_conflict) << F.
FileName;
4214 ModuleFile *F, llvm::StringRef StreamData,
unsigned ClientLoadCapabilities,
4216 bool ValidateDiagnosticOptions) {
4218 BitstreamCursor Stream(StreamData);
4230 ASTReadResult Result =
Success;
4232 llvm::BitstreamEntry Entry = Stream.advance();
4234 switch (Entry.Kind) {
4236 case llvm::BitstreamEntry::SubBlock:
4239 case llvm::BitstreamEntry::EndBlock:
4242 case llvm::BitstreamEntry::Record:
4253 std::copy(Record.begin(), Record.end(), F->
Signature.data());
4257 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
4258 if (Listener && ValidateDiagnosticOptions &&
4259 !AllowCompatibleConfigurationMismatch &&
4260 ParseDiagnosticOptions(Record, Complain, *Listener))
4271 Record.begin(), Record.end());
4282 if (Record.size() < 4)
return true;
4287 unsigned BlockNameLen = Record[2];
4288 unsigned UserInfoLen = Record[3];
4290 if (BlockNameLen + UserInfoLen > Blob.size())
return true;
4292 Metadata.
BlockName = std::string(Blob.data(), Blob.data() + BlockNameLen);
4293 Metadata.
UserInfo = std::string(Blob.data() + BlockNameLen,
4294 Blob.data() + BlockNameLen + UserInfoLen);
4299 BitstreamCursor &Stream = F.
Stream;
4303 llvm::BitstreamEntry Entry = Stream.advance();
4304 switch (Entry.Kind) {
4305 case llvm::BitstreamEntry::SubBlock:
4306 if (Stream.SkipBlock())
4311 case llvm::BitstreamEntry::EndBlock:
4317 case llvm::BitstreamEntry::Record:
4323 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4331 auto Known = ModuleFileExtensions.find(Metadata.
BlockName);
4332 if (Known == ModuleFileExtensions.end())
break;
4335 if (
auto Reader = Known->second->createExtensionReader(Metadata, *
this,
4349 assert(ContextObj &&
"no context to initialize");
4353 if (DeserializationListener)
4363 if (!Context.CFConstantStringTypeDecl)
4370 Error(
"FILE type is NULL");
4374 if (!Context.FILEDecl) {
4380 Error(
"Invalid FILE type in AST file");
4389 QualType Jmp_bufType = GetType(Jmp_buf);
4390 if (Jmp_bufType.
isNull()) {
4391 Error(
"jmp_buf type is NULL");
4395 if (!Context.jmp_bufDecl) {
4401 Error(
"Invalid jmp_buf type in AST file");
4410 QualType Sigjmp_bufType = GetType(Sigjmp_buf);
4411 if (Sigjmp_bufType.
isNull()) {
4412 Error(
"sigjmp_buf type is NULL");
4416 if (!Context.sigjmp_bufDecl) {
4421 assert(Tag &&
"Invalid sigjmp_buf type in AST file");
4427 if (
unsigned ObjCIdRedef
4429 if (Context.ObjCIdRedefinitionType.
isNull())
4430 Context.ObjCIdRedefinitionType = GetType(ObjCIdRedef);
4433 if (
unsigned ObjCClassRedef
4435 if (Context.ObjCClassRedefinitionType.
isNull())
4436 Context.ObjCClassRedefinitionType = GetType(ObjCClassRedef);
4439 if (
unsigned ObjCSelRedef
4441 if (Context.ObjCSelRedefinitionType.
isNull())
4442 Context.ObjCSelRedefinitionType = GetType(ObjCSelRedef);
4446 QualType Ucontext_tType = GetType(Ucontext_t);
4447 if (Ucontext_tType.
isNull()) {
4448 Error(
"ucontext_t type is NULL");
4452 if (!Context.ucontext_tDecl) {
4457 assert(Tag &&
"Invalid ucontext_t type in AST file");
4467 if (!CUDASpecialDeclRefs.empty()) {
4468 assert(CUDASpecialDeclRefs.size() == 1 &&
"More decl refs than expected!");
4470 cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
4475 for (
auto &Import : ImportedModules) {
4476 if (
Module *Imported = getSubmodule(Import.ID)) {
4479 if (Import.ImportLoc.isValid())
4480 PP.makeModuleVisible(Imported, Import.ImportLoc);
4484 ImportedModules.clear();
4494 BitstreamCursor Stream(PCH);
4505 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
4506 if (Entry.Kind != llvm::BitstreamEntry::Record)
4511 if (
SIGNATURE == Stream.readRecord(Entry.ID, Record, &Blob))
4512 return {{{(uint32_t)Record[0], (uint32_t)Record[1], (uint32_t)Record[2],
4513 (uint32_t)Record[3], (uint32_t)Record[4]}}};
4521 const std::string &ASTFileName,
FileManager &FileMgr,
4526 Diags.
Report(diag::err_fe_unable_to_read_pch_file)
4527 << ASTFileName <<
Buffer.getError().message();
4528 return std::string();
4536 Diags.
Report(diag::err_fe_not_a_pch_file) << ASTFileName;
4537 return std::string();
4542 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
4543 return std::string();
4549 llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
4550 if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
4551 return std::string();
4553 if (Entry.Kind != llvm::BitstreamEntry::Record) {
4554 Diags.
Report(diag::err_fe_pch_malformed_block) << ASTFileName;
4555 return std::string();
4560 if (Stream.readRecord(Entry.ID, Record, &Blob) ==
ORIGINAL_FILE)
4571 std::string ExistingModuleCachePath;
4575 SimplePCHValidator(
const LangOptions &ExistingLangOpts,
4578 StringRef ExistingModuleCachePath,
4580 : ExistingLangOpts(ExistingLangOpts),
4581 ExistingTargetOpts(ExistingTargetOpts),
4582 ExistingPPOpts(ExistingPPOpts),
4583 ExistingModuleCachePath(ExistingModuleCachePath),
4588 bool ReadLanguageOptions(
const LangOptions &LangOpts,
bool Complain,
4589 bool AllowCompatibleDifferences)
override {
4591 AllowCompatibleDifferences);
4594 bool ReadTargetOptions(
const TargetOptions &TargetOpts,
bool Complain,
4595 bool AllowCompatibleDifferences)
override {
4597 AllowCompatibleDifferences);
4601 StringRef SpecificModuleCachePath,
4602 bool Complain)
override {
4604 ExistingModuleCachePath,
4605 nullptr, ExistingLangOpts);
4610 std::string &SuggestedPredefines)
override {
4612 SuggestedPredefines, ExistingLangOpts);
4621 bool FindModuleFileExtensions,
4633 BitstreamCursor Stream(Bytes);
4646 BitstreamCursor InputFilesCursor;
4649 std::string ModuleDir;
4650 bool DoneWithControlBlock =
false;
4651 while (!DoneWithControlBlock) {
4652 llvm::BitstreamEntry Entry = Stream.advance();
4654 switch (Entry.Kind) {
4655 case llvm::BitstreamEntry::SubBlock: {
4658 std::string IgnoredSuggestedPredefines;
4659 if (ReadOptionsBlock(Stream, ARR_ConfigurationMismatch | ARR_OutOfDate,
4661 Listener, IgnoredSuggestedPredefines) != Success)
4667 InputFilesCursor = Stream;
4668 if (Stream.SkipBlock() ||
4675 if (Stream.SkipBlock())
4683 case llvm::BitstreamEntry::EndBlock:
4684 DoneWithControlBlock =
true;
4690 case llvm::BitstreamEntry::Record:
4694 if (DoneWithControlBlock)
break;
4698 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4717 auto Path = ReadString(Record, Idx);
4718 ResolveImportedPath(Path, ModuleDir);
4723 if (!NeedsInputFiles)
4726 unsigned NumInputFiles = Record[0];
4727 unsigned NumUserFiles = Record[1];
4728 const uint64_t *InputFileOffs = (
const uint64_t *)Blob.data();
4729 for (
unsigned I = 0; I != NumInputFiles; ++
I) {
4731 bool isSystemFile = I >= NumUserFiles;
4733 if (isSystemFile && !NeedsSystemInputFiles)
4736 BitstreamCursor &Cursor = InputFilesCursor;
4738 Cursor.JumpToBit(InputFileOffs[I]);
4740 unsigned Code = Cursor.ReadCode();
4743 bool shouldContinue =
false;
4746 bool Overridden =
static_cast<bool>(Record[3]);
4747 std::string Filename = Blob;
4748 ResolveImportedPath(Filename, ModuleDir);
4750 Filename, isSystemFile, Overridden,
false);
4753 if (!shouldContinue)
4763 unsigned Idx = 0, N = Record.size();
4767 std::string Filename = ReadString(Record, Idx);
4768 ResolveImportedPath(Filename, ModuleDir);
4781 if (FindModuleFileExtensions) {
4782 BitstreamCursor SavedStream = Stream;
4784 bool DoneWithExtensionBlock =
false;
4785 while (!DoneWithExtensionBlock) {
4786 llvm::BitstreamEntry Entry = Stream.advance();
4788 switch (Entry.Kind) {
4789 case llvm::BitstreamEntry::SubBlock:
4790 if (Stream.SkipBlock())
4795 case llvm::BitstreamEntry::EndBlock:
4796 DoneWithExtensionBlock =
true;
4802 case llvm::BitstreamEntry::Record:
4808 unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
4821 Stream = SavedStream;
4825 if (readUnhashedControlBlockImpl(
4826 nullptr, Bytes, ARR_ConfigurationMismatch | ARR_OutOfDate,
4828 ValidateDiagnosticOptions) != Success)
4839 StringRef ExistingModuleCachePath) {
4840 SimplePCHValidator validator(LangOpts, TargetOpts, PPOpts,
4841 ExistingModuleCachePath, FileMgr);
4842 return !readASTFileControlBlock(Filename, FileMgr, PCHContainerRdr,
4849 ASTReader::ReadSubmoduleBlock(ModuleFile &F,
unsigned ClientLoadCapabilities) {
4852 Error(
"malformed submodule block record in AST file");
4856 ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
4858 Module *CurrentModule =
nullptr;
4862 llvm::BitstreamEntry Entry = F.Stream.advanceSkippingSubblocks();
4864 switch (Entry.Kind) {
4865 case llvm::BitstreamEntry::SubBlock:
4867 Error(
"malformed block record in AST file");
4869 case llvm::BitstreamEntry::EndBlock:
4871 case llvm::BitstreamEntry::Record:
4879 auto Kind = F.Stream.readRecord(Entry.ID, Record, &Blob);
4882 Error(
"submodule metadata record should be at beginning of block");
4898 if (Record.size() < 8) {
4899 Error(
"malformed module definition");
4903 StringRef
Name = Blob;
4905 SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);
4906 SubmoduleID Parent = getGlobalSubmoduleID(F, Record[Idx++]);
4907 bool IsFramework = Record[Idx++];
4908 bool IsExplicit = Record[Idx++];
4909 bool IsSystem = Record[Idx++];
4910 bool IsExternC = Record[Idx++];
4911 bool InferSubmodules = Record[Idx++];
4912 bool InferExplicitSubmodules = Record[Idx++];
4913 bool InferExportWildcard = Record[Idx++];
4914 bool ConfigMacrosExhaustive = Record[Idx++];
4916 Module *ParentModule =
nullptr;
4918 ParentModule = getSubmodule(Parent);
4930 if (GlobalIndex >= SubmodulesLoaded.size() ||
4931 SubmodulesLoaded[GlobalIndex]) {
4932 Error(
"too many submodules");
4936 if (!ParentModule) {
4938 if (CurFile != F.File) {
4939 if (!Diags.isDiagnosticInFlight()) {
4940 Diag(diag::err_module_file_conflict)
4942 << CurFile->getName()
4943 << F.File->getName();
4962 if (DeserializationListener)
4963 DeserializationListener->ModuleRead(GlobalID, CurrentModule);
4965 SubmodulesLoaded[GlobalIndex] = CurrentModule;
4987 std::string Filename = Blob;
4988 ResolveImportedPath(F, Filename);
4989 if (
auto *Umbrella = PP.getFileManager().getFile(Filename)) {
4993 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
4994 Error(
"mismatched umbrella headers in submodule");
5021 std::string Dirname = Blob;
5022 ResolveImportedPath(F, Dirname);
5023 if (
auto *Umbrella = PP.getFileManager().getDirectory(Dirname)) {
5027 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
5028 Error(
"mismatched umbrella directories in submodule");
5036 F.BaseSubmoduleID = getTotalNumSubmodules();
5037 F.LocalNumSubmodules = Record[0];
5038 unsigned LocalBaseSubmoduleID = Record[1];
5039 if (F.LocalNumSubmodules > 0) {
5042 GlobalSubmoduleMap.insert(std::make_pair(getTotalNumSubmodules()+1,&F));
5046 F.SubmoduleRemap.insertOrReplace(
5047 std::make_pair(LocalBaseSubmoduleID,
5048 F.BaseSubmoduleID - LocalBaseSubmoduleID));
5050 SubmodulesLoaded.resize(SubmodulesLoaded.size() + F.LocalNumSubmodules);
5057 for (
unsigned Idx = 0; Idx != Record.size(); ++Idx) {
5058 UnresolvedModuleRef Unresolved;
5059 Unresolved.File = &F;
5060 Unresolved.Mod = CurrentModule;
5061 Unresolved.ID = Record[Idx];
5062 Unresolved.
Kind = UnresolvedModuleRef::Import;
5063 Unresolved.IsWildcard =
false;
5064 UnresolvedModuleRefs.push_back(Unresolved);
5070 for (
unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
5071 UnresolvedModuleRef Unresolved;
5072 Unresolved.File = &F;
5073 Unresolved.Mod = CurrentModule;
5074 Unresolved.ID = Record[Idx];
5075 Unresolved.
Kind = UnresolvedModuleRef::Export;
5076 Unresolved.IsWildcard = Record[Idx + 1];
5077 UnresolvedModuleRefs.push_back(Unresolved);
5087 PP.getTargetInfo());
5101 UnresolvedModuleRef Unresolved;
5102 Unresolved.File = &F;
5103 Unresolved.Mod = CurrentModule;
5104 Unresolved.ID = Record[0];
5105 Unresolved.
Kind = UnresolvedModuleRef::Conflict;
5106 Unresolved.IsWildcard =
false;
5107 Unresolved.String = Blob;
5108 UnresolvedModuleRefs.push_back(Unresolved);
5116 for (
auto &ID : Record)
5117 Inits.push_back(getGlobalDeclID(F, ID));
5118 ContextObj->addLazyModuleInitializers(CurrentModule, Inits);
5131 bool ASTReader::ParseLanguageOptions(
const RecordData &Record,
5134 bool AllowCompatibleDifferences) {
5137 #define LANGOPT(Name, Bits, Default, Description) \
5138 LangOpts.Name = Record[Idx++];
5139 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
5140 LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++]));
5141 #include "clang/Basic/LangOptions.def"
5142 #define SANITIZER(NAME, ID) \
5143 LangOpts.Sanitize.set(SanitizerKind::ID, Record[Idx++]);
5144 #include "clang/Basic/Sanitizers.def"
5146 for (
unsigned N = Record[Idx++]; N; --N)
5150 VersionTuple runtimeVersion = ReadVersionTuple(Record, Idx);
5156 for (
unsigned N = Record[Idx++]; N; --N) {
5158 ReadString(Record, Idx));
5163 for (
unsigned N = Record[Idx++]; N; --N) {
5164 LangOpts.
OMPTargetTriples.push_back(llvm::Triple(ReadString(Record, Idx)));
5170 AllowCompatibleDifferences);
5173 bool ASTReader::ParseTargetOptions(
const RecordData &Record,
bool Complain,
5175 bool AllowCompatibleDifferences) {
5178 TargetOpts.
Triple = ReadString(Record, Idx);
5179 TargetOpts.
CPU = ReadString(Record, Idx);
5180 TargetOpts.
ABI = ReadString(Record, Idx);
5181 for (
unsigned N = Record[Idx++]; N; --N) {
5184 for (
unsigned N = Record[Idx++]; N; --N) {
5185 TargetOpts.
Features.push_back(ReadString(Record, Idx));
5189 AllowCompatibleDifferences);
5192 bool ASTReader::ParseDiagnosticOptions(
const RecordData &Record,
bool Complain,
5196 #define DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++];
5197 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
5198 DiagOpts->set##Name(static_cast<Type>(Record[Idx++]));
5199 #include "clang/Basic/DiagnosticOptions.def"
5201 for (
unsigned N = Record[Idx++]; N; --N)
5202 DiagOpts->Warnings.push_back(ReadString(Record, Idx));
5203 for (
unsigned N = Record[Idx++]; N; --N)
5204 DiagOpts->Remarks.push_back(ReadString(Record, Idx));
5209 bool ASTReader::ParseFileSystemOptions(
const RecordData &Record,
bool Complain,
5217 bool ASTReader::ParseHeaderSearchOptions(
const RecordData &Record,
5222 HSOpts.
Sysroot = ReadString(Record, Idx);
5225 for (
unsigned N = Record[Idx++]; N; --N) {
5226 std::string Path = ReadString(Record, Idx);
5229 bool IsFramework = Record[Idx++];
5230 bool IgnoreSysRoot = Record[Idx++];
5231 HSOpts.
UserEntries.emplace_back(std::move(Path), Group, IsFramework,
5236 for (
unsigned N = Record[Idx++]; N; --N) {
5237 std::string Prefix = ReadString(Record, Idx);
5238 bool IsSystemHeader = Record[Idx++];
5252 std::string SpecificModuleCachePath = ReadString(Record, Idx);
5258 bool ASTReader::ParsePreprocessorOptions(
const RecordData &Record,
5261 std::string &SuggestedPredefines) {
5266 for (
unsigned N = Record[Idx++]; N; --N) {
5267 std::string
Macro = ReadString(Record, Idx);
5268 bool IsUndef = Record[Idx++];
5269 PPOpts.
Macros.push_back(std::make_pair(Macro, IsUndef));
5273 for (
unsigned N = Record[Idx++]; N; --N) {
5274 PPOpts.
Includes.push_back(ReadString(Record, Idx));
5278 for (
unsigned N = Record[Idx++]; N; --N) {
5288 SuggestedPredefines.clear();
5290 SuggestedPredefines);
5293 std::pair<ModuleFile *, unsigned>
5294 ASTReader::getModulePreprocessedEntity(
unsigned GlobalIndex) {
5295 GlobalPreprocessedEntityMapType::iterator
5296 I = GlobalPreprocessedEntityMap.find(GlobalIndex);
5297 assert(I != GlobalPreprocessedEntityMap.end() &&
5298 "Corrupted global preprocessed entity map");
5300 unsigned LocalIndex = GlobalIndex - M->BasePreprocessedEntityID;
5301 return std::make_pair(M, LocalIndex);
5304 llvm::iterator_range<PreprocessingRecord::iterator>
5305 ASTReader::getModulePreprocessedEntities(
ModuleFile &Mod)
const {
5314 llvm::iterator_range<ASTReader::ModuleDeclIterator>
5316 return llvm::make_range(
5324 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
5326 unsigned LocalIndex = PPInfo.second;
5329 if (!PP.getPreprocessingRecord()) {
5330 Error(
"no preprocessing record");
5337 llvm::BitstreamEntry Entry =
5339 if (Entry.Kind != llvm::BitstreamEntry::Record)
5344 TranslateSourceLocation(M, PPOffs.
getEnd()));
5350 Entry.ID, Record, &Blob);
5353 bool isBuiltin = Record[0];
5357 Name = getLocalIdentifier(M, Record[1]);
5360 getGlobalPreprocessedEntityID(M, Record[1]);
5361 Def = cast<MacroDefinitionRecord>(
5362 PPRec.getLoadedPreprocessedEntity(GlobalID - 1));
5380 if (DeserializationListener)
5381 DeserializationListener->MacroDefinitionRead(PPID, MD);
5387 const char *FullFileNameStart = Blob.data() + Record[0];
5388 StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]);
5390 if (!FullFileName.empty())
5391 File = PP.getFileManager().getFile(FullFileName);
5398 StringRef(Blob.data(), Record[0]),
5399 Record[1], Record[3],
5406 llvm_unreachable(
"Invalid PreprocessorDetailRecordTypes");
5414 GlobalSLocOffsetMapType::const_iterator SLocMapI)
const {
5416 for (GlobalSLocOffsetMapType::const_iterator
5417 EndI = GlobalSLocOffsetMap.end(); SLocMapI != EndI; ++SLocMapI) {
5418 ModuleFile &M = *SLocMapI->second;
5419 if (M.NumPreprocessedEntities)
5423 return getTotalNumPreprocessedEntities();
5428 struct PPEntityComp {
5437 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
5442 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
5447 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
5451 return Reader.TranslateSourceLocation(M, PPE.
getBegin());
5458 bool EndsAfter)
const {
5459 if (
SourceMgr.isLocalSourceLocation(Loc))
5460 return getTotalNumPreprocessedEntities();
5462 GlobalSLocOffsetMapType::const_iterator SLocMapI = GlobalSLocOffsetMap.find(
5463 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
5464 assert(SLocMapI != GlobalSLocOffsetMap.end() &&
5465 "Corrupted global sloc offset map");
5467 if (SLocMapI->second->NumPreprocessedEntities == 0)
5468 return findNextPreprocessedEntity(SLocMapI);
5477 pp_iterator First = pp_begin;
5481 PPI = std::upper_bound(pp_begin, pp_end, Loc,
5482 PPEntityComp(*
this, M));
5491 std::advance(PPI, Half);
5492 if (
SourceMgr.isBeforeInTranslationUnit(
5493 TranslateSourceLocation(M, PPI->getEnd()), Loc)) {
5496 Count = Count - Half - 1;
5503 return findNextPreprocessedEntity(SLocMapI);
5510 std::pair<unsigned, unsigned>
5513 return std::make_pair(0,0);
5517 findPreprocessedEntity(Range.
getBegin(),
false);
5519 return std::make_pair(BeginID, EndID);
5529 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
5531 unsigned LocalIndex = PPInfo.second;
5547 class HeaderFileInfoVisitor {
5553 explicit HeaderFileInfoVisitor(
const FileEntry *FE)
5563 HeaderFileInfoLookupTable::iterator Pos = Table->find(FE);
5564 if (Pos == Table->end())
5577 HeaderFileInfoVisitor Visitor(FE);
5578 ModuleMgr.visit(Visitor);
5586 using DiagState = DiagnosticsEngine::DiagState;
5591 auto &Record = F.PragmaDiagMappings;
5597 auto ReadDiagState =
5599 bool IncludeNonPragmaStates) -> DiagnosticsEngine::DiagState * {
5600 unsigned BackrefID = Record[Idx++];
5602 return DiagStates[BackrefID - 1];
5605 Diag.DiagStates.push_back(BasedOn);
5606 DiagState *NewState = &Diag.DiagStates.back();
5607 DiagStates.push_back(NewState);
5608 unsigned Size = Record[Idx++];
5609 assert(Idx + Size * 2 <= Record.size() &&
5610 "Invalid data, not enough diag/map pairs");
5612 unsigned DiagID = Record[Idx++];
5615 if (!NewMapping.
isPragma() && !IncludeNonPragmaStates)
5628 Mapping = NewMapping;
5634 DiagState *FirstState;
5639 FirstState = Diag.DiagStatesByLoc.FirstDiagState;
5640 DiagStates.push_back(FirstState);
5643 assert(Record[1] == 0 &&
5644 "Invalid data, unexpected backref in initial state");
5645 Idx = 3 + Record[2] * 2;
5646 assert(Idx < Record.size() &&
5647 "Invalid data, not enough state change pairs in initial state");
5648 }
else if (F.isModule()) {
5652 unsigned Flags = Record[Idx++];
5654 Initial.SuppressSystemWarnings = Flags & 1; Flags >>= 1;
5655 Initial.ErrorsAsFatal = Flags & 1; Flags >>= 1;
5656 Initial.WarningsAsErrors = Flags & 1; Flags >>= 1;
5657 Initial.EnableAllWarnings = Flags & 1; Flags >>= 1;
5658 Initial.IgnoreAllWarnings = Flags & 1; Flags >>= 1;
5665 Diag.DiagStatesByLoc.Files[F.OriginalSourceFileID]
5666 .StateTransitions.push_back({FirstState, 0});
5671 FirstState = ReadDiagState(*Diag.DiagStatesByLoc.CurDiagState,
5676 unsigned NumLocations = Record[Idx++];
5677 while (NumLocations--) {
5678 assert(Idx < Record.size() &&
5679 "Invalid data, missing pragma diagnostic states");
5681 auto IDAndOffset =
SourceMgr.getDecomposedLoc(Loc);
5682 assert(IDAndOffset.second == 0 &&
"not a start location for a FileID");
5683 unsigned Transitions = Record[Idx++];
5689 auto &F = Diag.DiagStatesByLoc.Files[IDAndOffset.first];
5690 F.StateTransitions.reserve(F.StateTransitions.size() + Transitions);
5691 for (
unsigned I = 0; I != Transitions; ++
I) {
5692 unsigned Offset = Record[Idx++];
5694 ReadDiagState(*FirstState, Loc.getLocWithOffset(Offset),
false);
5695 F.StateTransitions.push_back({
State, Offset});
5700 assert(Idx < Record.size() &&
5701 "Invalid data, missing final pragma diagnostic state");
5703 ReadSourceLocation(F, F.PragmaDiagMappings[Idx++]);
5704 auto *CurState = ReadDiagState(*FirstState, CurStateLoc,
false);
5706 if (!F.isModule()) {
5707 Diag.DiagStatesByLoc.CurDiagState = CurState;
5708 Diag.DiagStatesByLoc.CurDiagStateLoc = CurStateLoc;
5712 auto &T = Diag.DiagStatesByLoc.Files[
FileID()].StateTransitions;
5714 T.push_back({CurState, 0});
5716 T[0].State = CurState;
5725 ASTReader::RecordLocation ASTReader::TypeCursorForIndex(
unsigned Index) {
5726 GlobalTypeMapType::iterator I = GlobalTypeMap.find(Index);
5727 assert(I != GlobalTypeMap.end() &&
"Corrupted global type map");
5729 return RecordLocation(M, M->TypeOffsets[Index - M->BaseTypeIndex]);
5738 QualType ASTReader::readTypeRecord(
unsigned Index) {
5739 assert(ContextObj &&
"reading type with no AST context");
5741 RecordLocation Loc = TypeCursorForIndex(Index);
5742 BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
5748 ReadingKindTracker ReadingKind(Read_Type, *
this);
5751 Deserializing AType(
this);
5754 DeclsCursor.JumpToBit(Loc.Offset);
5756 unsigned Code = DeclsCursor.ReadCode();
5757 switch ((
TypeCode)DeclsCursor.readRecord(Code, Record)) {
5759 if (Record.size() != 2) {
5760 Error(
"Incorrect encoding of extended qualifier type");
5769 if (Record.size() != 1) {
5770 Error(
"Incorrect encoding of complex type");
5773 QualType ElemType = readType(*Loc.F, Record, Idx);
5778 if (Record.size() != 1) {
5779 Error(
"Incorrect encoding of pointer type");
5782 QualType PointeeType = readType(*Loc.F, Record, Idx);
5787 if (Record.size() != 1) {
5788 Error(
"Incorrect encoding of decayed type");
5791 QualType OriginalType = readType(*Loc.F, Record, Idx);
5793 if (!isa<DecayedType>(DT))
5794 Error(
"Decayed type does not decay");
5799 if (Record.size() != 2) {
5800 Error(
"Incorrect encoding of adjusted type");
5803 QualType OriginalTy = readType(*Loc.F, Record, Idx);
5804 QualType AdjustedTy = readType(*Loc.F, Record, Idx);
5809 if (Record.size() != 1) {
5810 Error(
"Incorrect encoding of block pointer type");
5813 QualType PointeeType = readType(*Loc.F, Record, Idx);
5818 if (Record.size() != 2) {
5819 Error(
"Incorrect encoding of lvalue reference type");
5822 QualType PointeeType = readType(*Loc.F, Record, Idx);
5827 if (Record.size() != 1) {
5828 Error(
"Incorrect encoding of rvalue reference type");
5831 QualType PointeeType = readType(*Loc.F, Record, Idx);
5836 if (Record.size() != 2) {
5837 Error(
"Incorrect encoding of member pointer type");
5840 QualType PointeeType = readType(*Loc.F, Record, Idx);
5841 QualType ClassType = readType(*Loc.F, Record, Idx);
5849 QualType ElementType = readType(*Loc.F, Record, Idx);
5851 unsigned IndexTypeQuals = Record[2];
5853 llvm::APInt Size = ReadAPInt(Record, Idx);
5855 ASM, IndexTypeQuals);
5859 QualType ElementType = readType(*Loc.F, Record, Idx);
5861 unsigned IndexTypeQuals = Record[2];
5866 QualType ElementType = readType(*Loc.F, Record, Idx);
5868 unsigned IndexTypeQuals = Record[2];
5872 ASM, IndexTypeQuals,
5877 if (Record.size() != 3) {
5878 Error(
"incorrect encoding of vector type in AST file");
5882 QualType ElementType = readType(*Loc.F, Record, Idx);
5883 unsigned NumElements = Record[1];
5884 unsigned VecKind = Record[2];
5890 if (Record.size() != 3) {
5891 Error(
"incorrect encoding of extended vector type in AST file");
5895 QualType ElementType = readType(*Loc.F, Record, Idx);
5896 unsigned NumElements = Record[1];
5901 if (Record.size() != 7) {
5902 Error(
"incorrect encoding of no-proto function type");
5905 QualType ResultType = readType(*Loc.F, Record, Idx);
5912 QualType ResultType = readType(*Loc.F, Record, Idx);
5918 static_cast<CallingConv>(Record[4]),
5929 readExceptionSpec(*Loc.F, ExceptionStorage, EPI.
ExceptionSpec, Record, Idx);
5931 unsigned NumParams = Record[Idx++];
5933 for (
unsigned I = 0; I != NumParams; ++
I)
5934 ParamTypes.push_back(readType(*Loc.F, Record, Idx));
5937 if (Idx != Record.size()) {
5938 for (
unsigned I = 0; I != NumParams; ++
I)
5939 ExtParameterInfos.push_back(
5941 ::getFromOpaqueValue(Record[Idx++]));
5945 assert(Idx == Record.size());
5953 ReadDeclAs<UnresolvedUsingTypenameDecl>(*Loc.F, Record, Idx));
5957 if (Record.size() != 2) {
5958 Error(
"incorrect encoding of typedef type");
5963 QualType Canonical = readType(*Loc.F, Record, Idx);
5964 if (!Canonical.isNull())
5973 if (Record.size() != 1) {
5974 Error(
"incorrect encoding of typeof(type) in AST file");
5977 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
5982 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
5987 QualType BaseType = readType(*Loc.F, Record, Idx);
5988 QualType UnderlyingType = readType(*Loc.F, Record, Idx);
5994 QualType Deduced = readType(*Loc.F, Record, Idx);
5996 bool IsDependent = Deduced.
isNull() ? Record[Idx++] :
false;
5997 return Context.
getAutoType(Deduced, Keyword, IsDependent);
6001 TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx);
6002 QualType Deduced = readType(*Loc.F, Record, Idx);
6003 bool IsDependent = Deduced.
isNull() ? Record[Idx++] :
false;
6009 if (Record.size() != 2) {
6010 Error(
"incorrect encoding of record type");
6014 bool IsDependent = Record[Idx++];
6015 RecordDecl *RD = ReadDeclAs<RecordDecl>(*Loc.F, Record, Idx);
6016 RD = cast_or_null<RecordDecl>(RD->getCanonicalDecl());
6018 const_cast<Type*
>(T.getTypePtr())->setDependent(IsDependent);
6023 if (Record.size() != 2) {
6024 Error(
"incorrect encoding of enum type");
6028 bool IsDependent = Record[Idx++];
6030 = Context.
getEnumType(ReadDeclAs<EnumDecl>(*Loc.F, Record, Idx));
6031 const_cast<Type*
>(T.
getTypePtr())->setDependent(IsDependent);
6036 if (Record.size() != 3) {
6037 Error(
"incorrect encoding of attributed type");
6040 QualType modifiedType = readType(*Loc.F, Record, Idx);
6041 QualType equivalentType = readType(*Loc.F, Record, Idx);
6047 if (Record.size() != 1) {
6048 Error(
"incorrect encoding of paren type");
6051 QualType InnerType = readType(*Loc.F, Record, Idx);
6056 if (Record.size() != 2) {
6057 Error(
"incorrect encoding of pack expansion type");
6060 QualType Pattern = readType(*Loc.F, Record, Idx);
6065 NumExpansions = Record[1] - 1;
6073 QualType NamedType = readType(*Loc.F, Record, Idx);
6080 = ReadDeclAs<ObjCInterfaceDecl>(*Loc.F, Record, Idx);
6087 = ReadDeclAs<ObjCTypeParamDecl>(*Loc.F, Record, Idx);
6088 unsigned NumProtos = Record[Idx++];
6090 for (
unsigned I = 0; I != NumProtos; ++
I)
6091 Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
6096 QualType Base = readType(*Loc.F, Record, Idx);
6097 unsigned NumTypeArgs = Record[Idx++];
6099 for (
unsigned I = 0; I != NumTypeArgs; ++
I)
6100 TypeArgs.push_back(readType(*Loc.F, Record, Idx));
6101 unsigned NumProtos = Record[Idx++];
6103 for (
unsigned I = 0; I != NumProtos; ++
I)
6104 Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
6105 bool IsKindOf = Record[Idx++];
6111 QualType Pointee = readType(*Loc.F, Record, Idx);
6117 QualType Parm = readType(*Loc.F, Record, Idx);
6120 cast<TemplateTypeParmType>(Parm),
6126 QualType Parm = readType(*Loc.F, Record, Idx);
6129 cast<TemplateTypeParmType>(Parm),
6134 CXXRecordDecl *D = ReadDeclAs<CXXRecordDecl>(*Loc.F, Record, Idx);
6135 QualType TST = readType(*Loc.F, Record, Idx);
6138 const Type *T =
nullptr;
6140 if (
const Type *Existing = DI->getTypeForDecl()) {
6148 DI->setTypeForDecl(T);
6155 unsigned Depth = Record[Idx++];
6156 unsigned Index = Record[Idx++];
6157 bool Pack = Record[Idx++];
6159 = ReadDeclAs<TemplateTypeParmDecl>(*Loc.F, Record, Idx);
6167 const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx);
6168 QualType Canon = readType(*Loc.F, Record, Idx);
6178 const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx);
6179 unsigned NumArgs = Record[Idx++];
6181 Args.reserve(NumArgs);
6183 Args.push_back(ReadTemplateArgument(*Loc.F, Record, Idx));
6192 QualType ElementType = readType(*Loc.F, Record, Idx);
6195 unsigned IndexTypeQuals = Record[Idx++];
6198 Expr *NumElts = ReadExpr(*Loc.F);
6199 SourceRange Brackets = ReadSourceRange(*Loc.F, Record, Idx);
6202 IndexTypeQuals, Brackets);
6207 bool IsDependent = Record[Idx++];
6208 TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx);
6210 ReadTemplateArgumentList(Args, *Loc.F, Record, Idx);
6211 QualType Underlying = readType(*Loc.F, Record, Idx);
6217 const_cast<Type*
>(T.
getTypePtr())->setDependent(IsDependent);
6222 if (Record.size() != 1) {
6223 Error(
"Incorrect encoding of atomic type");
6226 QualType ValueType = readType(*Loc.F, Record, Idx);
6231 if (Record.size() != 2) {
6232 Error(
"Incorrect encoding of pipe type");
6237 QualType ElementType = readType(*Loc.F, Record, Idx);
6238 unsigned ReadOnly = Record[1];
6239 return Context.getPipeType(ElementType, ReadOnly);
6246 QualType ElementType = readType(*Loc.F, Record, Idx);
6247 Expr *SizeExpr = ReadExpr(*Loc.F);
6248 SourceLocation AttrLoc = ReadSourceLocation(*Loc.F, Record, Idx);
6254 llvm_unreachable(
"Invalid TypeCode!");
6260 const RecordData &Record,
unsigned &Idx) {
6265 for (
unsigned I = 0, N = Record[Idx++]; I != N; ++
I)
6266 Exceptions.push_back(readType(ModuleFile, Record, Idx));
6271 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6272 ESI.
SourceTemplate = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6274 ESI.
SourceDecl = ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
6285 return Reader->ReadSourceLocation(*F, Record, Idx);
6289 return Reader->GetTypeSourceInfo(*F, Record, Idx);
6293 return Reader->ReadNestedNameSpecifierLoc(*F, Record, Idx);
6299 : F(&F), Reader(&Reader), Record(Record), Idx(Idx) {}
6304 #define ABSTRACT_TYPELOC(CLASS, PARENT)
6305 #define TYPELOC(CLASS, PARENT) \
6306 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
6307 #include "clang/AST/TypeLocNodes.def"
6370 VisitArrayTypeLoc(TL);
6374 VisitArrayTypeLoc(TL);
6378 VisitArrayTypeLoc(TL);
6381 void TypeLocReader::VisitDependentSizedArrayTypeLoc(
6383 VisitArrayTypeLoc(TL);
6386 void TypeLocReader::VisitDependentSizedExtVectorTypeLoc(
6404 Reader->ReadSourceLocation(*F, Record, Idx)));
6406 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i) {
6412 VisitFunctionTypeLoc(TL);
6416 VisitFunctionTypeLoc(TL);
6446 void TypeLocReader::VisitAutoTypeLoc(
AutoTypeLoc TL) {
6450 void TypeLocReader::VisitDeducedTemplateSpecializationTypeLoc(
6459 void TypeLocReader::VisitEnumTypeLoc(
EnumTypeLoc TL) {
6464 TL.setAttrNameLoc(ReadSourceLocation());
6467 range.
setBegin(ReadSourceLocation());
6468 range.
setEnd(ReadSourceLocation());
6473 TL.setAttrExprOperand(Reader->ReadExpr(*F));
6475 TL.setAttrExprOperand(
nullptr);
6484 void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
6488 void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
6492 void TypeLocReader::VisitTemplateSpecializationTypeLoc(
6498 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
6501 Reader->GetTemplateArgumentLocInfo(
6504 void TypeLocReader::VisitParenTypeLoc(
ParenTypeLoc TL) {
6524 void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc(
6535 Reader->GetTemplateArgumentLocInfo(
6578 void TypeLocReader::VisitPipeTypeLoc(
PipeTypeLoc TL) {
6585 QualType InfoTy = readType(F, Record, Idx);
6589 TypeSourceInfo *TInfo = getContext().CreateTypeSourceInfo(InfoTy);
6597 assert(ContextObj &&
"reading type with no AST context");
6708 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
6709 case PREDEF_TYPE_##Id##_ID: \
6710 T = Context.SingletonId; \
6712 #include "clang/Basic/OpenCLImageTypes.def"
6749 assert(!T.
isNull() &&
"Unknown predefined type");
6754 assert(Index < TypesLoaded.size() &&
"Type index out-of-range");
6755 if (TypesLoaded[Index].isNull()) {
6756 TypesLoaded[Index] = readTypeRecord(Index);
6757 if (TypesLoaded[Index].isNull())
6760 TypesLoaded[Index]->setFromAST();
6761 if (DeserializationListener)
6763 TypesLoaded[Index]);
6766 return TypesLoaded[Index].withFastQualifiers(FastQuals);
6770 return GetType(getGlobalTypeID(F, LocalID));
6782 ReadModuleOffsetMap(F);
6786 assert(I != F.
TypeRemap.
end() &&
"Invalid index into type index remap");
6788 unsigned GlobalIndex = LocalIndex + I->second;
6789 return (GlobalIndex << Qualifiers::FastWidth) | FastQuals;
6801 return GetTypeSourceInfo(F, Record, Index);
6805 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
6812 SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
6813 SourceLocation EllipsisLoc = ReadSourceLocation(F, Record, Index);
6825 llvm_unreachable(
"unexpected template argument loc");
6834 if (Record[Index++])
6847 unsigned NumArgsAsWritten = Record[Index++];
6849 for (
unsigned i = 0; i != NumArgsAsWritten; ++i)
6850 TemplArgsInfo.
addArgument(ReadTemplateArgumentLoc(F, Record, Index));
6859 if (NumCurrentElementsDeserializing) {
6864 PendingIncompleteDeclChains.push_back(const_cast<Decl*>(D));
6875 if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC) ||
6876 isa<CXXRecordDecl>(DC) || isa<EnumDecl>(DC)) {
6878 if (!getContext().getLangOpts().
CPlusPlus &&
6879 isa<TranslationUnitDecl>(DC)) {
6883 auto *II = Name.getAsIdentifierInfo();
6884 assert(II &&
"non-identifier name in C?");
6885 if (II->isOutOfDate())
6886 updateOutOfDateIdentifier(*II);
6892 auto *DC = cast<DeclContext>(DCDecl);
6894 FindExternalLexicalDecls(
6900 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D))
6901 CTSD->getSpecializedTemplate()->LoadLazySpecializations();
6902 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D))
6903 VTSD->getSpecializedTemplate()->LoadLazySpecializations();
6904 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
6905 if (
auto *Template = FD->getPrimaryTemplate())
6906 Template->LoadLazySpecializations();
6912 RecordLocation Loc = getLocalBitOffset(Offset);
6913 BitstreamCursor &Cursor = Loc.F->DeclsCursor;
6915 Cursor.JumpToBit(Loc.Offset);
6916 ReadingKindTracker ReadingKind(Read_Decl, *
this);
6919 unsigned Code = Cursor.ReadCode();
6920 unsigned RecCode = Cursor.readRecord(Code, Record);
6922 Error(
"malformed AST file: missing C++ ctor initializers");
6927 return ReadCXXCtorInitializers(*Loc.F, Record, Idx);
6931 assert(ContextObj &&
"reading base specifiers with no AST context");
6934 RecordLocation Loc = getLocalBitOffset(Offset);
6935 BitstreamCursor &Cursor = Loc.F->DeclsCursor;
6937 Cursor.JumpToBit(Loc.Offset);
6938 ReadingKindTracker ReadingKind(Read_Decl, *
this);
6940 unsigned Code = Cursor.ReadCode();
6941 unsigned RecCode = Cursor.readRecord(Code, Record);
6943 Error(
"malformed AST file: missing C++ base specifiers");
6948 unsigned NumBases = Record[Idx++];
6951 for (
unsigned I = 0; I != NumBases; ++
I)
6952 Bases[I] = ReadCXXBaseSpecifier(*Loc.F, Record, Idx);
6962 ReadModuleOffsetMap(F);
6966 assert(I != F.
DeclRemap.
end() &&
"Invalid index into decl index remap");
6968 return LocalID + I->second;
6972 ModuleFile &M)
const {
6985 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
6995 if (Index > DeclsLoaded.size()) {
6996 Error(
"declaration ID out-of-range for AST file");
7000 if (Decl *D = DeclsLoaded[Index])
7004 DeclCursorForID(ID, Loc);
7061 llvm_unreachable(
"PredefinedDeclIDs unknown enum value");
7065 assert(ContextObj &&
"reading decl with no AST context");
7073 Merged.push_back(ID);
7080 if (Index >= DeclsLoaded.size()) {
7081 assert(0 &&
"declaration ID out-of-range for AST file");
7082 Error(
"declaration ID out-of-range for AST file");
7086 return DeclsLoaded[Index];
7091 return GetExistingDecl(ID);
7095 if (Index >= DeclsLoaded.size()) {
7096 assert(0 &&
"declaration ID out-of-range for AST file");
7097 Error(
"declaration ID out-of-range for AST file");
7101 if (!DeclsLoaded[Index]) {
7103 if (DeserializationListener)
7104 DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);
7107 return DeclsLoaded[Index];
7116 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
7117 ModuleFile *Owner = I->second;
7119 llvm::DenseMap<ModuleFile *, serialization::DeclID>::iterator Pos
7124 return GlobalID - Owner->BaseDeclID + Pos->second;
7130 if (Idx >= Record.size()) {
7131 Error(
"Corrupted AST file");
7135 return getGlobalDeclID(F, Record[Idx++]);
7145 ClearSwitchCaseIDs();
7148 RecordLocation Loc = getLocalBitOffset(Offset);
7149 Loc.F->DeclsCursor.JumpToBit(Loc.Offset);
7150 assert(NumCurrentElementsDeserializing == 0 &&
7151 "should not be called while already deserializing");
7153 return ReadStmtFromStream(*Loc.F);
7162 assert(LexicalDecls.size() % 2 == 0 &&
"expected an even number of entries");
7163 for (
int I = 0, N = LexicalDecls.size(); I != N; I += 2) {
7165 if (!IsKindWeWant(K))
7173 if (PredefsVisited[ID])
7176 PredefsVisited[
ID] =
true;
7179 if (Decl *D = GetLocalDecl(*M, ID)) {
7180 assert(D->
getKind() == K &&
"wrong kind for lexical decl");
7187 if (isa<TranslationUnitDecl>(DC)) {
7188 for (
auto Lexical : TULexicalDecls)
7189 Visit(Lexical.first, Lexical.second);
7191 auto I = LexicalDecls.find(DC);
7192 if (I != LexicalDecls.end())
7193 Visit(I->second.first, I->second.second);
7196 ++NumLexicalDeclContextsRead;
7206 DeclIDComp(
ASTReader &Reader, ModuleFile &M) : Reader(Reader), Mod(M) {}
7211 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
7216 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
7221 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
7225 return Reader.getSourceManager().getFileLoc(
7226 Reader.getSourceLocationForDeclID(Reader.getGlobalDeclID(Mod, ID)));
7233 unsigned Offset,
unsigned Length,
7237 llvm::DenseMap<FileID, FileDeclsInfo>::iterator I = FileDeclIDs.find(File);
7238 if (I == FileDeclIDs.end())
7241 FileDeclsInfo &DInfo = I->second;
7242 if (DInfo.Decls.empty())
7249 DeclIDComp DIDComp(*
this, *DInfo.Mod);
7251 BeginIt = std::lower_bound(DInfo.Decls.begin(), DInfo.Decls.end(),
7253 if (BeginIt != DInfo.Decls.begin())
7259 while (BeginIt != DInfo.Decls.begin() &&
7260 GetDecl(getGlobalDeclID(*DInfo.Mod, *BeginIt))
7261 ->isTopLevelDeclInObjCContainer())
7265 EndIt = std::upper_bound(DInfo.Decls.begin(), DInfo.Decls.end(),
7267 if (EndIt != DInfo.Decls.end())
7271 DIt = BeginIt; DIt != EndIt; ++DIt)
7272 Decls.push_back(GetDecl(getGlobalDeclID(*DInfo.Mod, *DIt)));
7279 "DeclContext has no visible decls in storage");
7283 auto It = Lookups.find(DC);
7284 if (It == Lookups.end())
7291 for (
DeclID ID : It->second.Table.find(Name)) {
7292 NamedDecl *ND = cast<NamedDecl>(GetDecl(ID));
7294 Decls.push_back(ND);
7297 ++NumVisibleDeclContextsRead;
7298 SetExternalVisibleDeclsForName(DC, Name, Decls);
7299 return !Decls.empty();
7306 auto It = Lookups.find(DC);
7307 assert(It != Lookups.end() &&
7308 "have external visible storage but no lookup tables");
7312 for (
DeclID ID : It->second.Table.findAll()) {
7313 NamedDecl *ND = cast<NamedDecl>(GetDecl(ID));
7317 ++NumVisibleDeclContextsRead;
7319 for (DeclsMap::iterator I = Decls.begin(), E = Decls.end(); I !=
E; ++
I) {
7320 SetExternalVisibleDeclsForName(DC, I->first, I->second);
7322 const_cast<DeclContext *
>(DC)->setHasExternalVisibleStorage(
false);
7327 auto I = Lookups.find(Primary);
7328 return I == Lookups.end() ?
nullptr : &I->second;
7337 assert(ImplD && Consumer);
7339 for (
auto *I : ImplD->
methods())
7345 void ASTReader::PassInterestingDeclToConsumer(Decl *D) {
7353 this->Consumer = Consumer;
7356 PassInterestingDeclsToConsumer();
7358 if (DeserializationListener)
7359 DeserializationListener->ReaderInitialized(
this);
7363 std::fprintf(stderr,
"*** AST File Statistics:\n");
7365 unsigned NumTypesLoaded
7366 = TypesLoaded.size() - std::count(TypesLoaded.begin(), TypesLoaded.end(),
7368 unsigned NumDeclsLoaded
7369 = DeclsLoaded.size() - std::count(DeclsLoaded.begin(), DeclsLoaded.end(),
7371 unsigned NumIdentifiersLoaded
7372 = IdentifiersLoaded.size() - std::count(IdentifiersLoaded.begin(),
7373 IdentifiersLoaded.end(),
7375 unsigned NumMacrosLoaded
7376 = MacrosLoaded.size() - std::count(MacrosLoaded.begin(),
7379 unsigned NumSelectorsLoaded
7380 = SelectorsLoaded.size() - std::count(SelectorsLoaded.begin(),
7381 SelectorsLoaded.end(),
7384 if (
unsigned TotalNumSLocEntries = getTotalNumSLocs())
7385 std::fprintf(stderr,
" %u/%u source location entries read (%f%%)\n",
7386 NumSLocEntriesRead, TotalNumSLocEntries,
7387 ((
float)NumSLocEntriesRead/TotalNumSLocEntries * 100));
7388 if (!TypesLoaded.empty())
7389 std::fprintf(stderr,
" %u/%u types read (%f%%)\n",
7390 NumTypesLoaded, (
unsigned)TypesLoaded.size(),
7391 ((float)NumTypesLoaded/TypesLoaded.size() * 100));
7392 if (!DeclsLoaded.empty())
7393 std::fprintf(stderr,
" %u/%u declarations read (%f%%)\n",
7394 NumDeclsLoaded, (
unsigned)DeclsLoaded.size(),
7395 ((float)NumDeclsLoaded/DeclsLoaded.size() * 100));
7396 if (!IdentifiersLoaded.empty())
7397 std::fprintf(stderr,
" %u/%u identifiers read (%f%%)\n",
7398 NumIdentifiersLoaded, (
unsigned)IdentifiersLoaded.size(),
7399 ((float)NumIdentifiersLoaded/IdentifiersLoaded.size() * 100));
7400 if (!MacrosLoaded.empty())
7401 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
7402 NumMacrosLoaded, (
unsigned)MacrosLoaded.size(),
7403 ((float)NumMacrosLoaded/MacrosLoaded.size() * 100));
7404 if (!SelectorsLoaded.empty())
7405 std::fprintf(stderr,
" %u/%u selectors read (%f%%)\n",
7406 NumSelectorsLoaded, (
unsigned)SelectorsLoaded.size(),
7407 ((float)NumSelectorsLoaded/SelectorsLoaded.size() * 100));
7408 if (TotalNumStatements)
7409 std::fprintf(stderr,
" %u/%u statements read (%f%%)\n",
7410 NumStatementsRead, TotalNumStatements,
7411 ((
float)NumStatementsRead/TotalNumStatements * 100));
7413 std::fprintf(stderr,
" %u/%u macros read (%f%%)\n",
7414 NumMacrosRead, TotalNumMacros,
7415 ((
float)NumMacrosRead/TotalNumMacros * 100));
7416 if (TotalLexicalDeclContexts)
7417 std::fprintf(stderr,
" %u/%u lexical declcontexts read (%f%%)\n",
7418 NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
7419 ((
float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts
7421 if (TotalVisibleDeclContexts)
7422 std::fprintf(stderr,
" %u/%u visible declcontexts read (%f%%)\n",
7423 NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
7424 ((
float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
7426 if (TotalNumMethodPoolEntries) {
7427 std::fprintf(stderr,
" %u/%u method pool entries read (%f%%)\n",
7428 NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
7429 ((
float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
7432 if (NumMethodPoolLookups) {
7433 std::fprintf(stderr,
" %u/%u method pool lookups succeeded (%f%%)\n",
7434 NumMethodPoolHits, NumMethodPoolLookups,
7435 ((
float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
7437 if (NumMethodPoolTableLookups) {
7438 std::fprintf(stderr,
" %u/%u method pool table lookups succeeded (%f%%)\n",
7439 NumMethodPoolTableHits, NumMethodPoolTableLookups,
7440 ((
float)NumMethodPoolTableHits/NumMethodPoolTableLookups
7444 if (NumIdentifierLookupHits) {
7445 std::fprintf(stderr,
7446 " %u / %u identifier table lookups succeeded (%f%%)\n",
7447 NumIdentifierLookupHits, NumIdentifierLookups,
7448 (
double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
7452 std::fprintf(stderr,
"\n");
7453 GlobalIndex->printStats();
7456 std::fprintf(stderr,
"\n");
7458 std::fprintf(stderr,
"\n");
7461 template<
typename Key,
typename ModuleFile,
unsigned InitialCapacity>
7462 LLVM_DUMP_METHOD
static void
7465 InitialCapacity> &
Map) {
7466 if (
Map.begin() ==
Map.end())
7470 llvm::errs() << Name <<
":\n";
7471 for (
typename MapType::const_iterator I =
Map.begin(), IEnd =
Map.end();
7473 llvm::errs() <<
" " << I->first <<
" -> " << I->second->FileName
7479 llvm::errs() <<
"*** PCH/ModuleFile Remappings:\n";
7481 dumpModuleIDMap(
"Global source location entry map", GlobalSLocEntryMap);
7489 GlobalPreprocessedEntityMap);
7491 llvm::errs() <<
"\n*** PCH/Modules Loaded:";
7492 for (ModuleFile &M : ModuleMgr)
7499 for (ModuleFile &I : ModuleMgr) {
7500 if (llvm::MemoryBuffer *buf = I.Buffer) {
7501 size_t bytes = buf->getBufferSize();
7502 switch (buf->getBufferKind()) {
7503 case llvm::MemoryBuffer::MemoryBuffer_Malloc:
7506 case llvm::MemoryBuffer::MemoryBuffer_MMap:
7520 for (uint64_t ID : PreloadedDeclIDs) {
7521 NamedDecl *D = cast<NamedDecl>(GetDecl(ID));
7524 PreloadedDeclIDs.clear();
7527 if (!FPPragmaOptions.empty()) {
7528 assert(FPPragmaOptions.size() == 1 &&
"Wrong number of FP_PRAGMA_OPTIONS");
7529 SemaObj->FPFeatures =
FPOptions(FPPragmaOptions[0]);
7532 SemaObj->OpenCLFeatures.copy(OpenCLExtensions);
7533 SemaObj->OpenCLTypeExtMap = OpenCLTypeExtMap;
7534 SemaObj->OpenCLDeclExtMap = OpenCLDeclExtMap;
7540 assert(SemaObj &&
"no Sema to update");
7544 if (!SemaDeclRefs.empty()) {
7545 assert(SemaDeclRefs.size() % 3 == 0);
7546 for (
unsigned I = 0; I != SemaDeclRefs.size(); I += 3) {
7547 if (!SemaObj->StdNamespace)
7548 SemaObj->StdNamespace = SemaDeclRefs[
I];
7549 if (!SemaObj->StdBadAlloc)
7550 SemaObj->StdBadAlloc = SemaDeclRefs[I+1];
7551 if (!SemaObj->StdAlignValT)
7552 SemaObj->StdAlignValT = SemaDeclRefs[I+2];
7554 SemaDeclRefs.clear();
7559 if(OptimizeOffPragmaLocation.isValid())
7560 SemaObj->ActOnPragmaOptimize(
false, OptimizeOffPragmaLocation);
7561 if (PragmaMSStructState != -1)
7563 if (PointersToMembersPragmaLocation.isValid()) {
7564 SemaObj->ActOnPragmaMSPointersToMembers(
7566 PragmaMSPointersToMembersState,
7567 PointersToMembersPragmaLocation);
7569 SemaObj->ForceCUDAHostDeviceDepth = ForceCUDAHostDeviceDepth;
7571 if (PragmaPackCurrentValue) {
7575 bool DropFirst =
false;
7576 if (!PragmaPackStack.empty() &&
7577 PragmaPackStack.front().Location.isInvalid()) {
7578 assert(PragmaPackStack.front().Value == SemaObj->PackStack.DefaultValue &&
7579 "Expected a default alignment value");
7580 SemaObj->PackStack.Stack.emplace_back(
7581 PragmaPackStack.front().SlotLabel, SemaObj->PackStack.CurrentValue,
7582 SemaObj->PackStack.CurrentPragmaLocation);
7585 for (
const auto &Entry :
7586 llvm::makeArrayRef(PragmaPackStack).drop_front(DropFirst ? 1 : 0))
7587 SemaObj->PackStack.Stack.emplace_back(Entry.SlotLabel, Entry.Value,
7589 if (PragmaPackCurrentLocation.isInvalid()) {
7590 assert(*PragmaPackCurrentValue == SemaObj->PackStack.DefaultValue &&
7591 "Expected a default alignment value");
7594 SemaObj->PackStack.CurrentValue = *PragmaPackCurrentValue;
7595 SemaObj->PackStack.CurrentPragmaLocation = PragmaPackCurrentLocation;
7604 IdentifierLookupVisitor Visitor(Name, 0,
7605 NumIdentifierLookups,
7606 NumIdentifierLookupHits);
7612 if (PP.getLangOpts().CPlusPlus) {
7613 for (
auto F : ModuleMgr.pch_modules())
7621 if (!loadGlobalIndex()) {
7622 if (GlobalIndex->lookupIdentifier(Name, Hits)) {
7627 ModuleMgr.visit(Visitor, HitsPtr);
7631 markIdentifierUpToDate(II);
7649 ASTIdentifierLookupTable::key_iterator
Current;
7653 ASTIdentifierLookupTable::key_iterator
End;
7660 bool SkipModules =
false);
7662 StringRef
Next()
override;
7669 : Reader(Reader), Index(Reader.ModuleMgr.size()), SkipModules(SkipModules) {
7673 while (Current == End) {
7679 ModuleFile &F = Reader.ModuleMgr[Index];
7680 if (SkipModules && F.isModule())
7685 Current = IdTable->key_begin();
7686 End = IdTable->key_end();
7691 StringRef Result = *Current;
7700 std::unique_ptr<IdentifierIterator>
Current;
7701 std::unique_ptr<IdentifierIterator> Queued;
7704 ChainedIdentifierIterator(std::unique_ptr<IdentifierIterator> First,
7705 std::unique_ptr<IdentifierIterator> Second)
7706 :
Current(std::move(First)), Queued(std::move(Second)) {}
7708 StringRef
Next()
override {
7712 StringRef result =
Current->Next();
7713 if (!result.empty())
7727 std::unique_ptr<IdentifierIterator> ReaderIter(
7729 std::unique_ptr<IdentifierIterator> ModulesIter(
7730 GlobalIndex->createIdentifierIterator());
7731 return new ChainedIdentifierIterator(std::move(ReaderIter),
7732 std::move(ModulesIter));
7739 namespace serialization {
7744 unsigned PriorGeneration;
7745 unsigned InstanceBits;
7746 unsigned FactoryBits;
7747 bool InstanceHasMoreThanOneDecl;
7748 bool FactoryHasMoreThanOneDecl;
7754 unsigned PriorGeneration)
7755 : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration),
7756 InstanceBits(0), FactoryBits(0), InstanceHasMoreThanOneDecl(
false),
7757 FactoryHasMoreThanOneDecl(
false) {}
7767 ++Reader.NumMethodPoolTableLookups;
7770 ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel);
7771 if (Pos == PoolTable->end())
7774 ++Reader.NumMethodPoolTableHits;
7775 ++Reader.NumSelectorsRead;
7779 ++Reader.NumMethodPoolEntriesRead;
7781 if (Reader.DeserializationListener)
7795 return InstanceMethods;
7800 return FactoryMethods;
7806 return InstanceHasMoreThanOneDecl;
7817 for (
unsigned I = 0, N = Methods.size(); I != N; ++
I) {
7824 unsigned &Generation = SelectorGeneration[Sel];
7825 unsigned PriorGeneration = Generation;
7827 SelectorOutOfDate[Sel] =
false;
7830 ++NumMethodPoolLookups;
7832 ModuleMgr.
visit(Visitor);
7838 ++NumMethodPoolHits;
7844 Sema::GlobalMethodPool::iterator Pos
7860 if (SelectorOutOfDate[Sel])
7868 for (
unsigned I = 0, N = KnownNamespaces.size(); I != N; ++
I) {
7870 = dyn_cast_or_null<NamespaceDecl>(
GetDecl(KnownNamespaces[I])))
7871 Namespaces.push_back(Namespace);
7876 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
7877 for (
unsigned Idx = 0, N = UndefinedButUsed.size(); Idx != N;) {
7881 Undefined.insert(std::make_pair(D, Loc));
7888 for (
unsigned Idx = 0, N = DelayedDeleteExprs.size(); Idx != N;) {
7890 uint64_t Count = DelayedDeleteExprs[Idx++];
7891 for (uint64_t C = 0; C < Count; ++C) {
7894 const bool IsArrayForm = DelayedDeleteExprs[Idx++];
7895 Exprs[FD].push_back(std::make_pair(DeleteLoc, IsArrayForm));
7902 for (
unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++
I) {
7903 VarDecl *Var = dyn_cast_or_null<VarDecl>(
GetDecl(TentativeDefinitions[I]));
7905 TentativeDefs.push_back(Var);
7907 TentativeDefinitions.clear();
7912 for (
unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++
I) {
7914 = dyn_cast_or_null<DeclaratorDecl>(
GetDecl(UnusedFileScopedDecls[I]));
7918 UnusedFileScopedDecls.clear();
7923 for (
unsigned I = 0, N = DelegatingCtorDecls.size(); I != N; ++
I) {
7925 = dyn_cast_or_null<CXXConstructorDecl>(
GetDecl(DelegatingCtorDecls[I]));
7929 DelegatingCtorDecls.clear();
7933 for (
unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++
I) {
7935 = dyn_cast_or_null<TypedefNameDecl>(
GetDecl(ExtVectorDecls[I]));
7939 ExtVectorDecls.clear();
7944 for (
unsigned I = 0, N = UnusedLocalTypedefNameCandidates.size(); I != N;
7947 GetDecl(UnusedLocalTypedefNameCandidates[I]));
7951 UnusedLocalTypedefNameCandidates.clear();
7956 if (ReferencedSelectorsData.empty())
7961 unsigned int DataSize = ReferencedSelectorsData.size()-1;
7963 while (I < DataSize) {
7967 Sels.push_back(std::make_pair(Sel, SelLoc));
7969 ReferencedSelectorsData.clear();
7974 if (WeakUndeclaredIdentifiers.empty())
7977 for (
unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; ) {
7984 bool Used = WeakUndeclaredIdentifiers[I++];
7987 WeakIDs.push_back(std::make_pair(WeakId, WI));
7989 WeakUndeclaredIdentifiers.clear();
7993 for (
unsigned Idx = 0, N = VTableUses.size(); Idx < N; ) {
7995 VT.
Record = dyn_cast_or_null<CXXRecordDecl>(
GetDecl(VTableUses[Idx++]));
7998 VTables.push_back(VT);
8006 for (
unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
8011 Pending.push_back(std::make_pair(D, Loc));
8013 PendingInstantiations.clear();
8017 llvm::MapVector<
const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
8019 for (
unsigned Idx = 0, N = LateParsedTemplates.size(); Idx < N;
8023 auto LT = llvm::make_unique<LateParsedTemplate>();
8024 LT->D =
GetDecl(LateParsedTemplates[Idx++]);
8027 assert(F &&
"No module");
8029 unsigned TokN = LateParsedTemplates[Idx++];
8030 LT->Toks.reserve(TokN);
8031 for (
unsigned T = 0; T < TokN; ++T)
8032 LT->Toks.push_back(
ReadToken(*F, LateParsedTemplates, Idx));
8034 LPTMap.insert(std::make_pair(FD, std::move(LT)));
8037 LateParsedTemplates.clear();
8046 assert(ID &&
"Non-zero identifier ID required");
8047 assert(ID <= IdentifiersLoaded.size() &&
"identifier ID out of range");
8048 IdentifiersLoaded[ID - 1] = II;
8049 if (DeserializationListener)
8073 if (NumCurrentElementsDeserializing && !Decls) {
8074 PendingIdentifierInfos[II].append(DeclIDs.begin(), DeclIDs.end());
8078 for (
unsigned I = 0, N = DeclIDs.size(); I != N; ++
I) {
8091 Decls->push_back(D);
8098 pushExternalDeclIntoScope(D, II);
8106 if (IdentifiersLoaded.empty()) {
8107 Error(
"no identifier table in AST file");
8112 if (!IdentifiersLoaded[ID]) {
8114 assert(I != GlobalIdentifierMap.
end() &&
"Corrupted global identifier map");
8115 ModuleFile *M = I->second;
8116 unsigned Index = ID - M->BaseIdentifierID;
8117 const char *Str = M->IdentifierTableData + M->IdentifierOffsets[Index];
8124 const unsigned char *StrLenPtr = (
const unsigned char*) Str - 2;
8125 unsigned StrLen = (((
unsigned) StrLenPtr[0])
8126 | (((
unsigned) StrLenPtr[1]) << 8)) - 1;
8128 IdentifiersLoaded[
ID] = &II;
8130 if (DeserializationListener)
8134 return IdentifiersLoaded[
ID];
8146 ReadModuleOffsetMap(M);
8151 &&
"Invalid index into identifier index remap");
8153 return LocalID + I->second;
8160 if (MacrosLoaded.empty()) {
8161 Error(
"no macro table in AST file");
8166 if (!MacrosLoaded[ID]) {
8169 assert(I != GlobalMacroMap.
end() &&
"Corrupted global macro map");
8170 ModuleFile *M = I->second;
8171 unsigned Index = ID - M->BaseMacroID;
8174 if (DeserializationListener)
8179 return MacrosLoaded[
ID];
8187 ReadModuleOffsetMap(M);
8191 assert(I != M.
MacroRemap.
end() &&
"Invalid index into macro index remap");
8193 return LocalID + I->second;
8198 if (LocalID < NUM_PREDEF_SUBMODULE_IDS)
8202 ReadModuleOffsetMap(M);
8207 &&
"Invalid index into submodule index remap");
8209 return LocalID + I->second;
8213 if (GlobalID < NUM_PREDEF_SUBMODULE_IDS) {
8214 assert(GlobalID == 0 &&
"Unhandled global submodule ID");
8218 if (GlobalID > SubmodulesLoaded.size()) {
8219 Error(
"submodule ID out of range in AST file");
8234 return I == GlobalSubmoduleMap.
end() ?
nullptr : I->second;
8237 unsigned IndexFromEnd = ID >> 1;
8238 assert(IndexFromEnd &&
"got reference to unknown module file");
8255 auto I = std::find(PCHModules.begin(), PCHModules.end(), F);
8256 assert(I != PCHModules.end() &&
"emitting reference to unknown file");
8257 return (I - PCHModules.end()) << 1;
8268 if (
std::distance(std::begin(PCHChain), std::end(PCHChain))) {
8271 StringRef FileName = llvm::sys::path::filename(MF.
FileName);
8279 auto I = BodySource.find(FD);
8280 if (I == BodySource.end())
8293 if (ID > SelectorsLoaded.size()) {
8294 Error(
"selector ID out of range in AST file");
8298 if (SelectorsLoaded[ID - 1].getAsOpaquePtr() ==
nullptr) {
8301 assert(I != GlobalSelectorMap.
end() &&
"Corrupted global selector map");
8302 ModuleFile &M = *I->second;
8305 SelectorsLoaded[ID - 1] =
8306 Trait.
ReadKey(M.SelectorLookupTableData + M.SelectorOffsets[Idx], 0);
8307 if (DeserializationListener)
8308 DeserializationListener->
SelectorRead(ID, SelectorsLoaded[ID - 1]);
8311 return SelectorsLoaded[ID - 1];
8329 ReadModuleOffsetMap(M);
8334 &&
"Invalid index into selector index remap");
8336 return LocalID + I->second;
8363 ReadDeclAs<TemplateDecl>(F, Record, Idx));
8381 llvm_unreachable(
"Invalid NameKind!");
8430 unsigned NumTPLists = Record[Idx++];
8435 for (
unsigned i = 0; i != NumTPLists; ++i)
8447 return TemplateName(ReadDeclAs<TemplateDecl>(F, Record, Idx));
8450 unsigned size = Record[Idx++];
8453 Decls.
addDecl(ReadDeclAs<NamedDecl>(F, Record, Idx));
8460 bool hasTemplKeyword = Record[Idx++];
8461 TemplateDecl *Template = ReadDeclAs<TemplateDecl>(F, Record, Idx);
8477 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
8485 = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
8497 llvm_unreachable(
"Unhandled template name kind!");
8503 bool Canonicalize) {
8521 ValueDecl *D = ReadDeclAs<ValueDecl>(F, Record, Idx);
8536 if (
unsigned NumExpansions = Record[Idx++])
8537 NumTemplateExpansions = NumExpansions - 1;
8543 unsigned NumArgs = Record[Idx++];
8545 for (
unsigned I = 0; I != NumArgs; ++
I)
8551 llvm_unreachable(
"Unhandled template argument kind!");
8561 unsigned NumParams = Record[Idx++];
8563 Params.reserve(NumParams);
8565 Params.push_back(ReadDeclAs<NamedDecl>(F, Record, Idx));
8569 getContext(), TemplateLoc, LAngleLoc, Params, RAngleLoc,
nullptr);
8570 return TemplateParams;
8577 unsigned &Idx,
bool Canonicalize) {
8578 unsigned NumTemplateArgs = Record[Idx++];
8579 TemplArgs.reserve(NumTemplateArgs);
8580 while (NumTemplateArgs--)
8587 unsigned NumDecls = Record[Idx++];
8589 while (NumDecls--) {
8599 bool isVirtual =
static_cast<bool>(Record[Idx++]);
8600 bool isBaseOfClass =
static_cast<bool>(Record[Idx++]);
8602 bool inheritConstructors =
static_cast<bool>(Record[Idx++]);
8616 unsigned NumInitializers = Record[Idx++];
8617 assert(NumInitializers &&
"wrote ctor initializers but have no inits");
8619 for (
unsigned i = 0; i != NumInitializers; ++i) {
8621 bool IsBaseVirtual =
false;
8629 IsBaseVirtual = Record[Idx++];
8637 Member = ReadDeclAs<FieldDecl>(F, Record, Idx);
8641 IndirectMember = ReadDeclAs<IndirectFieldDecl>(F, Record, Idx);
8654 RParenLoc, MemberOrEllipsisLoc);
8665 LParenLoc, Init, RParenLoc);
8667 if (Record[Idx++]) {
8668 unsigned SourceOrder = Record[Idx++];
8672 CtorInitializers[i] = BOMInit;
8675 return CtorInitializers;
8682 unsigned N = Record[Idx++];
8684 for (
unsigned I = 0; I != N; ++
I) {
8695 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
8712 bool Template = Record[Idx++];
8724 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
8738 unsigned N = Record[Idx++];
8740 for (
unsigned I = 0; I != N; ++
I) {
8752 NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx);
8754 Builder.
Extend(Context, NS, Range.getBegin(), Range.getEnd());
8761 Builder.
Extend(Context, Alias, Range.getBegin(), Range.getEnd());
8767 bool Template = Record[Idx++];
8787 CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
8789 Builder.
MakeSuper(Context, RD, Range.getBegin(), Range.getEnd());
8808 unsigned BitWidth = Record[Idx++];
8809 unsigned NumWords = llvm::APInt::getNumWords(BitWidth);
8810 llvm::APInt
Result(BitWidth, NumWords, &Record[Idx]);
8817 bool isUnsigned = Record[Idx++];
8818 return llvm::APSInt(
ReadAPInt(Record, Idx), isUnsigned);
8823 const llvm::fltSemantics &Sem,
8825 return llvm::APFloat(Sem,
ReadAPInt(Record, Idx));
8830 unsigned Len = Record[Idx++];
8831 std::string
Result(Record.data() + Idx, Record.data() + Idx + Len);
8838 std::string Filename =
ReadString(Record, Idx);
8845 unsigned Major = Record[Idx++];
8846 unsigned Minor = Record[Idx++];
8847 unsigned Subminor = Record[Idx++];
8863 return Diag(CurrentImportLoc, DiagID);
8867 return Diags.
Report(Loc, DiagID);
8879 assert((*CurrSwitchCaseStmts)[ID] ==
nullptr &&
8880 "Already have a SwitchCase with this ID");
8881 (*CurrSwitchCaseStmts)[
ID] = SC;
8886 assert((*CurrSwitchCaseStmts)[ID] !=
nullptr &&
"No SwitchCase with this ID");
8887 return (*CurrSwitchCaseStmts)[
ID];
8891 CurrSwitchCaseStmts->clear();
8896 std::vector<RawComment *> Comments;
8903 BitstreamCursor &Cursor = I->first;
8909 llvm::BitstreamEntry Entry =
8910 Cursor.advanceSkippingSubblocks(BitstreamCursor::AF_DontPopBlockAtEnd);
8912 switch (Entry.Kind) {
8913 case llvm::BitstreamEntry::SubBlock:
8915 Error(
"malformed block record in AST file");
8917 case llvm::BitstreamEntry::EndBlock:
8919 case llvm::BitstreamEntry::Record:
8932 bool IsTrailingComment = Record[Idx++];
8933 bool IsAlmostTrailingComment = Record[Idx++];
8935 SR, Kind, IsTrailingComment, IsAlmostTrailingComment,
8944 std::sort(Comments.begin(), Comments.end(),
8946 Context.
Comments.addDeserializedComments(Comments);
8951 bool IncludeSystem,
bool Complain,
8956 assert(NumUserInputs <= NumInputs);
8957 unsigned N = IncludeSystem ? NumInputs : NumUserInputs;
8958 for (
unsigned I = 0; I < N; ++
I) {
8959 bool IsSystem = I >= NumUserInputs;
8960 InputFile IF = getInputFile(MF, I+1, Complain);
8961 Visitor(IF, IsSystem);
8967 llvm::function_ref<
void(
const FileEntry *FE)> Visitor) {
8969 for (
unsigned I = 0; I < NumInputs; ++
I) {
8970 InputFileInfo IFI = readInputFileInfo(MF, I + 1);
8971 if (IFI.TopLevelModuleMap)
8973 if (
auto *FE = getInputFile(MF, I + 1).getFile())
8981 return M->getFullModuleName();
8991 void ASTReader::finishPendingActions() {
8992 while (!PendingIdentifierInfos.empty() ||
8993 !PendingIncompleteDeclChains.empty() || !PendingDeclChains.empty() ||
8994 !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
8995 !PendingUpdateRecords.empty()) {
8998 typedef llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2> >
9000 TopLevelDeclsMap TopLevelDecls;
9002 while (!PendingIdentifierInfos.empty()) {
9005 std::move(PendingIdentifierInfos.back().second);
9006 PendingIdentifierInfos.pop_back();
9013 for (
unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++
I) {
9014 markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
9016 PendingIncompleteDeclChains.clear();
9019 for (
unsigned I = 0; I != PendingDeclChains.size(); ++
I)
9020 loadPendingDeclChain(PendingDeclChains[I].first, PendingDeclChains[I].second);
9021 PendingDeclChains.clear();
9024 for (TopLevelDeclsMap::iterator TLD = TopLevelDecls.begin(),
9025 TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) {
9027 for (
unsigned I = 0, N = TLD->second.size(); I != N; ++
I) {
9028 pushExternalDeclIntoScope(cast<NamedDecl>(TLD->second[I]), II);
9033 for (
unsigned I = 0; I != PendingMacroIDs.size(); ++
I) {
9036 GlobalIDs.swap(PendingMacroIDs.begin()[
I].second);
9038 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9040 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9041 if (!Info.M->isModule())
9045 for (
unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9047 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9048 if (Info.M->isModule())
9052 PendingMacroIDs.clear();
9056 while (!PendingDeclContextInfos.empty()) {
9057 PendingDeclContextInfo Info = PendingDeclContextInfos.front();
9058 PendingDeclContextInfos.pop_front();
9061 Info.D->setDeclContextsImpl(SemaDC, LexicalDC,
getContext());
9065 while (!PendingUpdateRecords.empty()) {
9066 auto Update = PendingUpdateRecords.pop_back_val();
9067 ReadingKindTracker ReadingKind(Read_Decl, *
this);
9068 loadDeclUpdateRecords(Update);
9074 assert(PendingFakeDefinitionData.empty() &&
9075 "faked up a class definition but never saw the real one");
9081 for (Decl *D : PendingDefinitions) {
9082 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
9083 if (
const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) {
9088 if (
auto RD = dyn_cast<CXXRecordDecl>(D)) {
9089 for (
auto *R = getMostRecentExistingDecl(RD); R;
9092 cast<CXXRecordDecl>(R)->isThisDeclarationADefinition() &&
9093 "declaration thinks it's the definition but it isn't");
9094 cast<CXXRecordDecl>(R)->DefinitionData = RD->DefinitionData;
9101 if (
auto ID = dyn_cast<ObjCInterfaceDecl>(D)) {
9106 for (
auto *R = getMostRecentExistingDecl(ID); R; R = R->
getPreviousDecl())
9107 cast<ObjCInterfaceDecl>(R)->Data = ID->Data;
9112 if (
auto PD = dyn_cast<ObjCProtocolDecl>(D)) {
9113 for (
auto *R = getMostRecentExistingDecl(PD); R; R = R->
getPreviousDecl())
9114 cast<ObjCProtocolDecl>(R)->Data = PD->Data;
9120 for (
auto *R = getMostRecentExistingDecl(RTD); R; R = R->
getPreviousDecl())
9121 cast<RedeclarableTemplateDecl>(R)->Common = RTD->Common;
9123 PendingDefinitions.clear();
9129 for (PendingBodiesMap::iterator PB = PendingBodies.begin(),
9130 PBEnd = PendingBodies.end();
9131 PB != PBEnd; ++PB) {
9132 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
9147 PendingBodies.clear();
9150 for (
auto *ND : PendingMergedDefinitionsToDeduplicate)
9152 PendingMergedDefinitionsToDeduplicate.clear();
9155 void ASTReader::diagnoseOdrViolations() {
9156 if (PendingOdrMergeFailures.empty() && PendingOdrMergeChecks.empty())
9163 auto OdrMergeFailures = std::move(PendingOdrMergeFailures);
9164 PendingOdrMergeFailures.clear();
9165 for (
auto &Merge : OdrMergeFailures) {
9166 Merge.first->buildLookup();
9167 Merge.first->decls_begin();
9168 Merge.first->bases_begin();
9169 Merge.first->vbases_begin();
9170 for (
auto *RD : Merge.second) {
9183 while (!PendingOdrMergeChecks.empty()) {
9184 NamedDecl *D = PendingOdrMergeChecks.pop_back_val();
9198 for (
auto RI : D->
redecls()) {
9199 if (RI->getLexicalDeclContext() == CanonDef) {
9214 for (
auto *CanonMember : CanonDef->
decls()) {
9215 if (CanonMember->getCanonicalDecl() == DCanon) {
9224 if (
auto *ND = dyn_cast<NamedDecl>(CanonMember))
9226 Candidates.push_back(ND);
9232 if (!isa<TagDecl>(D))
9237 Deserializing RecursionGuard(
this);
9239 std::string CanonDefModule =
9243 << CanonDef << CanonDefModule.empty() << CanonDefModule;
9245 if (Candidates.empty())
9246 Diag(cast<Decl>(CanonDef)->getLocation(),
9247 diag::note_module_odr_violation_no_possible_decls) << D;
9249 for (
unsigned I = 0, N = Candidates.size(); I != N; ++
I)
9250 Diag(Candidates[I]->getLocation(),
9251 diag::note_module_odr_violation_possible_decl)
9255 DiagnosedOdrMergeFailures.insert(CanonDef);
9259 if (OdrMergeFailures.empty())
9264 Deserializing RecursionGuard(
this);
9267 for (
auto &Merge : OdrMergeFailures) {
9270 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
9273 bool Diagnosed =
false;
9279 if (FirstRecord == SecondRecord)
9284 DeclHashes FirstHashes;
9285 DeclHashes SecondHashes;
9288 auto PopulateHashes = [&Hash, FirstRecord](DeclHashes &Hashes,
9290 for (
auto *D : Record->decls()) {
9300 PopulateHashes(FirstHashes, FirstRecord);
9301 PopulateHashes(SecondHashes, SecondRecord);
9319 } FirstDiffType = Other,
9320 SecondDiffType = Other;
9322 auto DifferenceSelector = [](Decl *D) {
9323 assert(D &&
"valid Decl required");
9327 case Decl::AccessSpec:
9330 return PublicSpecifer;
9332 return PrivateSpecifer;
9334 return ProtectedSpecifer;
9338 llvm_unreachable(
"Invalid access specifier");
9339 case Decl::StaticAssert:
9340 return StaticAssert;
9343 case Decl::CXXMethod:
9344 case Decl::CXXConstructor:
9345 case Decl::CXXDestructor:
9347 case Decl::TypeAlias:
9358 Decl *FirstDecl =
nullptr;
9359 Decl *SecondDecl =
nullptr;
9360 auto FirstIt = FirstHashes.begin();
9361 auto SecondIt = SecondHashes.begin();
9366 while (FirstIt != FirstHashes.end() || SecondIt != SecondHashes.end()) {
9367 if (FirstIt != FirstHashes.end() && SecondIt != SecondHashes.end() &&
9368 FirstIt->second == SecondIt->second) {
9374 FirstDecl = FirstIt == FirstHashes.end() ?
nullptr : FirstIt->first;
9375 SecondDecl = SecondIt == SecondHashes.end() ?
nullptr : SecondIt->first;
9377 FirstDiffType = FirstDecl ? DifferenceSelector(FirstDecl) : EndOfClass;
9379 SecondDecl ? DifferenceSelector(SecondDecl) : EndOfClass;
9384 if (FirstDiffType == Other || SecondDiffType == Other) {
9389 diag::err_module_odr_violation_different_definitions)
9390 << FirstRecord << FirstModule.empty() << FirstModule;
9398 diag::note_module_odr_violation_different_definitions)
9410 if (FirstDiffType != SecondDiffType) {
9413 if (FirstDiffType == EndOfClass) {
9416 FirstLoc = FirstIt->first->getLocation();
9417 FirstRange = FirstIt->first->getSourceRange();
9419 Diag(FirstLoc, diag::err_module_odr_violation_mismatch_decl)
9420 << FirstRecord << FirstModule.empty() << FirstModule << FirstRange
9425 if (SecondDiffType == EndOfClass) {
9431 Diag(SecondLoc, diag::note_module_odr_violation_mismatch_decl)
9432 << SecondModule << SecondRange << SecondDiffType;
9437 assert(FirstDiffType == SecondDiffType);
9441 enum ODRDeclDifference{
9442 StaticAssertCondition,
9443 StaticAssertMessage,
9444 StaticAssertOnlyMessage,
9447 FieldSingleBitField,
9448 FieldDifferentWidthBitField,
9450 FieldSingleInitializer,
9451 FieldDifferentInitializers,
9459 MethodNumberParameters,
9460 MethodParameterType,
9461 MethodParameterName,
9462 MethodParameterSingleDefaultArgument,
9463 MethodParameterDifferentDefaultArgument,
9468 VarSingleInitializer,
9469 VarDifferentInitializer,
9479 auto ODRDiagError = [FirstRecord, &FirstModule,
this](
9481 return Diag(Loc, diag::err_module_odr_violation_mismatch_decl_diff)
9482 << FirstRecord << FirstModule.empty() << FirstModule << Range
9485 auto ODRDiagNote = [&SecondModule,
this](
9487 return Diag(Loc, diag::note_module_odr_violation_mismatch_decl_diff)
9488 << SecondModule << Range << DiffType;
9491 auto ComputeODRHash = [&Hash](
const Stmt*
S) {
9498 auto ComputeQualTypeODRHash = [&Hash](
QualType Ty) {
9504 switch (FirstDiffType) {
9507 case PublicSpecifer:
9508 case PrivateSpecifer:
9509 case ProtectedSpecifer:
9510 llvm_unreachable(
"Invalid diff type");
9512 case StaticAssert: {
9517 Expr *SecondExpr = SecondSA->getAssertExpr();
9518 unsigned FirstODRHash = ComputeODRHash(FirstExpr);
9519 unsigned SecondODRHash = ComputeODRHash(SecondExpr);
9520 if (FirstODRHash != SecondODRHash) {
9521 ODRDiagError(FirstExpr->getLocStart(), FirstExpr->getSourceRange(),
9522 StaticAssertCondition);
9531 assert((FirstStr || SecondStr) &&
"Both messages cannot be empty");
9532 if ((FirstStr && !SecondStr) || (!FirstStr && SecondStr)) {
9546 SecondLoc = SecondSA->getLocStart();
9547 SecondRange = SecondSA->getSourceRange();
9549 ODRDiagError(FirstLoc, FirstRange, StaticAssertOnlyMessage)
9550 << (FirstStr ==
nullptr);
9551 ODRDiagNote(SecondLoc, SecondRange, StaticAssertOnlyMessage)
9552 << (SecondStr ==
nullptr);
9557 if (FirstStr && SecondStr &&
9560 StaticAssertMessage);
9562 StaticAssertMessage);
9569 FieldDecl *FirstField = cast<FieldDecl>(FirstDecl);
9570 FieldDecl *SecondField = cast<FieldDecl>(SecondDecl);
9573 if (FirstII->getName() != SecondII->
getName()) {
9577 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
9586 SecondField->getType()));
9589 QualType SecondType = SecondField->getType();
9590 if (ComputeQualTypeODRHash(FirstType) !=
9591 ComputeQualTypeODRHash(SecondType)) {
9594 << FirstII << FirstType;
9595 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
9597 << SecondII << SecondType;
9603 const bool IsFirstBitField = FirstField->
isBitField();
9604 const bool IsSecondBitField = SecondField->isBitField();
9605 if (IsFirstBitField != IsSecondBitField) {
9607 FieldSingleBitField)
9608 << FirstII << IsFirstBitField;
9609 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
9610 FieldSingleBitField)
9611 << SecondII << IsSecondBitField;
9616 if (IsFirstBitField && IsSecondBitField) {
9618 FieldDifferentWidthBitField)
9620 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
9621 FieldDifferentWidthBitField)
9622 << SecondII << SecondField->getBitWidth()->getSourceRange();
9627 const bool IsFirstMutable = FirstField->
isMutable();
9628 const bool IsSecondMutable = SecondField->isMutable();
9629 if (IsFirstMutable != IsSecondMutable) {
9632 << FirstII << IsFirstMutable;
9633 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
9635 << SecondII << IsSecondMutable;
9641 const Expr *SecondInitializer = SecondField->getInClassInitializer();
9642 if ((!FirstInitializer && SecondInitializer) ||
9643 (FirstInitializer && !SecondInitializer)) {
9645 FieldSingleInitializer)
9646 << FirstII << (FirstInitializer !=
nullptr);
9647 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
9648 FieldSingleInitializer)
9649 << SecondII << (SecondInitializer !=
nullptr);
9654 if (FirstInitializer && SecondInitializer) {
9655 unsigned FirstInitHash = ComputeODRHash(FirstInitializer);
9656 unsigned SecondInitHash = ComputeODRHash(SecondInitializer);
9657 if (FirstInitHash != SecondInitHash) {
9660 FieldDifferentInitializers)
9662 ODRDiagNote(SecondField->getLocation(),
9663 SecondField->getSourceRange(),
9664 FieldDifferentInitializers)
9680 auto GetMethodTypeForDiagnostics = [](
const CXXMethodDecl* D) {
9681 if (isa<CXXConstructorDecl>(D))
return DiagConstructor;
9682 if (isa<CXXDestructorDecl>(D))
return DiagDestructor;
9685 const CXXMethodDecl *FirstMethod = cast<CXXMethodDecl>(FirstDecl);
9686 const CXXMethodDecl *SecondMethod = cast<CXXMethodDecl>(SecondDecl);
9687 FirstMethodType = GetMethodTypeForDiagnostics(FirstMethod);
9688 SecondMethodType = GetMethodTypeForDiagnostics(SecondMethod);
9690 auto SecondName = SecondMethod->getDeclName();
9691 if (FirstMethodType != SecondMethodType || FirstName != SecondName) {
9694 << FirstMethodType << FirstName;
9695 ODRDiagNote(SecondMethod->getLocation(),
9696 SecondMethod->getSourceRange(), MethodName)
9697 << SecondMethodType << SecondName;
9703 const bool FirstDeleted = FirstMethod->
isDeleted();
9704 const bool SecondDeleted = SecondMethod->isDeleted();
9705 if (FirstDeleted != SecondDeleted) {
9708 << FirstMethodType << FirstName << FirstDeleted;
9710 ODRDiagNote(SecondMethod->getLocation(),
9711 SecondMethod->getSourceRange(), MethodDeleted)
9712 << SecondMethodType << SecondName << SecondDeleted;
9718 const bool SecondVirtual = SecondMethod->isVirtualAsWritten();
9719 const bool FirstPure = FirstMethod->
isPure();
9720 const bool SecondPure = SecondMethod->isPure();
9721 if ((FirstVirtual || SecondVirtual) &&
9722 (FirstVirtual != SecondVirtual || FirstPure != SecondPure)) {
9725 << FirstMethodType << FirstName << FirstPure << FirstVirtual;
9726 ODRDiagNote(SecondMethod->getLocation(),
9727 SecondMethod->getSourceRange(), MethodVirtual)
9728 << SecondMethodType << SecondName << SecondPure << SecondVirtual;
9737 const auto SecondStorage = SecondMethod->getStorageClass();
9738 const bool FirstStatic = FirstStorage ==
SC_Static;
9739 const bool SecondStatic = SecondStorage ==
SC_Static;
9740 if (FirstStatic != SecondStatic) {
9743 << FirstMethodType << FirstName << FirstStatic;
9744 ODRDiagNote(SecondMethod->getLocation(),
9745 SecondMethod->getSourceRange(), MethodStatic)
9746 << SecondMethodType << SecondName << SecondStatic;
9751 const bool FirstVolatile = FirstMethod->
isVolatile();
9752 const bool SecondVolatile = SecondMethod->isVolatile();
9753 if (FirstVolatile != SecondVolatile) {
9756 << FirstMethodType << FirstName << FirstVolatile;
9757 ODRDiagNote(SecondMethod->getLocation(),
9758 SecondMethod->getSourceRange(), MethodVolatile)
9759 << SecondMethodType << SecondName << SecondVolatile;
9764 const bool FirstConst = FirstMethod->
isConst();
9765 const bool SecondConst = SecondMethod->isConst();
9766 if (FirstConst != SecondConst) {
9769 << FirstMethodType << FirstName << FirstConst;
9770 ODRDiagNote(SecondMethod->getLocation(),
9771 SecondMethod->getSourceRange(), MethodConst)
9772 << SecondMethodType << SecondName << SecondConst;
9778 const bool SecondInline = SecondMethod->isInlineSpecified();
9779 if (FirstInline != SecondInline) {
9782 << FirstMethodType << FirstName << FirstInline;
9783 ODRDiagNote(SecondMethod->getLocation(),
9784 SecondMethod->getSourceRange(), MethodInline)
9785 << SecondMethodType << SecondName << SecondInline;
9790 const unsigned FirstNumParameters = FirstMethod->
param_size();
9791 const unsigned SecondNumParameters = SecondMethod->param_size();
9792 if (FirstNumParameters != SecondNumParameters) {
9795 << FirstMethodType << FirstName << FirstNumParameters;
9796 ODRDiagNote(SecondMethod->getLocation(),
9797 SecondMethod->getSourceRange(), MethodNumberParameters)
9798 << SecondMethodType << SecondName << SecondNumParameters;
9804 bool ParameterMismatch =
false;
9805 for (
unsigned I = 0; I < FirstNumParameters; ++
I) {
9807 const ParmVarDecl *SecondParam = SecondMethod->getParamDecl(I);
9811 if (FirstParamType != SecondParamType &&
9812 ComputeQualTypeODRHash(FirstParamType) !=
9813 ComputeQualTypeODRHash(SecondParamType)) {
9818 << FirstMethodType << FirstName << (I + 1) << FirstParamType
9819 <<
true << ParamDecayedType->getOriginalType();
9823 << FirstMethodType << FirstName << (I + 1) << FirstParamType
9829 ODRDiagNote(SecondMethod->getLocation(),
9830 SecondMethod->getSourceRange(), MethodParameterType)
9831 << SecondMethodType << SecondName << (I + 1)
9832 << SecondParamType <<
true
9833 << ParamDecayedType->getOriginalType();
9835 ODRDiagNote(SecondMethod->getLocation(),
9836 SecondMethod->getSourceRange(), MethodParameterType)
9837 << SecondMethodType << SecondName << (I + 1)
9838 << SecondParamType <<
false;
9840 ParameterMismatch =
true;
9846 if (FirstParamName != SecondParamName) {
9849 << FirstMethodType << FirstName << (I + 1) << FirstParamName;
9850 ODRDiagNote(SecondMethod->getLocation(),
9851 SecondMethod->getSourceRange(), MethodParameterName)
9852 << SecondMethodType << SecondName << (I + 1) << SecondParamName;
9853 ParameterMismatch =
true;
9859 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
9862 MethodParameterSingleDefaultArgument)
9863 << FirstMethodType << FirstName << (I + 1)
9864 << (FirstInit ==
nullptr)
9866 ODRDiagNote(SecondMethod->getLocation(),
9867 SecondMethod->getSourceRange(),
9868 MethodParameterSingleDefaultArgument)
9869 << SecondMethodType << SecondName << (I + 1)
9870 << (SecondInit ==
nullptr)
9872 ParameterMismatch =
true;
9876 if (FirstInit && SecondInit &&
9877 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
9880 MethodParameterDifferentDefaultArgument)
9881 << FirstMethodType << FirstName << (I + 1)
9883 ODRDiagNote(SecondMethod->getLocation(),
9884 SecondMethod->getSourceRange(),
9885 MethodParameterDifferentDefaultArgument)
9886 << SecondMethodType << SecondName << (I + 1)
9888 ParameterMismatch =
true;
9894 if (ParameterMismatch) {
9906 auto SecondName = SecondTD->getDeclName();
9907 if (FirstName != SecondName) {
9910 << (FirstDiffType == TypeAlias) << FirstName;
9911 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
9913 << (FirstDiffType == TypeAlias) << SecondName;
9919 QualType SecondType = SecondTD->getUnderlyingType();
9920 if (ComputeQualTypeODRHash(FirstType) !=
9921 ComputeQualTypeODRHash(SecondType)) {
9924 << (FirstDiffType == TypeAlias) << FirstName << FirstType;
9925 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
9927 << (FirstDiffType == TypeAlias) << SecondName << SecondType;
9934 VarDecl *FirstVD = cast<VarDecl>(FirstDecl);
9935 VarDecl *SecondVD = cast<VarDecl>(SecondDecl);
9937 auto SecondName = SecondVD->getDeclName();
9938 if (FirstName != SecondName) {
9942 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
9950 QualType SecondType = SecondVD->getType();
9951 if (ComputeQualTypeODRHash(FirstType) !=
9952 ComputeQualTypeODRHash(SecondType)) {
9955 << FirstName << FirstType;
9956 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
9958 << SecondName << SecondType;
9964 const Expr *SecondInit = SecondVD->getInit();
9965 if ((FirstInit ==
nullptr) != (SecondInit ==
nullptr)) {
9967 VarSingleInitializer)
9968 << FirstName << (FirstInit ==
nullptr)
9970 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
9971 VarSingleInitializer)
9972 << SecondName << (SecondInit ==
nullptr)
9978 if (FirstInit && SecondInit &&
9979 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
9981 VarDifferentInitializer)
9983 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
9984 VarDifferentInitializer)
9990 const bool FirstIsConstexpr = FirstVD->
isConstexpr();
9991 const bool SecondIsConstexpr = SecondVD->isConstexpr();
9992 if (FirstIsConstexpr != SecondIsConstexpr) {
9995 << FirstName << FirstIsConstexpr;
9996 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
9998 << SecondName << SecondIsConstexpr;
10005 FriendDecl *FirstFriend = cast<FriendDecl>(FirstDecl);
10006 FriendDecl *SecondFriend = cast<FriendDecl>(SecondDecl);
10009 NamedDecl *SecondND = SecondFriend->getFriendDecl();
10014 if (FirstND && SecondND) {
10018 ODRDiagNote(SecondFriend->getFriendLoc(),
10019 SecondFriend->getSourceRange(), FriendFunction)
10026 if (FirstTSI && SecondTSI) {
10029 assert(ComputeQualTypeODRHash(FirstFriendType) !=
10030 ComputeQualTypeODRHash(SecondFriendType));
10033 << FirstFriendType;
10034 ODRDiagNote(SecondFriend->getFriendLoc(),
10035 SecondFriend->getSourceRange(), FriendType)
10036 << SecondFriendType;
10042 FriendTypeFunction)
10043 << (FirstTSI ==
nullptr);
10044 ODRDiagNote(SecondFriend->getFriendLoc(),
10045 SecondFriend->getSourceRange(), FriendTypeFunction)
10046 << (SecondTSI ==
nullptr);
10053 if (Diagnosed ==
true)
10057 diag::err_module_odr_violation_mismatch_decl_unknown)
10058 << FirstRecord << FirstModule.empty() << FirstModule << FirstDiffType
10061 diag::note_module_odr_violation_mismatch_decl_unknown)
10062 << SecondModule << FirstDiffType << SecondDecl->
getSourceRange();
10073 Diag(Merge.first->getLocation(),
10074 diag::err_module_odr_violation_different_instantiations)
10081 if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get())
10082 ReadTimer->startTimer();
10086 assert(NumCurrentElementsDeserializing &&
10087 "FinishedDeserializing not paired with StartedDeserializing");
10088 if (NumCurrentElementsDeserializing == 1) {
10091 finishPendingActions();
10093 --NumCurrentElementsDeserializing;
10095 if (NumCurrentElementsDeserializing == 0) {
10097 while (!PendingExceptionSpecUpdates.empty()) {
10098 auto Updates = std::move(PendingExceptionSpecUpdates);
10099 PendingExceptionSpecUpdates.clear();
10100 for (
auto Update :
Updates) {
10101 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
10103 auto ESI = FPT->getExtProtoInfo().ExceptionSpec;
10104 if (
auto *Listener =
getContext().getASTMutationListener())
10105 Listener->ResolvedExceptionSpec(cast<FunctionDecl>(Update.second));
10106 for (
auto *Redecl : Update.second->redecls())
10112 ReadTimer->stopTimer();
10114 diagnoseOdrViolations();
10119 PassInterestingDeclsToConsumer();
10126 auto It = PendingFakeLookupResults.find(II);
10127 if (It != PendingFakeLookupResults.end()) {
10128 for (
auto *ND : It->second)
10133 It->second.clear();
10139 }
else if (SemaObj->
TUScope) {
10151 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
10152 StringRef isysroot,
bool DisableValidation,
10153 bool AllowASTWithCompilerErrors,
10154 bool AllowConfigurationMismatch,
bool ValidateSystemInputs,
10155 bool UseGlobalIndex,
10156 std::unique_ptr<llvm::Timer> ReadTimer)
10157 : Listener(DisableValidation
10160 SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()),
10161 PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()), PP(PP),
10162 ContextObj(Context),
10163 ModuleMgr(PP.getFileManager(), PP.getPCMCache(), PCHContainerRdr),
10164 PCMCache(PP.getPCMCache()), DummyIdResolver(PP),
10165 ReadTimer(std::move(ReadTimer)), isysroot(isysroot),
10166 DisableValidation(DisableValidation),
10167 AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
10168 AllowConfigurationMismatch(AllowConfigurationMismatch),
10169 ValidateSystemInputs(ValidateSystemInputs),
10170 UseGlobalIndex(UseGlobalIndex), CurrSwitchCaseStmts(&SwitchCaseStmts) {
10173 for (
const auto &Ext : Extensions) {
10174 auto BlockName = Ext->getExtensionMetadata().BlockName;
10175 auto Known = ModuleFileExtensions.find(BlockName);
10176 if (Known != ModuleFileExtensions.end()) {
10177 Diags.
Report(diag::warn_duplicate_module_file_extension)
10182 ModuleFileExtensions.insert({BlockName, Ext});
10187 if (OwnsDeserializationListener)
10188 delete DeserializationListener;
10192 return SemaObj ? SemaObj->
IdResolver : DummyIdResolver;
10196 unsigned AbbrevID) {
10199 return Cursor.readRecord(AbbrevID, Record);
llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx)
Read an integral value.
Decl * GetExistingDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration.
unsigned IsAvailable
Whether this module is available in the current translation unit.
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
bool isPoisoned() const
Return true if this token has been poisoned.
void setSourceOrder(int Pos)
Set the source order of this initializer.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
SmallVector< std::pair< llvm::BitstreamCursor, serialization::ModuleFile * >, 8 > CommentsCursors
Cursors for comments blocks.
Defines the clang::ASTContext interface.
static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts, const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts, StringRef ExistingModuleCachePath)
Determine whether the given AST file is acceptable to load into a translation unit with the given lan...
SourceLocation getEnd() const
const FileEntry * OrigEntry
Reference to the file entry representing this ContentCache.
void updateOutOfDateSelector(Selector Sel) override
Load the contents of the global method pool for a given selector if necessary.
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override
Finds all the visible declarations with a given name.
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons...
Record code for the preprocessor options table.
std::vector< unsigned > PreloadIdentifierOffsets
Offsets of identifiers that we're going to preload within IdentifierTableData.
SmallVector< UnresolvedExportDecl, 2 > UnresolvedExports
The set of export declarations that have yet to be resolved.
static const Decl * getCanonicalDecl(const Decl *D)
The client can handle an AST file that cannot load because it was built with a different version of C...
void setInfo(const DeclarationNameLoc &Info)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
ASTFileSignature Signature
The module signature.
std::string Name
The name of this module.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Source range/offset of a preprocessed entity.
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
std::vector< std::pair< std::string, bool > > Macros
IdentifierIterator * getIdentifiers() override
Retrieve an iterator into the set of all identifiers in all loaded AST files.
void * IdentifierLookupTable
A pointer to an on-disk hash table of opaque type IdentifierHashTable.
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Record code for potentially unused local typedef names.
Record code for map of Objective-C class definition IDs to the ObjC categories in a module that are a...
Smart pointer class that efficiently represents Objective-C method names.
static void updateModuleTimestamp(ModuleFile &MF)
static hash_value_type ComputeHash(Selector Sel)
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system...
static bool checkTargetOptions(const TargetOptions &TargetOpts, const TargetOptions &ExistingTargetOpts, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true)
Compare the given set of target options against an existing set of target options.
A (possibly-)qualified type.
static LLVM_DUMP_METHOD void dumpModuleIDMap(StringRef Name, const ContinuousRangeMap< Key, ModuleFile *, InitialCapacity > &Map)
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines)
Receives the preprocessor options.
CtorInitializerType
The different kinds of data that can occur in a CtorInitializer.
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
void setChangedSinceDeserialization()
Note that this identifier has changed since it was loaded from an AST file.
void AddTokenToBody(const Token &Tok)
Add the specified token to the replacement text for the macro.
void setStarLoc(SourceLocation Loc)
NameKind
NameKind - The kind of name this object contains.
The macro directives history for a particular identifier.
Represents a version number in the form major[.minor[.subminor[.build]]].
static bool startsWithASTFileMagic(BitstreamCursor &Stream)
Whether Stream starts with the AST/PCH file magic number 'CPCH'.
void SetIdentifierInfo(unsigned ID, IdentifierInfo *II)
virtual bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule)
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Implements support for file system lookup, file system caching, and directory search management...
The (signed) 'long long' type.
bool isBitField() const
Determines whether this field is a bitfield.
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
virtual void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind)
This is called for each AST file loaded.
A simple structure that captures a vtable use for the purposes of the ExternalSemaSource.
bool operator()(ModuleFile &M)
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes...
Defines the clang::FileManager interface and associated types.
CXXBaseSpecifier * GetExternalCXXBaseSpecifiers(uint64_t Offset) override
Resolve the offset of a set of C++ base specifiers in the decl stream into an array of specifiers...
Record code for the source manager line table information, which stores information about #line direc...
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
virtual StringRef ExtractPCH(llvm::MemoryBufferRef Buffer) const =0
Returns the serialized AST inside the PCH container Buffer.
bool tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name)
Try to add the given declaration to the top level scope, if it (or a redeclaration of it) hasn't alre...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
ObjCXXARCStandardLibraryKind
Enumerate the kinds of standard library that.
This header is part of the module (for layering purposes) but should be textually included...
The 'bool' or '_Bool' type.
static SanitizerMask getPPTransparentSanitizers()
Return the sanitizers which do not affect preprocessing.
bool factoryHasMoreThanOneDecl() const
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
void setKWLoc(SourceLocation Loc)
unsigned getHash() const
Compute a fingerprint of this key for use in on-disk hash table.
void setRParenLoc(SourceLocation Loc)
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Stmt - This represents one statement.
void setStarLoc(SourceLocation Loc)
Optional< bool > isPreprocessedEntityInFileID(unsigned Index, FileID FID) override
Optionally returns true or false if the preallocated preprocessed entity with index Index came from f...
void setLAngleLoc(SourceLocation Loc)
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
void AddQualType(QualType T)
void setExceptionSpecRange(SourceRange R)
SanitizerSet Sanitize
Set of enabled sanitizers.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
SourceLocation DirectImportLoc
The source location where the module was explicitly or implicitly imported in the local translation u...
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "...
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
ControlRecordTypes
Record types that occur within the control block.
void addTopHeaderFilename(StringRef Filename)
Add a top-level header filename associated with this module.
llvm::MemoryBuffer * Buffer
The memory buffer that stores the data associated with this AST file, owned by the PCMCache in the Mo...
unsigned Generation
The generation of which this module file is a part.
void ReadComments() override
Loads comments ranges.
std::vector< UnresolvedConflict > UnresolvedConflicts
The list of conflicts for which the module-id has not yet been resolved.
C Language Family Type Representation.
Defines the SourceManager interface.
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
The 'unknown any' placeholder type.
void setWrittenWidthSpec(TypeSpecifierWidth written)
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
RawCommentList Comments
All comments in this translation unit.
QualType getUnderlyingType() const
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
unsigned size() const
Number of modules loaded.
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
Decl - This represents one declaration (or definition), e.g.
SmallVector< uint64_t, 4 > PreloadSLocEntries
SLocEntries that we're going to preload.
Module * getCurrentModule()
Retrieves the module that we're currently building, if any.
std::string getTimestampFilename() const
virtual void MacroRead(serialization::MacroID ID, MacroInfo *MI)
A macro was read from the AST file.
CanQualType ObjCBuiltinSelTy
RetTy Visit(TypeLoc TyLoc)
void VisitFunctionTypeLoc(FunctionTypeLoc)
ModuleKind Kind
The type of this module.
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
Defines the C++ template declaration subclasses.
Describes a source location entry (SLocEntry) for a macro expansion.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
unsigned getFactoryBits() const
std::vector< std::string > Includes
static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts, const PreprocessorOptions &ExistingPPOpts, DiagnosticsEngine *Diags, FileManager &FileMgr, std::string &SuggestedPredefines, const LangOptions &LangOpts, bool Validate=true)
Check the preprocessor options deserialized from the control block against the preprocessor options i...
An LValueReferenceType record.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
The placeholder type for builtin functions.
Defines the clang::MacroInfo and clang::MacroDirective classes.
Defines types useful for describing an Objective-C runtime.
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
Specifies the submodules that are imported by this submodule.
std::string ModuleName
The name of the module.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
CanQualType ARCUnbridgedCastTy
A record that stores the set of declarations that are lexically stored within a given DeclContext...
The module file is out-of-date.
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
Specifies an umbrella directory.
The base class of the type hierarchy.
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
IdentifierInfo * getLocalIdentifier(ModuleFile &M, unsigned LocalID)
unsigned LocalNumObjCCategoriesInMap
The number of redeclaration info entries in ObjCCategoriesMap.
void setHasLineDirectives()
Set the flag that indicates that this FileID has line table entries associated with it...
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
#define CHECK_TARGET_OPT(Field, Name)
A SubstTemplateTypeParmType record.
QualType getRecordType(const RecordDecl *Decl) const
std::unique_ptr< llvm::MemoryBuffer > Buffer
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void setTemplateKeywordLoc(SourceLocation Loc)
void setFlag(TokenFlags Flag)
Set the specified flag.
const Expr * getInit() const
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamespaceDecl - Represent a C++ namespace.
Wrapper for source info for typedefs.
static void markIdentifierFromAST(ASTReader &Reader, IdentifierInfo &II)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
A container of type source information.
RefQualifierKind RefQualifier
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
uint64_t GlobalBitOffset
The global bit offset (or base) of this module.
SmallVector< ObjCMethodDecl *, 2 > Instance
Record code for enabled OpenCL extensions.
Record code for the module build directory.
Floating point control options.
void * getAsOpaquePtr() const
SourceLocation getLocStart() const LLVM_READONLY
void makeModuleVisible(Module *Mod, Module::NameVisibilityKind NameVisibility, SourceLocation ImportLoc)
Make the entities in the given module and any of its (non-explicit) submodules visible to name lookup...
An ElaboratedType record.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
virtual void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II)
An identifier was deserialized from the AST file.
An UnresolvedUsingType record.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
Wrapper for source info for pointers decayed from arrays and functions.
bool hasAttrEnumOperand() const
ASTFileSignature Signature
The signature of the module file, which may be used instead of the size and modification time to iden...
Represents a C++ constructor within a class.
TypeLoc getNextTypeLoc() const
This is a module that was defined by a module map and built out of header files.
An IncompleteArrayType record.
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
The internal '__type_pack_element' template.
A template template parameter that has been substituted for some other template name.
void addPendingMacro(IdentifierInfo *II, ModuleFile *M, uint64_t MacroDirectivesOffset)
Add a macro to deserialize its macro directive history.
Expr * getInClassInitializer() const
getInClassInitializer - Get the C++11 in-class initializer for this member, or null if one has not be...
Specifies a header that is part of the module but must be textually included.
const uint32_t * SLocEntryOffsets
Offsets for all of the source location entries in the AST file.
bool RelocatablePCH
Whether this precompiled header is a relocatable PCH file.
CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a C++ base specifier.
ARC's unbridged-cast placeholder type.
The client can handle an AST file that cannot load because it is out-of-date relative to its input fi...
void visit(llvm::function_ref< bool(ModuleFile &M)> Visitor, llvm::SmallPtrSetImpl< ModuleFile * > *ModuleFilesHit=nullptr)
Visit each of the modules.
unsigned NumPreprocessedEntities
ArrayRef< ObjCMethodDecl * > getInstanceMethods() const
Retrieve the instance methods found by this visitor.
bool getWarningsAsErrors() const
uint32_t IdentifierID
An ID number that refers to an identifier in an AST file.
An identifier, stored as an IdentifierInfo*.
The internal '__builtin_va_list' typedef.
The stack of open #ifs/#ifdefs recorded in a preamble.
void addRequirement(StringRef Feature, bool RequiredState, const LangOptions &LangOpts, const TargetInfo &Target)
Add the given feature requirement to the list of features required by this module.
void getExportedModules(SmallVectorImpl< Module * > &Exported) const
Appends this module's list of exported modules to Exported.
Manages the set of modules loaded by an AST reader.
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
static Qualifiers fromOpaqueValue(unsigned opaque)
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation > > &Sels) override
Read the set of referenced selectors known to the external Sema source.
Record code for #pragma pack options.
A block with unhashed content.
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type...
std::string ImplicitPTHInclude
The implicit PTH input included at the start of the translation unit, or empty.
const FileEntry * getASTFile() const
The serialized AST file for this module, if one was created.
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
Wrapper for source info for member pointers.
void VisitArrayTypeLoc(ArrayTypeLoc)
Options for controlling the target.
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const
Map a local type ID within a given AST file into a global type ID.
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing)...
bool hasAttrExprOperand() const
Record code for declarations associated with OpenCL extensions.
void CompleteRedeclChain(const Decl *D) override
If any redeclarations of D have been imported since it was last checked, this digs out those redeclar...
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
AccessSpecifier getAccess() const
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
The value of the next COUNTER to dispense.
ObjCMethodDecl - Represents an instance or class method declaration.
unsigned getLineTableFilenameID(StringRef Str)
Specifies the umbrella header used to create this module, if any.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
A namespace, stored as a NamespaceDecl*.
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
Record code for header search information.
data_type ReadData(Selector, const unsigned char *d, unsigned DataLen)
void setProtocolRAngleLoc(SourceLocation Loc)
Stores a list of template parameters for a TemplateDecl and its derived classes.
void setBegin(SourceLocation b)
void setParameterList(ArrayRef< IdentifierInfo * > List, llvm::BumpPtrAllocator &PPAllocator)
Set the specified list of identifiers as the parameter list for this macro.
Describes a source location entry (SLocEntry) for a buffer.
Used to hold and unique data used to represent #line information.
Record code for the target options table.
static StringRef bytes(const std::vector< T, Allocator > &v)
bool hasAttrOperand() const
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Record code for the array of eagerly deserialized decls.
std::string PresumedModuleMapFile
The presumed file name for the module map defining this module.
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx)
int SLocEntryBaseID
The base ID in the source manager's view of this module.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
ContinuousRangeMap< uint32_t, int, 2 > DeclRemap
Remapping table for declaration IDs in this module.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
The collection of all-type qualifiers we support.
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
SourceLocation ImportLoc
The source location where this module was first imported.
void ReadTentativeDefinitions(SmallVectorImpl< VarDecl * > &TentativeDefs) override
Read the set of tentative definitions known to the external Sema source.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
An UnresolvedSet-like class that might not have been loaded from the external AST source yet...
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
The width of the "fast" qualifier mask.
ModuleKind Kind
The kind of this module.
The client can handle an AST file that cannot load because it is missing.
Defines the clang::SanitizerKind enum.
void ReadUndefinedButUsed(llvm::MapVector< NamedDecl *, SourceLocation > &Undefined) override
Load the set of used but not defined functions or variables with internal linkage, or used but not defined internal functions.
Base wrapper for a particular "section" of type source info.
StringRef ModuleOffsetMap
The module offset map data for this file.
RecordDecl - Represents a struct/union/class.
C ucontext_t typedef type.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class...
SourceLocation getBegin() const
static bool isWhitelistedDecl(const Decl *D, const CXXRecordDecl *Record)
DeclarationName getName() const
getName - Returns the embedded declaration name.
FunctionType::ExtInfo ExtInfo
One of these records is kept for each identifier that is lexed.
A macro directive exported by a module.
void setLocalRangeEnd(SourceLocation L)
void addLazyDecl(ASTContext &C, uintptr_t ID, AccessSpecifier AS)
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
void disableFileContentsOverride(const FileEntry *File)
Disable overridding the contents of a file, previously enabled with overrideFileContents.
Specifies a top-level header that falls into this (sub)module.
std::string ActualOriginalSourceFileName
The actual original source file name that was used to build this AST file.
The block containing comments.
This table allows us to fully hide how we implement multi-keyword caching.
AddModuleResult
The result of attempting to add a new module.
The Objective-C 'SEL' type.
StringLiteral * getMessage()
bool isDeclInLexicalTraversal(const Decl *D) const
Determine whether the given declaration is stored in the list of declarations lexically within this c...
A library or framework to link against when an entity from this module is used.
bool instanceHasMoreThanOneDecl() const
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
Iteration over the preprocessed entities.
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
static Module * getTopImportImplicitModule(ModuleManager &ModuleMgr, Preprocessor &PP)
Return the top import module if it is implicit, nullptr otherwise.
CXXRecordDecl * getPreviousDecl()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
Record the location of a macro definition.
unsigned getNumArgs() const
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
The 'char' type, when it is signed.
static std::string resolveFileRelativeToOriginalDir(const std::string &Filename, const std::string &OriginalDir, const std::string &CurrDir)
If a header file is not found at the path that we expect it to be and the PCH file was moved from its...
serialization::SelectorID getGlobalSelectorID(ModuleFile &F, unsigned LocalID) const
Retrieve the global selector ID that corresponds to this the local selector ID in a given module...
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
void setBuiltinLoc(SourceLocation Loc)
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
The 'unsigned long' type.
Specifies a header that has been explicitly excluded from this submodule.
void setRBracketLoc(SourceLocation Loc)
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
SmallVector< Requirement, 2 > Requirements
The set of language features required to use this module.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
llvm::MemoryBuffer * getRawBuffer() const
Get the underlying buffer, returning NULL if the buffer is not yet available.
The unsigned 128-bit integer type.
ContinuousRangeMap< uint32_t, int, 2 > PreprocessedEntityRemap
Remapping table for preprocessed entity IDs in this module.
Record code for the module map file that was used to build this AST file.
One instance of this struct is kept for every file loaded or used.
bool isPure() const
Whether this virtual function is pure, i.e.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args) const
Delete expressions that will be analyzed later.
llvm::SmallPtrSet< ModuleFile *, 4 > HitSet
A set of module files in which we found a result.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Helper class that saves the current stream position and then restores it when destroyed.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
unsigned getNumProtocols() const
void setElaboratedKeywordLoc(SourceLocation Loc)
TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template name.
const LangOptions & getLangOpts() const
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
SanitizerMask Mask
Bitmask of enabled sanitizers.
Token - This structure provides full information about a lexed token.
method_range methods() const
void setUmbrellaDir(Module *Mod, const DirectoryEntry *UmbrellaDir, Twine NameAsWritten)
Sets the umbrella directory of the given module to the given directory.
unsigned DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
QualType getTypeOfType(QualType t) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes...
unsigned getNumProtocols() const
Wrapper for source info for unresolved typename using decls.
std::string OriginalDir
The directory that the PCH was originally created in.
void setKind(tok::TokenKind K)
Sema * getSema()
Retrieve the semantic analysis object used to analyze the translation unit in which the precompiled h...
void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl * > &Decls) override
Read the set of ext_vector type declarations known to the external Sema source.
An AttributedType record.
An object-like macro definition.
The client can handle an AST file that cannot load because it's compiled configuration doesn't match ...
CanQualType OCLReserveIDTy
StringRef internal_key_type
The signature of a module, which is a hash of the AST content.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
SourceLocation getEnd() const
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
internal_key_type ReadKey(const unsigned char *d, unsigned)
void ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo > > &WI) override
Read the set of weak, undeclared identifiers known to the external Sema source.
Describes a module or submodule.
ASTReadResult ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, unsigned ClientLoadCapabilities, SmallVectorImpl< ImportedSubmodule > *Imported=nullptr)
Load the AST file designated by the given file name.
void completeVisibleDeclsMap(const DeclContext *DC) override
Load all external visible decls in the given DeclContext.
unsigned LocalNumHeaderFileInfos
The number of local HeaderFileInfo structures.
Record code for the set of ext_vector type names.
iterator end()
end - Returns an iterator that has 'finished'.
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
llvm::Optional< ASTSourceDescriptor > getSourceDescriptor(unsigned ID) override
Return a descriptor for the corresponding module.
static void collectMacroDefinitions(const PreprocessorOptions &PPOpts, MacroDefinitionsMap &Macros, SmallVectorImpl< StringRef > *MacroNames=nullptr)
Collect the macro definitions provided by the given preprocessor options.
SourceLocation getBeginLoc() const
Get the begin source location.
const PPEntityOffset * PreprocessedEntityOffsets
Specifies the submodules that are re-exported from this submodule.
void setProtocolLoc(unsigned i, SourceLocation Loc)
TemplateParameterList ** TemplParamLists
TemplParamLists - A new-allocated array of size NumTemplParamLists, containing pointers to the "outer...
serialization::MacroID BaseMacroID
Base macro ID for macros local to this module.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
QualType getParenType(QualType NamedType) const
The Objective-C 'id' type.
void setLParenLoc(SourceLocation Loc)
unsigned InferExportWildcard
Whether, when inferring submodules, the inferr submodules should export all modules they import (e...
void setNameLoc(SourceLocation Loc)
A qualified template name, where the qualification is kept to describe the source code as written...
virtual void HandleInterestingDecl(DeclGroupRef D)
HandleInterestingDecl - Handle the specified interesting declaration.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
PreprocessedEntity * ReadPreprocessedEntity(unsigned Index) override
Read a preallocated preprocessed entity from the external source.
void setCaretLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
const LangOptions & getLangOpts() const
Wrapper for source info for injected class names of class templates.
bool isAvailable() const
Determine whether this module is available for use within the current translation unit...
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
TypeSourceInfo * GetTypeSourceInfo(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declarator info from the given record.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const unsigned NumSpecialTypeIDs
The number of special type IDs.
A convenient class for passing around template argument information.
void setcudaConfigureCallDecl(FunctionDecl *FD)
Describes a blob that contains the data for a buffer entry.
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Record code for the language options table.
ModuleManager & getModuleManager()
Retrieve the module manager.
void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, const RecordData &Record, unsigned &Idx)
std::string Message
The message provided to the user when there is a conflict.
Wrapper for source info for functions.
Specifies a conflict with another module.
The signed 128-bit integer type.
CXXCtorInitializer ** ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a CXXCtorInitializer array.
llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx)
Read a signed integral value.
A UnaryTransformType record.
An ObjCObjectType record.
A ConstantArrayType record.
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
llvm::iterator_range< ModuleDeclIterator > getModuleFileLevelDecls(ModuleFile &Mod)
Wrapper for substituted template type parameters.
std::string getOwningModuleNameForDiagnostic(const Decl *D)
Get the best name we know for the module that owns the given declaration, or an empty string if the d...
TemplateName getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param, TemplateName replacement) const
Concrete class used by the front-end to report problems and issues.
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID)
Retrieve the global submodule ID given a module and its local ID number.
Record code for #pragma optimize options.
uint32_t BitOffset
Offset in the AST file.
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
HeaderSearch & getHeaderSearchInfo() const
StringRef Data
The serialized bitstream data for this file.
Specifies a header that is private to this submodule but must be textually included.
Record code for pending implicit instantiations.
Wrapper for substituted template type parameters.
ExtKind hasExternalDefinitions(const Decl *D) override
CanQualType PseudoObjectTy
The internal '__make_integer_seq' template.
bool needsExtraLocalData() const
void setRParenLoc(SourceLocation Loc)
void setLazyBody(uint64_t Offset)
TemplateArgument ReadTemplateArgument(ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument.
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
Record code for floating point #pragma options.
CommentRecordTypes
Record types used within a comments block.
StringRef getName() const
static internal_key_type ReadKey(const unsigned char *d, unsigned n)
void setMustBuildLookupTable()
Mark that there are external lexical declarations that we need to include in our lookup table (and th...
The module file is missing.
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
unsigned IsFromModuleFile
Whether this module was loaded from a module file.
std::string OriginalSourceFileName
The original source file name that was used to build the primary AST file, which may have been modifi...
Wrapper for source info for ObjC interfaces.
Record code for the set of known namespaces, which are used for typo correction.
static bool isDiagnosedResult(ASTReader::ASTReadResult ARR, unsigned Caps)
Record code for an array of all of the (sub)modules that were imported by the AST file...
The 'unsigned short' type.
serialization::DeclID BaseDeclID
Base declaration ID for declarations local to this module.
Present this diagnostic as an error.
SourceLocation FirstLoc
The first source location in this module.
void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation > > &Pending) override
Read the set of pending instantiations known to the external Sema source.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
A BlockPointerType record.
void setProtocolLoc(unsigned i, SourceLocation Loc)
A MemberPointerType record.
ContinuousRangeMap< uint32_t, int, 2 > SLocRemap
Remapping table for source locations in this module.
void setLocalRangeBegin(SourceLocation L)
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
Represents an ObjC class declaration.
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
The AST file itself appears corrupted.
detail::InMemoryDirectory::const_iterator I
void dump()
Dump information about the AST reader to standard error.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
unsigned getNumParams() const
void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &Exprs) override
static ASTFileSignature readASTFileSignature(StringRef PCH)
Reads and return the signature record from PCH's control block, or else returns 0.
A DependentSizedExtVectorType record.
uint64_t PreprocessorDetailStartOffset
The offset of the start of the preprocessor detail cursor.
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type...
CanQualType UnsignedCharTy
Record code for the table of offsets into the block of source-location information.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
friend class ASTIdentifierIterator
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
A SubstTemplateTypeParmPackType record.
Objective-C "id" redefinition type.
void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl * > &Decls) override
Read the set of delegating constructors known to the external Sema source.
static std::string ReadString(const RecordData &Record, unsigned &Idx)
TypeCode
Record codes for each kind of type.
Records the location of a macro expansion.
DiagnosticsEngine & getDiagnostics() const
virtual void SelectorRead(serialization::SelectorID iD, Selector Sel)
A selector was read from the AST file.
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
void setUnderlyingTInfo(TypeSourceInfo *TI) const
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
Class that aids in the construction of nested-name-specifiers along with source-location information ...
unsigned getObjCOrBuiltinID() const
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
unsigned IsSystem
Whether this is a "system" module (which assumes that all headers in it are system headers)...
The block containing information about the source manager.
IdentifierInfo * GetIdentifierInfo(ModuleFile &M, const RecordData &Record, unsigned &Idx)
The placeholder type for OpenMP array section.
A VariableArrayType record.
const FileEntry * getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
void setLazyBody(uint64_t Offset)
Sema - This implements semantic analysis and AST building for C.
diag::Severity getExtensionHandlingBehavior() const
const unsigned int NUM_PREDEF_PP_ENTITY_IDS
The number of predefined preprocessed entity IDs.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
void setUsedForHeaderGuard(bool Val)
ASTRecordTypes
Record types that occur within the AST block itself.
A little helper class used to produce diagnostics.
static bool parseModuleFileExtensionMetadata(const SmallVectorImpl< uint64_t > &Record, StringRef Blob, ModuleFileExtensionMetadata &Metadata)
Parse a record and blob containing module file extension metadata.
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
unsigned NumTemplParamLists
NumTemplParamLists - The number of "outer" template parameter lists.
Represents a prototype with parameter type info, e.g.
Defines the major attributes of a submodule, including its name and parent.
llvm::BitstreamCursor Stream
The main bitstream cursor for the main block.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
llvm::DenseMap< ModuleFile *, serialization::DeclID > GlobalToLocalDeclIDs
Mapping from the module files that this module file depends on to the base declaration ID for that mo...
Represents a ValueDecl that came out of a declarator.
The "auto &&" deduction type.
ModuleHeaderRole
Flags describing the role of a module header.
ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel, unsigned PriorGeneration)
ModuleKind
Specifies the kind of module that has been loaded.
A dependent template name that has not been resolved to a template (or set of templates).
DeclarationNameTable DeclarationNames
llvm::iterator_range< SmallVectorImpl< ModuleFile * >::const_iterator > pch_modules() const
A range covering the PCH and preamble module files loaded.
ArraySizeModifier
Capture whether this is a normal array (e.g.
void SetGloballyVisibleDecls(IdentifierInfo *II, const SmallVectorImpl< uint32_t > &DeclIDs, SmallVectorImpl< Decl * > *Decls=nullptr)
Set the globally-visible declarations associated with the given identifier.
unsigned getOwningModuleID() const
Retrieve the global ID of the module that owns this particular declaration.
std::vector< bool > & Stack
void ReadModuleMapFile(StringRef ModuleMapPath) override
void setSizeExpr(Expr *Size)
unsigned LocalNumSLocEntries
The number of source location entries in this AST file.
void setCFConstantStringType(QualType T)
Captures information about a #pragma weak directive.
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
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.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Record code for the table of offsets of each macro ID.
const DirectoryEntry * Entry
const uint32_t * TypeOffsets
Offset of each type within the bitstream, indexed by the type ID, or the representation of a Type*...
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo)
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
unsigned UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
void setTemplateNameLoc(SourceLocation Loc)
static NestedNameSpecifier * SuperSpecifier(const ASTContext &Context, CXXRecordDecl *RD)
Returns the nested name specifier representing the __super scope for the given CXXRecordDecl.
serialization::PreprocessedEntityID getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const
Determine the global preprocessed entity ID that corresponds to the given local ID within the given m...
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
A record containing CXXBaseSpecifiers.
ASTReaderListener implementation to validate the information of the PCH file against an initialized P...
CommentOptions CommentOpts
Options for parsing comments.
bool isDeleted() const
Whether this function has been deleted.
Specifies some declarations with initializers that must be emitted to initialize the module...
An TemplateSpecializationType record.
An ObjCObjectPointerType record.
File is from a prebuilt module path.
Type source information for an attributed type.
An ObjCInterfaceType record.
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
const Type * getTypePtrOrNull() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override
Read the header file information for the given file entry.
Describes a zlib-compressed blob that contains the data for a buffer entry.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
Defines the clang::LangOptions interface.
StringRef getName() const
Return the actual identifier string.
Record code for the array of VTable uses.
IncludeDirGroup
IncludeDirGroup - Identifies the group an include Entry belongs to, representing its relative positiv...
The 'char' type, when it is unsigned.
void setHasCommaPasting()
static bool isInterestingIdentifier(ASTReader &Reader, IdentifierInfo &II, bool IsModule)
Whether the given identifier is "interesting".
void setModeAttr(bool written)
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID)
Retrieve the global macro ID corresponding to the given local ID within the given module file...
The directory that the PCH was originally created in.
QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a type from the current position in the given record, which was read from the given AST file...
Declaration of a template type parameter.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
std::string WorkingDir
If set, paths are resolved as if the working directory was set to the value of WorkingDir.
unsigned LocalNumIdentifiers
The number of identifiers in this AST file.
void ReadUsedVTables(SmallVectorImpl< ExternalVTableUse > &VTables) override
Read the set of used vtables known to the external Sema source.
The placeholder type for overloaded function sets.
std::string OMPHostIRFile
Name of the IR file that contains the result of the OpenMP target host code generation.
Implements an efficient mapping from strings to IdentifierInfo nodes.
Defines implementation details of the clang::SourceManager class.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
virtual void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata)
Indicates that a particular module file extension has been read.
Expr * getBitWidth() const
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
unsigned ConfigMacrosExhaustive
Whether the set of configuration macros is exhaustive.
Record code for the table of offsets to entries in the preprocessing record.
Represents a C++ destructor within a class.
ContinuousRangeMap< uint32_t, int, 2 > IdentifierRemap
Remapping table for identifier IDs in this module.
CanQualType OMPArraySectionTy
llvm::BitstreamCursor SLocEntryCursor
Cursor used to read source location entries.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
TranslationUnitDecl * getTranslationUnitDecl() const
Defines version macros and version-related utility functions for Clang.
The OpenCL 'half' / ARM NEON __fp16 type.
const FileEntry * ContentsEntry
References the file which the contents were actually loaded from.
Defines an enumeration for C++ overloaded operators.
Defines the clang::Preprocessor interface.
ArgKind
The kind of template argument we're storing.
serialization::DeclID getGlobalDeclID(ModuleFile &F, serialization::LocalDeclID LocalID) const
Map from a local declaration ID within a given module to a global declaration ID. ...
The block containing the detailed preprocessing record.
const ParmVarDecl * getParamDecl(unsigned i) const
ArgKind getKind() const
Return the kind of stored template argument.
ASTReaderListenter implementation to set SuggestedPredefines of ASTReader which is required to use a ...
Record code for #pragma diagnostic mappings.
std::pair< SourceLocation, StringRef > getModuleImportLoc(int ID) override
Retrieve the module import location and module name for the given source manager entry ID...
DeclContext * getDeclContext()
static LineEntry get(unsigned Offs, unsigned Line, int Filename, SrcMgr::CharacteristicKind FileKind, unsigned IncludeOffset)
void setWrittenSignSpec(TypeSpecifierSign written)
llvm::BitstreamCursor InputFilesCursor
The cursor to the start of the input-files block.
unsigned LocalNumMacros
The number of macros in this AST file.
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a source range.
A record containing CXXCtorInitializers.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Record code for the original file that was used to generate the AST file, including both its file ID ...
void setRParenLoc(SourceLocation Loc)
Represents a C++ template name within the type system.
llvm::SmallVector< LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used...
void clear(SanitizerMask K=SanitizerKind::All)
Disable the sanitizers specified in K.
QualType getLocalType(ModuleFile &F, unsigned LocalID)
Resolve a local type ID within a given AST file into a type.
Information about a module that has been loaded by the ASTReader.
A namespace alias, stored as a NamespaceAliasDecl*.
virtual ~ASTReaderListener()
Record code for the diagnostic options table.
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
CanQualType UnsignedInt128Ty
An iterator that walks over all of the known identifiers in the lookup table.
SmallVector< uint64_t, 1 > ObjCCategories
The Objective-C category lists for categories known to this module.
void setNameLoc(SourceLocation Loc)
unsigned getInstanceBits() const
void setLParenLoc(SourceLocation Loc)
FileID OriginalSourceFileID
The file ID for the original source file that was used to build this AST file.
A FunctionProtoType record.
void setInheritConstructors(bool Inherit=true)
Set that this base class's constructors should be inherited.
bool HasTimestamps
Whether timestamps are included in this module file.
Describes a source location entry (SLocEntry) for a file.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
Wrapper for source info for enum types.
A block containing a module file extension.
bool isInstanceMethod() const
unsigned NumUserInputFiles
clang::ObjCRuntime ObjCRuntime
std::string FileName
The file name of the module file.
void setUmbrellaHeader(Module *Mod, const FileEntry *UmbrellaHeader, Twine NameAsWritten)
Sets the umbrella header of the given module to the given header.
void setEllipsisLoc(SourceLocation Loc)
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...
Record code for an update to a decl context's lookup table.
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
void setHasBaseTypeAsWritten(bool HasBaseType)
Record the location of an inclusion directive, such as an #include or #import statement.
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Record code for #pragma ms_struct options.
InclusionKind
The kind of inclusion directives known to the preprocessor.
unsigned Map[FirstTargetAddressSpace]
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
QualType withFastQualifiers(unsigned TQs) const
struct CXXOpName CXXOperatorName
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
QualType getSubstTemplateTypeParmPackType(const TemplateTypeParmType *Replaced, const TemplateArgument &ArgPack)
Retrieve a.
void insertOrReplace(const value_type &Val)
void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method)
Add the given method to the list of globally-known methods.
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
void deduplicateMergedDefinitonsFor(NamedDecl *ND)
Clean up the merged definition list.
void StartedDeserializing() override
Notify ASTReader that we started deserialization of a decl or type so until FinishedDeserializing is ...
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
BuiltinTemplateDecl * getMakeIntegerSeqDecl() const
The result type of a method or function.
unsigned SLocEntryBaseOffset
The base offset in the source manager's view of this module.
Record code for the table of offsets of each identifier ID.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
A type, stored as a Type*.
SmallVector< uint64_t, 16 > PreloadedDeclIDs
Record code for undefined but used functions and variables that need a definition in this TU...
void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, const RecordData &Record, unsigned &Idx)
A DependentNameType record.
SmallVector< ObjCMethodDecl *, 2 > Factory
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Record code for the identifier table.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
The AST file was missing.
NestedNameSpecifier * ReadNestedNameSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
void AddEntry(FileID FID, const std::vector< LineEntry > &Entries)
Add a new line entry that has already been encoded into the internal representation of the line table...
The placeholder type for bound member functions.
void setIsUsed(bool Val)
Set the value of the IsUsed flag.
The "auto" deduction type.
void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef)
Note that MergedDef is a redefinition of the canonical definition Def, so Def should be visible whene...
std::string CPU
If given, the name of the target CPU to generate code for.
bool getSuppressSystemWarnings() const
unsigned readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID)
Reads a record with id AbbrevID from Cursor, resetting the internal state.
void setStarLoc(SourceLocation Loc)
std::vector< std::unique_ptr< ModuleFileExtensionReader > > ExtensionReaders
The list of extension readers that are attached to this module file.
Representation::const_iterator const_iterator
QualType getPackExpansionType(QualType Pattern, Optional< unsigned > NumExpansions)
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
void setTypeofLoc(SourceLocation Loc)
The Objective-C 'Class' type.
SpecifierKind
The kind of specifier that completes this nested name specifier.
SourceLocation getLocStart() const LLVM_READONLY
std::pair< Module *, bool > findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework, bool IsExplicit)
Find a new module or submodule, or create it if it does not already exist.
void makeNamesVisible(const HiddenNames &Names, Module *Owner)
Make the names within this set of hidden names visible.
StringRef Next() override
Retrieve the next string in the identifier table and advances the iterator for the following string...
The 'unsigned long long' type.
A template template parameter pack that has been substituted for a template template argument pack...
Wrapper for source info for arrays.
Record code for the set of source location entries that need to be preloaded by the AST reader...
QualifierInfo - A struct with extended info about a syntactic name qualifier, to be used for the case...
The control block was read successfully.
The list of delegating constructor declarations.
Information about a FileID, basically just the logical file that it represents and include stack info...
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Record code for types associated with OpenCL extensions.
void setAttrOperandParensRange(SourceRange range)
static bool readBit(unsigned &Bits)
void setIsFunctionLike()
Function/Object-likeness.
const unsigned char * SelectorLookupTableData
A pointer to the character data that comprises the selector table.
Encapsulates changes to the "macros namespace" (the location where the macro name became active...
Representation::iterator iterator
bool ReadFullVersionInformation(StringRef FullVersion) override
Receives the full Clang version information.
serialization::TypeID BaseTypeIndex
Base type ID for types local to this module as represented in the global type ID space.
ContinuousRangeMap< uint32_t, int, 2 > SelectorRemap
Remapping table for selector IDs in this module.
std::string ABI
If given, the name of the target ABI to use.
void setASTFile(const FileEntry *File)
Set the serialized AST file for the top-level module of this module.
bool isGlobalIndexUnavailable() const
Determine whether we tried to load the global index, but failed, e.g., because it is out-of-date or d...
bool hasRevertedBuiltin() const
True if setNotBuiltin() was called.
ExceptionSpecificationType Type
The kind of exception specification this is.
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
void setLAngleLoc(SourceLocation Loc)
serialization::IdentID BaseIdentifierID
Base identifier ID for identifiers local to this module.
MacroInfo * ReadMacroRecord(ModuleFile &F, uint64_t Offset)
Reads the macro record located at the given offset.
File is a PCH file treated as the preamble.
ContinuousRangeMap< unsigned, int, 2 > SLocRemap
static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method)
Move the given method to the back of the global list of methods.
const ExtParameterInfo * ExtParameterInfos
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
ExternCContextDecl * getExternCContextDecl() const
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static bool checkHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, StringRef ExistingModuleCachePath, DiagnosticsEngine *Diags, const LangOptions &LangOpts)
Check the header search options deserialized from the control block against the header search options...
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
A record that stores the set of declarations that are visible from a given DeclContext.
File is a PCH file treated as such.
IdentifierInfo * get(StringRef Name) override
Retrieve the IdentifierInfo for the named identifier.
void setLength(unsigned Len)
Specifies a library or framework to link against.
Record code for file ID of the file or buffer that was used to generate the AST file.
Represents a C++ temporary.
Interfaces are the core concept in Objective-C for object oriented design.
void InitializeContext()
Initializes the ASTContext.
Specifies a header that falls into this (sub)module.
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
ContinuousRangeMap< uint32_t, int, 2 > SubmoduleRemap
Remapping table for submodule IDs in this module.
void setUsed(bool Used=true)
SourceRange getBraceRange() const
Record code for special CUDA declarations.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
Options for controlling the compiler diagnostics engine.
A list of "interesting" identifiers.
NameVisibilityKind NameVisibility
The visibility of names within this particular module.
An identifier-lookup iterator that enumerates all of the identifiers stored within a set of AST files...
void setProtocolLAngleLoc(SourceLocation Loc)
The block of configuration options, used to check that a module is being used in a configuration comp...
TagDecl - Represents the declaration of a struct/union/class/enum.
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply...
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...
PredefinedTypeIDs
Predefined type IDs.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
All of the names in this module are hidden.
File is an implicitly-loaded module.
IdentifierTable & getIdentifierTable()
void setProtocolRAngleLoc(SourceLocation Loc)
The 'unsigned char' type.
Cached information about one file (either on disk or in the virtual file system). ...
Metadata describing this particular extension.
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
void setIsC99Varargs()
Varargs querying methods. This can only be set for function-like macros.
MacroInfo * getMacro(serialization::MacroID ID)
Retrieve the macro with the given ID.
uint64_t SizeInBits
The size of this file, in bits.
TemplateParameterList * ReadTemplateParameterList(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template parameter list.
An ObjCTypeParamType record.
void ProcessWarningOptions(DiagnosticsEngine &Diags, const DiagnosticOptions &Opts, bool ReportDiags=true)
ProcessWarningOptions - Initialize the diagnostic client and process the warning options specified on...
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
The (signed) 'long' type.
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
Represents a static or instance method of a struct/union/class.
ModuleReverseIterator rbegin()
Reverse iterator to traverse all loaded modules.
Record code for the offsets of each decl.
void setIdentifierInfo(IdentifierInfo *II)
void ReadMethodPool(Selector Sel) override
Load the contents of the global method pool for a given selector.
void * SelectorLookupTable
A pointer to an on-disk hash table of opaque type ASTSelectorLookupTable.
Metadata for submodules as a whole.
const uint32_t * IdentifierOffsets
Offsets into the identifier table data.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Class that performs lookup for a selector's entries in the global method pool stored in an AST file...
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
Record code for late parsed template functions.
The (signed) 'short' type.
Defines the clang::TargetOptions class.
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
QualType getIncompleteArrayType(QualType EltTy, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type...
void setDefinitionEndLoc(SourceLocation EndLoc)
Set the location of the last token in the macro.
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings starting...
unsigned LocalNumDecls
The number of declarations in this AST file.
void setUpgradedFromWarning(bool Value)
unsigned NumFileSortedDecls
The internal 'instancetype' typedef.
OptionsRecordTypes
Record types that occur within the options block inside the control block.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
void addDecl(NamedDecl *D)
unsigned getNumTypeArgs() const
Describes the categories of an Objective-C class.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
The AST block, which acts as a container around the full AST block.
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
IdentID ReadIdentifierID(const unsigned char *d)
A DeducedTemplateSpecializationType record.
void setElaboratedKeywordLoc(SourceLocation Loc)
void setWrittenTypeSpec(TypeSpecifierType written)
Objective-C "SEL" redefinition type.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line...
SourceLocation getBegin() const
void setAmpLoc(SourceLocation Loc)
UnhashedControlBlockRecordTypes
Record codes for the unhashed control block.
llvm::SetVector< ModuleFile * > ImportedBy
List of modules which depend on this module.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void setLBracketLoc(SourceLocation Loc)
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
void dump()
Dump debugging output for this module.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
static bool checkLanguageOptions(const LangOptions &LangOpts, const LangOptions &ExistingLangOpts, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true)
Compare the given set of language options against an existing set of language options.
An InjectedClassNameType record.
const serialization::DeclID * FileSortedDecls
Array of file-level DeclIDs sorted by file.
PragmaMSPointersToMembersKind
Record code for the extra statistics we gather while generating an AST file.
bool getEnableAllWarnings() const
static Decl * getPredefinedDecl(ASTContext &Context, PredefinedDeclIDs ID)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
virtual void visitImport(StringRef Filename)
If needsImportVisitation returns true, this is called for each AST file imported by this AST file...
Represents a C++11 static_assert declaration.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags, DiagnosticsEngine &Diags, bool Complain)
std::vector< InputFile > InputFilesLoaded
The input files that have been loaded from this AST file.
The module file was just loaded in response to this call.
DeclarationName ReadDeclarationName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a declaration name.
HashTableTy::const_iterator iterator
unsigned ComputeHash(Selector Sel)
The AST file was writtten with a different language/target configuration.
ArrayRef< ObjCMethodDecl * > getFactoryMethods() const
Retrieve the instance methods found by this visitor.
bool wasUpgradedFromWarning() const
Whether this mapping attempted to map the diagnostic to a warning, but was overruled because the diag...
const char * HeaderFileInfoTableData
Actual data for the on-disk hash table of header file information.
void markIdentifierUpToDate(IdentifierInfo *II)
Note that this identifier is up-to-date.
QualType getType() const
Return the type wrapped by this type source info.
const llvm::support::unaligned_uint64_t * InputFileOffsets
Offsets for all of the input file entries in the AST file.
void addArgument(const TemplateArgumentLoc &Loc)
Record code for the signature that identifiers this AST file.
void addHeader(Module *Mod, Module::Header Header, ModuleHeaderRole Role, bool Imported=false)
Adds this header to the given module.
File is a PCH file treated as the actual main file.
llvm::APFloat ReadAPFloat(const RecordData &Record, const llvm::fltSemantics &Sem, unsigned &Idx)
Read a floating-point value.
Record code for referenced selector pool.
void AddSubDecl(const Decl *D)
std::vector< std::string > MacroIncludes
Represents a pointer type decayed from an array or function type.
The injected class name of a C++ class template or class template partial specialization.
ModuleFile * getLocalModuleFile(ModuleFile &M, unsigned ID)
Retrieve the module file with a given local ID within the specified ModuleFile.
Record code for the set of non-builtin, special types.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
Defines various enumerations that describe declaration and type specifiers.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
void setLParenLoc(SourceLocation Loc)
void setTemplateKeywordLoc(SourceLocation Loc)
void setTypeArgsLAngleLoc(SourceLocation Loc)
uint64_t InputFilesValidationTimestamp
If non-zero, specifies the time when we last validated input files.
CanQualType UnsignedShortTy
const uint32_t * MacroOffsets
Offsets of macros in the preprocessor block.
Base class for declarations which introduce a typedef-name.
unsigned LocalNumSelectors
The number of selectors new to this file.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
Represents a template argument.
Record code for the list of other AST files imported by this AST file.
Selector getLocalSelector(ModuleFile &M, unsigned LocalID)
Retrieve a selector from the given module with its local ID number.
Describes a macro definition within the preprocessing record.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
const ASTTemplateArgumentListInfo * ReadASTTemplateArgumentListInfo(ModuleFile &F, const RecordData &Record, unsigned &Index)
A conflict between two modules.
void setClassTInfo(TypeSourceInfo *TI)
bool ReadSLocEntry(int ID) override
Read the source location entry with index ID.
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
The internal '__NSConstantString' typedef.
Record code for the module name.
Selector getObjCSelector() const
getObjCSelector - Get the Objective-C selector stored in this declaration name.
TemplateName getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param, const TemplateArgument &ArgPack) const
CanQualType ObjCBuiltinIdTy
void ResolveImportedPath(ModuleFile &M, std::string &Filename)
If we are loading a relocatable PCH or module file, and the filename is not an absolute path...
void setDeserializationListener(ASTDeserializationListener *Listener, bool TakeOwnership=false)
Set the AST deserialization listener.
Describes an inclusion directive within the preprocessing record.
The internal '__builtin_ms_va_list' typedef.
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.
unsigned IsMissingRequirement
Whether this module is missing a feature from Requirements.
not evaluated yet, for special member function
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Record code for a file sorted array of DeclIDs in a module.
void setAmpAmpLoc(SourceLocation Loc)
Record code for the array of Objective-C categories (including extensions).
void updateOutOfDateIdentifier(IdentifierInfo &II) override
Update an out-of-date identifier.
void reserve(ASTContext &C, unsigned N)
Specifies a configuration macro for this module.
void ReadDefinedMacros() override
Read the set of macros defined by this external macro source.
The base class of all kinds of template declarations (e.g., class, function, etc.).
PreprocessorDetailRecordTypes
Record types used within a preprocessor detail block.
static std::pair< GlobalModuleIndex *, ErrorCode > readIndex(StringRef Path)
Read a global index file for the given directory.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
static unsigned moduleKindForDiagnostic(ModuleKind Kind)
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain) override
Receives the file system options.
The basic abstraction for the target Objective-C runtime.
uint64_t MacroStartOffset
The offset of the start of the set of defined macros.
The template argument is a pack expansion of a template name that was provided for a template templat...
Record code for the array of unused file scoped decls.
A FunctionNoProtoType record.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
static bool SkipCursorToBlock(BitstreamCursor &Cursor, unsigned BlockID)
Given a cursor at the start of an AST file, scan ahead and drop the cursor into the start of the give...
Reads an AST files chain containing the contents of a translation unit.
File is an explicitly-loaded module.
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
Expr * ReadExpr(ModuleFile &F)
Reads an expression.
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
ModuleFile & getPrimaryModule()
Returns the primary module associated with the manager, that is, the first module loaded...
CanQualType UnsignedLongLongTy
bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule) override
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
QualType getEnumType(const EnumDecl *Decl) const
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(const FileEntry *Entry, bool isVolatile=false, bool ShouldCloseOpenFile=true)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
bool isErrorOrFatal() const
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
DeclarationName - The name of a declaration.
Represents the declaration of an Objective-C type parameter.
Record code for the Objective-C method pool,.
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
Specifies a header that is private to this submodule.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool needsInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
U cast(CodeGen::Address addr)
Describes a macro expansion within the preprocessing record.
QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
StringRef getString() const
size_t param_size() const
Selector getSelector() const
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.
detail::InMemoryDirectory::const_iterator E
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
IdentifierResolver IdResolver
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
A map from continuous integer ranges to some value, with a very specialized interface.
Class that performs lookup for an identifier stored in an AST file.
void setExternalSLocEntrySource(ExternalSLocEntrySource *Source)
ContinuousRangeMap< uint32_t, int, 2 > MacroRemap
Remapping table for macro IDs in this module.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
An RValueReferenceType record.
void ReadDeclarationNameLoc(ModuleFile &F, DeclarationNameLoc &DNLoc, DeclarationName Name, const RecordData &Record, unsigned &Idx)
A type that was preceded by the 'template' keyword, stored as a Type*.
void ClearSwitchCaseIDs()
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, uint32_t Raw) const
Read a source location from raw form.
void setHasExternalLexicalStorage(bool ES=true)
State whether this DeclContext has external storage for declarations lexically in this context...
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate >> &LPTMap) override
Read the set of late parsed template functions for this source.
BuiltinTemplateDecl * getTypePackElementDecl() const
static void PassObjCImplDeclToConsumer(ObjCImplDecl *ImplD, ASTConsumer *Consumer)
Under non-PCH compilation the consumer receives the objc methods before receiving the implementation...
The placeholder type for dependent types.
const TemplateArgument & getArg(unsigned Idx) const
All of the names in this module are visible.
void setNameLoc(SourceLocation Loc)
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
Number of unmatched #pragma clang cuda_force_host_device begin directives we've seen.
Encapsulates the data about a macro definition (e.g.
Decl * GetExternalDecl(uint32_t ID) override
Resolve a declaration ID into a declaration, potentially building a new declaration.
std::string toString(const til::SExpr *E)
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope...
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
uint32_t getGeneration() const
Get the current generation of this AST source.
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
time_t getModificationTime() const
void ReadUnresolvedSet(ModuleFile &F, LazyASTUnresolvedSet &Set, const RecordData &Record, unsigned &Idx)
Read a UnresolvedSet structure.
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl * > protocols, QualType Canonical=QualType()) const
void setAttrEnumOperandLoc(SourceLocation loc)
struct CXXLitOpName CXXLiteralOperatorName
Abstract interface for callback invocations by the ASTReader.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Location wrapper for a TemplateArgument.
C sigjmp_buf typedef type.
std::vector< Conflict > Conflicts
The list of conflicts.
const T * getAs() const
Member-template getAs<specific type>'.
NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
std::pair< unsigned, unsigned > findPreprocessedEntitiesInRange(SourceRange Range) override
Returns a pair of [Begin, End) indices of preallocated preprocessed entities that Range encompasses...
Record code for the table of offsets into the Objective-C method pool.
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
Defines the clang::FileSystemOptions interface.
Represents a C++ base or member initializer.
A DependentSizedArrayType record.
CanQualType UnsignedLongTy
Record code for the remapping information used to relate loaded modules to the various offsets and ID...
virtual bool needsImportVisitation() const
Returns true if this ASTReaderListener wants to receive the imports of the AST file via visitImport...
bool InstanceHasMoreThanOneDecl
A key used when looking up entities by DeclarationName.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata) override
Indicates that a particular module file extension has been read.
unsigned getNumArgs() const
Record code for declarations that Sema keeps references of.
void ReadTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument array.
void setTemplateNameLoc(SourceLocation Loc)
void * HeaderFileInfoTable
The on-disk hash table that contains information about each of the header files.
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
void visitTopLevelModuleMaps(serialization::ModuleFile &MF, llvm::function_ref< void(const FileEntry *)> Visitor)
Visit all the top-level module maps loaded when building the given module file.
bool hasBody() const override
Determine whether this method has a body.
Offsets into the input-files block where input files reside.
bool FactoryHasMoreThanOneDecl
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
CanQualType ObjCBuiltinClassTy
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
PreprocessorRecordTypes
Record types used within a preprocessor block.
static bool isExtHandlingFromDiagsError(DiagnosticsEngine &Diags)
CanQualType BoundMemberTy
The block containing the submodule structure.
void setTypeArgsRAngleLoc(SourceLocation Loc)
Wrapper for source info for record types.
std::string BaseDirectory
The base directory of the module.
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
The template argument is a type.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
Wraps an ObjCPointerType with source location information.
const TypeClass * getTypePtr() const
ContinuousRangeMap< uint32_t, int, 2 > TypeRemap
Remapping table for type IDs in this module.
Selector DecodeSelector(serialization::SelectorID Idx)
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
The template argument is actually a parameter pack.
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
const TemplateArgument & getArg(unsigned Idx) const
Retrieve a specific template argument as a type.
Represents a base class of a C++ class.
Cached information about one directory (either on disk or in the virtual file system).
uint32_t GetNumExternalSelectors() override
Returns the number of selectors known to the external AST source.
unsigned BufferOverridden
Indicates whether the buffer itself was provided to override the actual file contents.
void PrintStats() override
Print some statistics about AST usage.
void setSeverity(diag::Severity Value)
Defines the clang::TokenKind enum and support functions.
void insert(const value_type &Val)
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Keeps track of options that affect how file operations are performed.
static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID)
ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the specified cursor.
QualType GetType(serialization::TypeID ID)
Resolve a type ID into a type, potentially building a new type.
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
IdentifierInfo * DecodeIdentifierInfo(serialization::IdentifierID ID)
Expr * NoexceptExpr
Noexcept expression, if this is EST_ComputedNoexcept.
NestedNameSpecifierLoc QualifierLoc
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain)
Receives the header search options.
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Canon=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
QualType getTypeOfExprType(Expr *e) const
GCC extension.
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void setKWLoc(SourceLocation Loc)
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
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.
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type...
TemplateArgumentLoc ReadTemplateArgumentLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLoc.
unsigned InferSubmodules
Whether we should infer submodules for this module based on the headers.
void setEnd(SourceLocation e)
TemplateArgumentLocInfo GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind.
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
static const ASTTemplateArgumentListInfo * Create(ASTContext &C, const TemplateArgumentListInfo &List)
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declaration ID from the given position in a record in the given module.
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
An TemplateTypeParmType record.
llvm::PointerIntPair< Module *, 1, bool > ExportDecl
Describes an exported module.
The template argument is a template name that was provided for a template template parameter...
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
SmallVector< uint64_t, 8 > PragmaDiagMappings
Diagnostic IDs and their mappings that the user changed.
Record code for the filesystem options table.
static hash_value_type ComputeHash(const internal_key_type &a)
Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx)
Reads a token out of a record.
const char * IdentifierTableData
Actual data for the on-disk hash table of identifiers.
void setParam(unsigned i, ParmVarDecl *VD)
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
void * Allocate(size_t Size, unsigned Align=8) const
Level
The level of the diagnostic, after it has been through mapping.
static DiagnosticMapping deserialize(unsigned Bits)
Deserialize a mapping.
void setOutOfDate(bool OOD)
Set whether the information for this identifier is out of date with respect to the external source...
void setLParenLoc(SourceLocation Loc)
const DeclOffset * DeclOffsets
Offset of each declaration within the bitstream, indexed by the declaration ID (-1).
Location information for a TemplateArgument.
virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the target options.
Record code for the offsets of each type.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
The block containing the definitions of all of the types and decls used within the AST file...
The internal '__va_list_tag' struct, if any.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
virtual void ReadModuleName(StringRef ModuleName)
TypedefDecl * getCFConstantStringDecl() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
ASTIdentifierIterator(const ASTReader &Reader, bool SkipModules=false)
The module file had already been loaded.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
The AST file is out-of-date relative to its input files, and needs to be regenerated.
TypeLocReader(ModuleFile &F, ASTReader &Reader, const ASTReader::RecordData &Record, unsigned &Idx)
Defines the clang::VersionTuple class, which represents a version in the form major[.minor[.subminor]].
NameVisibilityKind
Describes the visibility of the various names within a particular module.
void setPrevious(MacroDirective *Prev)
Set previous definition of the macro with the same name.
a linked list of methods with the same selector name but different signatures.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void setRAngleLoc(SourceLocation Loc)
std::pair< ObjCMethodList, ObjCMethodList > GlobalMethods
data_type ReadData(const internal_key_type &k, const unsigned char *d, unsigned DataLen)
Kind
Lists the kind of concrete classes of Decl.
Specifies a required feature.
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated, or computed.
SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID)
Returns the source location for the decl ID.
std::vector< std::string > ConfigMacros
The set of "configuration macros", which are macros that (intentionally) change how this module is bu...
TagDecl * getDecl() const
void AddStmt(const Stmt *S)
SourceRange getSourceRange() const override LLVM_READONLY
Retrieves the source range for the friend declaration.
Abstracts clang modules and precompiled header files and holds everything needed to generate debug in...
The AST file was written by a different version of Clang.
Record for offsets of DECL_UPDATES records for declarations that were modified after being deserializ...
static bool checkDiagnosticMappings(DiagnosticsEngine &StoredDiags, DiagnosticsEngine &Diags, bool IsSystem, bool Complain)
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions, ASTReaderListener &Listener, bool ValidateDiagnosticOptions)
Read the control block for the named AST file.
llvm::BitstreamCursor PreprocessorDetailCursor
The cursor to the start of the (optional) detailed preprocessing record block.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
void setProtocolLAngleLoc(SourceLocation Loc)
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
ModuleFile * getOwningModuleFile(const Decl *D)
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
RecordDecl * getCFConstantStringTagDecl() const
Record code for weak undeclared identifiers.
The block containing information about the preprocessor.
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type...
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
void StartTranslationUnit(ASTConsumer *Consumer) override
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
void setLocation(SourceLocation L)
bool hadMacroDefinition() const
Returns true if this identifier was #defined to some value at any moment.
uint32_t TypeID
An ID number that refers to a type in an AST file.
unsigned getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
Wrapper for source info for builtin types.
void setRParenLoc(SourceLocation Loc)
A set of overloaded template declarations.
Wrapper for template type parameters.
Record code for the headers search options table.
Module * Other
The module that this module conflicts with.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
std::string ModuleMapPath
NamedDecl - This represents a decl with a name.
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
AST file metadata, including the AST file version number and information about the compiler used to b...
bool isFileOverridden(const FileEntry *File) const
Returns true if the file contents have been overridden.
The block of input files, which were used as inputs to create this AST file.
static DeclarationName getUsingDirectiveName()
getUsingDirectiveName - Return name for all using-directives.
Present this diagnostic as a warning.
ObjCMethodList * getNext() const
llvm::BitstreamCursor MacroCursor
The cursor to the start of the preprocessor block, which stores all of the macro definitions.
const uint32_t * SelectorOffsets
Offsets into the selector lookup table's data array where each selector resides.
void UpdateSema()
Update the state of Sema after loading some additional modules.
unsigned LocalNumTypes
The number of types in this AST file.
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
Represents a C++ namespace alias.
void setTemplateNameLoc(SourceLocation Loc)
Kind
The basic Objective-C runtimes that we know about.
The internal '__NSConstantString' tag type.
static TypeIdx fromTypeID(TypeID ID)
serialization::DeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M, serialization::DeclID GlobalID)
Map a global declaration ID into the declaration ID used to refer to this declaration within the give...
InputFileRecordTypes
Record types that occur within the input-files block inside the control block.
void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl * > &Decls) override
Read the set of unused file-scope declarations known to the external Sema source. ...
void FinishedDeserializing() override
Notify ASTReader that we finished the deserialization of a decl or type.
A function-like macro definition.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
The Objective-C 'Protocol' type.
QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced, QualType Replacement) const
Retrieve a substitution-result type.
The global specifier '::'. There is no stored value.
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
T * getFETokenInfo() const
getFETokenInfo/setFETokenInfo - The language front-end is allowed to associate arbitrary metadata wit...
The control block, which contains all of the information that needs to be validated prior to committi...
SourceLocation getLocStart() const LLVM_READONLY
Wrapper for source info for pointers.
std::string Triple
The name of the target triple to compile for.
Wrapper for source info for block pointers.
void ReadModuleName(StringRef ModuleName) override
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
This class handles loading and caching of source files into memory.
ExceptionSpecInfo ExceptionSpec
PredefinedDeclIDs
Predefined declaration IDs.
Record code for an update to the TU's lexically contained declarations.
A class which abstracts out some details necessary for making a call.
void setElaboratedKeywordLoc(SourceLocation Loc)
Source range/offset of a preprocessed entity.
void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind) override
This is called for each AST file loaded.
const serialization::ObjCCategoriesInfo * ObjCCategoriesMap
Array of category list location information within this module file, sorted by the definition ID...
bool loadGlobalIndex()
Attempts to load the global index.
void startToken()
Reset all flags to cleared.
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
Objective-C "Class" redefinition type.
A PackExpansionType record.
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls) override
Read the set of potentially unused typedefs known to the source.
A single template declaration.
CanQualType OCLClkEventTy
The pseudo-object placeholder type.
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
virtual bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain)
Receives the diagnostic options.
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.
Record code for #pragma ms_struct options.
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID)
Record that the given ID maps to the given switch-case statement.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
A DependentTemplateSpecializationType record.
CanQualType UnsignedIntTy
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, unsigned LocalID)
Record code for the array of tentative definitions.
static void addMethodsToPool(Sema &S, ArrayRef< ObjCMethodDecl * > Methods, ObjCMethodList &List)
Add the given set of methods to the method list.
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++1z deduced class template specialization type.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.