86#include "llvm/ADT/APFloat.h"
87#include "llvm/ADT/APInt.h"
88#include "llvm/ADT/ArrayRef.h"
89#include "llvm/ADT/DenseMap.h"
90#include "llvm/ADT/DenseSet.h"
91#include "llvm/ADT/PointerIntPair.h"
92#include "llvm/ADT/STLExtras.h"
93#include "llvm/ADT/ScopeExit.h"
94#include "llvm/ADT/SmallPtrSet.h"
95#include "llvm/ADT/SmallString.h"
96#include "llvm/ADT/SmallVector.h"
97#include "llvm/ADT/StringRef.h"
98#include "llvm/Bitstream/BitCodes.h"
99#include "llvm/Bitstream/BitstreamWriter.h"
100#include "llvm/Support/Compression.h"
101#include "llvm/Support/DJB.h"
102#include "llvm/Support/EndianStream.h"
103#include "llvm/Support/ErrorHandling.h"
104#include "llvm/Support/LEB128.h"
105#include "llvm/Support/MemoryBuffer.h"
106#include "llvm/Support/OnDiskHashTable.h"
107#include "llvm/Support/Path.h"
108#include "llvm/Support/SHA1.h"
109#include "llvm/Support/TimeProfiler.h"
110#include "llvm/Support/VersionTuple.h"
111#include "llvm/Support/VirtualFileSystem.h"
112#include "llvm/Support/raw_ostream.h"
127using namespace clang;
130template <
typename T,
typename Allocator>
131static StringRef
bytes(
const std::vector<T, Allocator> &v) {
132 if (v.empty())
return StringRef();
133 return StringRef(
reinterpret_cast<const char*
>(&v[0]),
134 sizeof(
T) * v.size());
139 return StringRef(
reinterpret_cast<const char*
>(v.data()),
140 sizeof(
T) * v.size());
143static std::string
bytes(
const std::vector<bool> &
V) {
145 Str.reserve(
V.size() / 8);
146 for (
unsigned I = 0, E =
V.size(); I < E;) {
148 for (
unsigned Bit = 0; Bit < 8 && I < E; ++Bit, ++I)
161#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
162 case Type::CLASS_ID: return TYPE_##CODE_ID;
163#include "clang/Serialization/TypeBitCodes.def"
164 case Type::LateParsedAttr:
166 "should be replaced with a concrete type before serialization");
168 llvm_unreachable(
"shouldn't be serializing a builtin type this way");
170 llvm_unreachable(
"bad type kind");
175struct AffectingModuleMaps {
176 llvm::DenseSet<FileID> DefinitionFileIDs;
177 llvm::DenseSet<const FileEntry *> DefinitionFiles;
180std::optional<AffectingModuleMaps>
193 enum AffectedReason :
bool {
194 AR_TextualHeader = 0,
195 AR_ImportOrTextualHeader = 1,
197 auto AssignMostImportant = [](AffectedReason &LHS, AffectedReason RHS) {
198 LHS = std::max(LHS, RHS);
200 llvm::DenseMap<FileID, AffectedReason> ModuleMaps;
201 llvm::DenseMap<const Module *, AffectedReason> ProcessedModules;
202 auto CollectModuleMapsForHierarchy = [&](
const Module *M,
203 AffectedReason Reason) {
209 if (
auto [It, Inserted] = ProcessedModules.insert({M, Reason});
210 !Inserted && Reason <= It->second) {
216 std::queue<const Module *> Q;
219 const Module *Mod = Q.front();
225 AssignMostImportant(ModuleMaps[F], Reason);
230 AssignMostImportant(ModuleMaps[UniqF], Reason);
239 CollectModuleMapsForHierarchy(RootModule, AR_ImportOrTextualHeader);
241 std::queue<const Module *> Q;
244 const Module *CurrentModule = Q.front();
248 CollectModuleMapsForHierarchy(ImportedModule, AR_ImportOrTextualHeader);
250 CollectModuleMapsForHierarchy(UndeclaredModule, AR_ImportOrTextualHeader);
265 if (
const Module *M = KH.getModule())
266 CollectModuleMapsForHierarchy(M, AR_TextualHeader);
287 llvm::DenseSet<const FileEntry *> ModuleFileEntries;
288 llvm::DenseSet<FileID> ModuleFileIDs;
289 for (
auto [FID, Reason] : ModuleMaps) {
290 if (Reason == AR_ImportOrTextualHeader)
291 ModuleFileIDs.insert(FID);
293 ModuleFileEntries.insert(FE);
296 AffectingModuleMaps
R;
297 R.DefinitionFileIDs = std::move(ModuleFileIDs);
298 R.DefinitionFiles = std::move(ModuleFileEntries);
305 ASTRecordWriter BasicWriter;
308 ASTTypeWriter(ASTContext &Context, ASTWriter &Writer)
309 : Writer(Writer), BasicWriter(Context, Writer, Record) {}
312 if (
T.hasLocalNonFastQualifiers()) {
313 Qualifiers Qs =
T.getLocalQualifiers();
314 BasicWriter.writeQualType(
T.getLocalUnqualifiedType());
315 BasicWriter.writeQualifiers(Qs);
316 return BasicWriter.Emit(
TYPE_EXT_QUAL, Writer.getTypeExtQualAbbrev());
319 const Type *typePtr =
T.getTypePtr();
320 serialization::AbstractTypeWriter<ASTRecordWriter> atw(BasicWriter);
328 ASTRecordWriter &Record;
330 void addSourceLocation(SourceLocation Loc) { Record.AddSourceLocation(Loc); }
331 void addSourceRange(SourceRange Range) { Record.AddSourceRange(Range); }
334 TypeLocWriter(ASTRecordWriter &Record) : Record(Record) {}
336#define ABSTRACT_TYPELOC(CLASS, PARENT)
337#define TYPELOC(CLASS, PARENT) \
338 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
339#include "clang/AST/TypeLocNodes.def"
352void TypeLocWriter::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
362void TypeLocWriter::VisitComplexTypeLoc(ComplexTypeLoc TL) {
366void TypeLocWriter::VisitPointerTypeLoc(PointerTypeLoc TL) {
370void TypeLocWriter::VisitDecayedTypeLoc(DecayedTypeLoc TL) {
374void TypeLocWriter::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
378void TypeLocWriter::VisitArrayParameterTypeLoc(ArrayParameterTypeLoc TL) {
382void TypeLocWriter::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
386void TypeLocWriter::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
390void TypeLocWriter::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
394void TypeLocWriter::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
399void TypeLocWriter::VisitArrayTypeLoc(ArrayTypeLoc TL) {
407void TypeLocWriter::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) {
408 VisitArrayTypeLoc(TL);
411void TypeLocWriter::VisitIncompleteArrayTypeLoc(IncompleteArrayTypeLoc TL) {
412 VisitArrayTypeLoc(TL);
415void TypeLocWriter::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
416 VisitArrayTypeLoc(TL);
419void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
420 DependentSizedArrayTypeLoc TL) {
421 VisitArrayTypeLoc(TL);
424void TypeLocWriter::VisitDependentAddressSpaceTypeLoc(
425 DependentAddressSpaceTypeLoc TL) {
428 addSourceLocation(
range.getBegin());
429 addSourceLocation(
range.getEnd());
433void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
434 DependentSizedExtVectorTypeLoc TL) {
438void TypeLocWriter::VisitVectorTypeLoc(VectorTypeLoc TL) {
442void TypeLocWriter::VisitDependentVectorTypeLoc(
443 DependentVectorTypeLoc TL) {
447void TypeLocWriter::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
451void TypeLocWriter::VisitConstantMatrixTypeLoc(ConstantMatrixTypeLoc TL) {
454 addSourceLocation(
range.getBegin());
455 addSourceLocation(
range.getEnd());
460void TypeLocWriter::VisitDependentSizedMatrixTypeLoc(
461 DependentSizedMatrixTypeLoc TL) {
464 addSourceLocation(
range.getBegin());
465 addSourceLocation(
range.getEnd());
470void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
476 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i)
480void TypeLocWriter::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {
481 VisitFunctionTypeLoc(TL);
484void TypeLocWriter::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) {
485 VisitFunctionTypeLoc(TL);
488void TypeLocWriter::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
494void TypeLocWriter::VisitUsingTypeLoc(UsingTypeLoc TL) {
500void TypeLocWriter::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
506void TypeLocWriter::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
515void TypeLocWriter::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
521void TypeLocWriter::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
528void TypeLocWriter::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
533void TypeLocWriter::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
556void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
561 Record.AddConceptReference(CR);
567void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
568 DeducedTemplateSpecializationTypeLoc TL) {
574void TypeLocWriter::VisitTagTypeLoc(TagTypeLoc TL) {
580void TypeLocWriter::VisitRecordTypeLoc(RecordTypeLoc TL) {
584void TypeLocWriter::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
588void TypeLocWriter::VisitEnumTypeLoc(EnumTypeLoc TL) { VisitTagTypeLoc(TL); }
590void TypeLocWriter::VisitAttributedTypeLoc(AttributedTypeLoc TL) {
594void TypeLocWriter::VisitCountAttributedTypeLoc(CountAttributedTypeLoc TL) {
598void TypeLocWriter::VisitLateParsedAttrTypeLoc(LateParsedAttrTypeLoc TL) {
600 "should be replaced with a concrete type before serialization");
603void TypeLocWriter::VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
607void TypeLocWriter::VisitOverflowBehaviorTypeLoc(OverflowBehaviorTypeLoc TL) {
611void TypeLocWriter::VisitHLSLAttributedResourceTypeLoc(
612 HLSLAttributedResourceTypeLoc TL) {
616void TypeLocWriter::VisitHLSLInlineSpirvTypeLoc(HLSLInlineSpirvTypeLoc TL) {
620void TypeLocWriter::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
624void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
625 SubstTemplateTypeParmTypeLoc TL) {
629void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
630 SubstTemplateTypeParmPackTypeLoc TL) {
634void TypeLocWriter::VisitSubstBuiltinTemplatePackTypeLoc(
635 SubstBuiltinTemplatePackTypeLoc TL) {
639void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
640 TemplateSpecializationTypeLoc TL) {
647 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
651void TypeLocWriter::VisitParenTypeLoc(ParenTypeLoc TL) {
656void TypeLocWriter::VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
660void TypeLocWriter::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
666void TypeLocWriter::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) {
670void TypeLocWriter::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
675void TypeLocWriter::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
687void TypeLocWriter::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
691void TypeLocWriter::VisitAtomicTypeLoc(AtomicTypeLoc TL) {
697void TypeLocWriter::VisitPipeTypeLoc(PipeTypeLoc TL) {
700void TypeLocWriter::VisitBitIntTypeLoc(clang::BitIntTypeLoc TL) {
703void TypeLocWriter::VisitDependentBitIntTypeLoc(
704 clang::DependentBitIntTypeLoc TL) {
708void TypeLocWriter::VisitPredefinedSugarTypeLoc(
709 clang::PredefinedSugarTypeLoc TL) {
713void ASTWriter::WriteTypeAbbrevs() {
714 using namespace llvm;
716 std::shared_ptr<BitCodeAbbrev> Abv;
719 Abv = std::make_shared<BitCodeAbbrev>();
721 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
722 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
723 TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
731 llvm::BitstreamWriter &Stream,
735 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID,
Record);
738 if (!Name || Name[0] == 0)
742 Record.push_back(*Name++);
743 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME,
Record);
747 llvm::BitstreamWriter &Stream,
752 Record.push_back(*Name++);
753 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME,
Record);
758#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
891void ASTWriter::WriteBlockInfoBlock() {
893 Stream.EnterBlockInfoBlock();
895#define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
896#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
899 BLOCK(CONTROL_BLOCK);
910 BLOCK(OPTIONS_BLOCK);
918 BLOCK(INPUT_FILES_BLOCK);
986 BLOCK(SOURCE_MANAGER_BLOCK);
994 BLOCK(PREPROCESSOR_BLOCK);
1002 BLOCK(SUBMODULE_BLOCK);
1025 BLOCK(COMMENTS_BLOCK);
1029 BLOCK(DECLTYPES_BLOCK);
1033 RECORD(TYPE_BLOCK_POINTER);
1034 RECORD(TYPE_LVALUE_REFERENCE);
1035 RECORD(TYPE_RVALUE_REFERENCE);
1036 RECORD(TYPE_MEMBER_POINTER);
1037 RECORD(TYPE_CONSTANT_ARRAY);
1038 RECORD(TYPE_INCOMPLETE_ARRAY);
1039 RECORD(TYPE_VARIABLE_ARRAY);
1042 RECORD(TYPE_FUNCTION_NO_PROTO);
1043 RECORD(TYPE_FUNCTION_PROTO);
1045 RECORD(TYPE_TYPEOF_EXPR);
1049 RECORD(TYPE_OBJC_INTERFACE);
1050 RECORD(TYPE_OBJC_OBJECT_POINTER);
1052 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM);
1053 RECORD(TYPE_UNRESOLVED_USING);
1054 RECORD(TYPE_INJECTED_CLASS_NAME);
1055 RECORD(TYPE_OBJC_OBJECT);
1056 RECORD(TYPE_TEMPLATE_TYPE_PARM);
1057 RECORD(TYPE_TEMPLATE_SPECIALIZATION);
1058 RECORD(TYPE_DEPENDENT_NAME);
1059 RECORD(TYPE_DEPENDENT_SIZED_ARRAY);
1061 RECORD(TYPE_MACRO_QUALIFIED);
1062 RECORD(TYPE_PACK_EXPANSION);
1064 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK);
1065 RECORD(TYPE_SUBST_BUILTIN_TEMPLATE_PACK);
1067 RECORD(TYPE_UNARY_TRANSFORM);
1071 RECORD(TYPE_OBJC_TYPE_PARAM);
1152 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
1158 BLOCK(EXTENSION_BLOCK);
1161 BLOCK(UNHASHED_CONTROL_BLOCK);
1185 StringRef BaseDir) {
1186 if (BaseDir.empty())
1191 for (; Pos < Filename.size() && Pos < BaseDir.size(); ++Pos)
1192 if (Filename[Pos] != BaseDir[Pos])
1196 if (Pos == Filename.size()) {
1197 if (Pos != BaseDir.size())
1200 Filename.assign(1,
'.');
1206 if (!llvm::sys::path::is_separator(Filename[Pos])) {
1207 if (!llvm::sys::path::is_separator(BaseDir.back()))
1221 Filename.erase(Filename.begin(), Filename.begin() + Pos);
1225std::pair<ASTFileSignature, ASTFileSignature>
1226ASTWriter::createSignature()
const {
1227 StringRef AllBytes(Buffer.data(), Buffer.size());
1230 Hasher.update(AllBytes.slice(ASTBlockRange.first, ASTBlockRange.second));
1235 Hasher.update(AllBytes.slice(0, UnhashedControlBlockRange.first));
1238 AllBytes.slice(UnhashedControlBlockRange.second, ASTBlockRange.first));
1240 Hasher.update(AllBytes.substr(ASTBlockRange.second));
1243 return std::make_pair(ASTBlockHash, Signature);
1246ASTFileSignature ASTWriter::createSignatureForNamedModule()
const {
1248 Hasher.update(StringRef(Buffer.data(), Buffer.size()));
1250 assert(WritingModule);
1251 assert(WritingModule->isNamedModule());
1255 for (
auto [ExportImported, _] : WritingModule->Exports)
1256 Hasher.update(ExportImported->Signature);
1280 for (
Module *M : TouchedTopLevelModules)
1289 Stream.BackpatchByte(BitNo, Byte);
1294ASTFileSignature ASTWriter::backpatchSignature() {
1295 if (isWritingStdCXXNamedModules()) {
1296 ASTFileSignature Signature = createSignatureForNamedModule();
1301 if (!WritingModule ||
1306 ASTFileSignature ASTBlockHash;
1307 ASTFileSignature Signature;
1308 std::tie(ASTBlockHash, Signature) = createSignature();
1316void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP) {
1317 using namespace llvm;
1320 Stream.FlushToWord();
1321 UnhashedControlBlockRange.first = Stream.GetCurrentBitNo() >> 3;
1329 if (isWritingStdCXXNamedModules() ||
1340 SmallString<128> Blob{Dummy.begin(), Dummy.end()};
1343 if (!isWritingStdCXXNamedModules()) {
1344 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1346 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1347 unsigned ASTBlockHashAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1350 Stream.EmitRecordWithBlob(ASTBlockHashAbbrev,
Record, Blob);
1351 ASTBlockHashOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1355 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1356 Abbrev->Add(BitCodeAbbrevOp(
SIGNATURE));
1357 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1358 unsigned SignatureAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1361 Stream.EmitRecordWithBlob(SignatureAbbrev,
Record, Blob);
1362 SignatureOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1371 if (!HSOpts.ModulesSkipDiagnosticOptions) {
1372#define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name);
1373#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
1374 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name()));
1375#include "clang/Basic/DiagnosticOptions.def"
1377 for (
unsigned I = 0, N = DiagOpts.
Warnings.size(); I != N; ++I)
1380 for (
unsigned I = 0, N = DiagOpts.
Remarks.size(); I != N; ++I)
1389 if (!HSOpts.ModulesSkipHeaderSearchPaths) {
1391 Record.push_back(HSOpts.UserEntries.size());
1392 for (
unsigned I = 0, N = HSOpts.UserEntries.size(); I != N; ++I) {
1393 const HeaderSearchOptions::Entry &Entry = HSOpts.UserEntries[I];
1395 Record.push_back(
static_cast<unsigned>(Entry.
Group));
1401 Record.push_back(HSOpts.SystemHeaderPrefixes.size());
1402 for (
unsigned I = 0, N = HSOpts.SystemHeaderPrefixes.size(); I != N; ++I) {
1403 AddString(HSOpts.SystemHeaderPrefixes[I].Prefix,
Record);
1404 Record.push_back(HSOpts.SystemHeaderPrefixes[I].IsSystemHeader);
1408 Record.push_back(HSOpts.VFSOverlayFiles.size());
1409 for (StringRef VFSOverlayFile : HSOpts.VFSOverlayFiles)
1410 AddString(VFSOverlayFile,
Record);
1415 if (!HSOpts.ModulesSkipPragmaDiagnosticMappings)
1416 WritePragmaDiagnosticMappings(Diags, WritingModule);
1421 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1423 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1424 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1425 unsigned HSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1427 HSEntryUsage.size()};
1428 Stream.EmitRecordWithBlob(HSUsageAbbrevCode,
Record,
bytes(HSEntryUsage));
1434 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1435 Abbrev->Add(BitCodeAbbrevOp(
VFS_USAGE));
1436 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1437 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1438 unsigned VFSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1440 Stream.EmitRecordWithBlob(VFSUsageAbbrevCode,
Record,
bytes(VFSUsage));
1445 UnhashedControlBlockRange.second = Stream.GetCurrentBitNo() >> 3;
1449void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
1450 using namespace llvm;
1459 auto MetadataAbbrev = std::make_shared<BitCodeAbbrev>();
1460 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1461 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1462 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1463 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1464 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1465 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1467 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1468 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1469 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1470 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1471 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev));
1472 assert((!WritingModule || isysroot.empty()) &&
1473 "writing module as a relocatable PCH?");
1478 CLANG_VERSION_MAJOR,
1479 CLANG_VERSION_MINOR,
1481 isWritingStdCXXNamedModules(),
1483 ASTHasCompilerErrors};
1484 Stream.EmitRecordWithBlob(MetadataAbbrevCode,
Record,
1488 if (WritingModule) {
1490 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1492 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1493 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1495 Stream.EmitRecordWithBlob(AbbrevCode,
Record, WritingModule->Name);
1497 auto BaseDir = [&]() -> std::optional<SmallString<128>> {
1503 if (WritingModule->Directory) {
1504 return WritingModule->Directory->getName();
1506 return std::nullopt;
1518 WritingModule->Directory->getName() !=
".")) {
1520 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1522 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1523 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1526 Stream.EmitRecordWithBlob(AbbrevCode,
Record, *BaseDir);
1530 BaseDirectory.assign(BaseDir->begin(), BaseDir->end());
1532 }
else if (!isysroot.empty()) {
1534 SmallString<128> CleanedSysroot(isysroot);
1536 BaseDirectory.assign(CleanedSysroot.begin(), CleanedSysroot.end());
1540 if (WritingModule && WritingModule->Kind == Module::ModuleMapModule) {
1544 AddPath(WritingModule->PresumedModuleMapFile.empty()
1545 ? Map.getModuleMapFileForUniquing(WritingModule)
1546 ->getNameAsRequested()
1547 : StringRef(WritingModule->PresumedModuleMapFile),
1551 if (
auto *AdditionalModMaps =
1552 Map.getAdditionalModuleMapFiles(WritingModule)) {
1553 Record.push_back(AdditionalModMaps->size());
1554 SmallVector<FileEntryRef, 1> ModMaps(AdditionalModMaps->begin(),
1555 AdditionalModMaps->end());
1556 llvm::sort(ModMaps, [](FileEntryRef A, FileEntryRef B) {
1559 for (FileEntryRef F : ModMaps)
1560 AddPath(F.getName(),
Record);
1568 if (WritingModule && !WritingModule->getDirectoryDependencies().empty()) {
1571 SmallVector<StringRef> Dirs(WritingModule->getDirectoryDependencies());
1573 Record.push_back(Dirs.size());
1574 for (StringRef Dir : Dirs)
1581 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1582 Abbrev->Add(BitCodeAbbrevOp(
IMPORT));
1583 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1584 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1585 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1586 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1587 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1588 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1589 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1590 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1591 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1592 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1594 SmallString<128> Blob;
1596 for (ModuleFile &M : Chain->getModuleManager()) {
1598 if (!M.isDirectlyImported())
1606 AddSourceLocation(M.ImportLoc,
Record);
1607 AddStringBlob(M.ModuleName,
Record, Blob);
1608 Record.push_back(M.StandardCXXModule);
1612 if (M.StandardCXXModule) {
1623 Record.push_back(M.FileName.getRawKind());
1627 AddPathBlob(M.FileName,
Record, Blob);
1630 Stream.EmitRecordWithBlob(AbbrevCode,
Record, Blob);
1641 const uint64_t LanguageOptionValues[] = {
1642#define LANGOPT(Name, Bits, Default, Compatibility, Description) LangOpts.Name,
1643#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
1644 static_cast<unsigned>(LangOpts.get##Name()),
1645#include "clang/Basic/LangOptions.def"
1646#define SANITIZER(NAME, ID) LangOpts.Sanitize.has(SanitizerKind::ID),
1647#include "clang/Basic/Sanitizers.def"
1649 llvm::append_range(
Record, LanguageOptionValues);
1670 AddString(
T.getTriple(),
Record);
1678 using CK = CodeGenOptions::CompatibilityKind;
1680 const CodeGenOptions &CGOpts = getCodeGenOpts();
1681#define CODEGENOPT(Name, Bits, Default, Compatibility) \
1682 if constexpr (CK::Compatibility != CK::Benign) \
1683 Record.push_back(static_cast<unsigned>(CGOpts.Name));
1684#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility) \
1685 if constexpr (CK::Compatibility != CK::Benign) \
1686 Record.push_back(static_cast<unsigned>(CGOpts.get##Name()));
1687#define DEBUGOPT(Name, Bits, Default, Compatibility)
1688#define VALUE_DEBUGOPT(Name, Bits, Default, Compatibility)
1689#define ENUM_DEBUGOPT(Name, Type, Bits, Default, Compatibility)
1690#include "clang/Basic/CodeGenOptions.def"
1706 for (
unsigned I = 0, N = TargetOpts.
Features.size(); I != N; ++I) {
1719 const HeaderSearchOptions &HSOpts =
1722 StringRef HSOpts_ModuleCachePath =
1727 AddString(HSOpts_ModuleCachePath,
Record);
1748 bool WriteMacros = !SkipMacros;
1749 Record.push_back(WriteMacros);
1753 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
1761 for (
unsigned I = 0, N = PPOpts.
Includes.size(); I != N; ++I)
1766 for (
unsigned I = 0, N = PPOpts.
MacroIncludes.size(); I != N; ++I)
1787 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1789 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1790 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1791 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
1796 EmitRecordWithPath(FileAbbrevCode,
Record, MainFile->getName());
1803 WriteInputFiles(SourceMgr);
1810struct InputFileEntry {
1814 bool BufferOverridden;
1821 void trySetContentHash(
1823 llvm::function_ref<std::optional<llvm::MemoryBufferRef>()> GetMemBuff) {
1832 auto MemBuff = GetMemBuff();
1834 PP.
Diag(SourceLocation(), diag::err_module_unable_to_hash_content)
1839 uint64_t Hash = xxh3_64bits(MemBuff->getBuffer());
1841 ContentHash[1] =
uint32_t(Hash >> 32);
1847SourceLocation ASTWriter::getAffectingIncludeLoc(
const SourceManager &SourceMgr,
1848 const SrcMgr::FileInfo &
File) {
1849 SourceLocation IncludeLoc =
File.getIncludeLoc();
1851 FileID IncludeFID = SourceMgr.
getFileID(IncludeLoc);
1852 assert(IncludeFID.
isValid() &&
"IncludeLoc in invalid file");
1853 if (!IsSLocAffecting[IncludeFID.ID])
1854 IncludeLoc = SourceLocation();
1859void ASTWriter::WriteInputFiles(SourceManager &SourceMgr) {
1860 using namespace llvm;
1865 auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
1867 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1868 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1869 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1870 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1871 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1872 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1873 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1874 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
1875 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1876 unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
1879 auto IFHAbbrev = std::make_shared<BitCodeAbbrev>();
1881 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1882 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1883 unsigned IFHAbbrevCode = Stream.EmitAbbrev(std::move(IFHAbbrev));
1885 uint64_t InputFilesOffsetBase = Stream.GetCurrentBitNo();
1889 std::vector<InputFileEntry> SystemFiles;
1893 assert(&SourceMgr.
getSLocEntry(FileID::get(I)) == SLoc);
1900 if (!
Cache->OrigEntry)
1904 if (!IsSLocFileEntryAffecting[I])
1907 InputFileEntry Entry(*
Cache->OrigEntry);
1908 Entry.IsSystemFile =
isSystem(
File.getFileCharacteristic());
1909 Entry.IsTransient =
Cache->IsTransient;
1910 Entry.BufferOverridden =
Cache->BufferOverridden;
1912 FileID IncludeFileID = SourceMgr.
getFileID(
File.getIncludeLoc());
1913 Entry.IsTopLevel = IncludeFileID.
isInvalid() || IncludeFileID.ID < 0 ||
1914 !IsSLocFileEntryAffecting[IncludeFileID.ID];
1917 Entry.trySetContentHash(*PP, [&] {
return Cache->getBufferIfLoaded(); });
1919 if (Entry.IsSystemFile)
1920 SystemFiles.push_back(Entry);
1929 if (!Sysroot.empty()) {
1930 SmallString<128> SDKSettingsJSON = Sysroot;
1931 llvm::sys::path::append(SDKSettingsJSON,
"SDKSettings.json");
1934 InputFileEntry Entry(*FE);
1935 Entry.IsSystemFile =
true;
1936 Entry.IsTransient =
false;
1937 Entry.BufferOverridden =
false;
1938 Entry.IsTopLevel =
true;
1939 Entry.IsModuleMap =
false;
1940 std::unique_ptr<MemoryBuffer> MB;
1941 Entry.trySetContentHash(*PP, [&]() -> std::optional<MemoryBufferRef> {
1943 MB = std::move(*MBOrErr);
1944 return MB->getMemBufferRef();
1946 return std::nullopt;
1948 SystemFiles.push_back(Entry);
1953 auto SortedFiles = llvm::concat<InputFileEntry>(std::move(
UserFiles),
1954 std::move(SystemFiles));
1956 unsigned UserFilesNum = 0;
1958 std::vector<uint64_t> InputFileOffsets;
1959 for (
const auto &Entry : SortedFiles) {
1960 uint32_t &InputFileID = InputFileIDs[Entry.File];
1961 if (InputFileID != 0)
1965 InputFileOffsets.push_back(Stream.GetCurrentBitNo() - InputFilesOffsetBase);
1967 InputFileID = InputFileOffsets.size();
1969 if (!Entry.IsSystemFile)
1975 SmallString<128> NameAsRequested = Entry.File.getNameAsRequested();
1976 SmallString<128> Name = Entry.File.getName();
1978 PreparePathForOutput(NameAsRequested);
1979 PreparePathForOutput(Name);
1981 if (Name == NameAsRequested)
1984 RecordData::value_type
Record[] = {
1986 InputFileOffsets.size(),
1988 (
uint64_t)getTimestampForOutput(Entry.File.getModificationTime()),
1989 Entry.BufferOverridden,
1993 NameAsRequested.size()};
1995 Stream.EmitRecordWithBlob(IFAbbrevCode,
Record,
1996 (NameAsRequested + Name).str());
2002 Entry.ContentHash[1]};
2003 Stream.EmitRecordWithAbbrev(IFHAbbrevCode,
Record);
2010 auto OffsetsAbbrev = std::make_shared<BitCodeAbbrev>();
2012 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2013 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2015 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2016 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(std::move(OffsetsAbbrev));
2020 InputFileOffsets.size(), UserFilesNum};
2021 Stream.EmitRecordWithBlob(OffsetsAbbrevCode,
Record,
bytes(InputFileOffsets));
2031 using namespace llvm;
2033 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2035 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2036 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2037 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
2038 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2040 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2041 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2042 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
2043 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2044 return Stream.EmitAbbrev(std::move(Abbrev));
2050 using namespace llvm;
2052 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2054 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2055 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2056 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
2057 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2058 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2059 return Stream.EmitAbbrev(std::move(Abbrev));
2066 using namespace llvm;
2068 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2072 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2073 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2074 return Stream.EmitAbbrev(std::move(Abbrev));
2080 using namespace llvm;
2082 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2089 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2090 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2091 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2092 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2093 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2094 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2095 return Stream.EmitAbbrev(std::move(Abbrev));
2100static std::pair<unsigned, unsigned>
2102 llvm::encodeULEB128(KeyLen, Out);
2103 llvm::encodeULEB128(DataLen, Out);
2104 return std::make_pair(KeyLen, DataLen);
2110 class HeaderFileInfoTrait {
2114 HeaderFileInfoTrait(ASTWriter &Writer) : Writer(Writer) {}
2121 using key_type_ref =
const key_type &;
2123 using UnresolvedModule =
2124 llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
2127 data_type(
const HeaderFileInfo &HFI,
bool AlreadyIncluded,
2128 ArrayRef<ModuleMap::KnownHeader> KnownHeaders,
2130 : HFI(HFI), AlreadyIncluded(AlreadyIncluded),
2134 bool AlreadyIncluded;
2135 SmallVector<ModuleMap::KnownHeader, 1> KnownHeaders;
2138 using data_type_ref =
const data_type &;
2140 using hash_value_type = unsigned;
2141 using offset_type = unsigned;
2147 uint8_t buf[
sizeof(key.Size) +
sizeof(key.ModTime)];
2148 memcpy(buf, &key.Size,
sizeof(key.Size));
2149 memcpy(buf +
sizeof(key.Size), &key.ModTime,
sizeof(key.ModTime));
2150 return llvm::xxh3_64bits(buf);
2153 std::pair<unsigned, unsigned>
2154 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref
Data) {
2155 unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
2157 for (
auto ModInfo :
Data.KnownHeaders)
2160 if (
Data.Unresolved.getPointer())
2165 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
2166 using namespace llvm::support;
2168 endian::Writer
LE(Out, llvm::endianness::little);
2173 Out.write(key.Filename.data(), KeyLen);
2176 void EmitData(raw_ostream &Out, key_type_ref key,
2177 data_type_ref
Data,
unsigned DataLen) {
2178 using namespace llvm::support;
2180 endian::Writer
LE(Out, llvm::endianness::little);
2183 unsigned char Flags = (
Data.AlreadyIncluded << 6)
2184 | (
Data.HFI.isImport << 5)
2186 Data.HFI.isPragmaOnce << 4)
2187 | (
Data.HFI.DirInfo << 1);
2190 if (
Data.HFI.LazyControllingMacro.isID())
2199 assert((
Value >> 3) == ModID &&
"overflow in header module info");
2204 for (
auto ModInfo :
Data.KnownHeaders)
2205 EmitModule(ModInfo.getModule(), ModInfo.getRole());
2206 if (
Data.Unresolved.getPointer())
2207 EmitModule(
Data.Unresolved.getPointer(),
Data.Unresolved.getInt());
2209 assert(
Out.tell() - Start == DataLen &&
"Wrong data length");
2218void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
2219 HeaderFileInfoTrait GeneratorTrait(*
this);
2220 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait>
Generator;
2221 SmallVector<const char *, 4> SavedStrings;
2222 unsigned NumHeaderSearchEntries = 0;
2228 const HeaderFileInfo
Empty;
2229 if (WritingModule) {
2230 llvm::SmallVector<Module *, 16> Worklist(1, WritingModule);
2231 while (!Worklist.empty()) {
2232 Module *M = Worklist.pop_back_val();
2249 if (!U.Size || (!U.ModTime && IncludeTimestamps)) {
2250 PP->
Diag(U.FileNameLoc, diag::err_module_no_size_mtime_for_header)
2251 << WritingModule->getFullModuleName() << U.Size.has_value()
2258 llvm::sys::path::append(Filename, U.FileName);
2259 PreparePathForOutput(Filename);
2261 StringRef FilenameDup = strdup(Filename.c_str());
2262 SavedStrings.push_back(FilenameDup.data());
2264 HeaderFileInfoTrait::key_type Key = {
2265 FilenameDup, *U.Size, IncludeTimestamps ? *U.ModTime : 0};
2266 HeaderFileInfoTrait::data_type
Data = {
2271 ++NumHeaderSearchEntries;
2274 Worklist.append(SubmodulesRange.begin(), SubmodulesRange.end());
2279 [&](FileEntryRef
File,
const HeaderFileInfo &HFI) {
2286 StringRef Filename =
File.getName();
2287 SmallString<128> FilenameTmp(Filename);
2288 if (PreparePathForOutput(FilenameTmp)) {
2291 Filename = StringRef(strdup(FilenameTmp.c_str()));
2292 SavedStrings.push_back(Filename.data());
2297 HeaderFileInfoTrait::key_type Key = {
2298 Filename,
File.getSize(),
2299 getTimestampForOutput(
File.getModificationTime())};
2300 HeaderFileInfoTrait::data_type
Data = {
2306 ++NumHeaderSearchEntries;
2310 SmallString<4096> TableData;
2313 using namespace llvm::support;
2315 llvm::raw_svector_ostream
Out(TableData);
2317 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
2318 BucketOffset =
Generator.Emit(Out, GeneratorTrait);
2322 using namespace llvm;
2324 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2326 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2327 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2328 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2329 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2330 unsigned TableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2334 NumHeaderSearchEntries, TableData.size()};
2335 Stream.EmitRecordWithBlob(TableAbbrev,
Record, TableData);
2338 for (
unsigned I = 0, N = SavedStrings.size(); I != N; ++I)
2339 free(
const_cast<char *
>(SavedStrings[I]));
2342static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
2343 unsigned SLocBufferBlobCompressedAbbrv,
2344 unsigned SLocBufferBlobAbbrv) {
2345 using RecordDataType = ASTWriter::RecordData::value_type;
2350 if (llvm::compression::zstd::isAvailable()) {
2351 llvm::compression::zstd::compress(
2352 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer, 9);
2354 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2355 llvm::toStringRef(CompressedBuffer));
2358 if (llvm::compression::zlib::isAvailable()) {
2359 llvm::compression::zlib::compress(
2360 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer);
2362 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2363 llvm::toStringRef(CompressedBuffer));
2368 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv,
Record, Blob);
2379void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
2384 const uint64_t SourceManagerBlockOffset = Stream.GetCurrentBitNo();
2390 unsigned SLocBufferBlobCompressedAbbrv =
2396 std::vector<uint32_t> SLocEntryOffsets;
2397 uint64_t SLocEntryOffsetsBase = Stream.GetCurrentBitNo();
2403 FileID FID = FileID::get(I);
2407 uint64_t Offset = Stream.GetCurrentBitNo() - SLocEntryOffsetsBase;
2408 assert((Offset >> 32) == 0 &&
"SLocEntry offset too large");
2414 if (
Cache->OrigEntry) {
2427 if (!IsSLocAffecting[I])
2429 SLocEntryOffsets.push_back(Offset);
2430 Record.push_back(getEntryOffset(*SLoc));
2431 AddSourceLocation(getAffectingIncludeLoc(SourceMgr,
File),
Record);
2432 Record.push_back(
File.getFileCharacteristic());
2435 bool EmitBlob =
false;
2438 "Writing to AST an overridden file is not supported");
2441 assert(InputFileIDs[*Content->
OrigEntry] != 0 &&
"Missed file entry");
2444 Record.push_back(getAdjustedNumCreatedFIDs(FID));
2446 FileDeclIDsTy::iterator FDI = FileDeclIDs.find(FID);
2447 if (FDI != FileDeclIDs.end()) {
2448 Record.push_back(FDI->second->FirstDeclIndex);
2449 Record.push_back(FDI->second->DeclIDs.size());
2455 Stream.EmitRecordWithAbbrev(SLocFileAbbrv,
Record);
2466 std::optional<llvm::MemoryBufferRef> Buffer = Content->
getBufferOrNone(
2468 StringRef Name = Buffer ? Buffer->getBufferIdentifier() :
"";
2469 Stream.EmitRecordWithBlob(SLocBufferAbbrv,
Record,
2470 StringRef(Name.data(), Name.size() + 1));
2477 std::optional<llvm::MemoryBufferRef> Buffer = Content->
getBufferOrNone(
2480 Buffer = llvm::MemoryBufferRef(
"<<<INVALID BUFFER>>>",
"");
2481 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
2482 emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv,
2483 SLocBufferBlobAbbrv);
2487 const SrcMgr::ExpansionInfo &Expansion = SLoc->
getExpansion();
2488 SLocEntryOffsets.push_back(Offset);
2489 auto Chain = EmitEntryOffset(*SLoc,
Record);
2506 Record.push_back(getAdjustedOffset(NextOffset - SLoc->
getOffset()) - 1);
2507 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv,
Record);
2513 if (SLocEntryOffsets.empty())
2518 using namespace llvm;
2520 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2522 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2523 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2524 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2525 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2526 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2528 RecordData::value_type
Record[] = {
2531 SLocEntryOffsetsBase - SourceManagerBlockOffset};
2532 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev,
Record,
2533 bytes(SLocEntryOffsets));
2544 llvm::DenseMap<int, int> FilenameMap;
2545 FilenameMap[-1] = -1;
2546 for (
const auto &L : LineTable) {
2549 for (
auto &LE : L.second) {
2550 if (FilenameMap.insert(std::make_pair(
LE.FilenameID,
2551 FilenameMap.size() - 1)).second)
2552 AddPath(LineTable.getFilename(
LE.FilenameID),
Record);
2558 for (
const auto &L : LineTable) {
2563 AddFileID(L.first,
Record);
2566 Record.push_back(L.second.size());
2567 for (
const auto &LE : L.second) {
2570 Record.push_back(FilenameMap[
LE.FilenameID]);
2571 Record.push_back((
unsigned)
LE.FileKind);
2572 Record.push_back(
LE.IncludeOffset);
2587 if (MI->isBuiltinMacro())
2603void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2604 uint64_t MacroOffsetsBase = Stream.GetCurrentBitNo();
2608 WritePreprocessorDetail(*PPRec, MacroOffsetsBase);
2611 RecordData ModuleMacroRecord;
2621 SourceLocation AssumeNonNullLoc =
2623 if (AssumeNonNullLoc.
isValid()) {
2625 AddSourceLocation(AssumeNonNullLoc,
Record);
2635 AddSourceLocation(SkipInfo->HashTokenLoc,
Record);
2636 AddSourceLocation(SkipInfo->IfTokenLoc,
Record);
2637 Record.push_back(SkipInfo->FoundNonSkipPortion);
2638 Record.push_back(SkipInfo->FoundElse);
2639 AddSourceLocation(SkipInfo->ElseLoc,
Record);
2644 AddSourceLocation(Cond.IfLoc,
Record);
2645 Record.push_back(Cond.WasSkipping);
2646 Record.push_back(Cond.FoundNonSkip);
2647 Record.push_back(Cond.FoundElse);
2655 AddSourceLocation(S,
Record);
2665 PP.
Diag(SourceLocation(), diag::warn_module_uses_date_time) << IsModule;
2672 SmallVector<const IdentifierInfo *, 128> MacroIdentifiers;
2675 if (!isWritingStdCXXNamedModules())
2677 if (Id.second->hadMacroDefinition() &&
2678 (!Id.second->isFromAST() ||
2679 Id.second->hasChangedSinceDeserialization()))
2680 MacroIdentifiers.push_back(Id.second);
2683 llvm::sort(MacroIdentifiers, llvm::deref<std::less<>>());
2687 for (
const IdentifierInfo *Name : MacroIdentifiers) {
2689 uint64_t StartOffset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2690 assert((StartOffset >> 32) == 0 &&
"Macro identifiers offset too large");
2693 bool EmittedModuleMacros =
false;
2701 if (IsModule && WritingModule->isHeaderUnit()) {
2710 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2711 Record.push_back(getMacroRef(DefMD->getInfo(), Name));
2712 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2713 Record.push_back(VisMD->isPublic());
2715 ModuleMacroRecord.push_back(getSubmoduleID(WritingModule));
2716 AddMacroRef(MD->
getMacroInfo(), Name, ModuleMacroRecord);
2718 ModuleMacroRecord.clear();
2719 EmittedModuleMacros =
true;
2729 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2730 Record.push_back(getMacroRef(DefMD->getInfo(), Name));
2731 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2732 Record.push_back(VisMD->isPublic());
2738 SmallVector<ModuleMacro *, 8> Worklist(Leafs);
2739 llvm::DenseMap<ModuleMacro *, unsigned> Visits;
2740 while (!Worklist.empty()) {
2741 auto *
Macro = Worklist.pop_back_val();
2744 ModuleMacroRecord.push_back(getSubmoduleID(
Macro->getOwningModule()));
2745 AddMacroRef(
Macro->getMacroInfo(), Name, ModuleMacroRecord);
2746 for (
auto *M :
Macro->overrides())
2747 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2750 ModuleMacroRecord.clear();
2753 for (
auto *M :
Macro->overrides())
2754 if (++Visits[M] == M->getNumOverridingMacros())
2755 Worklist.push_back(M);
2757 EmittedModuleMacros =
true;
2760 if (
Record.empty() && !EmittedModuleMacros)
2763 IdentMacroDirectivesOffsetMap[Name] = StartOffset;
2774 std::vector<uint32_t> MacroOffsets;
2776 for (
unsigned I = 0, N = MacroInfosToEmit.size(); I != N; ++I) {
2777 const IdentifierInfo *Name = MacroInfosToEmit[I].Name;
2778 MacroInfo *MI = MacroInfosToEmit[I].MI;
2781 if (ID < FirstMacroID) {
2782 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2787 unsigned Index =
ID - FirstMacroID;
2788 if (Index >= MacroOffsets.size())
2789 MacroOffsets.resize(Index + 1);
2791 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2792 assert((Offset >> 32) == 0 &&
"Macro offset too large");
2793 MacroOffsets[Index] = Offset;
2795 AddIdentifierRef(Name,
Record);
2811 for (
const IdentifierInfo *Param : MI->
params())
2812 AddIdentifierRef(Param,
Record);
2820 Stream.EmitRecord(Code,
Record);
2824 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2839 using namespace llvm;
2841 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2843 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2844 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2845 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2847 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2850 MacroOffsetsBase - ASTBlockStartOffset};
2851 Stream.EmitRecordWithBlob(MacroOffsetAbbrev,
Record,
bytes(MacroOffsets));
2855void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec,
2856 uint64_t MacroOffsetsBase) {
2860 SmallVector<PPEntityOffset, 64> PreprocessedEntityOffsets;
2866 unsigned NumPreprocessingRecords = 0;
2867 using namespace llvm;
2870 unsigned InclusionAbbrev = 0;
2872 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2874 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2875 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2876 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2877 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2878 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2879 InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2883 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2885 for (PreprocessingRecord::iterator E = PPRec.
local_begin(),
2888 (
void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2891 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2892 assert((Offset >> 32) == 0 &&
"Preprocessed entity offset too large");
2893 SourceRange
R = getAdjustedRange((*E)->getSourceRange());
2894 PreprocessedEntityOffsets.emplace_back(
2895 getRawSourceLocationEncoding(
R.getBegin()),
2896 getRawSourceLocationEncoding(
R.getEnd()), Offset);
2898 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*E)) {
2900 MacroDefinitions[MD] = NextPreprocessorEntityID;
2902 AddIdentifierRef(MD->getName(),
Record);
2907 if (
auto *ME = dyn_cast<MacroExpansion>(*E)) {
2908 Record.push_back(ME->isBuiltinMacro());
2909 if (ME->isBuiltinMacro())
2910 AddIdentifierRef(ME->getName(),
Record);
2912 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2917 if (
auto *ID = dyn_cast<InclusionDirective>(*E)) {
2919 Record.push_back(
ID->getFileName().size());
2920 Record.push_back(
ID->wasInQuotes());
2921 Record.push_back(
static_cast<unsigned>(
ID->getKind()));
2922 Record.push_back(
ID->importedModule());
2923 SmallString<64> Buffer;
2924 Buffer +=
ID->getFileName();
2928 Buffer +=
ID->getFile()->getName();
2929 Stream.EmitRecordWithBlob(InclusionAbbrev,
Record, Buffer);
2933 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2938 if (NumPreprocessingRecords > 0) {
2939 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2942 using namespace llvm;
2944 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2946 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2947 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2950 Stream.EmitRecordWithBlob(PPEOffsetAbbrev,
Record,
2951 bytes(PreprocessedEntityOffsets));
2956 if (SkippedRanges.size() > 0) {
2957 std::vector<PPSkippedRange> SerializedSkippedRanges;
2958 SerializedSkippedRanges.reserve(SkippedRanges.size());
2959 for (
auto const &Range : SkippedRanges) {
2960 SourceRange
R = getAdjustedRange(Range);
2961 SerializedSkippedRanges.emplace_back(
2962 getRawSourceLocationEncoding(
R.getBegin()),
2963 getRawSourceLocationEncoding(
R.getEnd()));
2966 using namespace llvm;
2967 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2969 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2970 unsigned PPESkippedRangeAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2974 Stream.EmitRecordWithBlob(PPESkippedRangeAbbrev,
Record,
2975 bytes(SerializedSkippedRanges));
2983 auto Known = SubmoduleIDs.find(Mod);
2984 if (Known != SubmoduleIDs.end())
2985 return Known->second;
2988 if (Top != WritingModule &&
2990 !Top->fullModuleNameIs(StringRef(
getLangOpts().CurrentModule))))
2993 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2996unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2997 unsigned ID = getLocalOrImportedSubmoduleID(Mod);
3006void ASTWriter::WriteSubmodules(
Module *WritingModule,
ASTContext *Context) {
3011 using namespace llvm;
3013 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3015 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3016 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3017 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
3018 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
3019 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4));
3020 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3021 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3022 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3023 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3024 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3025 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3026 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3027 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3028 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3029 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3030 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3031 unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3033 Abbrev = std::make_shared<BitCodeAbbrev>();
3035 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3036 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3038 Abbrev = std::make_shared<BitCodeAbbrev>();
3040 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3041 unsigned HeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3043 Abbrev = std::make_shared<BitCodeAbbrev>();
3045 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3046 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3048 Abbrev = std::make_shared<BitCodeAbbrev>();
3050 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3051 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3053 Abbrev = std::make_shared<BitCodeAbbrev>();
3055 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3056 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3057 unsigned RequiresAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3059 Abbrev = std::make_shared<BitCodeAbbrev>();
3061 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3062 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3064 Abbrev = std::make_shared<BitCodeAbbrev>();
3066 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3067 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3069 Abbrev = std::make_shared<BitCodeAbbrev>();
3071 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3072 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3074 Abbrev = std::make_shared<BitCodeAbbrev>();
3076 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3077 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3079 Abbrev = std::make_shared<BitCodeAbbrev>();
3081 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3082 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3083 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3085 Abbrev = std::make_shared<BitCodeAbbrev>();
3087 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3088 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3090 Abbrev = std::make_shared<BitCodeAbbrev>();
3092 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3093 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3094 unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3096 Abbrev = std::make_shared<BitCodeAbbrev>();
3098 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3099 unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3101 Abbrev = std::make_shared<BitCodeAbbrev>();
3103 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3104 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3105 unsigned ChildAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3108 uint64_t SubmoduleOffsetBase = Stream.GetCurrentBitNo();
3110 unsigned TopLevelID = getSubmoduleID(WritingModule);
3113 std::queue<Module *> Q;
3114 Q.push(WritingModule);
3115 while (!Q.empty()) {
3118 unsigned ID = getSubmoduleID(Mod);
3119 if (ID < FirstSubmoduleID) {
3120 assert(0 &&
"Loaded submodule entered WritingModule ?");
3125 unsigned Index =
ID - FirstSubmoduleID;
3126 if (Index >= SubmoduleOffsets.size())
3127 SubmoduleOffsets.resize(Index + 1);
3129 uint64_t Offset = Stream.GetCurrentBitNo() - SubmoduleOffsetBase;
3130 assert((Offset >> 32) == 0 &&
"Submodule offset too large");
3131 SubmoduleOffsets[Index] = Offset;
3135 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
3136 ParentID = SubmoduleIDs[Mod->
Parent];
3140 getRawSourceLocationEncoding(getAdjustedLocation(Mod->
DefinitionLoc));
3143 FileID UnadjustedInferredFID;
3146 int InferredFID = getAdjustedFileID(UnadjustedInferredFID).
getOpaqueValue();
3153 (RecordData::value_type)Mod->
Kind,
3155 (RecordData::value_type)InferredFID,
3166 Stream.EmitRecordWithBlob(DefinitionAbbrev,
Record, Mod->
Name);
3172 Stream.EmitRecordWithBlob(RequiresAbbrev,
Record,
R.FeatureName);
3176 if (std::optional<Module::Header> UmbrellaHeader =
3179 Stream.EmitRecordWithBlob(UmbrellaAbbrev,
Record,
3180 UmbrellaHeader->NameAsWritten);
3181 }
else if (std::optional<Module::DirectoryName> UmbrellaDir =
3184 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev,
Record,
3185 UmbrellaDir->NameAsWritten);
3190 unsigned RecordKind;
3192 Module::HeaderKind HeaderKind;
3198 Module::HK_PrivateTextual},
3201 for (
const auto &HL : HeaderLists) {
3202 RecordData::value_type
Record[] = {HL.RecordKind};
3203 for (
const auto &H : Mod->
getHeaders(HL.HeaderKind))
3204 Stream.EmitRecordWithBlob(HL.Abbrev,
Record, H.NameAsWritten);
3211 SmallString<128> HeaderName(H.getName());
3212 PreparePathForOutput(HeaderName);
3213 Stream.EmitRecordWithBlob(TopHeaderAbbrev,
Record, HeaderName);
3221 Record.push_back(getSubmoduleID(I));
3229 Record.push_back(getSubmoduleID(I));
3236 for (
const auto &E : Mod->
Exports) {
3239 Record.push_back(getSubmoduleID(E.first));
3240 Record.push_back(E.second);
3255 Stream.EmitRecordWithBlob(LinkLibraryAbbrev,
Record, LL.Library);
3263 getSubmoduleID(
C.Other)};
3264 Stream.EmitRecordWithBlob(ConflictAbbrev,
Record,
C.Message);
3270 Stream.EmitRecordWithBlob(ConfigMacroAbbrev,
Record, CM);
3275 if (Context && !GeneratingReducedBMI) {
3278 if (wasDeclEmitted(D))
3279 AddDeclRef(D,
Inits);
3294 getSubmoduleID(Child)};
3295 Stream.EmitRecordWithBlob(ChildAbbrev,
Record, Child->Name);
3311 assert((NextSubmoduleID - FirstSubmoduleID == SubmoduleOffsets.size()) &&
3312 "Wrong # of submodules; found a reference to a non-local, "
3313 "non-imported submodule?");
3315 Abbrev = std::make_shared<BitCodeAbbrev>();
3317 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3318 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3319 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3320 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3321 unsigned SubmoduleMetadataAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3323 RecordData::value_type
Record[] = {
3326 Stream.EmitRecordWithBlob(SubmoduleMetadataAbbrev,
Record,
3327 bytes(SubmoduleOffsets));
3330void ASTWriter::WritePragmaDiagnosticMappings(
const DiagnosticsEngine &
Diag,
3332 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
3334 unsigned CurrID = 0;
3337 auto EncodeDiagStateFlags =
3338 [](
const DiagnosticsEngine::DiagState *DS) ->
unsigned {
3339 unsigned Result = (unsigned)DS->ExtBehavior;
3341 {(unsigned)DS->IgnoreAllWarnings, (
unsigned)DS->EnableAllWarnings,
3342 (unsigned)DS->WarningsAsErrors, (
unsigned)DS->ErrorsAsFatal,
3343 (unsigned)DS->SuppressSystemWarnings})
3348 unsigned Flags = EncodeDiagStateFlags(
Diag.DiagStatesByLoc.FirstDiagState);
3351 auto AddDiagState = [&](
const DiagnosticsEngine::DiagState *State,
3352 bool IncludeNonPragmaStates) {
3355 assert(Flags == EncodeDiagStateFlags(State) &&
3356 "diag state flags vary in single AST file");
3360 assert(!IncludeNonPragmaStates ||
3361 State ==
Diag.DiagStatesByLoc.FirstDiagState);
3363 unsigned &DiagStateID = DiagStateIDMap[State];
3364 Record.push_back(DiagStateID);
3366 if (DiagStateID == 0) {
3367 DiagStateID = ++CurrID;
3368 SmallVector<std::pair<unsigned, DiagnosticMapping>> Mappings;
3371 auto SizeIdx =
Record.size();
3373 for (
const auto &I : *State) {
3375 if (!I.second.isPragma() && !IncludeNonPragmaStates)
3379 if (!I.second.isPragma() &&
3380 I.second ==
Diag.getDiagnosticIDs()->getDefaultMapping(I.first))
3382 Mappings.push_back(I);
3386 llvm::sort(Mappings, llvm::less_first());
3388 for (
const auto &I : Mappings) {
3389 Record.push_back(I.first);
3390 Record.push_back(I.second.serialize());
3397 AddDiagState(
Diag.DiagStatesByLoc.FirstDiagState, isModule);
3400 auto NumLocationsIdx =
Record.size();
3404 unsigned NumLocations = 0;
3405 for (
auto &FileIDAndFile :
Diag.DiagStatesByLoc.Files) {
3406 if (!FileIDAndFile.first.isValid() ||
3407 !FileIDAndFile.second.HasLocalTransitions)
3411 AddFileID(FileIDAndFile.first,
Record);
3413 Record.push_back(FileIDAndFile.second.StateTransitions.size());
3414 for (
auto &StatePoint : FileIDAndFile.second.StateTransitions) {
3415 Record.push_back(StatePoint.Offset);
3416 AddDiagState(StatePoint.State,
false);
3421 Record[NumLocationsIdx] = NumLocations;
3429 AddSourceLocation(
Diag.DiagStatesByLoc.CurDiagStateLoc,
Record);
3430 AddDiagState(
Diag.DiagStatesByLoc.CurDiagState,
false);
3435 Record.push_back(
Diag.DiagStateOnPushStack.size());
3436 for (
const auto *State :
Diag.DiagStateOnPushStack)
3437 AddDiagState(State,
false);
3447void ASTWriter::WriteType(ASTContext &Context, QualType
T) {
3448 TypeIdx &IdxRef = TypeIdxs[
T];
3450 IdxRef = TypeIdx(0, NextTypeID++);
3451 TypeIdx Idx = IdxRef;
3454 assert(Idx.
getValue() >= FirstTypeID &&
"Writing predefined type");
3458 ASTTypeWriter(Context, *
this).write(
T) - DeclTypesBlockStartOffset;
3462 if (TypeOffsets.size() == Index)
3463 TypeOffsets.emplace_back(Offset);
3464 else if (TypeOffsets.size() < Index) {
3465 TypeOffsets.resize(Index + 1);
3466 TypeOffsets[Index].set(Offset);
3468 llvm_unreachable(
"Types emitted in wrong order");
3477 auto *ND = dyn_cast<NamedDecl>(D);
3492uint64_t ASTWriter::WriteDeclContextLexicalBlock(ASTContext &Context,
3493 const DeclContext *DC) {
3501 uint64_t Offset = Stream.GetCurrentBitNo();
3502 SmallVector<DeclID, 128> KindDeclPairs;
3503 for (
const auto *D : DC->
decls()) {
3504 if (DoneWritingDeclsAndTypes && !wasDeclEmitted(D))
3512 if (GeneratingReducedBMI && !D->isFromExplicitGlobalModule() &&
3516 KindDeclPairs.push_back(D->getKind());
3517 KindDeclPairs.push_back(GetDeclRef(D).getRawValue());
3520 ++NumLexicalDeclContexts;
3522 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev,
Record,
3523 bytes(KindDeclPairs));
3527void ASTWriter::WriteTypeDeclOffsets() {
3528 using namespace llvm;
3531 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3533 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3534 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3535 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3538 Stream.EmitRecordWithBlob(TypeOffsetAbbrev,
Record,
bytes(TypeOffsets));
3542 Abbrev = std::make_shared<BitCodeAbbrev>();
3544 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3545 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3546 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3549 Stream.EmitRecordWithBlob(DeclOffsetAbbrev,
Record,
bytes(DeclOffsets));
3553void ASTWriter::WriteFileDeclIDsMap() {
3554 using namespace llvm;
3556 SmallVector<std::pair<FileID, DeclIDInFileInfo *>, 64> SortedFileDeclIDs;
3557 SortedFileDeclIDs.reserve(FileDeclIDs.size());
3558 for (
const auto &P : FileDeclIDs)
3559 SortedFileDeclIDs.push_back(std::make_pair(P.first, P.second.get()));
3560 llvm::sort(SortedFileDeclIDs, llvm::less_first());
3563 SmallVector<DeclID, 256> FileGroupedDeclIDs;
3564 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
3565 DeclIDInFileInfo &Info = *FileDeclEntry.second;
3566 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
3567 llvm::stable_sort(Info.DeclIDs);
3568 for (
auto &LocDeclEntry : Info.DeclIDs)
3569 FileGroupedDeclIDs.push_back(LocDeclEntry.second.getRawValue());
3572 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3574 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3575 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3576 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
3578 FileGroupedDeclIDs.size()};
3579 Stream.EmitRecordWithBlob(AbbrevCode,
Record,
bytes(FileGroupedDeclIDs));
3582void ASTWriter::WriteComments(ASTContext &Context) {
3584 llvm::scope_exit _([
this] { Stream.ExitBlock(); });
3589 for (
const auto &FO : Context.
Comments.OrderedComments) {
3590 for (
const auto &OC : FO.second) {
3591 const RawComment *I = OC.second;
3609class ASTMethodPoolTrait {
3613 using key_type = Selector;
3614 using key_type_ref = key_type;
3618 ObjCMethodList Instance, Factory;
3620 using data_type_ref =
const data_type &;
3622 using hash_value_type = unsigned;
3623 using offset_type = unsigned;
3625 explicit ASTMethodPoolTrait(ASTWriter &Writer) : Writer(Writer) {}
3627 static hash_value_type
ComputeHash(Selector Sel) {
3631 std::pair<unsigned, unsigned>
3632 EmitKeyDataLength(raw_ostream& Out, Selector Sel,
3633 data_type_ref Methods) {
3637 unsigned DataLen = 4 + 2 + 2;
3638 for (
const ObjCMethodList *
Method = &Methods.Instance;
Method;
3640 if (ShouldWriteMethodListNode(
Method))
3641 DataLen +=
sizeof(
DeclID);
3642 for (
const ObjCMethodList *
Method = &Methods.Factory;
Method;
3644 if (ShouldWriteMethodListNode(
Method))
3645 DataLen +=
sizeof(
DeclID);
3649 void EmitKey(raw_ostream& Out, Selector Sel,
unsigned) {
3650 using namespace llvm::support;
3652 endian::Writer
LE(Out, llvm::endianness::little);
3654 assert((Start >> 32) == 0 &&
"Selector key offset too large");
3660 for (
unsigned I = 0; I != N; ++I)
3665 void EmitData(raw_ostream& Out, key_type_ref,
3666 data_type_ref Methods,
unsigned DataLen) {
3667 using namespace llvm::support;
3669 endian::Writer
LE(Out, llvm::endianness::little);
3672 unsigned NumInstanceMethods = 0;
3673 for (
const ObjCMethodList *
Method = &Methods.Instance;
Method;
3675 if (ShouldWriteMethodListNode(
Method))
3676 ++NumInstanceMethods;
3678 unsigned NumFactoryMethods = 0;
3679 for (
const ObjCMethodList *
Method = &Methods.Factory;
Method;
3681 if (ShouldWriteMethodListNode(
Method))
3682 ++NumFactoryMethods;
3684 unsigned InstanceBits = Methods.Instance.getBits();
3685 assert(InstanceBits < 4);
3686 unsigned InstanceHasMoreThanOneDeclBit =
3687 Methods.Instance.hasMoreThanOneDecl();
3688 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
3689 (InstanceHasMoreThanOneDeclBit << 2) |
3691 unsigned FactoryBits = Methods.Factory.getBits();
3692 assert(FactoryBits < 4);
3693 unsigned FactoryHasMoreThanOneDeclBit =
3694 Methods.Factory.hasMoreThanOneDecl();
3695 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
3696 (FactoryHasMoreThanOneDeclBit << 2) |
3700 for (
const ObjCMethodList *
Method = &Methods.Instance;
Method;
3702 if (ShouldWriteMethodListNode(
Method))
3704 for (
const ObjCMethodList *
Method = &Methods.Factory;
Method;
3706 if (ShouldWriteMethodListNode(
Method))
3709 assert(
Out.tell() - Start == DataLen &&
"Data length is wrong");
3713 static bool ShouldWriteMethodListNode(
const ObjCMethodList *Node) {
3725void ASTWriter::WriteSelectors(Sema &SemaRef) {
3726 using namespace llvm;
3731 unsigned NumTableEntries = 0;
3734 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait>
Generator;
3735 ASTMethodPoolTrait Trait(*
this);
3739 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
3740 for (
auto &SelectorAndID : SelectorIDs) {
3741 Selector S = SelectorAndID.first;
3743 SemaObjC::GlobalMethodPool::iterator F =
3745 ASTMethodPoolTrait::data_type
Data = {
3751 Data.Instance = F->second.first;
3752 Data.Factory = F->second.second;
3756 if (Chain && ID < FirstSelectorID) {
3758 bool changed =
false;
3759 for (ObjCMethodList *M = &
Data.Instance; M && M->getMethod();
3761 if (!M->getMethod()->isFromASTFile()) {
3767 for (ObjCMethodList *M = &
Data.Factory; M && M->getMethod();
3769 if (!M->getMethod()->isFromASTFile()) {
3777 }
else if (
Data.Instance.getMethod() ||
Data.Factory.getMethod()) {
3785 SmallString<4096> MethodPool;
3788 using namespace llvm::support;
3790 ASTMethodPoolTrait Trait(*
this);
3791 llvm::raw_svector_ostream
Out(MethodPool);
3793 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
3794 BucketOffset =
Generator.Emit(Out, Trait);
3798 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3800 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3801 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3802 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3803 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3809 Stream.EmitRecordWithBlob(MethodPoolAbbrev,
Record, MethodPool);
3813 Abbrev = std::make_shared<BitCodeAbbrev>();
3815 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3816 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3817 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3818 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3822 RecordData::value_type
Record[] = {
3825 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev,
Record,
3826 bytes(SelectorOffsets));
3832void ASTWriter::WriteReferencedSelectorsPool(Sema &SemaRef) {
3833 using namespace llvm;
3845 Selector Sel = SelectorAndLocation.first;
3846 SourceLocation Loc = SelectorAndLocation.second;
3847 Writer.AddSelectorRef(Sel);
3869 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3871 if (!Redecl->isFromASTFile()) {
3875 if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
3883 if (Redecl->getOwningModuleID() == 0)
3888 if (!
First->isFromASTFile())
3899bool IsInterestingIdentifier(
const IdentifierInfo *II, uint64_t MacroOffset,
3900 bool IsModule,
bool IsCPlusPlus) {
3901 bool NeedDecls = !IsModule || !IsCPlusPlus;
3903 bool IsInteresting =
3910 II->
isPoisoned() || (!IsModule && IsInteresting) ||
3918bool IsInterestingNonMacroIdentifier(
const IdentifierInfo *II,
3919 ASTWriter &Writer) {
3921 bool IsCPlusPlus = Writer.
getLangOpts().CPlusPlus;
3922 return IsInterestingIdentifier(II, 0, IsModule, IsCPlusPlus);
3925class ASTIdentifierTableTrait {
3928 IdentifierResolver *IdResolver;
3938 return IsInterestingIdentifier(II, MacroOffset, IsModule,
3943 using key_type =
const IdentifierInfo *;
3944 using key_type_ref = key_type;
3947 using data_type_ref = data_type;
3949 using hash_value_type = unsigned;
3950 using offset_type = unsigned;
3952 ASTIdentifierTableTrait(ASTWriter &Writer, Preprocessor &PP,
3953 IdentifierResolver *IdResolver,
bool IsModule,
3955 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3956 NeedDecls(!IsModule || !Writer.getLangOpts().
CPlusPlus),
3957 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3959 bool needDecls()
const {
return NeedDecls; }
3961 static hash_value_type
ComputeHash(
const IdentifierInfo* II) {
3962 return llvm::djbHash(II->
getName());
3970 std::pair<unsigned, unsigned>
3971 EmitKeyDataLength(raw_ostream &Out,
const IdentifierInfo *II,
IdentifierID ID) {
3980 if (InterestingIdentifierOffsets &&
3982 InterestingIdentifierOffsets->push_back(
Out.tell());
3993 if (NeedDecls && IdResolver)
3994 DataLen += std::distance(IdResolver->
begin(II), IdResolver->
end()) *
4000 void EmitKey(raw_ostream &Out,
const IdentifierInfo *II,
unsigned KeyLen) {
4004 void EmitData(raw_ostream &Out,
const IdentifierInfo *II,
IdentifierID ID,
4006 using namespace llvm::support;
4008 endian::Writer
LE(Out, llvm::endianness::little);
4018 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
4021 bool HasMacroDefinition =
4024 Bits = (Bits << 1) |
unsigned(HasMacroDefinition);
4026 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
4031 if (HasMacroDefinition)
4034 if (NeedDecls && IdResolver) {
4041 SmallVector<NamedDecl *, 16> Decls(IdResolver->
decls(II));
4042 for (NamedDecl *D : llvm::reverse(Decls))
4060void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
4061 IdentifierResolver *IdResolver,
4063 using namespace llvm;
4065 RecordData InterestingIdents;
4070 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait>
Generator;
4071 ASTIdentifierTableTrait Trait(*
this, PP, IdResolver, IsModule,
4072 IsModule ? &InterestingIdents :
nullptr);
4076 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
4077 for (
auto IdentIDPair : IdentifierIDs) {
4078 const IdentifierInfo *II = IdentIDPair.first;
4080 assert(II &&
"NULL identifier in identifier table");
4085 (Trait.needDecls() &&
4091 SmallString<4096> IdentifierTable;
4094 using namespace llvm::support;
4096 llvm::raw_svector_ostream
Out(IdentifierTable);
4098 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
4099 BucketOffset =
Generator.Emit(Out, Trait);
4103 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4105 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
4106 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4107 unsigned IDTableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4111 Stream.EmitRecordWithBlob(IDTableAbbrev,
Record, IdentifierTable);
4115 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4117 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
4118 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4119 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4122 for (
unsigned I = 0, N = IdentifierOffsets.size(); I != N; ++I)
4123 assert(IdentifierOffsets[I] &&
"Missing identifier offset?");
4127 IdentifierOffsets.size()};
4128 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev,
Record,
4129 bytes(IdentifierOffsets));
4133 if (!InterestingIdents.empty())
4141 PendingEmittingVTables.push_back(RD);
4145 TouchedModuleFiles.insert(MF);
4154class ASTDeclContextNameLookupTraitBase {
4162 using data_type = std::pair<unsigned, unsigned>;
4163 using data_type_ref =
const data_type &;
4168 explicit ASTDeclContextNameLookupTraitBase(
ASTWriter &Writer)
4171 data_type getData(
const DeclIDsTy &LocalIDs) {
4172 unsigned Start = DeclIDs.size();
4173 for (
auto ID : LocalIDs)
4174 DeclIDs.push_back(ID);
4175 return std::make_pair(Start, DeclIDs.size());
4178 data_type ImportData(
const reader::ASTDeclContextNameLookupTrait::data_type &FromReader) {
4179 unsigned Start = DeclIDs.size();
4182 DeclIDIterator<GlobalDeclID, LocalDeclID>(FromReader.begin()),
4183 DeclIDIterator<GlobalDeclID, LocalDeclID>(FromReader.end()));
4184 return std::make_pair(Start, DeclIDs.size());
4187 void EmitFileRef(raw_ostream &Out, ModuleFile *F)
const {
4189 "have reference to loaded module file but no chain?");
4191 using namespace llvm::support;
4194 llvm::endianness::little);
4197 std::pair<unsigned, unsigned> EmitKeyDataLengthBase(raw_ostream &Out,
4198 DeclarationNameKey Name,
4199 data_type_ref Lookup) {
4200 unsigned KeyLen = 1;
4223 unsigned DataLen =
sizeof(
DeclID) * (Lookup.second - Lookup.first);
4225 return {KeyLen, DataLen};
4228 void EmitKeyBase(raw_ostream &Out, DeclarationNameKey Name) {
4229 using namespace llvm::support;
4231 endian::Writer
LE(Out, llvm::endianness::little);
4246 "Invalid operator?");
4256 llvm_unreachable(
"Invalid name kind?");
4259 void EmitDataBase(raw_ostream &Out, data_type Lookup,
unsigned DataLen) {
4260 using namespace llvm::support;
4262 endian::Writer
LE(Out, llvm::endianness::little);
4264 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
4266 assert(
Out.tell() - Start == DataLen &&
"Data length is wrong");
4270class ModuleLevelNameLookupTrait :
public ASTDeclContextNameLookupTraitBase {
4272 using primary_module_hash_type = unsigned;
4274 using key_type = std::pair<DeclarationNameKey, primary_module_hash_type>;
4275 using key_type_ref = key_type;
4277 explicit ModuleLevelNameLookupTrait(ASTWriter &Writer)
4278 : ASTDeclContextNameLookupTraitBase(Writer) {}
4280 static bool EqualKey(key_type_ref a, key_type_ref b) {
return a == b; }
4283 llvm::FoldingSetNodeID
ID;
4284 ID.AddInteger(Key.first.getHash());
4285 ID.AddInteger(Key.second);
4286 return ID.computeStableHash();
4289 std::pair<unsigned, unsigned>
4290 EmitKeyDataLength(raw_ostream &Out, key_type Key, data_type_ref Lookup) {
4291 auto [KeyLen, DataLen] = EmitKeyDataLengthBase(Out, Key.first, Lookup);
4292 KeyLen +=
sizeof(Key.second);
4296 void EmitKey(raw_ostream &Out, key_type Key,
unsigned) {
4297 EmitKeyBase(Out, Key.first);
4298 llvm::support::endian::Writer
LE(Out, llvm::endianness::little);
4299 LE.write<primary_module_hash_type>(Key.second);
4302 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4304 EmitDataBase(Out, Lookup, DataLen);
4308class ASTDeclContextNameTrivialLookupTrait
4309 :
public ASTDeclContextNameLookupTraitBase {
4311 using key_type = DeclarationNameKey;
4312 using key_type_ref = key_type;
4315 using ASTDeclContextNameLookupTraitBase::ASTDeclContextNameLookupTraitBase;
4317 using ASTDeclContextNameLookupTraitBase::getData;
4319 static bool EqualKey(key_type_ref a, key_type_ref b) {
return a == b; }
4321 hash_value_type
ComputeHash(key_type Name) {
return Name.getHash(); }
4323 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
4324 DeclarationNameKey Name,
4325 data_type_ref Lookup) {
4326 auto [KeyLen, DataLen] = EmitKeyDataLengthBase(Out, Name, Lookup);
4330 void EmitKey(raw_ostream &Out, DeclarationNameKey Name,
unsigned) {
4331 return EmitKeyBase(Out, Name);
4334 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4336 EmitDataBase(Out, Lookup, DataLen);
4340static bool isModuleLocalDecl(NamedDecl *D) {
4345 return isModuleLocalDecl(Parent);
4354 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
4372static bool isTULocalInNamedModules(NamedDecl *D) {
4395class ASTDeclContextNameLookupTrait
4396 :
public ASTDeclContextNameTrivialLookupTrait {
4398 using TULocalDeclsMapTy = llvm::DenseMap<key_type, DeclIDsTy>;
4400 using ModuleLevelDeclsMapTy =
4401 llvm::DenseMap<ModuleLevelNameLookupTrait::key_type, DeclIDsTy>;
4404 enum class LookupVisibility {
4414 LookupVisibility getLookupVisibility(NamedDecl *D)
const {
4417 return LookupVisibility::GenerallyVisibile;
4419 if (isModuleLocalDecl(D))
4420 return LookupVisibility::ModuleLocalVisible;
4421 if (isTULocalInNamedModules(D))
4422 return LookupVisibility::TULocal;
4434 if (
auto *ECD = dyn_cast<EnumConstantDecl>(D);
4435 ECD && DC.
isFileContext() && ECD->getTopLevelOwningNamedModule()) {
4440 return Found->isInvisibleOutsideTheOwningModule();
4442 return ECD->isFromExplicitGlobalModule() ||
4443 ECD->isInAnonymousNamespace()
4444 ? LookupVisibility::TULocal
4445 : LookupVisibility::ModuleLocalVisible;
4448 return LookupVisibility::GenerallyVisibile;
4452 ModuleLevelDeclsMapTy ModuleLocalDeclsMap;
4453 TULocalDeclsMapTy TULocalDeclsMap;
4456 using ASTDeclContextNameTrivialLookupTrait::
4457 ASTDeclContextNameTrivialLookupTrait;
4459 ASTDeclContextNameLookupTrait(ASTWriter &Writer, DeclContext &DC)
4460 : ASTDeclContextNameTrivialLookupTrait(Writer), DC(DC) {}
4462 template <
typename Coll> data_type getData(
const Coll &Decls) {
4463 unsigned Start = DeclIDs.size();
4464 auto AddDecl = [
this](NamedDecl *D) {
4465 NamedDecl *DeclForLocalLookup =
4481 switch (getLookupVisibility(DeclForLocalLookup)) {
4482 case LookupVisibility::ModuleLocalVisible:
4485 auto Key = std::make_pair(D->
getDeclName(), *PrimaryModuleHash);
4486 auto Iter = ModuleLocalDeclsMap.find(Key);
4487 if (Iter == ModuleLocalDeclsMap.end())
4488 ModuleLocalDeclsMap.insert({Key, DeclIDsTy{
ID}});
4490 Iter->second.push_back(ID);
4494 case LookupVisibility::TULocal: {
4495 auto Iter = TULocalDeclsMap.find(D->
getDeclName());
4496 if (Iter == TULocalDeclsMap.end())
4499 Iter->second.push_back(ID);
4502 case LookupVisibility::GenerallyVisibile:
4507 DeclIDs.push_back(ID);
4509 ASTReader *Chain = Writer.
getChain();
4510 for (NamedDecl *D : Decls) {
4521 for (
const auto &[_,
First] : Firsts)
4527 return std::make_pair(Start, DeclIDs.size());
4530 const ModuleLevelDeclsMapTy &getModuleLocalDecls() {
4531 return ModuleLocalDeclsMap;
4534 const TULocalDeclsMapTy &getTULocalDecls() {
return TULocalDeclsMap; }
4540class LazySpecializationInfoLookupTrait {
4542 llvm::SmallVector<serialization::reader::LazySpecializationInfo, 64> Specs;
4545 using key_type = unsigned;
4546 using key_type_ref = key_type;
4549 using data_type = std::pair<unsigned, unsigned>;
4550 using data_type_ref =
const data_type &;
4552 using hash_value_type = unsigned;
4553 using offset_type = unsigned;
4555 explicit LazySpecializationInfoLookupTrait(ASTWriter &Writer)
4558 template <
typename Col,
typename Col2>
4559 data_type getData(Col &&
C, Col2 &ExistingInfo) {
4560 unsigned Start = Specs.size();
4563 const_cast<NamedDecl *
>(D));
4568 Specs.push_back(Info);
4569 return std::make_pair(Start, Specs.size());
4572 data_type ImportData(
4574 unsigned Start = Specs.size();
4575 for (
auto ID : FromReader)
4576 Specs.push_back(ID);
4577 return std::make_pair(Start, Specs.size());
4580 static bool EqualKey(key_type_ref a, key_type_ref b) {
return a == b; }
4582 hash_value_type
ComputeHash(key_type Name) {
return Name; }
4584 void EmitFileRef(raw_ostream &Out, ModuleFile *F)
const {
4586 "have reference to loaded module file but no chain?");
4588 using namespace llvm::support;
4591 llvm::endianness::little);
4594 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
4596 data_type_ref Lookup) {
4598 unsigned KeyLen = 4;
4600 (Lookup.second - Lookup.first);
4605 void EmitKey(raw_ostream &Out, key_type HashValue,
unsigned) {
4606 using namespace llvm::support;
4608 endian::Writer
LE(Out, llvm::endianness::little);
4612 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4614 using namespace llvm::support;
4616 endian::Writer
LE(Out, llvm::endianness::little);
4619 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I) {
4620 LE.write<
DeclID>(Specs[I].getRawValue());
4622 assert(
Out.tell() - Start == DataLen &&
"Data length is wrong");
4626unsigned CalculateODRHashForSpecs(
const Decl *Spec) {
4627 ArrayRef<TemplateArgument> Args;
4628 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Spec))
4629 Args = CTSD->getTemplateArgs().asArray();
4630 else if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Spec))
4631 Args = VTSD->getTemplateArgs().asArray();
4632 else if (
auto *FD = dyn_cast<FunctionDecl>(Spec))
4633 Args = FD->getTemplateSpecializationArgs()->asArray();
4635 llvm_unreachable(
"New Specialization Kind?");
4641void ASTWriter::GenerateSpecializationInfoLookupTable(
4642 const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
4643 llvm::SmallVectorImpl<char> &LookupTable,
bool IsPartial) {
4647 MultiOnDiskHashTableGenerator<reader::LazySpecializationInfoLookupTrait,
4648 LazySpecializationInfoLookupTrait>
4650 LazySpecializationInfoLookupTrait Trait(*
this);
4652 llvm::MapVector<unsigned, llvm::SmallVector<const NamedDecl *, 4>>
4658 auto Iter = SpecializationMaps.find(HashedValue);
4659 if (Iter == SpecializationMaps.end())
4660 Iter = SpecializationMaps
4661 .try_emplace(HashedValue,
4662 llvm::SmallVector<const NamedDecl *, 4>())
4672 for (
auto &[HashValue, Specs] : SpecializationMaps) {
4673 SmallVector<serialization::reader::LazySpecializationInfo, 16>
4683 ExisitingSpecs = Lookups->Table.find(HashValue);
4685 Generator.insert(HashValue, Trait.getData(Specs, ExisitingSpecs), Trait);
4695 auto *ToEmitMaybeMergedLookupTable =
4696 (!isGeneratingReducedBMI() && Lookups) ? &Lookups->
Table :
nullptr;
4697 Generator.emit(LookupTable, Trait, ToEmitMaybeMergedLookupTable);
4700uint64_t ASTWriter::WriteSpecializationInfoLookupTable(
4701 const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
4704 llvm::SmallString<4096> LookupTable;
4705 GenerateSpecializationInfoLookupTable(D, Specializations, LookupTable,
4708 uint64_t Offset = Stream.GetCurrentBitNo();
4709 RecordData::value_type
Record[] = {
static_cast<RecordData::value_type
>(
4711 Stream.EmitRecordWithBlob(IsPartial ? DeclPartialSpecializationsAbbrev
4712 : DeclSpecializationsAbbrev,
4724 for (
auto *D :
Result.getLookupResult()) {
4726 if (LocalD->isFromASTFile())
4744void ASTWriter::GenerateNameLookupTable(
4745 ASTContext &Context,
const DeclContext *ConstDC,
4746 llvm::SmallVectorImpl<char> &LookupTable,
4747 llvm::SmallVectorImpl<char> &ModuleLocalLookupTable,
4748 llvm::SmallVectorImpl<char> &TULookupTable) {
4749 assert(!ConstDC->hasLazyLocalLexicalLookups() &&
4750 !ConstDC->hasLazyExternalLexicalLookups() &&
4751 "must call buildLookups first");
4754 auto *DC =
const_cast<DeclContext*
>(ConstDC);
4758 MultiOnDiskHashTableGenerator<reader::ASTDeclContextNameLookupTrait,
4759 ASTDeclContextNameLookupTrait>
4761 ASTDeclContextNameLookupTrait Trait(*
this, *DC);
4766 SmallVector<DeclarationName, 16> Names;
4770 bool IncludeConstructorNames =
false;
4771 bool IncludeConversionNames =
false;
4798 if (
Result.getLookupResult().empty())
4801 switch (Name.getNameKind()) {
4803 Names.push_back(Name);
4807 IncludeConstructorNames =
true;
4811 IncludeConversionNames =
true;
4819 if (IncludeConstructorNames || IncludeConversionNames) {
4824 llvm::SmallPtrSet<DeclarationName, 8> AddedNames;
4826 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
4827 auto Name = ChildND->getDeclName();
4828 switch (Name.getNameKind()) {
4833 if (!IncludeConstructorNames)
4838 if (!IncludeConversionNames)
4842 if (AddedNames.insert(Name).second)
4843 Names.push_back(Name);
4851 for (
auto &Name : Names)
4858 SmallVector<NamedDecl *, 8> ConstructorDecls;
4859 SmallVector<NamedDecl *, 8> ConversionDecls;
4863 for (
auto &Name : Names) {
4866 switch (Name.getNameKind()) {
4884 if (!ConstructorDecls.empty())
4885 Generator.insert(ConstructorDecls.front()->getDeclName(),
4886 Trait.getData(ConstructorDecls), Trait);
4887 if (!ConversionDecls.empty())
4888 Generator.insert(ConversionDecls.front()->getDeclName(),
4889 Trait.getData(ConversionDecls), Trait);
4901 auto *ToEmitMaybeMergedLookupTable =
4902 (!isGeneratingReducedBMI() && Lookups) ? &Lookups->
Table :
nullptr;
4903 Generator.emit(LookupTable, Trait, ToEmitMaybeMergedLookupTable);
4905 const auto &ModuleLocalDecls = Trait.getModuleLocalDecls();
4906 if (!ModuleLocalDecls.empty()) {
4907 MultiOnDiskHashTableGenerator<reader::ModuleLocalNameLookupTrait,
4908 ModuleLevelNameLookupTrait>
4909 ModuleLocalLookupGenerator;
4910 ModuleLevelNameLookupTrait ModuleLocalTrait(*
this);
4912 for (
const auto &ModuleLocalIter : ModuleLocalDecls) {
4913 const auto &Key = ModuleLocalIter.first;
4914 const auto &IDs = ModuleLocalIter.second;
4915 ModuleLocalLookupGenerator.insert(Key, ModuleLocalTrait.getData(IDs),
4921 auto *ModuleLocalLookups =
4922 (isGeneratingReducedBMI() && Chain &&
4926 ModuleLocalLookupGenerator.emit(ModuleLocalLookupTable, ModuleLocalTrait,
4927 ModuleLocalLookups);
4930 const auto &TULocalDecls = Trait.getTULocalDecls();
4931 if (!TULocalDecls.empty() && !isGeneratingReducedBMI()) {
4932 MultiOnDiskHashTableGenerator<reader::ASTDeclContextNameLookupTrait,
4933 ASTDeclContextNameTrivialLookupTrait>
4935 ASTDeclContextNameTrivialLookupTrait TULocalTrait(*
this);
4937 for (
const auto &TULocalIter : TULocalDecls) {
4938 const auto &Key = TULocalIter.first;
4939 const auto &IDs = TULocalIter.second;
4940 TULookupGenerator.insert(Key, TULocalTrait.getData(IDs), TULocalTrait);
4945 auto *TULocalLookups =
4949 TULookupGenerator.emit(TULookupTable, TULocalTrait, TULocalLookups);
4958void ASTWriter::WriteDeclContextVisibleBlock(
4959 ASTContext &Context, DeclContext *DC, VisibleLookupBlockOffsets &Offsets) {
4969 Prev = Prev->getPreviousDecl())
4970 if (!Prev->isFromASTFile())
4980 SmallVector<std::pair<DeclarationName, DeclContext::lookup_result>, 16>
4983 LookupResults.reserve(Map->size());
4984 for (
auto &Entry : *Map)
4985 LookupResults.push_back(
4986 std::make_pair(Entry.first, Entry.second.getLookupResult()));
4989 llvm::sort(LookupResults, llvm::less_first());
4990 for (
auto &NameAndResult : LookupResults) {
4991 DeclarationName Name = NameAndResult.first;
4998 assert(
Result.empty() &&
"Cannot have a constructor or conversion "
4999 "function name in a namespace!");
5003 for (NamedDecl *ND :
Result) {
5007 if (DoneWritingDeclsAndTypes && !wasDeclEmitted(ND))
5041 if (!Map || Map->empty())
5046 SmallString<4096> LookupTable;
5047 SmallString<4096> ModuleLocalLookupTable;
5048 SmallString<4096> TULookupTable;
5049 GenerateNameLookupTable(Context, DC, LookupTable, ModuleLocalLookupTable,
5054 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev,
Record,
5056 ++NumVisibleDeclContexts;
5058 if (!ModuleLocalLookupTable.empty()) {
5062 RecordData::value_type ModuleLocalRecord[] = {
5064 Stream.EmitRecordWithBlob(DeclModuleLocalVisibleLookupAbbrev,
5065 ModuleLocalRecord, ModuleLocalLookupTable);
5066 ++NumModuleLocalDeclContexts;
5069 if (!TULookupTable.empty()) {
5072 RecordData::value_type TULocalDeclsRecord[] = {
5074 Stream.EmitRecordWithBlob(DeclTULocalLookupAbbrev, TULocalDeclsRecord,
5076 ++NumTULocalDeclContexts;
5086void ASTWriter::WriteDeclContextVisibleUpdate(ASTContext &Context,
5087 const DeclContext *DC) {
5089 if (!Map || Map->empty())
5093 SmallString<4096> LookupTable;
5094 SmallString<4096> ModuleLocalLookupTable;
5095 SmallString<4096> TULookupTable;
5096 GenerateNameLookupTable(Context, DC, LookupTable, ModuleLocalLookupTable,
5107 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev,
Record, LookupTable);
5109 if (!ModuleLocalLookupTable.empty()) {
5111 RecordData::value_type ModuleLocalRecord[] = {
5113 Stream.EmitRecordWithBlob(ModuleLocalUpdateVisibleAbbrev, ModuleLocalRecord,
5114 ModuleLocalLookupTable);
5117 if (!TULookupTable.empty()) {
5118 RecordData::value_type GMFRecord[] = {
5120 Stream.EmitRecordWithBlob(TULocalUpdateVisibleAbbrev, GMFRecord,
5126void ASTWriter::WriteFPPragmaOptions(
const FPOptionsOverride &Opts) {
5132void ASTWriter::WriteOpenCLExtensions(Sema &SemaRef) {
5138 for (
const auto &I:Opts.OptMap) {
5139 AddString(I.getKey(),
Record);
5140 auto V = I.getValue();
5141 Record.push_back(
V.Supported ? 1 : 0);
5142 Record.push_back(
V.Enabled ? 1 : 0);
5143 Record.push_back(
V.WithPragma ? 1 : 0);
5150void ASTWriter::WriteCUDAPragmas(Sema &SemaRef) {
5151 if (SemaRef.
CUDA().ForceHostDeviceDepth > 0) {
5152 RecordData::value_type
Record[] = {SemaRef.
CUDA().ForceHostDeviceDepth};
5157void ASTWriter::WriteObjCCategories() {
5158 if (ObjCClassesWithCategories.empty())
5161 SmallVector<ObjCCategoriesInfo, 2> CategoriesMap;
5162 RecordData Categories;
5164 for (
unsigned I = 0, N = ObjCClassesWithCategories.size(); I != N; ++I) {
5166 unsigned StartIndex = Categories.size();
5168 ObjCInterfaceDecl *
Class = ObjCClassesWithCategories[I];
5171 Categories.push_back(0);
5175 Cat =
Class->known_categories_begin(),
5176 CatEnd =
Class->known_categories_end();
5177 Cat != CatEnd; ++Cat, ++Size) {
5178 assert(getDeclID(*Cat).isValid() &&
"Bogus category");
5179 AddDeclRef(*Cat, Categories);
5183 Categories[StartIndex] =
Size;
5186 ObjCCategoriesInfo CatInfo = { getDeclID(
Class), StartIndex };
5187 CategoriesMap.push_back(CatInfo);
5192 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
5195 using namespace llvm;
5197 auto Abbrev = std::make_shared<BitCodeAbbrev>();
5199 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
5200 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
5201 unsigned AbbrevID = Stream.EmitAbbrev(std::move(Abbrev));
5204 Stream.EmitRecordWithBlob(AbbrevID,
Record,
5205 reinterpret_cast<char *
>(CategoriesMap.data()),
5206 CategoriesMap.size() *
sizeof(ObjCCategoriesInfo));
5212void ASTWriter::WriteLateParsedTemplates(Sema &SemaRef) {
5219 for (
auto &LPTMapEntry : LPTMap) {
5220 const FunctionDecl *FD = LPTMapEntry.first;
5221 LateParsedTemplate &LPT = *LPTMapEntry.second;
5227 for (
const auto &
Tok : LPT.
Toks) {
5235void ASTWriter::WriteOptimizePragmaOptions(Sema &SemaRef) {
5238 AddSourceLocation(PragmaLoc,
Record);
5243void ASTWriter::WriteMSStructPragmaOptions(Sema &SemaRef) {
5251void ASTWriter::WriteMSPointersToMembersPragmaOptions(Sema &SemaRef) {
5259void ASTWriter::WritePackPragmaOptions(Sema &SemaRef) {
5270 AddAlignPackInfo(StackEntry.Value,
Record);
5271 AddSourceLocation(StackEntry.PragmaLocation,
Record);
5272 AddSourceLocation(StackEntry.PragmaPushLocation,
Record);
5273 AddString(StackEntry.StackSlotLabel,
Record);
5279void ASTWriter::WriteFloatControlPragmaOptions(Sema &SemaRef) {
5289 for (
const auto &StackEntry : SemaRef.
FpPragmaStack.Stack) {
5290 Record.push_back(StackEntry.Value.getAsOpaqueInt());
5291 AddSourceLocation(StackEntry.PragmaLocation,
Record);
5292 AddSourceLocation(StackEntry.PragmaPushLocation,
Record);
5293 AddString(StackEntry.StackSlotLabel,
Record);
5299void ASTWriter::WriteDeclsWithEffectsToVerify(Sema &SemaRef) {
5310void ASTWriter::WriteOpenMPRequiresDecls(Sema &SemaRef) {
5315 for (
const OMPRequiresDecl *D : Decls)
5322void ASTWriter::WriteModuleFileExtension(Sema &SemaRef,
5323 ModuleFileExtensionWriter &Writer) {
5328 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
5330 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5331 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5332 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5333 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5334 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
5335 unsigned Abbrev = Stream.EmitAbbrev(std::move(Abv));
5341 Record.push_back(Metadata.MajorVersion);
5342 Record.push_back(Metadata.MinorVersion);
5343 Record.push_back(Metadata.BlockName.size());
5344 Record.push_back(Metadata.UserInfo.size());
5345 SmallString<64> Buffer;
5346 Buffer += Metadata.BlockName;
5347 Buffer += Metadata.UserInfo;
5348 Stream.EmitRecordWithBlob(Abbrev,
Record, Buffer);
5357void ASTWriter::WriteRISCVIntrinsicPragmas(Sema &SemaRef) {
5372 auto &Record = *
this;
5378 Writer->isWritingStdCXXHeaderUnit())))
5379 return Record.push_back(0);
5381 Record.push_back(A->
getKind() + 1);
5385 Record.AddSourceRange(A->
getRange());
5389 Record.push_back(A->getAttributeSpellingListIndexRaw());
5392#include "clang/Serialization/AttrPCHWrite.inc"
5398 for (
const auto *A : Attrs)
5409 if (
Tok.isAnnotation()) {
5411 switch (
Tok.getKind()) {
5412 case tok::annot_pragma_loop_hint: {
5416 Record.push_back(Info->Toks.size());
5417 for (
const auto &
T : Info->Toks)
5421 case tok::annot_pragma_pack: {
5424 Record.push_back(
static_cast<unsigned>(Info->Action));
5430 case tok::annot_pragma_openmp:
5431 case tok::annot_pragma_openmp_end:
5432 case tok::annot_pragma_unused:
5433 case tok::annot_pragma_openacc:
5434 case tok::annot_pragma_openacc_end:
5435 case tok::annot_repl_input_end:
5438 llvm_unreachable(
"missing serialization code for annotation token");
5449 Record.push_back(Str.size());
5450 llvm::append_range(
Record, Str);
5455 Record.push_back(Str.size());
5456 llvm::append_range(Blob, Str);
5460 assert(WritingAST &&
"can't prepare path for output when not writing AST");
5463 StringRef PathStr(Path.data(), Path.size());
5464 if (PathStr ==
"<built-in>" || PathStr ==
"<command line>")
5468 PP->getFileManager().makeAbsolutePath(Path,
true);
5492 Stream.EmitRecordWithBlob(Abbrev,
Record, FilePath);
5497 Record.push_back(Version.getMajor());
5498 if (std::optional<unsigned> Minor = Version.getMinor())
5499 Record.push_back(*Minor + 1);
5502 if (std::optional<unsigned> Subminor = Version.getSubminor())
5503 Record.push_back(*Subminor + 1);
5521 assert(ID < IdentifierOffsets.size());
5522 IdentifierOffsets[ID] = Offset;
5528 unsigned ID = SelectorIDs[Sel];
5529 assert(ID &&
"Unknown selector");
5532 if (ID < FirstSelectorID)
5534 SelectorOffsets[ID - FirstSelectorID] = Offset;
5540 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
5541 bool IncludeTimestamps,
bool BuildingImplicitModule,
5542 bool GeneratingReducedBMI)
5543 : Stream(Stream), Buffer(Buffer), ModCache(ModCache),
5544 CodeGenOpts(CodeGenOpts), IncludeTimestamps(IncludeTimestamps),
5545 BuildingImplicitModule(BuildingImplicitModule),
5546 GeneratingReducedBMI(GeneratingReducedBMI) {
5547 for (
const auto &Ext : Extensions) {
5548 if (
auto Writer = Ext->createExtensionWriter(*
this))
5549 ModuleFileExtensionWriters.push_back(std::move(Writer));
5556 assert(WritingAST &&
"can't determine lang opts when not writing AST");
5557 return PP->getLangOpts();
5561 return IncludeTimestamps ? ModTime : 0;
5566 StringRef OutputFile,
Module *WritingModule,
5567 StringRef isysroot) {
5568 llvm::TimeTraceScope scope(
"WriteAST", OutputFile);
5571 Sema *SemaPtr = dyn_cast<Sema *>(Subject);
5578 Stream.Emit((
unsigned)
'C', 8);
5579 Stream.Emit((
unsigned)
'P', 8);
5580 Stream.Emit((
unsigned)
'C', 8);
5581 Stream.Emit((
unsigned)
'H', 8);
5583 WriteBlockInfoBlock();
5586 this->WritingModule = WritingModule;
5587 ASTFileSignature Signature = WriteASTCore(SemaPtr, isysroot, WritingModule);
5589 this->WritingModule =
nullptr;
5590 this->BaseDirectory.clear();
5597template<
typename Vector>
5599 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
5605template <
typename Vector>
5608 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
5614void ASTWriter::computeNonAffectingInputFiles() {
5615 SourceManager &SrcMgr = PP->getSourceManager();
5618 IsSLocAffecting.resize(N,
true);
5619 IsSLocFileEntryAffecting.resize(N,
true);
5624 auto AffectingModuleMaps = GetAffectingModuleMaps(*PP, WritingModule);
5626 unsigned FileIDAdjustment = 0;
5627 unsigned OffsetAdjustment = 0;
5629 NonAffectingFileIDAdjustments.reserve(N);
5630 NonAffectingOffsetAdjustments.reserve(N);
5632 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
5633 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
5635 for (
unsigned I = 1; I != N; ++I) {
5637 FileID FID = FileID::get(I);
5644 if (!
Cache->OrigEntry)
5652 if (!AffectingModuleMaps)
5656 if (AffectingModuleMaps->DefinitionFileIDs.contains(FID))
5659 IsSLocAffecting[I] =
false;
5660 IsSLocFileEntryAffecting[I] =
5661 AffectingModuleMaps->DefinitionFiles.contains(*
Cache->OrigEntry);
5663 FileIDAdjustment += 1;
5669 if (!NonAffectingFileIDs.empty() &&
5670 NonAffectingFileIDs.back().ID == FID.ID - 1) {
5671 NonAffectingFileIDs.back() = FID;
5673 NonAffectingFileIDAdjustments.back() = FileIDAdjustment;
5674 NonAffectingOffsetAdjustments.back() = OffsetAdjustment;
5678 NonAffectingFileIDs.push_back(FID);
5681 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
5682 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
5685 if (!PP->getHeaderSearchInfo().getHeaderSearchOpts().ModulesIncludeVFSUsage)
5688 FileManager &FileMgr = PP->getFileManager();
5691 for (StringRef Path :
5692 PP->getHeaderSearchInfo().getHeaderSearchOpts().VFSOverlayFiles)
5694 for (
unsigned I = 1; I != N; ++I) {
5695 if (IsSLocAffecting[I]) {
5701 if (!
Cache->OrigEntry)
5704 Cache->OrigEntry->getNameAsRequested());
5710void ASTWriter::prepareLazyUpdates() {
5713 if (!GeneratingReducedBMI)
5716 DeclUpdateMap DeclUpdatesTmp;
5724 for (
auto &DeclUpdate : DeclUpdates) {
5725 const Decl *D = DeclUpdate.first;
5727 for (
auto &
Update : DeclUpdate.second) {
5730 if (Kind == DeclUpdateKind::CXXAddedFunctionDefinition)
5731 DeclUpdatesTmp[D].push_back(
5732 ASTWriter::DeclUpdate(DeclUpdateKind::CXXAddedFunctionDefinition));
5734 DeclUpdatesLazy[D].push_back(
Update);
5737 DeclUpdates.swap(DeclUpdatesTmp);
5739 UpdatedDeclContextsLazy.swap(UpdatedDeclContexts);
5741 DeclsToEmitEvenIfUnreferenced.clear();
5744void ASTWriter::PrepareWritingSpecialDecls(
Sema &SemaRef) {
5745 ASTContext &Context = SemaRef.
Context;
5747 bool isModule = WritingModule !=
nullptr;
5749 prepareLazyUpdates();
5756 PredefinedDecls.insert(D);
5764 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
5768 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
5772 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
5774 RegisterPredefDecl(Context.BuiltinZOSVaListDecl,
5781 RegisterPredefDecl(Context.CFConstantStringTypeDecl,
5783 RegisterPredefDecl(Context.CFConstantStringTagDecl,
5785#define BuiltinTemplate(BTName) \
5786 RegisterPredefDecl(Context.Decl##BTName, PREDEF_DECL##BTName##_ID);
5787#include "clang/Basic/BuiltinTemplates.inc"
5799 if (GeneratingReducedBMI) {
5825 if (GeneratingReducedBMI)
5847 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I)
5852 SmallVector<const TypedefNameDecl *, 4> UnusedLocalTypedefs;
5854 for (
const TypedefNameDecl *TD : UnusedLocalTypedefs)
5861 "There are local ones at end of translation unit!");
5879 for (
const auto &I : SemaRef.KnownNamespaces)
5884 SmallVector<std::pair<NamedDecl *, SourceLocation>, 16>
Undefined;
5892 for (
const auto &DeleteExprsInfo :
5899 for (
const auto *I : DeclsToEmitEvenIfUnreferenced)
5901 DeclsToEmitEvenIfUnreferenced.clear();
5906 llvm::SmallVector<const IdentifierInfo*, 256> IIs;
5908 const IdentifierInfo *II =
ID.second;
5914 llvm::sort(IIs, llvm::deref<std::less<>>());
5916 for (
const IdentifierInfo *II : IIs)
5927 for (CXXRecordDecl *RD : PendingEmittingVTables)
5930 PendingEmittingVTables.clear();
5933void ASTWriter::WriteSpecialDeclRecords(
Sema &SemaRef) {
5934 ASTContext &Context = SemaRef.
Context;
5936 bool isModule = WritingModule !=
nullptr;
5939 if (!EagerlyDeserializedDecls.empty())
5942 if (!ModularCodegenDecls.empty())
5948 TentativeDefinitions);
5949 if (!TentativeDefinitions.empty())
5956 UnusedFileScopedDecls);
5957 if (!UnusedFileScopedDecls.empty())
5963 if (!ExtVectorDecls.empty())
5969 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I) {
5970 CXXRecordDecl *D = SemaRef.
VTableUses[I].first;
5984 SmallVector<const TypedefNameDecl *, 4> SortedCandidates;
5986 for (
const TypedefNameDecl *TD : SortedCandidates)
5988 if (!UnusedLocalTypedefNameCandidates.empty())
5990 UnusedLocalTypedefNameCandidates);
5992 if (!GeneratingReducedBMI) {
6002 if (!PendingInstantiations.empty())
6006 auto AddEmittedDeclRefOrZero = [
this](
RecordData &Refs,
Decl *D) {
6020 if (!SemaDeclRefs.empty())
6028 if (!DeclsToCheckForDeferredDiags.empty())
6030 DeclsToCheckForDeferredDiags);
6037 CudaCallDecl || CudaGetParamDecl || CudaLaunchDecl) {
6038 AddEmittedDeclRefOrZero(CUDASpecialDeclRefs, CudaCallDecl);
6039 AddEmittedDeclRefOrZero(CUDASpecialDeclRefs, CudaGetParamDecl);
6040 AddEmittedDeclRefOrZero(CUDASpecialDeclRefs, CudaLaunchDecl);
6048 DelegatingCtorDecls);
6049 if (!DelegatingCtorDecls.empty())
6054 for (
const auto &I : SemaRef.KnownNamespaces) {
6058 if (!KnownNamespaces.empty())
6063 SmallVector<std::pair<NamedDecl *, SourceLocation>, 16>
Undefined;
6072 if (!UndefinedButUsed.empty())
6079 for (
const auto &DeleteExprsInfo :
6084 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
6085 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
6086 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
6088 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
6092 if (!DeleteExprsToAnalyze.empty())
6096 for (CXXRecordDecl *RD : PendingEmittingVTables) {
6103 if (!VTablesToEmit.empty())
6109 using namespace llvm;
6111 bool isModule = WritingModule !=
nullptr;
6115 Chain->finalizeForWriting();
6119 computeNonAffectingInputFiles();
6121 writeUnhashedControlBlock(*PP);
6134 IdentifierIDs.clear();
6145 SmallVector<const IdentifierInfo *, 128> IIs;
6146 for (
const auto &ID : PP->getIdentifierTable())
6147 if (IsInterestingNonMacroIdentifier(
ID.second, *
this))
6148 IIs.push_back(
ID.second);
6151 llvm::sort(IIs, llvm::deref<std::less<>>());
6152 for (
const IdentifierInfo *II : IIs)
6160 for (
const auto &WeakUndeclaredIdentifierList :
6162 const IdentifierInfo *
const II = WeakUndeclaredIdentifierList.first;
6163 for (
const auto &WI : WeakUndeclaredIdentifierList.second) {
6176 ASTContext &Context = SemaPtr->
Context;
6178 Context, *
this, ExtnameUndeclaredIdentifiers);
6180 ExtnameUndeclaredIdentifiersWriter.AddIdentifierRef(II);
6181 ExtnameUndeclaredIdentifiersWriter.AddIdentifierRef(
6183 ExtnameUndeclaredIdentifiersWriter.AddSourceLocation(AL->getLocation());
6190 ASTContext &Context = SemaPtr->
Context;
6195 AddTypeRef(Context, Context.ObjCIdRedefinitionType, SpecialTypes);
6196 AddTypeRef(Context, Context.ObjCClassRedefinitionType, SpecialTypes);
6197 AddTypeRef(Context, Context.ObjCSelRedefinitionType, SpecialTypes);
6202 PrepareWritingSpecialDecls(*SemaPtr);
6205 WriteControlBlock(*PP, isysroot);
6208 Stream.FlushToWord();
6209 ASTBlockRange.first = Stream.GetCurrentBitNo() >> 3;
6211 ASTBlockStartOffset = Stream.GetCurrentBitNo();
6228 llvm::SmallVector<Selector, 256> AllSelectors;
6229 for (
auto &SelectorAndID : SelectorIDs)
6230 AllSelectors.push_back(SelectorAndID.first);
6231 for (
auto &Selector : AllSelectors)
6255 auto Abbrev = std::make_shared<BitCodeAbbrev>();
6257 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
6258 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
6259 SmallString<2048> Buffer;
6261 llvm::raw_svector_ostream
Out(Buffer);
6262 for (ModuleFile &M : Chain->ModuleMgr) {
6263 using namespace llvm::support;
6265 endian::Writer
LE(Out, llvm::endianness::little);
6273 Out.write(Name.data(), Name.size());
6279 auto writeBaseIDOrNone = [&](
auto BaseID,
bool ShouldWrite) {
6280 assert(BaseID < std::numeric_limits<uint32_t>::max() &&
"base id too high");
6294 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev,
Record,
6295 Buffer.data(), Buffer.size());
6299 WriteDeclAndTypes(SemaPtr->
Context);
6301 WriteFileDeclIDsMap();
6302 WriteSourceManagerBlock(PP->getSourceManager());
6304 WriteComments(SemaPtr->
Context);
6305 WritePreprocessor(*PP, isModule);
6306 WriteHeaderSearch(PP->getHeaderSearchInfo());
6308 WriteSelectors(*SemaPtr);
6309 WriteReferencedSelectorsPool(*SemaPtr);
6310 WriteLateParsedTemplates(*SemaPtr);
6312 WriteIdentifierTable(*PP, SemaPtr ? &SemaPtr->
IdResolver :
nullptr, isModule);
6315 WriteOpenCLExtensions(*SemaPtr);
6316 WriteCUDAPragmas(*SemaPtr);
6317 WriteRISCVIntrinsicPragmas(*SemaPtr);
6322 WriteSubmodules(WritingModule, SemaPtr ? &SemaPtr->
Context :
nullptr);
6327 WriteSpecialDeclRecords(*SemaPtr);
6330 if (!WeakUndeclaredIdentifiers.empty())
6332 WeakUndeclaredIdentifiers);
6336 if (!ExtnameUndeclaredIdentifiers.empty())
6338 ExtnameUndeclaredIdentifiers);
6340 if (!WritingModule) {
6345 ModuleInfo(uint64_t ID,
Module *M) :
ID(
ID), M(M) {}
6347 llvm::SmallVector<ModuleInfo, 64> Imports;
6350 assert(SubmoduleIDs.contains(I->getImportedModule()));
6351 Imports.push_back(ModuleInfo(SubmoduleIDs[I->getImportedModule()],
6352 I->getImportedModule()));
6356 if (!Imports.empty()) {
6357 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
6360 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
6361 return A.ID == B.ID;
6365 llvm::sort(Imports,
Cmp);
6366 Imports.erase(llvm::unique(Imports, Eq), Imports.end());
6369 for (
const auto &Import : Imports) {
6370 ImportedModules.push_back(
Import.ID);
6381 WriteObjCCategories();
6383 if (!WritingModule) {
6384 WriteOptimizePragmaOptions(*SemaPtr);
6385 WriteMSStructPragmaOptions(*SemaPtr);
6386 WriteMSPointersToMembersPragmaOptions(*SemaPtr);
6388 WritePackPragmaOptions(*SemaPtr);
6389 WriteFloatControlPragmaOptions(*SemaPtr);
6390 WriteDeclsWithEffectsToVerify(*SemaPtr);
6391 WriteOpenMPRequiresDecls(*SemaPtr);
6395 RecordData::value_type
Record[] = {NumStatements,
6397 NumLexicalDeclContexts,
6398 NumVisibleDeclContexts,
6399 NumModuleLocalDeclContexts,
6400 NumTULocalDeclContexts};
6403 Stream.FlushToWord();
6404 ASTBlockRange.second = Stream.GetCurrentBitNo() >> 3;
6408 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
6409 WriteModuleFileExtension(*SemaPtr, *ExtWriter);
6411 return backpatchSignature();
6417void ASTWriter::AddedManglingNumber(
const Decl *D,
unsigned Number) {
6421 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::ManglingNumber, Number));
6423void ASTWriter::AddedStaticLocalNumbers(
const Decl *D,
unsigned Number) {
6427 DeclUpdates[D].push_back(
6428 DeclUpdate(DeclUpdateKind::StaticLocalNumber, Number));
6437 ASTWriter::UpdateRecord &
Record = DeclUpdates[TU];
6440 DeclUpdate(DeclUpdateKind::CXXAddedAnonymousNamespace, NS));
6444void ASTWriter::WriteDeclAndTypes(
ASTContext &Context) {
6449 DeclTypesBlockStartOffset = Stream.GetCurrentBitNo();
6453 WriteDeclUpdatesBlocks(Context, DeclUpdatesOffsetsRecord);
6454 while (!DeclTypesToEmit.empty()) {
6455 DeclOrType DOT = DeclTypesToEmit.front();
6456 DeclTypesToEmit.pop();
6458 WriteType(Context, DOT.getType());
6460 WriteDecl(Context, DOT.getDecl());
6462 }
while (!DeclUpdates.empty());
6464 DoneWritingDeclsAndTypes =
true;
6468 assert(DelayedNamespace.empty() || GeneratingReducedBMI);
6470 for (NamespaceDecl *NS : DelayedNamespace) {
6471 LookupBlockOffsets Offsets;
6473 Offsets.
LexicalOffset = WriteDeclContextLexicalBlock(Context, NS);
6474 WriteDeclContextVisibleBlock(Context, NS, Offsets);
6495 assert(DeclTypesToEmit.empty());
6496 assert(DeclUpdates.empty());
6501 WriteTypeDeclOffsets();
6502 if (!DeclUpdatesOffsetsRecord.empty())
6505 if (!DelayedNamespaceRecord.empty())
6507 DelayedNamespaceRecord);
6509 if (!RelatedDeclsMap.empty()) {
6513 for (
const auto &Pair : RelatedDeclsMap) {
6514 RelatedDeclsMapRecord.push_back(Pair.first.getRawValue());
6515 RelatedDeclsMapRecord.push_back(Pair.second.size());
6516 for (
const auto &Lambda : Pair.second)
6517 RelatedDeclsMapRecord.push_back(Lambda.getRawValue());
6520 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6522 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Array));
6523 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6524 unsigned FunctionToLambdaMapAbbrev = Stream.EmitAbbrev(std::move(Abv));
6526 FunctionToLambdaMapAbbrev);
6529 if (!SpecializationsUpdates.empty()) {
6530 WriteSpecializationsUpdates(
false);
6531 SpecializationsUpdates.clear();
6534 if (!PartialSpecializationsUpdates.empty()) {
6535 WriteSpecializationsUpdates(
true);
6536 PartialSpecializationsUpdates.clear();
6542 SmallVector<DeclID, 128> NewGlobalKindDeclPairs;
6551 NewGlobalKindDeclPairs.push_back(D->
getKind());
6552 NewGlobalKindDeclPairs.push_back(
GetDeclRef(D).getRawValue());
6555 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6557 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6558 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
6561 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev,
Record,
6562 bytes(NewGlobalKindDeclPairs));
6564 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6566 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6567 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6568 UpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6570 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6572 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6573 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6574 ModuleLocalUpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6576 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6578 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6579 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6580 TULocalUpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6583 WriteDeclContextVisibleUpdate(Context, TU);
6586 if (Context.ExternCContext)
6587 WriteDeclContextVisibleUpdate(Context, Context.ExternCContext);
6590 for (
auto *DC : UpdatedDeclContexts)
6591 WriteDeclContextVisibleUpdate(Context, DC);
6594void ASTWriter::WriteSpecializationsUpdates(
bool IsPartial) {
6598 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6599 Abv->Add(llvm::BitCodeAbbrevOp(RecordType));
6600 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6601 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6602 auto UpdateSpecializationAbbrev = Stream.EmitAbbrev(std::move(Abv));
6605 IsPartial ? PartialSpecializationsUpdates : SpecializationsUpdates;
6606 for (
auto &SpecializationUpdate : SpecUpdates) {
6607 const NamedDecl *D = SpecializationUpdate.first;
6609 llvm::SmallString<4096> LookupTable;
6610 GenerateSpecializationInfoLookupTable(D, SpecializationUpdate.second,
6611 LookupTable, IsPartial);
6614 RecordData::value_type
Record[] = {
6615 static_cast<RecordData::value_type
>(RecordType),
6617 Stream.EmitRecordWithBlob(UpdateSpecializationAbbrev,
Record, LookupTable);
6621void ASTWriter::WriteDeclUpdatesBlocks(
ASTContext &Context,
6622 RecordDataImpl &OffsetsRecord) {
6623 if (DeclUpdates.empty())
6626 DeclUpdateMap LocalUpdates;
6627 LocalUpdates.swap(DeclUpdates);
6629 for (
auto &DeclUpdate : LocalUpdates) {
6630 const Decl *D = DeclUpdate.first;
6632 bool HasUpdatedBody =
false;
6633 bool HasAddedVarDefinition =
false;
6636 for (
auto &
Update : DeclUpdate.second) {
6641 if (Kind == DeclUpdateKind::CXXAddedFunctionDefinition)
6642 HasUpdatedBody =
true;
6643 else if (Kind == DeclUpdateKind::CXXAddedVarDefinition)
6644 HasAddedVarDefinition =
true;
6646 Record.push_back(llvm::to_underlying(Kind));
6649 case DeclUpdateKind::CXXAddedImplicitMember:
6650 case DeclUpdateKind::CXXAddedAnonymousNamespace:
6651 assert(
Update.getDecl() &&
"no decl to add?");
6654 case DeclUpdateKind::CXXAddedFunctionDefinition:
6655 case DeclUpdateKind::CXXAddedVarDefinition:
6658 case DeclUpdateKind::CXXPointOfInstantiation:
6663 case DeclUpdateKind::CXXInstantiatedDefaultArgument:
6668 case DeclUpdateKind::CXXInstantiatedDefaultMemberInitializer:
6673 case DeclUpdateKind::CXXInstantiatedClassDefinition: {
6675 UpdatedDeclContexts.insert(RD->getPrimaryContext());
6676 Record.push_back(RD->isParamDestroyedInCallee());
6677 Record.push_back(llvm::to_underlying(RD->getArgPassingRestrictions()));
6678 Record.AddCXXDefinitionData(RD);
6679 Record.AddOffset(WriteDeclContextLexicalBlock(Context, RD));
6684 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
6685 Record.push_back(MSInfo->getTemplateSpecializationKind());
6686 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
6689 Record.push_back(Spec->getTemplateSpecializationKind());
6690 Record.AddSourceLocation(Spec->getPointOfInstantiation());
6694 auto From = Spec->getInstantiatedFrom();
6695 if (
auto PartialSpec =
6696 From.dyn_cast<ClassTemplatePartialSpecializationDecl*>()) {
6698 Record.AddDeclRef(PartialSpec);
6699 Record.AddTemplateArgumentList(
6700 &Spec->getTemplateInstantiationArgs());
6705 Record.push_back(llvm::to_underlying(RD->getTagKind()));
6706 Record.AddSourceLocation(RD->getLocation());
6707 Record.AddSourceLocation(RD->getBeginLoc());
6708 Record.AddSourceRange(RD->getBraceRange());
6719 case DeclUpdateKind::CXXResolvedDtorDelete:
6724 case DeclUpdateKind::CXXResolvedDtorGlobDelete:
6728 case DeclUpdateKind::CXXResolvedDtorArrayDelete:
6732 case DeclUpdateKind::CXXResolvedDtorGlobArrayDelete:
6736 case DeclUpdateKind::CXXResolvedExceptionSpec: {
6739 Record.writeExceptionSpecInfo(prototype->getExceptionSpecInfo());
6743 case DeclUpdateKind::CXXDeducedReturnType:
6747 case DeclUpdateKind::DeclMarkedUsed:
6750 case DeclUpdateKind::ManglingNumber:
6751 case DeclUpdateKind::StaticLocalNumber:
6755 case DeclUpdateKind::DeclMarkedOpenMPThreadPrivate:
6757 D->
getAttr<OMPThreadPrivateDeclAttr>()->getRange());
6760 case DeclUpdateKind::DeclMarkedOpenMPAllocate: {
6761 auto *A = D->
getAttr<OMPAllocateDeclAttr>();
6762 Record.push_back(A->getAllocatorType());
6763 Record.AddStmt(A->getAllocator());
6764 Record.AddStmt(A->getAlignment());
6765 Record.AddSourceRange(A->getRange());
6769 case DeclUpdateKind::DeclMarkedOpenMPIndirectCall:
6771 D->
getAttr<OMPTargetIndirectCallAttr>()->getRange());
6774 case DeclUpdateKind::DeclMarkedOpenMPDeclareTarget:
6775 Record.push_back(D->
getAttr<OMPDeclareTargetDeclAttr>()->getMapType());
6777 D->
getAttr<OMPDeclareTargetDeclAttr>()->getRange());
6780 case DeclUpdateKind::DeclExported:
6784 case DeclUpdateKind::AddedAttrToRecord:
6785 Record.AddAttributes(llvm::ArrayRef(
Update.getAttr()));
6793 if (HasUpdatedBody) {
6796 llvm::to_underlying(DeclUpdateKind::CXXAddedFunctionDefinition));
6797 Record.push_back(Def->isInlined());
6798 Record.AddSourceLocation(Def->getInnerLocStart());
6799 Record.AddFunctionDefinition(Def);
6800 }
else if (HasAddedVarDefinition) {
6803 llvm::to_underlying(DeclUpdateKind::CXXAddedVarDefinition));
6804 Record.push_back(VD->isInline());
6805 Record.push_back(VD->isInlineSpecified());
6806 Record.AddVarDeclInit(VD);
6823 NonAffectingFileIDs.empty())
6825 auto It = llvm::lower_bound(NonAffectingFileIDs, FID);
6826 unsigned Idx = std::distance(NonAffectingFileIDs.begin(), It);
6827 unsigned Offset = NonAffectingFileIDAdjustments[Idx];
6831unsigned ASTWriter::getAdjustedNumCreatedFIDs(
FileID FID)
const {
6837 unsigned AdjustedNumCreatedFIDs = 0;
6838 for (
unsigned I = FID.ID, N = I + NumCreatedFIDs; I != N; ++I)
6839 if (IsSLocAffecting[I])
6840 ++AdjustedNumCreatedFIDs;
6841 return AdjustedNumCreatedFIDs;
6851 return SourceRange(getAdjustedLocation(
Range.getBegin()),
6852 getAdjustedLocation(
Range.getEnd()));
6857 return Offset - getAdjustment(Offset);
6862 if (NonAffectingRanges.empty())
6865 if (PP->getSourceManager().isLoadedOffset(Offset))
6868 if (Offset > NonAffectingRanges.back().getEnd().getOffset())
6869 return NonAffectingOffsetAdjustments.back();
6871 if (Offset < NonAffectingRanges.front().getBegin().getOffset())
6875 return Range.getEnd().getOffset() < Offset;
6878 auto It = llvm::lower_bound(NonAffectingRanges, Offset, Contains);
6879 unsigned Idx = std::distance(NonAffectingRanges.begin(), It);
6880 return NonAffectingOffsetAdjustments[Idx];
6884 Record.push_back(getAdjustedFileID(FID).getOpaqueValue());
6890 unsigned ModuleFileIndex = 0;
6893 if (PP->getSourceManager().isLoadedSourceLocation(Loc) && Loc.
isValid()) {
6896 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
6897 assert(SLocMapI !=
getChain()->GlobalSLocOffsetMap.end() &&
6898 "Corrupted global sloc offset map");
6903 ModuleFileIndex = F->
Index + 1;
6913 return getAdjustedOffset(SLoc.
getOffset()) - 2;
6920 Record.push_back(Offset);
6938 Loc = getAdjustedLocation(Loc);
6983 MacroInfoToEmitData Info = { Name, MI, ID };
6984 MacroInfosToEmit.push_back(Info);
6990 return IdentMacroDirectivesOffsetMap.lookup(Name);
6994 Record->push_back(Writer->getSelectorRef(SelRef));
7003 if (SID == 0 && Chain) {
7006 Chain->LoadSelector(Sel);
7007 SID = SelectorIDs[Sel];
7010 SID = NextSelectorID++;
7011 SelectorIDs[Sel] = SID;
7053 bool InfoHasSameExpr
7055 Record->push_back(InfoHasSameExpr);
7056 if (InfoHasSameExpr)
7073 TypeLocWriter TLW(*
this);
7083template <
typename IdxForTypeTy>
7085 IdxForTypeTy IdxForType) {
7089 unsigned FastQuals =
T.getLocalFastQualifiers();
7090 T.removeLocalFastQualifiers();
7092 if (
T.hasLocalNonFastQualifiers())
7093 return IdxForType(
T).asTypeID(FastQuals);
7095 assert(!
T.hasLocalQualifiers());
7097 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(
T.getTypePtr()))
7100 if (
T == Context.AutoDeductTy)
7102 if (
T == Context.AutoRRefDeductTy)
7105 return IdxForType(
T).asTypeID(FastQuals);
7112 assert(!
T.getLocalFastQualifiers());
7116 if (DoneWritingDeclsAndTypes) {
7117 assert(0 &&
"New type seen after serializing all the types to emit!");
7123 Idx =
TypeIdx(0, NextTypeID++);
7124 DeclTypesToEmit.push(
T);
7130llvm::MapVector<ModuleFile *, const Decl *>
7132 llvm::MapVector<ModuleFile *, const Decl *> Firsts;
7135 if (R->isFromASTFile())
7136 Firsts[Chain->getOwningModuleFile(R)] = R;
7137 else if (IncludeLocal)
7138 Firsts[
nullptr] = R;
7154 Record.push_back(MacroRef >> 32);
7155 Record.push_back(MacroRef & llvm::maskTrailingOnes<MacroID>(32));
7170 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
7187 assert(!(
reinterpret_cast<uintptr_t>(D) & 0x01) &&
"Invalid decl pointer");
7189 if (ID.isInvalid()) {
7190 if (DoneWritingDeclsAndTypes) {
7191 assert(0 &&
"New decl seen after serializing all the decls to emit!");
7198 DeclTypesToEmit.push(
const_cast<Decl *
>(D));
7213 assert(DeclIDs.contains(D) &&
"Declaration not emitted!");
7220 assert(DoneWritingDeclsAndTypes &&
7221 "wasDeclEmitted should only be called after writing declarations");
7226 bool Emitted = DeclIDs.contains(D);
7228 GeneratingReducedBMI) &&
7229 "The declaration within modules can only be omitted in reduced BMI.");
7233void ASTWriter::getLazyUpdates(
const Decl *D) {
7234 if (!GeneratingReducedBMI)
7237 if (
auto *Iter = DeclUpdatesLazy.find(D); Iter != DeclUpdatesLazy.end()) {
7238 for (DeclUpdate &
Update : Iter->second)
7239 DeclUpdates[D].push_back(
Update);
7240 DeclUpdatesLazy.erase(Iter);
7244 if (
auto *DC = dyn_cast<DeclContext>(D);
7245 DC && UpdatedDeclContextsLazy.count(DC)) {
7246 UpdatedDeclContexts.insert(DC);
7247 UpdatedDeclContextsLazy.remove(DC);
7252 assert(
ID.isValid());
7269 SourceManager &SM = PP->getSourceManager();
7276 assert(IsSLocAffecting[FID.ID]);
7278 std::unique_ptr<DeclIDInFileInfo> &Info = FileDeclIDs[FID];
7280 Info = std::make_unique<DeclIDInFileInfo>();
7282 std::pair<unsigned, LocalDeclID> LocDecl(Offset, ID);
7283 LocDeclIDsTy &Decls = Info->DeclIDs;
7284 Decls.push_back(LocDecl);
7289 "expected an anonymous declaration");
7293 auto It = AnonymousDeclarationNumbers.find(D);
7294 if (It == AnonymousDeclarationNumbers.end()) {
7297 AnonymousDeclarationNumbers[ND] = Number;
7300 It = AnonymousDeclarationNumbers.find(D);
7301 assert(It != AnonymousDeclarationNumbers.end() &&
7302 "declaration not found within its lexical context");
7357 while (QualifierLoc) {
7358 NestedNames.push_back(QualifierLoc);
7362 Record->push_back(NestedNames.size());
7363 while(!NestedNames.empty()) {
7364 QualifierLoc = NestedNames.pop_back_val();
7367 Record->push_back(llvm::to_underlying(Kind));
7370 AddDeclRef(Qualifier.getAsNamespaceAndPrefix().Namespace);
7392 llvm_unreachable(
"unexpected null nested name specifier");
7399 assert(TemplateParams &&
"No TemplateParams!");
7404 Record->push_back(TemplateParams->
size());
7405 for (
const auto &P : *TemplateParams)
7408 Record->push_back(
true);
7411 Record->push_back(
false);
7418 assert(TemplateArgs &&
"No TemplateArgs!");
7419 Record->push_back(TemplateArgs->
size());
7420 for (
int i = 0, e = TemplateArgs->
size(); i != e; ++i)
7426 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
7436 Record->push_back(
Set.size());
7438 I =
Set.begin(), E =
Set.end(); I != E; ++I) {
7440 Record->push_back(I.getAccess());
7446 Record->push_back(
Base.isVirtual());
7447 Record->push_back(
Base.isBaseOfClass());
7448 Record->push_back(
Base.getAccessSpecifierAsWritten());
7449 Record->push_back(
Base.getInheritConstructors());
7462 for (
auto &
Base : Bases)
7480 for (
auto *
Init : CtorInits) {
7481 if (
Init->isBaseInitializer()) {
7485 }
else if (
Init->isDelegatingInitializer()) {
7488 }
else if (
Init->isMemberInitializer()){
7501 if (
Init->isWritten())
7515 auto &
Data = D->data();
7517 Record->push_back(
Data.IsLambda);
7521#define FIELD(Name, Width, Merge) \
7522 if (!DefinitionBits.canWriteNextNBits(Width)) { \
7523 Record->push_back(DefinitionBits); \
7524 DefinitionBits.reset(0); \
7526 DefinitionBits.addBits(Data.Name, Width);
7528#include "clang/AST/CXXRecordDeclDefinitionBits.def"
7531 Record->push_back(DefinitionBits);
7537 bool ModulesCodegen =
7542 Record->push_back(ModulesCodegen);
7544 Writer->AddDeclRef(D, Writer->ModularCodegenDecls);
7549 Record->push_back(
Data.ComputedVisibleConversions);
7550 if (
Data.ComputedVisibleConversions)
7554 if (!
Data.IsLambda) {
7555 Record->push_back(
Data.NumBases);
7556 if (
Data.NumBases > 0)
7560 Record->push_back(
Data.NumVBases);
7561 if (
Data.NumVBases > 0)
7566 auto &Lambda = D->getLambdaData();
7569 LambdaBits.
addBits(Lambda.DependencyKind, 2);
7570 LambdaBits.
addBit(Lambda.IsGenericLambda);
7571 LambdaBits.
addBits(Lambda.CaptureDefault, 2);
7572 LambdaBits.
addBits(Lambda.NumCaptures, 15);
7573 LambdaBits.
addBit(Lambda.HasKnownInternalLinkage);
7574 Record->push_back(LambdaBits);
7576 Record->push_back(Lambda.NumExplicitCaptures);
7577 Record->push_back(Lambda.ManglingNumber);
7582 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
7589 Record->push_back(CaptureBits);
7591 switch (
Capture.getCaptureKind()) {
7621 assert(ES->CheckedForSideEffects);
7622 Val |= (ES->HasConstantInitialization ? 2 : 0);
7623 Val |= (ES->HasConstantDestruction ? 4 : 0);
7637void ASTWriter::ReaderInitialized(
ASTReader *Reader) {
7638 assert(Reader &&
"Cannot remove chain");
7639 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
7640 assert(FirstDeclID == NextDeclID &&
7641 FirstTypeID == NextTypeID &&
7642 FirstIdentID == NextIdentID &&
7643 FirstMacroID == NextMacroID &&
7644 FirstSubmoduleID == NextSubmoduleID &&
7645 FirstSelectorID == NextSelectorID &&
7646 "Setting chain after writing has started.");
7652 NextSelectorID = FirstSelectorID;
7653 NextSubmoduleID = FirstSubmoduleID;
7663 unsigned OriginalModuleFileIndex = StoredID >> 32;
7667 if (OriginalModuleFileIndex == 0 && StoredID)
7678 MacroID &StoredID = MacroIDs[MI];
7679 unsigned OriginalModuleFileIndex = StoredID >> 32;
7682 if (OriginalModuleFileIndex == 0 && StoredID)
7691void ASTWriter::TypeRead(TypeIdx Idx,
QualType T) {
7703 TypeIdx &StoredIdx = TypeIdxs[
T];
7709 if (ModuleFileIndex == 0 && StoredIdx.
getValue())
7720 DeclIDs[D] = LocalDeclID(ID);
7721 PredefinedDecls.insert(D);
7733 assert(!MacroDefinitions.contains(MD));
7734 MacroDefinitions[MD] =
ID;
7738 assert(!SubmoduleIDs.contains(Mod));
7739 SubmoduleIDs[Mod] =
ID;
7742void ASTWriter::CompletedTagDefinition(
const TagDecl *D) {
7743 if (Chain && Chain->isProcessingUpdateRecords())
return;
7745 assert(!WritingAST &&
"Already writing the AST!");
7746 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
7748 if (RD->isFromASTFile()) {
7753 "completed a tag from another module but not by instantiation?");
7754 DeclUpdates[RD].push_back(
7755 DeclUpdate(DeclUpdateKind::CXXInstantiatedClassDefinition));
7769void ASTWriter::AddedVisibleDecl(
const DeclContext *DC,
const Decl *D) {
7770 if (Chain && Chain->isProcessingUpdateRecords())
return;
7772 "Should not add lookup results to non-lookup contexts!");
7793 assert(!WritingAST &&
"Already writing the AST!");
7794 if (UpdatedDeclContexts.insert(DC) && !
cast<Decl>(DC)->isFromASTFile()) {
7798 llvm::append_range(DeclsToEmitEvenIfUnreferenced, DC->
decls());
7800 DeclsToEmitEvenIfUnreferenced.push_back(D);
7804 if (Chain && Chain->isProcessingUpdateRecords())
return;
7817 assert(!WritingAST &&
"Already writing the AST!");
7818 DeclUpdates[RD].push_back(
7819 DeclUpdate(DeclUpdateKind::CXXAddedImplicitMember, D));
7822void ASTWriter::ResolvedExceptionSpec(
const FunctionDecl *FD) {
7823 if (Chain && Chain->isProcessingUpdateRecords())
return;
7824 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
7826 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
7831 ->castAs<FunctionProtoType>()
7832 ->getExceptionSpecType()))
7833 DeclUpdates[D].push_back(DeclUpdateKind::CXXResolvedExceptionSpec);
7838 if (Chain && Chain->isProcessingUpdateRecords())
return;
7839 assert(!WritingAST &&
"Already writing the AST!");
7841 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
7842 DeclUpdates[D].push_back(
7843 DeclUpdate(DeclUpdateKind::CXXDeducedReturnType, ReturnType));
7850 if (Chain && Chain->isProcessingUpdateRecords())
return;
7851 assert(!WritingAST &&
"Already writing the AST!");
7852 assert(
Delete &&
"Not given an operator delete");
7854 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7855 DeclUpdates[D].push_back(
7856 DeclUpdate(DeclUpdateKind::CXXResolvedDtorDelete,
Delete));
7862 if (Chain && Chain->isProcessingUpdateRecords())
7864 assert(!WritingAST &&
"Already writing the AST!");
7865 assert(GlobDelete &&
"Not given an operator delete");
7868 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7869 DeclUpdates[D].push_back(
7870 DeclUpdate(DeclUpdateKind::CXXResolvedDtorGlobDelete, GlobDelete));
7876 if (Chain && Chain->isProcessingUpdateRecords())
7878 assert(!WritingAST &&
"Already writing the AST!");
7879 assert(ArrayDelete &&
"Not given an operator delete");
7882 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7883 DeclUpdates[D].push_back(
7884 DeclUpdate(DeclUpdateKind::CXXResolvedDtorArrayDelete, ArrayDelete));
7888void ASTWriter::ResolvedOperatorGlobArrayDelete(
7890 if (Chain && Chain->isProcessingUpdateRecords())
7892 assert(!WritingAST &&
"Already writing the AST!");
7893 assert(GlobArrayDelete &&
"Not given an operator delete");
7896 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7897 DeclUpdates[D].push_back(DeclUpdate(
7898 DeclUpdateKind::CXXResolvedDtorGlobArrayDelete, GlobArrayDelete));
7902void ASTWriter::CompletedImplicitDefinition(
const FunctionDecl *D) {
7903 if (Chain && Chain->isProcessingUpdateRecords())
return;
7904 assert(!WritingAST &&
"Already writing the AST!");
7913 DeclUpdates[D].push_back(
7914 DeclUpdate(DeclUpdateKind::CXXAddedFunctionDefinition));
7917void ASTWriter::VariableDefinitionInstantiated(
const VarDecl *D) {
7918 if (Chain && Chain->isProcessingUpdateRecords())
return;
7919 assert(!WritingAST &&
"Already writing the AST!");
7923 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::CXXAddedVarDefinition));
7926void ASTWriter::FunctionDefinitionInstantiated(
const FunctionDecl *D) {
7927 if (Chain && Chain->isProcessingUpdateRecords())
return;
7928 assert(!WritingAST &&
"Already writing the AST!");
7936 DeclUpdates[D].push_back(
7937 DeclUpdate(DeclUpdateKind::CXXAddedFunctionDefinition));
7940void ASTWriter::InstantiationRequested(
const ValueDecl *D) {
7941 if (Chain && Chain->isProcessingUpdateRecords())
return;
7942 assert(!WritingAST &&
"Already writing the AST!");
7949 if (
auto *VD = dyn_cast<VarDecl>(D))
7950 POI = VD->getPointOfInstantiation();
7953 DeclUpdates[D].push_back(
7954 DeclUpdate(DeclUpdateKind::CXXPointOfInstantiation, POI));
7957void ASTWriter::DefaultArgumentInstantiated(
const ParmVarDecl *D) {
7958 if (Chain && Chain->isProcessingUpdateRecords())
return;
7959 assert(!WritingAST &&
"Already writing the AST!");
7963 DeclUpdates[D].push_back(
7964 DeclUpdate(DeclUpdateKind::CXXInstantiatedDefaultArgument, D));
7967void ASTWriter::DefaultMemberInitializerInstantiated(
const FieldDecl *D) {
7968 assert(!WritingAST &&
"Already writing the AST!");
7972 DeclUpdates[D].push_back(
7973 DeclUpdate(DeclUpdateKind::CXXInstantiatedDefaultMemberInitializer, D));
7978 if (Chain && Chain->isProcessingUpdateRecords())
return;
7979 assert(!WritingAST &&
"Already writing the AST!");
7983 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
7984 ObjCClassesWithCategories.insert(
7988void ASTWriter::DeclarationMarkedUsed(
const Decl *D) {
7989 if (Chain && Chain->isProcessingUpdateRecords())
return;
7990 assert(!WritingAST &&
"Already writing the AST!");
7999 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::DeclMarkedUsed));
8002void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(
const Decl *D) {
8003 if (Chain && Chain->isProcessingUpdateRecords())
return;
8004 assert(!WritingAST &&
"Already writing the AST!");
8008 DeclUpdates[D].push_back(
8009 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPThreadPrivate));
8012void ASTWriter::DeclarationMarkedOpenMPAllocate(
const Decl *D,
const Attr *A) {
8013 if (Chain && Chain->isProcessingUpdateRecords())
return;
8014 assert(!WritingAST &&
"Already writing the AST!");
8018 DeclUpdates[D].push_back(
8019 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPAllocate, A));
8022void ASTWriter::DeclarationMarkedOpenMPIndirectCall(
const Decl *D) {
8023 if (Chain && Chain->isProcessingUpdateRecords())
8025 assert(!WritingAST &&
"Already writing the AST!");
8029 DeclUpdates[D].push_back(
8030 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPIndirectCall));
8033void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
8035 if (Chain && Chain->isProcessingUpdateRecords())
return;
8036 assert(!WritingAST &&
"Already writing the AST!");
8040 DeclUpdates[D].push_back(
8041 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPDeclareTarget, Attr));
8044void ASTWriter::RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M) {
8045 if (Chain && Chain->isProcessingUpdateRecords())
return;
8046 assert(!WritingAST &&
"Already writing the AST!");
8048 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::DeclExported, M));
8051void ASTWriter::AddedAttributeToRecord(
const Attr *
Attr,
8053 if (Chain && Chain->isProcessingUpdateRecords())
return;
8054 assert(!WritingAST &&
"Already writing the AST!");
8055 if (!
Record->isFromASTFile())
8057 DeclUpdates[
Record].push_back(
8058 DeclUpdate(DeclUpdateKind::AddedAttrToRecord, Attr));
8061void ASTWriter::AddedCXXTemplateSpecialization(
8063 assert(!WritingAST &&
"Already writing the AST!");
8067 if (Chain && Chain->isProcessingUpdateRecords())
8070 DeclsToEmitEvenIfUnreferenced.push_back(D);
8073void ASTWriter::AddedCXXTemplateSpecialization(
8075 assert(!WritingAST &&
"Already writing the AST!");
8079 if (Chain && Chain->isProcessingUpdateRecords())
8082 DeclsToEmitEvenIfUnreferenced.push_back(D);
8087 assert(!WritingAST &&
"Already writing the AST!");
8091 if (Chain && Chain->isProcessingUpdateRecords())
8094 DeclsToEmitEvenIfUnreferenced.push_back(D);
8103class OMPClauseWriter :
public OMPClauseVisitor<OMPClauseWriter> {
8108#define GEN_CLANG_CLAUSE_CLASS
8109#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
8110#include "llvm/Frontend/OpenMP/OMP.inc"
8119 OMPClauseWriter(*this).writeClause(
C);
8122void OMPClauseWriter::writeClause(
OMPClause *
C) {
8123 Record.push_back(
unsigned(
C->getClauseKind()));
8125 Record.AddSourceLocation(
C->getBeginLoc());
8126 Record.AddSourceLocation(
C->getEndLoc());
8130 Record.push_back(uint64_t(
C->getCaptureRegion()));
8131 Record.AddStmt(
C->getPreInitStmt());
8135 VisitOMPClauseWithPreInit(
C);
8136 Record.AddStmt(
C->getPostUpdateExpr());
8139void OMPClauseWriter::VisitOMPIfClause(
OMPIfClause *
C) {
8140 VisitOMPClauseWithPreInit(
C);
8142 Record.AddSourceLocation(
C->getNameModifierLoc());
8143 Record.AddSourceLocation(
C->getColonLoc());
8144 Record.AddStmt(
C->getCondition());
8145 Record.AddSourceLocation(
C->getLParenLoc());
8149 VisitOMPClauseWithPreInit(
C);
8150 Record.AddStmt(
C->getCondition());
8151 Record.AddSourceLocation(
C->getLParenLoc());
8155 Record.push_back(
C->varlist_size());
8156 Record.writeEnum(
C->getPrescriptivenessModifier());
8157 Record.AddSourceLocation(
C->getPrescriptivenessModifierLoc());
8158 Record.writeEnum(
C->getDimsModifier());
8159 Record.AddSourceLocation(
C->getDimsModifierLoc());
8160 Record.AddStmt(
C->getDimsModifierExpr());
8161 VisitOMPClauseWithPreInit(
C);
8162 Record.AddSourceLocation(
C->getLParenLoc());
8163 for (
auto *
VE :
C->varlist())
8168 Record.AddStmt(
C->getSafelen());
8169 Record.AddSourceLocation(
C->getLParenLoc());
8173 Record.AddStmt(
C->getSimdlen());
8174 Record.AddSourceLocation(
C->getLParenLoc());
8178 Record.push_back(
C->getNumSizes());
8179 for (
Expr *Size :
C->getSizesRefs())
8181 Record.AddSourceLocation(
C->getLParenLoc());
8185 Record.push_back(
C->getNumCounts());
8186 Record.push_back(
C->hasOmpFill());
8187 if (
C->hasOmpFill())
8188 Record.push_back(*
C->getOmpFillIndex());
8189 Record.AddSourceLocation(
C->getOmpFillLoc());
8190 for (
Expr *Count :
C->getCountsRefs())
8192 Record.AddSourceLocation(
C->getLParenLoc());
8196 Record.push_back(
C->getNumLoops());
8197 for (
Expr *Size :
C->getArgsRefs())
8199 Record.AddSourceLocation(
C->getLParenLoc());
8205 Record.AddStmt(
C->getFactor());
8206 Record.AddSourceLocation(
C->getLParenLoc());
8210 Record.AddStmt(
C->getDepth());
8211 Record.AddSourceLocation(
C->getLParenLoc());
8215 Record.AddStmt(
C->getFirst());
8216 Record.AddStmt(
C->getCount());
8217 Record.AddSourceLocation(
C->getLParenLoc());
8218 Record.AddSourceLocation(
C->getFirstLoc());
8219 Record.AddSourceLocation(
C->getCountLoc());
8223 Record.AddStmt(
C->getAllocator());
8224 Record.AddSourceLocation(
C->getLParenLoc());
8228 Record.AddStmt(
C->getNumForLoops());
8229 Record.AddSourceLocation(
C->getLParenLoc());
8232void OMPClauseWriter::VisitOMPDetachClause(OMPDetachClause *
C) {
8233 Record.AddStmt(
C->getEventHandler());
8234 Record.AddSourceLocation(
C->getLParenLoc());
8238 Record.push_back(
unsigned(
C->getDefaultKind()));
8239 Record.AddSourceLocation(
C->getLParenLoc());
8240 Record.AddSourceLocation(
C->getDefaultKindKwLoc());
8241 Record.push_back(
unsigned(
C->getDefaultVC()));
8242 Record.AddSourceLocation(
C->getDefaultVCLoc());
8246 Record.AddSourceLocation(
C->getLParenLoc());
8247 Record.AddSourceLocation(
C->getThreadsetKindLoc());
8248 Record.writeEnum(
C->getThreadsetKind());
8251void OMPClauseWriter::VisitOMPTransparentClause(OMPTransparentClause *
C) {
8252 Record.AddSourceLocation(
C->getLParenLoc());
8253 Record.AddStmt(
C->getImpexType());
8256void OMPClauseWriter::VisitOMPProcBindClause(OMPProcBindClause *
C) {
8257 Record.push_back(
unsigned(
C->getProcBindKind()));
8258 Record.AddSourceLocation(
C->getLParenLoc());
8259 Record.AddSourceLocation(
C->getProcBindKindKwLoc());
8262void OMPClauseWriter::VisitOMPScheduleClause(OMPScheduleClause *
C) {
8263 VisitOMPClauseWithPreInit(
C);
8264 Record.push_back(
C->getScheduleKind());
8265 Record.push_back(
C->getFirstScheduleModifier());
8266 Record.push_back(
C->getSecondScheduleModifier());
8267 Record.AddStmt(
C->getChunkSize());
8268 Record.AddSourceLocation(
C->getLParenLoc());
8269 Record.AddSourceLocation(
C->getFirstScheduleModifierLoc());
8270 Record.AddSourceLocation(
C->getSecondScheduleModifierLoc());
8271 Record.AddSourceLocation(
C->getScheduleKindLoc());
8272 Record.AddSourceLocation(
C->getCommaLoc());
8275void OMPClauseWriter::VisitOMPOrderedClause(OMPOrderedClause *
C) {
8276 Record.push_back(
C->getLoopNumIterations().size());
8277 Record.AddStmt(
C->getNumForLoops());
8278 for (
Expr *NumIter :
C->getLoopNumIterations())
8280 for (
unsigned I = 0, E =
C->getLoopNumIterations().size(); I <E; ++I)
8281 Record.AddStmt(
C->getLoopCounter(I));
8282 Record.AddSourceLocation(
C->getLParenLoc());
8285void OMPClauseWriter::VisitOMPNowaitClause(OMPNowaitClause *
C) {
8286 Record.AddStmt(
C->getCondition());
8287 Record.AddSourceLocation(
C->getLParenLoc());
8290void OMPClauseWriter::VisitOMPUntiedClause(OMPUntiedClause *) {}
8292void OMPClauseWriter::VisitOMPMergeableClause(OMPMergeableClause *) {}
8294void OMPClauseWriter::VisitOMPReadClause(OMPReadClause *) {}
8296void OMPClauseWriter::VisitOMPWriteClause(OMPWriteClause *) {}
8298void OMPClauseWriter::VisitOMPUpdateClause(OMPUpdateClause *) {}
8300void OMPClauseWriter::VisitOMPUpdateDependObjectsClause(
8301 OMPUpdateDependObjectsClause *
C) {
8302 Record.AddSourceLocation(
C->getLParenLoc());
8303 Record.AddSourceLocation(
C->getArgumentLoc());
8304 Record.writeEnum(
C->getDependencyKind());
8307void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {}
8309void OMPClauseWriter::VisitOMPCompareClause(OMPCompareClause *) {}
8312void OMPClauseWriter::VisitOMPFailClause(OMPFailClause *
C) {
8313 Record.AddSourceLocation(
C->getLParenLoc());
8314 Record.AddSourceLocation(
C->getFailParameterLoc());
8315 Record.writeEnum(
C->getFailParameter());
8318void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
8320void OMPClauseWriter::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
8322void OMPClauseWriter::VisitOMPAbsentClause(OMPAbsentClause *
C) {
8323 Record.push_back(
static_cast<uint64_t>(
C->getDirectiveKinds().size()));
8324 Record.AddSourceLocation(
C->getLParenLoc());
8325 for (
auto K :
C->getDirectiveKinds()) {
8330void OMPClauseWriter::VisitOMPHoldsClause(OMPHoldsClause *
C) {
8332 Record.AddSourceLocation(
C->getLParenLoc());
8335void OMPClauseWriter::VisitOMPContainsClause(OMPContainsClause *
C) {
8336 Record.push_back(
static_cast<uint64_t>(
C->getDirectiveKinds().size()));
8337 Record.AddSourceLocation(
C->getLParenLoc());
8338 for (
auto K :
C->getDirectiveKinds()) {
8343void OMPClauseWriter::VisitOMPNoOpenMPClause(OMPNoOpenMPClause *) {}
8345void OMPClauseWriter::VisitOMPNoOpenMPRoutinesClause(
8346 OMPNoOpenMPRoutinesClause *) {}
8348void OMPClauseWriter::VisitOMPNoOpenMPConstructsClause(
8349 OMPNoOpenMPConstructsClause *) {}
8351void OMPClauseWriter::VisitOMPNoParallelismClause(OMPNoParallelismClause *) {}
8353void OMPClauseWriter::VisitOMPAcquireClause(OMPAcquireClause *) {}
8355void OMPClauseWriter::VisitOMPReleaseClause(OMPReleaseClause *) {}
8357void OMPClauseWriter::VisitOMPRelaxedClause(OMPRelaxedClause *) {}
8359void OMPClauseWriter::VisitOMPWeakClause(OMPWeakClause *) {}
8361void OMPClauseWriter::VisitOMPThreadsClause(OMPThreadsClause *) {}
8363void OMPClauseWriter::VisitOMPSIMDClause(OMPSIMDClause *) {}
8365void OMPClauseWriter::VisitOMPNogroupClause(OMPNogroupClause *) {}
8367void OMPClauseWriter::VisitOMPInitClause(OMPInitClause *
C) {
8370 Record.push_back(
C->varlist_size());
8371 Record.push_back(
C->attrs().size());
8375 Record.writeBool(
C->getIsTarget());
8376 Record.writeBool(
C->getIsTargetSync());
8377 Record.writeBool(
C->hasPreferAttrs());
8379 for (OMPInitClause::PrefView P :
C->prefs()) {
8380 Record.push_back(P.Attrs.size());
8381 for (
Expr *A : P.Attrs)
8384 Record.AddSourceLocation(
C->getLParenLoc());
8385 Record.AddSourceLocation(
C->getVarLoc());
8388void OMPClauseWriter::VisitOMPUseClause(OMPUseClause *
C) {
8389 Record.AddStmt(
C->getInteropVar());
8390 Record.AddSourceLocation(
C->getLParenLoc());
8391 Record.AddSourceLocation(
C->getVarLoc());
8394void OMPClauseWriter::VisitOMPDestroyClause(OMPDestroyClause *
C) {
8395 Record.AddStmt(
C->getInteropVar());
8396 Record.AddSourceLocation(
C->getLParenLoc());
8397 Record.AddSourceLocation(
C->getVarLoc());
8400void OMPClauseWriter::VisitOMPNovariantsClause(OMPNovariantsClause *
C) {
8401 VisitOMPClauseWithPreInit(
C);
8402 Record.AddStmt(
C->getCondition());
8403 Record.AddSourceLocation(
C->getLParenLoc());
8406void OMPClauseWriter::VisitOMPNocontextClause(OMPNocontextClause *
C) {
8407 VisitOMPClauseWithPreInit(
C);
8408 Record.AddStmt(
C->getCondition());
8409 Record.AddSourceLocation(
C->getLParenLoc());
8412void OMPClauseWriter::VisitOMPFilterClause(OMPFilterClause *
C) {
8413 VisitOMPClauseWithPreInit(
C);
8414 Record.AddStmt(
C->getThreadID());
8415 Record.AddSourceLocation(
C->getLParenLoc());
8419 Record.AddStmt(
C->getAlignment());
8420 Record.AddSourceLocation(
C->getLParenLoc());
8423void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *
C) {
8424 Record.push_back(
C->varlist_size());
8425 Record.AddSourceLocation(
C->getLParenLoc());
8426 for (
auto *
VE :
C->varlist()) {
8429 for (
auto *
VE :
C->private_copies()) {
8434void OMPClauseWriter::VisitOMPFirstprivateClause(OMPFirstprivateClause *
C) {
8435 Record.push_back(
C->varlist_size());
8436 VisitOMPClauseWithPreInit(
C);
8437 Record.AddSourceLocation(
C->getLParenLoc());
8438 for (
auto *
VE :
C->varlist()) {
8441 for (
auto *
VE :
C->private_copies()) {
8444 for (
auto *
VE :
C->inits()) {
8449void OMPClauseWriter::VisitOMPLastprivateClause(OMPLastprivateClause *
C) {
8450 Record.push_back(
C->varlist_size());
8451 VisitOMPClauseWithPostUpdate(
C);
8452 Record.AddSourceLocation(
C->getLParenLoc());
8453 Record.writeEnum(
C->getKind());
8454 Record.AddSourceLocation(
C->getKindLoc());
8455 Record.AddSourceLocation(
C->getColonLoc());
8456 for (
auto *
VE :
C->varlist())
8458 for (
auto *E :
C->private_copies())
8460 for (
auto *E :
C->source_exprs())
8462 for (
auto *E :
C->destination_exprs())
8464 for (
auto *E :
C->assignment_ops())
8468void OMPClauseWriter::VisitOMPSharedClause(OMPSharedClause *
C) {
8469 Record.push_back(
C->varlist_size());
8470 Record.AddSourceLocation(
C->getLParenLoc());
8471 for (
auto *
VE :
C->varlist())
8475void OMPClauseWriter::VisitOMPReductionClause(OMPReductionClause *
C) {
8476 Record.push_back(
C->varlist_size());
8477 Record.writeEnum(
C->getModifier());
8478 VisitOMPClauseWithPostUpdate(
C);
8479 Record.AddSourceLocation(
C->getLParenLoc());
8480 Record.AddSourceLocation(
C->getModifierLoc());
8481 Record.AddSourceLocation(
C->getColonLoc());
8482 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
8483 Record.AddDeclarationNameInfo(
C->getNameInfo());
8484 for (
auto *
VE :
C->varlist())
8486 for (
auto *
VE :
C->privates())
8488 for (
auto *E :
C->lhs_exprs())
8490 for (
auto *E :
C->rhs_exprs())
8492 for (
auto *E :
C->reduction_ops())
8494 if (
C->getModifier() == clang::OMPC_REDUCTION_inscan) {
8495 for (
auto *E :
C->copy_ops())
8497 for (
auto *E :
C->copy_array_temps())
8499 for (
auto *E :
C->copy_array_elems())
8502 auto PrivateFlags =
C->private_var_reduction_flags();
8503 Record.push_back(std::distance(PrivateFlags.begin(), PrivateFlags.end()));
8504 for (
bool Flag : PrivateFlags)
8508void OMPClauseWriter::VisitOMPTaskReductionClause(OMPTaskReductionClause *
C) {
8509 Record.push_back(
C->varlist_size());
8510 VisitOMPClauseWithPostUpdate(
C);
8511 Record.AddSourceLocation(
C->getLParenLoc());
8512 Record.AddSourceLocation(
C->getColonLoc());
8513 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
8514 Record.AddDeclarationNameInfo(
C->getNameInfo());
8515 for (
auto *
VE :
C->varlist())
8517 for (
auto *
VE :
C->privates())
8519 for (
auto *E :
C->lhs_exprs())
8521 for (
auto *E :
C->rhs_exprs())
8523 for (
auto *E :
C->reduction_ops())
8527void OMPClauseWriter::VisitOMPInReductionClause(OMPInReductionClause *
C) {
8528 Record.push_back(
C->varlist_size());
8529 VisitOMPClauseWithPostUpdate(
C);
8530 Record.AddSourceLocation(
C->getLParenLoc());
8531 Record.AddSourceLocation(
C->getColonLoc());
8532 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
8533 Record.AddDeclarationNameInfo(
C->getNameInfo());
8534 for (
auto *
VE :
C->varlist())
8536 for (
auto *
VE :
C->privates())
8538 for (
auto *E :
C->lhs_exprs())
8540 for (
auto *E :
C->rhs_exprs())
8542 for (
auto *E :
C->reduction_ops())
8544 for (
auto *E :
C->taskgroup_descriptors())
8548void OMPClauseWriter::VisitOMPLinearClause(OMPLinearClause *
C) {
8549 Record.push_back(
C->varlist_size());
8550 VisitOMPClauseWithPostUpdate(
C);
8551 Record.AddSourceLocation(
C->getLParenLoc());
8552 Record.AddSourceLocation(
C->getColonLoc());
8553 Record.push_back(
C->getModifier());
8554 Record.AddSourceLocation(
C->getModifierLoc());
8555 for (
auto *
VE :
C->varlist()) {
8558 for (
auto *
VE :
C->privates()) {
8561 for (
auto *
VE :
C->inits()) {
8564 for (
auto *
VE :
C->updates()) {
8567 for (
auto *
VE :
C->finals()) {
8571 Record.AddStmt(
C->getCalcStep());
8572 for (
auto *
VE :
C->used_expressions())
8576void OMPClauseWriter::VisitOMPAlignedClause(OMPAlignedClause *
C) {
8577 Record.push_back(
C->varlist_size());
8578 Record.AddSourceLocation(
C->getLParenLoc());
8579 Record.AddSourceLocation(
C->getColonLoc());
8580 for (
auto *
VE :
C->varlist())
8582 Record.AddStmt(
C->getAlignment());
8585void OMPClauseWriter::VisitOMPCopyinClause(OMPCopyinClause *
C) {
8586 Record.push_back(
C->varlist_size());
8587 Record.AddSourceLocation(
C->getLParenLoc());
8588 for (
auto *
VE :
C->varlist())
8590 for (
auto *E :
C->source_exprs())
8592 for (
auto *E :
C->destination_exprs())
8594 for (
auto *E :
C->assignment_ops())
8598void OMPClauseWriter::VisitOMPCopyprivateClause(OMPCopyprivateClause *
C) {
8599 Record.push_back(
C->varlist_size());
8600 Record.AddSourceLocation(
C->getLParenLoc());
8601 for (
auto *
VE :
C->varlist())
8603 for (
auto *E :
C->source_exprs())
8605 for (
auto *E :
C->destination_exprs())
8607 for (
auto *E :
C->assignment_ops())
8611void OMPClauseWriter::VisitOMPFlushClause(OMPFlushClause *
C) {
8612 Record.push_back(
C->varlist_size());
8613 Record.AddSourceLocation(
C->getLParenLoc());
8614 for (
auto *
VE :
C->varlist())
8618void OMPClauseWriter::VisitOMPDepobjClause(OMPDepobjClause *
C) {
8619 Record.AddStmt(
C->getDepobj());
8620 Record.AddSourceLocation(
C->getLParenLoc());
8623void OMPClauseWriter::VisitOMPDependClause(OMPDependClause *
C) {
8624 Record.push_back(
C->varlist_size());
8625 Record.push_back(
C->getNumLoops());
8626 Record.AddSourceLocation(
C->getLParenLoc());
8627 Record.AddStmt(
C->getModifier());
8628 Record.push_back(
C->getDependencyKind());
8629 Record.AddSourceLocation(
C->getDependencyLoc());
8630 Record.AddSourceLocation(
C->getColonLoc());
8631 Record.AddSourceLocation(
C->getOmpAllMemoryLoc());
8632 for (
auto *
VE :
C->varlist())
8634 for (
unsigned I = 0, E =
C->getNumLoops(); I < E; ++I)
8635 Record.AddStmt(
C->getLoopData(I));
8638void OMPClauseWriter::VisitOMPDeviceClause(OMPDeviceClause *
C) {
8639 VisitOMPClauseWithPreInit(
C);
8640 Record.writeEnum(
C->getModifier());
8641 Record.AddStmt(
C->getDevice());
8642 Record.AddSourceLocation(
C->getModifierLoc());
8643 Record.AddSourceLocation(
C->getLParenLoc());
8646void OMPClauseWriter::VisitOMPMapClause(OMPMapClause *
C) {
8647 Record.push_back(
C->varlist_size());
8648 Record.push_back(
C->getUniqueDeclarationsNum());
8649 Record.push_back(
C->getTotalComponentListNum());
8650 Record.push_back(
C->getTotalComponentsNum());
8651 Record.AddSourceLocation(
C->getLParenLoc());
8652 bool HasIteratorModifier =
false;
8654 Record.push_back(
C->getMapTypeModifier(I));
8655 Record.AddSourceLocation(
C->getMapTypeModifierLoc(I));
8656 if (
C->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator)
8657 HasIteratorModifier =
true;
8659 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8660 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8661 Record.push_back(
C->getMapType());
8662 Record.AddSourceLocation(
C->getMapLoc());
8663 Record.AddSourceLocation(
C->getColonLoc());
8664 for (
auto *E :
C->varlist())
8666 for (
auto *E :
C->mapperlists())
8668 if (HasIteratorModifier)
8669 Record.AddStmt(
C->getIteratorModifier());
8670 for (
auto *D :
C->all_decls())
8672 for (
auto N :
C->all_num_lists())
8674 for (
auto N :
C->all_lists_sizes())
8676 for (
auto &M :
C->all_components()) {
8677 Record.AddStmt(M.getAssociatedExpression());
8678 Record.AddDeclRef(M.getAssociatedDeclaration());
8683 Record.push_back(
C->varlist_size());
8684 Record.writeEnum(
C->getFirstAllocateModifier());
8685 Record.writeEnum(
C->getSecondAllocateModifier());
8686 Record.AddSourceLocation(
C->getLParenLoc());
8687 Record.AddSourceLocation(
C->getColonLoc());
8688 Record.AddStmt(
C->getAllocator());
8689 Record.AddStmt(
C->getAlignment());
8690 for (
auto *
VE :
C->varlist())
8694void OMPClauseWriter::VisitOMPNumTeamsClause(OMPNumTeamsClause *
C) {
8695 Record.push_back(
C->varlist_size());
8696 Record.writeEnum(
C->getModifier());
8697 Record.AddSourceLocation(
C->getModifierLoc());
8698 Record.AddStmt(
C->getModifierExpr());
8699 VisitOMPClauseWithPreInit(
C);
8700 Record.AddSourceLocation(
C->getLParenLoc());
8701 for (
auto *
VE :
C->varlist())
8705void OMPClauseWriter::VisitOMPThreadLimitClause(OMPThreadLimitClause *
C) {
8706 Record.push_back(
C->varlist_size());
8707 Record.writeEnum(
C->getModifier());
8708 Record.AddSourceLocation(
C->getModifierLoc());
8709 Record.AddStmt(
C->getModifierExpr());
8710 VisitOMPClauseWithPreInit(
C);
8711 Record.AddSourceLocation(
C->getLParenLoc());
8712 for (
auto *
VE :
C->varlist())
8716void OMPClauseWriter::VisitOMPPriorityClause(OMPPriorityClause *
C) {
8717 VisitOMPClauseWithPreInit(
C);
8718 Record.AddStmt(
C->getPriority());
8719 Record.AddSourceLocation(
C->getLParenLoc());
8722void OMPClauseWriter::VisitOMPGrainsizeClause(OMPGrainsizeClause *
C) {
8723 VisitOMPClauseWithPreInit(
C);
8724 Record.writeEnum(
C->getModifier());
8725 Record.AddStmt(
C->getGrainsize());
8726 Record.AddSourceLocation(
C->getModifierLoc());
8727 Record.AddSourceLocation(
C->getLParenLoc());
8730void OMPClauseWriter::VisitOMPNumTasksClause(OMPNumTasksClause *
C) {
8731 VisitOMPClauseWithPreInit(
C);
8732 Record.writeEnum(
C->getModifier());
8733 Record.AddStmt(
C->getNumTasks());
8734 Record.AddSourceLocation(
C->getModifierLoc());
8735 Record.AddSourceLocation(
C->getLParenLoc());
8738void OMPClauseWriter::VisitOMPHintClause(OMPHintClause *
C) {
8740 Record.AddSourceLocation(
C->getLParenLoc());
8743void OMPClauseWriter::VisitOMPDistScheduleClause(OMPDistScheduleClause *
C) {
8744 VisitOMPClauseWithPreInit(
C);
8745 Record.push_back(
C->getDistScheduleKind());
8746 Record.AddStmt(
C->getChunkSize());
8747 Record.AddSourceLocation(
C->getLParenLoc());
8748 Record.AddSourceLocation(
C->getDistScheduleKindLoc());
8749 Record.AddSourceLocation(
C->getCommaLoc());
8752void OMPClauseWriter::VisitOMPDefaultmapClause(OMPDefaultmapClause *
C) {
8753 Record.push_back(
C->getDefaultmapKind());
8754 Record.push_back(
C->getDefaultmapModifier());
8755 Record.AddSourceLocation(
C->getLParenLoc());
8756 Record.AddSourceLocation(
C->getDefaultmapModifierLoc());
8757 Record.AddSourceLocation(
C->getDefaultmapKindLoc());
8760void OMPClauseWriter::VisitOMPToClause(OMPToClause *
C) {
8761 Record.push_back(
C->varlist_size());
8762 Record.push_back(
C->getUniqueDeclarationsNum());
8763 Record.push_back(
C->getTotalComponentListNum());
8764 Record.push_back(
C->getTotalComponentsNum());
8765 Record.AddSourceLocation(
C->getLParenLoc());
8767 Record.push_back(
C->getMotionModifier(I));
8768 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
8769 if (
C->getMotionModifier(I) == OMPC_MOTION_MODIFIER_iterator)
8770 Record.AddStmt(
C->getIteratorModifier());
8772 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8773 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8774 Record.AddSourceLocation(
C->getColonLoc());
8775 for (
auto *E :
C->varlist())
8777 for (
auto *E :
C->mapperlists())
8779 for (
auto *D :
C->all_decls())
8781 for (
auto N :
C->all_num_lists())
8783 for (
auto N :
C->all_lists_sizes())
8785 for (
auto &M :
C->all_components()) {
8786 Record.AddStmt(M.getAssociatedExpression());
8787 Record.writeBool(M.isNonContiguous());
8788 Record.AddDeclRef(M.getAssociatedDeclaration());
8792void OMPClauseWriter::VisitOMPFromClause(OMPFromClause *
C) {
8793 Record.push_back(
C->varlist_size());
8794 Record.push_back(
C->getUniqueDeclarationsNum());
8795 Record.push_back(
C->getTotalComponentListNum());
8796 Record.push_back(
C->getTotalComponentsNum());
8797 Record.AddSourceLocation(
C->getLParenLoc());
8799 Record.push_back(
C->getMotionModifier(I));
8800 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
8801 if (
C->getMotionModifier(I) == OMPC_MOTION_MODIFIER_iterator)
8802 Record.AddStmt(
C->getIteratorModifier());
8804 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8805 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8806 Record.AddSourceLocation(
C->getColonLoc());
8807 for (
auto *E :
C->varlist())
8809 for (
auto *E :
C->mapperlists())
8811 for (
auto *D :
C->all_decls())
8813 for (
auto N :
C->all_num_lists())
8815 for (
auto N :
C->all_lists_sizes())
8817 for (
auto &M :
C->all_components()) {
8818 Record.AddStmt(M.getAssociatedExpression());
8819 Record.writeBool(M.isNonContiguous());
8820 Record.AddDeclRef(M.getAssociatedDeclaration());
8824void OMPClauseWriter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *
C) {
8825 Record.push_back(
C->varlist_size());
8826 Record.push_back(
C->getUniqueDeclarationsNum());
8827 Record.push_back(
C->getTotalComponentListNum());
8828 Record.push_back(
C->getTotalComponentsNum());
8829 Record.AddSourceLocation(
C->getLParenLoc());
8830 Record.writeEnum(
C->getFallbackModifier());
8831 Record.AddSourceLocation(
C->getFallbackModifierLoc());
8832 for (
auto *E :
C->varlist())
8834 for (
auto *
VE :
C->private_copies())
8836 for (
auto *
VE :
C->inits())
8838 for (
auto *D :
C->all_decls())
8840 for (
auto N :
C->all_num_lists())
8842 for (
auto N :
C->all_lists_sizes())
8844 for (
auto &M :
C->all_components()) {
8845 Record.AddStmt(M.getAssociatedExpression());
8846 Record.AddDeclRef(M.getAssociatedDeclaration());
8850void OMPClauseWriter::VisitOMPUseDeviceAddrClause(OMPUseDeviceAddrClause *
C) {
8851 Record.push_back(
C->varlist_size());
8852 Record.push_back(
C->getUniqueDeclarationsNum());
8853 Record.push_back(
C->getTotalComponentListNum());
8854 Record.push_back(
C->getTotalComponentsNum());
8855 Record.AddSourceLocation(
C->getLParenLoc());
8856 for (
auto *E :
C->varlist())
8858 for (
auto *D :
C->all_decls())
8860 for (
auto N :
C->all_num_lists())
8862 for (
auto N :
C->all_lists_sizes())
8864 for (
auto &M :
C->all_components()) {
8865 Record.AddStmt(M.getAssociatedExpression());
8866 Record.AddDeclRef(M.getAssociatedDeclaration());
8870void OMPClauseWriter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *
C) {
8871 Record.push_back(
C->varlist_size());
8872 Record.push_back(
C->getUniqueDeclarationsNum());
8873 Record.push_back(
C->getTotalComponentListNum());
8874 Record.push_back(
C->getTotalComponentsNum());
8875 Record.AddSourceLocation(
C->getLParenLoc());
8876 for (
auto *E :
C->varlist())
8878 for (
auto *D :
C->all_decls())
8880 for (
auto N :
C->all_num_lists())
8882 for (
auto N :
C->all_lists_sizes())
8884 for (
auto &M :
C->all_components()) {
8885 Record.AddStmt(M.getAssociatedExpression());
8886 Record.AddDeclRef(M.getAssociatedDeclaration());
8890void OMPClauseWriter::VisitOMPHasDeviceAddrClause(OMPHasDeviceAddrClause *
C) {
8891 Record.push_back(
C->varlist_size());
8892 Record.push_back(
C->getUniqueDeclarationsNum());
8893 Record.push_back(
C->getTotalComponentListNum());
8894 Record.push_back(
C->getTotalComponentsNum());
8895 Record.AddSourceLocation(
C->getLParenLoc());
8896 for (
auto *E :
C->varlist())
8898 for (
auto *D :
C->all_decls())
8900 for (
auto N :
C->all_num_lists())
8902 for (
auto N :
C->all_lists_sizes())
8904 for (
auto &M :
C->all_components()) {
8905 Record.AddStmt(M.getAssociatedExpression());
8906 Record.AddDeclRef(M.getAssociatedDeclaration());
8910void OMPClauseWriter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {}
8912void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
8913 OMPUnifiedSharedMemoryClause *) {}
8915void OMPClauseWriter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
8918OMPClauseWriter::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
8921void OMPClauseWriter::VisitOMPAtomicDefaultMemOrderClause(
8922 OMPAtomicDefaultMemOrderClause *
C) {
8923 Record.push_back(
C->getAtomicDefaultMemOrderKind());
8924 Record.AddSourceLocation(
C->getLParenLoc());
8925 Record.AddSourceLocation(
C->getAtomicDefaultMemOrderKindKwLoc());
8928void OMPClauseWriter::VisitOMPSelfMapsClause(OMPSelfMapsClause *) {}
8930void OMPClauseWriter::VisitOMPAtClause(OMPAtClause *
C) {
8931 Record.push_back(
C->getAtKind());
8932 Record.AddSourceLocation(
C->getLParenLoc());
8933 Record.AddSourceLocation(
C->getAtKindKwLoc());
8936void OMPClauseWriter::VisitOMPSeverityClause(OMPSeverityClause *
C) {
8937 Record.push_back(
C->getSeverityKind());
8938 Record.AddSourceLocation(
C->getLParenLoc());
8939 Record.AddSourceLocation(
C->getSeverityKindKwLoc());
8942void OMPClauseWriter::VisitOMPMessageClause(OMPMessageClause *
C) {
8943 VisitOMPClauseWithPreInit(
C);
8944 Record.AddStmt(
C->getMessageString());
8945 Record.AddSourceLocation(
C->getLParenLoc());
8948void OMPClauseWriter::VisitOMPNontemporalClause(OMPNontemporalClause *
C) {
8949 Record.push_back(
C->varlist_size());
8950 Record.AddSourceLocation(
C->getLParenLoc());
8951 for (
auto *
VE :
C->varlist())
8953 for (
auto *E :
C->private_refs())
8957void OMPClauseWriter::VisitOMPInclusiveClause(OMPInclusiveClause *
C) {
8958 Record.push_back(
C->varlist_size());
8959 Record.AddSourceLocation(
C->getLParenLoc());
8960 for (
auto *
VE :
C->varlist())
8964void OMPClauseWriter::VisitOMPExclusiveClause(OMPExclusiveClause *
C) {
8965 Record.push_back(
C->varlist_size());
8966 Record.AddSourceLocation(
C->getLParenLoc());
8967 for (
auto *
VE :
C->varlist())
8971void OMPClauseWriter::VisitOMPOrderClause(OMPOrderClause *
C) {
8972 Record.writeEnum(
C->getKind());
8973 Record.writeEnum(
C->getModifier());
8974 Record.AddSourceLocation(
C->getLParenLoc());
8975 Record.AddSourceLocation(
C->getKindKwLoc());
8976 Record.AddSourceLocation(
C->getModifierKwLoc());
8979void OMPClauseWriter::VisitOMPUsesAllocatorsClause(OMPUsesAllocatorsClause *
C) {
8980 Record.push_back(
C->getNumberOfAllocators());
8981 Record.AddSourceLocation(
C->getLParenLoc());
8982 for (
unsigned I = 0, E =
C->getNumberOfAllocators(); I < E; ++I) {
8983 OMPUsesAllocatorsClause::Data
Data =
C->getAllocatorData(I);
8991void OMPClauseWriter::VisitOMPAffinityClause(OMPAffinityClause *
C) {
8992 Record.push_back(
C->varlist_size());
8993 Record.AddSourceLocation(
C->getLParenLoc());
8994 Record.AddStmt(
C->getModifier());
8995 Record.AddSourceLocation(
C->getColonLoc());
8996 for (
Expr *E :
C->varlist())
9000void OMPClauseWriter::VisitOMPBindClause(OMPBindClause *
C) {
9001 Record.writeEnum(
C->getBindKind());
9002 Record.AddSourceLocation(
C->getLParenLoc());
9003 Record.AddSourceLocation(
C->getBindKindLoc());
9006void OMPClauseWriter::VisitOMPXDynCGroupMemClause(OMPXDynCGroupMemClause *
C) {
9007 VisitOMPClauseWithPreInit(
C);
9009 Record.AddSourceLocation(
C->getLParenLoc());
9012void OMPClauseWriter::VisitOMPDynGroupprivateClause(
9013 OMPDynGroupprivateClause *
C) {
9014 VisitOMPClauseWithPreInit(
C);
9015 Record.push_back(
C->getDynGroupprivateModifier());
9016 Record.push_back(
C->getDynGroupprivateFallbackModifier());
9018 Record.AddSourceLocation(
C->getLParenLoc());
9019 Record.AddSourceLocation(
C->getDynGroupprivateModifierLoc());
9020 Record.AddSourceLocation(
C->getDynGroupprivateFallbackModifierLoc());
9023void OMPClauseWriter::VisitOMPDoacrossClause(OMPDoacrossClause *
C) {
9024 Record.push_back(
C->varlist_size());
9025 Record.push_back(
C->getNumLoops());
9026 Record.AddSourceLocation(
C->getLParenLoc());
9027 Record.push_back(
C->getDependenceType());
9028 Record.AddSourceLocation(
C->getDependenceLoc());
9029 Record.AddSourceLocation(
C->getColonLoc());
9030 for (
auto *
VE :
C->varlist())
9032 for (
unsigned I = 0, E =
C->getNumLoops(); I < E; ++I)
9033 Record.AddStmt(
C->getLoopData(I));
9036void OMPClauseWriter::VisitOMPXAttributeClause(OMPXAttributeClause *
C) {
9037 Record.AddAttributes(
C->getAttrs());
9038 Record.AddSourceLocation(
C->getBeginLoc());
9039 Record.AddSourceLocation(
C->getLParenLoc());
9040 Record.AddSourceLocation(
C->getEndLoc());
9043void OMPClauseWriter::VisitOMPXBareClause(OMPXBareClause *
C) {}
9047 for (
const auto &
Set : TI->
Sets) {
9054 writeExprRef(
Selector.ScoreOrCondition);
9068 for (
unsigned I = 0, E =
Data->getNumClauses(); I < E; ++I)
9070 if (
Data->hasAssociatedStmt())
9072 for (
unsigned I = 0, E =
Data->getNumChildren(); I < E; ++I)
9078 for (
Expr *E :
C->getVarList())
9084 for (
Expr *E : Exprs)
9093 switch (
C->getClauseKind()) {
9103 AddStmt(
const_cast<Expr*
>(IC->getConditionExpr()));
9110 if (SC->isConditionExprClause()) {
9112 if (SC->hasConditionExpr())
9113 AddStmt(
const_cast<Expr *
>(SC->getConditionExpr()));
9116 for (
Expr *E : SC->getVarList())
9125 for (
Expr *E : NGC->getIntExprs())
9159 static_assert(
sizeof(R) == 1 *
sizeof(
int *));
9182 static_assert(
sizeof(R) == 2 *
sizeof(
int *));
9270 if (AC->hasIntExpr())
9278 if (
Expr *DNE = WC->getDevNumExpr())
9292 if (Arg.getIdentifierInfo())
9311 for (
auto &CombinerRecipe : R.CombinerRecipes) {
9339 for (
Expr *E : TC->getSizeExprs())
9347 for (
unsigned I = 0; I < GC->getNumExprs(); ++I) {
9349 AddStmt(
const_cast<Expr *
>(GC->getExpr(I).second));
9357 if (WC->hasIntExpr())
9365 if (VC->hasIntExpr())
9386 if (BC->isStringArgument())
9395 llvm_unreachable(
"Clause serialization not yet implemented");
9397 llvm_unreachable(
"Invalid Clause Kind");
9406 const OpenACCRoutineDeclAttr *A) {
#define RECORD(CLASS, BASE)
Defines the clang::ASTContext interface.
static bool isInterestingIdentifier(ASTReader &Reader, const IdentifierInfo &II, bool IsModule)
Whether the given identifier is "interesting".
static NamedDecl * getDeclForLocalLookup(const LangOptions &LangOpts, NamedDecl *D)
Determine the declaration that should be put into the name lookup table to represent the given declar...
static unsigned CreateSLocBufferAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a buffer.
static bool isLookupResultNotInteresting(ASTWriter &Writer, StoredDeclsList &Result)
Returns true if all of the lookup result are either external, not emitted or predefined.
static void AddLazyVectorDecls(ASTWriter &Writer, Vector &Vec)
static bool IsInternalDeclFromFileContext(const Decl *D)
static TypeID MakeTypeID(ASTContext &Context, QualType T, IdxForTypeTy IdxForType)
static void AddLazyVectorEmiitedDecls(ASTWriter &Writer, Vector &Vec, ASTWriter::RecordData &Record)
static unsigned CreateSLocExpansionAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a macro expansion.
static StringRef bytes(const std::vector< T, Allocator > &v)
static unsigned CreateSLocBufferBlobAbbrev(llvm::BitstreamWriter &Stream, bool Compressed)
Create an abbreviation for the SLocEntry that refers to a buffer's blob.
static void BackpatchSignatureAt(llvm::BitstreamWriter &Stream, const ASTFileSignature &S, uint64_t BitNo)
static bool isLocalIdentifierID(IdentifierID ID)
If the.
static bool isImportedDeclContext(ASTReader *Chain, const Decl *D)
static TypeCode getTypeCodeForTypeClass(Type::TypeClass id)
static void AddStmtsExprs(llvm::BitstreamWriter &Stream, ASTWriter::RecordDataImpl &Record)
static bool adjustFilenameForRelocatableAST(SmallVectorImpl< char > &Filename, StringRef BaseDir)
Adjusts the given filename to only write out the portion of the filename that is not part of the syst...
static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob, unsigned SLocBufferBlobCompressedAbbrv, unsigned SLocBufferBlobAbbrv)
static uint64_t EmitCXXBaseSpecifiers(ASTContext &Context, ASTWriter &W, ArrayRef< CXXBaseSpecifier > Bases)
static std::pair< unsigned, unsigned > emitULEBKeyDataLength(unsigned KeyLen, unsigned DataLen, raw_ostream &Out)
Emit key length and data length as ULEB-encoded data, and return them as a pair.
static bool shouldIgnoreMacro(MacroDirective *MD, bool IsModule, const Preprocessor &PP)
static uint64_t EmitCXXCtorInitializers(ASTContext &Context, ASTWriter &W, ArrayRef< CXXCtorInitializer * > CtorInits)
static unsigned CreateSLocFileAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a file.
Defines the Diagnostic-related interfaces.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines interfaces for clang::FileEntry and clang::FileEntryRef.
Defines the clang::FileManager interface and associated types.
Defines the clang::FileSystemOptions interface.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Result
Implement __builtin_bit_cast and related operations.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the LambdaCapture class.
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
Defines the clang::LangOptions interface.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Target Target
llvm::MachO::Record Record
Defines the clang::MacroInfo and clang::MacroDirective classes.
Defines the clang::Module class, which describes a module in the source code.
Defines types useful for describing an Objective-C runtime.
Defines some OpenACC-specific enums and functions.
Defines the clang::OpenCLOptions class.
This file defines OpenMP AST classes for clauses.
Defines the clang::Preprocessor interface.
This file declares semantic analysis for CUDA constructs.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis functions specific to RISC-V.
static void EmitBlockID(unsigned ID, const char *Name, llvm::BitstreamWriter &Stream, RecordDataImpl &Record)
Emits a block ID in the BLOCKINFO block.
static void EmitRecordID(unsigned ID, const char *Name, llvm::BitstreamWriter &Stream, RecordDataImpl &Record)
Emits a record ID in the BLOCKINFO block.
Defines the clang::SourceLocation class and associated facilities.
Defines implementation details of the clang::SourceManager class.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TargetOptions class.
#define IMPORT(DERIVED, BASE)
#define BLOCK(DERIVED, BASE)
Defines the clang::TypeLoc interface and its subclasses.
TypePropertyCache< Private > Cache
C Language Family Type Representation.
Defines version macros and version-related utility functions for Clang.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Contains data for OpenMP directives: clauses, children expressions/statements (helpers for codegen) a...
llvm::SmallVector< OMPTraitSet, 2 > Sets
The outermost level of selector sets.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
QualType getRawCFConstantStringType() const
Get the structure type used to representation CFStrings, or NULL if it hasn't yet been built.
QualType getucontext_tType() const
Retrieve the C ucontext_t type.
FunctionDecl * getcudaGetParameterBufferDecl()
QualType getFILEType() const
Retrieve the C FILE type.
ArrayRef< Decl * > getModuleInitializers(Module *M)
Get the initializations to perform when importing a module, if any.
const LangOptions & getLangOpts() const
RawCommentList Comments
All comments in this translation unit.
TagDecl * MSTypeInfoTagDecl
QualType getjmp_bufType() const
Retrieve the C jmp_buf type.
QualType getsigjmp_bufType() const
Retrieve the C sigjmp_buf type.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
FunctionDecl * getcudaConfigureCallDecl()
import_range local_imports() const
FunctionDecl * getcudaLaunchDeviceDecl()
Reads an AST files chain containing the contents of a translation unit.
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
const serialization::reader::ModuleLocalLookupTable * getModuleLocalLookupTables(DeclContext *Primary) const
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
Decl * getKeyDeclaration(Decl *D)
Returns the first key declaration for the given declaration.
serialization::reader::LazySpecializationInfoLookupTable * getLoadedSpecializationsLookupTables(const Decl *D, bool IsPartial)
Get the loaded specializations lookup tables for D, if any.
const serialization::reader::DeclContextLookupTable * getTULocalLookupTables(DeclContext *Primary) const
An object for streaming information to a record.
void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
void AddCXXBaseSpecifiers(ArrayRef< CXXBaseSpecifier > Bases)
Emit a set of C++ base specifiers.
void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs)
Emit a template argument list.
uint64_t Emit(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, followed by its substatements, and return its offset.
void AddCXXTemporary(const CXXTemporary *Temp)
Emit a CXXTemporary.
void writeOMPTraitInfo(const OMPTraitInfo *TI)
Write an OMPTraitInfo object.
void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Emit a C++ base specifier.
void writeOMPClause(OMPClause *C)
void writeBool(bool Value)
void AddAPValue(const APValue &Value)
Emit an APvalue.
void AddUnresolvedSet(const ASTUnresolvedSet &Set)
Emit a UnresolvedSet structure.
void AddIdentifierRef(const IdentifierInfo *II)
Emit a reference to an identifier.
void AddStmt(Stmt *S)
Add the given statement or expression to the queue of statements to emit.
void AddDeclarationName(DeclarationName Name)
Emit a declaration name.
void AddTemplateArgumentLocInfo(const TemplateArgumentLoc &Arg)
Emits a template argument location info.
void AddTypeLoc(TypeLoc TL)
Emits source location information for a type. Does not emit the type.
void AddSelectorRef(Selector S)
Emit a Selector (which is a smart pointer reference).
void writeSourceLocation(SourceLocation Loc)
void AddOffset(uint64_t BitOffset)
Add a bit offset into the record.
void AddTypeRef(QualType T)
Emit a reference to a type.
void writeOpenACCClauseList(ArrayRef< const OpenACCClause * > Clauses)
Writes out a list of OpenACC clauses.
void push_back(uint64_t N)
Minimal vector-like interface.
void AddCXXCtorInitializers(ArrayRef< CXXCtorInitializer * > CtorInits)
Emit a CXXCtorInitializer array.
void AddTemplateParameterList(const TemplateParameterList *TemplateParams)
Emit a template parameter list.
void AddTemplateArgument(const TemplateArgument &Arg)
Emit a template argument.
void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc, DeclarationName Name)
void writeOpenACCIntExprList(ArrayRef< Expr * > Exprs)
void AddTemplateName(TemplateName Name)
Emit a template name.
void AddAPFloat(const llvm::APFloat &Value)
Emit a floating-point value.
void AddTypeSourceInfo(TypeSourceInfo *TInfo)
Emits a reference to a declarator info.
void AddQualifierInfo(const QualifierInfo &Info)
void writeUInt32(uint32_t Value)
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
void writeOMPChildren(OMPChildren *Data)
Writes data related to the OpenMP directives.
void AddConceptReference(const ConceptReference *CR)
void AddSourceRange(SourceRange Range)
Emit a source range.
void AddAPInt(const llvm::APInt &Value)
Emit an integral value.
void AddSourceLocation(SourceLocation Loc)
Emit a source location.
void writeOpenACCVarList(const OpenACCClauseWithVarList *C)
void AddAttributes(ArrayRef< const Attr * > Attrs)
Emit a list of attributes.
void AddASTTemplateArgumentListInfo(const ASTTemplateArgumentListInfo *ASTTemplArgList)
Emits an AST template argument list info.
void AddCXXDefinitionData(const CXXRecordDecl *D)
void AddVarDeclInit(const VarDecl *VD)
Emit information about the initializer of a VarDecl.
void writeStmtRef(const Stmt *S)
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg)
Emits a template argument location.
void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Emit a nested name specifier with source-location information.
void AddOpenACCRoutineDeclAttr(const OpenACCRoutineDeclAttr *A)
void writeOpenACCClause(const OpenACCClause *C)
Writes out a single OpenACC Clause.
void AddAttr(const Attr *A)
An UnresolvedSet-like class which uses the ASTContext's allocator.
UnresolvedSetIterator const_iterator
Writes an AST file containing the contents of a translation unit.
static SourceLocationEncoding::Chain EmitSourceLocationOffset(SourceLocation::UIntTy Offset, SourceLocation::UIntTy InitialDelta, RecordDataImpl &Record)
Emit Offset as the next record field and return a chain anchored at Offset + InitialDelta,...
SourceLocation::UIntTy getEntryOffset(const SrcMgr::SLocEntry &SLoc) const
The starting offset of SLoc's entry within this module, with the dummy entry skipped.
void AddEmittedDeclRef(const Decl *D, RecordDataImpl &Record)
friend class ASTRecordWriter
bool isWritingStdCXXNamedModules() const
ArrayRef< uint64_t > RecordDataRef
void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record, StringRef Path)
Emit the current record with the given path as a blob.
void AddFileID(FileID FID, RecordDataImpl &Record)
Emit a FileID.
bool isDeclPredefined(const Decl *D) const
bool IsLocalDecl(const Decl *D) const
Is this a local declaration (that is, one that will be written to our AST file)?
void AddPath(StringRef Path, RecordDataImpl &Record)
Add a path to the given record.
SmallVectorImpl< uint64_t > RecordDataImpl
void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record)
Add a version tuple to the given record.
bool isGeneratingReducedBMI() const
uint32_t getMacroDirectivesOffset(const IdentifierInfo *Name)
void AddAlignPackInfo(const Sema::AlignPackInfo &Info, RecordDataImpl &Record)
Emit a AlignPackInfo.
void AddPathBlob(StringRef Str, RecordDataImpl &Record, SmallVectorImpl< char > &Blob)
llvm::MapVector< serialization::ModuleFile *, const Decl * > CollectFirstDeclFromEachModule(const Decl *D, bool IncludeLocal)
Collect the first declaration from each module file that provides a declaration of D.
void AddTypeRef(ASTContext &Context, QualType T, RecordDataImpl &Record)
Emit a reference to a type.
bool wasDeclEmitted(const Decl *D) const
Whether or not the declaration got emitted.
void AddString(StringRef Str, RecordDataImpl &Record)
Add a string to the given record.
bool isWritingModule() const
LocalDeclID GetDeclRef(const Decl *D)
Force a declaration to be emitted and get its local ID to the module file been writing.
void AddSourceRange(SourceRange Range, RecordDataImpl &Record)
Emit a source range.
LocalDeclID getDeclID(const Decl *D)
Determine the local declaration ID of an already-emitted declaration.
void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record)
Emit a source location.
ASTFileSignature WriteAST(llvm::PointerUnion< Sema *, Preprocessor * > Subject, StringRef OutputFile, Module *WritingModule, StringRef isysroot)
Write a precompiled header or a module with the AST produced by the Sema object, or a dependency scan...
void addTouchedModuleFile(serialization::ModuleFile *)
void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record)
Emit a reference to an identifier.
serialization::MacroID getMacroRef(MacroInfo *MI, const IdentifierInfo *Name)
Get the unique number used to refer to the given macro.
SourceLocationEncoding::RawLocEncoding getRawSourceLocationEncoding(SourceLocation Loc)
Return the raw encodings for source locations.
ASTReader * getChain() const
SourceLocationEncoding::Chain EmitEntryOffset(const SrcMgr::SLocEntry &SLoc, RecordDataImpl &Record)
Emit SLoc's entry offset as the record's first field and return a chain anchored at that entry,...
bool getDoneWritingDeclsAndTypes() const
serialization::IdentifierID getIdentifierRef(const IdentifierInfo *II)
Get the unique number used to refer to the given identifier.
ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl< char > &Buffer, ModuleCache &ModCache, const CodeGenOptions &CodeGenOpts, ArrayRef< std::shared_ptr< ModuleFileExtension > > Extensions, bool IncludeTimestamps=true, bool BuildingImplicitModule=false, bool GeneratingReducedBMI=false)
Create a new precompiled header writer that outputs to the given bitstream.
time_t getTimestampForOutput(time_t ModTime) const
Get a timestamp for output into the AST file.
void handleVTable(CXXRecordDecl *RD)
unsigned getLocalOrImportedSubmoduleID(const Module *Mod)
Retrieve or create a submodule ID for this module, or return 0 if the submodule is neither local (a s...
void AddToken(const Token &Tok, RecordDataImpl &Record)
Emit a token.
void AddLookupOffsets(const LookupBlockOffsets &Offsets, RecordDataImpl &Record)
serialization::SelectorID getSelectorRef(Selector Sel)
Get the unique number used to refer to the given selector.
SmallVector< uint64_t, 64 > RecordData
serialization::TypeID GetOrCreateTypeID(ASTContext &Context, QualType T)
Force a type to be emitted and get its ID.
unsigned getAnonymousDeclarationNumber(const NamedDecl *D)
void AddMacroRef(MacroInfo *MI, const IdentifierInfo *Name, RecordDataImpl &Record)
Emit a reference to a macro.
const LangOptions & getLangOpts() const
void SetSelectorOffset(Selector Sel, uint32_t Offset)
Note that the selector Sel occurs at the given offset within the method pool/selector table.
bool PreparePathForOutput(SmallVectorImpl< char > &Path)
Convert a path from this build process into one that is appropriate for emission in the module file.
void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset)
Note that the identifier II occurs at the given offset within the identifier table.
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
void AddStringBlob(StringRef Str, RecordDataImpl &Record, SmallVectorImpl< char > &Blob)
Wrapper for source info for arrays.
SourceLocation getLBracketLoc() const
Expr * getSizeExpr() const
SourceLocation getRBracketLoc() const
SourceLocation getRParenLoc() const
SourceLocation getKWLoc() const
SourceLocation getLParenLoc() const
Attr - This represents one attribute.
attr::Kind getKind() const
SourceLocation getScopeLoc() const
SourceRange getRange() const
const IdentifierInfo * getScopeName() const
bool isRegularKeywordAttribute() const
const IdentifierInfo * getAttrName() const
Kind getParsedKind() const
const Attr * getAttr() const
The type attribute.
SourceLocation getRParenLoc() const
bool isDecltypeAuto() const
bool isConstrained() const
ConceptReference * getConceptReference() const
A simple helper class to pack several bits in order into (a) 32 bit integer(s).
void addBits(uint32_t Value, uint32_t BitsWidth)
SourceLocation getCaretLoc() const
SourceLocation getBuiltinLoc() const
TypeSpecifierType getWrittenTypeSpec() const
TypeSpecifierWidth getWrittenWidthSpec() const
bool needsExtraLocalData() const
TypeSpecifierSign getWrittenSignSpec() const
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
Represents a C++ destructor within a class.
Represents a C++ struct/union/class.
unsigned getDeviceLambdaManglingNumber() const
Retrieve the device side mangling number.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
unsigned getODRHash() const
Represents a C++ temporary.
const CXXDestructorDecl * getDestructor() const
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
A reference to a concept and its template args, as it appears in the code.
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
NamedDecl * getFoundDecl() const
const DeclarationNameInfo & getConceptNameInfo() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
TemplateName getNamedConcept() const
SourceLocation getTemplateKWLoc() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isFileContext() const
DeclContextLookupResult lookup_result
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isLookupContext() const
Test whether the context supports looking up names.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
StoredDeclsMap * buildLookup()
Ensure the lookup structure is fully-built and return it.
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
StoredDeclsMap * getLookupPtr() const
Retrieve the internal representation of the lookup structure.
DeclID getRawValue() const
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Module * getTopLevelOwningNamedModule() const
Get the top level owning named module that owns this declaration if any.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool isInNamedModule() const
Whether this declaration comes from a named module.
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
@ FOK_None
Not a friend object.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
bool isFromExplicitGlobalModule() const
Whether this declaration comes from explicit global module.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
DeclContext * getNonTransparentDeclContext()
Return the non transparent context.
SourceLocation getLocation() const
DeclContext * getDeclContext()
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
GlobalDeclID getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
DeclarationNameLoc - Additional source/type location info for a declaration name.
SourceLocation getCXXLiteralOperatorNameLoc() const
Return the location of the literal operator name (without the operator keyword).
TypeSourceInfo * getNamedTypeInfo() const
Returns the source type info.
SourceRange getCXXOperatorNameRange() const
Return the range of the operator name (without the operator keyword).
The name of a declaration.
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
SourceLocation getDecltypeLoc() const
SourceLocation getRParenLoc() const
SourceLocation getElaboratedKeywordLoc() const
SourceLocation getTemplateNameLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
Expr * getAttrExprOperand() const
The attribute's expression operand, if it has one.
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
NestedNameSpecifierLoc getQualifierLoc() const
SourceLocation getNameLoc() const
SourceLocation getElaboratedKeywordLoc() const
SourceLocation getNameLoc() const
SourceLocation getNameLoc() const
std::vector< std::string > Remarks
The list of -R... options used to alter the diagnostic mappings, with the prefixes removed.
std::vector< std::string > Warnings
The list of -W... options used to alter the diagnostic mappings, with the prefixes removed.
DiagnosticOptions & getDiagnosticOptions() const
Retrieve the diagnostic options.
bool hasUncompilableErrorOccurred() const
Errors that actually prevent compilation, not those that are upgraded from a warning by -Werror.
StringRef getName() const
SourceLocation getElaboratedKeywordLoc() const
SourceLocation getNameLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
This represents one expression.
storage_type getAsOpaqueInt() const
storage_type getAsOpaqueInt() const
Represents a member of a struct/union/class.
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
StringRef getName() const
The name of this FileEntry.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
int getOpaqueValue() const
Returns the raw integer representation of this FileID.
void trackVFSUsage(bool Active)
Enable or disable tracking of VFS usage.
llvm::vfs::FileSystem & getVirtualFileSystem() const
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(FileEntryRef Entry, bool isVolatile=false, bool RequiresNullTerminator=true, std::optional< int64_t > MaybeLimit=std::nullopt, bool IsText=true)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
FileSystemOptions & getFileSystemOpts()
Returns the current file system options.
bool makeAbsolutePath(SmallVectorImpl< char > &Path, bool Canonicalize=false) const
Makes Path absolute taking into account FileSystemOptions and the working directory option,...
OptionalFileEntryRef getOptionalFileRef(StringRef Filename, bool OpenFile=false, bool CacheFailure=true, bool IsText=true)
Get a FileEntryRef if it exists, without doing anything on error.
OptionalDirectoryEntryRef getOptionalDirectoryRef(StringRef DirName, bool CacheFailure=true)
Get a DirectoryEntryRef if it exists, without doing anything on error.
std::string WorkingDir
If set, paths are resolved as if the working directory was set to the value of WorkingDir.
Represents a function declaration or definition.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Declaration of a template function.
Wrapper for source info for functions.
unsigned getNumParams() const
ParmVarDecl * getParam(unsigned i) const
SourceLocation getLocalRangeEnd() const
SourceRange getExceptionSpecRange() const
SourceLocation getLocalRangeBegin() const
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
One of these records is kept for each identifier that is lexed.
unsigned getLength() const
Efficiently return the length of this identifier info.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
bool hasChangedSinceDeserialization() const
Determine whether this identifier has changed since it was loaded from an AST file.
bool isCPlusPlusOperatorKeyword() const
bool hasFETokenInfoChangedSinceDeserialization() const
Determine whether the frontend token information for this identifier has changed since it was loaded ...
bool hasMacroDefinition() const
Return true if this identifier is #defined to some other value.
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
bool isPoisoned() const
Return true if this token has been poisoned.
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
tok::NotableIdentifierKind getNotableIdentifierID() const
unsigned getObjCOrBuiltinID() const
tok::ObjCKeywordKind getObjCKeywordID() const
Return the Objective-C keyword ID for the this identifier.
void * getFETokenInfo() const
Get and set FETokenInfo.
StringRef getName() const
Return the actual identifier string.
bool isExtensionToken() const
get/setExtension - Initialize information about whether or not this language token is an extension.
iterator begin(DeclarationName Name)
Returns an iterator over decls with the name 'Name'.
iterator end()
Returns the end iterator.
llvm::iterator_range< iterator > decls(DeclarationName Name)
Returns a range of decls with the name 'Name'.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
SourceLocation getAmpLoc() const
Describes the capture of a variable or of this, or of a C++1y init-capture.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
clang::ObjCRuntime ObjCRuntime
CommentOptions CommentOpts
Options for parsing comments.
std::string OMPHostIRFile
Name of the IR file that contains the result of the OpenMP target host code generation.
LangStandard::Kind LangStd
The used language standard.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
std::string CurrentModule
The name of the current module, of which the main source file is a part.
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
Record the location of a macro definition.
Encapsulates changes to the "macros namespace" (the location where the macro name became active,...
const MacroDirective * getPrevious() const
Get previous definition of the macro with the same name.
const MacroInfo * getMacroInfo() const
SourceLocation getLocation() const
Encapsulates the data about a macro definition (e.g.
bool isUsed() const
Return false if this macro is defined in the main file and has not yet been used.
bool isC99Varargs() const
SourceLocation getDefinitionEndLoc() const
Return the location of the last token in the macro.
ArrayRef< const IdentifierInfo * > params() const
unsigned getNumTokens() const
Return the number of tokens that this macro expands to.
unsigned getNumParams() const
const Token & getReplacementToken(unsigned Tok) const
bool isBuiltinMacro() const
Return true if this macro requires processing before expansion.
SourceLocation getDefinitionLoc() const
Return the location that the macro was defined at.
bool hasCommaPasting() const
bool isObjectLike() const
bool isUsedForHeaderGuard() const
Determine whether this macro was used for a header guard.
bool isGNUVarargs() const
SourceLocation getExpansionLoc() const
Expr * getAttrColumnOperand() const
The attribute's column operand, if it has one.
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Expr * getAttrRowOperand() const
The attribute's row operand, if it has one.
NestedNameSpecifierLoc getQualifierLoc() const
SourceLocation getStarLoc() const
The module cache used for compiling modules implicitly.
virtual void writeExtensionContents(Sema &SemaRef, llvm::BitstreamWriter &Stream)=0
Write the contents of the extension block into the given bitstream.
ModuleFileExtension * getExtension() const
Retrieve the module file extension with which this writer is associated.
virtual ModuleFileExtensionMetadata getExtensionMetadata() const =0
Retrieves the metadata for this module file extension.
StringRef str() const
Returns the plain module file name.
void resolveHeaderDirectives(const FileEntry *File) const
Resolve all lazy header directives for the specified file.
ArrayRef< KnownHeader > findResolvedModulesForHeader(FileEntryRef File) const
Like findAllModulesForHeader, but do not attempt to infer module ownership from umbrella headers if w...
FileID getModuleMapFileIDForUniquing(const Module *M) const
Get the module map file that (along with the module name) uniquely identifies this module.
FileID getContainingModuleMapFileID(const Module *Module) const
Retrieve the module map file containing the definition of the given module.
ModuleHeaderRole
Flags describing the role of a module header.
static ModuleHeaderRole headerKindToRole(Module::HeaderKind Kind)
Convert a header kind to a role. Requires Kind to not be HK_Excluded.
Describes a module or submodule.
unsigned IsExplicit
Whether this is an explicit submodule.
SmallVector< ExportDecl, 2 > Exports
The set of export declarations.
unsigned InferSubmodules
Whether we should infer submodules for this module based on the headers.
std::vector< std::string > ConfigMacros
The set of "configuration macros", which are macros that (intentionally) change how this module is bu...
SourceLocation DefinitionLoc
The location of the module definition.
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system.
Module * Parent
The parent of this module.
ModuleKind Kind
The kind of this module.
bool isUnimportable() const
Determine whether this module has been declared unimportable.
unsigned IsInferred
Whether this is an inferred submodule (module * { ... }).
unsigned IsSystem
Whether this is a "system" module (which assumes that all headers in it are system headers).
std::string Name
The name of this module.
llvm::iterator_range< submodule_iterator > submodules()
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "C"...
unsigned ModuleMapIsPrivate
Whether this module came from a "private" module map, found next to a regular (public) module map.
llvm::SmallVector< LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used.
std::optional< Header > getUmbrellaHeaderAsWritten() const
Retrieve the umbrella header as written.
SmallVector< Requirement, 2 > Requirements
The set of language features required to use this module.
llvm::SmallSetVector< const Module *, 2 > UndeclaredUses
When NoUndeclaredIncludes is true, the set of modules this module tried to import but didn't because ...
OptionalDirectoryEntryRef Directory
The build directory of this module.
llvm::SmallVector< ModuleRef, 2 > AffectingClangModules
The set of top-level modules that affected the compilation of this module, but were not imported.
unsigned NamedModuleHasInit
Whether this C++20 named modules doesn't need an initializer.
unsigned ConfigMacrosExhaustive
Whether the set of configuration macros is exhaustive.
ASTFileSignature Signature
The module signature.
ArrayRef< Header > getHeaders(HeaderKind HK) const
unsigned InferExportWildcard
Whether, when inferring submodules, the inferr submodules should export all modules they import (e....
ArrayRef< FileEntryRef > getTopHeaders(FileManager &FileMgr)
The top-level headers associated with this module.
std::optional< DirectoryName > getUmbrellaDirAsWritten() const
Retrieve the umbrella directory as written.
unsigned IsFramework
Whether this is a framework module.
std::string ExportAsModule
The module through which entities defined in this module will eventually be exposed,...
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
llvm::SmallVector< ModuleRef, 2 > Imports
The set of modules imported by this module, and on which this module depends.
std::vector< Conflict > Conflicts
The list of conflicts.
This represents a decl that may have a name.
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
NamespaceAndPrefixLoc getAsNamespaceAndPrefix() const
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
SourceRange getLocalSourceRange() const
Retrieve the source range covering just the last part of this nested-name-specifier,...
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Kind
The kind of specifier that completes this nested name specifier.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
This represents the 'align' clause in the 'pragma omp allocate' directive.
This represents clause 'allocate' in the 'pragma omp ...' directives.
This represents 'allocator' clause in the 'pragma omp ...' directive.
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc.
Class that handles pre-initialization statement for some clauses, like 'schedule',...
This is a basic class for representing single OpenMP clause.
This represents 'collapse' clause in the 'pragma omp ...' directive.
This represents the 'counts' clause in the 'pragma omp split' directive.
This represents 'default' clause in the 'pragma omp ...' directive.
This represents the 'depth' clause on the 'pragma omp flatten' (and 'pragma omp fuse') loop-transform...
This represents 'final' clause in the 'pragma omp ...' directive.
Representation of the 'full' clause of the 'pragma omp unroll' directive.
This represents 'if' clause in the 'pragma omp ...' directive.
This class represents the 'looprange' clause in the 'pragma omp fuse' directive.
This represents 'num_threads' clause in the 'pragma omp ...' directive.
Representation of the 'partial' clause of the 'pragma omp unroll' directive.
This class represents the 'permutation' clause in the 'pragma omp interchange' directive.
This represents 'safelen' clause in the 'pragma omp ...' directive.
This represents 'simdlen' clause in the 'pragma omp ...' directive.
This represents the 'sizes' clause in the 'pragma omp tile' directive.
This represents 'threadset' clause in the 'pragma omp task ...' directive.
ObjCCategoryDecl - Represents a category declaration.
Represents an ObjC class declaration.
filtered_category_iterator< isKnownCategory > known_categories_iterator
Iterator that walks over all of the known categories and extensions, including those that are hidden.
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
SourceLocation getNameEndLoc() const
SourceLocation getNameLoc() const
SourceLocation getStarLoc() const
bool hasBaseTypeAsWritten() const
SourceLocation getTypeArgsLAngleLoc() const
unsigned getNumTypeArgs() const
unsigned getNumProtocols() const
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
SourceLocation getProtocolRAngleLoc() const
SourceLocation getProtocolLoc(unsigned i) const
SourceLocation getProtocolLAngleLoc() const
SourceLocation getTypeArgsRAngleLoc() const
const VersionTuple & getVersion() const
unsigned getNumProtocols() const
SourceLocation getProtocolLoc(unsigned i) const
SourceLocation getProtocolLAngleLoc() const
SourceLocation getProtocolRAngleLoc() const
Represents a clause with one or more 'var' objects, represented as an expr, as its arguments.
This is the base type for all OpenACC Clauses.
SourceLocation getAttrLoc() const
SourceLocation getEllipsisLoc() const
SourceLocation getEllipsisLoc() const
SourceLocation getRParenLoc() const
SourceLocation getLParenLoc() const
Represents a parameter to a function.
SourceLocation getKWLoc() const
SourceLocation getStarLoc() const
MacroDefinitionRecord * findMacroDefinition(const MacroInfo *MI)
Retrieve the macro definition that corresponds to the given MacroInfo.
const std::vector< SourceRange > & getSkippedRanges()
Retrieve all ranges that got skipped while preprocessing.
iterator local_begin()
Begin iterator for local, non-loaded, preprocessed entities.
iterator local_end()
End iterator for local, non-loaded, preprocessed entities.
std::vector< std::string > MacroIncludes
std::vector< std::string > Includes
bool WriteCommentListToPCH
Whether to write comment locations into the PCH when building it.
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
bool DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
std::vector< std::pair< std::string, bool > > Macros
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
ArrayRef< ModuleMacro * > getLeafModuleMacros(const IdentifierInfo *II) const
Get the list of leaf (non-overridden) module macros for a name.
ArrayRef< PPConditionalInfo > getPreambleConditionalStack() const
bool isRecordingPreamble() const
MacroDirective * getLocalMacroDirectiveHistory(const IdentifierInfo *II) const
Given an identifier, return the latest non-imported macro directive for that identifier.
bool SawDateOrTime() const
Returns true if the preprocessor has seen a use of DATE or TIME in the file so far.
SourceManager & getSourceManager() const
std::optional< PreambleSkipInfo > getPreambleSkipInfo() const
bool hasRecordedPreamble() const
const TargetInfo & getTargetInfo() const
FileManager & getFileManager() const
bool alreadyIncluded(FileEntryRef File) const
Return true if this header has already been included.
FileID getPredefinesFileID() const
Returns the FileID for the preprocessor predefines.
HeaderSearch & getHeaderSearchInfo() const
SmallVector< SourceLocation, 64 > serializeSafeBufferOptOutMap() const
IdentifierTable & getIdentifierTable()
const PreprocessorOptions & getPreprocessorOpts() const
Retrieve the preprocessor options used to initialize this preprocessor.
const LangOptions & getLangOpts() const
PreprocessingRecord * getPreprocessingRecord() const
Retrieve the preprocessing record, or NULL if there is no preprocessing record.
DiagnosticsEngine & getDiagnostics() const
uint32_t getCounterValue() const
SourceLocation getPreambleRecordedPragmaAssumeNonNullLoc() const
Get the location of the recorded unterminated #pragma clang assume_nonnull begin in the preamble,...
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
A (possibly-)qualified type.
Wrapper of type source information for a type with non-trivial direct qualifiers.
SourceLocation getAmpAmpLoc() const
Represents a struct/union/class.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Smart pointer class that efficiently represents Objective-C method names.
const IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
void * getAsOpaquePtr() const
unsigned getNumArgs() const
void updateOutOfDateSelector(Selector Sel)
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
ArrayRef< const OMPRequiresDecl * > getRequiresDecls() const
The 'requires' directives seen so far in this translation unit.
bool DeclareAndesVectorBuiltins
Indicate RISC-V Andes vector builtin functions enabled or not.
bool DeclareSiFiveVectorBuiltins
Indicate RISC-V SiFive vector builtin functions enabled or not.
bool DeclareRVVBuiltins
Indicate RISC-V vector builtin functions enabled or not.
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Sema - This implements semantic analysis and AST building for C.
DelegatingCtorDeclsType DelegatingCtorDecls
All the delegating constructors seen so far in the file, used for cycle detection at the end of the T...
Preprocessor & getPreprocessor() const
PragmaStack< FPOptionsOverride > FpPragmaStack
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimizeoff". If this location is invalid,...
FPOptionsOverride CurFPFeatureOverrides()
LateParsedTemplateMapT LateParsedTemplateMap
UnusedFileScopedDeclsType UnusedFileScopedDecls
The set of file scoped decls seen so far that have not been used and must warn if not used.
SmallVector< const Decl * > DeclsWithEffectsToVerify
All functions/lambdas/blocks which have bodies and which have a non-empty FunctionEffectsRef to be ve...
EnumDecl * getStdAlignValT() const
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate > > LateParsedTemplateMapT
CXXRecordDecl * getStdBadAlloc() const
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
llvm::DenseMap< CXXRecordDecl *, bool > VTablesUsed
The set of classes whose vtables have been used within this translation unit, and a bit that will be ...
PragmaStack< AlignPackInfo > AlignPackStack
llvm::SmallSetVector< Decl *, 4 > DeclsToCheckForDeferredDiags
Function or variable declarations to be checked for whether the deferred diagnostics should be emitte...
llvm::MapVector< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
const llvm::MapVector< FieldDecl *, DeleteLocs > & getMismatchingDeleteExpressions() const
Retrieves list of suspicious delete-expressions that will be checked at the end of translation unit.
OpenCLOptions & getOpenCLOptions()
NamespaceDecl * getStdNamespace() const
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
llvm::MapVector< IdentifierInfo *, llvm::SetVector< WeakInfo, llvm::SmallVector< WeakInfo, 1u >, llvm::SmallDenseSet< WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly > > > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
void getSortedUnusedLocalTypedefNameCandidates(SmallVectorImpl< const TypedefNameDecl * > &Sorted) const
Store UnusedLocalTypedefNameCandidates in Sorted in a deterministic order.
IdentifierResolver IdResolver
A delta encoder for a run of source locations.
static RawLocEncoding encode(SourceLocation Loc, UIntTy BaseOffset, unsigned BaseModuleFileIndex)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
FileIDAndOffset getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
DiagnosticsEngine & getDiagnostics() const
SourceLocation::UIntTy getNextLocalOffset() const
bool isLocalSourceLocation(SourceLocation Loc) const
Returns true if Loc did not come from a PCH/Module.
OptionalFileEntryRef getFileEntryRefForID(FileID FID) const
Returns the FileEntryRef for the provided FileID.
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location,...
const SrcMgr::SLocEntry & getLocalSLocEntry(unsigned Index) const
Get a local SLocEntry. This is exposed for indexing.
FileManager & getFileManager() const
unsigned local_sloc_entry_size() const
Get the number of local SLocEntries we have.
SourceLocation getLocForEndOfFile(FileID FID) const
Return the source location corresponding to the last byte of the specified file.
FileID getMainFileID() const
Returns the FileID of the main source file.
unsigned getFileIDSize(FileID FID) const
The size of the SLocEntry that FID represents.
bool hasLineTable() const
Determine if the source manager has a line table.
bool isLoadedFileID(FileID FID) const
Returns true if FID came from a PCH/Module.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
LineTableInfo & getLineTable()
Retrieve the stored line table.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
OptionalFileEntryRef ContentsEntry
References the file which the contents were actually loaded from.
unsigned IsTransient
True if this file may be transient, that is, if it might not exist at some later point in time when t...
std::optional< llvm::MemoryBufferRef > getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM, SourceLocation Loc=SourceLocation()) const
Returns the memory buffer for the associated content.
unsigned BufferOverridden
Indicates whether the buffer itself was provided to override the actual file contents.
OptionalFileEntryRef OrigEntry
Reference to the file entry representing this ContentCache.
SourceLocation getExpansionLocStart() const
bool isExpansionTokenRange() const
SourceLocation getSpellingLoc() const
bool isMacroArgExpansion() const
SourceLocation getExpansionLocEnd() const
const ContentCache & getContentCache() const
This is a discriminated union of FileInfo and ExpansionInfo.
SourceLocation::UIntTy getOffset() const
const FileInfo & getFile() const
const ExpansionInfo & getExpansion() const
An array of decls optimized for the common case of only containing one entry.
StringLiteral - This represents a string literal expression, e.g.
Represents the declaration of a struct/union/class/enum.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
SourceLocation getNameLoc() const
SourceLocation getElaboratedKeywordLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
TargetOptions & getTargetOpts() const
Retrieve the target options.
std::string Triple
The name of the target triple to compile for.
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings starting...
std::string ABI
If given, the name of the target ABI to use.
std::string TuneCPU
If given, the name of the target CPU to tune code for.
std::string CPU
If given, the name of the target CPU to generate code for.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line.
A template argument list.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
Location wrapper for a TemplateArgument.
SourceLocation getTemplateEllipsisLoc() const
TemplateArgumentLocInfo getLocInfo() const
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKWLoc() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
Stores a list of template parameters for a TemplateDecl and its derived classes.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
SourceLocation getTemplateLoc() const
unsigned getNumArgs() const
SourceLocation getLAngleLoc() const
TemplateArgumentLoc getArgLoc(unsigned i) const
SourceLocation getRAngleLoc() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKeywordLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
SourceLocation getElaboratedKeywordLoc() const
Token - This structure provides full information about a lexed token.
The top declaration context.
NamespaceDecl * getAnonymousNamespace() const
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
TypeSourceInfo * getUnmodifiedTInfo() const
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getNameLoc() const
TypeClass getTypeClass() const
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
SourceLocation getTypeofLoc() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
const APValue * getEvaluatedValue() const
Return the already-evaluated value of this variable's initializer, or nullptr if the value is not yet...
bool hasInitWithSideEffects() const
Checks whether this declaration has an initializer with side effects.
EvaluatedStmt * getEvaluatedStmt() const
const Expr * getInit() const
Declaration of a variable template.
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getNameLoc() const
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
SourceLocation getEllipsisLoc() const
Retrieve the source location of the ellipsis, whose presence indicates that the capture is a pack exp...
OverloadedOperatorKind getOperatorKind() const
IdentifierInfo * getIdentifier() const
Selector getSelector() const
Information about a module that has been loaded by the ASTReader.
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
unsigned LocalNumSubmodules
The number of submodules in this module.
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
unsigned Index
The index of this module in the list of modules.
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
SourceLocation::UIntTy SLocEntryBaseOffset
The base offset in the source manager's view of this module.
ModuleFileName FileName
The file name of the module file.
unsigned LocalNumSelectors
The number of selectors new to this file.
ModuleKind Kind
The type of this module.
std::string ModuleName
The name of the module.
A type index; the type ID with the qualifier bits removed.
uint32_t getModuleFileIndex() const
TypeID asTypeID(unsigned FastQuals) const
uint64_t getValue() const
SmallVector< LazySpecializationInfo, 4 > data_type
The lookup result is a list of global declaration IDs.
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
TypeCode
Record codes for each kind of type.
const unsigned int DECL_UPDATES
Record of updates for a declaration that was modified after being deserialized.
@ PREDEF_TYPE_AUTO_RREF_DEDUCT
The "auto &&" deduction type.
@ PREDEF_TYPE_NULL_ID
The NULL type.
@ PREDEF_TYPE_AUTO_DEDUCT
The "auto" deduction type.
@ CTOR_INITIALIZER_MEMBER
@ CTOR_INITIALIZER_DELEGATING
@ CTOR_INITIALIZER_INDIRECT_MEMBER
@ DECL_EMPTY
An EmptyDecl record.
@ DECL_CXX_BASE_SPECIFIERS
A record containing CXXBaseSpecifiers.
@ DECL_CXX_RECORD
A CXXRecordDecl record.
@ DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION
A VarTemplatePartialSpecializationDecl record.
@ DECL_OMP_ALLOCATE
An OMPAllocateDcl record.
@ DECL_MS_PROPERTY
A MSPropertyDecl record.
@ DECL_REQUIRES_EXPR_BODY
A RequiresExprBodyDecl record.
@ DECL_STATIC_ASSERT
A StaticAssertDecl record.
@ DECL_INDIRECTFIELD
A IndirectFieldDecl record.
@ DECL_TEMPLATE_TEMPLATE_PARM
A TemplateTemplateParmDecl record.
@ DECL_IMPORT
An ImportDecl recording a module import.
@ DECL_ACCESS_SPEC
An AccessSpecDecl record.
@ DECL_OBJC_TYPE_PARAM
An ObjCTypeParamDecl record.
@ DECL_OBJC_CATEGORY_IMPL
A ObjCCategoryImplDecl record.
@ DECL_ENUM_CONSTANT
An EnumConstantDecl record.
@ DECL_PARM_VAR
A ParmVarDecl record.
@ DECL_TYPEDEF
A TypedefDecl record.
@ DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack.
@ DECL_HLSL_BUFFER
A HLSLBufferDecl record.
@ DECL_NAMESPACE_ALIAS
A NamespaceAliasDecl record.
@ DECL_TYPEALIAS
A TypeAliasDecl record.
@ DECL_FUNCTION_TEMPLATE
A FunctionTemplateDecl record.
@ DECL_UNRESOLVED_USING_TYPENAME
An UnresolvedUsingTypenameDecl record.
@ DECL_CLASS_TEMPLATE_SPECIALIZATION
A ClassTemplateSpecializationDecl record.
@ DECL_FILE_SCOPE_ASM
A FileScopeAsmDecl record.
@ DECL_PARTIAL_SPECIALIZATIONS
@ DECL_CXX_CONSTRUCTOR
A CXXConstructorDecl record.
@ DECL_CXX_CONVERSION
A CXXConversionDecl record.
@ DECL_FIELD
A FieldDecl record.
@ DECL_LINKAGE_SPEC
A LinkageSpecDecl record.
@ DECL_CONTEXT_TU_LOCAL_VISIBLE
A record that stores the set of declarations that are only visible to the TU.
@ DECL_NAMESPACE
A NamespaceDecl record.
@ DECL_NON_TYPE_TEMPLATE_PARM
A NonTypeTemplateParmDecl record.
@ DECL_FUNCTION
A FunctionDecl record.
@ DECL_USING_DIRECTIVE
A UsingDirecitveDecl record.
@ DECL_RECORD
A RecordDecl record.
@ DECL_CONTEXT_LEXICAL
A record that stores the set of declarations that are lexically stored within a given DeclContext.
@ DECL_BLOCK
A BlockDecl record.
@ DECL_UNRESOLVED_USING_VALUE
An UnresolvedUsingValueDecl record.
@ DECL_TYPE_ALIAS_TEMPLATE
A TypeAliasTemplateDecl record.
@ DECL_CXX_CTOR_INITIALIZERS
A record containing CXXCtorInitializers.
@ DECL_OBJC_CATEGORY
A ObjCCategoryDecl record.
@ DECL_VAR
A VarDecl record.
@ DECL_USING
A UsingDecl record.
@ DECL_OBJC_PROTOCOL
A ObjCProtocolDecl record.
@ DECL_TEMPLATE_TYPE_PARM
A TemplateTypeParmDecl record.
@ DECL_VAR_TEMPLATE_SPECIALIZATION
A VarTemplateSpecializationDecl record.
@ DECL_OBJC_IMPLEMENTATION
A ObjCImplementationDecl record.
@ DECL_OBJC_COMPATIBLE_ALIAS
A ObjCCompatibleAliasDecl record.
@ DECL_FRIEND_TEMPLATE
A FriendTemplateDecl record.
@ DECL_PRAGMA_DETECT_MISMATCH
A PragmaDetectMismatchDecl record.
@ DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack.
@ DECL_OBJC_AT_DEFS_FIELD
A ObjCAtDefsFieldDecl record.
@ DECL_IMPLICIT_PARAM
An ImplicitParamDecl record.
@ DECL_FRIEND
A FriendDecl record.
@ DECL_CXX_METHOD
A CXXMethodDecl record.
@ DECL_EXPORT
An ExportDecl record.
@ DECL_PRAGMA_COMMENT
A PragmaCommentDecl record.
@ DECL_ENUM
An EnumDecl record.
@ DECL_CONTEXT_MODULE_LOCAL_VISIBLE
A record containing the set of declarations that are only visible from DeclContext in the same module...
@ DECL_OMP_DECLARE_REDUCTION
An OMPDeclareReductionDecl record.
@ DECL_OMP_THREADPRIVATE
An OMPThreadPrivateDecl record.
@ DECL_OBJC_METHOD
A ObjCMethodDecl record.
@ DECL_CXX_DESTRUCTOR
A CXXDestructorDecl record.
@ DECL_OMP_CAPTUREDEXPR
An OMPCapturedExprDecl record.
@ DECL_CLASS_TEMPLATE
A ClassTemplateDecl record.
@ DECL_USING_SHADOW
A UsingShadowDecl record.
@ DECL_CONCEPT
A ConceptDecl record.
@ DECL_OBJC_IVAR
A ObjCIvarDecl record.
@ DECL_OBJC_PROPERTY
A ObjCPropertyDecl record.
@ DECL_OBJC_INTERFACE
A ObjCInterfaceDecl record.
@ DECL_VAR_TEMPLATE
A VarTemplateDecl record.
@ DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION
A ClassTemplatePartialSpecializationDecl record.
@ DECL_CONTEXT_VISIBLE
A record that stores the set of declarations that are visible from a given DeclContext.
@ DECL_OBJC_PROPERTY_IMPL
A ObjCPropertyImplDecl record.
@ TYPE_EXT_QUAL
An ExtQualType record.
@ EXPR_DESIGNATED_INIT
A DesignatedInitExpr record.
@ EXPR_COMPOUND_LITERAL
A CompoundLiteralExpr record.
@ EXPR_OBJC_IVAR_REF_EXPR
An ObjCIvarRefExpr record.
@ EXPR_MEMBER
A MemberExpr record.
@ EXPR_CXX_TEMPORARY_OBJECT
A CXXTemporaryObjectExpr record.
@ EXPR_CXX_UNRESOLVED_LOOKUP
@ EXPR_COMPOUND_ASSIGN_OPERATOR
A CompoundAssignOperator record.
@ EXPR_EXPR_WITH_CLEANUPS
@ EXPR_CXX_STATIC_CAST
A CXXStaticCastExpr record.
@ EXPR_OBJC_STRING_LITERAL
An ObjCStringLiteral record.
@ EXPR_VA_ARG
A VAArgExpr record.
@ EXPR_CXX_OPERATOR_CALL
A CXXOperatorCallExpr record.
@ STMT_OBJC_AT_TRY
An ObjCAtTryStmt record.
@ EXPR_CXX_UNRESOLVED_CONSTRUCT
@ EXPR_FIXEDPOINT_LITERAL
@ STMT_DO
A DoStmt record.
@ STMT_OBJC_CATCH
An ObjCAtCatchStmt record.
@ STMT_IF
An IfStmt record.
@ EXPR_CXX_EXPRESSION_TRAIT
@ EXPR_STRING_LITERAL
A StringLiteral record.
@ EXPR_IMPLICIT_CAST
An ImplicitCastExpr record.
@ STMT_GCCASM
A GCC-style AsmStmt record.
@ EXPR_IMAGINARY_LITERAL
An ImaginaryLiteral record.
@ STMT_WHILE
A WhileStmt record.
@ EXPR_STMT
A StmtExpr record.
@ EXPR_CXX_REINTERPRET_CAST
A CXXReinterpretCastExpr record.
@ EXPR_DESIGNATED_INIT_UPDATE
A DesignatedInitUpdateExpr record.
@ STMT_OBJC_AT_SYNCHRONIZED
An ObjCAtSynchronizedStmt record.
@ EXPR_CXX_PSEUDO_DESTRUCTOR
@ EXPR_CHARACTER_LITERAL
A CharacterLiteral record.
@ EXPR_OBJC_ENCODE
An ObjCEncodeExpr record.
@ EXPR_CSTYLE_CAST
A CStyleCastExpr record.
@ EXPR_OBJC_BOXED_EXPRESSION
@ EXPR_OBJC_BOOL_LITERAL
An ObjCBoolLiteralExpr record.
@ EXPR_CXX_BIND_TEMPORARY
@ EXPR_EXT_VECTOR_ELEMENT
An ExtVectorElementExpr record.
@ STMT_RETURN
A ReturnStmt record.
@ STMT_OBJC_FOR_COLLECTION
An ObjCForCollectionStmt record.
@ STMT_CONTINUE
A ContinueStmt record.
@ EXPR_PREDEFINED
A PredefinedExpr record.
@ EXPR_CXX_BOOL_LITERAL
A CXXBoolLiteralExpr record.
@ EXPR_PAREN_LIST
A ParenListExpr record.
@ EXPR_CXX_PAREN_LIST_INIT
A CXXParenListInitExpr record.
@ STMT_COMPOUND
A CompoundStmt record.
@ STMT_FOR
A ForStmt record.
@ STMT_ATTRIBUTED
An AttributedStmt record.
@ EXPR_CXX_REWRITTEN_BINARY_OPERATOR
A CXXRewrittenBinaryOperator record.
@ STMT_GOTO
A GotoStmt record.
@ EXPR_NO_INIT
An NoInitExpr record.
@ EXPR_OBJC_ARRAY_LITERAL
@ EXPR_OBJC_PROTOCOL_EXPR
An ObjCProtocolExpr record.
@ EXPR_CXX_CONSTRUCT
A CXXConstructExpr record.
@ EXPR_OBJC_DICTIONARY_LITERAL
@ EXPR_CXX_DYNAMIC_CAST
A CXXDynamicCastExpr record.
@ STMT_CXX_TRY
A CXXTryStmt record.
@ EXPR_GENERIC_SELECTION
A GenericSelectionExpr record.
@ EXPR_CALL
A CallExpr record.
@ EXPR_GNU_NULL
A GNUNullExpr record.
@ EXPR_BINARY_CONDITIONAL_OPERATOR
@ EXPR_OBJC_PROPERTY_REF_EXPR
An ObjCPropertyRefExpr record.
@ EXPR_CXX_CONST_CAST
A CXXConstCastExpr record.
@ STMT_REF_PTR
A reference to a previously [de]serialized Stmt record.
@ EXPR_OBJC_MESSAGE_EXPR
An ObjCMessageExpr record.
@ EXPR_CXX_DEPENDENT_SCOPE_DECL_REF
@ STMT_CASE
A CaseStmt record.
@ EXPR_FUNCTION_PARM_PACK
@ STMT_STOP
A marker record that indicates that we are at the end of an expression.
@ EXPR_CXX_NULL_PTR_LITERAL
@ STMT_MSASM
A MS-style AsmStmt record.
@ EXPR_CONDITIONAL_OPERATOR
A ConditionOperator record.
@ EXPR_BINARY_OPERATOR
A BinaryOperator record.
@ EXPR_CXX_STD_INITIALIZER_LIST
A CXXStdInitializerListExpr record.
@ EXPR_SHUFFLE_VECTOR
A ShuffleVectorExpr record.
@ STMT_OBJC_FINALLY
An ObjCAtFinallyStmt record.
@ EXPR_OBJC_SELECTOR_EXPR
An ObjCSelectorExpr record.
@ EXPR_FLOATING_LITERAL
A FloatingLiteral record.
@ EXPR_CXX_DEPENDENT_SCOPE_MEMBER
@ STMT_NULL_PTR
A NULL expression.
@ STMT_DEFAULT
A DefaultStmt record.
@ EXPR_CHOOSE
A ChooseExpr record.
@ STMT_NULL
A NullStmt record.
@ EXPR_DECL_REF
A DeclRefExpr record.
@ EXPR_SUBST_NON_TYPE_TEMPLATE_PARM
@ EXPR_INIT_LIST
An InitListExpr record.
@ EXPR_IMPLICIT_VALUE_INIT
An ImplicitValueInitExpr record.
@ EXPR_PAREN
A ParenExpr record.
@ EXPR_DEPENDENT_TEMPLATE_ID
@ STMT_LABEL
A LabelStmt record.
@ EXPR_CXX_FUNCTIONAL_CAST
A CXXFunctionalCastExpr record.
@ EXPR_USER_DEFINED_LITERAL
A UserDefinedLiteral record.
@ EXPR_INTEGER_LITERAL
An IntegerLiteral record.
@ EXPR_MATERIALIZE_TEMPORARY
@ EXPR_CXX_MEMBER_CALL
A CXXMemberCallExpr record.
@ STMT_SWITCH
A SwitchStmt record.
@ STMT_DECL
A DeclStmt record.
@ EXPR_CXX_UNRESOLVED_MEMBER
@ EXPR_OBJC_KVC_REF_EXPR
UNUSED.
@ EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK
@ EXPR_CXX_SCALAR_VALUE_INIT
@ EXPR_SIZEOF_ALIGN_OF
A SizefAlignOfExpr record.
@ STMT_BREAK
A BreakStmt record.
@ STMT_OBJC_AT_THROW
An ObjCAtThrowStmt record.
@ EXPR_ADDR_LABEL
An AddrLabelExpr record.
@ STMT_CXX_FOR_RANGE
A CXXForRangeStmt record.
@ EXPR_CXX_ADDRSPACE_CAST
A CXXAddrspaceCastExpr record.
@ EXPR_ARRAY_SUBSCRIPT
An ArraySubscriptExpr record.
@ EXPR_UNARY_OPERATOR
A UnaryOperator record.
@ STMT_CXX_CATCH
A CXXCatchStmt record.
@ STMT_INDIRECT_GOTO
An IndirectGotoStmt record.
Defines the clang::TargetInfo interface.
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
bool isModuleMap(CharacteristicKind CK)
Determine whether a file characteristic is for a module map.
bool LE(InterpState &S, CodePtr OpPC)
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
GlobalDeclID LazySpecializationInfo
@ EXTENSION_METADATA
Metadata describing this particular extension.
@ SUBMODULE_EXCLUDED_HEADER
Specifies a header that has been explicitly excluded from this submodule.
@ SUBMODULE_TOPHEADER
Specifies a top-level header that falls into this (sub)module.
@ SUBMODULE_PRIVATE_TEXTUAL_HEADER
Specifies a header that is private to this submodule but must be textually included.
@ SUBMODULE_HEADER
Specifies a header that falls into this (sub)module.
@ SUBMODULE_EXPORT_AS
Specifies the name of the module that will eventually re-export the entities in this module.
@ SUBMODULE_UMBRELLA_DIR
Specifies an umbrella directory.
@ SUBMODULE_UMBRELLA_HEADER
Specifies the umbrella header used to create this module, if any.
@ SUBMODULE_REQUIRES
Specifies a required feature.
@ SUBMODULE_PRIVATE_HEADER
Specifies a header that is private to this submodule.
@ SUBMODULE_IMPORTS
Specifies the submodules that are imported by this submodule.
@ SUBMODULE_CONFLICT
Specifies a conflict with another module.
@ SUBMODULE_CHILD
Specifies a direct submodule by name and ID, enabling on-demand deserialization of children without l...
@ SUBMODULE_INITIALIZERS
Specifies some declarations with initializers that must be emitted to initialize the module.
@ SUBMODULE_END
Defines the end of a single submodule. Sentinel record without any data.
@ SUBMODULE_DEFINITION
Defines the major attributes of a submodule, including its name and parent.
@ SUBMODULE_LINK_LIBRARY
Specifies a library or framework to link against.
@ SUBMODULE_CONFIG_MACRO
Specifies a configuration macro for this module.
@ SUBMODULE_EXPORTS
Specifies the submodules that are re-exported from this submodule.
@ SUBMODULE_TEXTUAL_HEADER
Specifies a header that is part of the module but must be textually included.
@ SUBMODULE_AFFECTING_MODULES
Specifies affecting modules that were not imported.
TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT)
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
@ UserFiles
When the validation is done only for user files as an optimization.
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
@ FILE_SYSTEM_OPTIONS
Record code for the filesystem options table.
@ TARGET_OPTIONS
Record code for the target options table.
@ PREPROCESSOR_OPTIONS
Record code for the preprocessor options table.
@ HEADER_SEARCH_OPTIONS
Record code for the headers search options table.
@ CODEGEN_OPTIONS
Record code for the codegen options table.
@ LANGUAGE_OPTIONS
Record code for the language options table.
const unsigned int NUM_PREDEF_PP_ENTITY_IDS
The number of predefined preprocessed entity IDs.
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
@ SUBMODULE_BLOCK_ID
The block containing the submodule structure.
@ PREPROCESSOR_DETAIL_BLOCK_ID
The block containing the detailed preprocessing record.
@ AST_BLOCK_ID
The AST block, which acts as a container around the full AST block.
@ SOURCE_MANAGER_BLOCK_ID
The block containing information about the source manager.
@ CONTROL_BLOCK_ID
The control block, which contains all of the information that needs to be validated prior to committi...
@ DECLTYPES_BLOCK_ID
The block containing the definitions of all of the types and decls used within the AST file.
@ PREPROCESSOR_BLOCK_ID
The block containing information about the preprocessor.
@ COMMENTS_BLOCK_ID
The block containing comments.
@ UNHASHED_CONTROL_BLOCK_ID
A block with unhashed content.
@ EXTENSION_BLOCK_ID
A block containing a module file extension.
@ OPTIONS_BLOCK_ID
The block of configuration options, used to check that a module is being used in a configuration comp...
@ INPUT_FILES_BLOCK_ID
The block of input files, which were used as inputs to create this AST file.
unsigned StableHashForTemplateArguments(llvm::ArrayRef< TemplateArgument > Args)
Calculate a stable hash value for template arguments.
DeclIDBase::DeclID DeclID
An ID number that refers to a declaration in an AST file.
const unsigned VERSION_MINOR
AST file minor version number supported by this version of Clang.
@ SM_SLOC_FILE_ENTRY
Describes a source location entry (SLocEntry) for a file.
@ SM_SLOC_BUFFER_BLOB_COMPRESSED
Describes a zlib-compressed blob that contains the data for a buffer entry.
@ SM_SLOC_BUFFER_ENTRY
Describes a source location entry (SLocEntry) for a buffer.
@ SM_SLOC_BUFFER_BLOB
Describes a blob that contains the data for a buffer entry.
@ SM_SLOC_EXPANSION_ENTRY
Describes a source location entry (SLocEntry) for a macro expansion.
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
uint64_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
@ PP_TOKEN
Describes one token.
@ PP_MACRO_FUNCTION_LIKE
A function-like macro definition.
@ PP_MACRO_OBJECT_LIKE
An object-like macro definition.
@ PP_MACRO_DIRECTIVE_HISTORY
The macro directives history for a particular identifier.
@ PP_MODULE_MACRO
A macro directive exported by a module.
void numberAnonymousDeclsWithin(const DeclContext *DC, Fn Visit)
Visit each declaration within DC that needs an anonymous declaration number and call Visit with the d...
@ MODULE_DIRECTORY_DEPENDENCIES
Record code for the directories this AST file depends on the listing of.
@ MODULE_MAP_FILE
Record code for the module map file that was used to build this AST file.
@ MODULE_DIRECTORY
Record code for the module build directory.
@ ORIGINAL_FILE_ID
Record code for file ID of the file or buffer that was used to generate the AST file.
@ MODULE_NAME
Record code for the module name.
@ ORIGINAL_FILE
Record code for the original file that was used to generate the AST file, including both its file ID ...
@ INPUT_FILE_OFFSETS
Offsets into the input-files block where input files reside.
@ METADATA
AST file metadata, including the AST file version number and information about the compiler used to b...
@ DIAGNOSTIC_OPTIONS
Record code for the diagnostic options table.
@ HEADER_SEARCH_ENTRY_USAGE
Record code for the indices of used header search entries.
@ AST_BLOCK_HASH
Record code for the content hash of the AST block.
@ DIAG_PRAGMA_MAPPINGS
Record code for #pragma diagnostic mappings.
@ SIGNATURE
Record code for the signature that identifiers this AST file.
@ HEADER_SEARCH_PATHS
Record code for the headers search paths.
@ VFS_USAGE
Record code for the indices of used VFSs.
uint64_t MacroID
An ID number that refers to a macro in an AST file.
@ INPUT_FILE_HASH
The input file content hash.
@ INPUT_FILE
An input file.
const DeclContext * getDefinitiveDeclContext(const DeclContext *DC)
Retrieve the "definitive" declaration that provides all of the visible entries for the given declarat...
uint64_t TypeID
An ID number that refers to a type in an AST file.
@ PPD_INCLUSION_DIRECTIVE
Describes an inclusion directive within the preprocessing record.
@ PPD_MACRO_EXPANSION
Describes a macro expansion within the preprocessing record.
@ PPD_MACRO_DEFINITION
Describes a macro definition within the preprocessing record.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
@ DECL_UPDATE_OFFSETS
Record for offsets of DECL_UPDATES records for declarations that were modified after being deserializ...
@ STATISTICS
Record code for the extra statistics we gather while generating an AST file.
@ FLOAT_CONTROL_PRAGMA_OPTIONS
Record code for #pragma float_control options.
@ KNOWN_NAMESPACES
Record code for the set of known namespaces, which are used for typo correction.
@ SPECIAL_TYPES
Record code for the set of non-builtin, special types.
@ PENDING_IMPLICIT_INSTANTIATIONS
Record code for pending implicit instantiations.
@ CXX_ADDED_TEMPLATE_SPECIALIZATION
@ TYPE_OFFSET
Record code for the offsets of each type.
@ DELEGATING_CTORS
The list of delegating constructor declarations.
@ PP_ASSUME_NONNULL_LOC
ID 66 used to be the list of included files.
@ EXT_VECTOR_DECLS
Record code for the set of ext_vector type names.
@ OPENCL_EXTENSIONS
Record code for enabled OpenCL extensions.
@ FP_PRAGMA_OPTIONS
Record code for floating point #pragma options.
@ PP_UNSAFE_BUFFER_USAGE
Record code for #pragma clang unsafe_buffer_usage begin/end.
@ CXX_ADDED_TEMPLATE_PARTIAL_SPECIALIZATION
@ DECLS_WITH_EFFECTS_TO_VERIFY
Record code for Sema's vector of functions/blocks with effects to be verified.
@ VTABLE_USES
Record code for the array of VTable uses.
@ LATE_PARSED_TEMPLATE
Record code for late parsed template functions.
@ DECLS_TO_CHECK_FOR_DEFERRED_DIAGS
Record code for the Decls to be checked for deferred diags.
@ SUBMODULE_METADATA
Record that encodes the number of submodules, their base ID in the AST file, and for each module the ...
@ DECL_OFFSET
Record code for the offsets of each decl.
@ SOURCE_MANAGER_LINE_TABLE
Record code for the source manager line table information, which stores information about #line direc...
@ PP_COUNTER_VALUE
The value of the next COUNTER to dispense.
@ OMP_REQUIRES_DECLS
Record code for the OpenMP 'requires' directives seen in the TU.
@ DELETE_EXPRS_TO_ANALYZE
Delete expressions that will be analyzed later.
@ EXTNAME_UNDECLARED_IDENTIFIERS
Record code for extname-redefined undeclared identifiers.
@ RELATED_DECLS_MAP
Record code for related declarations that have to be deserialized together from the same module.
@ UPDATE_VISIBLE
Record code for an update to a decl context's lookup table.
@ CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH
Number of unmatched pragma clang cuda_force_host_device begin directives we've seen.
@ MACRO_OFFSET
Record code for the table of offsets of each macro ID.
@ PPD_ENTITIES_OFFSETS
Record code for the table of offsets to entries in the preprocessing record.
@ RISCV_VECTOR_INTRINSICS_PRAGMA
Record code for pragma clang riscv intrinsic vector.
@ OPENCL_EXTENSION_DECLS
Record code for declarations associated with OpenCL extensions.
@ VTABLES_TO_EMIT
Record code for vtables to emit.
@ UPDATE_MODULE_LOCAL_VISIBLE
@ IDENTIFIER_OFFSET
Record code for the table of offsets of each identifier ID.
@ OBJC_CATEGORIES
Record code for the array of Objective-C categories (including extensions).
@ METHOD_POOL
Record code for the Objective-C method pool,.
@ DELAYED_NAMESPACE_LEXICAL_VISIBLE_RECORD
Record code for lexical and visible block for delayed namespace in reduced BMI.
@ PP_CONDITIONAL_STACK
The stack of open ifs/ifdefs recorded in a preamble.
@ REFERENCED_SELECTOR_POOL
Record code for referenced selector pool.
@ SOURCE_LOCATION_OFFSETS
Record code for the table of offsets into the block of source-location information.
@ WEAK_UNDECLARED_IDENTIFIERS
Record code for weak undeclared identifiers.
@ UNDEFINED_BUT_USED
Record code for undefined but used functions and variables that need a definition in this TU.
@ FILE_SORTED_DECLS
Record code for a file sorted array of DeclIDs in a module.
@ MSSTRUCT_PRAGMA_OPTIONS
Record code for #pragma ms_struct options.
@ TENTATIVE_DEFINITIONS
Record code for the array of tentative definitions.
@ UPDATE_TU_LOCAL_VISIBLE
@ UNUSED_FILESCOPED_DECLS
Record code for the array of unused file scoped decls.
@ ALIGN_PACK_PRAGMA_OPTIONS
Record code for #pragma align/pack options.
@ IMPORTED_MODULES
Record code for an array of all of the (sub)modules that were imported by the AST file.
@ SELECTOR_OFFSETS
Record code for the table of offsets into the Objective-C method pool.
@ UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES
Record code for potentially unused local typedef names.
@ OPENCL_EXTENSION_TYPES
Record code for types associated with OpenCL extensions.
@ EAGERLY_DESERIALIZED_DECLS
Record code for the array of eagerly deserialized decls.
@ INTERESTING_IDENTIFIERS
A list of "interesting" identifiers.
@ HEADER_SEARCH_TABLE
Record code for header search information.
@ OBJC_CATEGORIES_MAP
Record code for map of Objective-C class definition IDs to the ObjC categories in a module that are a...
@ METADATA_OLD_FORMAT
This is so that older clang versions, before the introduction of the control block,...
@ CUDA_SPECIAL_DECL_REFS
Record code for special CUDA declarations.
@ TU_UPDATE_LEXICAL
Record code for an update to the TU's lexically contained declarations.
@ PPD_SKIPPED_RANGES
A table of skipped ranges within the preprocessing record.
@ IDENTIFIER_TABLE
Record code for the identifier table.
@ SEMA_DECL_REFS
Record code for declarations that Sema keeps references of.
@ OPTIMIZE_PRAGMA_OPTIONS
Record code for #pragma optimize options.
@ MODULE_OFFSET_MAP
Record code for the remapping information used to relate loaded modules to the various offsets and ID...
@ POINTERS_TO_MEMBERS_PRAGMA_OPTIONS
Record code for #pragma ms_struct options.
unsigned ComputeHash(Selector Sel)
uint64_t IdentifierID
An ID number that refers to an identifier in an AST file.
Top level wrappers for InstallAPI frontend operations.
@ NUM_OVERLOADED_OPERATORS
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
@ LCK_ByRef
Capturing by reference.
@ LCK_VLAType
Capturing variable-length array type.
@ LCK_StarThis
Capturing the *this object by copy.
@ LCK_This
Capturing the *this object by reference.
@ Auto
'auto' clause, allowed on 'loop' directives.
@ Bind
'bind' clause, allowed on routine constructs.
@ Gang
'gang' clause, allowed on 'loop' and Combined constructs.
@ Wait
'wait' clause, allowed on Compute, Data, 'update', and Combined constructs.
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ PCopyOut
'copyout' clause alias 'pcopyout'. Preserved for diagnostic purposes.
@ VectorLength
'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop', and 'kernels loop' constru...
@ Async
'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined constructs.
@ PresentOrCreate
'create' clause alias 'present_or_create'.
@ Collapse
'collapse' clause, allowed on 'loop' and Combined constructs.
@ NoHost
'nohost' clause, allowed on 'routine' directives.
@ PresentOrCopy
'copy' clause alias 'present_or_copy'. Preserved for diagnostic purposes.
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Copy
'copy' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ Worker
'worker' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ DeviceType
'device_type' clause, allowed on Compute, 'data', 'init', 'shutdown', 'set', update',...
@ DefaultAsync
'default_async' clause, allowed on 'set' construct.
@ Attach
'attach' clause, allowed on Compute and Combined constructs, plus 'data' and 'enter data'.
@ Shortloop
'shortloop' is represented in the ACC.td file, but isn't present in the standard.
@ NumGangs
'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs.
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...
@ Default
'default' clause, allowed on parallel, serial, kernel (and compound) constructs.
@ UseDevice
'use_device' clause, allowed on 'host_data' construct.
@ NoCreate
'no_create' clause, allowed on allowed on Compute and Combined constructs, plus 'data'.
@ PresentOrCopyOut
'copyout' clause alias 'present_or_copyout'.
@ Link
'link' clause, allowed on 'declare' construct.
@ Reduction
'reduction' clause, allowed on Parallel, Serial, Loop, and the combined constructs.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ CopyOut
'copyout' clause, allowed on Compute and Combined constructs, plus 'data', 'exit data',...
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
@ FirstPrivate
'firstprivate' clause, allowed on 'parallel', 'serial', 'parallel loop', and 'serial loop' constructs...
@ Host
'host' clause, allowed on 'update' construct.
@ PCopy
'copy' clause alias 'pcopy'. Preserved for diagnostic purposes.
@ Tile
'tile' clause, allowed on 'loop' and Combined constructs.
@ PCopyIn
'copyin' clause alias 'pcopyin'. Preserved for diagnostic purposes.
@ DeviceResident
'device_resident' clause, allowed on the 'declare' construct.
@ PCreate
'create' clause alias 'pcreate'. Preserved for diagnostic purposes.
@ Present
'present' clause, allowed on Compute and Combined constructs, plus 'data' and 'declare'.
@ DType
'dtype' clause, an alias for 'device_type', stored separately for diagnostic purposes.
@ CopyIn
'copyin' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ Device
'device' clause, allowed on the 'update' construct.
@ Independent
'independent' clause, allowed on 'loop' directives.
@ NumWorkers
'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs...
@ IfPresent
'if_present' clause, allowed on 'host_data' and 'update' directives.
@ Detach
'detach' clause, allowed on the 'exit data' construct.
@ Delete
'delete' clause, allowed on the 'exit data' construct.
@ PresentOrCopyIn
'copyin' clause alias 'present_or_copyin'.
@ Finalize
'finalize' clause, allowed on 'exit data' directive.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
IdentifierLoc DeviceTypeArgument
static constexpr unsigned NumberOfOMPMapClauseModifiers
Number of allowed map-type-modifiers.
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
@ Undefined
Keep undefined.
PredefinedDeclIDs
Predefined declaration IDs.
@ PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID
The internal '__NSConstantString' tag type.
@ PREDEF_DECL_TRANSLATION_UNIT_ID
The translation unit.
@ PREDEF_DECL_OBJC_CLASS_ID
The Objective-C 'Class' type.
@ PREDEF_DECL_BUILTIN_MS_GUID_ID
The predeclared '_GUID' struct.
@ PREDEF_DECL_BUILTIN_MS_TYPE_INFO_TAG_ID
The predeclared 'type_info' struct.
@ PREDEF_DECL_OBJC_INSTANCETYPE_ID
The internal 'instancetype' typedef.
@ PREDEF_DECL_OBJC_PROTOCOL_ID
The Objective-C 'Protocol' type.
@ PREDEF_DECL_UNSIGNED_INT_128_ID
The unsigned 128-bit integer type.
@ PREDEF_DECL_OBJC_SEL_ID
The Objective-C 'SEL' type.
@ PREDEF_DECL_INT_128_ID
The signed 128-bit integer type.
@ PREDEF_DECL_VA_LIST_TAG
The internal '__va_list_tag' struct, if any.
@ PREDEF_DECL_BUILTIN_MS_VA_LIST_ID
The internal '__builtin_ms_va_list' typedef.
@ PREDEF_DECL_CF_CONSTANT_STRING_ID
The internal '__NSConstantString' typedef.
@ PREDEF_DECL_BUILTIN_VA_LIST_ID
The internal '__builtin_va_list' typedef.
@ PREDEF_DECL_EXTERN_C_CONTEXT_ID
The extern "C" context.
@ PREDEF_DECL_OBJC_ID_ID
The Objective-C 'id' type.
@ PREDEF_DECL_BUILTIN_ZOS_VA_LIST_ID
The internal '__builtin_zos_va_list' typedef.
@ Property
The type of a property.
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
bool CanElideDeclDef(const Decl *D)
If we can elide the definition of.
static constexpr unsigned NumberOfOMPMotionModifiers
Number of allowed motion-modifiers.
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
U cast(CodeGen::Address addr)
@ Class
The "class" keyword introduces the elaborated-type-specifier.
UnsignedOrNone getPrimaryModuleHash(const Module *M)
Calculate a hash value for the primary module name of the given module.
Diagnostic wrappers for TextAPI types for error reporting.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 uint8_t
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 __packed_splat4 uint16_t
The signature of a module, which is a hash of the AST content.
static ASTFileSignature create(std::array< uint8_t, 20 > Bytes)
static ASTFileSignature createDummy()
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
const DeclarationNameLoc & getInfo() const
Structure used to store a statement, the constant value to which it was evaluated (if any),...
FPOptions FPO
Floating-point options in the point of definition.
Decl * D
The template function declaration to be late parsed.
NestedNameSpecifierLoc Prefix
ObjCMethodDecl * getMethod() const
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
TemplateParameterList ** TemplParamLists
A new-allocated array of size NumTemplParamLists, containing pointers to the "outer" template paramet...
NestedNameSpecifierLoc QualifierLoc
unsigned NumTemplParamLists
The number of "outer" template parameter lists.
Location information for a TemplateArgument.
TypeSourceInfo * getAsTypeSourceInfo() const
uint64_t ModuleLocalOffset
MultiOnDiskHashTable< ASTDeclContextNameLookupTrait > Table
MultiOnDiskHashTable< LazySpecializationInfoLookupTrait > Table
MultiOnDiskHashTable< ModuleLocalNameLookupTrait > Table