82#include "llvm/ADT/APFloat.h"
83#include "llvm/ADT/APInt.h"
84#include "llvm/ADT/ArrayRef.h"
85#include "llvm/ADT/DenseMap.h"
86#include "llvm/ADT/DenseSet.h"
87#include "llvm/ADT/PointerIntPair.h"
88#include "llvm/ADT/STLExtras.h"
89#include "llvm/ADT/ScopeExit.h"
90#include "llvm/ADT/SmallPtrSet.h"
91#include "llvm/ADT/SmallString.h"
92#include "llvm/ADT/SmallVector.h"
93#include "llvm/ADT/StringRef.h"
94#include "llvm/Bitstream/BitCodes.h"
95#include "llvm/Bitstream/BitstreamWriter.h"
96#include "llvm/Support/Compression.h"
97#include "llvm/Support/DJB.h"
98#include "llvm/Support/EndianStream.h"
99#include "llvm/Support/ErrorHandling.h"
100#include "llvm/Support/LEB128.h"
101#include "llvm/Support/MemoryBuffer.h"
102#include "llvm/Support/OnDiskHashTable.h"
103#include "llvm/Support/Path.h"
104#include "llvm/Support/SHA1.h"
105#include "llvm/Support/TimeProfiler.h"
106#include "llvm/Support/VersionTuple.h"
107#include "llvm/Support/raw_ostream.h"
122using namespace clang;
125template <
typename T,
typename Allocator>
126static StringRef
bytes(
const std::vector<T, Allocator> &v) {
127 if (v.empty())
return StringRef();
128 return StringRef(
reinterpret_cast<const char*
>(&v[0]),
129 sizeof(T) * v.size());
134 return StringRef(
reinterpret_cast<const char*
>(v.data()),
135 sizeof(T) * v.size());
138static std::string
bytes(
const std::vector<bool> &
V) {
140 Str.reserve(
V.size() / 8);
141 for (
unsigned I = 0, E =
V.size(); I < E;) {
143 for (
unsigned Bit = 0; Bit < 8 && I < E; ++Bit, ++I)
156#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
157 case Type::CLASS_ID: return TYPE_##CODE_ID;
158#include "clang/Serialization/TypeBitCodes.def"
160 llvm_unreachable(
"shouldn't be serializing a builtin type this way");
162 llvm_unreachable(
"bad type kind");
167struct AffectingModuleMaps {
168 llvm::DenseSet<FileID> DefinitionFileIDs;
169 llvm::DenseSet<const FileEntry *> DefinitionFiles;
172std::optional<AffectingModuleMaps>
185 enum AffectedReason :
bool {
186 AR_TextualHeader = 0,
187 AR_ImportOrTextualHeader = 1,
189 auto AssignMostImportant = [](AffectedReason &LHS, AffectedReason RHS) {
190 LHS = std::max(LHS, RHS);
192 llvm::DenseMap<FileID, AffectedReason> ModuleMaps;
193 llvm::DenseMap<const Module *, AffectedReason> ProcessedModules;
194 auto CollectModuleMapsForHierarchy = [&](
const Module *M,
195 AffectedReason Reason) {
201 if (
auto [It, Inserted] = ProcessedModules.insert({M, Reason});
202 !Inserted && Reason <= It->second) {
208 std::queue<const Module *> Q;
211 const Module *Mod = Q.front();
217 AssignMostImportant(ModuleMaps[F], Reason);
222 AssignMostImportant(ModuleMaps[UniqF], Reason);
231 CollectModuleMapsForHierarchy(RootModule, AR_ImportOrTextualHeader);
233 std::queue<const Module *> Q;
236 const Module *CurrentModule = Q.front();
240 CollectModuleMapsForHierarchy(ImportedModule, AR_ImportOrTextualHeader);
242 CollectModuleMapsForHierarchy(UndeclaredModule, AR_ImportOrTextualHeader);
257 if (
const Module *M = KH.getModule())
258 CollectModuleMapsForHierarchy(M, AR_TextualHeader);
279 llvm::DenseSet<const FileEntry *> ModuleFileEntries;
280 llvm::DenseSet<FileID> ModuleFileIDs;
281 for (
auto [FID, Reason] : ModuleMaps) {
282 if (Reason == AR_ImportOrTextualHeader)
283 ModuleFileIDs.insert(FID);
284 if (
auto *FE =
SM.getFileEntryForID(FID))
285 ModuleFileEntries.insert(FE);
288 AffectingModuleMaps
R;
289 R.DefinitionFileIDs = std::move(ModuleFileIDs);
290 R.DefinitionFiles = std::move(ModuleFileEntries);
297 ASTRecordWriter BasicWriter;
300 ASTTypeWriter(ASTContext &Context, ASTWriter &Writer)
301 : Writer(Writer), BasicWriter(Context, Writer, Record) {}
307 BasicWriter.writeQualifiers(Qs);
308 return BasicWriter.Emit(
TYPE_EXT_QUAL, Writer.getTypeExtQualAbbrev());
312 serialization::AbstractTypeWriter<ASTRecordWriter> atw(BasicWriter);
320 ASTRecordWriter &Record;
322 void addSourceLocation(SourceLocation Loc) { Record.AddSourceLocation(Loc); }
323 void addSourceRange(SourceRange Range) { Record.AddSourceRange(Range); }
326 TypeLocWriter(ASTRecordWriter &Record) : Record(Record) {}
328#define ABSTRACT_TYPELOC(CLASS, PARENT)
329#define TYPELOC(CLASS, PARENT) \
330 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
331#include "clang/AST/TypeLocNodes.def"
344void TypeLocWriter::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
354void TypeLocWriter::VisitComplexTypeLoc(ComplexTypeLoc TL) {
358void TypeLocWriter::VisitPointerTypeLoc(PointerTypeLoc TL) {
362void TypeLocWriter::VisitDecayedTypeLoc(DecayedTypeLoc TL) {
366void TypeLocWriter::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
370void TypeLocWriter::VisitArrayParameterTypeLoc(ArrayParameterTypeLoc TL) {
374void TypeLocWriter::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
378void TypeLocWriter::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
382void TypeLocWriter::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
386void TypeLocWriter::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
391void TypeLocWriter::VisitArrayTypeLoc(ArrayTypeLoc TL) {
399void TypeLocWriter::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) {
400 VisitArrayTypeLoc(TL);
403void TypeLocWriter::VisitIncompleteArrayTypeLoc(IncompleteArrayTypeLoc TL) {
404 VisitArrayTypeLoc(TL);
407void TypeLocWriter::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
408 VisitArrayTypeLoc(TL);
411void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
412 DependentSizedArrayTypeLoc TL) {
413 VisitArrayTypeLoc(TL);
416void TypeLocWriter::VisitDependentAddressSpaceTypeLoc(
417 DependentAddressSpaceTypeLoc TL) {
420 addSourceLocation(
range.getBegin());
421 addSourceLocation(
range.getEnd());
425void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
426 DependentSizedExtVectorTypeLoc TL) {
430void TypeLocWriter::VisitVectorTypeLoc(VectorTypeLoc TL) {
434void TypeLocWriter::VisitDependentVectorTypeLoc(
435 DependentVectorTypeLoc TL) {
439void TypeLocWriter::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
443void TypeLocWriter::VisitConstantMatrixTypeLoc(ConstantMatrixTypeLoc TL) {
446 addSourceLocation(
range.getBegin());
447 addSourceLocation(
range.getEnd());
452void TypeLocWriter::VisitDependentSizedMatrixTypeLoc(
453 DependentSizedMatrixTypeLoc TL) {
456 addSourceLocation(
range.getBegin());
457 addSourceLocation(
range.getEnd());
462void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
468 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i)
472void TypeLocWriter::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {
473 VisitFunctionTypeLoc(TL);
476void TypeLocWriter::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) {
477 VisitFunctionTypeLoc(TL);
480void TypeLocWriter::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
486void TypeLocWriter::VisitUsingTypeLoc(UsingTypeLoc TL) {
492void TypeLocWriter::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
498void TypeLocWriter::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
507void TypeLocWriter::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
513void TypeLocWriter::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
520void TypeLocWriter::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
525void TypeLocWriter::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
548void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
553 Record.AddConceptReference(CR);
559void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
560 DeducedTemplateSpecializationTypeLoc TL) {
566void TypeLocWriter::VisitTagTypeLoc(TagTypeLoc TL) {
572void TypeLocWriter::VisitRecordTypeLoc(RecordTypeLoc TL) {
576void TypeLocWriter::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
580void TypeLocWriter::VisitEnumTypeLoc(EnumTypeLoc TL) { VisitTagTypeLoc(TL); }
582void TypeLocWriter::VisitAttributedTypeLoc(AttributedTypeLoc TL) {
586void TypeLocWriter::VisitCountAttributedTypeLoc(CountAttributedTypeLoc TL) {
590void TypeLocWriter::VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
594void TypeLocWriter::VisitOverflowBehaviorTypeLoc(OverflowBehaviorTypeLoc TL) {
598void TypeLocWriter::VisitHLSLAttributedResourceTypeLoc(
599 HLSLAttributedResourceTypeLoc TL) {
603void TypeLocWriter::VisitHLSLInlineSpirvTypeLoc(HLSLInlineSpirvTypeLoc TL) {
607void TypeLocWriter::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
611void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
612 SubstTemplateTypeParmTypeLoc TL) {
616void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
617 SubstTemplateTypeParmPackTypeLoc TL) {
621void TypeLocWriter::VisitSubstBuiltinTemplatePackTypeLoc(
622 SubstBuiltinTemplatePackTypeLoc TL) {
626void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
627 TemplateSpecializationTypeLoc TL) {
634 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
638void TypeLocWriter::VisitParenTypeLoc(ParenTypeLoc TL) {
643void TypeLocWriter::VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
647void TypeLocWriter::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
653void TypeLocWriter::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) {
657void TypeLocWriter::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
662void TypeLocWriter::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
674void TypeLocWriter::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
678void TypeLocWriter::VisitAtomicTypeLoc(AtomicTypeLoc TL) {
684void TypeLocWriter::VisitPipeTypeLoc(PipeTypeLoc TL) {
687void TypeLocWriter::VisitBitIntTypeLoc(clang::BitIntTypeLoc TL) {
690void TypeLocWriter::VisitDependentBitIntTypeLoc(
691 clang::DependentBitIntTypeLoc TL) {
695void TypeLocWriter::VisitPredefinedSugarTypeLoc(
696 clang::PredefinedSugarTypeLoc TL) {
700void ASTWriter::WriteTypeAbbrevs() {
701 using namespace llvm;
703 std::shared_ptr<BitCodeAbbrev> Abv;
706 Abv = std::make_shared<BitCodeAbbrev>();
708 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
709 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
710 TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
718 llvm::BitstreamWriter &Stream,
722 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID,
Record);
725 if (!Name || Name[0] == 0)
729 Record.push_back(*Name++);
730 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME,
Record);
734 llvm::BitstreamWriter &Stream,
739 Record.push_back(*Name++);
740 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME,
Record);
745#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
877void ASTWriter::WriteBlockInfoBlock() {
879 Stream.EnterBlockInfoBlock();
881#define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
882#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
885 BLOCK(CONTROL_BLOCK);
895 BLOCK(OPTIONS_BLOCK);
903 BLOCK(INPUT_FILES_BLOCK);
971 BLOCK(SOURCE_MANAGER_BLOCK);
979 BLOCK(PREPROCESSOR_BLOCK);
987 BLOCK(SUBMODULE_BLOCK);
1010 BLOCK(COMMENTS_BLOCK);
1014 BLOCK(DECLTYPES_BLOCK);
1018 RECORD(TYPE_BLOCK_POINTER);
1019 RECORD(TYPE_LVALUE_REFERENCE);
1020 RECORD(TYPE_RVALUE_REFERENCE);
1021 RECORD(TYPE_MEMBER_POINTER);
1022 RECORD(TYPE_CONSTANT_ARRAY);
1023 RECORD(TYPE_INCOMPLETE_ARRAY);
1024 RECORD(TYPE_VARIABLE_ARRAY);
1027 RECORD(TYPE_FUNCTION_NO_PROTO);
1028 RECORD(TYPE_FUNCTION_PROTO);
1030 RECORD(TYPE_TYPEOF_EXPR);
1034 RECORD(TYPE_OBJC_INTERFACE);
1035 RECORD(TYPE_OBJC_OBJECT_POINTER);
1037 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM);
1038 RECORD(TYPE_UNRESOLVED_USING);
1039 RECORD(TYPE_INJECTED_CLASS_NAME);
1040 RECORD(TYPE_OBJC_OBJECT);
1041 RECORD(TYPE_TEMPLATE_TYPE_PARM);
1042 RECORD(TYPE_TEMPLATE_SPECIALIZATION);
1043 RECORD(TYPE_DEPENDENT_NAME);
1044 RECORD(TYPE_DEPENDENT_SIZED_ARRAY);
1046 RECORD(TYPE_MACRO_QUALIFIED);
1047 RECORD(TYPE_PACK_EXPANSION);
1049 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK);
1050 RECORD(TYPE_SUBST_BUILTIN_TEMPLATE_PACK);
1052 RECORD(TYPE_UNARY_TRANSFORM);
1056 RECORD(TYPE_OBJC_TYPE_PARAM);
1137 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
1143 BLOCK(EXTENSION_BLOCK);
1146 BLOCK(UNHASHED_CONTROL_BLOCK);
1172 assert(Filename &&
"No file name to adjust?");
1174 if (BaseDir.empty())
1179 for (; Filename[Pos] && Pos < BaseDir.size(); ++Pos)
1180 if (Filename[Pos] != BaseDir[Pos])
1189 if (!llvm::sys::path::is_separator(Filename[Pos])) {
1190 if (!llvm::sys::path::is_separator(BaseDir.back()))
1204 return Filename + Pos;
1207std::pair<ASTFileSignature, ASTFileSignature>
1208ASTWriter::createSignature()
const {
1209 StringRef AllBytes(Buffer.data(), Buffer.size());
1212 Hasher.update(AllBytes.slice(ASTBlockRange.first, ASTBlockRange.second));
1217 Hasher.update(AllBytes.slice(0, UnhashedControlBlockRange.first));
1220 AllBytes.slice(UnhashedControlBlockRange.second, ASTBlockRange.first));
1222 Hasher.update(AllBytes.substr(ASTBlockRange.second));
1225 return std::make_pair(ASTBlockHash, Signature);
1228ASTFileSignature ASTWriter::createSignatureForNamedModule()
const {
1230 Hasher.update(StringRef(Buffer.data(), Buffer.size()));
1232 assert(WritingModule);
1233 assert(WritingModule->isNamedModule());
1237 for (
auto [ExportImported, _] : WritingModule->Exports)
1238 Hasher.update(ExportImported->Signature);
1262 for (
Module *M : TouchedTopLevelModules)
1271 Stream.BackpatchByte(BitNo, Byte);
1276ASTFileSignature ASTWriter::backpatchSignature() {
1277 if (isWritingStdCXXNamedModules()) {
1278 ASTFileSignature Signature = createSignatureForNamedModule();
1283 if (!WritingModule ||
1288 ASTFileSignature ASTBlockHash;
1289 ASTFileSignature Signature;
1290 std::tie(ASTBlockHash, Signature) = createSignature();
1298void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP) {
1299 using namespace llvm;
1302 Stream.FlushToWord();
1303 UnhashedControlBlockRange.first = Stream.GetCurrentBitNo() >> 3;
1311 if (isWritingStdCXXNamedModules() ||
1322 SmallString<128> Blob{Dummy.begin(), Dummy.end()};
1325 if (!isWritingStdCXXNamedModules()) {
1326 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1328 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1329 unsigned ASTBlockHashAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1332 Stream.EmitRecordWithBlob(ASTBlockHashAbbrev,
Record, Blob);
1333 ASTBlockHashOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1337 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1338 Abbrev->Add(BitCodeAbbrevOp(
SIGNATURE));
1339 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1340 unsigned SignatureAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1343 Stream.EmitRecordWithBlob(SignatureAbbrev,
Record, Blob);
1344 SignatureOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1353 if (!HSOpts.ModulesSkipDiagnosticOptions) {
1354#define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name);
1355#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
1356 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name()));
1357#include "clang/Basic/DiagnosticOptions.def"
1359 for (
unsigned I = 0, N = DiagOpts.
Warnings.size(); I != N; ++I)
1362 for (
unsigned I = 0, N = DiagOpts.
Remarks.size(); I != N; ++I)
1371 if (!HSOpts.ModulesSkipHeaderSearchPaths) {
1373 Record.push_back(HSOpts.UserEntries.size());
1374 for (
unsigned I = 0, N = HSOpts.UserEntries.size(); I != N; ++I) {
1375 const HeaderSearchOptions::Entry &Entry = HSOpts.UserEntries[I];
1377 Record.push_back(
static_cast<unsigned>(Entry.
Group));
1383 Record.push_back(HSOpts.SystemHeaderPrefixes.size());
1384 for (
unsigned I = 0, N = HSOpts.SystemHeaderPrefixes.size(); I != N; ++I) {
1385 AddString(HSOpts.SystemHeaderPrefixes[I].Prefix,
Record);
1386 Record.push_back(HSOpts.SystemHeaderPrefixes[I].IsSystemHeader);
1390 Record.push_back(HSOpts.VFSOverlayFiles.size());
1391 for (StringRef VFSOverlayFile : HSOpts.VFSOverlayFiles)
1392 AddString(VFSOverlayFile,
Record);
1397 if (!HSOpts.ModulesSkipPragmaDiagnosticMappings)
1398 WritePragmaDiagnosticMappings(Diags, WritingModule);
1403 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1405 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1406 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1407 unsigned HSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1409 HSEntryUsage.size()};
1410 Stream.EmitRecordWithBlob(HSUsageAbbrevCode,
Record,
bytes(HSEntryUsage));
1416 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1417 Abbrev->Add(BitCodeAbbrevOp(
VFS_USAGE));
1418 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1419 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1420 unsigned VFSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1422 Stream.EmitRecordWithBlob(VFSUsageAbbrevCode,
Record,
bytes(VFSUsage));
1427 UnhashedControlBlockRange.second = Stream.GetCurrentBitNo() >> 3;
1431void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
1432 using namespace llvm;
1441 auto MetadataAbbrev = std::make_shared<BitCodeAbbrev>();
1442 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1443 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1444 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1445 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1446 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1447 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1449 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1450 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1451 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1452 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1453 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev));
1454 assert((!WritingModule || isysroot.empty()) &&
1455 "writing module as a relocatable PCH?");
1460 CLANG_VERSION_MAJOR,
1461 CLANG_VERSION_MINOR,
1463 isWritingStdCXXNamedModules(),
1465 ASTHasCompilerErrors};
1466 Stream.EmitRecordWithBlob(MetadataAbbrevCode,
Record,
1470 if (WritingModule) {
1472 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1474 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1475 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1477 Stream.EmitRecordWithBlob(AbbrevCode,
Record, WritingModule->Name);
1479 auto BaseDir = [&]() -> std::optional<SmallString<128>> {
1485 if (WritingModule->Directory) {
1486 return WritingModule->Directory->getName();
1488 return std::nullopt;
1500 WritingModule->Directory->getName() !=
".")) {
1502 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1504 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1505 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1508 Stream.EmitRecordWithBlob(AbbrevCode,
Record, *BaseDir);
1512 BaseDirectory.assign(BaseDir->begin(), BaseDir->end());
1514 }
else if (!isysroot.empty()) {
1516 SmallString<128> CleanedSysroot(isysroot);
1518 BaseDirectory.assign(CleanedSysroot.begin(), CleanedSysroot.end());
1522 if (WritingModule && WritingModule->Kind == Module::ModuleMapModule) {
1526 AddPath(WritingModule->PresumedModuleMapFile.empty()
1527 ? Map.getModuleMapFileForUniquing(WritingModule)
1528 ->getNameAsRequested()
1529 : StringRef(WritingModule->PresumedModuleMapFile),
1533 if (
auto *AdditionalModMaps =
1534 Map.getAdditionalModuleMapFiles(WritingModule)) {
1535 Record.push_back(AdditionalModMaps->size());
1536 SmallVector<FileEntryRef, 1> ModMaps(AdditionalModMaps->begin(),
1537 AdditionalModMaps->end());
1538 llvm::sort(ModMaps, [](FileEntryRef A, FileEntryRef B) {
1541 for (FileEntryRef F : ModMaps)
1542 AddPath(F.getName(),
Record);
1552 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1553 Abbrev->Add(BitCodeAbbrevOp(
IMPORT));
1554 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1555 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1556 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1557 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1558 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1559 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1560 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1561 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1562 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1563 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1565 SmallString<128> Blob;
1567 for (ModuleFile &M : Chain->getModuleManager()) {
1569 if (!M.isDirectlyImported())
1577 AddSourceLocation(M.ImportLoc,
Record);
1578 AddStringBlob(M.ModuleName,
Record, Blob);
1579 Record.push_back(M.StandardCXXModule);
1583 if (M.StandardCXXModule) {
1594 Record.push_back(M.FileName.getRawKind());
1598 AddPathBlob(M.FileName,
Record, Blob);
1601 Stream.EmitRecordWithBlob(AbbrevCode,
Record, Blob);
1611 const uint64_t LanguageOptionValues[] = {
1612#define LANGOPT(Name, Bits, Default, Compatibility, Description) LangOpts.Name,
1613#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
1614 static_cast<unsigned>(LangOpts.get##Name()),
1615#include "clang/Basic/LangOptions.def"
1616#define SANITIZER(NAME, ID) LangOpts.Sanitize.has(SanitizerKind::ID),
1617#include "clang/Basic/Sanitizers.def"
1619 llvm::append_range(
Record, LanguageOptionValues);
1640 AddString(T.getTriple(),
Record);
1648 using CK = CodeGenOptions::CompatibilityKind;
1650 const CodeGenOptions &CGOpts = getCodeGenOpts();
1651#define CODEGENOPT(Name, Bits, Default, Compatibility) \
1652 if constexpr (CK::Compatibility != CK::Benign) \
1653 Record.push_back(static_cast<unsigned>(CGOpts.Name));
1654#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility) \
1655 if constexpr (CK::Compatibility != CK::Benign) \
1656 Record.push_back(static_cast<unsigned>(CGOpts.get##Name()));
1657#define DEBUGOPT(Name, Bits, Default, Compatibility)
1658#define VALUE_DEBUGOPT(Name, Bits, Default, Compatibility)
1659#define ENUM_DEBUGOPT(Name, Type, Bits, Default, Compatibility)
1660#include "clang/Basic/CodeGenOptions.def"
1676 for (
unsigned I = 0, N = TargetOpts.
Features.size(); I != N; ++I) {
1689 const HeaderSearchOptions &HSOpts =
1692 StringRef HSOpts_ModuleCachePath =
1697 AddString(HSOpts_ModuleCachePath,
Record);
1718 bool WriteMacros = !SkipMacros;
1719 Record.push_back(WriteMacros);
1723 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
1731 for (
unsigned I = 0, N = PPOpts.
Includes.size(); I != N; ++I)
1736 for (
unsigned I = 0, N = PPOpts.
MacroIncludes.size(); I != N; ++I)
1757 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1759 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1760 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1761 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
1766 EmitRecordWithPath(FileAbbrevCode,
Record, MainFile->getName());
1773 WriteInputFiles(SourceMgr);
1780struct InputFileEntry {
1784 bool BufferOverridden;
1791 void trySetContentHash(
1793 llvm::function_ref<std::optional<llvm::MemoryBufferRef>()> GetMemBuff) {
1802 auto MemBuff = GetMemBuff();
1804 PP.
Diag(SourceLocation(), diag::err_module_unable_to_hash_content)
1809 uint64_t Hash = xxh3_64bits(MemBuff->getBuffer());
1811 ContentHash[1] =
uint32_t(Hash >> 32);
1817SourceLocation ASTWriter::getAffectingIncludeLoc(
const SourceManager &SourceMgr,
1818 const SrcMgr::FileInfo &
File) {
1819 SourceLocation IncludeLoc =
File.getIncludeLoc();
1821 FileID IncludeFID = SourceMgr.
getFileID(IncludeLoc);
1822 assert(IncludeFID.
isValid() &&
"IncludeLoc in invalid file");
1823 if (!IsSLocAffecting[IncludeFID.ID])
1824 IncludeLoc = SourceLocation();
1829void ASTWriter::WriteInputFiles(SourceManager &SourceMgr) {
1830 using namespace llvm;
1835 auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
1837 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1838 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1839 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1840 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1841 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1842 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1843 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1844 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
1845 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1846 unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
1849 auto IFHAbbrev = std::make_shared<BitCodeAbbrev>();
1851 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1852 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1853 unsigned IFHAbbrevCode = Stream.EmitAbbrev(std::move(IFHAbbrev));
1855 uint64_t InputFilesOffsetBase = Stream.GetCurrentBitNo();
1859 std::vector<InputFileEntry> SystemFiles;
1863 assert(&SourceMgr.
getSLocEntry(FileID::get(I)) == SLoc);
1870 if (!
Cache->OrigEntry)
1874 if (!IsSLocFileEntryAffecting[I])
1877 InputFileEntry Entry(*
Cache->OrigEntry);
1878 Entry.IsSystemFile =
isSystem(
File.getFileCharacteristic());
1879 Entry.IsTransient =
Cache->IsTransient;
1880 Entry.BufferOverridden =
Cache->BufferOverridden;
1882 FileID IncludeFileID = SourceMgr.
getFileID(
File.getIncludeLoc());
1883 Entry.IsTopLevel = IncludeFileID.
isInvalid() || IncludeFileID.ID < 0 ||
1884 !IsSLocFileEntryAffecting[IncludeFileID.ID];
1887 Entry.trySetContentHash(*PP, [&] {
return Cache->getBufferIfLoaded(); });
1889 if (Entry.IsSystemFile)
1890 SystemFiles.push_back(Entry);
1899 if (!Sysroot.empty()) {
1900 SmallString<128> SDKSettingsJSON = Sysroot;
1901 llvm::sys::path::append(SDKSettingsJSON,
"SDKSettings.json");
1904 InputFileEntry Entry(*FE);
1905 Entry.IsSystemFile =
true;
1906 Entry.IsTransient =
false;
1907 Entry.BufferOverridden =
false;
1908 Entry.IsTopLevel =
true;
1909 Entry.IsModuleMap =
false;
1910 std::unique_ptr<MemoryBuffer> MB;
1911 Entry.trySetContentHash(*PP, [&]() -> std::optional<MemoryBufferRef> {
1913 MB = std::move(*MBOrErr);
1914 return MB->getMemBufferRef();
1916 return std::nullopt;
1918 SystemFiles.push_back(Entry);
1923 auto SortedFiles = llvm::concat<InputFileEntry>(std::move(
UserFiles),
1924 std::move(SystemFiles));
1926 unsigned UserFilesNum = 0;
1928 std::vector<uint64_t> InputFileOffsets;
1929 for (
const auto &Entry : SortedFiles) {
1930 uint32_t &InputFileID = InputFileIDs[Entry.File];
1931 if (InputFileID != 0)
1935 InputFileOffsets.push_back(Stream.GetCurrentBitNo() - InputFilesOffsetBase);
1937 InputFileID = InputFileOffsets.size();
1939 if (!Entry.IsSystemFile)
1945 SmallString<128> NameAsRequested = Entry.File.getNameAsRequested();
1946 SmallString<128> Name = Entry.File.getName();
1948 PreparePathForOutput(NameAsRequested);
1949 PreparePathForOutput(Name);
1951 if (Name == NameAsRequested)
1954 RecordData::value_type
Record[] = {
1956 InputFileOffsets.size(),
1958 (
uint64_t)getTimestampForOutput(Entry.File.getModificationTime()),
1959 Entry.BufferOverridden,
1963 NameAsRequested.size()};
1965 Stream.EmitRecordWithBlob(IFAbbrevCode,
Record,
1966 (NameAsRequested + Name).str());
1972 Entry.ContentHash[1]};
1973 Stream.EmitRecordWithAbbrev(IFHAbbrevCode,
Record);
1980 auto OffsetsAbbrev = std::make_shared<BitCodeAbbrev>();
1982 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1983 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1985 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1986 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(std::move(OffsetsAbbrev));
1990 InputFileOffsets.size(), UserFilesNum};
1991 Stream.EmitRecordWithBlob(OffsetsAbbrevCode,
Record,
bytes(InputFileOffsets));
2001 using namespace llvm;
2003 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2005 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2006 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2007 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
2008 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2010 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2011 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2012 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
2013 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2014 return Stream.EmitAbbrev(std::move(Abbrev));
2020 using namespace llvm;
2022 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2024 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2025 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2026 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
2027 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2028 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2029 return Stream.EmitAbbrev(std::move(Abbrev));
2036 using namespace llvm;
2038 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2042 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2043 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
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::VBR, 6));
2057 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2058 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2059 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2060 return Stream.EmitAbbrev(std::move(Abbrev));
2065static std::pair<unsigned, unsigned>
2067 llvm::encodeULEB128(KeyLen, Out);
2068 llvm::encodeULEB128(DataLen, Out);
2069 return std::make_pair(KeyLen, DataLen);
2075 class HeaderFileInfoTrait {
2079 HeaderFileInfoTrait(ASTWriter &Writer) : Writer(Writer) {}
2086 using key_type_ref =
const key_type &;
2088 using UnresolvedModule =
2089 llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
2092 data_type(
const HeaderFileInfo &HFI,
bool AlreadyIncluded,
2093 ArrayRef<ModuleMap::KnownHeader> KnownHeaders,
2095 : HFI(HFI), AlreadyIncluded(AlreadyIncluded),
2099 bool AlreadyIncluded;
2100 SmallVector<ModuleMap::KnownHeader, 1> KnownHeaders;
2103 using data_type_ref =
const data_type &;
2105 using hash_value_type = unsigned;
2106 using offset_type = unsigned;
2112 uint8_t buf[
sizeof(key.Size) +
sizeof(key.ModTime)];
2113 memcpy(buf, &key.Size,
sizeof(key.Size));
2114 memcpy(buf +
sizeof(key.Size), &key.ModTime,
sizeof(key.ModTime));
2115 return llvm::xxh3_64bits(buf);
2118 std::pair<unsigned, unsigned>
2119 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref
Data) {
2120 unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
2122 for (
auto ModInfo :
Data.KnownHeaders)
2125 if (
Data.Unresolved.getPointer())
2130 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
2131 using namespace llvm::support;
2133 endian::Writer
LE(Out, llvm::endianness::little);
2138 Out.write(key.Filename.data(), KeyLen);
2141 void EmitData(raw_ostream &Out, key_type_ref key,
2142 data_type_ref
Data,
unsigned DataLen) {
2143 using namespace llvm::support;
2145 endian::Writer
LE(Out, llvm::endianness::little);
2148 unsigned char Flags = (
Data.AlreadyIncluded << 6)
2149 | (
Data.HFI.isImport << 5)
2151 Data.HFI.isPragmaOnce << 4)
2152 | (
Data.HFI.DirInfo << 1);
2155 if (
Data.HFI.LazyControllingMacro.isID())
2164 assert((
Value >> 3) == ModID &&
"overflow in header module info");
2169 for (
auto ModInfo :
Data.KnownHeaders)
2170 EmitModule(ModInfo.getModule(), ModInfo.getRole());
2171 if (
Data.Unresolved.getPointer())
2172 EmitModule(
Data.Unresolved.getPointer(),
Data.Unresolved.getInt());
2174 assert(
Out.tell() - Start == DataLen &&
"Wrong data length");
2183void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
2184 HeaderFileInfoTrait GeneratorTrait(*
this);
2185 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait>
Generator;
2186 SmallVector<const char *, 4> SavedStrings;
2187 unsigned NumHeaderSearchEntries = 0;
2193 const HeaderFileInfo
Empty;
2194 if (WritingModule) {
2195 llvm::SmallVector<Module *, 16> Worklist(1, WritingModule);
2196 while (!Worklist.empty()) {
2197 Module *M = Worklist.pop_back_val();
2214 if (!U.Size || (!U.ModTime && IncludeTimestamps)) {
2215 PP->
Diag(U.FileNameLoc, diag::err_module_no_size_mtime_for_header)
2216 << WritingModule->getFullModuleName() << U.Size.has_value()
2223 llvm::sys::path::append(Filename, U.FileName);
2224 PreparePathForOutput(Filename);
2226 StringRef FilenameDup = strdup(Filename.c_str());
2227 SavedStrings.push_back(FilenameDup.data());
2229 HeaderFileInfoTrait::key_type Key = {
2230 FilenameDup, *U.Size, IncludeTimestamps ? *U.ModTime : 0};
2231 HeaderFileInfoTrait::data_type
Data = {
2236 ++NumHeaderSearchEntries;
2239 Worklist.append(SubmodulesRange.begin(), SubmodulesRange.end());
2244 [&](FileEntryRef
File,
const HeaderFileInfo &HFI) {
2251 StringRef Filename =
File.getName();
2252 SmallString<128> FilenameTmp(Filename);
2253 if (PreparePathForOutput(FilenameTmp)) {
2256 Filename = StringRef(strdup(FilenameTmp.c_str()));
2257 SavedStrings.push_back(Filename.data());
2262 HeaderFileInfoTrait::key_type Key = {
2263 Filename,
File.getSize(),
2264 getTimestampForOutput(
File.getModificationTime())};
2265 HeaderFileInfoTrait::data_type
Data = {
2271 ++NumHeaderSearchEntries;
2275 SmallString<4096> TableData;
2278 using namespace llvm::support;
2280 llvm::raw_svector_ostream
Out(TableData);
2282 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
2283 BucketOffset =
Generator.Emit(Out, GeneratorTrait);
2287 using namespace llvm;
2289 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2291 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2292 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2293 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2294 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2295 unsigned TableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2299 NumHeaderSearchEntries, TableData.size()};
2300 Stream.EmitRecordWithBlob(TableAbbrev,
Record, TableData);
2303 for (
unsigned I = 0, N = SavedStrings.size(); I != N; ++I)
2304 free(
const_cast<char *
>(SavedStrings[I]));
2307static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
2308 unsigned SLocBufferBlobCompressedAbbrv,
2309 unsigned SLocBufferBlobAbbrv) {
2310 using RecordDataType = ASTWriter::RecordData::value_type;
2315 if (llvm::compression::zstd::isAvailable()) {
2316 llvm::compression::zstd::compress(
2317 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer, 9);
2319 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2320 llvm::toStringRef(CompressedBuffer));
2323 if (llvm::compression::zlib::isAvailable()) {
2324 llvm::compression::zlib::compress(
2325 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer);
2327 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2328 llvm::toStringRef(CompressedBuffer));
2333 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv,
Record, Blob);
2344void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
2349 const uint64_t SourceManagerBlockOffset = Stream.GetCurrentBitNo();
2355 unsigned SLocBufferBlobCompressedAbbrv =
2361 std::vector<uint32_t> SLocEntryOffsets;
2362 uint64_t SLocEntryOffsetsBase = Stream.GetCurrentBitNo();
2368 FileID FID = FileID::get(I);
2372 uint64_t Offset = Stream.GetCurrentBitNo() - SLocEntryOffsetsBase;
2373 assert((Offset >> 32) == 0 &&
"SLocEntry offset too large");
2379 if (
Cache->OrigEntry) {
2392 if (!IsSLocAffecting[I])
2394 SLocEntryOffsets.push_back(Offset);
2397 AddSourceLocation(getAffectingIncludeLoc(SourceMgr,
File),
Record);
2398 Record.push_back(
File.getFileCharacteristic());
2401 bool EmitBlob =
false;
2404 "Writing to AST an overridden file is not supported");
2407 assert(InputFileIDs[*Content->
OrigEntry] != 0 &&
"Missed file entry");
2410 Record.push_back(getAdjustedNumCreatedFIDs(FID));
2412 FileDeclIDsTy::iterator FDI = FileDeclIDs.find(FID);
2413 if (FDI != FileDeclIDs.end()) {
2414 Record.push_back(FDI->second->FirstDeclIndex);
2415 Record.push_back(FDI->second->DeclIDs.size());
2421 Stream.EmitRecordWithAbbrev(SLocFileAbbrv,
Record);
2432 std::optional<llvm::MemoryBufferRef> Buffer = Content->
getBufferOrNone(
2434 StringRef Name = Buffer ? Buffer->getBufferIdentifier() :
"";
2435 Stream.EmitRecordWithBlob(SLocBufferAbbrv,
Record,
2436 StringRef(Name.data(), Name.size() + 1));
2443 std::optional<llvm::MemoryBufferRef> Buffer = Content->
getBufferOrNone(
2446 Buffer = llvm::MemoryBufferRef(
"<<<INVALID BUFFER>>>",
"");
2447 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
2448 emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv,
2449 SLocBufferBlobAbbrv);
2453 const SrcMgr::ExpansionInfo &Expansion = SLoc->
getExpansion();
2454 SLocEntryOffsets.push_back(Offset);
2469 Record.push_back(getAdjustedOffset(NextOffset - SLoc->
getOffset()) - 1);
2470 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv,
Record);
2476 if (SLocEntryOffsets.empty())
2481 using namespace llvm;
2483 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2485 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2486 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2487 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2488 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2489 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2491 RecordData::value_type
Record[] = {
2494 SLocEntryOffsetsBase - SourceManagerBlockOffset};
2495 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev,
Record,
2496 bytes(SLocEntryOffsets));
2507 llvm::DenseMap<int, int> FilenameMap;
2508 FilenameMap[-1] = -1;
2509 for (
const auto &L : LineTable) {
2512 for (
auto &LE : L.second) {
2513 if (FilenameMap.insert(std::make_pair(
LE.FilenameID,
2514 FilenameMap.size() - 1)).second)
2515 AddPath(LineTable.getFilename(
LE.FilenameID),
Record);
2521 for (
const auto &L : LineTable) {
2526 AddFileID(L.first,
Record);
2529 Record.push_back(L.second.size());
2530 for (
const auto &LE : L.second) {
2533 Record.push_back(FilenameMap[
LE.FilenameID]);
2534 Record.push_back((
unsigned)
LE.FileKind);
2535 Record.push_back(
LE.IncludeOffset);
2550 if (MI->isBuiltinMacro())
2566void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2567 uint64_t MacroOffsetsBase = Stream.GetCurrentBitNo();
2571 WritePreprocessorDetail(*PPRec, MacroOffsetsBase);
2574 RecordData ModuleMacroRecord;
2584 SourceLocation AssumeNonNullLoc =
2586 if (AssumeNonNullLoc.
isValid()) {
2588 AddSourceLocation(AssumeNonNullLoc,
Record);
2598 AddSourceLocation(SkipInfo->HashTokenLoc,
Record);
2599 AddSourceLocation(SkipInfo->IfTokenLoc,
Record);
2600 Record.push_back(SkipInfo->FoundNonSkipPortion);
2601 Record.push_back(SkipInfo->FoundElse);
2602 AddSourceLocation(SkipInfo->ElseLoc,
Record);
2618 AddSourceLocation(S,
Record);
2628 PP.
Diag(SourceLocation(), diag::warn_module_uses_date_time) << IsModule;
2635 SmallVector<const IdentifierInfo *, 128> MacroIdentifiers;
2638 if (!isWritingStdCXXNamedModules())
2640 if (Id.second->hadMacroDefinition() &&
2641 (!Id.second->isFromAST() ||
2642 Id.second->hasChangedSinceDeserialization()))
2643 MacroIdentifiers.push_back(Id.second);
2646 llvm::sort(MacroIdentifiers, llvm::deref<std::less<>>());
2650 for (
const IdentifierInfo *Name : MacroIdentifiers) {
2652 uint64_t StartOffset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2653 assert((StartOffset >> 32) == 0 &&
"Macro identifiers offset too large");
2656 bool EmittedModuleMacros =
false;
2664 if (IsModule && WritingModule->isHeaderUnit()) {
2673 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2674 Record.push_back(getMacroRef(DefMD->getInfo(), Name));
2675 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2676 Record.push_back(VisMD->isPublic());
2678 ModuleMacroRecord.push_back(getSubmoduleID(WritingModule));
2679 AddMacroRef(MD->
getMacroInfo(), Name, ModuleMacroRecord);
2681 ModuleMacroRecord.clear();
2682 EmittedModuleMacros =
true;
2692 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2693 Record.push_back(getMacroRef(DefMD->getInfo(), Name));
2694 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2695 Record.push_back(VisMD->isPublic());
2701 SmallVector<ModuleMacro *, 8> Worklist(Leafs);
2702 llvm::DenseMap<ModuleMacro *, unsigned> Visits;
2703 while (!Worklist.empty()) {
2704 auto *
Macro = Worklist.pop_back_val();
2707 ModuleMacroRecord.push_back(getSubmoduleID(
Macro->getOwningModule()));
2708 AddMacroRef(
Macro->getMacroInfo(), Name, ModuleMacroRecord);
2709 for (
auto *M :
Macro->overrides())
2710 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2713 ModuleMacroRecord.clear();
2716 for (
auto *M :
Macro->overrides())
2717 if (++Visits[M] == M->getNumOverridingMacros())
2718 Worklist.push_back(M);
2720 EmittedModuleMacros =
true;
2723 if (
Record.empty() && !EmittedModuleMacros)
2726 IdentMacroDirectivesOffsetMap[Name] = StartOffset;
2737 std::vector<uint32_t> MacroOffsets;
2739 for (
unsigned I = 0, N = MacroInfosToEmit.size(); I != N; ++I) {
2740 const IdentifierInfo *Name = MacroInfosToEmit[I].Name;
2741 MacroInfo *MI = MacroInfosToEmit[I].MI;
2744 if (ID < FirstMacroID) {
2745 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2750 unsigned Index =
ID - FirstMacroID;
2751 if (Index >= MacroOffsets.size())
2752 MacroOffsets.resize(Index + 1);
2754 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2755 assert((Offset >> 32) == 0 &&
"Macro offset too large");
2756 MacroOffsets[Index] = Offset;
2758 AddIdentifierRef(Name,
Record);
2774 for (
const IdentifierInfo *Param : MI->
params())
2775 AddIdentifierRef(Param,
Record);
2783 Stream.EmitRecord(Code,
Record);
2787 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2802 using namespace llvm;
2804 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2806 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2807 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2808 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2810 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2813 MacroOffsetsBase - ASTBlockStartOffset};
2814 Stream.EmitRecordWithBlob(MacroOffsetAbbrev,
Record,
bytes(MacroOffsets));
2818void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec,
2819 uint64_t MacroOffsetsBase) {
2823 SmallVector<PPEntityOffset, 64> PreprocessedEntityOffsets;
2829 unsigned NumPreprocessingRecords = 0;
2830 using namespace llvm;
2833 unsigned InclusionAbbrev = 0;
2835 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2837 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2838 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2839 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2840 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2841 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2842 InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2846 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2848 for (PreprocessingRecord::iterator E = PPRec.
local_begin(),
2851 (
void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2854 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2855 assert((Offset >> 32) == 0 &&
"Preprocessed entity offset too large");
2856 SourceRange
R = getAdjustedRange((*E)->getSourceRange());
2857 PreprocessedEntityOffsets.emplace_back(
2858 getRawSourceLocationEncoding(
R.getBegin()),
2859 getRawSourceLocationEncoding(
R.getEnd()), Offset);
2861 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*E)) {
2863 MacroDefinitions[MD] = NextPreprocessorEntityID;
2865 AddIdentifierRef(MD->getName(),
Record);
2870 if (
auto *ME = dyn_cast<MacroExpansion>(*E)) {
2871 Record.push_back(ME->isBuiltinMacro());
2872 if (ME->isBuiltinMacro())
2873 AddIdentifierRef(ME->getName(),
Record);
2875 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2880 if (
auto *ID = dyn_cast<InclusionDirective>(*E)) {
2882 Record.push_back(
ID->getFileName().size());
2883 Record.push_back(
ID->wasInQuotes());
2884 Record.push_back(
static_cast<unsigned>(
ID->getKind()));
2885 Record.push_back(
ID->importedModule());
2886 SmallString<64> Buffer;
2887 Buffer +=
ID->getFileName();
2891 Buffer +=
ID->getFile()->getName();
2892 Stream.EmitRecordWithBlob(InclusionAbbrev,
Record, Buffer);
2896 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2901 if (NumPreprocessingRecords > 0) {
2902 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2905 using namespace llvm;
2907 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2909 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2910 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2913 Stream.EmitRecordWithBlob(PPEOffsetAbbrev,
Record,
2914 bytes(PreprocessedEntityOffsets));
2919 if (SkippedRanges.size() > 0) {
2920 std::vector<PPSkippedRange> SerializedSkippedRanges;
2921 SerializedSkippedRanges.reserve(SkippedRanges.size());
2922 for (
auto const& Range : SkippedRanges)
2923 SerializedSkippedRanges.emplace_back(
2924 getRawSourceLocationEncoding(
Range.getBegin()),
2925 getRawSourceLocationEncoding(
Range.getEnd()));
2927 using namespace llvm;
2928 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2930 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2931 unsigned PPESkippedRangeAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2935 Stream.EmitRecordWithBlob(PPESkippedRangeAbbrev,
Record,
2936 bytes(SerializedSkippedRanges));
2944 auto Known = SubmoduleIDs.find(Mod);
2945 if (Known != SubmoduleIDs.end())
2946 return Known->second;
2949 if (Top != WritingModule &&
2951 !Top->fullModuleNameIs(StringRef(
getLangOpts().CurrentModule))))
2954 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2957unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2958 unsigned ID = getLocalOrImportedSubmoduleID(Mod);
2967void ASTWriter::WriteSubmodules(
Module *WritingModule,
ASTContext *Context) {
2972 using namespace llvm;
2974 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2976 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2977 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2978 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
2979 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2980 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4));
2981 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2982 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2983 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2984 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2985 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2986 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2987 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2988 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2989 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2990 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2991 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2992 unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2994 Abbrev = std::make_shared<BitCodeAbbrev>();
2996 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2997 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2999 Abbrev = std::make_shared<BitCodeAbbrev>();
3001 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3002 unsigned HeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3004 Abbrev = std::make_shared<BitCodeAbbrev>();
3006 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3007 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3009 Abbrev = std::make_shared<BitCodeAbbrev>();
3011 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3012 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3014 Abbrev = std::make_shared<BitCodeAbbrev>();
3016 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3017 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3018 unsigned RequiresAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3020 Abbrev = std::make_shared<BitCodeAbbrev>();
3022 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3023 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3025 Abbrev = std::make_shared<BitCodeAbbrev>();
3027 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3028 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3030 Abbrev = std::make_shared<BitCodeAbbrev>();
3032 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3033 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3035 Abbrev = std::make_shared<BitCodeAbbrev>();
3037 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3038 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3040 Abbrev = std::make_shared<BitCodeAbbrev>();
3042 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3043 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3044 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3046 Abbrev = std::make_shared<BitCodeAbbrev>();
3048 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3049 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3051 Abbrev = std::make_shared<BitCodeAbbrev>();
3053 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3054 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3055 unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3057 Abbrev = std::make_shared<BitCodeAbbrev>();
3059 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3060 unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3062 Abbrev = std::make_shared<BitCodeAbbrev>();
3064 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3065 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3066 unsigned ChildAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3069 uint64_t SubmoduleOffsetBase = Stream.GetCurrentBitNo();
3071 unsigned TopLevelID = getSubmoduleID(WritingModule);
3074 std::queue<Module *> Q;
3075 Q.push(WritingModule);
3076 while (!Q.empty()) {
3079 unsigned ID = getSubmoduleID(Mod);
3080 if (ID < FirstSubmoduleID) {
3081 assert(0 &&
"Loaded submodule entered WritingModule ?");
3086 unsigned Index =
ID - FirstSubmoduleID;
3087 if (Index >= SubmoduleOffsets.size())
3088 SubmoduleOffsets.resize(Index + 1);
3090 uint64_t Offset = Stream.GetCurrentBitNo() - SubmoduleOffsetBase;
3091 assert((Offset >> 32) == 0 &&
"Submodule offset too large");
3092 SubmoduleOffsets[Index] = Offset;
3096 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
3097 ParentID = SubmoduleIDs[Mod->
Parent];
3101 getRawSourceLocationEncoding(getAdjustedLocation(Mod->
DefinitionLoc));
3104 FileID UnadjustedInferredFID;
3107 int InferredFID = getAdjustedFileID(UnadjustedInferredFID).getOpaqueValue();
3114 (RecordData::value_type)Mod->
Kind,
3116 (RecordData::value_type)InferredFID,
3127 Stream.EmitRecordWithBlob(DefinitionAbbrev,
Record, Mod->
Name);
3133 Stream.EmitRecordWithBlob(RequiresAbbrev,
Record,
R.FeatureName);
3137 if (std::optional<Module::Header> UmbrellaHeader =
3140 Stream.EmitRecordWithBlob(UmbrellaAbbrev,
Record,
3141 UmbrellaHeader->NameAsWritten);
3142 }
else if (std::optional<Module::DirectoryName> UmbrellaDir =
3145 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev,
Record,
3146 UmbrellaDir->NameAsWritten);
3151 unsigned RecordKind;
3153 Module::HeaderKind HeaderKind;
3159 Module::HK_PrivateTextual},
3162 for (
const auto &HL : HeaderLists) {
3163 RecordData::value_type
Record[] = {HL.RecordKind};
3164 for (
const auto &H : Mod->
getHeaders(HL.HeaderKind))
3165 Stream.EmitRecordWithBlob(HL.Abbrev,
Record, H.NameAsWritten);
3172 SmallString<128> HeaderName(H.getName());
3173 PreparePathForOutput(HeaderName);
3174 Stream.EmitRecordWithBlob(TopHeaderAbbrev,
Record, HeaderName);
3182 Record.push_back(getSubmoduleID(I));
3190 Record.push_back(getSubmoduleID(I));
3197 for (
const auto &E : Mod->
Exports) {
3200 Record.push_back(getSubmoduleID(E.first));
3201 Record.push_back(E.second);
3216 Stream.EmitRecordWithBlob(LinkLibraryAbbrev,
Record, LL.Library);
3224 getSubmoduleID(
C.Other)};
3225 Stream.EmitRecordWithBlob(ConflictAbbrev,
Record,
C.Message);
3231 Stream.EmitRecordWithBlob(ConfigMacroAbbrev,
Record, CM);
3236 if (Context && !GeneratingReducedBMI) {
3239 if (wasDeclEmitted(D))
3240 AddDeclRef(D,
Inits);
3255 getSubmoduleID(Child)};
3256 Stream.EmitRecordWithBlob(ChildAbbrev,
Record, Child->Name);
3272 assert((NextSubmoduleID - FirstSubmoduleID == SubmoduleOffsets.size()) &&
3273 "Wrong # of submodules; found a reference to a non-local, "
3274 "non-imported submodule?");
3276 Abbrev = std::make_shared<BitCodeAbbrev>();
3278 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3279 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3280 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3281 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3282 unsigned SubmoduleMetadataAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3284 RecordData::value_type
Record[] = {
3287 Stream.EmitRecordWithBlob(SubmoduleMetadataAbbrev,
Record,
3288 bytes(SubmoduleOffsets));
3291void ASTWriter::WritePragmaDiagnosticMappings(
const DiagnosticsEngine &
Diag,
3293 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
3295 unsigned CurrID = 0;
3298 auto EncodeDiagStateFlags =
3299 [](
const DiagnosticsEngine::DiagState *DS) ->
unsigned {
3300 unsigned Result = (unsigned)DS->ExtBehavior;
3302 {(unsigned)DS->IgnoreAllWarnings, (
unsigned)DS->EnableAllWarnings,
3303 (unsigned)DS->WarningsAsErrors, (
unsigned)DS->ErrorsAsFatal,
3304 (unsigned)DS->SuppressSystemWarnings})
3309 unsigned Flags = EncodeDiagStateFlags(
Diag.DiagStatesByLoc.FirstDiagState);
3312 auto AddDiagState = [&](
const DiagnosticsEngine::DiagState *State,
3313 bool IncludeNonPragmaStates) {
3316 assert(Flags == EncodeDiagStateFlags(State) &&
3317 "diag state flags vary in single AST file");
3321 assert(!IncludeNonPragmaStates ||
3322 State ==
Diag.DiagStatesByLoc.FirstDiagState);
3324 unsigned &DiagStateID = DiagStateIDMap[State];
3325 Record.push_back(DiagStateID);
3327 if (DiagStateID == 0) {
3328 DiagStateID = ++CurrID;
3329 SmallVector<std::pair<unsigned, DiagnosticMapping>> Mappings;
3332 auto SizeIdx =
Record.size();
3334 for (
const auto &I : *State) {
3336 if (!I.second.isPragma() && !IncludeNonPragmaStates)
3340 if (!I.second.isPragma() &&
3341 I.second ==
Diag.getDiagnosticIDs()->getDefaultMapping(I.first))
3343 Mappings.push_back(I);
3347 llvm::sort(Mappings, llvm::less_first());
3349 for (
const auto &I : Mappings) {
3350 Record.push_back(I.first);
3351 Record.push_back(I.second.serialize());
3358 AddDiagState(
Diag.DiagStatesByLoc.FirstDiagState, isModule);
3361 auto NumLocationsIdx =
Record.size();
3365 unsigned NumLocations = 0;
3366 for (
auto &FileIDAndFile :
Diag.DiagStatesByLoc.Files) {
3367 if (!FileIDAndFile.first.isValid() ||
3368 !FileIDAndFile.second.HasLocalTransitions)
3372 AddFileID(FileIDAndFile.first,
Record);
3374 Record.push_back(FileIDAndFile.second.StateTransitions.size());
3375 for (
auto &StatePoint : FileIDAndFile.second.StateTransitions) {
3376 Record.push_back(StatePoint.Offset);
3377 AddDiagState(StatePoint.State,
false);
3382 Record[NumLocationsIdx] = NumLocations;
3390 AddSourceLocation(
Diag.DiagStatesByLoc.CurDiagStateLoc,
Record);
3391 AddDiagState(
Diag.DiagStatesByLoc.CurDiagState,
false);
3396 Record.push_back(
Diag.DiagStateOnPushStack.size());
3397 for (
const auto *State :
Diag.DiagStateOnPushStack)
3398 AddDiagState(State,
false);
3408void ASTWriter::WriteType(ASTContext &Context, QualType T) {
3409 TypeIdx &IdxRef = TypeIdxs[T];
3411 IdxRef = TypeIdx(0, NextTypeID++);
3412 TypeIdx Idx = IdxRef;
3415 assert(Idx.
getValue() >= FirstTypeID &&
"Writing predefined type");
3419 ASTTypeWriter(Context, *
this).write(T) - DeclTypesBlockStartOffset;
3423 if (TypeOffsets.size() == Index)
3424 TypeOffsets.emplace_back(Offset);
3425 else if (TypeOffsets.size() < Index) {
3426 TypeOffsets.resize(Index + 1);
3427 TypeOffsets[Index].set(Offset);
3429 llvm_unreachable(
"Types emitted in wrong order");
3438 auto *ND = dyn_cast<NamedDecl>(D);
3453uint64_t ASTWriter::WriteDeclContextLexicalBlock(ASTContext &Context,
3454 const DeclContext *DC) {
3462 uint64_t Offset = Stream.GetCurrentBitNo();
3463 SmallVector<DeclID, 128> KindDeclPairs;
3464 for (
const auto *D : DC->
decls()) {
3465 if (DoneWritingDeclsAndTypes && !wasDeclEmitted(D))
3473 if (GeneratingReducedBMI && !D->isFromExplicitGlobalModule() &&
3477 KindDeclPairs.push_back(D->getKind());
3478 KindDeclPairs.push_back(GetDeclRef(D).getRawValue());
3481 ++NumLexicalDeclContexts;
3483 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev,
Record,
3484 bytes(KindDeclPairs));
3488void ASTWriter::WriteTypeDeclOffsets() {
3489 using namespace llvm;
3492 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3494 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3495 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3496 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3499 Stream.EmitRecordWithBlob(TypeOffsetAbbrev,
Record,
bytes(TypeOffsets));
3503 Abbrev = std::make_shared<BitCodeAbbrev>();
3505 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3506 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3507 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3510 Stream.EmitRecordWithBlob(DeclOffsetAbbrev,
Record,
bytes(DeclOffsets));
3514void ASTWriter::WriteFileDeclIDsMap() {
3515 using namespace llvm;
3517 SmallVector<std::pair<FileID, DeclIDInFileInfo *>, 64> SortedFileDeclIDs;
3518 SortedFileDeclIDs.reserve(FileDeclIDs.size());
3519 for (
const auto &P : FileDeclIDs)
3520 SortedFileDeclIDs.push_back(std::make_pair(P.first, P.second.get()));
3521 llvm::sort(SortedFileDeclIDs, llvm::less_first());
3524 SmallVector<DeclID, 256> FileGroupedDeclIDs;
3525 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
3526 DeclIDInFileInfo &Info = *FileDeclEntry.second;
3527 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
3528 llvm::stable_sort(Info.DeclIDs);
3529 for (
auto &LocDeclEntry : Info.DeclIDs)
3530 FileGroupedDeclIDs.push_back(LocDeclEntry.second.getRawValue());
3533 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3535 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3536 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3537 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
3539 FileGroupedDeclIDs.size()};
3540 Stream.EmitRecordWithBlob(AbbrevCode,
Record,
bytes(FileGroupedDeclIDs));
3543void ASTWriter::WriteComments(ASTContext &Context) {
3545 llvm::scope_exit _([
this] { Stream.ExitBlock(); });
3550 for (
const auto &FO : Context.
Comments.OrderedComments) {
3551 for (
const auto &OC : FO.second) {
3552 const RawComment *I = OC.second;
3570class ASTMethodPoolTrait {
3574 using key_type = Selector;
3575 using key_type_ref = key_type;
3579 ObjCMethodList Instance, Factory;
3581 using data_type_ref =
const data_type &;
3583 using hash_value_type = unsigned;
3584 using offset_type = unsigned;
3586 explicit ASTMethodPoolTrait(ASTWriter &Writer) : Writer(Writer) {}
3588 static hash_value_type
ComputeHash(Selector Sel) {
3592 std::pair<unsigned, unsigned>
3593 EmitKeyDataLength(raw_ostream& Out, Selector Sel,
3594 data_type_ref Methods) {
3598 unsigned DataLen = 4 + 2 + 2;
3599 for (
const ObjCMethodList *
Method = &Methods.Instance;
Method;
3601 if (ShouldWriteMethodListNode(
Method))
3602 DataLen +=
sizeof(
DeclID);
3603 for (
const ObjCMethodList *
Method = &Methods.Factory;
Method;
3605 if (ShouldWriteMethodListNode(
Method))
3606 DataLen +=
sizeof(
DeclID);
3610 void EmitKey(raw_ostream& Out, Selector Sel,
unsigned) {
3611 using namespace llvm::support;
3613 endian::Writer
LE(Out, llvm::endianness::little);
3615 assert((Start >> 32) == 0 &&
"Selector key offset too large");
3621 for (
unsigned I = 0; I != N; ++I)
3626 void EmitData(raw_ostream& Out, key_type_ref,
3627 data_type_ref Methods,
unsigned DataLen) {
3628 using namespace llvm::support;
3630 endian::Writer
LE(Out, llvm::endianness::little);
3633 unsigned NumInstanceMethods = 0;
3634 for (
const ObjCMethodList *
Method = &Methods.Instance;
Method;
3636 if (ShouldWriteMethodListNode(
Method))
3637 ++NumInstanceMethods;
3639 unsigned NumFactoryMethods = 0;
3640 for (
const ObjCMethodList *
Method = &Methods.Factory;
Method;
3642 if (ShouldWriteMethodListNode(
Method))
3643 ++NumFactoryMethods;
3645 unsigned InstanceBits = Methods.Instance.getBits();
3646 assert(InstanceBits < 4);
3647 unsigned InstanceHasMoreThanOneDeclBit =
3648 Methods.Instance.hasMoreThanOneDecl();
3649 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
3650 (InstanceHasMoreThanOneDeclBit << 2) |
3652 unsigned FactoryBits = Methods.Factory.getBits();
3653 assert(FactoryBits < 4);
3654 unsigned FactoryHasMoreThanOneDeclBit =
3655 Methods.Factory.hasMoreThanOneDecl();
3656 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
3657 (FactoryHasMoreThanOneDeclBit << 2) |
3661 for (
const ObjCMethodList *
Method = &Methods.Instance;
Method;
3663 if (ShouldWriteMethodListNode(
Method))
3665 for (
const ObjCMethodList *
Method = &Methods.Factory;
Method;
3667 if (ShouldWriteMethodListNode(
Method))
3670 assert(
Out.tell() - Start == DataLen &&
"Data length is wrong");
3674 static bool ShouldWriteMethodListNode(
const ObjCMethodList *Node) {
3686void ASTWriter::WriteSelectors(Sema &SemaRef) {
3687 using namespace llvm;
3692 unsigned NumTableEntries = 0;
3695 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait>
Generator;
3696 ASTMethodPoolTrait Trait(*
this);
3700 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
3701 for (
auto &SelectorAndID : SelectorIDs) {
3702 Selector S = SelectorAndID.first;
3704 SemaObjC::GlobalMethodPool::iterator F =
3706 ASTMethodPoolTrait::data_type
Data = {
3712 Data.Instance = F->second.first;
3713 Data.Factory = F->second.second;
3717 if (Chain && ID < FirstSelectorID) {
3719 bool changed =
false;
3720 for (ObjCMethodList *M = &
Data.Instance; M && M->getMethod();
3722 if (!M->getMethod()->isFromASTFile()) {
3728 for (ObjCMethodList *M = &
Data.Factory; M && M->getMethod();
3730 if (!M->getMethod()->isFromASTFile()) {
3738 }
else if (
Data.Instance.getMethod() ||
Data.Factory.getMethod()) {
3746 SmallString<4096> MethodPool;
3749 using namespace llvm::support;
3751 ASTMethodPoolTrait Trait(*
this);
3752 llvm::raw_svector_ostream
Out(MethodPool);
3754 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
3755 BucketOffset =
Generator.Emit(Out, Trait);
3759 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3761 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3762 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3763 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3764 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3770 Stream.EmitRecordWithBlob(MethodPoolAbbrev,
Record, MethodPool);
3774 Abbrev = std::make_shared<BitCodeAbbrev>();
3776 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3777 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3778 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3779 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3783 RecordData::value_type
Record[] = {
3786 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev,
Record,
3787 bytes(SelectorOffsets));
3793void ASTWriter::WriteReferencedSelectorsPool(Sema &SemaRef) {
3794 using namespace llvm;
3806 Selector Sel = SelectorAndLocation.first;
3807 SourceLocation Loc = SelectorAndLocation.second;
3808 Writer.AddSelectorRef(Sel);
3830 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3832 if (!Redecl->isFromASTFile()) {
3836 if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
3844 if (Redecl->getOwningModuleID() == 0)
3849 if (!
First->isFromASTFile())
3860bool IsInterestingIdentifier(
const IdentifierInfo *II, uint64_t MacroOffset,
3861 bool IsModule,
bool IsCPlusPlus) {
3862 bool NeedDecls = !IsModule || !IsCPlusPlus;
3864 bool IsInteresting =
3871 II->
isPoisoned() || (!IsModule && IsInteresting) ||
3879bool IsInterestingNonMacroIdentifier(
const IdentifierInfo *II,
3880 ASTWriter &Writer) {
3882 bool IsCPlusPlus = Writer.
getLangOpts().CPlusPlus;
3883 return IsInterestingIdentifier(II, 0, IsModule, IsCPlusPlus);
3886class ASTIdentifierTableTrait {
3889 IdentifierResolver *IdResolver;
3899 return IsInterestingIdentifier(II, MacroOffset, IsModule,
3904 using key_type =
const IdentifierInfo *;
3905 using key_type_ref = key_type;
3908 using data_type_ref = data_type;
3910 using hash_value_type = unsigned;
3911 using offset_type = unsigned;
3913 ASTIdentifierTableTrait(ASTWriter &Writer, Preprocessor &PP,
3914 IdentifierResolver *IdResolver,
bool IsModule,
3916 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3917 NeedDecls(!IsModule || !Writer.getLangOpts().
CPlusPlus),
3918 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3920 bool needDecls()
const {
return NeedDecls; }
3922 static hash_value_type
ComputeHash(
const IdentifierInfo* II) {
3923 return llvm::djbHash(II->
getName());
3931 std::pair<unsigned, unsigned>
3932 EmitKeyDataLength(raw_ostream &Out,
const IdentifierInfo *II,
IdentifierID ID) {
3941 if (InterestingIdentifierOffsets &&
3943 InterestingIdentifierOffsets->push_back(
Out.tell());
3954 if (NeedDecls && IdResolver)
3955 DataLen += std::distance(IdResolver->
begin(II), IdResolver->
end()) *
3961 void EmitKey(raw_ostream &Out,
const IdentifierInfo *II,
unsigned KeyLen) {
3965 void EmitData(raw_ostream &Out,
const IdentifierInfo *II,
IdentifierID ID,
3967 using namespace llvm::support;
3969 endian::Writer
LE(Out, llvm::endianness::little);
3979 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
3982 bool HasMacroDefinition =
3985 Bits = (Bits << 1) |
unsigned(HasMacroDefinition);
3987 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
3992 if (HasMacroDefinition)
3995 if (NeedDecls && IdResolver) {
4002 SmallVector<NamedDecl *, 16> Decls(IdResolver->
decls(II));
4003 for (NamedDecl *D : llvm::reverse(Decls))
4021void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
4022 IdentifierResolver *IdResolver,
4024 using namespace llvm;
4026 RecordData InterestingIdents;
4031 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait>
Generator;
4032 ASTIdentifierTableTrait Trait(*
this, PP, IdResolver, IsModule,
4033 IsModule ? &InterestingIdents :
nullptr);
4037 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
4038 for (
auto IdentIDPair : IdentifierIDs) {
4039 const IdentifierInfo *II = IdentIDPair.first;
4041 assert(II &&
"NULL identifier in identifier table");
4046 (Trait.needDecls() &&
4052 SmallString<4096> IdentifierTable;
4055 using namespace llvm::support;
4057 llvm::raw_svector_ostream
Out(IdentifierTable);
4059 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
4060 BucketOffset =
Generator.Emit(Out, Trait);
4064 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4066 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
4067 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4068 unsigned IDTableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4072 Stream.EmitRecordWithBlob(IDTableAbbrev,
Record, IdentifierTable);
4076 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4078 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
4079 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4080 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4083 for (
unsigned I = 0, N = IdentifierOffsets.size(); I != N; ++I)
4084 assert(IdentifierOffsets[I] &&
"Missing identifier offset?");
4088 IdentifierOffsets.size()};
4089 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev,
Record,
4090 bytes(IdentifierOffsets));
4094 if (!InterestingIdents.empty())
4102 PendingEmittingVTables.push_back(RD);
4106 TouchedModuleFiles.insert(MF);
4115class ASTDeclContextNameLookupTraitBase {
4123 using data_type = std::pair<unsigned, unsigned>;
4124 using data_type_ref =
const data_type &;
4129 explicit ASTDeclContextNameLookupTraitBase(
ASTWriter &Writer)
4132 data_type getData(
const DeclIDsTy &LocalIDs) {
4133 unsigned Start = DeclIDs.size();
4134 for (
auto ID : LocalIDs)
4135 DeclIDs.push_back(ID);
4136 return std::make_pair(Start, DeclIDs.size());
4139 data_type ImportData(
const reader::ASTDeclContextNameLookupTrait::data_type &FromReader) {
4140 unsigned Start = DeclIDs.size();
4143 DeclIDIterator<GlobalDeclID, LocalDeclID>(FromReader.begin()),
4144 DeclIDIterator<GlobalDeclID, LocalDeclID>(FromReader.end()));
4145 return std::make_pair(Start, DeclIDs.size());
4148 void EmitFileRef(raw_ostream &Out, ModuleFile *F)
const {
4150 "have reference to loaded module file but no chain?");
4152 using namespace llvm::support;
4155 llvm::endianness::little);
4158 std::pair<unsigned, unsigned> EmitKeyDataLengthBase(raw_ostream &Out,
4159 DeclarationNameKey Name,
4160 data_type_ref Lookup) {
4161 unsigned KeyLen = 1;
4184 unsigned DataLen =
sizeof(
DeclID) * (Lookup.second - Lookup.first);
4186 return {KeyLen, DataLen};
4189 void EmitKeyBase(raw_ostream &Out, DeclarationNameKey Name) {
4190 using namespace llvm::support;
4192 endian::Writer
LE(Out, llvm::endianness::little);
4207 "Invalid operator?");
4217 llvm_unreachable(
"Invalid name kind?");
4220 void EmitDataBase(raw_ostream &Out, data_type Lookup,
unsigned DataLen) {
4221 using namespace llvm::support;
4223 endian::Writer
LE(Out, llvm::endianness::little);
4225 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
4227 assert(
Out.tell() - Start == DataLen &&
"Data length is wrong");
4231class ModuleLevelNameLookupTrait :
public ASTDeclContextNameLookupTraitBase {
4233 using primary_module_hash_type = unsigned;
4235 using key_type = std::pair<DeclarationNameKey, primary_module_hash_type>;
4236 using key_type_ref = key_type;
4238 explicit ModuleLevelNameLookupTrait(ASTWriter &Writer)
4239 : ASTDeclContextNameLookupTraitBase(Writer) {}
4241 static bool EqualKey(key_type_ref a, key_type_ref b) {
return a == b; }
4244 llvm::FoldingSetNodeID
ID;
4245 ID.AddInteger(Key.first.getHash());
4246 ID.AddInteger(Key.second);
4247 return ID.computeStableHash();
4250 std::pair<unsigned, unsigned>
4251 EmitKeyDataLength(raw_ostream &Out, key_type Key, data_type_ref Lookup) {
4252 auto [KeyLen, DataLen] = EmitKeyDataLengthBase(Out, Key.first, Lookup);
4253 KeyLen +=
sizeof(Key.second);
4257 void EmitKey(raw_ostream &Out, key_type Key,
unsigned) {
4258 EmitKeyBase(Out, Key.first);
4259 llvm::support::endian::Writer
LE(Out, llvm::endianness::little);
4260 LE.write<primary_module_hash_type>(Key.second);
4263 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4265 EmitDataBase(Out, Lookup, DataLen);
4269class ASTDeclContextNameTrivialLookupTrait
4270 :
public ASTDeclContextNameLookupTraitBase {
4272 using key_type = DeclarationNameKey;
4273 using key_type_ref = key_type;
4276 using ASTDeclContextNameLookupTraitBase::ASTDeclContextNameLookupTraitBase;
4278 using ASTDeclContextNameLookupTraitBase::getData;
4280 static bool EqualKey(key_type_ref a, key_type_ref b) {
return a == b; }
4282 hash_value_type
ComputeHash(key_type Name) {
return Name.getHash(); }
4284 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
4285 DeclarationNameKey Name,
4286 data_type_ref Lookup) {
4287 auto [KeyLen, DataLen] = EmitKeyDataLengthBase(Out, Name, Lookup);
4291 void EmitKey(raw_ostream &Out, DeclarationNameKey Name,
unsigned) {
4292 return EmitKeyBase(Out, Name);
4295 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4297 EmitDataBase(Out, Lookup, DataLen);
4301static bool isModuleLocalDecl(NamedDecl *D) {
4306 return isModuleLocalDecl(Parent);
4310 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
4311 if (
auto *CDGD = dyn_cast<CXXDeductionGuideDecl>(FTD->getTemplatedDecl()))
4312 return isModuleLocalDecl(CDGD->getDeducedTemplate());
4328static bool isTULocalInNamedModules(NamedDecl *D) {
4351class ASTDeclContextNameLookupTrait
4352 :
public ASTDeclContextNameTrivialLookupTrait {
4354 using TULocalDeclsMapTy = llvm::DenseMap<key_type, DeclIDsTy>;
4356 using ModuleLevelDeclsMapTy =
4357 llvm::DenseMap<ModuleLevelNameLookupTrait::key_type, DeclIDsTy>;
4360 enum class LookupVisibility {
4370 LookupVisibility getLookupVisibility(NamedDecl *D)
const {
4373 return LookupVisibility::GenerallyVisibile;
4375 if (isModuleLocalDecl(D))
4376 return LookupVisibility::ModuleLocalVisible;
4377 if (isTULocalInNamedModules(D))
4378 return LookupVisibility::TULocal;
4390 if (
auto *ECD = dyn_cast<EnumConstantDecl>(D);
4391 ECD && DC.
isFileContext() && ECD->getTopLevelOwningNamedModule()) {
4396 return Found->isInvisibleOutsideTheOwningModule();
4398 return ECD->isFromExplicitGlobalModule() ||
4399 ECD->isInAnonymousNamespace()
4400 ? LookupVisibility::TULocal
4401 : LookupVisibility::ModuleLocalVisible;
4404 return LookupVisibility::GenerallyVisibile;
4408 ModuleLevelDeclsMapTy ModuleLocalDeclsMap;
4409 TULocalDeclsMapTy TULocalDeclsMap;
4412 using ASTDeclContextNameTrivialLookupTrait::
4413 ASTDeclContextNameTrivialLookupTrait;
4415 ASTDeclContextNameLookupTrait(ASTWriter &Writer, DeclContext &DC)
4416 : ASTDeclContextNameTrivialLookupTrait(Writer), DC(DC) {}
4418 template <
typename Coll> data_type getData(
const Coll &Decls) {
4419 unsigned Start = DeclIDs.size();
4420 auto AddDecl = [
this](NamedDecl *D) {
4421 NamedDecl *DeclForLocalLookup =
4437 switch (getLookupVisibility(DeclForLocalLookup)) {
4438 case LookupVisibility::ModuleLocalVisible:
4441 auto Key = std::make_pair(D->
getDeclName(), *PrimaryModuleHash);
4442 auto Iter = ModuleLocalDeclsMap.find(Key);
4443 if (Iter == ModuleLocalDeclsMap.end())
4444 ModuleLocalDeclsMap.insert({Key, DeclIDsTy{
ID}});
4446 Iter->second.push_back(ID);
4450 case LookupVisibility::TULocal: {
4451 auto Iter = TULocalDeclsMap.find(D->
getDeclName());
4452 if (Iter == TULocalDeclsMap.end())
4455 Iter->second.push_back(ID);
4458 case LookupVisibility::GenerallyVisibile:
4463 DeclIDs.push_back(ID);
4465 ASTReader *Chain = Writer.
getChain();
4466 for (NamedDecl *D : Decls) {
4477 for (
const auto &[_,
First] : Firsts)
4483 return std::make_pair(Start, DeclIDs.size());
4486 const ModuleLevelDeclsMapTy &getModuleLocalDecls() {
4487 return ModuleLocalDeclsMap;
4490 const TULocalDeclsMapTy &getTULocalDecls() {
return TULocalDeclsMap; }
4496class LazySpecializationInfoLookupTrait {
4498 llvm::SmallVector<serialization::reader::LazySpecializationInfo, 64> Specs;
4501 using key_type = unsigned;
4502 using key_type_ref = key_type;
4505 using data_type = std::pair<unsigned, unsigned>;
4506 using data_type_ref =
const data_type &;
4508 using hash_value_type = unsigned;
4509 using offset_type = unsigned;
4511 explicit LazySpecializationInfoLookupTrait(ASTWriter &Writer)
4514 template <
typename Col,
typename Col2>
4515 data_type getData(Col &&
C, Col2 &ExistingInfo) {
4516 unsigned Start = Specs.size();
4519 const_cast<NamedDecl *
>(D));
4524 Specs.push_back(Info);
4525 return std::make_pair(Start, Specs.size());
4528 data_type ImportData(
4530 unsigned Start = Specs.size();
4531 for (
auto ID : FromReader)
4532 Specs.push_back(ID);
4533 return std::make_pair(Start, Specs.size());
4536 static bool EqualKey(key_type_ref a, key_type_ref b) {
return a == b; }
4538 hash_value_type
ComputeHash(key_type Name) {
return Name; }
4540 void EmitFileRef(raw_ostream &Out, ModuleFile *F)
const {
4542 "have reference to loaded module file but no chain?");
4544 using namespace llvm::support;
4547 llvm::endianness::little);
4550 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
4552 data_type_ref Lookup) {
4554 unsigned KeyLen = 4;
4556 (Lookup.second - Lookup.first);
4561 void EmitKey(raw_ostream &Out, key_type HashValue,
unsigned) {
4562 using namespace llvm::support;
4564 endian::Writer
LE(Out, llvm::endianness::little);
4568 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4570 using namespace llvm::support;
4572 endian::Writer
LE(Out, llvm::endianness::little);
4575 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I) {
4576 LE.write<
DeclID>(Specs[I].getRawValue());
4578 assert(
Out.tell() - Start == DataLen &&
"Data length is wrong");
4582unsigned CalculateODRHashForSpecs(
const Decl *Spec) {
4583 ArrayRef<TemplateArgument> Args;
4584 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Spec))
4585 Args = CTSD->getTemplateArgs().asArray();
4586 else if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Spec))
4587 Args = VTSD->getTemplateArgs().asArray();
4588 else if (
auto *FD = dyn_cast<FunctionDecl>(Spec))
4589 Args = FD->getTemplateSpecializationArgs()->asArray();
4591 llvm_unreachable(
"New Specialization Kind?");
4597void ASTWriter::GenerateSpecializationInfoLookupTable(
4598 const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
4599 llvm::SmallVectorImpl<char> &LookupTable,
bool IsPartial) {
4603 MultiOnDiskHashTableGenerator<reader::LazySpecializationInfoLookupTrait,
4604 LazySpecializationInfoLookupTrait>
4606 LazySpecializationInfoLookupTrait Trait(*
this);
4608 llvm::MapVector<unsigned, llvm::SmallVector<const NamedDecl *, 4>>
4614 auto Iter = SpecializationMaps.find(HashedValue);
4615 if (Iter == SpecializationMaps.end())
4616 Iter = SpecializationMaps
4617 .try_emplace(HashedValue,
4618 llvm::SmallVector<const NamedDecl *, 4>())
4628 for (
auto &[HashValue, Specs] : SpecializationMaps) {
4629 SmallVector<serialization::reader::LazySpecializationInfo, 16>
4639 ExisitingSpecs = Lookups->Table.find(HashValue);
4641 Generator.insert(HashValue, Trait.getData(Specs, ExisitingSpecs), Trait);
4651 auto *ToEmitMaybeMergedLookupTable =
4652 (!isGeneratingReducedBMI() && Lookups) ? &Lookups->
Table :
nullptr;
4653 Generator.emit(LookupTable, Trait, ToEmitMaybeMergedLookupTable);
4656uint64_t ASTWriter::WriteSpecializationInfoLookupTable(
4657 const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
4660 llvm::SmallString<4096> LookupTable;
4661 GenerateSpecializationInfoLookupTable(D, Specializations, LookupTable,
4664 uint64_t Offset = Stream.GetCurrentBitNo();
4665 RecordData::value_type
Record[] = {
static_cast<RecordData::value_type
>(
4667 Stream.EmitRecordWithBlob(IsPartial ? DeclPartialSpecializationsAbbrev
4668 : DeclSpecializationsAbbrev,
4680 for (
auto *D :
Result.getLookupResult()) {
4682 if (LocalD->isFromASTFile())
4700void ASTWriter::GenerateNameLookupTable(
4701 ASTContext &Context,
const DeclContext *ConstDC,
4702 llvm::SmallVectorImpl<char> &LookupTable,
4703 llvm::SmallVectorImpl<char> &ModuleLocalLookupTable,
4704 llvm::SmallVectorImpl<char> &TULookupTable) {
4705 assert(!ConstDC->hasLazyLocalLexicalLookups() &&
4706 !ConstDC->hasLazyExternalLexicalLookups() &&
4707 "must call buildLookups first");
4710 auto *DC =
const_cast<DeclContext*
>(ConstDC);
4714 MultiOnDiskHashTableGenerator<reader::ASTDeclContextNameLookupTrait,
4715 ASTDeclContextNameLookupTrait>
4717 ASTDeclContextNameLookupTrait Trait(*
this, *DC);
4722 SmallVector<DeclarationName, 16> Names;
4726 bool IncludeConstructorNames =
false;
4727 bool IncludeConversionNames =
false;
4754 if (
Result.getLookupResult().empty())
4757 switch (Name.getNameKind()) {
4759 Names.push_back(Name);
4763 IncludeConstructorNames =
true;
4767 IncludeConversionNames =
true;
4775 if (IncludeConstructorNames || IncludeConversionNames) {
4780 llvm::SmallPtrSet<DeclarationName, 8> AddedNames;
4782 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
4783 auto Name = ChildND->getDeclName();
4784 switch (Name.getNameKind()) {
4789 if (!IncludeConstructorNames)
4794 if (!IncludeConversionNames)
4798 if (AddedNames.insert(Name).second)
4799 Names.push_back(Name);
4807 for (
auto &Name : Names)
4814 SmallVector<NamedDecl *, 8> ConstructorDecls;
4815 SmallVector<NamedDecl *, 8> ConversionDecls;
4819 for (
auto &Name : Names) {
4822 switch (Name.getNameKind()) {
4840 if (!ConstructorDecls.empty())
4841 Generator.insert(ConstructorDecls.front()->getDeclName(),
4842 Trait.getData(ConstructorDecls), Trait);
4843 if (!ConversionDecls.empty())
4844 Generator.insert(ConversionDecls.front()->getDeclName(),
4845 Trait.getData(ConversionDecls), Trait);
4857 auto *ToEmitMaybeMergedLookupTable =
4858 (!isGeneratingReducedBMI() && Lookups) ? &Lookups->
Table :
nullptr;
4859 Generator.emit(LookupTable, Trait, ToEmitMaybeMergedLookupTable);
4861 const auto &ModuleLocalDecls = Trait.getModuleLocalDecls();
4862 if (!ModuleLocalDecls.empty()) {
4863 MultiOnDiskHashTableGenerator<reader::ModuleLocalNameLookupTrait,
4864 ModuleLevelNameLookupTrait>
4865 ModuleLocalLookupGenerator;
4866 ModuleLevelNameLookupTrait ModuleLocalTrait(*
this);
4868 for (
const auto &ModuleLocalIter : ModuleLocalDecls) {
4869 const auto &Key = ModuleLocalIter.first;
4870 const auto &IDs = ModuleLocalIter.second;
4871 ModuleLocalLookupGenerator.insert(Key, ModuleLocalTrait.getData(IDs),
4877 auto *ModuleLocalLookups =
4878 (isGeneratingReducedBMI() && Chain &&
4882 ModuleLocalLookupGenerator.emit(ModuleLocalLookupTable, ModuleLocalTrait,
4883 ModuleLocalLookups);
4886 const auto &TULocalDecls = Trait.getTULocalDecls();
4887 if (!TULocalDecls.empty() && !isGeneratingReducedBMI()) {
4888 MultiOnDiskHashTableGenerator<reader::ASTDeclContextNameLookupTrait,
4889 ASTDeclContextNameTrivialLookupTrait>
4891 ASTDeclContextNameTrivialLookupTrait TULocalTrait(*
this);
4893 for (
const auto &TULocalIter : TULocalDecls) {
4894 const auto &Key = TULocalIter.first;
4895 const auto &IDs = TULocalIter.second;
4896 TULookupGenerator.insert(Key, TULocalTrait.getData(IDs), TULocalTrait);
4901 auto *TULocalLookups =
4905 TULookupGenerator.emit(TULookupTable, TULocalTrait, TULocalLookups);
4914void ASTWriter::WriteDeclContextVisibleBlock(
4915 ASTContext &Context, DeclContext *DC, VisibleLookupBlockOffsets &Offsets) {
4925 Prev = Prev->getPreviousDecl())
4926 if (!Prev->isFromASTFile())
4936 SmallVector<std::pair<DeclarationName, DeclContext::lookup_result>, 16>
4939 LookupResults.reserve(Map->size());
4940 for (
auto &Entry : *Map)
4941 LookupResults.push_back(
4942 std::make_pair(Entry.first, Entry.second.getLookupResult()));
4945 llvm::sort(LookupResults, llvm::less_first());
4946 for (
auto &NameAndResult : LookupResults) {
4947 DeclarationName Name = NameAndResult.first;
4954 assert(
Result.empty() &&
"Cannot have a constructor or conversion "
4955 "function name in a namespace!");
4959 for (NamedDecl *ND :
Result) {
4963 if (DoneWritingDeclsAndTypes && !wasDeclEmitted(ND))
4997 if (!Map || Map->empty())
5002 SmallString<4096> LookupTable;
5003 SmallString<4096> ModuleLocalLookupTable;
5004 SmallString<4096> TULookupTable;
5005 GenerateNameLookupTable(Context, DC, LookupTable, ModuleLocalLookupTable,
5010 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev,
Record,
5012 ++NumVisibleDeclContexts;
5014 if (!ModuleLocalLookupTable.empty()) {
5018 RecordData::value_type ModuleLocalRecord[] = {
5020 Stream.EmitRecordWithBlob(DeclModuleLocalVisibleLookupAbbrev,
5021 ModuleLocalRecord, ModuleLocalLookupTable);
5022 ++NumModuleLocalDeclContexts;
5025 if (!TULookupTable.empty()) {
5028 RecordData::value_type TULocalDeclsRecord[] = {
5030 Stream.EmitRecordWithBlob(DeclTULocalLookupAbbrev, TULocalDeclsRecord,
5032 ++NumTULocalDeclContexts;
5042void ASTWriter::WriteDeclContextVisibleUpdate(ASTContext &Context,
5043 const DeclContext *DC) {
5045 if (!Map || Map->empty())
5049 SmallString<4096> LookupTable;
5050 SmallString<4096> ModuleLocalLookupTable;
5051 SmallString<4096> TULookupTable;
5052 GenerateNameLookupTable(Context, DC, LookupTable, ModuleLocalLookupTable,
5063 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev,
Record, LookupTable);
5065 if (!ModuleLocalLookupTable.empty()) {
5067 RecordData::value_type ModuleLocalRecord[] = {
5069 Stream.EmitRecordWithBlob(ModuleLocalUpdateVisibleAbbrev, ModuleLocalRecord,
5070 ModuleLocalLookupTable);
5073 if (!TULookupTable.empty()) {
5074 RecordData::value_type GMFRecord[] = {
5076 Stream.EmitRecordWithBlob(TULocalUpdateVisibleAbbrev, GMFRecord,
5082void ASTWriter::WriteFPPragmaOptions(
const FPOptionsOverride &Opts) {
5088void ASTWriter::WriteOpenCLExtensions(Sema &SemaRef) {
5094 for (
const auto &I:Opts.OptMap) {
5095 AddString(I.getKey(),
Record);
5096 auto V = I.getValue();
5097 Record.push_back(
V.Supported ? 1 : 0);
5098 Record.push_back(
V.Enabled ? 1 : 0);
5099 Record.push_back(
V.WithPragma ? 1 : 0);
5106void ASTWriter::WriteCUDAPragmas(Sema &SemaRef) {
5107 if (SemaRef.
CUDA().ForceHostDeviceDepth > 0) {
5108 RecordData::value_type
Record[] = {SemaRef.
CUDA().ForceHostDeviceDepth};
5113void ASTWriter::WriteObjCCategories() {
5114 if (ObjCClassesWithCategories.empty())
5117 SmallVector<ObjCCategoriesInfo, 2> CategoriesMap;
5118 RecordData Categories;
5120 for (
unsigned I = 0, N = ObjCClassesWithCategories.size(); I != N; ++I) {
5122 unsigned StartIndex = Categories.size();
5124 ObjCInterfaceDecl *
Class = ObjCClassesWithCategories[I];
5127 Categories.push_back(0);
5131 Cat =
Class->known_categories_begin(),
5132 CatEnd =
Class->known_categories_end();
5133 Cat != CatEnd; ++Cat, ++Size) {
5134 assert(getDeclID(*Cat).isValid() &&
"Bogus category");
5135 AddDeclRef(*Cat, Categories);
5139 Categories[StartIndex] =
Size;
5142 ObjCCategoriesInfo CatInfo = { getDeclID(
Class), StartIndex };
5143 CategoriesMap.push_back(CatInfo);
5148 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
5151 using namespace llvm;
5153 auto Abbrev = std::make_shared<BitCodeAbbrev>();
5155 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
5156 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
5157 unsigned AbbrevID = Stream.EmitAbbrev(std::move(Abbrev));
5160 Stream.EmitRecordWithBlob(AbbrevID,
Record,
5161 reinterpret_cast<char *
>(CategoriesMap.data()),
5162 CategoriesMap.size() *
sizeof(ObjCCategoriesInfo));
5168void ASTWriter::WriteLateParsedTemplates(Sema &SemaRef) {
5175 for (
auto &LPTMapEntry : LPTMap) {
5176 const FunctionDecl *FD = LPTMapEntry.first;
5177 LateParsedTemplate &LPT = *LPTMapEntry.second;
5183 for (
const auto &
Tok : LPT.
Toks) {
5191void ASTWriter::WriteOptimizePragmaOptions(Sema &SemaRef) {
5194 AddSourceLocation(PragmaLoc,
Record);
5199void ASTWriter::WriteMSStructPragmaOptions(Sema &SemaRef) {
5207void ASTWriter::WriteMSPointersToMembersPragmaOptions(Sema &SemaRef) {
5215void ASTWriter::WritePackPragmaOptions(Sema &SemaRef) {
5226 AddAlignPackInfo(StackEntry.Value,
Record);
5227 AddSourceLocation(StackEntry.PragmaLocation,
Record);
5228 AddSourceLocation(StackEntry.PragmaPushLocation,
Record);
5229 AddString(StackEntry.StackSlotLabel,
Record);
5235void ASTWriter::WriteFloatControlPragmaOptions(Sema &SemaRef) {
5245 for (
const auto &StackEntry : SemaRef.
FpPragmaStack.Stack) {
5246 Record.push_back(StackEntry.Value.getAsOpaqueInt());
5247 AddSourceLocation(StackEntry.PragmaLocation,
Record);
5248 AddSourceLocation(StackEntry.PragmaPushLocation,
Record);
5249 AddString(StackEntry.StackSlotLabel,
Record);
5255void ASTWriter::WriteDeclsWithEffectsToVerify(Sema &SemaRef) {
5265void ASTWriter::WriteModuleFileExtension(Sema &SemaRef,
5266 ModuleFileExtensionWriter &Writer) {
5271 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
5273 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5274 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5275 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5276 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5277 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
5278 unsigned Abbrev = Stream.EmitAbbrev(std::move(Abv));
5284 Record.push_back(Metadata.MajorVersion);
5285 Record.push_back(Metadata.MinorVersion);
5286 Record.push_back(Metadata.BlockName.size());
5287 Record.push_back(Metadata.UserInfo.size());
5288 SmallString<64> Buffer;
5289 Buffer += Metadata.BlockName;
5290 Buffer += Metadata.UserInfo;
5291 Stream.EmitRecordWithBlob(Abbrev,
Record, Buffer);
5300void ASTWriter::WriteRISCVIntrinsicPragmas(Sema &SemaRef) {
5315 auto &Record = *
this;
5321 Writer->isWritingStdCXXHeaderUnit())))
5322 return Record.push_back(0);
5324 Record.push_back(A->
getKind() + 1);
5328 Record.AddSourceRange(A->
getRange());
5332 Record.push_back(A->getAttributeSpellingListIndexRaw());
5335#include "clang/Serialization/AttrPCHWrite.inc"
5341 for (
const auto *A : Attrs)
5352 if (
Tok.isAnnotation()) {
5354 switch (
Tok.getKind()) {
5355 case tok::annot_pragma_loop_hint: {
5359 Record.push_back(Info->Toks.size());
5360 for (
const auto &T : Info->Toks)
5364 case tok::annot_pragma_pack: {
5367 Record.push_back(
static_cast<unsigned>(Info->Action));
5373 case tok::annot_pragma_openmp:
5374 case tok::annot_pragma_openmp_end:
5375 case tok::annot_pragma_unused:
5376 case tok::annot_pragma_openacc:
5377 case tok::annot_pragma_openacc_end:
5378 case tok::annot_repl_input_end:
5381 llvm_unreachable(
"missing serialization code for annotation token");
5392 Record.push_back(Str.size());
5393 llvm::append_range(
Record, Str);
5398 Record.push_back(Str.size());
5399 llvm::append_range(Blob, Str);
5403 assert(WritingAST &&
"can't prepare path for output when not writing AST");
5406 StringRef PathStr(Path.data(), Path.size());
5407 if (PathStr ==
"<built-in>" || PathStr ==
"<command line>")
5411 PP->getFileManager().makeAbsolutePath(Path,
true);
5413 const char *PathBegin = Path.data();
5414 const char *PathPtr =
5416 if (PathPtr != PathBegin) {
5417 Path.erase(Path.begin(), Path.begin() + (PathPtr - PathBegin));
5441 Stream.EmitRecordWithBlob(Abbrev,
Record, FilePath);
5446 Record.push_back(Version.getMajor());
5447 if (std::optional<unsigned> Minor = Version.getMinor())
5448 Record.push_back(*Minor + 1);
5451 if (std::optional<unsigned> Subminor = Version.getSubminor())
5452 Record.push_back(*Subminor + 1);
5470 assert(ID < IdentifierOffsets.size());
5471 IdentifierOffsets[ID] = Offset;
5477 unsigned ID = SelectorIDs[Sel];
5478 assert(ID &&
"Unknown selector");
5481 if (ID < FirstSelectorID)
5483 SelectorOffsets[ID - FirstSelectorID] = Offset;
5489 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
5490 bool IncludeTimestamps,
bool BuildingImplicitModule,
5491 bool GeneratingReducedBMI)
5492 : Stream(Stream), Buffer(Buffer), ModCache(ModCache),
5493 CodeGenOpts(CodeGenOpts), IncludeTimestamps(IncludeTimestamps),
5494 BuildingImplicitModule(BuildingImplicitModule),
5495 GeneratingReducedBMI(GeneratingReducedBMI) {
5496 for (
const auto &Ext : Extensions) {
5497 if (
auto Writer = Ext->createExtensionWriter(*
this))
5498 ModuleFileExtensionWriters.push_back(std::move(Writer));
5505 assert(WritingAST &&
"can't determine lang opts when not writing AST");
5506 return PP->getLangOpts();
5510 return IncludeTimestamps ? ModTime : 0;
5515 StringRef OutputFile,
Module *WritingModule,
5516 StringRef isysroot) {
5517 llvm::TimeTraceScope scope(
"WriteAST", OutputFile);
5520 Sema *SemaPtr = dyn_cast<Sema *>(Subject);
5527 Stream.Emit((
unsigned)
'C', 8);
5528 Stream.Emit((
unsigned)
'P', 8);
5529 Stream.Emit((
unsigned)
'C', 8);
5530 Stream.Emit((
unsigned)
'H', 8);
5532 WriteBlockInfoBlock();
5535 this->WritingModule = WritingModule;
5536 ASTFileSignature Signature = WriteASTCore(SemaPtr, isysroot, WritingModule);
5538 this->WritingModule =
nullptr;
5539 this->BaseDirectory.clear();
5546template<
typename Vector>
5548 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
5554template <
typename Vector>
5557 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
5563void ASTWriter::computeNonAffectingInputFiles() {
5564 SourceManager &SrcMgr = PP->getSourceManager();
5567 IsSLocAffecting.resize(N,
true);
5568 IsSLocFileEntryAffecting.resize(N,
true);
5573 auto AffectingModuleMaps = GetAffectingModuleMaps(*PP, WritingModule);
5575 unsigned FileIDAdjustment = 0;
5576 unsigned OffsetAdjustment = 0;
5578 NonAffectingFileIDAdjustments.reserve(N);
5579 NonAffectingOffsetAdjustments.reserve(N);
5581 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
5582 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
5584 for (
unsigned I = 1; I != N; ++I) {
5586 FileID FID = FileID::get(I);
5593 if (!
Cache->OrigEntry)
5601 if (!AffectingModuleMaps)
5605 if (AffectingModuleMaps->DefinitionFileIDs.contains(FID))
5608 IsSLocAffecting[I] =
false;
5609 IsSLocFileEntryAffecting[I] =
5610 AffectingModuleMaps->DefinitionFiles.contains(*
Cache->OrigEntry);
5612 FileIDAdjustment += 1;
5618 if (!NonAffectingFileIDs.empty() &&
5619 NonAffectingFileIDs.back().ID == FID.ID - 1) {
5620 NonAffectingFileIDs.back() = FID;
5622 NonAffectingFileIDAdjustments.back() = FileIDAdjustment;
5623 NonAffectingOffsetAdjustments.back() = OffsetAdjustment;
5627 NonAffectingFileIDs.push_back(FID);
5630 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
5631 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
5634 if (!PP->getHeaderSearchInfo().getHeaderSearchOpts().ModulesIncludeVFSUsage)
5637 FileManager &FileMgr = PP->getFileManager();
5640 for (StringRef Path :
5641 PP->getHeaderSearchInfo().getHeaderSearchOpts().VFSOverlayFiles)
5643 for (
unsigned I = 1; I != N; ++I) {
5644 if (IsSLocAffecting[I]) {
5650 if (!
Cache->OrigEntry)
5653 Cache->OrigEntry->getNameAsRequested());
5659void ASTWriter::prepareLazyUpdates() {
5662 if (!GeneratingReducedBMI)
5665 DeclUpdateMap DeclUpdatesTmp;
5673 for (
auto &DeclUpdate : DeclUpdates) {
5674 const Decl *D = DeclUpdate.first;
5676 for (
auto &
Update : DeclUpdate.second) {
5679 if (Kind == DeclUpdateKind::CXXAddedFunctionDefinition)
5680 DeclUpdatesTmp[D].push_back(
5681 ASTWriter::DeclUpdate(DeclUpdateKind::CXXAddedFunctionDefinition));
5683 DeclUpdatesLazy[D].push_back(
Update);
5686 DeclUpdates.swap(DeclUpdatesTmp);
5688 UpdatedDeclContextsLazy.swap(UpdatedDeclContexts);
5690 DeclsToEmitEvenIfUnreferenced.clear();
5693void ASTWriter::PrepareWritingSpecialDecls(
Sema &SemaRef) {
5694 ASTContext &Context = SemaRef.
Context;
5696 bool isModule = WritingModule !=
nullptr;
5698 prepareLazyUpdates();
5705 PredefinedDecls.insert(D);
5713 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
5717 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
5721 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
5728 RegisterPredefDecl(Context.CFConstantStringTypeDecl,
5730 RegisterPredefDecl(Context.CFConstantStringTagDecl,
5732#define BuiltinTemplate(BTName) \
5733 RegisterPredefDecl(Context.Decl##BTName, PREDEF_DECL##BTName##_ID);
5734#include "clang/Basic/BuiltinTemplates.inc"
5746 if (GeneratingReducedBMI) {
5772 if (GeneratingReducedBMI)
5794 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I)
5805 "There are local ones at end of translation unit!");
5823 for (
const auto &I : SemaRef.KnownNamespaces)
5828 SmallVector<std::pair<NamedDecl *, SourceLocation>, 16>
Undefined;
5836 for (
const auto &DeleteExprsInfo :
5843 for (
const auto *I : DeclsToEmitEvenIfUnreferenced)
5845 DeclsToEmitEvenIfUnreferenced.clear();
5850 llvm::SmallVector<const IdentifierInfo*, 256> IIs;
5852 const IdentifierInfo *II =
ID.second;
5858 llvm::sort(IIs, llvm::deref<std::less<>>());
5860 for (
const IdentifierInfo *II : IIs)
5871 for (CXXRecordDecl *RD : PendingEmittingVTables)
5874 PendingEmittingVTables.clear();
5877void ASTWriter::WriteSpecialDeclRecords(
Sema &SemaRef) {
5878 ASTContext &Context = SemaRef.
Context;
5880 bool isModule = WritingModule !=
nullptr;
5883 if (!EagerlyDeserializedDecls.empty())
5886 if (!ModularCodegenDecls.empty())
5892 TentativeDefinitions);
5893 if (!TentativeDefinitions.empty())
5900 UnusedFileScopedDecls);
5901 if (!UnusedFileScopedDecls.empty())
5907 if (!ExtVectorDecls.empty())
5913 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I) {
5914 CXXRecordDecl *D = SemaRef.
VTableUses[I].first;
5929 if (!UnusedLocalTypedefNameCandidates.empty())
5931 UnusedLocalTypedefNameCandidates);
5933 if (!GeneratingReducedBMI) {
5943 if (!PendingInstantiations.empty())
5947 auto AddEmittedDeclRefOrZero = [
this](
RecordData &Refs,
Decl *D) {
5961 if (!SemaDeclRefs.empty())
5969 if (!DeclsToCheckForDeferredDiags.empty())
5971 DeclsToCheckForDeferredDiags);
5978 CudaCallDecl || CudaGetParamDecl || CudaLaunchDecl) {
5979 AddEmittedDeclRefOrZero(CUDASpecialDeclRefs, CudaCallDecl);
5980 AddEmittedDeclRefOrZero(CUDASpecialDeclRefs, CudaGetParamDecl);
5981 AddEmittedDeclRefOrZero(CUDASpecialDeclRefs, CudaLaunchDecl);
5989 DelegatingCtorDecls);
5990 if (!DelegatingCtorDecls.empty())
5995 for (
const auto &I : SemaRef.KnownNamespaces) {
5999 if (!KnownNamespaces.empty())
6004 SmallVector<std::pair<NamedDecl *, SourceLocation>, 16>
Undefined;
6013 if (!UndefinedButUsed.empty())
6020 for (
const auto &DeleteExprsInfo :
6025 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
6026 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
6027 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
6029 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
6033 if (!DeleteExprsToAnalyze.empty())
6037 for (CXXRecordDecl *RD : PendingEmittingVTables) {
6044 if (!VTablesToEmit.empty())
6050 using namespace llvm;
6052 bool isModule = WritingModule !=
nullptr;
6056 Chain->finalizeForWriting();
6060 computeNonAffectingInputFiles();
6062 writeUnhashedControlBlock(*PP);
6075 IdentifierIDs.clear();
6086 SmallVector<const IdentifierInfo *, 128> IIs;
6087 for (
const auto &ID : PP->getIdentifierTable())
6088 if (IsInterestingNonMacroIdentifier(
ID.second, *
this))
6089 IIs.push_back(
ID.second);
6092 llvm::sort(IIs, llvm::deref<std::less<>>());
6093 for (
const IdentifierInfo *II : IIs)
6101 for (
const auto &WeakUndeclaredIdentifierList :
6103 const IdentifierInfo *
const II = WeakUndeclaredIdentifierList.first;
6104 for (
const auto &WI : WeakUndeclaredIdentifierList.second) {
6117 ASTContext &Context = SemaPtr->
Context;
6119 Context, *
this, ExtnameUndeclaredIdentifiers);
6121 ExtnameUndeclaredIdentifiersWriter.AddIdentifierRef(II);
6122 ExtnameUndeclaredIdentifiersWriter.AddIdentifierRef(
6124 ExtnameUndeclaredIdentifiersWriter.AddSourceLocation(AL->getLocation());
6131 ASTContext &Context = SemaPtr->
Context;
6136 AddTypeRef(Context, Context.ObjCIdRedefinitionType, SpecialTypes);
6137 AddTypeRef(Context, Context.ObjCClassRedefinitionType, SpecialTypes);
6138 AddTypeRef(Context, Context.ObjCSelRedefinitionType, SpecialTypes);
6143 PrepareWritingSpecialDecls(*SemaPtr);
6146 WriteControlBlock(*PP, isysroot);
6149 Stream.FlushToWord();
6150 ASTBlockRange.first = Stream.GetCurrentBitNo() >> 3;
6152 ASTBlockStartOffset = Stream.GetCurrentBitNo();
6169 llvm::SmallVector<Selector, 256> AllSelectors;
6170 for (
auto &SelectorAndID : SelectorIDs)
6171 AllSelectors.push_back(SelectorAndID.first);
6172 for (
auto &Selector : AllSelectors)
6196 auto Abbrev = std::make_shared<BitCodeAbbrev>();
6198 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
6199 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
6200 SmallString<2048> Buffer;
6202 llvm::raw_svector_ostream
Out(Buffer);
6203 for (ModuleFile &M : Chain->ModuleMgr) {
6204 using namespace llvm::support;
6206 endian::Writer
LE(Out, llvm::endianness::little);
6214 Out.write(Name.data(), Name.size());
6220 auto writeBaseIDOrNone = [&](
auto BaseID,
bool ShouldWrite) {
6221 assert(BaseID < std::numeric_limits<uint32_t>::max() &&
"base id too high");
6235 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev,
Record,
6236 Buffer.data(), Buffer.size());
6240 WriteDeclAndTypes(SemaPtr->
Context);
6242 WriteFileDeclIDsMap();
6243 WriteSourceManagerBlock(PP->getSourceManager());
6245 WriteComments(SemaPtr->
Context);
6246 WritePreprocessor(*PP, isModule);
6247 WriteHeaderSearch(PP->getHeaderSearchInfo());
6249 WriteSelectors(*SemaPtr);
6250 WriteReferencedSelectorsPool(*SemaPtr);
6251 WriteLateParsedTemplates(*SemaPtr);
6253 WriteIdentifierTable(*PP, SemaPtr ? &SemaPtr->
IdResolver :
nullptr, isModule);
6256 WriteOpenCLExtensions(*SemaPtr);
6257 WriteCUDAPragmas(*SemaPtr);
6258 WriteRISCVIntrinsicPragmas(*SemaPtr);
6263 WriteSubmodules(WritingModule, SemaPtr ? &SemaPtr->
Context :
nullptr);
6268 WriteSpecialDeclRecords(*SemaPtr);
6271 if (!WeakUndeclaredIdentifiers.empty())
6273 WeakUndeclaredIdentifiers);
6277 if (!ExtnameUndeclaredIdentifiers.empty())
6279 ExtnameUndeclaredIdentifiers);
6281 if (!WritingModule) {
6286 ModuleInfo(uint64_t ID,
Module *M) :
ID(
ID), M(M) {}
6288 llvm::SmallVector<ModuleInfo, 64> Imports;
6291 assert(SubmoduleIDs.contains(I->getImportedModule()));
6292 Imports.push_back(ModuleInfo(SubmoduleIDs[I->getImportedModule()],
6293 I->getImportedModule()));
6297 if (!Imports.empty()) {
6298 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
6301 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
6302 return A.ID == B.ID;
6306 llvm::sort(Imports,
Cmp);
6307 Imports.erase(llvm::unique(Imports, Eq), Imports.end());
6310 for (
const auto &Import : Imports) {
6311 ImportedModules.push_back(
Import.ID);
6322 WriteObjCCategories();
6324 if (!WritingModule) {
6325 WriteOptimizePragmaOptions(*SemaPtr);
6326 WriteMSStructPragmaOptions(*SemaPtr);
6327 WriteMSPointersToMembersPragmaOptions(*SemaPtr);
6329 WritePackPragmaOptions(*SemaPtr);
6330 WriteFloatControlPragmaOptions(*SemaPtr);
6331 WriteDeclsWithEffectsToVerify(*SemaPtr);
6335 RecordData::value_type
Record[] = {NumStatements,
6337 NumLexicalDeclContexts,
6338 NumVisibleDeclContexts,
6339 NumModuleLocalDeclContexts,
6340 NumTULocalDeclContexts};
6343 Stream.FlushToWord();
6344 ASTBlockRange.second = Stream.GetCurrentBitNo() >> 3;
6348 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
6349 WriteModuleFileExtension(*SemaPtr, *ExtWriter);
6351 return backpatchSignature();
6357void ASTWriter::AddedManglingNumber(
const Decl *D,
unsigned Number) {
6361 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::ManglingNumber, Number));
6363void ASTWriter::AddedStaticLocalNumbers(
const Decl *D,
unsigned Number) {
6367 DeclUpdates[D].push_back(
6368 DeclUpdate(DeclUpdateKind::StaticLocalNumber, Number));
6377 ASTWriter::UpdateRecord &
Record = DeclUpdates[TU];
6380 DeclUpdate(DeclUpdateKind::CXXAddedAnonymousNamespace, NS));
6384void ASTWriter::WriteDeclAndTypes(
ASTContext &Context) {
6389 DeclTypesBlockStartOffset = Stream.GetCurrentBitNo();
6393 WriteDeclUpdatesBlocks(Context, DeclUpdatesOffsetsRecord);
6394 while (!DeclTypesToEmit.empty()) {
6395 DeclOrType DOT = DeclTypesToEmit.front();
6396 DeclTypesToEmit.pop();
6398 WriteType(Context, DOT.getType());
6400 WriteDecl(Context, DOT.getDecl());
6402 }
while (!DeclUpdates.empty());
6404 DoneWritingDeclsAndTypes =
true;
6408 assert(DelayedNamespace.empty() || GeneratingReducedBMI);
6410 for (NamespaceDecl *NS : DelayedNamespace) {
6411 LookupBlockOffsets Offsets;
6413 Offsets.
LexicalOffset = WriteDeclContextLexicalBlock(Context, NS);
6414 WriteDeclContextVisibleBlock(Context, NS, Offsets);
6435 assert(DeclTypesToEmit.empty());
6436 assert(DeclUpdates.empty());
6441 WriteTypeDeclOffsets();
6442 if (!DeclUpdatesOffsetsRecord.empty())
6445 if (!DelayedNamespaceRecord.empty())
6447 DelayedNamespaceRecord);
6449 if (!RelatedDeclsMap.empty()) {
6453 for (
const auto &Pair : RelatedDeclsMap) {
6454 RelatedDeclsMapRecord.push_back(Pair.first.getRawValue());
6455 RelatedDeclsMapRecord.push_back(Pair.second.size());
6456 for (
const auto &Lambda : Pair.second)
6457 RelatedDeclsMapRecord.push_back(Lambda.getRawValue());
6460 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6462 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Array));
6463 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6464 unsigned FunctionToLambdaMapAbbrev = Stream.EmitAbbrev(std::move(Abv));
6466 FunctionToLambdaMapAbbrev);
6469 if (!SpecializationsUpdates.empty()) {
6470 WriteSpecializationsUpdates(
false);
6471 SpecializationsUpdates.clear();
6474 if (!PartialSpecializationsUpdates.empty()) {
6475 WriteSpecializationsUpdates(
true);
6476 PartialSpecializationsUpdates.clear();
6482 SmallVector<DeclID, 128> NewGlobalKindDeclPairs;
6491 NewGlobalKindDeclPairs.push_back(D->
getKind());
6492 NewGlobalKindDeclPairs.push_back(
GetDeclRef(D).getRawValue());
6495 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6497 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6498 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
6501 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev,
Record,
6502 bytes(NewGlobalKindDeclPairs));
6504 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6506 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6507 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6508 UpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6510 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6512 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6513 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6514 ModuleLocalUpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6516 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6518 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6519 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6520 TULocalUpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6523 WriteDeclContextVisibleUpdate(Context, TU);
6526 if (Context.ExternCContext)
6527 WriteDeclContextVisibleUpdate(Context, Context.ExternCContext);
6530 for (
auto *DC : UpdatedDeclContexts)
6531 WriteDeclContextVisibleUpdate(Context, DC);
6534void ASTWriter::WriteSpecializationsUpdates(
bool IsPartial) {
6538 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6539 Abv->Add(llvm::BitCodeAbbrevOp(RecordType));
6540 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6541 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6542 auto UpdateSpecializationAbbrev = Stream.EmitAbbrev(std::move(Abv));
6545 IsPartial ? PartialSpecializationsUpdates : SpecializationsUpdates;
6546 for (
auto &SpecializationUpdate : SpecUpdates) {
6547 const NamedDecl *D = SpecializationUpdate.first;
6549 llvm::SmallString<4096> LookupTable;
6550 GenerateSpecializationInfoLookupTable(D, SpecializationUpdate.second,
6551 LookupTable, IsPartial);
6554 RecordData::value_type
Record[] = {
6555 static_cast<RecordData::value_type
>(RecordType),
6557 Stream.EmitRecordWithBlob(UpdateSpecializationAbbrev,
Record, LookupTable);
6561void ASTWriter::WriteDeclUpdatesBlocks(
ASTContext &Context,
6562 RecordDataImpl &OffsetsRecord) {
6563 if (DeclUpdates.empty())
6566 DeclUpdateMap LocalUpdates;
6567 LocalUpdates.swap(DeclUpdates);
6569 for (
auto &DeclUpdate : LocalUpdates) {
6570 const Decl *D = DeclUpdate.first;
6572 bool HasUpdatedBody =
false;
6573 bool HasAddedVarDefinition =
false;
6576 for (
auto &
Update : DeclUpdate.second) {
6581 if (Kind == DeclUpdateKind::CXXAddedFunctionDefinition)
6582 HasUpdatedBody =
true;
6583 else if (Kind == DeclUpdateKind::CXXAddedVarDefinition)
6584 HasAddedVarDefinition =
true;
6586 Record.push_back(llvm::to_underlying(Kind));
6589 case DeclUpdateKind::CXXAddedImplicitMember:
6590 case DeclUpdateKind::CXXAddedAnonymousNamespace:
6591 assert(
Update.getDecl() &&
"no decl to add?");
6594 case DeclUpdateKind::CXXAddedFunctionDefinition:
6595 case DeclUpdateKind::CXXAddedVarDefinition:
6598 case DeclUpdateKind::CXXPointOfInstantiation:
6603 case DeclUpdateKind::CXXInstantiatedDefaultArgument:
6608 case DeclUpdateKind::CXXInstantiatedDefaultMemberInitializer:
6613 case DeclUpdateKind::CXXInstantiatedClassDefinition: {
6615 UpdatedDeclContexts.insert(RD->getPrimaryContext());
6616 Record.push_back(RD->isParamDestroyedInCallee());
6617 Record.push_back(llvm::to_underlying(RD->getArgPassingRestrictions()));
6618 Record.AddCXXDefinitionData(RD);
6619 Record.AddOffset(WriteDeclContextLexicalBlock(Context, RD));
6624 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
6625 Record.push_back(MSInfo->getTemplateSpecializationKind());
6626 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
6629 Record.push_back(Spec->getTemplateSpecializationKind());
6630 Record.AddSourceLocation(Spec->getPointOfInstantiation());
6634 auto From = Spec->getInstantiatedFrom();
6635 if (
auto PartialSpec =
6636 From.dyn_cast<ClassTemplatePartialSpecializationDecl*>()) {
6638 Record.AddDeclRef(PartialSpec);
6639 Record.AddTemplateArgumentList(
6640 &Spec->getTemplateInstantiationArgs());
6645 Record.push_back(llvm::to_underlying(RD->getTagKind()));
6646 Record.AddSourceLocation(RD->getLocation());
6647 Record.AddSourceLocation(RD->getBeginLoc());
6648 Record.AddSourceRange(RD->getBraceRange());
6659 case DeclUpdateKind::CXXResolvedDtorDelete:
6664 case DeclUpdateKind::CXXResolvedDtorGlobDelete:
6668 case DeclUpdateKind::CXXResolvedDtorArrayDelete:
6672 case DeclUpdateKind::CXXResolvedDtorGlobArrayDelete:
6676 case DeclUpdateKind::CXXResolvedExceptionSpec: {
6679 Record.writeExceptionSpecInfo(prototype->getExceptionSpecInfo());
6683 case DeclUpdateKind::CXXDeducedReturnType:
6687 case DeclUpdateKind::DeclMarkedUsed:
6690 case DeclUpdateKind::ManglingNumber:
6691 case DeclUpdateKind::StaticLocalNumber:
6695 case DeclUpdateKind::DeclMarkedOpenMPThreadPrivate:
6697 D->
getAttr<OMPThreadPrivateDeclAttr>()->getRange());
6700 case DeclUpdateKind::DeclMarkedOpenMPAllocate: {
6701 auto *A = D->
getAttr<OMPAllocateDeclAttr>();
6702 Record.push_back(A->getAllocatorType());
6703 Record.AddStmt(A->getAllocator());
6704 Record.AddStmt(A->getAlignment());
6705 Record.AddSourceRange(A->getRange());
6709 case DeclUpdateKind::DeclMarkedOpenMPIndirectCall:
6711 D->
getAttr<OMPTargetIndirectCallAttr>()->getRange());
6714 case DeclUpdateKind::DeclMarkedOpenMPDeclareTarget:
6715 Record.push_back(D->
getAttr<OMPDeclareTargetDeclAttr>()->getMapType());
6717 D->
getAttr<OMPDeclareTargetDeclAttr>()->getRange());
6720 case DeclUpdateKind::DeclExported:
6724 case DeclUpdateKind::AddedAttrToRecord:
6725 Record.AddAttributes(llvm::ArrayRef(
Update.getAttr()));
6733 if (HasUpdatedBody) {
6736 llvm::to_underlying(DeclUpdateKind::CXXAddedFunctionDefinition));
6737 Record.push_back(Def->isInlined());
6738 Record.AddSourceLocation(Def->getInnerLocStart());
6739 Record.AddFunctionDefinition(Def);
6740 }
else if (HasAddedVarDefinition) {
6743 llvm::to_underlying(DeclUpdateKind::CXXAddedVarDefinition));
6744 Record.push_back(VD->isInline());
6745 Record.push_back(VD->isInlineSpecified());
6746 Record.AddVarDeclInit(VD);
6763 NonAffectingFileIDs.empty())
6765 auto It = llvm::lower_bound(NonAffectingFileIDs, FID);
6766 unsigned Idx = std::distance(NonAffectingFileIDs.begin(), It);
6767 unsigned Offset = NonAffectingFileIDAdjustments[Idx];
6768 return FileID::get(FID.getOpaqueValue() - Offset);
6771unsigned ASTWriter::getAdjustedNumCreatedFIDs(
FileID FID)
const {
6777 unsigned AdjustedNumCreatedFIDs = 0;
6778 for (
unsigned I = FID.ID, N = I + NumCreatedFIDs; I != N; ++I)
6779 if (IsSLocAffecting[I])
6780 ++AdjustedNumCreatedFIDs;
6781 return AdjustedNumCreatedFIDs;
6791 return SourceRange(getAdjustedLocation(
Range.getBegin()),
6792 getAdjustedLocation(
Range.getEnd()));
6797 return Offset - getAdjustment(Offset);
6802 if (NonAffectingRanges.empty())
6805 if (PP->getSourceManager().isLoadedOffset(Offset))
6808 if (Offset > NonAffectingRanges.back().getEnd().getOffset())
6809 return NonAffectingOffsetAdjustments.back();
6811 if (Offset < NonAffectingRanges.front().getBegin().getOffset())
6815 return Range.getEnd().getOffset() < Offset;
6818 auto It = llvm::lower_bound(NonAffectingRanges, Offset, Contains);
6819 unsigned Idx = std::distance(NonAffectingRanges.begin(), It);
6820 return NonAffectingOffsetAdjustments[Idx];
6824 Record.push_back(getAdjustedFileID(FID).getOpaqueValue());
6830 unsigned ModuleFileIndex = 0;
6833 if (PP->getSourceManager().isLoadedSourceLocation(Loc) && Loc.
isValid()) {
6836 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
6837 assert(SLocMapI !=
getChain()->GlobalSLocOffsetMap.end() &&
6838 "Corrupted global sloc offset map");
6843 ModuleFileIndex = F->
Index + 1;
6851 Loc = getAdjustedLocation(Loc);
6888 MacroInfoToEmitData Info = { Name, MI, ID };
6889 MacroInfosToEmit.push_back(Info);
6895 return IdentMacroDirectivesOffsetMap.lookup(Name);
6899 Record->push_back(Writer->getSelectorRef(SelRef));
6908 if (SID == 0 && Chain) {
6911 Chain->LoadSelector(Sel);
6912 SID = SelectorIDs[Sel];
6915 SID = NextSelectorID++;
6916 SelectorIDs[Sel] = SID;
6958 bool InfoHasSameExpr
6960 Record->push_back(InfoHasSameExpr);
6961 if (InfoHasSameExpr)
6978 TypeLocWriter TLW(*
this);
6988template <
typename IdxForTypeTy>
6990 IdxForTypeTy IdxForType) {
6994 unsigned FastQuals = T.getLocalFastQualifiers();
6995 T.removeLocalFastQualifiers();
6997 if (T.hasLocalNonFastQualifiers())
6998 return IdxForType(T).asTypeID(FastQuals);
7000 assert(!T.hasLocalQualifiers());
7002 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr()))
7005 if (T == Context.AutoDeductTy)
7007 if (T == Context.AutoRRefDeductTy)
7010 return IdxForType(T).asTypeID(FastQuals);
7017 assert(!T.getLocalFastQualifiers());
7021 if (DoneWritingDeclsAndTypes) {
7022 assert(0 &&
"New type seen after serializing all the types to emit!");
7028 Idx =
TypeIdx(0, NextTypeID++);
7029 DeclTypesToEmit.push(T);
7035llvm::MapVector<ModuleFile *, const Decl *>
7037 llvm::MapVector<ModuleFile *, const Decl *> Firsts;
7040 if (R->isFromASTFile())
7041 Firsts[Chain->getOwningModuleFile(R)] = R;
7042 else if (IncludeLocal)
7043 Firsts[
nullptr] = R;
7059 Record.push_back(MacroRef >> 32);
7060 Record.push_back(MacroRef & llvm::maskTrailingOnes<MacroID>(32));
7075 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
7092 assert(!(
reinterpret_cast<uintptr_t>(D) & 0x01) &&
"Invalid decl pointer");
7094 if (ID.isInvalid()) {
7095 if (DoneWritingDeclsAndTypes) {
7096 assert(0 &&
"New decl seen after serializing all the decls to emit!");
7103 DeclTypesToEmit.push(
const_cast<Decl *
>(D));
7118 assert(DeclIDs.contains(D) &&
"Declaration not emitted!");
7125 assert(DoneWritingDeclsAndTypes &&
7126 "wasDeclEmitted should only be called after writing declarations");
7131 bool Emitted = DeclIDs.contains(D);
7133 GeneratingReducedBMI) &&
7134 "The declaration within modules can only be omitted in reduced BMI.");
7138void ASTWriter::getLazyUpdates(
const Decl *D) {
7139 if (!GeneratingReducedBMI)
7142 if (
auto *Iter = DeclUpdatesLazy.find(D); Iter != DeclUpdatesLazy.end()) {
7143 for (DeclUpdate &
Update : Iter->second)
7144 DeclUpdates[D].push_back(
Update);
7145 DeclUpdatesLazy.erase(Iter);
7149 if (
auto *DC = dyn_cast<DeclContext>(D);
7150 DC && UpdatedDeclContextsLazy.count(DC)) {
7151 UpdatedDeclContexts.insert(DC);
7152 UpdatedDeclContextsLazy.remove(DC);
7157 assert(
ID.isValid());
7174 SourceManager &
SM = PP->getSourceManager();
7175 SourceLocation FileLoc =
SM.getFileLoc(Loc);
7176 assert(
SM.isLocalSourceLocation(FileLoc));
7177 auto [FID, Offset] =
SM.getDecomposedLoc(FileLoc);
7180 assert(
SM.getSLocEntry(FID).isFile());
7181 assert(IsSLocAffecting[FID.ID]);
7183 std::unique_ptr<DeclIDInFileInfo> &Info = FileDeclIDs[FID];
7185 Info = std::make_unique<DeclIDInFileInfo>();
7187 std::pair<unsigned, LocalDeclID> LocDecl(Offset, ID);
7188 LocDeclIDsTy &Decls = Info->DeclIDs;
7189 Decls.push_back(LocDecl);
7194 "expected an anonymous declaration");
7198 auto It = AnonymousDeclarationNumbers.find(D);
7199 if (It == AnonymousDeclarationNumbers.end()) {
7202 AnonymousDeclarationNumbers[ND] = Number;
7205 It = AnonymousDeclarationNumbers.find(D);
7206 assert(It != AnonymousDeclarationNumbers.end() &&
7207 "declaration not found within its lexical context");
7262 while (QualifierLoc) {
7263 NestedNames.push_back(QualifierLoc);
7267 Record->push_back(NestedNames.size());
7268 while(!NestedNames.empty()) {
7269 QualifierLoc = NestedNames.pop_back_val();
7272 Record->push_back(llvm::to_underlying(Kind));
7275 AddDeclRef(Qualifier.getAsNamespaceAndPrefix().Namespace);
7297 llvm_unreachable(
"unexpected null nested name specifier");
7304 assert(TemplateParams &&
"No TemplateParams!");
7309 Record->push_back(TemplateParams->
size());
7310 for (
const auto &P : *TemplateParams)
7313 Record->push_back(
true);
7316 Record->push_back(
false);
7323 assert(TemplateArgs &&
"No TemplateArgs!");
7324 Record->push_back(TemplateArgs->
size());
7325 for (
int i = 0, e = TemplateArgs->
size(); i != e; ++i)
7331 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
7341 Record->push_back(
Set.size());
7343 I =
Set.begin(), E =
Set.end(); I != E; ++I) {
7345 Record->push_back(I.getAccess());
7351 Record->push_back(
Base.isVirtual());
7352 Record->push_back(
Base.isBaseOfClass());
7353 Record->push_back(
Base.getAccessSpecifierAsWritten());
7354 Record->push_back(
Base.getInheritConstructors());
7367 for (
auto &
Base : Bases)
7385 for (
auto *
Init : CtorInits) {
7386 if (
Init->isBaseInitializer()) {
7390 }
else if (
Init->isDelegatingInitializer()) {
7393 }
else if (
Init->isMemberInitializer()){
7406 if (
Init->isWritten())
7420 auto &
Data = D->data();
7422 Record->push_back(
Data.IsLambda);
7426#define FIELD(Name, Width, Merge) \
7427 if (!DefinitionBits.canWriteNextNBits(Width)) { \
7428 Record->push_back(DefinitionBits); \
7429 DefinitionBits.reset(0); \
7431 DefinitionBits.addBits(Data.Name, Width);
7433#include "clang/AST/CXXRecordDeclDefinitionBits.def"
7436 Record->push_back(DefinitionBits);
7442 bool ModulesCodegen =
7447 Record->push_back(ModulesCodegen);
7449 Writer->AddDeclRef(D, Writer->ModularCodegenDecls);
7454 Record->push_back(
Data.ComputedVisibleConversions);
7455 if (
Data.ComputedVisibleConversions)
7459 if (!
Data.IsLambda) {
7460 Record->push_back(
Data.NumBases);
7461 if (
Data.NumBases > 0)
7465 Record->push_back(
Data.NumVBases);
7466 if (
Data.NumVBases > 0)
7471 auto &Lambda = D->getLambdaData();
7474 LambdaBits.
addBits(Lambda.DependencyKind, 2);
7475 LambdaBits.
addBit(Lambda.IsGenericLambda);
7476 LambdaBits.
addBits(Lambda.CaptureDefault, 2);
7477 LambdaBits.
addBits(Lambda.NumCaptures, 15);
7478 LambdaBits.
addBit(Lambda.HasKnownInternalLinkage);
7479 Record->push_back(LambdaBits);
7481 Record->push_back(Lambda.NumExplicitCaptures);
7482 Record->push_back(Lambda.ManglingNumber);
7487 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
7494 Record->push_back(CaptureBits);
7496 switch (
Capture.getCaptureKind()) {
7526 assert(ES->CheckedForSideEffects);
7527 Val |= (ES->HasConstantInitialization ? 2 : 0);
7528 Val |= (ES->HasConstantDestruction ? 4 : 0);
7542void ASTWriter::ReaderInitialized(
ASTReader *Reader) {
7543 assert(Reader &&
"Cannot remove chain");
7544 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
7545 assert(FirstDeclID == NextDeclID &&
7546 FirstTypeID == NextTypeID &&
7547 FirstIdentID == NextIdentID &&
7548 FirstMacroID == NextMacroID &&
7549 FirstSubmoduleID == NextSubmoduleID &&
7550 FirstSelectorID == NextSelectorID &&
7551 "Setting chain after writing has started.");
7557 NextSelectorID = FirstSelectorID;
7558 NextSubmoduleID = FirstSubmoduleID;
7568 unsigned OriginalModuleFileIndex = StoredID >> 32;
7572 if (OriginalModuleFileIndex == 0 && StoredID)
7583 MacroID &StoredID = MacroIDs[MI];
7584 unsigned OriginalModuleFileIndex = StoredID >> 32;
7587 if (OriginalModuleFileIndex == 0 && StoredID)
7596void ASTWriter::TypeRead(TypeIdx Idx,
QualType T) {
7608 TypeIdx &StoredIdx = TypeIdxs[T];
7614 if (ModuleFileIndex == 0 && StoredIdx.
getValue())
7625 DeclIDs[D] = LocalDeclID(ID);
7626 PredefinedDecls.insert(D);
7638 assert(!MacroDefinitions.contains(MD));
7639 MacroDefinitions[MD] =
ID;
7643 assert(!SubmoduleIDs.contains(Mod));
7644 SubmoduleIDs[Mod] =
ID;
7647void ASTWriter::CompletedTagDefinition(
const TagDecl *D) {
7648 if (Chain && Chain->isProcessingUpdateRecords())
return;
7650 assert(!WritingAST &&
"Already writing the AST!");
7651 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
7653 if (RD->isFromASTFile()) {
7658 "completed a tag from another module but not by instantiation?");
7659 DeclUpdates[RD].push_back(
7660 DeclUpdate(DeclUpdateKind::CXXInstantiatedClassDefinition));
7674void ASTWriter::AddedVisibleDecl(
const DeclContext *DC,
const Decl *D) {
7675 if (Chain && Chain->isProcessingUpdateRecords())
return;
7677 "Should not add lookup results to non-lookup contexts!");
7698 assert(!WritingAST &&
"Already writing the AST!");
7699 if (UpdatedDeclContexts.insert(DC) && !
cast<Decl>(DC)->isFromASTFile()) {
7703 llvm::append_range(DeclsToEmitEvenIfUnreferenced, DC->
decls());
7705 DeclsToEmitEvenIfUnreferenced.push_back(D);
7709 if (Chain && Chain->isProcessingUpdateRecords())
return;
7722 assert(!WritingAST &&
"Already writing the AST!");
7723 DeclUpdates[RD].push_back(
7724 DeclUpdate(DeclUpdateKind::CXXAddedImplicitMember, D));
7727void ASTWriter::ResolvedExceptionSpec(
const FunctionDecl *FD) {
7728 if (Chain && Chain->isProcessingUpdateRecords())
return;
7729 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
7731 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
7736 ->castAs<FunctionProtoType>()
7737 ->getExceptionSpecType()))
7738 DeclUpdates[D].push_back(DeclUpdateKind::CXXResolvedExceptionSpec);
7743 if (Chain && Chain->isProcessingUpdateRecords())
return;
7744 assert(!WritingAST &&
"Already writing the AST!");
7746 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
7747 DeclUpdates[D].push_back(
7748 DeclUpdate(DeclUpdateKind::CXXDeducedReturnType, ReturnType));
7755 if (Chain && Chain->isProcessingUpdateRecords())
return;
7756 assert(!WritingAST &&
"Already writing the AST!");
7757 assert(
Delete &&
"Not given an operator delete");
7759 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7760 DeclUpdates[D].push_back(
7761 DeclUpdate(DeclUpdateKind::CXXResolvedDtorDelete,
Delete));
7767 if (Chain && Chain->isProcessingUpdateRecords())
7769 assert(!WritingAST &&
"Already writing the AST!");
7770 assert(GlobDelete &&
"Not given an operator delete");
7773 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7774 DeclUpdates[D].push_back(
7775 DeclUpdate(DeclUpdateKind::CXXResolvedDtorGlobDelete, GlobDelete));
7781 if (Chain && Chain->isProcessingUpdateRecords())
7783 assert(!WritingAST &&
"Already writing the AST!");
7784 assert(ArrayDelete &&
"Not given an operator delete");
7787 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7788 DeclUpdates[D].push_back(
7789 DeclUpdate(DeclUpdateKind::CXXResolvedDtorArrayDelete, ArrayDelete));
7793void ASTWriter::ResolvedOperatorGlobArrayDelete(
7795 if (Chain && Chain->isProcessingUpdateRecords())
7797 assert(!WritingAST &&
"Already writing the AST!");
7798 assert(GlobArrayDelete &&
"Not given an operator delete");
7801 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7802 DeclUpdates[D].push_back(DeclUpdate(
7803 DeclUpdateKind::CXXResolvedDtorGlobArrayDelete, GlobArrayDelete));
7807void ASTWriter::CompletedImplicitDefinition(
const FunctionDecl *D) {
7808 if (Chain && Chain->isProcessingUpdateRecords())
return;
7809 assert(!WritingAST &&
"Already writing the AST!");
7818 DeclUpdates[D].push_back(
7819 DeclUpdate(DeclUpdateKind::CXXAddedFunctionDefinition));
7822void ASTWriter::VariableDefinitionInstantiated(
const VarDecl *D) {
7823 if (Chain && Chain->isProcessingUpdateRecords())
return;
7824 assert(!WritingAST &&
"Already writing the AST!");
7828 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::CXXAddedVarDefinition));
7831void ASTWriter::FunctionDefinitionInstantiated(
const FunctionDecl *D) {
7832 if (Chain && Chain->isProcessingUpdateRecords())
return;
7833 assert(!WritingAST &&
"Already writing the AST!");
7841 DeclUpdates[D].push_back(
7842 DeclUpdate(DeclUpdateKind::CXXAddedFunctionDefinition));
7845void ASTWriter::InstantiationRequested(
const ValueDecl *D) {
7846 if (Chain && Chain->isProcessingUpdateRecords())
return;
7847 assert(!WritingAST &&
"Already writing the AST!");
7854 if (
auto *VD = dyn_cast<VarDecl>(D))
7855 POI = VD->getPointOfInstantiation();
7858 DeclUpdates[D].push_back(
7859 DeclUpdate(DeclUpdateKind::CXXPointOfInstantiation, POI));
7862void ASTWriter::DefaultArgumentInstantiated(
const ParmVarDecl *D) {
7863 if (Chain && Chain->isProcessingUpdateRecords())
return;
7864 assert(!WritingAST &&
"Already writing the AST!");
7868 DeclUpdates[D].push_back(
7869 DeclUpdate(DeclUpdateKind::CXXInstantiatedDefaultArgument, D));
7872void ASTWriter::DefaultMemberInitializerInstantiated(
const FieldDecl *D) {
7873 assert(!WritingAST &&
"Already writing the AST!");
7877 DeclUpdates[D].push_back(
7878 DeclUpdate(DeclUpdateKind::CXXInstantiatedDefaultMemberInitializer, D));
7883 if (Chain && Chain->isProcessingUpdateRecords())
return;
7884 assert(!WritingAST &&
"Already writing the AST!");
7888 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
7889 ObjCClassesWithCategories.insert(
7893void ASTWriter::DeclarationMarkedUsed(
const Decl *D) {
7894 if (Chain && Chain->isProcessingUpdateRecords())
return;
7895 assert(!WritingAST &&
"Already writing the AST!");
7904 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::DeclMarkedUsed));
7907void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(
const Decl *D) {
7908 if (Chain && Chain->isProcessingUpdateRecords())
return;
7909 assert(!WritingAST &&
"Already writing the AST!");
7913 DeclUpdates[D].push_back(
7914 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPThreadPrivate));
7917void ASTWriter::DeclarationMarkedOpenMPAllocate(
const Decl *D,
const Attr *A) {
7918 if (Chain && Chain->isProcessingUpdateRecords())
return;
7919 assert(!WritingAST &&
"Already writing the AST!");
7923 DeclUpdates[D].push_back(
7924 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPAllocate, A));
7927void ASTWriter::DeclarationMarkedOpenMPIndirectCall(
const Decl *D) {
7928 if (Chain && Chain->isProcessingUpdateRecords())
7930 assert(!WritingAST &&
"Already writing the AST!");
7934 DeclUpdates[D].push_back(
7935 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPIndirectCall));
7938void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
7940 if (Chain && Chain->isProcessingUpdateRecords())
return;
7941 assert(!WritingAST &&
"Already writing the AST!");
7945 DeclUpdates[D].push_back(
7946 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPDeclareTarget, Attr));
7949void ASTWriter::RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M) {
7950 if (Chain && Chain->isProcessingUpdateRecords())
return;
7951 assert(!WritingAST &&
"Already writing the AST!");
7953 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::DeclExported, M));
7956void ASTWriter::AddedAttributeToRecord(
const Attr *
Attr,
7958 if (Chain && Chain->isProcessingUpdateRecords())
return;
7959 assert(!WritingAST &&
"Already writing the AST!");
7960 if (!
Record->isFromASTFile())
7962 DeclUpdates[
Record].push_back(
7963 DeclUpdate(DeclUpdateKind::AddedAttrToRecord, Attr));
7966void ASTWriter::AddedCXXTemplateSpecialization(
7968 assert(!WritingAST &&
"Already writing the AST!");
7972 if (Chain && Chain->isProcessingUpdateRecords())
7975 DeclsToEmitEvenIfUnreferenced.push_back(D);
7978void ASTWriter::AddedCXXTemplateSpecialization(
7980 assert(!WritingAST &&
"Already writing the AST!");
7984 if (Chain && Chain->isProcessingUpdateRecords())
7987 DeclsToEmitEvenIfUnreferenced.push_back(D);
7992 assert(!WritingAST &&
"Already writing the AST!");
7996 if (Chain && Chain->isProcessingUpdateRecords())
7999 DeclsToEmitEvenIfUnreferenced.push_back(D);
8008class OMPClauseWriter :
public OMPClauseVisitor<OMPClauseWriter> {
8013#define GEN_CLANG_CLAUSE_CLASS
8014#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
8015#include "llvm/Frontend/OpenMP/OMP.inc"
8024 OMPClauseWriter(*this).writeClause(
C);
8027void OMPClauseWriter::writeClause(
OMPClause *
C) {
8028 Record.push_back(
unsigned(
C->getClauseKind()));
8030 Record.AddSourceLocation(
C->getBeginLoc());
8031 Record.AddSourceLocation(
C->getEndLoc());
8035 Record.push_back(uint64_t(
C->getCaptureRegion()));
8036 Record.AddStmt(
C->getPreInitStmt());
8040 VisitOMPClauseWithPreInit(
C);
8041 Record.AddStmt(
C->getPostUpdateExpr());
8044void OMPClauseWriter::VisitOMPIfClause(
OMPIfClause *
C) {
8045 VisitOMPClauseWithPreInit(
C);
8047 Record.AddSourceLocation(
C->getNameModifierLoc());
8048 Record.AddSourceLocation(
C->getColonLoc());
8049 Record.AddStmt(
C->getCondition());
8050 Record.AddSourceLocation(
C->getLParenLoc());
8054 VisitOMPClauseWithPreInit(
C);
8055 Record.AddStmt(
C->getCondition());
8056 Record.AddSourceLocation(
C->getLParenLoc());
8060 VisitOMPClauseWithPreInit(
C);
8061 Record.writeEnum(
C->getModifier());
8062 Record.AddStmt(
C->getNumThreads());
8063 Record.AddSourceLocation(
C->getModifierLoc());
8064 Record.AddSourceLocation(
C->getLParenLoc());
8068 Record.AddStmt(
C->getSafelen());
8069 Record.AddSourceLocation(
C->getLParenLoc());
8073 Record.AddStmt(
C->getSimdlen());
8074 Record.AddSourceLocation(
C->getLParenLoc());
8078 Record.push_back(
C->getNumSizes());
8079 for (
Expr *Size :
C->getSizesRefs())
8081 Record.AddSourceLocation(
C->getLParenLoc());
8085 Record.push_back(
C->getNumCounts());
8086 Record.push_back(
C->hasOmpFill());
8087 if (
C->hasOmpFill())
8088 Record.push_back(*
C->getOmpFillIndex());
8089 Record.AddSourceLocation(
C->getOmpFillLoc());
8090 for (
Expr *Count :
C->getCountsRefs())
8092 Record.AddSourceLocation(
C->getLParenLoc());
8096 Record.push_back(
C->getNumLoops());
8097 for (
Expr *Size :
C->getArgsRefs())
8099 Record.AddSourceLocation(
C->getLParenLoc());
8105 Record.AddStmt(
C->getFactor());
8106 Record.AddSourceLocation(
C->getLParenLoc());
8110 Record.AddStmt(
C->getFirst());
8111 Record.AddStmt(
C->getCount());
8112 Record.AddSourceLocation(
C->getLParenLoc());
8113 Record.AddSourceLocation(
C->getFirstLoc());
8114 Record.AddSourceLocation(
C->getCountLoc());
8118 Record.AddStmt(
C->getAllocator());
8119 Record.AddSourceLocation(
C->getLParenLoc());
8123 Record.AddStmt(
C->getNumForLoops());
8124 Record.AddSourceLocation(
C->getLParenLoc());
8127void OMPClauseWriter::VisitOMPDetachClause(OMPDetachClause *
C) {
8128 Record.AddStmt(
C->getEventHandler());
8129 Record.AddSourceLocation(
C->getLParenLoc());
8133 Record.push_back(
unsigned(
C->getDefaultKind()));
8134 Record.AddSourceLocation(
C->getLParenLoc());
8135 Record.AddSourceLocation(
C->getDefaultKindKwLoc());
8136 Record.push_back(
unsigned(
C->getDefaultVC()));
8137 Record.AddSourceLocation(
C->getDefaultVCLoc());
8141 Record.AddSourceLocation(
C->getLParenLoc());
8142 Record.AddSourceLocation(
C->getThreadsetKindLoc());
8143 Record.writeEnum(
C->getThreadsetKind());
8146void OMPClauseWriter::VisitOMPTransparentClause(OMPTransparentClause *
C) {
8147 Record.AddSourceLocation(
C->getLParenLoc());
8148 Record.AddStmt(
C->getImpexType());
8151void OMPClauseWriter::VisitOMPProcBindClause(OMPProcBindClause *
C) {
8152 Record.push_back(
unsigned(
C->getProcBindKind()));
8153 Record.AddSourceLocation(
C->getLParenLoc());
8154 Record.AddSourceLocation(
C->getProcBindKindKwLoc());
8157void OMPClauseWriter::VisitOMPScheduleClause(OMPScheduleClause *
C) {
8158 VisitOMPClauseWithPreInit(
C);
8159 Record.push_back(
C->getScheduleKind());
8160 Record.push_back(
C->getFirstScheduleModifier());
8161 Record.push_back(
C->getSecondScheduleModifier());
8162 Record.AddStmt(
C->getChunkSize());
8163 Record.AddSourceLocation(
C->getLParenLoc());
8164 Record.AddSourceLocation(
C->getFirstScheduleModifierLoc());
8165 Record.AddSourceLocation(
C->getSecondScheduleModifierLoc());
8166 Record.AddSourceLocation(
C->getScheduleKindLoc());
8167 Record.AddSourceLocation(
C->getCommaLoc());
8170void OMPClauseWriter::VisitOMPOrderedClause(OMPOrderedClause *
C) {
8171 Record.push_back(
C->getLoopNumIterations().size());
8172 Record.AddStmt(
C->getNumForLoops());
8173 for (
Expr *NumIter :
C->getLoopNumIterations())
8175 for (
unsigned I = 0, E =
C->getLoopNumIterations().size(); I <E; ++I)
8176 Record.AddStmt(
C->getLoopCounter(I));
8177 Record.AddSourceLocation(
C->getLParenLoc());
8180void OMPClauseWriter::VisitOMPNowaitClause(OMPNowaitClause *
C) {
8181 Record.AddStmt(
C->getCondition());
8182 Record.AddSourceLocation(
C->getLParenLoc());
8185void OMPClauseWriter::VisitOMPUntiedClause(OMPUntiedClause *) {}
8187void OMPClauseWriter::VisitOMPMergeableClause(OMPMergeableClause *) {}
8189void OMPClauseWriter::VisitOMPReadClause(OMPReadClause *) {}
8191void OMPClauseWriter::VisitOMPWriteClause(OMPWriteClause *) {}
8193void OMPClauseWriter::VisitOMPUpdateClause(OMPUpdateClause *
C) {
8194 Record.push_back(
C->isExtended() ? 1 : 0);
8195 if (
C->isExtended()) {
8196 Record.AddSourceLocation(
C->getLParenLoc());
8197 Record.AddSourceLocation(
C->getArgumentLoc());
8198 Record.writeEnum(
C->getDependencyKind());
8202void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {}
8204void OMPClauseWriter::VisitOMPCompareClause(OMPCompareClause *) {}
8207void OMPClauseWriter::VisitOMPFailClause(OMPFailClause *
C) {
8208 Record.AddSourceLocation(
C->getLParenLoc());
8209 Record.AddSourceLocation(
C->getFailParameterLoc());
8210 Record.writeEnum(
C->getFailParameter());
8213void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
8215void OMPClauseWriter::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
8217void OMPClauseWriter::VisitOMPAbsentClause(OMPAbsentClause *
C) {
8218 Record.push_back(
static_cast<uint64_t>(
C->getDirectiveKinds().size()));
8219 Record.AddSourceLocation(
C->getLParenLoc());
8220 for (
auto K :
C->getDirectiveKinds()) {
8225void OMPClauseWriter::VisitOMPHoldsClause(OMPHoldsClause *
C) {
8227 Record.AddSourceLocation(
C->getLParenLoc());
8230void OMPClauseWriter::VisitOMPContainsClause(OMPContainsClause *
C) {
8231 Record.push_back(
static_cast<uint64_t>(
C->getDirectiveKinds().size()));
8232 Record.AddSourceLocation(
C->getLParenLoc());
8233 for (
auto K :
C->getDirectiveKinds()) {
8238void OMPClauseWriter::VisitOMPNoOpenMPClause(OMPNoOpenMPClause *) {}
8240void OMPClauseWriter::VisitOMPNoOpenMPRoutinesClause(
8241 OMPNoOpenMPRoutinesClause *) {}
8243void OMPClauseWriter::VisitOMPNoOpenMPConstructsClause(
8244 OMPNoOpenMPConstructsClause *) {}
8246void OMPClauseWriter::VisitOMPNoParallelismClause(OMPNoParallelismClause *) {}
8248void OMPClauseWriter::VisitOMPAcquireClause(OMPAcquireClause *) {}
8250void OMPClauseWriter::VisitOMPReleaseClause(OMPReleaseClause *) {}
8252void OMPClauseWriter::VisitOMPRelaxedClause(OMPRelaxedClause *) {}
8254void OMPClauseWriter::VisitOMPWeakClause(OMPWeakClause *) {}
8256void OMPClauseWriter::VisitOMPThreadsClause(OMPThreadsClause *) {}
8258void OMPClauseWriter::VisitOMPSIMDClause(OMPSIMDClause *) {}
8260void OMPClauseWriter::VisitOMPNogroupClause(OMPNogroupClause *) {}
8262void OMPClauseWriter::VisitOMPInitClause(OMPInitClause *
C) {
8265 Record.push_back(
C->varlist_size());
8266 Record.push_back(
C->attrs().size());
8270 Record.writeBool(
C->getIsTarget());
8271 Record.writeBool(
C->getIsTargetSync());
8272 Record.writeBool(
C->hasPreferAttrs());
8274 for (OMPInitClause::PrefView P :
C->prefs()) {
8275 Record.push_back(P.Attrs.size());
8276 for (
Expr *A : P.Attrs)
8279 Record.AddSourceLocation(
C->getLParenLoc());
8280 Record.AddSourceLocation(
C->getVarLoc());
8283void OMPClauseWriter::VisitOMPUseClause(OMPUseClause *
C) {
8284 Record.AddStmt(
C->getInteropVar());
8285 Record.AddSourceLocation(
C->getLParenLoc());
8286 Record.AddSourceLocation(
C->getVarLoc());
8289void OMPClauseWriter::VisitOMPDestroyClause(OMPDestroyClause *
C) {
8290 Record.AddStmt(
C->getInteropVar());
8291 Record.AddSourceLocation(
C->getLParenLoc());
8292 Record.AddSourceLocation(
C->getVarLoc());
8295void OMPClauseWriter::VisitOMPNovariantsClause(OMPNovariantsClause *
C) {
8296 VisitOMPClauseWithPreInit(
C);
8297 Record.AddStmt(
C->getCondition());
8298 Record.AddSourceLocation(
C->getLParenLoc());
8301void OMPClauseWriter::VisitOMPNocontextClause(OMPNocontextClause *
C) {
8302 VisitOMPClauseWithPreInit(
C);
8303 Record.AddStmt(
C->getCondition());
8304 Record.AddSourceLocation(
C->getLParenLoc());
8307void OMPClauseWriter::VisitOMPFilterClause(OMPFilterClause *
C) {
8308 VisitOMPClauseWithPreInit(
C);
8309 Record.AddStmt(
C->getThreadID());
8310 Record.AddSourceLocation(
C->getLParenLoc());
8314 Record.AddStmt(
C->getAlignment());
8315 Record.AddSourceLocation(
C->getLParenLoc());
8318void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *
C) {
8319 Record.push_back(
C->varlist_size());
8320 Record.AddSourceLocation(
C->getLParenLoc());
8321 for (
auto *
VE :
C->varlist()) {
8324 for (
auto *
VE :
C->private_copies()) {
8329void OMPClauseWriter::VisitOMPFirstprivateClause(OMPFirstprivateClause *
C) {
8330 Record.push_back(
C->varlist_size());
8331 VisitOMPClauseWithPreInit(
C);
8332 Record.AddSourceLocation(
C->getLParenLoc());
8333 for (
auto *
VE :
C->varlist()) {
8336 for (
auto *
VE :
C->private_copies()) {
8339 for (
auto *
VE :
C->inits()) {
8344void OMPClauseWriter::VisitOMPLastprivateClause(OMPLastprivateClause *
C) {
8345 Record.push_back(
C->varlist_size());
8346 VisitOMPClauseWithPostUpdate(
C);
8347 Record.AddSourceLocation(
C->getLParenLoc());
8348 Record.writeEnum(
C->getKind());
8349 Record.AddSourceLocation(
C->getKindLoc());
8350 Record.AddSourceLocation(
C->getColonLoc());
8351 for (
auto *
VE :
C->varlist())
8353 for (
auto *E :
C->private_copies())
8355 for (
auto *E :
C->source_exprs())
8357 for (
auto *E :
C->destination_exprs())
8359 for (
auto *E :
C->assignment_ops())
8363void OMPClauseWriter::VisitOMPSharedClause(OMPSharedClause *
C) {
8364 Record.push_back(
C->varlist_size());
8365 Record.AddSourceLocation(
C->getLParenLoc());
8366 for (
auto *
VE :
C->varlist())
8370void OMPClauseWriter::VisitOMPReductionClause(OMPReductionClause *
C) {
8371 Record.push_back(
C->varlist_size());
8372 Record.writeEnum(
C->getModifier());
8373 VisitOMPClauseWithPostUpdate(
C);
8374 Record.AddSourceLocation(
C->getLParenLoc());
8375 Record.AddSourceLocation(
C->getModifierLoc());
8376 Record.AddSourceLocation(
C->getColonLoc());
8377 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
8378 Record.AddDeclarationNameInfo(
C->getNameInfo());
8379 for (
auto *
VE :
C->varlist())
8381 for (
auto *
VE :
C->privates())
8383 for (
auto *E :
C->lhs_exprs())
8385 for (
auto *E :
C->rhs_exprs())
8387 for (
auto *E :
C->reduction_ops())
8389 if (
C->getModifier() == clang::OMPC_REDUCTION_inscan) {
8390 for (
auto *E :
C->copy_ops())
8392 for (
auto *E :
C->copy_array_temps())
8394 for (
auto *E :
C->copy_array_elems())
8397 auto PrivateFlags =
C->private_var_reduction_flags();
8398 Record.push_back(std::distance(PrivateFlags.begin(), PrivateFlags.end()));
8399 for (
bool Flag : PrivateFlags)
8403void OMPClauseWriter::VisitOMPTaskReductionClause(OMPTaskReductionClause *
C) {
8404 Record.push_back(
C->varlist_size());
8405 VisitOMPClauseWithPostUpdate(
C);
8406 Record.AddSourceLocation(
C->getLParenLoc());
8407 Record.AddSourceLocation(
C->getColonLoc());
8408 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
8409 Record.AddDeclarationNameInfo(
C->getNameInfo());
8410 for (
auto *
VE :
C->varlist())
8412 for (
auto *
VE :
C->privates())
8414 for (
auto *E :
C->lhs_exprs())
8416 for (
auto *E :
C->rhs_exprs())
8418 for (
auto *E :
C->reduction_ops())
8422void OMPClauseWriter::VisitOMPInReductionClause(OMPInReductionClause *
C) {
8423 Record.push_back(
C->varlist_size());
8424 VisitOMPClauseWithPostUpdate(
C);
8425 Record.AddSourceLocation(
C->getLParenLoc());
8426 Record.AddSourceLocation(
C->getColonLoc());
8427 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
8428 Record.AddDeclarationNameInfo(
C->getNameInfo());
8429 for (
auto *
VE :
C->varlist())
8431 for (
auto *
VE :
C->privates())
8433 for (
auto *E :
C->lhs_exprs())
8435 for (
auto *E :
C->rhs_exprs())
8437 for (
auto *E :
C->reduction_ops())
8439 for (
auto *E :
C->taskgroup_descriptors())
8443void OMPClauseWriter::VisitOMPLinearClause(OMPLinearClause *
C) {
8444 Record.push_back(
C->varlist_size());
8445 VisitOMPClauseWithPostUpdate(
C);
8446 Record.AddSourceLocation(
C->getLParenLoc());
8447 Record.AddSourceLocation(
C->getColonLoc());
8448 Record.push_back(
C->getModifier());
8449 Record.AddSourceLocation(
C->getModifierLoc());
8450 for (
auto *
VE :
C->varlist()) {
8453 for (
auto *
VE :
C->privates()) {
8456 for (
auto *
VE :
C->inits()) {
8459 for (
auto *
VE :
C->updates()) {
8462 for (
auto *
VE :
C->finals()) {
8466 Record.AddStmt(
C->getCalcStep());
8467 for (
auto *
VE :
C->used_expressions())
8471void OMPClauseWriter::VisitOMPAlignedClause(OMPAlignedClause *
C) {
8472 Record.push_back(
C->varlist_size());
8473 Record.AddSourceLocation(
C->getLParenLoc());
8474 Record.AddSourceLocation(
C->getColonLoc());
8475 for (
auto *
VE :
C->varlist())
8477 Record.AddStmt(
C->getAlignment());
8480void OMPClauseWriter::VisitOMPCopyinClause(OMPCopyinClause *
C) {
8481 Record.push_back(
C->varlist_size());
8482 Record.AddSourceLocation(
C->getLParenLoc());
8483 for (
auto *
VE :
C->varlist())
8485 for (
auto *E :
C->source_exprs())
8487 for (
auto *E :
C->destination_exprs())
8489 for (
auto *E :
C->assignment_ops())
8493void OMPClauseWriter::VisitOMPCopyprivateClause(OMPCopyprivateClause *
C) {
8494 Record.push_back(
C->varlist_size());
8495 Record.AddSourceLocation(
C->getLParenLoc());
8496 for (
auto *
VE :
C->varlist())
8498 for (
auto *E :
C->source_exprs())
8500 for (
auto *E :
C->destination_exprs())
8502 for (
auto *E :
C->assignment_ops())
8506void OMPClauseWriter::VisitOMPFlushClause(OMPFlushClause *
C) {
8507 Record.push_back(
C->varlist_size());
8508 Record.AddSourceLocation(
C->getLParenLoc());
8509 for (
auto *
VE :
C->varlist())
8513void OMPClauseWriter::VisitOMPDepobjClause(OMPDepobjClause *
C) {
8514 Record.AddStmt(
C->getDepobj());
8515 Record.AddSourceLocation(
C->getLParenLoc());
8518void OMPClauseWriter::VisitOMPDependClause(OMPDependClause *
C) {
8519 Record.push_back(
C->varlist_size());
8520 Record.push_back(
C->getNumLoops());
8521 Record.AddSourceLocation(
C->getLParenLoc());
8522 Record.AddStmt(
C->getModifier());
8523 Record.push_back(
C->getDependencyKind());
8524 Record.AddSourceLocation(
C->getDependencyLoc());
8525 Record.AddSourceLocation(
C->getColonLoc());
8526 Record.AddSourceLocation(
C->getOmpAllMemoryLoc());
8527 for (
auto *
VE :
C->varlist())
8529 for (
unsigned I = 0, E =
C->getNumLoops(); I < E; ++I)
8530 Record.AddStmt(
C->getLoopData(I));
8533void OMPClauseWriter::VisitOMPDeviceClause(OMPDeviceClause *
C) {
8534 VisitOMPClauseWithPreInit(
C);
8535 Record.writeEnum(
C->getModifier());
8536 Record.AddStmt(
C->getDevice());
8537 Record.AddSourceLocation(
C->getModifierLoc());
8538 Record.AddSourceLocation(
C->getLParenLoc());
8541void OMPClauseWriter::VisitOMPMapClause(OMPMapClause *
C) {
8542 Record.push_back(
C->varlist_size());
8543 Record.push_back(
C->getUniqueDeclarationsNum());
8544 Record.push_back(
C->getTotalComponentListNum());
8545 Record.push_back(
C->getTotalComponentsNum());
8546 Record.AddSourceLocation(
C->getLParenLoc());
8547 bool HasIteratorModifier =
false;
8549 Record.push_back(
C->getMapTypeModifier(I));
8550 Record.AddSourceLocation(
C->getMapTypeModifierLoc(I));
8551 if (
C->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator)
8552 HasIteratorModifier =
true;
8554 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8555 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8556 Record.push_back(
C->getMapType());
8557 Record.AddSourceLocation(
C->getMapLoc());
8558 Record.AddSourceLocation(
C->getColonLoc());
8559 for (
auto *E :
C->varlist())
8561 for (
auto *E :
C->mapperlists())
8563 if (HasIteratorModifier)
8564 Record.AddStmt(
C->getIteratorModifier());
8565 for (
auto *D :
C->all_decls())
8567 for (
auto N :
C->all_num_lists())
8569 for (
auto N :
C->all_lists_sizes())
8571 for (
auto &M :
C->all_components()) {
8572 Record.AddStmt(M.getAssociatedExpression());
8573 Record.AddDeclRef(M.getAssociatedDeclaration());
8578 Record.push_back(
C->varlist_size());
8579 Record.writeEnum(
C->getFirstAllocateModifier());
8580 Record.writeEnum(
C->getSecondAllocateModifier());
8581 Record.AddSourceLocation(
C->getLParenLoc());
8582 Record.AddSourceLocation(
C->getColonLoc());
8583 Record.AddStmt(
C->getAllocator());
8584 Record.AddStmt(
C->getAlignment());
8585 for (
auto *
VE :
C->varlist())
8589void OMPClauseWriter::VisitOMPNumTeamsClause(OMPNumTeamsClause *
C) {
8590 Record.push_back(
C->varlist_size());
8591 VisitOMPClauseWithPreInit(
C);
8592 Record.AddSourceLocation(
C->getLParenLoc());
8593 for (
auto *
VE :
C->varlist())
8597void OMPClauseWriter::VisitOMPThreadLimitClause(OMPThreadLimitClause *
C) {
8598 Record.push_back(
C->varlist_size());
8599 VisitOMPClauseWithPreInit(
C);
8600 Record.AddSourceLocation(
C->getLParenLoc());
8601 for (
auto *
VE :
C->varlist())
8605void OMPClauseWriter::VisitOMPPriorityClause(OMPPriorityClause *
C) {
8606 VisitOMPClauseWithPreInit(
C);
8607 Record.AddStmt(
C->getPriority());
8608 Record.AddSourceLocation(
C->getLParenLoc());
8611void OMPClauseWriter::VisitOMPGrainsizeClause(OMPGrainsizeClause *
C) {
8612 VisitOMPClauseWithPreInit(
C);
8613 Record.writeEnum(
C->getModifier());
8614 Record.AddStmt(
C->getGrainsize());
8615 Record.AddSourceLocation(
C->getModifierLoc());
8616 Record.AddSourceLocation(
C->getLParenLoc());
8619void OMPClauseWriter::VisitOMPNumTasksClause(OMPNumTasksClause *
C) {
8620 VisitOMPClauseWithPreInit(
C);
8621 Record.writeEnum(
C->getModifier());
8622 Record.AddStmt(
C->getNumTasks());
8623 Record.AddSourceLocation(
C->getModifierLoc());
8624 Record.AddSourceLocation(
C->getLParenLoc());
8627void OMPClauseWriter::VisitOMPHintClause(OMPHintClause *
C) {
8629 Record.AddSourceLocation(
C->getLParenLoc());
8632void OMPClauseWriter::VisitOMPDistScheduleClause(OMPDistScheduleClause *
C) {
8633 VisitOMPClauseWithPreInit(
C);
8634 Record.push_back(
C->getDistScheduleKind());
8635 Record.AddStmt(
C->getChunkSize());
8636 Record.AddSourceLocation(
C->getLParenLoc());
8637 Record.AddSourceLocation(
C->getDistScheduleKindLoc());
8638 Record.AddSourceLocation(
C->getCommaLoc());
8641void OMPClauseWriter::VisitOMPDefaultmapClause(OMPDefaultmapClause *
C) {
8642 Record.push_back(
C->getDefaultmapKind());
8643 Record.push_back(
C->getDefaultmapModifier());
8644 Record.AddSourceLocation(
C->getLParenLoc());
8645 Record.AddSourceLocation(
C->getDefaultmapModifierLoc());
8646 Record.AddSourceLocation(
C->getDefaultmapKindLoc());
8649void OMPClauseWriter::VisitOMPToClause(OMPToClause *
C) {
8650 Record.push_back(
C->varlist_size());
8651 Record.push_back(
C->getUniqueDeclarationsNum());
8652 Record.push_back(
C->getTotalComponentListNum());
8653 Record.push_back(
C->getTotalComponentsNum());
8654 Record.AddSourceLocation(
C->getLParenLoc());
8656 Record.push_back(
C->getMotionModifier(I));
8657 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
8658 if (
C->getMotionModifier(I) == OMPC_MOTION_MODIFIER_iterator)
8659 Record.AddStmt(
C->getIteratorModifier());
8661 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8662 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8663 Record.AddSourceLocation(
C->getColonLoc());
8664 for (
auto *E :
C->varlist())
8666 for (
auto *E :
C->mapperlists())
8668 for (
auto *D :
C->all_decls())
8670 for (
auto N :
C->all_num_lists())
8672 for (
auto N :
C->all_lists_sizes())
8674 for (
auto &M :
C->all_components()) {
8675 Record.AddStmt(M.getAssociatedExpression());
8676 Record.writeBool(M.isNonContiguous());
8677 Record.AddDeclRef(M.getAssociatedDeclaration());
8681void OMPClauseWriter::VisitOMPFromClause(OMPFromClause *
C) {
8682 Record.push_back(
C->varlist_size());
8683 Record.push_back(
C->getUniqueDeclarationsNum());
8684 Record.push_back(
C->getTotalComponentListNum());
8685 Record.push_back(
C->getTotalComponentsNum());
8686 Record.AddSourceLocation(
C->getLParenLoc());
8688 Record.push_back(
C->getMotionModifier(I));
8689 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
8690 if (
C->getMotionModifier(I) == OMPC_MOTION_MODIFIER_iterator)
8691 Record.AddStmt(
C->getIteratorModifier());
8693 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8694 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8695 Record.AddSourceLocation(
C->getColonLoc());
8696 for (
auto *E :
C->varlist())
8698 for (
auto *E :
C->mapperlists())
8700 for (
auto *D :
C->all_decls())
8702 for (
auto N :
C->all_num_lists())
8704 for (
auto N :
C->all_lists_sizes())
8706 for (
auto &M :
C->all_components()) {
8707 Record.AddStmt(M.getAssociatedExpression());
8708 Record.writeBool(M.isNonContiguous());
8709 Record.AddDeclRef(M.getAssociatedDeclaration());
8713void OMPClauseWriter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *
C) {
8714 Record.push_back(
C->varlist_size());
8715 Record.push_back(
C->getUniqueDeclarationsNum());
8716 Record.push_back(
C->getTotalComponentListNum());
8717 Record.push_back(
C->getTotalComponentsNum());
8718 Record.AddSourceLocation(
C->getLParenLoc());
8719 Record.writeEnum(
C->getFallbackModifier());
8720 Record.AddSourceLocation(
C->getFallbackModifierLoc());
8721 for (
auto *E :
C->varlist())
8723 for (
auto *
VE :
C->private_copies())
8725 for (
auto *
VE :
C->inits())
8727 for (
auto *D :
C->all_decls())
8729 for (
auto N :
C->all_num_lists())
8731 for (
auto N :
C->all_lists_sizes())
8733 for (
auto &M :
C->all_components()) {
8734 Record.AddStmt(M.getAssociatedExpression());
8735 Record.AddDeclRef(M.getAssociatedDeclaration());
8739void OMPClauseWriter::VisitOMPUseDeviceAddrClause(OMPUseDeviceAddrClause *
C) {
8740 Record.push_back(
C->varlist_size());
8741 Record.push_back(
C->getUniqueDeclarationsNum());
8742 Record.push_back(
C->getTotalComponentListNum());
8743 Record.push_back(
C->getTotalComponentsNum());
8744 Record.AddSourceLocation(
C->getLParenLoc());
8745 for (
auto *E :
C->varlist())
8747 for (
auto *D :
C->all_decls())
8749 for (
auto N :
C->all_num_lists())
8751 for (
auto N :
C->all_lists_sizes())
8753 for (
auto &M :
C->all_components()) {
8754 Record.AddStmt(M.getAssociatedExpression());
8755 Record.AddDeclRef(M.getAssociatedDeclaration());
8759void OMPClauseWriter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *
C) {
8760 Record.push_back(
C->varlist_size());
8761 Record.push_back(
C->getUniqueDeclarationsNum());
8762 Record.push_back(
C->getTotalComponentListNum());
8763 Record.push_back(
C->getTotalComponentsNum());
8764 Record.AddSourceLocation(
C->getLParenLoc());
8765 for (
auto *E :
C->varlist())
8767 for (
auto *D :
C->all_decls())
8769 for (
auto N :
C->all_num_lists())
8771 for (
auto N :
C->all_lists_sizes())
8773 for (
auto &M :
C->all_components()) {
8774 Record.AddStmt(M.getAssociatedExpression());
8775 Record.AddDeclRef(M.getAssociatedDeclaration());
8779void OMPClauseWriter::VisitOMPHasDeviceAddrClause(OMPHasDeviceAddrClause *
C) {
8780 Record.push_back(
C->varlist_size());
8781 Record.push_back(
C->getUniqueDeclarationsNum());
8782 Record.push_back(
C->getTotalComponentListNum());
8783 Record.push_back(
C->getTotalComponentsNum());
8784 Record.AddSourceLocation(
C->getLParenLoc());
8785 for (
auto *E :
C->varlist())
8787 for (
auto *D :
C->all_decls())
8789 for (
auto N :
C->all_num_lists())
8791 for (
auto N :
C->all_lists_sizes())
8793 for (
auto &M :
C->all_components()) {
8794 Record.AddStmt(M.getAssociatedExpression());
8795 Record.AddDeclRef(M.getAssociatedDeclaration());
8799void OMPClauseWriter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {}
8801void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
8802 OMPUnifiedSharedMemoryClause *) {}
8804void OMPClauseWriter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
8807OMPClauseWriter::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
8810void OMPClauseWriter::VisitOMPAtomicDefaultMemOrderClause(
8811 OMPAtomicDefaultMemOrderClause *
C) {
8812 Record.push_back(
C->getAtomicDefaultMemOrderKind());
8813 Record.AddSourceLocation(
C->getLParenLoc());
8814 Record.AddSourceLocation(
C->getAtomicDefaultMemOrderKindKwLoc());
8817void OMPClauseWriter::VisitOMPSelfMapsClause(OMPSelfMapsClause *) {}
8819void OMPClauseWriter::VisitOMPAtClause(OMPAtClause *
C) {
8820 Record.push_back(
C->getAtKind());
8821 Record.AddSourceLocation(
C->getLParenLoc());
8822 Record.AddSourceLocation(
C->getAtKindKwLoc());
8825void OMPClauseWriter::VisitOMPSeverityClause(OMPSeverityClause *
C) {
8826 Record.push_back(
C->getSeverityKind());
8827 Record.AddSourceLocation(
C->getLParenLoc());
8828 Record.AddSourceLocation(
C->getSeverityKindKwLoc());
8831void OMPClauseWriter::VisitOMPMessageClause(OMPMessageClause *
C) {
8832 VisitOMPClauseWithPreInit(
C);
8833 Record.AddStmt(
C->getMessageString());
8834 Record.AddSourceLocation(
C->getLParenLoc());
8837void OMPClauseWriter::VisitOMPNontemporalClause(OMPNontemporalClause *
C) {
8838 Record.push_back(
C->varlist_size());
8839 Record.AddSourceLocation(
C->getLParenLoc());
8840 for (
auto *
VE :
C->varlist())
8842 for (
auto *E :
C->private_refs())
8846void OMPClauseWriter::VisitOMPInclusiveClause(OMPInclusiveClause *
C) {
8847 Record.push_back(
C->varlist_size());
8848 Record.AddSourceLocation(
C->getLParenLoc());
8849 for (
auto *
VE :
C->varlist())
8853void OMPClauseWriter::VisitOMPExclusiveClause(OMPExclusiveClause *
C) {
8854 Record.push_back(
C->varlist_size());
8855 Record.AddSourceLocation(
C->getLParenLoc());
8856 for (
auto *
VE :
C->varlist())
8860void OMPClauseWriter::VisitOMPOrderClause(OMPOrderClause *
C) {
8861 Record.writeEnum(
C->getKind());
8862 Record.writeEnum(
C->getModifier());
8863 Record.AddSourceLocation(
C->getLParenLoc());
8864 Record.AddSourceLocation(
C->getKindKwLoc());
8865 Record.AddSourceLocation(
C->getModifierKwLoc());
8868void OMPClauseWriter::VisitOMPUsesAllocatorsClause(OMPUsesAllocatorsClause *
C) {
8869 Record.push_back(
C->getNumberOfAllocators());
8870 Record.AddSourceLocation(
C->getLParenLoc());
8871 for (
unsigned I = 0, E =
C->getNumberOfAllocators(); I < E; ++I) {
8872 OMPUsesAllocatorsClause::Data
Data =
C->getAllocatorData(I);
8880void OMPClauseWriter::VisitOMPAffinityClause(OMPAffinityClause *
C) {
8881 Record.push_back(
C->varlist_size());
8882 Record.AddSourceLocation(
C->getLParenLoc());
8883 Record.AddStmt(
C->getModifier());
8884 Record.AddSourceLocation(
C->getColonLoc());
8885 for (
Expr *E :
C->varlist())
8889void OMPClauseWriter::VisitOMPBindClause(OMPBindClause *
C) {
8890 Record.writeEnum(
C->getBindKind());
8891 Record.AddSourceLocation(
C->getLParenLoc());
8892 Record.AddSourceLocation(
C->getBindKindLoc());
8895void OMPClauseWriter::VisitOMPXDynCGroupMemClause(OMPXDynCGroupMemClause *
C) {
8896 VisitOMPClauseWithPreInit(
C);
8898 Record.AddSourceLocation(
C->getLParenLoc());
8901void OMPClauseWriter::VisitOMPDynGroupprivateClause(
8902 OMPDynGroupprivateClause *
C) {
8903 VisitOMPClauseWithPreInit(
C);
8904 Record.push_back(
C->getDynGroupprivateModifier());
8905 Record.push_back(
C->getDynGroupprivateFallbackModifier());
8907 Record.AddSourceLocation(
C->getLParenLoc());
8908 Record.AddSourceLocation(
C->getDynGroupprivateModifierLoc());
8909 Record.AddSourceLocation(
C->getDynGroupprivateFallbackModifierLoc());
8912void OMPClauseWriter::VisitOMPDoacrossClause(OMPDoacrossClause *
C) {
8913 Record.push_back(
C->varlist_size());
8914 Record.push_back(
C->getNumLoops());
8915 Record.AddSourceLocation(
C->getLParenLoc());
8916 Record.push_back(
C->getDependenceType());
8917 Record.AddSourceLocation(
C->getDependenceLoc());
8918 Record.AddSourceLocation(
C->getColonLoc());
8919 for (
auto *
VE :
C->varlist())
8921 for (
unsigned I = 0, E =
C->getNumLoops(); I < E; ++I)
8922 Record.AddStmt(
C->getLoopData(I));
8925void OMPClauseWriter::VisitOMPXAttributeClause(OMPXAttributeClause *
C) {
8926 Record.AddAttributes(
C->getAttrs());
8927 Record.AddSourceLocation(
C->getBeginLoc());
8928 Record.AddSourceLocation(
C->getLParenLoc());
8929 Record.AddSourceLocation(
C->getEndLoc());
8932void OMPClauseWriter::VisitOMPXBareClause(OMPXBareClause *
C) {}
8936 for (
const auto &
Set : TI->
Sets) {
8943 writeExprRef(
Selector.ScoreOrCondition);
8957 for (
unsigned I = 0, E =
Data->getNumClauses(); I < E; ++I)
8959 if (
Data->hasAssociatedStmt())
8961 for (
unsigned I = 0, E =
Data->getNumChildren(); I < E; ++I)
8967 for (
Expr *E :
C->getVarList())
8973 for (
Expr *E : Exprs)
8982 switch (
C->getClauseKind()) {
8992 AddStmt(
const_cast<Expr*
>(IC->getConditionExpr()));
8999 if (SC->isConditionExprClause()) {
9001 if (SC->hasConditionExpr())
9002 AddStmt(
const_cast<Expr *
>(SC->getConditionExpr()));
9005 for (
Expr *E : SC->getVarList())
9014 for (
Expr *E : NGC->getIntExprs())
9048 static_assert(
sizeof(R) == 1 *
sizeof(
int *));
9071 static_assert(
sizeof(R) == 2 *
sizeof(
int *));
9159 if (AC->hasIntExpr())
9167 if (
Expr *DNE = WC->getDevNumExpr())
9181 if (Arg.getIdentifierInfo())
9200 for (
auto &CombinerRecipe : R.CombinerRecipes) {
9228 for (
Expr *E : TC->getSizeExprs())
9236 for (
unsigned I = 0; I < GC->getNumExprs(); ++I) {
9238 AddStmt(
const_cast<Expr *
>(GC->getExpr(I).second));
9246 if (WC->hasIntExpr())
9254 if (VC->hasIntExpr())
9275 if (BC->isStringArgument())
9284 llvm_unreachable(
"Clause serialization not yet implemented");
9286 llvm_unreachable(
"Invalid Clause Kind");
9295 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 const char * adjustFilenameForRelocatableAST(const 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 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 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....
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.
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 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.
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
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
TemplateDecl * 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
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...
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.
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 '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.
bool hasLocalNonFastQualifiers() const
Determine whether this particular QualType instance has any "non-fast" qualifiers,...
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
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".
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.
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
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.
IdentifierResolver IdResolver
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.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
DiagnosticsEngine & getDiagnostics() const
SourceLocation::UIntTy getNextLocalOffset() const
OptionalFileEntryRef getFileEntryRefForID(FileID FID) const
Returns the FileEntryRef for the provided FileID.
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.
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
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.
bool hasInitWithSideEffects() const
Checks whether this declaration has an initializer with side effects.
EvaluatedStmt * getEvaluatedStmt() const
const Expr * getInit() const
APValue * getEvaluatedValue() const
Return the already-evaluated value of this variable's initializer, or NULL if the value is not yet kn...
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.
@ 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_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.
@ 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.
The JSON file list parser is used to communicate input to InstallAPI.
@ 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.
@ Property
The type of a property.
OptionalUnsigned< unsigned > UnsignedOrNone
@ Type
The name was classified as a type.
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)
@ None
The alignment was not explicit in code.
@ 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...
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 uint16_t
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 uint32_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