83#include "llvm/ADT/APFloat.h"
84#include "llvm/ADT/APInt.h"
85#include "llvm/ADT/ArrayRef.h"
86#include "llvm/ADT/DenseMap.h"
87#include "llvm/ADT/DenseSet.h"
88#include "llvm/ADT/PointerIntPair.h"
89#include "llvm/ADT/STLExtras.h"
90#include "llvm/ADT/ScopeExit.h"
91#include "llvm/ADT/SmallPtrSet.h"
92#include "llvm/ADT/SmallString.h"
93#include "llvm/ADT/SmallVector.h"
94#include "llvm/ADT/StringRef.h"
95#include "llvm/Bitstream/BitCodes.h"
96#include "llvm/Bitstream/BitstreamWriter.h"
97#include "llvm/Support/Compression.h"
98#include "llvm/Support/DJB.h"
99#include "llvm/Support/EndianStream.h"
100#include "llvm/Support/ErrorHandling.h"
101#include "llvm/Support/LEB128.h"
102#include "llvm/Support/MemoryBuffer.h"
103#include "llvm/Support/OnDiskHashTable.h"
104#include "llvm/Support/Path.h"
105#include "llvm/Support/SHA1.h"
106#include "llvm/Support/TimeProfiler.h"
107#include "llvm/Support/VersionTuple.h"
108#include "llvm/Support/VirtualFileSystem.h"
109#include "llvm/Support/raw_ostream.h"
124using namespace clang;
127template <
typename T,
typename Allocator>
128static StringRef
bytes(
const std::vector<T, Allocator> &v) {
129 if (v.empty())
return StringRef();
130 return StringRef(
reinterpret_cast<const char*
>(&v[0]),
131 sizeof(
T) * v.size());
136 return StringRef(
reinterpret_cast<const char*
>(v.data()),
137 sizeof(
T) * v.size());
140static std::string
bytes(
const std::vector<bool> &
V) {
142 Str.reserve(
V.size() / 8);
143 for (
unsigned I = 0, E =
V.size(); I < E;) {
145 for (
unsigned Bit = 0; Bit < 8 && I < E; ++Bit, ++I)
158#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
159 case Type::CLASS_ID: return TYPE_##CODE_ID;
160#include "clang/Serialization/TypeBitCodes.def"
161 case Type::LateParsedAttr:
163 "should be replaced with a concrete type before serialization");
165 llvm_unreachable(
"shouldn't be serializing a builtin type this way");
167 llvm_unreachable(
"bad type kind");
172struct AffectingModuleMaps {
173 llvm::DenseSet<FileID> DefinitionFileIDs;
174 llvm::DenseSet<const FileEntry *> DefinitionFiles;
177std::optional<AffectingModuleMaps>
190 enum AffectedReason :
bool {
191 AR_TextualHeader = 0,
192 AR_ImportOrTextualHeader = 1,
194 auto AssignMostImportant = [](AffectedReason &LHS, AffectedReason RHS) {
195 LHS = std::max(LHS, RHS);
197 llvm::DenseMap<FileID, AffectedReason> ModuleMaps;
198 llvm::DenseMap<const Module *, AffectedReason> ProcessedModules;
199 auto CollectModuleMapsForHierarchy = [&](
const Module *M,
200 AffectedReason Reason) {
206 if (
auto [It, Inserted] = ProcessedModules.insert({M, Reason});
207 !Inserted && Reason <= It->second) {
213 std::queue<const Module *> Q;
216 const Module *Mod = Q.front();
222 AssignMostImportant(ModuleMaps[F], Reason);
227 AssignMostImportant(ModuleMaps[UniqF], Reason);
236 CollectModuleMapsForHierarchy(RootModule, AR_ImportOrTextualHeader);
238 std::queue<const Module *> Q;
241 const Module *CurrentModule = Q.front();
245 CollectModuleMapsForHierarchy(ImportedModule, AR_ImportOrTextualHeader);
247 CollectModuleMapsForHierarchy(UndeclaredModule, AR_ImportOrTextualHeader);
262 if (
const Module *M = KH.getModule())
263 CollectModuleMapsForHierarchy(M, AR_TextualHeader);
284 llvm::DenseSet<const FileEntry *> ModuleFileEntries;
285 llvm::DenseSet<FileID> ModuleFileIDs;
286 for (
auto [FID, Reason] : ModuleMaps) {
287 if (Reason == AR_ImportOrTextualHeader)
288 ModuleFileIDs.insert(FID);
290 ModuleFileEntries.insert(FE);
293 AffectingModuleMaps
R;
294 R.DefinitionFileIDs = std::move(ModuleFileIDs);
295 R.DefinitionFiles = std::move(ModuleFileEntries);
302 ASTRecordWriter BasicWriter;
305 ASTTypeWriter(ASTContext &Context, ASTWriter &Writer)
306 : Writer(Writer), BasicWriter(Context, Writer, Record) {}
309 if (
T.hasLocalNonFastQualifiers()) {
310 Qualifiers Qs =
T.getLocalQualifiers();
311 BasicWriter.writeQualType(
T.getLocalUnqualifiedType());
312 BasicWriter.writeQualifiers(Qs);
313 return BasicWriter.Emit(
TYPE_EXT_QUAL, Writer.getTypeExtQualAbbrev());
316 const Type *typePtr =
T.getTypePtr();
317 serialization::AbstractTypeWriter<ASTRecordWriter> atw(BasicWriter);
325 ASTRecordWriter &Record;
327 void addSourceLocation(SourceLocation Loc) { Record.AddSourceLocation(Loc); }
328 void addSourceRange(SourceRange Range) { Record.AddSourceRange(Range); }
331 TypeLocWriter(ASTRecordWriter &Record) : Record(Record) {}
333#define ABSTRACT_TYPELOC(CLASS, PARENT)
334#define TYPELOC(CLASS, PARENT) \
335 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
336#include "clang/AST/TypeLocNodes.def"
349void TypeLocWriter::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
359void TypeLocWriter::VisitComplexTypeLoc(ComplexTypeLoc TL) {
363void TypeLocWriter::VisitPointerTypeLoc(PointerTypeLoc TL) {
367void TypeLocWriter::VisitDecayedTypeLoc(DecayedTypeLoc TL) {
371void TypeLocWriter::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
375void TypeLocWriter::VisitArrayParameterTypeLoc(ArrayParameterTypeLoc TL) {
379void TypeLocWriter::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
383void TypeLocWriter::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
387void TypeLocWriter::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
391void TypeLocWriter::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
396void TypeLocWriter::VisitArrayTypeLoc(ArrayTypeLoc TL) {
404void TypeLocWriter::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) {
405 VisitArrayTypeLoc(TL);
408void TypeLocWriter::VisitIncompleteArrayTypeLoc(IncompleteArrayTypeLoc TL) {
409 VisitArrayTypeLoc(TL);
412void TypeLocWriter::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
413 VisitArrayTypeLoc(TL);
416void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
417 DependentSizedArrayTypeLoc TL) {
418 VisitArrayTypeLoc(TL);
421void TypeLocWriter::VisitDependentAddressSpaceTypeLoc(
422 DependentAddressSpaceTypeLoc TL) {
425 addSourceLocation(
range.getBegin());
426 addSourceLocation(
range.getEnd());
430void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
431 DependentSizedExtVectorTypeLoc TL) {
435void TypeLocWriter::VisitVectorTypeLoc(VectorTypeLoc TL) {
439void TypeLocWriter::VisitDependentVectorTypeLoc(
440 DependentVectorTypeLoc TL) {
444void TypeLocWriter::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
448void TypeLocWriter::VisitConstantMatrixTypeLoc(ConstantMatrixTypeLoc TL) {
451 addSourceLocation(
range.getBegin());
452 addSourceLocation(
range.getEnd());
457void TypeLocWriter::VisitDependentSizedMatrixTypeLoc(
458 DependentSizedMatrixTypeLoc TL) {
461 addSourceLocation(
range.getBegin());
462 addSourceLocation(
range.getEnd());
467void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
473 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i)
477void TypeLocWriter::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {
478 VisitFunctionTypeLoc(TL);
481void TypeLocWriter::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) {
482 VisitFunctionTypeLoc(TL);
485void TypeLocWriter::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
491void TypeLocWriter::VisitUsingTypeLoc(UsingTypeLoc TL) {
497void TypeLocWriter::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
503void TypeLocWriter::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
512void TypeLocWriter::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
518void TypeLocWriter::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
525void TypeLocWriter::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
530void TypeLocWriter::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
553void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
558 Record.AddConceptReference(CR);
564void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
565 DeducedTemplateSpecializationTypeLoc TL) {
571void TypeLocWriter::VisitTagTypeLoc(TagTypeLoc TL) {
577void TypeLocWriter::VisitRecordTypeLoc(RecordTypeLoc TL) {
581void TypeLocWriter::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
585void TypeLocWriter::VisitEnumTypeLoc(EnumTypeLoc TL) { VisitTagTypeLoc(TL); }
587void TypeLocWriter::VisitAttributedTypeLoc(AttributedTypeLoc TL) {
591void TypeLocWriter::VisitCountAttributedTypeLoc(CountAttributedTypeLoc TL) {
595void TypeLocWriter::VisitLateParsedAttrTypeLoc(LateParsedAttrTypeLoc TL) {
597 "should be replaced with a concrete type before serialization");
600void TypeLocWriter::VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
604void TypeLocWriter::VisitOverflowBehaviorTypeLoc(OverflowBehaviorTypeLoc TL) {
608void TypeLocWriter::VisitHLSLAttributedResourceTypeLoc(
609 HLSLAttributedResourceTypeLoc TL) {
613void TypeLocWriter::VisitHLSLInlineSpirvTypeLoc(HLSLInlineSpirvTypeLoc TL) {
617void TypeLocWriter::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
621void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
622 SubstTemplateTypeParmTypeLoc TL) {
626void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
627 SubstTemplateTypeParmPackTypeLoc TL) {
631void TypeLocWriter::VisitSubstBuiltinTemplatePackTypeLoc(
632 SubstBuiltinTemplatePackTypeLoc TL) {
636void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
637 TemplateSpecializationTypeLoc TL) {
644 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
648void TypeLocWriter::VisitParenTypeLoc(ParenTypeLoc TL) {
653void TypeLocWriter::VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
657void TypeLocWriter::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
663void TypeLocWriter::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) {
667void TypeLocWriter::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
672void TypeLocWriter::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
684void TypeLocWriter::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
688void TypeLocWriter::VisitAtomicTypeLoc(AtomicTypeLoc TL) {
694void TypeLocWriter::VisitPipeTypeLoc(PipeTypeLoc TL) {
697void TypeLocWriter::VisitBitIntTypeLoc(clang::BitIntTypeLoc TL) {
700void TypeLocWriter::VisitDependentBitIntTypeLoc(
701 clang::DependentBitIntTypeLoc TL) {
705void TypeLocWriter::VisitPredefinedSugarTypeLoc(
706 clang::PredefinedSugarTypeLoc TL) {
710void ASTWriter::WriteTypeAbbrevs() {
711 using namespace llvm;
713 std::shared_ptr<BitCodeAbbrev> Abv;
716 Abv = std::make_shared<BitCodeAbbrev>();
718 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
719 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
720 TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
728 llvm::BitstreamWriter &Stream,
732 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID,
Record);
735 if (!Name || Name[0] == 0)
739 Record.push_back(*Name++);
740 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME,
Record);
744 llvm::BitstreamWriter &Stream,
749 Record.push_back(*Name++);
750 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME,
Record);
755#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
888void ASTWriter::WriteBlockInfoBlock() {
890 Stream.EnterBlockInfoBlock();
892#define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
893#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
896 BLOCK(CONTROL_BLOCK);
906 BLOCK(OPTIONS_BLOCK);
914 BLOCK(INPUT_FILES_BLOCK);
982 BLOCK(SOURCE_MANAGER_BLOCK);
990 BLOCK(PREPROCESSOR_BLOCK);
998 BLOCK(SUBMODULE_BLOCK);
1021 BLOCK(COMMENTS_BLOCK);
1025 BLOCK(DECLTYPES_BLOCK);
1029 RECORD(TYPE_BLOCK_POINTER);
1030 RECORD(TYPE_LVALUE_REFERENCE);
1031 RECORD(TYPE_RVALUE_REFERENCE);
1032 RECORD(TYPE_MEMBER_POINTER);
1033 RECORD(TYPE_CONSTANT_ARRAY);
1034 RECORD(TYPE_INCOMPLETE_ARRAY);
1035 RECORD(TYPE_VARIABLE_ARRAY);
1038 RECORD(TYPE_FUNCTION_NO_PROTO);
1039 RECORD(TYPE_FUNCTION_PROTO);
1041 RECORD(TYPE_TYPEOF_EXPR);
1045 RECORD(TYPE_OBJC_INTERFACE);
1046 RECORD(TYPE_OBJC_OBJECT_POINTER);
1048 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM);
1049 RECORD(TYPE_UNRESOLVED_USING);
1050 RECORD(TYPE_INJECTED_CLASS_NAME);
1051 RECORD(TYPE_OBJC_OBJECT);
1052 RECORD(TYPE_TEMPLATE_TYPE_PARM);
1053 RECORD(TYPE_TEMPLATE_SPECIALIZATION);
1054 RECORD(TYPE_DEPENDENT_NAME);
1055 RECORD(TYPE_DEPENDENT_SIZED_ARRAY);
1057 RECORD(TYPE_MACRO_QUALIFIED);
1058 RECORD(TYPE_PACK_EXPANSION);
1060 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK);
1061 RECORD(TYPE_SUBST_BUILTIN_TEMPLATE_PACK);
1063 RECORD(TYPE_UNARY_TRANSFORM);
1067 RECORD(TYPE_OBJC_TYPE_PARAM);
1148 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
1154 BLOCK(EXTENSION_BLOCK);
1157 BLOCK(UNHASHED_CONTROL_BLOCK);
1183 assert(Filename &&
"No file name to adjust?");
1185 if (BaseDir.empty())
1190 for (; Filename[Pos] && Pos < BaseDir.size(); ++Pos)
1191 if (Filename[Pos] != BaseDir[Pos])
1200 if (!llvm::sys::path::is_separator(Filename[Pos])) {
1201 if (!llvm::sys::path::is_separator(BaseDir.back()))
1215 return Filename + Pos;
1218std::pair<ASTFileSignature, ASTFileSignature>
1219ASTWriter::createSignature()
const {
1220 StringRef AllBytes(Buffer.data(), Buffer.size());
1223 Hasher.update(AllBytes.slice(ASTBlockRange.first, ASTBlockRange.second));
1228 Hasher.update(AllBytes.slice(0, UnhashedControlBlockRange.first));
1231 AllBytes.slice(UnhashedControlBlockRange.second, ASTBlockRange.first));
1233 Hasher.update(AllBytes.substr(ASTBlockRange.second));
1236 return std::make_pair(ASTBlockHash, Signature);
1239ASTFileSignature ASTWriter::createSignatureForNamedModule()
const {
1241 Hasher.update(StringRef(Buffer.data(), Buffer.size()));
1243 assert(WritingModule);
1244 assert(WritingModule->isNamedModule());
1248 for (
auto [ExportImported, _] : WritingModule->Exports)
1249 Hasher.update(ExportImported->Signature);
1273 for (
Module *M : TouchedTopLevelModules)
1282 Stream.BackpatchByte(BitNo, Byte);
1287ASTFileSignature ASTWriter::backpatchSignature() {
1288 if (isWritingStdCXXNamedModules()) {
1289 ASTFileSignature Signature = createSignatureForNamedModule();
1294 if (!WritingModule ||
1299 ASTFileSignature ASTBlockHash;
1300 ASTFileSignature Signature;
1301 std::tie(ASTBlockHash, Signature) = createSignature();
1309void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP) {
1310 using namespace llvm;
1313 Stream.FlushToWord();
1314 UnhashedControlBlockRange.first = Stream.GetCurrentBitNo() >> 3;
1322 if (isWritingStdCXXNamedModules() ||
1333 SmallString<128> Blob{Dummy.begin(), Dummy.end()};
1336 if (!isWritingStdCXXNamedModules()) {
1337 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1339 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1340 unsigned ASTBlockHashAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1343 Stream.EmitRecordWithBlob(ASTBlockHashAbbrev,
Record, Blob);
1344 ASTBlockHashOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1348 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1349 Abbrev->Add(BitCodeAbbrevOp(
SIGNATURE));
1350 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1351 unsigned SignatureAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1354 Stream.EmitRecordWithBlob(SignatureAbbrev,
Record, Blob);
1355 SignatureOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1364 if (!HSOpts.ModulesSkipDiagnosticOptions) {
1365#define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name);
1366#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
1367 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name()));
1368#include "clang/Basic/DiagnosticOptions.def"
1370 for (
unsigned I = 0, N = DiagOpts.
Warnings.size(); I != N; ++I)
1373 for (
unsigned I = 0, N = DiagOpts.
Remarks.size(); I != N; ++I)
1382 if (!HSOpts.ModulesSkipHeaderSearchPaths) {
1384 Record.push_back(HSOpts.UserEntries.size());
1385 for (
unsigned I = 0, N = HSOpts.UserEntries.size(); I != N; ++I) {
1386 const HeaderSearchOptions::Entry &Entry = HSOpts.UserEntries[I];
1388 Record.push_back(
static_cast<unsigned>(Entry.
Group));
1394 Record.push_back(HSOpts.SystemHeaderPrefixes.size());
1395 for (
unsigned I = 0, N = HSOpts.SystemHeaderPrefixes.size(); I != N; ++I) {
1396 AddString(HSOpts.SystemHeaderPrefixes[I].Prefix,
Record);
1397 Record.push_back(HSOpts.SystemHeaderPrefixes[I].IsSystemHeader);
1401 Record.push_back(HSOpts.VFSOverlayFiles.size());
1402 for (StringRef VFSOverlayFile : HSOpts.VFSOverlayFiles)
1403 AddString(VFSOverlayFile,
Record);
1408 if (!HSOpts.ModulesSkipPragmaDiagnosticMappings)
1409 WritePragmaDiagnosticMappings(Diags, WritingModule);
1414 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1416 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1417 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1418 unsigned HSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1420 HSEntryUsage.size()};
1421 Stream.EmitRecordWithBlob(HSUsageAbbrevCode,
Record,
bytes(HSEntryUsage));
1427 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1428 Abbrev->Add(BitCodeAbbrevOp(
VFS_USAGE));
1429 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1430 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1431 unsigned VFSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1433 Stream.EmitRecordWithBlob(VFSUsageAbbrevCode,
Record,
bytes(VFSUsage));
1438 UnhashedControlBlockRange.second = Stream.GetCurrentBitNo() >> 3;
1442void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
1443 using namespace llvm;
1452 auto MetadataAbbrev = std::make_shared<BitCodeAbbrev>();
1453 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1454 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1455 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1456 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1457 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1458 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1460 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1461 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1462 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1463 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1464 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev));
1465 assert((!WritingModule || isysroot.empty()) &&
1466 "writing module as a relocatable PCH?");
1471 CLANG_VERSION_MAJOR,
1472 CLANG_VERSION_MINOR,
1474 isWritingStdCXXNamedModules(),
1476 ASTHasCompilerErrors};
1477 Stream.EmitRecordWithBlob(MetadataAbbrevCode,
Record,
1481 if (WritingModule) {
1483 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1485 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1486 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1488 Stream.EmitRecordWithBlob(AbbrevCode,
Record, WritingModule->Name);
1490 auto BaseDir = [&]() -> std::optional<SmallString<128>> {
1496 if (WritingModule->Directory) {
1497 return WritingModule->Directory->getName();
1499 return std::nullopt;
1511 WritingModule->Directory->getName() !=
".")) {
1513 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1515 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1516 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1519 Stream.EmitRecordWithBlob(AbbrevCode,
Record, *BaseDir);
1523 BaseDirectory.assign(BaseDir->begin(), BaseDir->end());
1525 }
else if (!isysroot.empty()) {
1527 SmallString<128> CleanedSysroot(isysroot);
1529 BaseDirectory.assign(CleanedSysroot.begin(), CleanedSysroot.end());
1533 if (WritingModule && WritingModule->Kind == Module::ModuleMapModule) {
1537 AddPath(WritingModule->PresumedModuleMapFile.empty()
1538 ? Map.getModuleMapFileForUniquing(WritingModule)
1539 ->getNameAsRequested()
1540 : StringRef(WritingModule->PresumedModuleMapFile),
1544 if (
auto *AdditionalModMaps =
1545 Map.getAdditionalModuleMapFiles(WritingModule)) {
1546 Record.push_back(AdditionalModMaps->size());
1547 SmallVector<FileEntryRef, 1> ModMaps(AdditionalModMaps->begin(),
1548 AdditionalModMaps->end());
1549 llvm::sort(ModMaps, [](FileEntryRef A, FileEntryRef B) {
1552 for (FileEntryRef F : ModMaps)
1553 AddPath(F.getName(),
Record);
1563 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1564 Abbrev->Add(BitCodeAbbrevOp(
IMPORT));
1565 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1566 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1567 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1568 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1569 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1570 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1571 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1572 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1573 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1574 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1576 SmallString<128> Blob;
1578 for (ModuleFile &M : Chain->getModuleManager()) {
1580 if (!M.isDirectlyImported())
1588 AddSourceLocation(M.ImportLoc,
Record);
1589 AddStringBlob(M.ModuleName,
Record, Blob);
1590 Record.push_back(M.StandardCXXModule);
1594 if (M.StandardCXXModule) {
1605 Record.push_back(M.FileName.getRawKind());
1609 AddPathBlob(M.FileName,
Record, Blob);
1612 Stream.EmitRecordWithBlob(AbbrevCode,
Record, Blob);
1623 const uint64_t LanguageOptionValues[] = {
1624#define LANGOPT(Name, Bits, Default, Compatibility, Description) LangOpts.Name,
1625#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
1626 static_cast<unsigned>(LangOpts.get##Name()),
1627#include "clang/Basic/LangOptions.def"
1628#define SANITIZER(NAME, ID) LangOpts.Sanitize.has(SanitizerKind::ID),
1629#include "clang/Basic/Sanitizers.def"
1631 llvm::append_range(
Record, LanguageOptionValues);
1652 AddString(
T.getTriple(),
Record);
1660 using CK = CodeGenOptions::CompatibilityKind;
1662 const CodeGenOptions &CGOpts = getCodeGenOpts();
1663#define CODEGENOPT(Name, Bits, Default, Compatibility) \
1664 if constexpr (CK::Compatibility != CK::Benign) \
1665 Record.push_back(static_cast<unsigned>(CGOpts.Name));
1666#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility) \
1667 if constexpr (CK::Compatibility != CK::Benign) \
1668 Record.push_back(static_cast<unsigned>(CGOpts.get##Name()));
1669#define DEBUGOPT(Name, Bits, Default, Compatibility)
1670#define VALUE_DEBUGOPT(Name, Bits, Default, Compatibility)
1671#define ENUM_DEBUGOPT(Name, Type, Bits, Default, Compatibility)
1672#include "clang/Basic/CodeGenOptions.def"
1688 for (
unsigned I = 0, N = TargetOpts.
Features.size(); I != N; ++I) {
1701 const HeaderSearchOptions &HSOpts =
1704 StringRef HSOpts_ModuleCachePath =
1709 AddString(HSOpts_ModuleCachePath,
Record);
1730 bool WriteMacros = !SkipMacros;
1731 Record.push_back(WriteMacros);
1735 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
1743 for (
unsigned I = 0, N = PPOpts.
Includes.size(); I != N; ++I)
1748 for (
unsigned I = 0, N = PPOpts.
MacroIncludes.size(); I != N; ++I)
1769 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1771 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1772 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1773 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
1778 EmitRecordWithPath(FileAbbrevCode,
Record, MainFile->getName());
1785 WriteInputFiles(SourceMgr);
1792struct InputFileEntry {
1796 bool BufferOverridden;
1803 void trySetContentHash(
1805 llvm::function_ref<std::optional<llvm::MemoryBufferRef>()> GetMemBuff) {
1814 auto MemBuff = GetMemBuff();
1816 PP.
Diag(SourceLocation(), diag::err_module_unable_to_hash_content)
1821 uint64_t Hash = xxh3_64bits(MemBuff->getBuffer());
1823 ContentHash[1] =
uint32_t(Hash >> 32);
1829SourceLocation ASTWriter::getAffectingIncludeLoc(
const SourceManager &SourceMgr,
1830 const SrcMgr::FileInfo &
File) {
1831 SourceLocation IncludeLoc =
File.getIncludeLoc();
1833 FileID IncludeFID = SourceMgr.
getFileID(IncludeLoc);
1834 assert(IncludeFID.
isValid() &&
"IncludeLoc in invalid file");
1835 if (!IsSLocAffecting[IncludeFID.ID])
1836 IncludeLoc = SourceLocation();
1841void ASTWriter::WriteInputFiles(SourceManager &SourceMgr) {
1842 using namespace llvm;
1847 auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
1849 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1850 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1851 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1852 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1853 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1854 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1855 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1856 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
1857 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1858 unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
1861 auto IFHAbbrev = std::make_shared<BitCodeAbbrev>();
1863 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1864 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1865 unsigned IFHAbbrevCode = Stream.EmitAbbrev(std::move(IFHAbbrev));
1867 uint64_t InputFilesOffsetBase = Stream.GetCurrentBitNo();
1871 std::vector<InputFileEntry> SystemFiles;
1875 assert(&SourceMgr.
getSLocEntry(FileID::get(I)) == SLoc);
1882 if (!
Cache->OrigEntry)
1886 if (!IsSLocFileEntryAffecting[I])
1889 InputFileEntry Entry(*
Cache->OrigEntry);
1890 Entry.IsSystemFile =
isSystem(
File.getFileCharacteristic());
1891 Entry.IsTransient =
Cache->IsTransient;
1892 Entry.BufferOverridden =
Cache->BufferOverridden;
1894 FileID IncludeFileID = SourceMgr.
getFileID(
File.getIncludeLoc());
1895 Entry.IsTopLevel = IncludeFileID.
isInvalid() || IncludeFileID.ID < 0 ||
1896 !IsSLocFileEntryAffecting[IncludeFileID.ID];
1899 Entry.trySetContentHash(*PP, [&] {
return Cache->getBufferIfLoaded(); });
1901 if (Entry.IsSystemFile)
1902 SystemFiles.push_back(Entry);
1911 if (!Sysroot.empty()) {
1912 SmallString<128> SDKSettingsJSON = Sysroot;
1913 llvm::sys::path::append(SDKSettingsJSON,
"SDKSettings.json");
1916 InputFileEntry Entry(*FE);
1917 Entry.IsSystemFile =
true;
1918 Entry.IsTransient =
false;
1919 Entry.BufferOverridden =
false;
1920 Entry.IsTopLevel =
true;
1921 Entry.IsModuleMap =
false;
1922 std::unique_ptr<MemoryBuffer> MB;
1923 Entry.trySetContentHash(*PP, [&]() -> std::optional<MemoryBufferRef> {
1925 MB = std::move(*MBOrErr);
1926 return MB->getMemBufferRef();
1928 return std::nullopt;
1930 SystemFiles.push_back(Entry);
1935 auto SortedFiles = llvm::concat<InputFileEntry>(std::move(
UserFiles),
1936 std::move(SystemFiles));
1938 unsigned UserFilesNum = 0;
1940 std::vector<uint64_t> InputFileOffsets;
1941 for (
const auto &Entry : SortedFiles) {
1942 uint32_t &InputFileID = InputFileIDs[Entry.File];
1943 if (InputFileID != 0)
1947 InputFileOffsets.push_back(Stream.GetCurrentBitNo() - InputFilesOffsetBase);
1949 InputFileID = InputFileOffsets.size();
1951 if (!Entry.IsSystemFile)
1957 SmallString<128> NameAsRequested = Entry.File.getNameAsRequested();
1958 SmallString<128> Name = Entry.File.getName();
1960 PreparePathForOutput(NameAsRequested);
1961 PreparePathForOutput(Name);
1963 if (Name == NameAsRequested)
1966 RecordData::value_type
Record[] = {
1968 InputFileOffsets.size(),
1970 (
uint64_t)getTimestampForOutput(Entry.File.getModificationTime()),
1971 Entry.BufferOverridden,
1975 NameAsRequested.size()};
1977 Stream.EmitRecordWithBlob(IFAbbrevCode,
Record,
1978 (NameAsRequested + Name).str());
1984 Entry.ContentHash[1]};
1985 Stream.EmitRecordWithAbbrev(IFHAbbrevCode,
Record);
1992 auto OffsetsAbbrev = std::make_shared<BitCodeAbbrev>();
1994 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1995 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1997 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1998 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(std::move(OffsetsAbbrev));
2002 InputFileOffsets.size(), UserFilesNum};
2003 Stream.EmitRecordWithBlob(OffsetsAbbrevCode,
Record,
bytes(InputFileOffsets));
2013 using namespace llvm;
2015 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2017 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2018 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2019 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
2020 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2022 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2023 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2024 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
2025 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2026 return Stream.EmitAbbrev(std::move(Abbrev));
2032 using namespace llvm;
2034 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2036 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2037 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2038 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
2039 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2040 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2041 return Stream.EmitAbbrev(std::move(Abbrev));
2048 using namespace llvm;
2050 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2054 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2055 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2056 return Stream.EmitAbbrev(std::move(Abbrev));
2062 using namespace llvm;
2064 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2066 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2067 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2068 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2069 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2070 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2071 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2072 return Stream.EmitAbbrev(std::move(Abbrev));
2077static std::pair<unsigned, unsigned>
2079 llvm::encodeULEB128(KeyLen, Out);
2080 llvm::encodeULEB128(DataLen, Out);
2081 return std::make_pair(KeyLen, DataLen);
2087 class HeaderFileInfoTrait {
2091 HeaderFileInfoTrait(ASTWriter &Writer) : Writer(Writer) {}
2098 using key_type_ref =
const key_type &;
2100 using UnresolvedModule =
2101 llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
2104 data_type(
const HeaderFileInfo &HFI,
bool AlreadyIncluded,
2105 ArrayRef<ModuleMap::KnownHeader> KnownHeaders,
2107 : HFI(HFI), AlreadyIncluded(AlreadyIncluded),
2111 bool AlreadyIncluded;
2112 SmallVector<ModuleMap::KnownHeader, 1> KnownHeaders;
2115 using data_type_ref =
const data_type &;
2117 using hash_value_type = unsigned;
2118 using offset_type = unsigned;
2124 uint8_t buf[
sizeof(key.Size) +
sizeof(key.ModTime)];
2125 memcpy(buf, &key.Size,
sizeof(key.Size));
2126 memcpy(buf +
sizeof(key.Size), &key.ModTime,
sizeof(key.ModTime));
2127 return llvm::xxh3_64bits(buf);
2130 std::pair<unsigned, unsigned>
2131 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref
Data) {
2132 unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
2134 for (
auto ModInfo :
Data.KnownHeaders)
2137 if (
Data.Unresolved.getPointer())
2142 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
2143 using namespace llvm::support;
2145 endian::Writer
LE(Out, llvm::endianness::little);
2150 Out.write(key.Filename.data(), KeyLen);
2153 void EmitData(raw_ostream &Out, key_type_ref key,
2154 data_type_ref
Data,
unsigned DataLen) {
2155 using namespace llvm::support;
2157 endian::Writer
LE(Out, llvm::endianness::little);
2160 unsigned char Flags = (
Data.AlreadyIncluded << 6)
2161 | (
Data.HFI.isImport << 5)
2163 Data.HFI.isPragmaOnce << 4)
2164 | (
Data.HFI.DirInfo << 1);
2167 if (
Data.HFI.LazyControllingMacro.isID())
2176 assert((
Value >> 3) == ModID &&
"overflow in header module info");
2181 for (
auto ModInfo :
Data.KnownHeaders)
2182 EmitModule(ModInfo.getModule(), ModInfo.getRole());
2183 if (
Data.Unresolved.getPointer())
2184 EmitModule(
Data.Unresolved.getPointer(),
Data.Unresolved.getInt());
2186 assert(
Out.tell() - Start == DataLen &&
"Wrong data length");
2195void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
2196 HeaderFileInfoTrait GeneratorTrait(*
this);
2197 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait>
Generator;
2198 SmallVector<const char *, 4> SavedStrings;
2199 unsigned NumHeaderSearchEntries = 0;
2205 const HeaderFileInfo
Empty;
2206 if (WritingModule) {
2207 llvm::SmallVector<Module *, 16> Worklist(1, WritingModule);
2208 while (!Worklist.empty()) {
2209 Module *M = Worklist.pop_back_val();
2226 if (!U.Size || (!U.ModTime && IncludeTimestamps)) {
2227 PP->
Diag(U.FileNameLoc, diag::err_module_no_size_mtime_for_header)
2228 << WritingModule->getFullModuleName() << U.Size.has_value()
2235 llvm::sys::path::append(Filename, U.FileName);
2236 PreparePathForOutput(Filename);
2238 StringRef FilenameDup = strdup(Filename.c_str());
2239 SavedStrings.push_back(FilenameDup.data());
2241 HeaderFileInfoTrait::key_type Key = {
2242 FilenameDup, *U.Size, IncludeTimestamps ? *U.ModTime : 0};
2243 HeaderFileInfoTrait::data_type
Data = {
2248 ++NumHeaderSearchEntries;
2251 Worklist.append(SubmodulesRange.begin(), SubmodulesRange.end());
2256 [&](FileEntryRef
File,
const HeaderFileInfo &HFI) {
2263 StringRef Filename =
File.getName();
2264 SmallString<128> FilenameTmp(Filename);
2265 if (PreparePathForOutput(FilenameTmp)) {
2268 Filename = StringRef(strdup(FilenameTmp.c_str()));
2269 SavedStrings.push_back(Filename.data());
2274 HeaderFileInfoTrait::key_type Key = {
2275 Filename,
File.getSize(),
2276 getTimestampForOutput(
File.getModificationTime())};
2277 HeaderFileInfoTrait::data_type
Data = {
2283 ++NumHeaderSearchEntries;
2287 SmallString<4096> TableData;
2290 using namespace llvm::support;
2292 llvm::raw_svector_ostream
Out(TableData);
2294 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
2295 BucketOffset =
Generator.Emit(Out, GeneratorTrait);
2299 using namespace llvm;
2301 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2303 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2304 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2305 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2306 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2307 unsigned TableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2311 NumHeaderSearchEntries, TableData.size()};
2312 Stream.EmitRecordWithBlob(TableAbbrev,
Record, TableData);
2315 for (
unsigned I = 0, N = SavedStrings.size(); I != N; ++I)
2316 free(
const_cast<char *
>(SavedStrings[I]));
2319static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
2320 unsigned SLocBufferBlobCompressedAbbrv,
2321 unsigned SLocBufferBlobAbbrv) {
2322 using RecordDataType = ASTWriter::RecordData::value_type;
2327 if (llvm::compression::zstd::isAvailable()) {
2328 llvm::compression::zstd::compress(
2329 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer, 9);
2331 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2332 llvm::toStringRef(CompressedBuffer));
2335 if (llvm::compression::zlib::isAvailable()) {
2336 llvm::compression::zlib::compress(
2337 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer);
2339 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2340 llvm::toStringRef(CompressedBuffer));
2345 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv,
Record, Blob);
2356void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
2361 const uint64_t SourceManagerBlockOffset = Stream.GetCurrentBitNo();
2367 unsigned SLocBufferBlobCompressedAbbrv =
2373 std::vector<uint32_t> SLocEntryOffsets;
2374 uint64_t SLocEntryOffsetsBase = Stream.GetCurrentBitNo();
2380 FileID FID = FileID::get(I);
2384 uint64_t Offset = Stream.GetCurrentBitNo() - SLocEntryOffsetsBase;
2385 assert((Offset >> 32) == 0 &&
"SLocEntry offset too large");
2391 if (
Cache->OrigEntry) {
2404 if (!IsSLocAffecting[I])
2406 SLocEntryOffsets.push_back(Offset);
2409 AddSourceLocation(getAffectingIncludeLoc(SourceMgr,
File),
Record);
2410 Record.push_back(
File.getFileCharacteristic());
2413 bool EmitBlob =
false;
2416 "Writing to AST an overridden file is not supported");
2419 assert(InputFileIDs[*Content->
OrigEntry] != 0 &&
"Missed file entry");
2422 Record.push_back(getAdjustedNumCreatedFIDs(FID));
2424 FileDeclIDsTy::iterator FDI = FileDeclIDs.find(FID);
2425 if (FDI != FileDeclIDs.end()) {
2426 Record.push_back(FDI->second->FirstDeclIndex);
2427 Record.push_back(FDI->second->DeclIDs.size());
2433 Stream.EmitRecordWithAbbrev(SLocFileAbbrv,
Record);
2444 std::optional<llvm::MemoryBufferRef> Buffer = Content->
getBufferOrNone(
2446 StringRef Name = Buffer ? Buffer->getBufferIdentifier() :
"";
2447 Stream.EmitRecordWithBlob(SLocBufferAbbrv,
Record,
2448 StringRef(Name.data(), Name.size() + 1));
2455 std::optional<llvm::MemoryBufferRef> Buffer = Content->
getBufferOrNone(
2458 Buffer = llvm::MemoryBufferRef(
"<<<INVALID BUFFER>>>",
"");
2459 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
2460 emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv,
2461 SLocBufferBlobAbbrv);
2465 const SrcMgr::ExpansionInfo &Expansion = SLoc->
getExpansion();
2466 SLocEntryOffsets.push_back(Offset);
2481 Record.push_back(getAdjustedOffset(NextOffset - SLoc->
getOffset()) - 1);
2482 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv,
Record);
2488 if (SLocEntryOffsets.empty())
2493 using namespace llvm;
2495 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2497 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2498 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2499 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2500 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2501 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2503 RecordData::value_type
Record[] = {
2506 SLocEntryOffsetsBase - SourceManagerBlockOffset};
2507 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev,
Record,
2508 bytes(SLocEntryOffsets));
2519 llvm::DenseMap<int, int> FilenameMap;
2520 FilenameMap[-1] = -1;
2521 for (
const auto &L : LineTable) {
2524 for (
auto &LE : L.second) {
2525 if (FilenameMap.insert(std::make_pair(
LE.FilenameID,
2526 FilenameMap.size() - 1)).second)
2527 AddPath(LineTable.getFilename(
LE.FilenameID),
Record);
2533 for (
const auto &L : LineTable) {
2538 AddFileID(L.first,
Record);
2541 Record.push_back(L.second.size());
2542 for (
const auto &LE : L.second) {
2545 Record.push_back(FilenameMap[
LE.FilenameID]);
2546 Record.push_back((
unsigned)
LE.FileKind);
2547 Record.push_back(
LE.IncludeOffset);
2562 if (MI->isBuiltinMacro())
2578void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2579 uint64_t MacroOffsetsBase = Stream.GetCurrentBitNo();
2583 WritePreprocessorDetail(*PPRec, MacroOffsetsBase);
2586 RecordData ModuleMacroRecord;
2596 SourceLocation AssumeNonNullLoc =
2598 if (AssumeNonNullLoc.
isValid()) {
2600 AddSourceLocation(AssumeNonNullLoc,
Record);
2610 AddSourceLocation(SkipInfo->HashTokenLoc,
Record);
2611 AddSourceLocation(SkipInfo->IfTokenLoc,
Record);
2612 Record.push_back(SkipInfo->FoundNonSkipPortion);
2613 Record.push_back(SkipInfo->FoundElse);
2614 AddSourceLocation(SkipInfo->ElseLoc,
Record);
2619 AddSourceLocation(Cond.IfLoc,
Record);
2620 Record.push_back(Cond.WasSkipping);
2621 Record.push_back(Cond.FoundNonSkip);
2622 Record.push_back(Cond.FoundElse);
2630 AddSourceLocation(S,
Record);
2640 PP.
Diag(SourceLocation(), diag::warn_module_uses_date_time) << IsModule;
2647 SmallVector<const IdentifierInfo *, 128> MacroIdentifiers;
2650 if (!isWritingStdCXXNamedModules())
2652 if (Id.second->hadMacroDefinition() &&
2653 (!Id.second->isFromAST() ||
2654 Id.second->hasChangedSinceDeserialization()))
2655 MacroIdentifiers.push_back(Id.second);
2658 llvm::sort(MacroIdentifiers, llvm::deref<std::less<>>());
2662 for (
const IdentifierInfo *Name : MacroIdentifiers) {
2664 uint64_t StartOffset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2665 assert((StartOffset >> 32) == 0 &&
"Macro identifiers offset too large");
2668 bool EmittedModuleMacros =
false;
2676 if (IsModule && WritingModule->isHeaderUnit()) {
2685 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2686 Record.push_back(getMacroRef(DefMD->getInfo(), Name));
2687 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2688 Record.push_back(VisMD->isPublic());
2690 ModuleMacroRecord.push_back(getSubmoduleID(WritingModule));
2691 AddMacroRef(MD->
getMacroInfo(), Name, ModuleMacroRecord);
2693 ModuleMacroRecord.clear();
2694 EmittedModuleMacros =
true;
2704 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2705 Record.push_back(getMacroRef(DefMD->getInfo(), Name));
2706 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2707 Record.push_back(VisMD->isPublic());
2713 SmallVector<ModuleMacro *, 8> Worklist(Leafs);
2714 llvm::DenseMap<ModuleMacro *, unsigned> Visits;
2715 while (!Worklist.empty()) {
2716 auto *
Macro = Worklist.pop_back_val();
2719 ModuleMacroRecord.push_back(getSubmoduleID(
Macro->getOwningModule()));
2720 AddMacroRef(
Macro->getMacroInfo(), Name, ModuleMacroRecord);
2721 for (
auto *M :
Macro->overrides())
2722 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2725 ModuleMacroRecord.clear();
2728 for (
auto *M :
Macro->overrides())
2729 if (++Visits[M] == M->getNumOverridingMacros())
2730 Worklist.push_back(M);
2732 EmittedModuleMacros =
true;
2735 if (
Record.empty() && !EmittedModuleMacros)
2738 IdentMacroDirectivesOffsetMap[Name] = StartOffset;
2749 std::vector<uint32_t> MacroOffsets;
2751 for (
unsigned I = 0, N = MacroInfosToEmit.size(); I != N; ++I) {
2752 const IdentifierInfo *Name = MacroInfosToEmit[I].Name;
2753 MacroInfo *MI = MacroInfosToEmit[I].MI;
2756 if (ID < FirstMacroID) {
2757 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2762 unsigned Index =
ID - FirstMacroID;
2763 if (Index >= MacroOffsets.size())
2764 MacroOffsets.resize(Index + 1);
2766 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2767 assert((Offset >> 32) == 0 &&
"Macro offset too large");
2768 MacroOffsets[Index] = Offset;
2770 AddIdentifierRef(Name,
Record);
2786 for (
const IdentifierInfo *Param : MI->
params())
2787 AddIdentifierRef(Param,
Record);
2795 Stream.EmitRecord(Code,
Record);
2799 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2814 using namespace llvm;
2816 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2818 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2819 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2820 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2822 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2825 MacroOffsetsBase - ASTBlockStartOffset};
2826 Stream.EmitRecordWithBlob(MacroOffsetAbbrev,
Record,
bytes(MacroOffsets));
2830void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec,
2831 uint64_t MacroOffsetsBase) {
2835 SmallVector<PPEntityOffset, 64> PreprocessedEntityOffsets;
2841 unsigned NumPreprocessingRecords = 0;
2842 using namespace llvm;
2845 unsigned InclusionAbbrev = 0;
2847 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2849 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2850 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2851 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2852 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2853 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2854 InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2858 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2860 for (PreprocessingRecord::iterator E = PPRec.
local_begin(),
2863 (
void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2866 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2867 assert((Offset >> 32) == 0 &&
"Preprocessed entity offset too large");
2868 SourceRange
R = getAdjustedRange((*E)->getSourceRange());
2869 PreprocessedEntityOffsets.emplace_back(
2870 getRawSourceLocationEncoding(
R.getBegin()),
2871 getRawSourceLocationEncoding(
R.getEnd()), Offset);
2873 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*E)) {
2875 MacroDefinitions[MD] = NextPreprocessorEntityID;
2877 AddIdentifierRef(MD->getName(),
Record);
2882 if (
auto *ME = dyn_cast<MacroExpansion>(*E)) {
2883 Record.push_back(ME->isBuiltinMacro());
2884 if (ME->isBuiltinMacro())
2885 AddIdentifierRef(ME->getName(),
Record);
2887 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2892 if (
auto *ID = dyn_cast<InclusionDirective>(*E)) {
2894 Record.push_back(
ID->getFileName().size());
2895 Record.push_back(
ID->wasInQuotes());
2896 Record.push_back(
static_cast<unsigned>(
ID->getKind()));
2897 Record.push_back(
ID->importedModule());
2898 SmallString<64> Buffer;
2899 Buffer +=
ID->getFileName();
2903 Buffer +=
ID->getFile()->getName();
2904 Stream.EmitRecordWithBlob(InclusionAbbrev,
Record, Buffer);
2908 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2913 if (NumPreprocessingRecords > 0) {
2914 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2917 using namespace llvm;
2919 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2921 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2922 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2925 Stream.EmitRecordWithBlob(PPEOffsetAbbrev,
Record,
2926 bytes(PreprocessedEntityOffsets));
2931 if (SkippedRanges.size() > 0) {
2932 std::vector<PPSkippedRange> SerializedSkippedRanges;
2933 SerializedSkippedRanges.reserve(SkippedRanges.size());
2934 for (
auto const& Range : SkippedRanges)
2935 SerializedSkippedRanges.emplace_back(
2936 getRawSourceLocationEncoding(
Range.getBegin()),
2937 getRawSourceLocationEncoding(
Range.getEnd()));
2939 using namespace llvm;
2940 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2942 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2943 unsigned PPESkippedRangeAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2947 Stream.EmitRecordWithBlob(PPESkippedRangeAbbrev,
Record,
2948 bytes(SerializedSkippedRanges));
2956 auto Known = SubmoduleIDs.find(Mod);
2957 if (Known != SubmoduleIDs.end())
2958 return Known->second;
2961 if (Top != WritingModule &&
2963 !Top->fullModuleNameIs(StringRef(
getLangOpts().CurrentModule))))
2966 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2969unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2970 unsigned ID = getLocalOrImportedSubmoduleID(Mod);
2979void ASTWriter::WriteSubmodules(
Module *WritingModule,
ASTContext *Context) {
2984 using namespace llvm;
2986 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2988 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2989 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2990 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
2991 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2992 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4));
2993 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2994 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2995 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2996 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2997 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2998 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2999 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3000 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3001 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3002 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3003 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3004 unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3006 Abbrev = std::make_shared<BitCodeAbbrev>();
3008 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3009 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3011 Abbrev = std::make_shared<BitCodeAbbrev>();
3013 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3014 unsigned HeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3016 Abbrev = std::make_shared<BitCodeAbbrev>();
3018 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3019 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3021 Abbrev = std::make_shared<BitCodeAbbrev>();
3023 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3024 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3026 Abbrev = std::make_shared<BitCodeAbbrev>();
3028 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3029 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3030 unsigned RequiresAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3032 Abbrev = std::make_shared<BitCodeAbbrev>();
3034 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3035 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3037 Abbrev = std::make_shared<BitCodeAbbrev>();
3039 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3040 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3042 Abbrev = std::make_shared<BitCodeAbbrev>();
3044 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3045 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3047 Abbrev = std::make_shared<BitCodeAbbrev>();
3049 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3050 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3052 Abbrev = std::make_shared<BitCodeAbbrev>();
3054 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3055 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3056 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3058 Abbrev = std::make_shared<BitCodeAbbrev>();
3060 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3061 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3063 Abbrev = std::make_shared<BitCodeAbbrev>();
3065 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3066 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3067 unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3069 Abbrev = std::make_shared<BitCodeAbbrev>();
3071 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3072 unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3074 Abbrev = std::make_shared<BitCodeAbbrev>();
3076 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3077 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3078 unsigned ChildAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3081 uint64_t SubmoduleOffsetBase = Stream.GetCurrentBitNo();
3083 unsigned TopLevelID = getSubmoduleID(WritingModule);
3086 std::queue<Module *> Q;
3087 Q.push(WritingModule);
3088 while (!Q.empty()) {
3091 unsigned ID = getSubmoduleID(Mod);
3092 if (ID < FirstSubmoduleID) {
3093 assert(0 &&
"Loaded submodule entered WritingModule ?");
3098 unsigned Index =
ID - FirstSubmoduleID;
3099 if (Index >= SubmoduleOffsets.size())
3100 SubmoduleOffsets.resize(Index + 1);
3102 uint64_t Offset = Stream.GetCurrentBitNo() - SubmoduleOffsetBase;
3103 assert((Offset >> 32) == 0 &&
"Submodule offset too large");
3104 SubmoduleOffsets[Index] = Offset;
3108 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
3109 ParentID = SubmoduleIDs[Mod->
Parent];
3113 getRawSourceLocationEncoding(getAdjustedLocation(Mod->
DefinitionLoc));
3116 FileID UnadjustedInferredFID;
3119 int InferredFID = getAdjustedFileID(UnadjustedInferredFID).getOpaqueValue();
3126 (RecordData::value_type)Mod->
Kind,
3128 (RecordData::value_type)InferredFID,
3139 Stream.EmitRecordWithBlob(DefinitionAbbrev,
Record, Mod->
Name);
3145 Stream.EmitRecordWithBlob(RequiresAbbrev,
Record,
R.FeatureName);
3149 if (std::optional<Module::Header> UmbrellaHeader =
3152 Stream.EmitRecordWithBlob(UmbrellaAbbrev,
Record,
3153 UmbrellaHeader->NameAsWritten);
3154 }
else if (std::optional<Module::DirectoryName> UmbrellaDir =
3157 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev,
Record,
3158 UmbrellaDir->NameAsWritten);
3163 unsigned RecordKind;
3165 Module::HeaderKind HeaderKind;
3171 Module::HK_PrivateTextual},
3174 for (
const auto &HL : HeaderLists) {
3175 RecordData::value_type
Record[] = {HL.RecordKind};
3176 for (
const auto &H : Mod->
getHeaders(HL.HeaderKind))
3177 Stream.EmitRecordWithBlob(HL.Abbrev,
Record, H.NameAsWritten);
3184 SmallString<128> HeaderName(H.getName());
3185 PreparePathForOutput(HeaderName);
3186 Stream.EmitRecordWithBlob(TopHeaderAbbrev,
Record, HeaderName);
3194 Record.push_back(getSubmoduleID(I));
3202 Record.push_back(getSubmoduleID(I));
3209 for (
const auto &E : Mod->
Exports) {
3212 Record.push_back(getSubmoduleID(E.first));
3213 Record.push_back(E.second);
3228 Stream.EmitRecordWithBlob(LinkLibraryAbbrev,
Record, LL.Library);
3236 getSubmoduleID(
C.Other)};
3237 Stream.EmitRecordWithBlob(ConflictAbbrev,
Record,
C.Message);
3243 Stream.EmitRecordWithBlob(ConfigMacroAbbrev,
Record, CM);
3248 if (Context && !GeneratingReducedBMI) {
3251 if (wasDeclEmitted(D))
3252 AddDeclRef(D,
Inits);
3267 getSubmoduleID(Child)};
3268 Stream.EmitRecordWithBlob(ChildAbbrev,
Record, Child->Name);
3284 assert((NextSubmoduleID - FirstSubmoduleID == SubmoduleOffsets.size()) &&
3285 "Wrong # of submodules; found a reference to a non-local, "
3286 "non-imported submodule?");
3288 Abbrev = std::make_shared<BitCodeAbbrev>();
3290 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3291 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3292 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3293 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3294 unsigned SubmoduleMetadataAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3296 RecordData::value_type
Record[] = {
3299 Stream.EmitRecordWithBlob(SubmoduleMetadataAbbrev,
Record,
3300 bytes(SubmoduleOffsets));
3303void ASTWriter::WritePragmaDiagnosticMappings(
const DiagnosticsEngine &
Diag,
3305 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
3307 unsigned CurrID = 0;
3310 auto EncodeDiagStateFlags =
3311 [](
const DiagnosticsEngine::DiagState *DS) ->
unsigned {
3312 unsigned Result = (unsigned)DS->ExtBehavior;
3314 {(unsigned)DS->IgnoreAllWarnings, (
unsigned)DS->EnableAllWarnings,
3315 (unsigned)DS->WarningsAsErrors, (
unsigned)DS->ErrorsAsFatal,
3316 (unsigned)DS->SuppressSystemWarnings})
3321 unsigned Flags = EncodeDiagStateFlags(
Diag.DiagStatesByLoc.FirstDiagState);
3324 auto AddDiagState = [&](
const DiagnosticsEngine::DiagState *State,
3325 bool IncludeNonPragmaStates) {
3328 assert(Flags == EncodeDiagStateFlags(State) &&
3329 "diag state flags vary in single AST file");
3333 assert(!IncludeNonPragmaStates ||
3334 State ==
Diag.DiagStatesByLoc.FirstDiagState);
3336 unsigned &DiagStateID = DiagStateIDMap[State];
3337 Record.push_back(DiagStateID);
3339 if (DiagStateID == 0) {
3340 DiagStateID = ++CurrID;
3341 SmallVector<std::pair<unsigned, DiagnosticMapping>> Mappings;
3344 auto SizeIdx =
Record.size();
3346 for (
const auto &I : *State) {
3348 if (!I.second.isPragma() && !IncludeNonPragmaStates)
3352 if (!I.second.isPragma() &&
3353 I.second ==
Diag.getDiagnosticIDs()->getDefaultMapping(I.first))
3355 Mappings.push_back(I);
3359 llvm::sort(Mappings, llvm::less_first());
3361 for (
const auto &I : Mappings) {
3362 Record.push_back(I.first);
3363 Record.push_back(I.second.serialize());
3370 AddDiagState(
Diag.DiagStatesByLoc.FirstDiagState, isModule);
3373 auto NumLocationsIdx =
Record.size();
3377 unsigned NumLocations = 0;
3378 for (
auto &FileIDAndFile :
Diag.DiagStatesByLoc.Files) {
3379 if (!FileIDAndFile.first.isValid() ||
3380 !FileIDAndFile.second.HasLocalTransitions)
3384 AddFileID(FileIDAndFile.first,
Record);
3386 Record.push_back(FileIDAndFile.second.StateTransitions.size());
3387 for (
auto &StatePoint : FileIDAndFile.second.StateTransitions) {
3388 Record.push_back(StatePoint.Offset);
3389 AddDiagState(StatePoint.State,
false);
3394 Record[NumLocationsIdx] = NumLocations;
3402 AddSourceLocation(
Diag.DiagStatesByLoc.CurDiagStateLoc,
Record);
3403 AddDiagState(
Diag.DiagStatesByLoc.CurDiagState,
false);
3408 Record.push_back(
Diag.DiagStateOnPushStack.size());
3409 for (
const auto *State :
Diag.DiagStateOnPushStack)
3410 AddDiagState(State,
false);
3420void ASTWriter::WriteType(ASTContext &Context, QualType
T) {
3421 TypeIdx &IdxRef = TypeIdxs[
T];
3423 IdxRef = TypeIdx(0, NextTypeID++);
3424 TypeIdx Idx = IdxRef;
3427 assert(Idx.
getValue() >= FirstTypeID &&
"Writing predefined type");
3431 ASTTypeWriter(Context, *
this).write(
T) - DeclTypesBlockStartOffset;
3435 if (TypeOffsets.size() == Index)
3436 TypeOffsets.emplace_back(Offset);
3437 else if (TypeOffsets.size() < Index) {
3438 TypeOffsets.resize(Index + 1);
3439 TypeOffsets[Index].set(Offset);
3441 llvm_unreachable(
"Types emitted in wrong order");
3450 auto *ND = dyn_cast<NamedDecl>(D);
3465uint64_t ASTWriter::WriteDeclContextLexicalBlock(ASTContext &Context,
3466 const DeclContext *DC) {
3474 uint64_t Offset = Stream.GetCurrentBitNo();
3475 SmallVector<DeclID, 128> KindDeclPairs;
3476 for (
const auto *D : DC->
decls()) {
3477 if (DoneWritingDeclsAndTypes && !wasDeclEmitted(D))
3485 if (GeneratingReducedBMI && !D->isFromExplicitGlobalModule() &&
3489 KindDeclPairs.push_back(D->getKind());
3490 KindDeclPairs.push_back(GetDeclRef(D).getRawValue());
3493 ++NumLexicalDeclContexts;
3495 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev,
Record,
3496 bytes(KindDeclPairs));
3500void ASTWriter::WriteTypeDeclOffsets() {
3501 using namespace llvm;
3504 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3506 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3507 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3508 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3511 Stream.EmitRecordWithBlob(TypeOffsetAbbrev,
Record,
bytes(TypeOffsets));
3515 Abbrev = std::make_shared<BitCodeAbbrev>();
3517 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3518 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3519 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3522 Stream.EmitRecordWithBlob(DeclOffsetAbbrev,
Record,
bytes(DeclOffsets));
3526void ASTWriter::WriteFileDeclIDsMap() {
3527 using namespace llvm;
3529 SmallVector<std::pair<FileID, DeclIDInFileInfo *>, 64> SortedFileDeclIDs;
3530 SortedFileDeclIDs.reserve(FileDeclIDs.size());
3531 for (
const auto &P : FileDeclIDs)
3532 SortedFileDeclIDs.push_back(std::make_pair(P.first, P.second.get()));
3533 llvm::sort(SortedFileDeclIDs, llvm::less_first());
3536 SmallVector<DeclID, 256> FileGroupedDeclIDs;
3537 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
3538 DeclIDInFileInfo &Info = *FileDeclEntry.second;
3539 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
3540 llvm::stable_sort(Info.DeclIDs);
3541 for (
auto &LocDeclEntry : Info.DeclIDs)
3542 FileGroupedDeclIDs.push_back(LocDeclEntry.second.getRawValue());
3545 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3547 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3548 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3549 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
3551 FileGroupedDeclIDs.size()};
3552 Stream.EmitRecordWithBlob(AbbrevCode,
Record,
bytes(FileGroupedDeclIDs));
3555void ASTWriter::WriteComments(ASTContext &Context) {
3557 llvm::scope_exit _([
this] { Stream.ExitBlock(); });
3562 for (
const auto &FO : Context.
Comments.OrderedComments) {
3563 for (
const auto &OC : FO.second) {
3564 const RawComment *I = OC.second;
3582class ASTMethodPoolTrait {
3586 using key_type = Selector;
3587 using key_type_ref = key_type;
3591 ObjCMethodList Instance, Factory;
3593 using data_type_ref =
const data_type &;
3595 using hash_value_type = unsigned;
3596 using offset_type = unsigned;
3598 explicit ASTMethodPoolTrait(ASTWriter &Writer) : Writer(Writer) {}
3600 static hash_value_type
ComputeHash(Selector Sel) {
3604 std::pair<unsigned, unsigned>
3605 EmitKeyDataLength(raw_ostream& Out, Selector Sel,
3606 data_type_ref Methods) {
3610 unsigned DataLen = 4 + 2 + 2;
3611 for (
const ObjCMethodList *
Method = &Methods.Instance;
Method;
3613 if (ShouldWriteMethodListNode(
Method))
3614 DataLen +=
sizeof(
DeclID);
3615 for (
const ObjCMethodList *
Method = &Methods.Factory;
Method;
3617 if (ShouldWriteMethodListNode(
Method))
3618 DataLen +=
sizeof(
DeclID);
3622 void EmitKey(raw_ostream& Out, Selector Sel,
unsigned) {
3623 using namespace llvm::support;
3625 endian::Writer
LE(Out, llvm::endianness::little);
3627 assert((Start >> 32) == 0 &&
"Selector key offset too large");
3633 for (
unsigned I = 0; I != N; ++I)
3638 void EmitData(raw_ostream& Out, key_type_ref,
3639 data_type_ref Methods,
unsigned DataLen) {
3640 using namespace llvm::support;
3642 endian::Writer
LE(Out, llvm::endianness::little);
3645 unsigned NumInstanceMethods = 0;
3646 for (
const ObjCMethodList *
Method = &Methods.Instance;
Method;
3648 if (ShouldWriteMethodListNode(
Method))
3649 ++NumInstanceMethods;
3651 unsigned NumFactoryMethods = 0;
3652 for (
const ObjCMethodList *
Method = &Methods.Factory;
Method;
3654 if (ShouldWriteMethodListNode(
Method))
3655 ++NumFactoryMethods;
3657 unsigned InstanceBits = Methods.Instance.getBits();
3658 assert(InstanceBits < 4);
3659 unsigned InstanceHasMoreThanOneDeclBit =
3660 Methods.Instance.hasMoreThanOneDecl();
3661 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
3662 (InstanceHasMoreThanOneDeclBit << 2) |
3664 unsigned FactoryBits = Methods.Factory.getBits();
3665 assert(FactoryBits < 4);
3666 unsigned FactoryHasMoreThanOneDeclBit =
3667 Methods.Factory.hasMoreThanOneDecl();
3668 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
3669 (FactoryHasMoreThanOneDeclBit << 2) |
3673 for (
const ObjCMethodList *
Method = &Methods.Instance;
Method;
3675 if (ShouldWriteMethodListNode(
Method))
3677 for (
const ObjCMethodList *
Method = &Methods.Factory;
Method;
3679 if (ShouldWriteMethodListNode(
Method))
3682 assert(
Out.tell() - Start == DataLen &&
"Data length is wrong");
3686 static bool ShouldWriteMethodListNode(
const ObjCMethodList *Node) {
3698void ASTWriter::WriteSelectors(Sema &SemaRef) {
3699 using namespace llvm;
3704 unsigned NumTableEntries = 0;
3707 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait>
Generator;
3708 ASTMethodPoolTrait Trait(*
this);
3712 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
3713 for (
auto &SelectorAndID : SelectorIDs) {
3714 Selector S = SelectorAndID.first;
3716 SemaObjC::GlobalMethodPool::iterator F =
3718 ASTMethodPoolTrait::data_type
Data = {
3724 Data.Instance = F->second.first;
3725 Data.Factory = F->second.second;
3729 if (Chain && ID < FirstSelectorID) {
3731 bool changed =
false;
3732 for (ObjCMethodList *M = &
Data.Instance; M && M->getMethod();
3734 if (!M->getMethod()->isFromASTFile()) {
3740 for (ObjCMethodList *M = &
Data.Factory; M && M->getMethod();
3742 if (!M->getMethod()->isFromASTFile()) {
3750 }
else if (
Data.Instance.getMethod() ||
Data.Factory.getMethod()) {
3758 SmallString<4096> MethodPool;
3761 using namespace llvm::support;
3763 ASTMethodPoolTrait Trait(*
this);
3764 llvm::raw_svector_ostream
Out(MethodPool);
3766 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
3767 BucketOffset =
Generator.Emit(Out, Trait);
3771 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3773 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3774 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3775 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3776 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3782 Stream.EmitRecordWithBlob(MethodPoolAbbrev,
Record, MethodPool);
3786 Abbrev = std::make_shared<BitCodeAbbrev>();
3788 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3789 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3790 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3791 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3795 RecordData::value_type
Record[] = {
3798 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev,
Record,
3799 bytes(SelectorOffsets));
3805void ASTWriter::WriteReferencedSelectorsPool(Sema &SemaRef) {
3806 using namespace llvm;
3818 Selector Sel = SelectorAndLocation.first;
3819 SourceLocation Loc = SelectorAndLocation.second;
3820 Writer.AddSelectorRef(Sel);
3842 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3844 if (!Redecl->isFromASTFile()) {
3848 if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
3856 if (Redecl->getOwningModuleID() == 0)
3861 if (!
First->isFromASTFile())
3872bool IsInterestingIdentifier(
const IdentifierInfo *II, uint64_t MacroOffset,
3873 bool IsModule,
bool IsCPlusPlus) {
3874 bool NeedDecls = !IsModule || !IsCPlusPlus;
3876 bool IsInteresting =
3883 II->
isPoisoned() || (!IsModule && IsInteresting) ||
3891bool IsInterestingNonMacroIdentifier(
const IdentifierInfo *II,
3892 ASTWriter &Writer) {
3894 bool IsCPlusPlus = Writer.
getLangOpts().CPlusPlus;
3895 return IsInterestingIdentifier(II, 0, IsModule, IsCPlusPlus);
3898class ASTIdentifierTableTrait {
3901 IdentifierResolver *IdResolver;
3911 return IsInterestingIdentifier(II, MacroOffset, IsModule,
3916 using key_type =
const IdentifierInfo *;
3917 using key_type_ref = key_type;
3920 using data_type_ref = data_type;
3922 using hash_value_type = unsigned;
3923 using offset_type = unsigned;
3925 ASTIdentifierTableTrait(ASTWriter &Writer, Preprocessor &PP,
3926 IdentifierResolver *IdResolver,
bool IsModule,
3928 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3929 NeedDecls(!IsModule || !Writer.getLangOpts().
CPlusPlus),
3930 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3932 bool needDecls()
const {
return NeedDecls; }
3934 static hash_value_type
ComputeHash(
const IdentifierInfo* II) {
3935 return llvm::djbHash(II->
getName());
3943 std::pair<unsigned, unsigned>
3944 EmitKeyDataLength(raw_ostream &Out,
const IdentifierInfo *II,
IdentifierID ID) {
3953 if (InterestingIdentifierOffsets &&
3955 InterestingIdentifierOffsets->push_back(
Out.tell());
3966 if (NeedDecls && IdResolver)
3967 DataLen += std::distance(IdResolver->
begin(II), IdResolver->
end()) *
3973 void EmitKey(raw_ostream &Out,
const IdentifierInfo *II,
unsigned KeyLen) {
3977 void EmitData(raw_ostream &Out,
const IdentifierInfo *II,
IdentifierID ID,
3979 using namespace llvm::support;
3981 endian::Writer
LE(Out, llvm::endianness::little);
3991 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
3994 bool HasMacroDefinition =
3997 Bits = (Bits << 1) |
unsigned(HasMacroDefinition);
3999 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
4004 if (HasMacroDefinition)
4007 if (NeedDecls && IdResolver) {
4014 SmallVector<NamedDecl *, 16> Decls(IdResolver->
decls(II));
4015 for (NamedDecl *D : llvm::reverse(Decls))
4033void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
4034 IdentifierResolver *IdResolver,
4036 using namespace llvm;
4038 RecordData InterestingIdents;
4043 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait>
Generator;
4044 ASTIdentifierTableTrait Trait(*
this, PP, IdResolver, IsModule,
4045 IsModule ? &InterestingIdents :
nullptr);
4049 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
4050 for (
auto IdentIDPair : IdentifierIDs) {
4051 const IdentifierInfo *II = IdentIDPair.first;
4053 assert(II &&
"NULL identifier in identifier table");
4058 (Trait.needDecls() &&
4064 SmallString<4096> IdentifierTable;
4067 using namespace llvm::support;
4069 llvm::raw_svector_ostream
Out(IdentifierTable);
4071 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
4072 BucketOffset =
Generator.Emit(Out, Trait);
4076 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4078 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
4079 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4080 unsigned IDTableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4084 Stream.EmitRecordWithBlob(IDTableAbbrev,
Record, IdentifierTable);
4088 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4090 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
4091 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4092 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4095 for (
unsigned I = 0, N = IdentifierOffsets.size(); I != N; ++I)
4096 assert(IdentifierOffsets[I] &&
"Missing identifier offset?");
4100 IdentifierOffsets.size()};
4101 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev,
Record,
4102 bytes(IdentifierOffsets));
4106 if (!InterestingIdents.empty())
4114 PendingEmittingVTables.push_back(RD);
4118 TouchedModuleFiles.insert(MF);
4127class ASTDeclContextNameLookupTraitBase {
4135 using data_type = std::pair<unsigned, unsigned>;
4136 using data_type_ref =
const data_type &;
4141 explicit ASTDeclContextNameLookupTraitBase(
ASTWriter &Writer)
4144 data_type getData(
const DeclIDsTy &LocalIDs) {
4145 unsigned Start = DeclIDs.size();
4146 for (
auto ID : LocalIDs)
4147 DeclIDs.push_back(ID);
4148 return std::make_pair(Start, DeclIDs.size());
4151 data_type ImportData(
const reader::ASTDeclContextNameLookupTrait::data_type &FromReader) {
4152 unsigned Start = DeclIDs.size();
4155 DeclIDIterator<GlobalDeclID, LocalDeclID>(FromReader.begin()),
4156 DeclIDIterator<GlobalDeclID, LocalDeclID>(FromReader.end()));
4157 return std::make_pair(Start, DeclIDs.size());
4160 void EmitFileRef(raw_ostream &Out, ModuleFile *F)
const {
4162 "have reference to loaded module file but no chain?");
4164 using namespace llvm::support;
4167 llvm::endianness::little);
4170 std::pair<unsigned, unsigned> EmitKeyDataLengthBase(raw_ostream &Out,
4171 DeclarationNameKey Name,
4172 data_type_ref Lookup) {
4173 unsigned KeyLen = 1;
4196 unsigned DataLen =
sizeof(
DeclID) * (Lookup.second - Lookup.first);
4198 return {KeyLen, DataLen};
4201 void EmitKeyBase(raw_ostream &Out, DeclarationNameKey Name) {
4202 using namespace llvm::support;
4204 endian::Writer
LE(Out, llvm::endianness::little);
4219 "Invalid operator?");
4229 llvm_unreachable(
"Invalid name kind?");
4232 void EmitDataBase(raw_ostream &Out, data_type Lookup,
unsigned DataLen) {
4233 using namespace llvm::support;
4235 endian::Writer
LE(Out, llvm::endianness::little);
4237 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
4239 assert(
Out.tell() - Start == DataLen &&
"Data length is wrong");
4243class ModuleLevelNameLookupTrait :
public ASTDeclContextNameLookupTraitBase {
4245 using primary_module_hash_type = unsigned;
4247 using key_type = std::pair<DeclarationNameKey, primary_module_hash_type>;
4248 using key_type_ref = key_type;
4250 explicit ModuleLevelNameLookupTrait(ASTWriter &Writer)
4251 : ASTDeclContextNameLookupTraitBase(Writer) {}
4253 static bool EqualKey(key_type_ref a, key_type_ref b) {
return a == b; }
4256 llvm::FoldingSetNodeID
ID;
4257 ID.AddInteger(Key.first.getHash());
4258 ID.AddInteger(Key.second);
4259 return ID.computeStableHash();
4262 std::pair<unsigned, unsigned>
4263 EmitKeyDataLength(raw_ostream &Out, key_type Key, data_type_ref Lookup) {
4264 auto [KeyLen, DataLen] = EmitKeyDataLengthBase(Out, Key.first, Lookup);
4265 KeyLen +=
sizeof(Key.second);
4269 void EmitKey(raw_ostream &Out, key_type Key,
unsigned) {
4270 EmitKeyBase(Out, Key.first);
4271 llvm::support::endian::Writer
LE(Out, llvm::endianness::little);
4272 LE.write<primary_module_hash_type>(Key.second);
4275 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4277 EmitDataBase(Out, Lookup, DataLen);
4281class ASTDeclContextNameTrivialLookupTrait
4282 :
public ASTDeclContextNameLookupTraitBase {
4284 using key_type = DeclarationNameKey;
4285 using key_type_ref = key_type;
4288 using ASTDeclContextNameLookupTraitBase::ASTDeclContextNameLookupTraitBase;
4290 using ASTDeclContextNameLookupTraitBase::getData;
4292 static bool EqualKey(key_type_ref a, key_type_ref b) {
return a == b; }
4294 hash_value_type
ComputeHash(key_type Name) {
return Name.getHash(); }
4296 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
4297 DeclarationNameKey Name,
4298 data_type_ref Lookup) {
4299 auto [KeyLen, DataLen] = EmitKeyDataLengthBase(Out, Name, Lookup);
4303 void EmitKey(raw_ostream &Out, DeclarationNameKey Name,
unsigned) {
4304 return EmitKeyBase(Out, Name);
4307 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4309 EmitDataBase(Out, Lookup, DataLen);
4313static bool isModuleLocalDecl(NamedDecl *D) {
4318 return isModuleLocalDecl(Parent);
4322 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
4323 if (
auto *CDGD = dyn_cast<CXXDeductionGuideDecl>(FTD->getTemplatedDecl()))
4324 return isModuleLocalDecl(CDGD->getDeducedTemplate());
4340static bool isTULocalInNamedModules(NamedDecl *D) {
4363class ASTDeclContextNameLookupTrait
4364 :
public ASTDeclContextNameTrivialLookupTrait {
4366 using TULocalDeclsMapTy = llvm::DenseMap<key_type, DeclIDsTy>;
4368 using ModuleLevelDeclsMapTy =
4369 llvm::DenseMap<ModuleLevelNameLookupTrait::key_type, DeclIDsTy>;
4372 enum class LookupVisibility {
4382 LookupVisibility getLookupVisibility(NamedDecl *D)
const {
4385 return LookupVisibility::GenerallyVisibile;
4387 if (isModuleLocalDecl(D))
4388 return LookupVisibility::ModuleLocalVisible;
4389 if (isTULocalInNamedModules(D))
4390 return LookupVisibility::TULocal;
4402 if (
auto *ECD = dyn_cast<EnumConstantDecl>(D);
4403 ECD && DC.
isFileContext() && ECD->getTopLevelOwningNamedModule()) {
4408 return Found->isInvisibleOutsideTheOwningModule();
4410 return ECD->isFromExplicitGlobalModule() ||
4411 ECD->isInAnonymousNamespace()
4412 ? LookupVisibility::TULocal
4413 : LookupVisibility::ModuleLocalVisible;
4416 return LookupVisibility::GenerallyVisibile;
4420 ModuleLevelDeclsMapTy ModuleLocalDeclsMap;
4421 TULocalDeclsMapTy TULocalDeclsMap;
4424 using ASTDeclContextNameTrivialLookupTrait::
4425 ASTDeclContextNameTrivialLookupTrait;
4427 ASTDeclContextNameLookupTrait(ASTWriter &Writer, DeclContext &DC)
4428 : ASTDeclContextNameTrivialLookupTrait(Writer), DC(DC) {}
4430 template <
typename Coll> data_type getData(
const Coll &Decls) {
4431 unsigned Start = DeclIDs.size();
4432 auto AddDecl = [
this](NamedDecl *D) {
4433 NamedDecl *DeclForLocalLookup =
4449 switch (getLookupVisibility(DeclForLocalLookup)) {
4450 case LookupVisibility::ModuleLocalVisible:
4453 auto Key = std::make_pair(D->
getDeclName(), *PrimaryModuleHash);
4454 auto Iter = ModuleLocalDeclsMap.find(Key);
4455 if (Iter == ModuleLocalDeclsMap.end())
4456 ModuleLocalDeclsMap.insert({Key, DeclIDsTy{
ID}});
4458 Iter->second.push_back(ID);
4462 case LookupVisibility::TULocal: {
4463 auto Iter = TULocalDeclsMap.find(D->
getDeclName());
4464 if (Iter == TULocalDeclsMap.end())
4467 Iter->second.push_back(ID);
4470 case LookupVisibility::GenerallyVisibile:
4475 DeclIDs.push_back(ID);
4477 ASTReader *Chain = Writer.
getChain();
4478 for (NamedDecl *D : Decls) {
4489 for (
const auto &[_,
First] : Firsts)
4495 return std::make_pair(Start, DeclIDs.size());
4498 const ModuleLevelDeclsMapTy &getModuleLocalDecls() {
4499 return ModuleLocalDeclsMap;
4502 const TULocalDeclsMapTy &getTULocalDecls() {
return TULocalDeclsMap; }
4508class LazySpecializationInfoLookupTrait {
4510 llvm::SmallVector<serialization::reader::LazySpecializationInfo, 64> Specs;
4513 using key_type = unsigned;
4514 using key_type_ref = key_type;
4517 using data_type = std::pair<unsigned, unsigned>;
4518 using data_type_ref =
const data_type &;
4520 using hash_value_type = unsigned;
4521 using offset_type = unsigned;
4523 explicit LazySpecializationInfoLookupTrait(ASTWriter &Writer)
4526 template <
typename Col,
typename Col2>
4527 data_type getData(Col &&
C, Col2 &ExistingInfo) {
4528 unsigned Start = Specs.size();
4531 const_cast<NamedDecl *
>(D));
4536 Specs.push_back(Info);
4537 return std::make_pair(Start, Specs.size());
4540 data_type ImportData(
4542 unsigned Start = Specs.size();
4543 for (
auto ID : FromReader)
4544 Specs.push_back(ID);
4545 return std::make_pair(Start, Specs.size());
4548 static bool EqualKey(key_type_ref a, key_type_ref b) {
return a == b; }
4550 hash_value_type
ComputeHash(key_type Name) {
return Name; }
4552 void EmitFileRef(raw_ostream &Out, ModuleFile *F)
const {
4554 "have reference to loaded module file but no chain?");
4556 using namespace llvm::support;
4559 llvm::endianness::little);
4562 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
4564 data_type_ref Lookup) {
4566 unsigned KeyLen = 4;
4568 (Lookup.second - Lookup.first);
4573 void EmitKey(raw_ostream &Out, key_type HashValue,
unsigned) {
4574 using namespace llvm::support;
4576 endian::Writer
LE(Out, llvm::endianness::little);
4580 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4582 using namespace llvm::support;
4584 endian::Writer
LE(Out, llvm::endianness::little);
4587 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I) {
4588 LE.write<
DeclID>(Specs[I].getRawValue());
4590 assert(
Out.tell() - Start == DataLen &&
"Data length is wrong");
4594unsigned CalculateODRHashForSpecs(
const Decl *Spec) {
4595 ArrayRef<TemplateArgument> Args;
4596 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Spec))
4597 Args = CTSD->getTemplateArgs().asArray();
4598 else if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Spec))
4599 Args = VTSD->getTemplateArgs().asArray();
4600 else if (
auto *FD = dyn_cast<FunctionDecl>(Spec))
4601 Args = FD->getTemplateSpecializationArgs()->asArray();
4603 llvm_unreachable(
"New Specialization Kind?");
4609void ASTWriter::GenerateSpecializationInfoLookupTable(
4610 const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
4611 llvm::SmallVectorImpl<char> &LookupTable,
bool IsPartial) {
4615 MultiOnDiskHashTableGenerator<reader::LazySpecializationInfoLookupTrait,
4616 LazySpecializationInfoLookupTrait>
4618 LazySpecializationInfoLookupTrait Trait(*
this);
4620 llvm::MapVector<unsigned, llvm::SmallVector<const NamedDecl *, 4>>
4626 auto Iter = SpecializationMaps.find(HashedValue);
4627 if (Iter == SpecializationMaps.end())
4628 Iter = SpecializationMaps
4629 .try_emplace(HashedValue,
4630 llvm::SmallVector<const NamedDecl *, 4>())
4640 for (
auto &[HashValue, Specs] : SpecializationMaps) {
4641 SmallVector<serialization::reader::LazySpecializationInfo, 16>
4651 ExisitingSpecs = Lookups->Table.find(HashValue);
4653 Generator.insert(HashValue, Trait.getData(Specs, ExisitingSpecs), Trait);
4663 auto *ToEmitMaybeMergedLookupTable =
4664 (!isGeneratingReducedBMI() && Lookups) ? &Lookups->
Table :
nullptr;
4665 Generator.emit(LookupTable, Trait, ToEmitMaybeMergedLookupTable);
4668uint64_t ASTWriter::WriteSpecializationInfoLookupTable(
4669 const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
4672 llvm::SmallString<4096> LookupTable;
4673 GenerateSpecializationInfoLookupTable(D, Specializations, LookupTable,
4676 uint64_t Offset = Stream.GetCurrentBitNo();
4677 RecordData::value_type
Record[] = {
static_cast<RecordData::value_type
>(
4679 Stream.EmitRecordWithBlob(IsPartial ? DeclPartialSpecializationsAbbrev
4680 : DeclSpecializationsAbbrev,
4692 for (
auto *D :
Result.getLookupResult()) {
4694 if (LocalD->isFromASTFile())
4712void ASTWriter::GenerateNameLookupTable(
4713 ASTContext &Context,
const DeclContext *ConstDC,
4714 llvm::SmallVectorImpl<char> &LookupTable,
4715 llvm::SmallVectorImpl<char> &ModuleLocalLookupTable,
4716 llvm::SmallVectorImpl<char> &TULookupTable) {
4717 assert(!ConstDC->hasLazyLocalLexicalLookups() &&
4718 !ConstDC->hasLazyExternalLexicalLookups() &&
4719 "must call buildLookups first");
4722 auto *DC =
const_cast<DeclContext*
>(ConstDC);
4726 MultiOnDiskHashTableGenerator<reader::ASTDeclContextNameLookupTrait,
4727 ASTDeclContextNameLookupTrait>
4729 ASTDeclContextNameLookupTrait Trait(*
this, *DC);
4734 SmallVector<DeclarationName, 16> Names;
4738 bool IncludeConstructorNames =
false;
4739 bool IncludeConversionNames =
false;
4766 if (
Result.getLookupResult().empty())
4769 switch (Name.getNameKind()) {
4771 Names.push_back(Name);
4775 IncludeConstructorNames =
true;
4779 IncludeConversionNames =
true;
4787 if (IncludeConstructorNames || IncludeConversionNames) {
4792 llvm::SmallPtrSet<DeclarationName, 8> AddedNames;
4794 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
4795 auto Name = ChildND->getDeclName();
4796 switch (Name.getNameKind()) {
4801 if (!IncludeConstructorNames)
4806 if (!IncludeConversionNames)
4810 if (AddedNames.insert(Name).second)
4811 Names.push_back(Name);
4819 for (
auto &Name : Names)
4826 SmallVector<NamedDecl *, 8> ConstructorDecls;
4827 SmallVector<NamedDecl *, 8> ConversionDecls;
4831 for (
auto &Name : Names) {
4834 switch (Name.getNameKind()) {
4852 if (!ConstructorDecls.empty())
4853 Generator.insert(ConstructorDecls.front()->getDeclName(),
4854 Trait.getData(ConstructorDecls), Trait);
4855 if (!ConversionDecls.empty())
4856 Generator.insert(ConversionDecls.front()->getDeclName(),
4857 Trait.getData(ConversionDecls), Trait);
4869 auto *ToEmitMaybeMergedLookupTable =
4870 (!isGeneratingReducedBMI() && Lookups) ? &Lookups->
Table :
nullptr;
4871 Generator.emit(LookupTable, Trait, ToEmitMaybeMergedLookupTable);
4873 const auto &ModuleLocalDecls = Trait.getModuleLocalDecls();
4874 if (!ModuleLocalDecls.empty()) {
4875 MultiOnDiskHashTableGenerator<reader::ModuleLocalNameLookupTrait,
4876 ModuleLevelNameLookupTrait>
4877 ModuleLocalLookupGenerator;
4878 ModuleLevelNameLookupTrait ModuleLocalTrait(*
this);
4880 for (
const auto &ModuleLocalIter : ModuleLocalDecls) {
4881 const auto &Key = ModuleLocalIter.first;
4882 const auto &IDs = ModuleLocalIter.second;
4883 ModuleLocalLookupGenerator.insert(Key, ModuleLocalTrait.getData(IDs),
4889 auto *ModuleLocalLookups =
4890 (isGeneratingReducedBMI() && Chain &&
4894 ModuleLocalLookupGenerator.emit(ModuleLocalLookupTable, ModuleLocalTrait,
4895 ModuleLocalLookups);
4898 const auto &TULocalDecls = Trait.getTULocalDecls();
4899 if (!TULocalDecls.empty() && !isGeneratingReducedBMI()) {
4900 MultiOnDiskHashTableGenerator<reader::ASTDeclContextNameLookupTrait,
4901 ASTDeclContextNameTrivialLookupTrait>
4903 ASTDeclContextNameTrivialLookupTrait TULocalTrait(*
this);
4905 for (
const auto &TULocalIter : TULocalDecls) {
4906 const auto &Key = TULocalIter.first;
4907 const auto &IDs = TULocalIter.second;
4908 TULookupGenerator.insert(Key, TULocalTrait.getData(IDs), TULocalTrait);
4913 auto *TULocalLookups =
4917 TULookupGenerator.emit(TULookupTable, TULocalTrait, TULocalLookups);
4926void ASTWriter::WriteDeclContextVisibleBlock(
4927 ASTContext &Context, DeclContext *DC, VisibleLookupBlockOffsets &Offsets) {
4937 Prev = Prev->getPreviousDecl())
4938 if (!Prev->isFromASTFile())
4948 SmallVector<std::pair<DeclarationName, DeclContext::lookup_result>, 16>
4951 LookupResults.reserve(Map->size());
4952 for (
auto &Entry : *Map)
4953 LookupResults.push_back(
4954 std::make_pair(Entry.first, Entry.second.getLookupResult()));
4957 llvm::sort(LookupResults, llvm::less_first());
4958 for (
auto &NameAndResult : LookupResults) {
4959 DeclarationName Name = NameAndResult.first;
4966 assert(
Result.empty() &&
"Cannot have a constructor or conversion "
4967 "function name in a namespace!");
4971 for (NamedDecl *ND :
Result) {
4975 if (DoneWritingDeclsAndTypes && !wasDeclEmitted(ND))
5009 if (!Map || Map->empty())
5014 SmallString<4096> LookupTable;
5015 SmallString<4096> ModuleLocalLookupTable;
5016 SmallString<4096> TULookupTable;
5017 GenerateNameLookupTable(Context, DC, LookupTable, ModuleLocalLookupTable,
5022 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev,
Record,
5024 ++NumVisibleDeclContexts;
5026 if (!ModuleLocalLookupTable.empty()) {
5030 RecordData::value_type ModuleLocalRecord[] = {
5032 Stream.EmitRecordWithBlob(DeclModuleLocalVisibleLookupAbbrev,
5033 ModuleLocalRecord, ModuleLocalLookupTable);
5034 ++NumModuleLocalDeclContexts;
5037 if (!TULookupTable.empty()) {
5040 RecordData::value_type TULocalDeclsRecord[] = {
5042 Stream.EmitRecordWithBlob(DeclTULocalLookupAbbrev, TULocalDeclsRecord,
5044 ++NumTULocalDeclContexts;
5054void ASTWriter::WriteDeclContextVisibleUpdate(ASTContext &Context,
5055 const DeclContext *DC) {
5057 if (!Map || Map->empty())
5061 SmallString<4096> LookupTable;
5062 SmallString<4096> ModuleLocalLookupTable;
5063 SmallString<4096> TULookupTable;
5064 GenerateNameLookupTable(Context, DC, LookupTable, ModuleLocalLookupTable,
5075 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev,
Record, LookupTable);
5077 if (!ModuleLocalLookupTable.empty()) {
5079 RecordData::value_type ModuleLocalRecord[] = {
5081 Stream.EmitRecordWithBlob(ModuleLocalUpdateVisibleAbbrev, ModuleLocalRecord,
5082 ModuleLocalLookupTable);
5085 if (!TULookupTable.empty()) {
5086 RecordData::value_type GMFRecord[] = {
5088 Stream.EmitRecordWithBlob(TULocalUpdateVisibleAbbrev, GMFRecord,
5094void ASTWriter::WriteFPPragmaOptions(
const FPOptionsOverride &Opts) {
5100void ASTWriter::WriteOpenCLExtensions(Sema &SemaRef) {
5106 for (
const auto &I:Opts.OptMap) {
5107 AddString(I.getKey(),
Record);
5108 auto V = I.getValue();
5109 Record.push_back(
V.Supported ? 1 : 0);
5110 Record.push_back(
V.Enabled ? 1 : 0);
5111 Record.push_back(
V.WithPragma ? 1 : 0);
5118void ASTWriter::WriteCUDAPragmas(Sema &SemaRef) {
5119 if (SemaRef.
CUDA().ForceHostDeviceDepth > 0) {
5120 RecordData::value_type
Record[] = {SemaRef.
CUDA().ForceHostDeviceDepth};
5125void ASTWriter::WriteObjCCategories() {
5126 if (ObjCClassesWithCategories.empty())
5129 SmallVector<ObjCCategoriesInfo, 2> CategoriesMap;
5130 RecordData Categories;
5132 for (
unsigned I = 0, N = ObjCClassesWithCategories.size(); I != N; ++I) {
5134 unsigned StartIndex = Categories.size();
5136 ObjCInterfaceDecl *
Class = ObjCClassesWithCategories[I];
5139 Categories.push_back(0);
5143 Cat =
Class->known_categories_begin(),
5144 CatEnd =
Class->known_categories_end();
5145 Cat != CatEnd; ++Cat, ++Size) {
5146 assert(getDeclID(*Cat).isValid() &&
"Bogus category");
5147 AddDeclRef(*Cat, Categories);
5151 Categories[StartIndex] =
Size;
5154 ObjCCategoriesInfo CatInfo = { getDeclID(
Class), StartIndex };
5155 CategoriesMap.push_back(CatInfo);
5160 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
5163 using namespace llvm;
5165 auto Abbrev = std::make_shared<BitCodeAbbrev>();
5167 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
5168 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
5169 unsigned AbbrevID = Stream.EmitAbbrev(std::move(Abbrev));
5172 Stream.EmitRecordWithBlob(AbbrevID,
Record,
5173 reinterpret_cast<char *
>(CategoriesMap.data()),
5174 CategoriesMap.size() *
sizeof(ObjCCategoriesInfo));
5180void ASTWriter::WriteLateParsedTemplates(Sema &SemaRef) {
5187 for (
auto &LPTMapEntry : LPTMap) {
5188 const FunctionDecl *FD = LPTMapEntry.first;
5189 LateParsedTemplate &LPT = *LPTMapEntry.second;
5195 for (
const auto &
Tok : LPT.
Toks) {
5203void ASTWriter::WriteOptimizePragmaOptions(Sema &SemaRef) {
5206 AddSourceLocation(PragmaLoc,
Record);
5211void ASTWriter::WriteMSStructPragmaOptions(Sema &SemaRef) {
5219void ASTWriter::WriteMSPointersToMembersPragmaOptions(Sema &SemaRef) {
5227void ASTWriter::WritePackPragmaOptions(Sema &SemaRef) {
5238 AddAlignPackInfo(StackEntry.Value,
Record);
5239 AddSourceLocation(StackEntry.PragmaLocation,
Record);
5240 AddSourceLocation(StackEntry.PragmaPushLocation,
Record);
5241 AddString(StackEntry.StackSlotLabel,
Record);
5247void ASTWriter::WriteFloatControlPragmaOptions(Sema &SemaRef) {
5257 for (
const auto &StackEntry : SemaRef.
FpPragmaStack.Stack) {
5258 Record.push_back(StackEntry.Value.getAsOpaqueInt());
5259 AddSourceLocation(StackEntry.PragmaLocation,
Record);
5260 AddSourceLocation(StackEntry.PragmaPushLocation,
Record);
5261 AddString(StackEntry.StackSlotLabel,
Record);
5267void ASTWriter::WriteDeclsWithEffectsToVerify(Sema &SemaRef) {
5277void ASTWriter::WriteModuleFileExtension(Sema &SemaRef,
5278 ModuleFileExtensionWriter &Writer) {
5283 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
5285 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5286 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5287 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5288 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5289 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
5290 unsigned Abbrev = Stream.EmitAbbrev(std::move(Abv));
5296 Record.push_back(Metadata.MajorVersion);
5297 Record.push_back(Metadata.MinorVersion);
5298 Record.push_back(Metadata.BlockName.size());
5299 Record.push_back(Metadata.UserInfo.size());
5300 SmallString<64> Buffer;
5301 Buffer += Metadata.BlockName;
5302 Buffer += Metadata.UserInfo;
5303 Stream.EmitRecordWithBlob(Abbrev,
Record, Buffer);
5312void ASTWriter::WriteRISCVIntrinsicPragmas(Sema &SemaRef) {
5327 auto &Record = *
this;
5333 Writer->isWritingStdCXXHeaderUnit())))
5334 return Record.push_back(0);
5336 Record.push_back(A->
getKind() + 1);
5340 Record.AddSourceRange(A->
getRange());
5344 Record.push_back(A->getAttributeSpellingListIndexRaw());
5347#include "clang/Serialization/AttrPCHWrite.inc"
5353 for (
const auto *A : Attrs)
5364 if (
Tok.isAnnotation()) {
5366 switch (
Tok.getKind()) {
5367 case tok::annot_pragma_loop_hint: {
5371 Record.push_back(Info->Toks.size());
5372 for (
const auto &
T : Info->Toks)
5376 case tok::annot_pragma_pack: {
5379 Record.push_back(
static_cast<unsigned>(Info->Action));
5385 case tok::annot_pragma_openmp:
5386 case tok::annot_pragma_openmp_end:
5387 case tok::annot_pragma_unused:
5388 case tok::annot_pragma_openacc:
5389 case tok::annot_pragma_openacc_end:
5390 case tok::annot_repl_input_end:
5393 llvm_unreachable(
"missing serialization code for annotation token");
5404 Record.push_back(Str.size());
5405 llvm::append_range(
Record, Str);
5410 Record.push_back(Str.size());
5411 llvm::append_range(Blob, Str);
5415 assert(WritingAST &&
"can't prepare path for output when not writing AST");
5418 StringRef PathStr(Path.data(), Path.size());
5419 if (PathStr ==
"<built-in>" || PathStr ==
"<command line>")
5423 PP->getFileManager().makeAbsolutePath(Path,
true);
5425 const char *PathBegin = Path.data();
5426 const char *PathPtr =
5428 if (PathPtr != PathBegin) {
5429 Path.erase(Path.begin(), Path.begin() + (PathPtr - PathBegin));
5453 Stream.EmitRecordWithBlob(Abbrev,
Record, FilePath);
5458 Record.push_back(Version.getMajor());
5459 if (std::optional<unsigned> Minor = Version.getMinor())
5460 Record.push_back(*Minor + 1);
5463 if (std::optional<unsigned> Subminor = Version.getSubminor())
5464 Record.push_back(*Subminor + 1);
5482 assert(ID < IdentifierOffsets.size());
5483 IdentifierOffsets[ID] = Offset;
5489 unsigned ID = SelectorIDs[Sel];
5490 assert(ID &&
"Unknown selector");
5493 if (ID < FirstSelectorID)
5495 SelectorOffsets[ID - FirstSelectorID] = Offset;
5501 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
5502 bool IncludeTimestamps,
bool BuildingImplicitModule,
5503 bool GeneratingReducedBMI)
5504 : Stream(Stream), Buffer(Buffer), ModCache(ModCache),
5505 CodeGenOpts(CodeGenOpts), IncludeTimestamps(IncludeTimestamps),
5506 BuildingImplicitModule(BuildingImplicitModule),
5507 GeneratingReducedBMI(GeneratingReducedBMI) {
5508 for (
const auto &Ext : Extensions) {
5509 if (
auto Writer = Ext->createExtensionWriter(*
this))
5510 ModuleFileExtensionWriters.push_back(std::move(Writer));
5517 assert(WritingAST &&
"can't determine lang opts when not writing AST");
5518 return PP->getLangOpts();
5522 return IncludeTimestamps ? ModTime : 0;
5527 StringRef OutputFile,
Module *WritingModule,
5528 StringRef isysroot) {
5529 llvm::TimeTraceScope scope(
"WriteAST", OutputFile);
5532 Sema *SemaPtr = dyn_cast<Sema *>(Subject);
5539 Stream.Emit((
unsigned)
'C', 8);
5540 Stream.Emit((
unsigned)
'P', 8);
5541 Stream.Emit((
unsigned)
'C', 8);
5542 Stream.Emit((
unsigned)
'H', 8);
5544 WriteBlockInfoBlock();
5547 this->WritingModule = WritingModule;
5548 ASTFileSignature Signature = WriteASTCore(SemaPtr, isysroot, WritingModule);
5550 this->WritingModule =
nullptr;
5551 this->BaseDirectory.clear();
5558template<
typename Vector>
5560 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
5566template <
typename Vector>
5569 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
5575void ASTWriter::computeNonAffectingInputFiles() {
5576 SourceManager &SrcMgr = PP->getSourceManager();
5579 IsSLocAffecting.resize(N,
true);
5580 IsSLocFileEntryAffecting.resize(N,
true);
5585 auto AffectingModuleMaps = GetAffectingModuleMaps(*PP, WritingModule);
5587 unsigned FileIDAdjustment = 0;
5588 unsigned OffsetAdjustment = 0;
5590 NonAffectingFileIDAdjustments.reserve(N);
5591 NonAffectingOffsetAdjustments.reserve(N);
5593 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
5594 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
5596 for (
unsigned I = 1; I != N; ++I) {
5598 FileID FID = FileID::get(I);
5605 if (!
Cache->OrigEntry)
5613 if (!AffectingModuleMaps)
5617 if (AffectingModuleMaps->DefinitionFileIDs.contains(FID))
5620 IsSLocAffecting[I] =
false;
5621 IsSLocFileEntryAffecting[I] =
5622 AffectingModuleMaps->DefinitionFiles.contains(*
Cache->OrigEntry);
5624 FileIDAdjustment += 1;
5630 if (!NonAffectingFileIDs.empty() &&
5631 NonAffectingFileIDs.back().ID == FID.ID - 1) {
5632 NonAffectingFileIDs.back() = FID;
5634 NonAffectingFileIDAdjustments.back() = FileIDAdjustment;
5635 NonAffectingOffsetAdjustments.back() = OffsetAdjustment;
5639 NonAffectingFileIDs.push_back(FID);
5642 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
5643 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
5646 if (!PP->getHeaderSearchInfo().getHeaderSearchOpts().ModulesIncludeVFSUsage)
5649 FileManager &FileMgr = PP->getFileManager();
5652 for (StringRef Path :
5653 PP->getHeaderSearchInfo().getHeaderSearchOpts().VFSOverlayFiles)
5655 for (
unsigned I = 1; I != N; ++I) {
5656 if (IsSLocAffecting[I]) {
5662 if (!
Cache->OrigEntry)
5665 Cache->OrigEntry->getNameAsRequested());
5671void ASTWriter::prepareLazyUpdates() {
5674 if (!GeneratingReducedBMI)
5677 DeclUpdateMap DeclUpdatesTmp;
5685 for (
auto &DeclUpdate : DeclUpdates) {
5686 const Decl *D = DeclUpdate.first;
5688 for (
auto &
Update : DeclUpdate.second) {
5691 if (Kind == DeclUpdateKind::CXXAddedFunctionDefinition)
5692 DeclUpdatesTmp[D].push_back(
5693 ASTWriter::DeclUpdate(DeclUpdateKind::CXXAddedFunctionDefinition));
5695 DeclUpdatesLazy[D].push_back(
Update);
5698 DeclUpdates.swap(DeclUpdatesTmp);
5700 UpdatedDeclContextsLazy.swap(UpdatedDeclContexts);
5702 DeclsToEmitEvenIfUnreferenced.clear();
5705void ASTWriter::PrepareWritingSpecialDecls(
Sema &SemaRef) {
5706 ASTContext &Context = SemaRef.
Context;
5708 bool isModule = WritingModule !=
nullptr;
5710 prepareLazyUpdates();
5717 PredefinedDecls.insert(D);
5725 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
5729 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
5733 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
5735 RegisterPredefDecl(Context.BuiltinZOSVaListDecl,
5742 RegisterPredefDecl(Context.CFConstantStringTypeDecl,
5744 RegisterPredefDecl(Context.CFConstantStringTagDecl,
5746#define BuiltinTemplate(BTName) \
5747 RegisterPredefDecl(Context.Decl##BTName, PREDEF_DECL##BTName##_ID);
5748#include "clang/Basic/BuiltinTemplates.inc"
5760 if (GeneratingReducedBMI) {
5786 if (GeneratingReducedBMI)
5808 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I)
5813 SmallVector<const TypedefNameDecl *, 4> UnusedLocalTypedefs;
5815 for (
const TypedefNameDecl *TD : UnusedLocalTypedefs)
5822 "There are local ones at end of translation unit!");
5840 for (
const auto &I : SemaRef.KnownNamespaces)
5845 SmallVector<std::pair<NamedDecl *, SourceLocation>, 16>
Undefined;
5853 for (
const auto &DeleteExprsInfo :
5860 for (
const auto *I : DeclsToEmitEvenIfUnreferenced)
5862 DeclsToEmitEvenIfUnreferenced.clear();
5867 llvm::SmallVector<const IdentifierInfo*, 256> IIs;
5869 const IdentifierInfo *II =
ID.second;
5875 llvm::sort(IIs, llvm::deref<std::less<>>());
5877 for (
const IdentifierInfo *II : IIs)
5888 for (CXXRecordDecl *RD : PendingEmittingVTables)
5891 PendingEmittingVTables.clear();
5894void ASTWriter::WriteSpecialDeclRecords(
Sema &SemaRef) {
5895 ASTContext &Context = SemaRef.
Context;
5897 bool isModule = WritingModule !=
nullptr;
5900 if (!EagerlyDeserializedDecls.empty())
5903 if (!ModularCodegenDecls.empty())
5909 TentativeDefinitions);
5910 if (!TentativeDefinitions.empty())
5917 UnusedFileScopedDecls);
5918 if (!UnusedFileScopedDecls.empty())
5924 if (!ExtVectorDecls.empty())
5930 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I) {
5931 CXXRecordDecl *D = SemaRef.
VTableUses[I].first;
5945 SmallVector<const TypedefNameDecl *, 4> SortedCandidates;
5947 for (
const TypedefNameDecl *TD : SortedCandidates)
5949 if (!UnusedLocalTypedefNameCandidates.empty())
5951 UnusedLocalTypedefNameCandidates);
5953 if (!GeneratingReducedBMI) {
5963 if (!PendingInstantiations.empty())
5967 auto AddEmittedDeclRefOrZero = [
this](
RecordData &Refs,
Decl *D) {
5981 if (!SemaDeclRefs.empty())
5989 if (!DeclsToCheckForDeferredDiags.empty())
5991 DeclsToCheckForDeferredDiags);
5998 CudaCallDecl || CudaGetParamDecl || CudaLaunchDecl) {
5999 AddEmittedDeclRefOrZero(CUDASpecialDeclRefs, CudaCallDecl);
6000 AddEmittedDeclRefOrZero(CUDASpecialDeclRefs, CudaGetParamDecl);
6001 AddEmittedDeclRefOrZero(CUDASpecialDeclRefs, CudaLaunchDecl);
6009 DelegatingCtorDecls);
6010 if (!DelegatingCtorDecls.empty())
6015 for (
const auto &I : SemaRef.KnownNamespaces) {
6019 if (!KnownNamespaces.empty())
6024 SmallVector<std::pair<NamedDecl *, SourceLocation>, 16>
Undefined;
6033 if (!UndefinedButUsed.empty())
6040 for (
const auto &DeleteExprsInfo :
6045 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
6046 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
6047 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
6049 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
6053 if (!DeleteExprsToAnalyze.empty())
6057 for (CXXRecordDecl *RD : PendingEmittingVTables) {
6064 if (!VTablesToEmit.empty())
6070 using namespace llvm;
6072 bool isModule = WritingModule !=
nullptr;
6076 Chain->finalizeForWriting();
6080 computeNonAffectingInputFiles();
6082 writeUnhashedControlBlock(*PP);
6095 IdentifierIDs.clear();
6106 SmallVector<const IdentifierInfo *, 128> IIs;
6107 for (
const auto &ID : PP->getIdentifierTable())
6108 if (IsInterestingNonMacroIdentifier(
ID.second, *
this))
6109 IIs.push_back(
ID.second);
6112 llvm::sort(IIs, llvm::deref<std::less<>>());
6113 for (
const IdentifierInfo *II : IIs)
6121 for (
const auto &WeakUndeclaredIdentifierList :
6123 const IdentifierInfo *
const II = WeakUndeclaredIdentifierList.first;
6124 for (
const auto &WI : WeakUndeclaredIdentifierList.second) {
6137 ASTContext &Context = SemaPtr->
Context;
6139 Context, *
this, ExtnameUndeclaredIdentifiers);
6141 ExtnameUndeclaredIdentifiersWriter.AddIdentifierRef(II);
6142 ExtnameUndeclaredIdentifiersWriter.AddIdentifierRef(
6144 ExtnameUndeclaredIdentifiersWriter.AddSourceLocation(AL->getLocation());
6151 ASTContext &Context = SemaPtr->
Context;
6156 AddTypeRef(Context, Context.ObjCIdRedefinitionType, SpecialTypes);
6157 AddTypeRef(Context, Context.ObjCClassRedefinitionType, SpecialTypes);
6158 AddTypeRef(Context, Context.ObjCSelRedefinitionType, SpecialTypes);
6163 PrepareWritingSpecialDecls(*SemaPtr);
6166 WriteControlBlock(*PP, isysroot);
6169 Stream.FlushToWord();
6170 ASTBlockRange.first = Stream.GetCurrentBitNo() >> 3;
6172 ASTBlockStartOffset = Stream.GetCurrentBitNo();
6189 llvm::SmallVector<Selector, 256> AllSelectors;
6190 for (
auto &SelectorAndID : SelectorIDs)
6191 AllSelectors.push_back(SelectorAndID.first);
6192 for (
auto &Selector : AllSelectors)
6216 auto Abbrev = std::make_shared<BitCodeAbbrev>();
6218 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
6219 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
6220 SmallString<2048> Buffer;
6222 llvm::raw_svector_ostream
Out(Buffer);
6223 for (ModuleFile &M : Chain->ModuleMgr) {
6224 using namespace llvm::support;
6226 endian::Writer
LE(Out, llvm::endianness::little);
6234 Out.write(Name.data(), Name.size());
6240 auto writeBaseIDOrNone = [&](
auto BaseID,
bool ShouldWrite) {
6241 assert(BaseID < std::numeric_limits<uint32_t>::max() &&
"base id too high");
6255 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev,
Record,
6256 Buffer.data(), Buffer.size());
6260 WriteDeclAndTypes(SemaPtr->
Context);
6262 WriteFileDeclIDsMap();
6263 WriteSourceManagerBlock(PP->getSourceManager());
6265 WriteComments(SemaPtr->
Context);
6266 WritePreprocessor(*PP, isModule);
6267 WriteHeaderSearch(PP->getHeaderSearchInfo());
6269 WriteSelectors(*SemaPtr);
6270 WriteReferencedSelectorsPool(*SemaPtr);
6271 WriteLateParsedTemplates(*SemaPtr);
6273 WriteIdentifierTable(*PP, SemaPtr ? &SemaPtr->
IdResolver :
nullptr, isModule);
6276 WriteOpenCLExtensions(*SemaPtr);
6277 WriteCUDAPragmas(*SemaPtr);
6278 WriteRISCVIntrinsicPragmas(*SemaPtr);
6283 WriteSubmodules(WritingModule, SemaPtr ? &SemaPtr->
Context :
nullptr);
6288 WriteSpecialDeclRecords(*SemaPtr);
6291 if (!WeakUndeclaredIdentifiers.empty())
6293 WeakUndeclaredIdentifiers);
6297 if (!ExtnameUndeclaredIdentifiers.empty())
6299 ExtnameUndeclaredIdentifiers);
6301 if (!WritingModule) {
6306 ModuleInfo(uint64_t ID,
Module *M) :
ID(
ID), M(M) {}
6308 llvm::SmallVector<ModuleInfo, 64> Imports;
6311 assert(SubmoduleIDs.contains(I->getImportedModule()));
6312 Imports.push_back(ModuleInfo(SubmoduleIDs[I->getImportedModule()],
6313 I->getImportedModule()));
6317 if (!Imports.empty()) {
6318 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
6321 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
6322 return A.ID == B.ID;
6326 llvm::sort(Imports,
Cmp);
6327 Imports.erase(llvm::unique(Imports, Eq), Imports.end());
6330 for (
const auto &Import : Imports) {
6331 ImportedModules.push_back(
Import.ID);
6342 WriteObjCCategories();
6344 if (!WritingModule) {
6345 WriteOptimizePragmaOptions(*SemaPtr);
6346 WriteMSStructPragmaOptions(*SemaPtr);
6347 WriteMSPointersToMembersPragmaOptions(*SemaPtr);
6349 WritePackPragmaOptions(*SemaPtr);
6350 WriteFloatControlPragmaOptions(*SemaPtr);
6351 WriteDeclsWithEffectsToVerify(*SemaPtr);
6355 RecordData::value_type
Record[] = {NumStatements,
6357 NumLexicalDeclContexts,
6358 NumVisibleDeclContexts,
6359 NumModuleLocalDeclContexts,
6360 NumTULocalDeclContexts};
6363 Stream.FlushToWord();
6364 ASTBlockRange.second = Stream.GetCurrentBitNo() >> 3;
6368 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
6369 WriteModuleFileExtension(*SemaPtr, *ExtWriter);
6371 return backpatchSignature();
6377void ASTWriter::AddedManglingNumber(
const Decl *D,
unsigned Number) {
6381 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::ManglingNumber, Number));
6383void ASTWriter::AddedStaticLocalNumbers(
const Decl *D,
unsigned Number) {
6387 DeclUpdates[D].push_back(
6388 DeclUpdate(DeclUpdateKind::StaticLocalNumber, Number));
6397 ASTWriter::UpdateRecord &
Record = DeclUpdates[TU];
6400 DeclUpdate(DeclUpdateKind::CXXAddedAnonymousNamespace, NS));
6404void ASTWriter::WriteDeclAndTypes(
ASTContext &Context) {
6409 DeclTypesBlockStartOffset = Stream.GetCurrentBitNo();
6413 WriteDeclUpdatesBlocks(Context, DeclUpdatesOffsetsRecord);
6414 while (!DeclTypesToEmit.empty()) {
6415 DeclOrType DOT = DeclTypesToEmit.front();
6416 DeclTypesToEmit.pop();
6418 WriteType(Context, DOT.getType());
6420 WriteDecl(Context, DOT.getDecl());
6422 }
while (!DeclUpdates.empty());
6424 DoneWritingDeclsAndTypes =
true;
6428 assert(DelayedNamespace.empty() || GeneratingReducedBMI);
6430 for (NamespaceDecl *NS : DelayedNamespace) {
6431 LookupBlockOffsets Offsets;
6433 Offsets.
LexicalOffset = WriteDeclContextLexicalBlock(Context, NS);
6434 WriteDeclContextVisibleBlock(Context, NS, Offsets);
6455 assert(DeclTypesToEmit.empty());
6456 assert(DeclUpdates.empty());
6461 WriteTypeDeclOffsets();
6462 if (!DeclUpdatesOffsetsRecord.empty())
6465 if (!DelayedNamespaceRecord.empty())
6467 DelayedNamespaceRecord);
6469 if (!RelatedDeclsMap.empty()) {
6473 for (
const auto &Pair : RelatedDeclsMap) {
6474 RelatedDeclsMapRecord.push_back(Pair.first.getRawValue());
6475 RelatedDeclsMapRecord.push_back(Pair.second.size());
6476 for (
const auto &Lambda : Pair.second)
6477 RelatedDeclsMapRecord.push_back(Lambda.getRawValue());
6480 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6482 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Array));
6483 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6484 unsigned FunctionToLambdaMapAbbrev = Stream.EmitAbbrev(std::move(Abv));
6486 FunctionToLambdaMapAbbrev);
6489 if (!SpecializationsUpdates.empty()) {
6490 WriteSpecializationsUpdates(
false);
6491 SpecializationsUpdates.clear();
6494 if (!PartialSpecializationsUpdates.empty()) {
6495 WriteSpecializationsUpdates(
true);
6496 PartialSpecializationsUpdates.clear();
6502 SmallVector<DeclID, 128> NewGlobalKindDeclPairs;
6511 NewGlobalKindDeclPairs.push_back(D->
getKind());
6512 NewGlobalKindDeclPairs.push_back(
GetDeclRef(D).getRawValue());
6515 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6517 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6518 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
6521 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev,
Record,
6522 bytes(NewGlobalKindDeclPairs));
6524 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6526 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6527 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6528 UpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6530 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6532 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6533 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6534 ModuleLocalUpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6536 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6538 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6539 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6540 TULocalUpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6543 WriteDeclContextVisibleUpdate(Context, TU);
6546 if (Context.ExternCContext)
6547 WriteDeclContextVisibleUpdate(Context, Context.ExternCContext);
6550 for (
auto *DC : UpdatedDeclContexts)
6551 WriteDeclContextVisibleUpdate(Context, DC);
6554void ASTWriter::WriteSpecializationsUpdates(
bool IsPartial) {
6558 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6559 Abv->Add(llvm::BitCodeAbbrevOp(RecordType));
6560 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6561 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6562 auto UpdateSpecializationAbbrev = Stream.EmitAbbrev(std::move(Abv));
6565 IsPartial ? PartialSpecializationsUpdates : SpecializationsUpdates;
6566 for (
auto &SpecializationUpdate : SpecUpdates) {
6567 const NamedDecl *D = SpecializationUpdate.first;
6569 llvm::SmallString<4096> LookupTable;
6570 GenerateSpecializationInfoLookupTable(D, SpecializationUpdate.second,
6571 LookupTable, IsPartial);
6574 RecordData::value_type
Record[] = {
6575 static_cast<RecordData::value_type
>(RecordType),
6577 Stream.EmitRecordWithBlob(UpdateSpecializationAbbrev,
Record, LookupTable);
6581void ASTWriter::WriteDeclUpdatesBlocks(
ASTContext &Context,
6582 RecordDataImpl &OffsetsRecord) {
6583 if (DeclUpdates.empty())
6586 DeclUpdateMap LocalUpdates;
6587 LocalUpdates.swap(DeclUpdates);
6589 for (
auto &DeclUpdate : LocalUpdates) {
6590 const Decl *D = DeclUpdate.first;
6592 bool HasUpdatedBody =
false;
6593 bool HasAddedVarDefinition =
false;
6596 for (
auto &
Update : DeclUpdate.second) {
6601 if (Kind == DeclUpdateKind::CXXAddedFunctionDefinition)
6602 HasUpdatedBody =
true;
6603 else if (Kind == DeclUpdateKind::CXXAddedVarDefinition)
6604 HasAddedVarDefinition =
true;
6606 Record.push_back(llvm::to_underlying(Kind));
6609 case DeclUpdateKind::CXXAddedImplicitMember:
6610 case DeclUpdateKind::CXXAddedAnonymousNamespace:
6611 assert(
Update.getDecl() &&
"no decl to add?");
6614 case DeclUpdateKind::CXXAddedFunctionDefinition:
6615 case DeclUpdateKind::CXXAddedVarDefinition:
6618 case DeclUpdateKind::CXXPointOfInstantiation:
6623 case DeclUpdateKind::CXXInstantiatedDefaultArgument:
6628 case DeclUpdateKind::CXXInstantiatedDefaultMemberInitializer:
6633 case DeclUpdateKind::CXXInstantiatedClassDefinition: {
6635 UpdatedDeclContexts.insert(RD->getPrimaryContext());
6636 Record.push_back(RD->isParamDestroyedInCallee());
6637 Record.push_back(llvm::to_underlying(RD->getArgPassingRestrictions()));
6638 Record.AddCXXDefinitionData(RD);
6639 Record.AddOffset(WriteDeclContextLexicalBlock(Context, RD));
6644 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
6645 Record.push_back(MSInfo->getTemplateSpecializationKind());
6646 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
6649 Record.push_back(Spec->getTemplateSpecializationKind());
6650 Record.AddSourceLocation(Spec->getPointOfInstantiation());
6654 auto From = Spec->getInstantiatedFrom();
6655 if (
auto PartialSpec =
6656 From.dyn_cast<ClassTemplatePartialSpecializationDecl*>()) {
6658 Record.AddDeclRef(PartialSpec);
6659 Record.AddTemplateArgumentList(
6660 &Spec->getTemplateInstantiationArgs());
6665 Record.push_back(llvm::to_underlying(RD->getTagKind()));
6666 Record.AddSourceLocation(RD->getLocation());
6667 Record.AddSourceLocation(RD->getBeginLoc());
6668 Record.AddSourceRange(RD->getBraceRange());
6679 case DeclUpdateKind::CXXResolvedDtorDelete:
6684 case DeclUpdateKind::CXXResolvedDtorGlobDelete:
6688 case DeclUpdateKind::CXXResolvedDtorArrayDelete:
6692 case DeclUpdateKind::CXXResolvedDtorGlobArrayDelete:
6696 case DeclUpdateKind::CXXResolvedExceptionSpec: {
6699 Record.writeExceptionSpecInfo(prototype->getExceptionSpecInfo());
6703 case DeclUpdateKind::CXXDeducedReturnType:
6707 case DeclUpdateKind::DeclMarkedUsed:
6710 case DeclUpdateKind::ManglingNumber:
6711 case DeclUpdateKind::StaticLocalNumber:
6715 case DeclUpdateKind::DeclMarkedOpenMPThreadPrivate:
6717 D->
getAttr<OMPThreadPrivateDeclAttr>()->getRange());
6720 case DeclUpdateKind::DeclMarkedOpenMPAllocate: {
6721 auto *A = D->
getAttr<OMPAllocateDeclAttr>();
6722 Record.push_back(A->getAllocatorType());
6723 Record.AddStmt(A->getAllocator());
6724 Record.AddStmt(A->getAlignment());
6725 Record.AddSourceRange(A->getRange());
6729 case DeclUpdateKind::DeclMarkedOpenMPIndirectCall:
6731 D->
getAttr<OMPTargetIndirectCallAttr>()->getRange());
6734 case DeclUpdateKind::DeclMarkedOpenMPDeclareTarget:
6735 Record.push_back(D->
getAttr<OMPDeclareTargetDeclAttr>()->getMapType());
6737 D->
getAttr<OMPDeclareTargetDeclAttr>()->getRange());
6740 case DeclUpdateKind::DeclExported:
6744 case DeclUpdateKind::AddedAttrToRecord:
6745 Record.AddAttributes(llvm::ArrayRef(
Update.getAttr()));
6753 if (HasUpdatedBody) {
6756 llvm::to_underlying(DeclUpdateKind::CXXAddedFunctionDefinition));
6757 Record.push_back(Def->isInlined());
6758 Record.AddSourceLocation(Def->getInnerLocStart());
6759 Record.AddFunctionDefinition(Def);
6760 }
else if (HasAddedVarDefinition) {
6763 llvm::to_underlying(DeclUpdateKind::CXXAddedVarDefinition));
6764 Record.push_back(VD->isInline());
6765 Record.push_back(VD->isInlineSpecified());
6766 Record.AddVarDeclInit(VD);
6783 NonAffectingFileIDs.empty())
6785 auto It = llvm::lower_bound(NonAffectingFileIDs, FID);
6786 unsigned Idx = std::distance(NonAffectingFileIDs.begin(), It);
6787 unsigned Offset = NonAffectingFileIDAdjustments[Idx];
6788 return FileID::get(FID.getOpaqueValue() - Offset);
6791unsigned ASTWriter::getAdjustedNumCreatedFIDs(
FileID FID)
const {
6797 unsigned AdjustedNumCreatedFIDs = 0;
6798 for (
unsigned I = FID.ID, N = I + NumCreatedFIDs; I != N; ++I)
6799 if (IsSLocAffecting[I])
6800 ++AdjustedNumCreatedFIDs;
6801 return AdjustedNumCreatedFIDs;
6811 return SourceRange(getAdjustedLocation(
Range.getBegin()),
6812 getAdjustedLocation(
Range.getEnd()));
6817 return Offset - getAdjustment(Offset);
6822 if (NonAffectingRanges.empty())
6825 if (PP->getSourceManager().isLoadedOffset(Offset))
6828 if (Offset > NonAffectingRanges.back().getEnd().getOffset())
6829 return NonAffectingOffsetAdjustments.back();
6831 if (Offset < NonAffectingRanges.front().getBegin().getOffset())
6835 return Range.getEnd().getOffset() < Offset;
6838 auto It = llvm::lower_bound(NonAffectingRanges, Offset, Contains);
6839 unsigned Idx = std::distance(NonAffectingRanges.begin(), It);
6840 return NonAffectingOffsetAdjustments[Idx];
6844 Record.push_back(getAdjustedFileID(FID).getOpaqueValue());
6850 unsigned ModuleFileIndex = 0;
6853 if (PP->getSourceManager().isLoadedSourceLocation(Loc) && Loc.
isValid()) {
6856 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
6857 assert(SLocMapI !=
getChain()->GlobalSLocOffsetMap.end() &&
6858 "Corrupted global sloc offset map");
6863 ModuleFileIndex = F->
Index + 1;
6871 Loc = getAdjustedLocation(Loc);
6908 MacroInfoToEmitData Info = { Name, MI, ID };
6909 MacroInfosToEmit.push_back(Info);
6915 return IdentMacroDirectivesOffsetMap.lookup(Name);
6919 Record->push_back(Writer->getSelectorRef(SelRef));
6928 if (SID == 0 && Chain) {
6931 Chain->LoadSelector(Sel);
6932 SID = SelectorIDs[Sel];
6935 SID = NextSelectorID++;
6936 SelectorIDs[Sel] = SID;
6978 bool InfoHasSameExpr
6980 Record->push_back(InfoHasSameExpr);
6981 if (InfoHasSameExpr)
6998 TypeLocWriter TLW(*
this);
7008template <
typename IdxForTypeTy>
7010 IdxForTypeTy IdxForType) {
7014 unsigned FastQuals =
T.getLocalFastQualifiers();
7015 T.removeLocalFastQualifiers();
7017 if (
T.hasLocalNonFastQualifiers())
7018 return IdxForType(
T).asTypeID(FastQuals);
7020 assert(!
T.hasLocalQualifiers());
7022 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(
T.getTypePtr()))
7025 if (
T == Context.AutoDeductTy)
7027 if (
T == Context.AutoRRefDeductTy)
7030 return IdxForType(
T).asTypeID(FastQuals);
7037 assert(!
T.getLocalFastQualifiers());
7041 if (DoneWritingDeclsAndTypes) {
7042 assert(0 &&
"New type seen after serializing all the types to emit!");
7048 Idx =
TypeIdx(0, NextTypeID++);
7049 DeclTypesToEmit.push(
T);
7055llvm::MapVector<ModuleFile *, const Decl *>
7057 llvm::MapVector<ModuleFile *, const Decl *> Firsts;
7060 if (R->isFromASTFile())
7061 Firsts[Chain->getOwningModuleFile(R)] = R;
7062 else if (IncludeLocal)
7063 Firsts[
nullptr] = R;
7079 Record.push_back(MacroRef >> 32);
7080 Record.push_back(MacroRef & llvm::maskTrailingOnes<MacroID>(32));
7095 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
7112 assert(!(
reinterpret_cast<uintptr_t>(D) & 0x01) &&
"Invalid decl pointer");
7114 if (ID.isInvalid()) {
7115 if (DoneWritingDeclsAndTypes) {
7116 assert(0 &&
"New decl seen after serializing all the decls to emit!");
7123 DeclTypesToEmit.push(
const_cast<Decl *
>(D));
7138 assert(DeclIDs.contains(D) &&
"Declaration not emitted!");
7145 assert(DoneWritingDeclsAndTypes &&
7146 "wasDeclEmitted should only be called after writing declarations");
7151 bool Emitted = DeclIDs.contains(D);
7153 GeneratingReducedBMI) &&
7154 "The declaration within modules can only be omitted in reduced BMI.");
7158void ASTWriter::getLazyUpdates(
const Decl *D) {
7159 if (!GeneratingReducedBMI)
7162 if (
auto *Iter = DeclUpdatesLazy.find(D); Iter != DeclUpdatesLazy.end()) {
7163 for (DeclUpdate &
Update : Iter->second)
7164 DeclUpdates[D].push_back(
Update);
7165 DeclUpdatesLazy.erase(Iter);
7169 if (
auto *DC = dyn_cast<DeclContext>(D);
7170 DC && UpdatedDeclContextsLazy.count(DC)) {
7171 UpdatedDeclContexts.insert(DC);
7172 UpdatedDeclContextsLazy.remove(DC);
7177 assert(
ID.isValid());
7194 SourceManager &SM = PP->getSourceManager();
7201 assert(IsSLocAffecting[FID.ID]);
7203 std::unique_ptr<DeclIDInFileInfo> &Info = FileDeclIDs[FID];
7205 Info = std::make_unique<DeclIDInFileInfo>();
7207 std::pair<unsigned, LocalDeclID> LocDecl(Offset, ID);
7208 LocDeclIDsTy &Decls = Info->DeclIDs;
7209 Decls.push_back(LocDecl);
7214 "expected an anonymous declaration");
7218 auto It = AnonymousDeclarationNumbers.find(D);
7219 if (It == AnonymousDeclarationNumbers.end()) {
7222 AnonymousDeclarationNumbers[ND] = Number;
7225 It = AnonymousDeclarationNumbers.find(D);
7226 assert(It != AnonymousDeclarationNumbers.end() &&
7227 "declaration not found within its lexical context");
7282 while (QualifierLoc) {
7283 NestedNames.push_back(QualifierLoc);
7287 Record->push_back(NestedNames.size());
7288 while(!NestedNames.empty()) {
7289 QualifierLoc = NestedNames.pop_back_val();
7292 Record->push_back(llvm::to_underlying(Kind));
7295 AddDeclRef(Qualifier.getAsNamespaceAndPrefix().Namespace);
7317 llvm_unreachable(
"unexpected null nested name specifier");
7324 assert(TemplateParams &&
"No TemplateParams!");
7329 Record->push_back(TemplateParams->
size());
7330 for (
const auto &P : *TemplateParams)
7333 Record->push_back(
true);
7336 Record->push_back(
false);
7343 assert(TemplateArgs &&
"No TemplateArgs!");
7344 Record->push_back(TemplateArgs->
size());
7345 for (
int i = 0, e = TemplateArgs->
size(); i != e; ++i)
7351 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
7361 Record->push_back(
Set.size());
7363 I =
Set.begin(), E =
Set.end(); I != E; ++I) {
7365 Record->push_back(I.getAccess());
7371 Record->push_back(
Base.isVirtual());
7372 Record->push_back(
Base.isBaseOfClass());
7373 Record->push_back(
Base.getAccessSpecifierAsWritten());
7374 Record->push_back(
Base.getInheritConstructors());
7387 for (
auto &
Base : Bases)
7405 for (
auto *
Init : CtorInits) {
7406 if (
Init->isBaseInitializer()) {
7410 }
else if (
Init->isDelegatingInitializer()) {
7413 }
else if (
Init->isMemberInitializer()){
7426 if (
Init->isWritten())
7440 auto &
Data = D->data();
7442 Record->push_back(
Data.IsLambda);
7446#define FIELD(Name, Width, Merge) \
7447 if (!DefinitionBits.canWriteNextNBits(Width)) { \
7448 Record->push_back(DefinitionBits); \
7449 DefinitionBits.reset(0); \
7451 DefinitionBits.addBits(Data.Name, Width);
7453#include "clang/AST/CXXRecordDeclDefinitionBits.def"
7456 Record->push_back(DefinitionBits);
7462 bool ModulesCodegen =
7467 Record->push_back(ModulesCodegen);
7469 Writer->AddDeclRef(D, Writer->ModularCodegenDecls);
7474 Record->push_back(
Data.ComputedVisibleConversions);
7475 if (
Data.ComputedVisibleConversions)
7479 if (!
Data.IsLambda) {
7480 Record->push_back(
Data.NumBases);
7481 if (
Data.NumBases > 0)
7485 Record->push_back(
Data.NumVBases);
7486 if (
Data.NumVBases > 0)
7491 auto &Lambda = D->getLambdaData();
7494 LambdaBits.
addBits(Lambda.DependencyKind, 2);
7495 LambdaBits.
addBit(Lambda.IsGenericLambda);
7496 LambdaBits.
addBits(Lambda.CaptureDefault, 2);
7497 LambdaBits.
addBits(Lambda.NumCaptures, 15);
7498 LambdaBits.
addBit(Lambda.HasKnownInternalLinkage);
7499 Record->push_back(LambdaBits);
7501 Record->push_back(Lambda.NumExplicitCaptures);
7502 Record->push_back(Lambda.ManglingNumber);
7507 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
7514 Record->push_back(CaptureBits);
7516 switch (
Capture.getCaptureKind()) {
7546 assert(ES->CheckedForSideEffects);
7547 Val |= (ES->HasConstantInitialization ? 2 : 0);
7548 Val |= (ES->HasConstantDestruction ? 4 : 0);
7562void ASTWriter::ReaderInitialized(
ASTReader *Reader) {
7563 assert(Reader &&
"Cannot remove chain");
7564 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
7565 assert(FirstDeclID == NextDeclID &&
7566 FirstTypeID == NextTypeID &&
7567 FirstIdentID == NextIdentID &&
7568 FirstMacroID == NextMacroID &&
7569 FirstSubmoduleID == NextSubmoduleID &&
7570 FirstSelectorID == NextSelectorID &&
7571 "Setting chain after writing has started.");
7577 NextSelectorID = FirstSelectorID;
7578 NextSubmoduleID = FirstSubmoduleID;
7588 unsigned OriginalModuleFileIndex = StoredID >> 32;
7592 if (OriginalModuleFileIndex == 0 && StoredID)
7603 MacroID &StoredID = MacroIDs[MI];
7604 unsigned OriginalModuleFileIndex = StoredID >> 32;
7607 if (OriginalModuleFileIndex == 0 && StoredID)
7616void ASTWriter::TypeRead(TypeIdx Idx,
QualType T) {
7628 TypeIdx &StoredIdx = TypeIdxs[
T];
7634 if (ModuleFileIndex == 0 && StoredIdx.
getValue())
7645 DeclIDs[D] = LocalDeclID(ID);
7646 PredefinedDecls.insert(D);
7658 assert(!MacroDefinitions.contains(MD));
7659 MacroDefinitions[MD] =
ID;
7663 assert(!SubmoduleIDs.contains(Mod));
7664 SubmoduleIDs[Mod] =
ID;
7667void ASTWriter::CompletedTagDefinition(
const TagDecl *D) {
7668 if (Chain && Chain->isProcessingUpdateRecords())
return;
7670 assert(!WritingAST &&
"Already writing the AST!");
7671 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
7673 if (RD->isFromASTFile()) {
7678 "completed a tag from another module but not by instantiation?");
7679 DeclUpdates[RD].push_back(
7680 DeclUpdate(DeclUpdateKind::CXXInstantiatedClassDefinition));
7694void ASTWriter::AddedVisibleDecl(
const DeclContext *DC,
const Decl *D) {
7695 if (Chain && Chain->isProcessingUpdateRecords())
return;
7697 "Should not add lookup results to non-lookup contexts!");
7718 assert(!WritingAST &&
"Already writing the AST!");
7719 if (UpdatedDeclContexts.insert(DC) && !
cast<Decl>(DC)->isFromASTFile()) {
7723 llvm::append_range(DeclsToEmitEvenIfUnreferenced, DC->
decls());
7725 DeclsToEmitEvenIfUnreferenced.push_back(D);
7729 if (Chain && Chain->isProcessingUpdateRecords())
return;
7742 assert(!WritingAST &&
"Already writing the AST!");
7743 DeclUpdates[RD].push_back(
7744 DeclUpdate(DeclUpdateKind::CXXAddedImplicitMember, D));
7747void ASTWriter::ResolvedExceptionSpec(
const FunctionDecl *FD) {
7748 if (Chain && Chain->isProcessingUpdateRecords())
return;
7749 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
7751 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
7756 ->castAs<FunctionProtoType>()
7757 ->getExceptionSpecType()))
7758 DeclUpdates[D].push_back(DeclUpdateKind::CXXResolvedExceptionSpec);
7763 if (Chain && Chain->isProcessingUpdateRecords())
return;
7764 assert(!WritingAST &&
"Already writing the AST!");
7766 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
7767 DeclUpdates[D].push_back(
7768 DeclUpdate(DeclUpdateKind::CXXDeducedReturnType, ReturnType));
7775 if (Chain && Chain->isProcessingUpdateRecords())
return;
7776 assert(!WritingAST &&
"Already writing the AST!");
7777 assert(
Delete &&
"Not given an operator delete");
7779 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7780 DeclUpdates[D].push_back(
7781 DeclUpdate(DeclUpdateKind::CXXResolvedDtorDelete,
Delete));
7787 if (Chain && Chain->isProcessingUpdateRecords())
7789 assert(!WritingAST &&
"Already writing the AST!");
7790 assert(GlobDelete &&
"Not given an operator delete");
7793 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7794 DeclUpdates[D].push_back(
7795 DeclUpdate(DeclUpdateKind::CXXResolvedDtorGlobDelete, GlobDelete));
7801 if (Chain && Chain->isProcessingUpdateRecords())
7803 assert(!WritingAST &&
"Already writing the AST!");
7804 assert(ArrayDelete &&
"Not given an operator delete");
7807 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7808 DeclUpdates[D].push_back(
7809 DeclUpdate(DeclUpdateKind::CXXResolvedDtorArrayDelete, ArrayDelete));
7813void ASTWriter::ResolvedOperatorGlobArrayDelete(
7815 if (Chain && Chain->isProcessingUpdateRecords())
7817 assert(!WritingAST &&
"Already writing the AST!");
7818 assert(GlobArrayDelete &&
"Not given an operator delete");
7821 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7822 DeclUpdates[D].push_back(DeclUpdate(
7823 DeclUpdateKind::CXXResolvedDtorGlobArrayDelete, GlobArrayDelete));
7827void ASTWriter::CompletedImplicitDefinition(
const FunctionDecl *D) {
7828 if (Chain && Chain->isProcessingUpdateRecords())
return;
7829 assert(!WritingAST &&
"Already writing the AST!");
7838 DeclUpdates[D].push_back(
7839 DeclUpdate(DeclUpdateKind::CXXAddedFunctionDefinition));
7842void ASTWriter::VariableDefinitionInstantiated(
const VarDecl *D) {
7843 if (Chain && Chain->isProcessingUpdateRecords())
return;
7844 assert(!WritingAST &&
"Already writing the AST!");
7848 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::CXXAddedVarDefinition));
7851void ASTWriter::FunctionDefinitionInstantiated(
const FunctionDecl *D) {
7852 if (Chain && Chain->isProcessingUpdateRecords())
return;
7853 assert(!WritingAST &&
"Already writing the AST!");
7861 DeclUpdates[D].push_back(
7862 DeclUpdate(DeclUpdateKind::CXXAddedFunctionDefinition));
7865void ASTWriter::InstantiationRequested(
const ValueDecl *D) {
7866 if (Chain && Chain->isProcessingUpdateRecords())
return;
7867 assert(!WritingAST &&
"Already writing the AST!");
7874 if (
auto *VD = dyn_cast<VarDecl>(D))
7875 POI = VD->getPointOfInstantiation();
7878 DeclUpdates[D].push_back(
7879 DeclUpdate(DeclUpdateKind::CXXPointOfInstantiation, POI));
7882void ASTWriter::DefaultArgumentInstantiated(
const ParmVarDecl *D) {
7883 if (Chain && Chain->isProcessingUpdateRecords())
return;
7884 assert(!WritingAST &&
"Already writing the AST!");
7888 DeclUpdates[D].push_back(
7889 DeclUpdate(DeclUpdateKind::CXXInstantiatedDefaultArgument, D));
7892void ASTWriter::DefaultMemberInitializerInstantiated(
const FieldDecl *D) {
7893 assert(!WritingAST &&
"Already writing the AST!");
7897 DeclUpdates[D].push_back(
7898 DeclUpdate(DeclUpdateKind::CXXInstantiatedDefaultMemberInitializer, D));
7903 if (Chain && Chain->isProcessingUpdateRecords())
return;
7904 assert(!WritingAST &&
"Already writing the AST!");
7908 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
7909 ObjCClassesWithCategories.insert(
7913void ASTWriter::DeclarationMarkedUsed(
const Decl *D) {
7914 if (Chain && Chain->isProcessingUpdateRecords())
return;
7915 assert(!WritingAST &&
"Already writing the AST!");
7924 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::DeclMarkedUsed));
7927void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(
const Decl *D) {
7928 if (Chain && Chain->isProcessingUpdateRecords())
return;
7929 assert(!WritingAST &&
"Already writing the AST!");
7933 DeclUpdates[D].push_back(
7934 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPThreadPrivate));
7937void ASTWriter::DeclarationMarkedOpenMPAllocate(
const Decl *D,
const Attr *A) {
7938 if (Chain && Chain->isProcessingUpdateRecords())
return;
7939 assert(!WritingAST &&
"Already writing the AST!");
7943 DeclUpdates[D].push_back(
7944 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPAllocate, A));
7947void ASTWriter::DeclarationMarkedOpenMPIndirectCall(
const Decl *D) {
7948 if (Chain && Chain->isProcessingUpdateRecords())
7950 assert(!WritingAST &&
"Already writing the AST!");
7954 DeclUpdates[D].push_back(
7955 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPIndirectCall));
7958void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
7960 if (Chain && Chain->isProcessingUpdateRecords())
return;
7961 assert(!WritingAST &&
"Already writing the AST!");
7965 DeclUpdates[D].push_back(
7966 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPDeclareTarget, Attr));
7969void ASTWriter::RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M) {
7970 if (Chain && Chain->isProcessingUpdateRecords())
return;
7971 assert(!WritingAST &&
"Already writing the AST!");
7973 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::DeclExported, M));
7976void ASTWriter::AddedAttributeToRecord(
const Attr *
Attr,
7978 if (Chain && Chain->isProcessingUpdateRecords())
return;
7979 assert(!WritingAST &&
"Already writing the AST!");
7980 if (!
Record->isFromASTFile())
7982 DeclUpdates[
Record].push_back(
7983 DeclUpdate(DeclUpdateKind::AddedAttrToRecord, Attr));
7986void ASTWriter::AddedCXXTemplateSpecialization(
7988 assert(!WritingAST &&
"Already writing the AST!");
7992 if (Chain && Chain->isProcessingUpdateRecords())
7995 DeclsToEmitEvenIfUnreferenced.push_back(D);
7998void ASTWriter::AddedCXXTemplateSpecialization(
8000 assert(!WritingAST &&
"Already writing the AST!");
8004 if (Chain && Chain->isProcessingUpdateRecords())
8007 DeclsToEmitEvenIfUnreferenced.push_back(D);
8012 assert(!WritingAST &&
"Already writing the AST!");
8016 if (Chain && Chain->isProcessingUpdateRecords())
8019 DeclsToEmitEvenIfUnreferenced.push_back(D);
8028class OMPClauseWriter :
public OMPClauseVisitor<OMPClauseWriter> {
8033#define GEN_CLANG_CLAUSE_CLASS
8034#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
8035#include "llvm/Frontend/OpenMP/OMP.inc"
8044 OMPClauseWriter(*this).writeClause(
C);
8047void OMPClauseWriter::writeClause(
OMPClause *
C) {
8048 Record.push_back(
unsigned(
C->getClauseKind()));
8050 Record.AddSourceLocation(
C->getBeginLoc());
8051 Record.AddSourceLocation(
C->getEndLoc());
8055 Record.push_back(uint64_t(
C->getCaptureRegion()));
8056 Record.AddStmt(
C->getPreInitStmt());
8060 VisitOMPClauseWithPreInit(
C);
8061 Record.AddStmt(
C->getPostUpdateExpr());
8064void OMPClauseWriter::VisitOMPIfClause(
OMPIfClause *
C) {
8065 VisitOMPClauseWithPreInit(
C);
8067 Record.AddSourceLocation(
C->getNameModifierLoc());
8068 Record.AddSourceLocation(
C->getColonLoc());
8069 Record.AddStmt(
C->getCondition());
8070 Record.AddSourceLocation(
C->getLParenLoc());
8074 VisitOMPClauseWithPreInit(
C);
8075 Record.AddStmt(
C->getCondition());
8076 Record.AddSourceLocation(
C->getLParenLoc());
8080 Record.push_back(
C->varlist_size());
8081 Record.writeEnum(
C->getPrescriptivenessModifier());
8082 Record.AddSourceLocation(
C->getPrescriptivenessModifierLoc());
8083 Record.writeEnum(
C->getDimsModifier());
8084 Record.AddSourceLocation(
C->getDimsModifierLoc());
8085 Record.AddStmt(
C->getDimsModifierExpr());
8086 VisitOMPClauseWithPreInit(
C);
8087 Record.AddSourceLocation(
C->getLParenLoc());
8088 for (
auto *
VE :
C->varlist())
8093 Record.AddStmt(
C->getSafelen());
8094 Record.AddSourceLocation(
C->getLParenLoc());
8098 Record.AddStmt(
C->getSimdlen());
8099 Record.AddSourceLocation(
C->getLParenLoc());
8103 Record.push_back(
C->getNumSizes());
8104 for (
Expr *Size :
C->getSizesRefs())
8106 Record.AddSourceLocation(
C->getLParenLoc());
8110 Record.push_back(
C->getNumCounts());
8111 Record.push_back(
C->hasOmpFill());
8112 if (
C->hasOmpFill())
8113 Record.push_back(*
C->getOmpFillIndex());
8114 Record.AddSourceLocation(
C->getOmpFillLoc());
8115 for (
Expr *Count :
C->getCountsRefs())
8117 Record.AddSourceLocation(
C->getLParenLoc());
8121 Record.push_back(
C->getNumLoops());
8122 for (
Expr *Size :
C->getArgsRefs())
8124 Record.AddSourceLocation(
C->getLParenLoc());
8130 Record.AddStmt(
C->getFactor());
8131 Record.AddSourceLocation(
C->getLParenLoc());
8135 Record.AddStmt(
C->getFirst());
8136 Record.AddStmt(
C->getCount());
8137 Record.AddSourceLocation(
C->getLParenLoc());
8138 Record.AddSourceLocation(
C->getFirstLoc());
8139 Record.AddSourceLocation(
C->getCountLoc());
8143 Record.AddStmt(
C->getAllocator());
8144 Record.AddSourceLocation(
C->getLParenLoc());
8148 Record.AddStmt(
C->getNumForLoops());
8149 Record.AddSourceLocation(
C->getLParenLoc());
8152void OMPClauseWriter::VisitOMPDetachClause(OMPDetachClause *
C) {
8153 Record.AddStmt(
C->getEventHandler());
8154 Record.AddSourceLocation(
C->getLParenLoc());
8158 Record.push_back(
unsigned(
C->getDefaultKind()));
8159 Record.AddSourceLocation(
C->getLParenLoc());
8160 Record.AddSourceLocation(
C->getDefaultKindKwLoc());
8161 Record.push_back(
unsigned(
C->getDefaultVC()));
8162 Record.AddSourceLocation(
C->getDefaultVCLoc());
8166 Record.AddSourceLocation(
C->getLParenLoc());
8167 Record.AddSourceLocation(
C->getThreadsetKindLoc());
8168 Record.writeEnum(
C->getThreadsetKind());
8171void OMPClauseWriter::VisitOMPTransparentClause(OMPTransparentClause *
C) {
8172 Record.AddSourceLocation(
C->getLParenLoc());
8173 Record.AddStmt(
C->getImpexType());
8176void OMPClauseWriter::VisitOMPProcBindClause(OMPProcBindClause *
C) {
8177 Record.push_back(
unsigned(
C->getProcBindKind()));
8178 Record.AddSourceLocation(
C->getLParenLoc());
8179 Record.AddSourceLocation(
C->getProcBindKindKwLoc());
8182void OMPClauseWriter::VisitOMPScheduleClause(OMPScheduleClause *
C) {
8183 VisitOMPClauseWithPreInit(
C);
8184 Record.push_back(
C->getScheduleKind());
8185 Record.push_back(
C->getFirstScheduleModifier());
8186 Record.push_back(
C->getSecondScheduleModifier());
8187 Record.AddStmt(
C->getChunkSize());
8188 Record.AddSourceLocation(
C->getLParenLoc());
8189 Record.AddSourceLocation(
C->getFirstScheduleModifierLoc());
8190 Record.AddSourceLocation(
C->getSecondScheduleModifierLoc());
8191 Record.AddSourceLocation(
C->getScheduleKindLoc());
8192 Record.AddSourceLocation(
C->getCommaLoc());
8195void OMPClauseWriter::VisitOMPOrderedClause(OMPOrderedClause *
C) {
8196 Record.push_back(
C->getLoopNumIterations().size());
8197 Record.AddStmt(
C->getNumForLoops());
8198 for (
Expr *NumIter :
C->getLoopNumIterations())
8200 for (
unsigned I = 0, E =
C->getLoopNumIterations().size(); I <E; ++I)
8201 Record.AddStmt(
C->getLoopCounter(I));
8202 Record.AddSourceLocation(
C->getLParenLoc());
8205void OMPClauseWriter::VisitOMPNowaitClause(OMPNowaitClause *
C) {
8206 Record.AddStmt(
C->getCondition());
8207 Record.AddSourceLocation(
C->getLParenLoc());
8210void OMPClauseWriter::VisitOMPUntiedClause(OMPUntiedClause *) {}
8212void OMPClauseWriter::VisitOMPMergeableClause(OMPMergeableClause *) {}
8214void OMPClauseWriter::VisitOMPReadClause(OMPReadClause *) {}
8216void OMPClauseWriter::VisitOMPWriteClause(OMPWriteClause *) {}
8218void OMPClauseWriter::VisitOMPUpdateClause(OMPUpdateClause *) {}
8220void OMPClauseWriter::VisitOMPUpdateDependObjectsClause(
8221 OMPUpdateDependObjectsClause *
C) {
8222 Record.AddSourceLocation(
C->getLParenLoc());
8223 Record.AddSourceLocation(
C->getArgumentLoc());
8224 Record.writeEnum(
C->getDependencyKind());
8227void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {}
8229void OMPClauseWriter::VisitOMPCompareClause(OMPCompareClause *) {}
8232void OMPClauseWriter::VisitOMPFailClause(OMPFailClause *
C) {
8233 Record.AddSourceLocation(
C->getLParenLoc());
8234 Record.AddSourceLocation(
C->getFailParameterLoc());
8235 Record.writeEnum(
C->getFailParameter());
8238void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
8240void OMPClauseWriter::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
8242void OMPClauseWriter::VisitOMPAbsentClause(OMPAbsentClause *
C) {
8243 Record.push_back(
static_cast<uint64_t>(
C->getDirectiveKinds().size()));
8244 Record.AddSourceLocation(
C->getLParenLoc());
8245 for (
auto K :
C->getDirectiveKinds()) {
8250void OMPClauseWriter::VisitOMPHoldsClause(OMPHoldsClause *
C) {
8252 Record.AddSourceLocation(
C->getLParenLoc());
8255void OMPClauseWriter::VisitOMPContainsClause(OMPContainsClause *
C) {
8256 Record.push_back(
static_cast<uint64_t>(
C->getDirectiveKinds().size()));
8257 Record.AddSourceLocation(
C->getLParenLoc());
8258 for (
auto K :
C->getDirectiveKinds()) {
8263void OMPClauseWriter::VisitOMPNoOpenMPClause(OMPNoOpenMPClause *) {}
8265void OMPClauseWriter::VisitOMPNoOpenMPRoutinesClause(
8266 OMPNoOpenMPRoutinesClause *) {}
8268void OMPClauseWriter::VisitOMPNoOpenMPConstructsClause(
8269 OMPNoOpenMPConstructsClause *) {}
8271void OMPClauseWriter::VisitOMPNoParallelismClause(OMPNoParallelismClause *) {}
8273void OMPClauseWriter::VisitOMPAcquireClause(OMPAcquireClause *) {}
8275void OMPClauseWriter::VisitOMPReleaseClause(OMPReleaseClause *) {}
8277void OMPClauseWriter::VisitOMPRelaxedClause(OMPRelaxedClause *) {}
8279void OMPClauseWriter::VisitOMPWeakClause(OMPWeakClause *) {}
8281void OMPClauseWriter::VisitOMPThreadsClause(OMPThreadsClause *) {}
8283void OMPClauseWriter::VisitOMPSIMDClause(OMPSIMDClause *) {}
8285void OMPClauseWriter::VisitOMPNogroupClause(OMPNogroupClause *) {}
8287void OMPClauseWriter::VisitOMPInitClause(OMPInitClause *
C) {
8290 Record.push_back(
C->varlist_size());
8291 Record.push_back(
C->attrs().size());
8295 Record.writeBool(
C->getIsTarget());
8296 Record.writeBool(
C->getIsTargetSync());
8297 Record.writeBool(
C->hasPreferAttrs());
8299 for (OMPInitClause::PrefView P :
C->prefs()) {
8300 Record.push_back(P.Attrs.size());
8301 for (
Expr *A : P.Attrs)
8304 Record.AddSourceLocation(
C->getLParenLoc());
8305 Record.AddSourceLocation(
C->getVarLoc());
8308void OMPClauseWriter::VisitOMPUseClause(OMPUseClause *
C) {
8309 Record.AddStmt(
C->getInteropVar());
8310 Record.AddSourceLocation(
C->getLParenLoc());
8311 Record.AddSourceLocation(
C->getVarLoc());
8314void OMPClauseWriter::VisitOMPDestroyClause(OMPDestroyClause *
C) {
8315 Record.AddStmt(
C->getInteropVar());
8316 Record.AddSourceLocation(
C->getLParenLoc());
8317 Record.AddSourceLocation(
C->getVarLoc());
8320void OMPClauseWriter::VisitOMPNovariantsClause(OMPNovariantsClause *
C) {
8321 VisitOMPClauseWithPreInit(
C);
8322 Record.AddStmt(
C->getCondition());
8323 Record.AddSourceLocation(
C->getLParenLoc());
8326void OMPClauseWriter::VisitOMPNocontextClause(OMPNocontextClause *
C) {
8327 VisitOMPClauseWithPreInit(
C);
8328 Record.AddStmt(
C->getCondition());
8329 Record.AddSourceLocation(
C->getLParenLoc());
8332void OMPClauseWriter::VisitOMPFilterClause(OMPFilterClause *
C) {
8333 VisitOMPClauseWithPreInit(
C);
8334 Record.AddStmt(
C->getThreadID());
8335 Record.AddSourceLocation(
C->getLParenLoc());
8339 Record.AddStmt(
C->getAlignment());
8340 Record.AddSourceLocation(
C->getLParenLoc());
8343void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *
C) {
8344 Record.push_back(
C->varlist_size());
8345 Record.AddSourceLocation(
C->getLParenLoc());
8346 for (
auto *
VE :
C->varlist()) {
8349 for (
auto *
VE :
C->private_copies()) {
8354void OMPClauseWriter::VisitOMPFirstprivateClause(OMPFirstprivateClause *
C) {
8355 Record.push_back(
C->varlist_size());
8356 VisitOMPClauseWithPreInit(
C);
8357 Record.AddSourceLocation(
C->getLParenLoc());
8358 for (
auto *
VE :
C->varlist()) {
8361 for (
auto *
VE :
C->private_copies()) {
8364 for (
auto *
VE :
C->inits()) {
8369void OMPClauseWriter::VisitOMPLastprivateClause(OMPLastprivateClause *
C) {
8370 Record.push_back(
C->varlist_size());
8371 VisitOMPClauseWithPostUpdate(
C);
8372 Record.AddSourceLocation(
C->getLParenLoc());
8373 Record.writeEnum(
C->getKind());
8374 Record.AddSourceLocation(
C->getKindLoc());
8375 Record.AddSourceLocation(
C->getColonLoc());
8376 for (
auto *
VE :
C->varlist())
8378 for (
auto *E :
C->private_copies())
8380 for (
auto *E :
C->source_exprs())
8382 for (
auto *E :
C->destination_exprs())
8384 for (
auto *E :
C->assignment_ops())
8388void OMPClauseWriter::VisitOMPSharedClause(OMPSharedClause *
C) {
8389 Record.push_back(
C->varlist_size());
8390 Record.AddSourceLocation(
C->getLParenLoc());
8391 for (
auto *
VE :
C->varlist())
8395void OMPClauseWriter::VisitOMPReductionClause(OMPReductionClause *
C) {
8396 Record.push_back(
C->varlist_size());
8397 Record.writeEnum(
C->getModifier());
8398 VisitOMPClauseWithPostUpdate(
C);
8399 Record.AddSourceLocation(
C->getLParenLoc());
8400 Record.AddSourceLocation(
C->getModifierLoc());
8401 Record.AddSourceLocation(
C->getColonLoc());
8402 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
8403 Record.AddDeclarationNameInfo(
C->getNameInfo());
8404 for (
auto *
VE :
C->varlist())
8406 for (
auto *
VE :
C->privates())
8408 for (
auto *E :
C->lhs_exprs())
8410 for (
auto *E :
C->rhs_exprs())
8412 for (
auto *E :
C->reduction_ops())
8414 if (
C->getModifier() == clang::OMPC_REDUCTION_inscan) {
8415 for (
auto *E :
C->copy_ops())
8417 for (
auto *E :
C->copy_array_temps())
8419 for (
auto *E :
C->copy_array_elems())
8422 auto PrivateFlags =
C->private_var_reduction_flags();
8423 Record.push_back(std::distance(PrivateFlags.begin(), PrivateFlags.end()));
8424 for (
bool Flag : PrivateFlags)
8428void OMPClauseWriter::VisitOMPTaskReductionClause(OMPTaskReductionClause *
C) {
8429 Record.push_back(
C->varlist_size());
8430 VisitOMPClauseWithPostUpdate(
C);
8431 Record.AddSourceLocation(
C->getLParenLoc());
8432 Record.AddSourceLocation(
C->getColonLoc());
8433 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
8434 Record.AddDeclarationNameInfo(
C->getNameInfo());
8435 for (
auto *
VE :
C->varlist())
8437 for (
auto *
VE :
C->privates())
8439 for (
auto *E :
C->lhs_exprs())
8441 for (
auto *E :
C->rhs_exprs())
8443 for (
auto *E :
C->reduction_ops())
8447void OMPClauseWriter::VisitOMPInReductionClause(OMPInReductionClause *
C) {
8448 Record.push_back(
C->varlist_size());
8449 VisitOMPClauseWithPostUpdate(
C);
8450 Record.AddSourceLocation(
C->getLParenLoc());
8451 Record.AddSourceLocation(
C->getColonLoc());
8452 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
8453 Record.AddDeclarationNameInfo(
C->getNameInfo());
8454 for (
auto *
VE :
C->varlist())
8456 for (
auto *
VE :
C->privates())
8458 for (
auto *E :
C->lhs_exprs())
8460 for (
auto *E :
C->rhs_exprs())
8462 for (
auto *E :
C->reduction_ops())
8464 for (
auto *E :
C->taskgroup_descriptors())
8468void OMPClauseWriter::VisitOMPLinearClause(OMPLinearClause *
C) {
8469 Record.push_back(
C->varlist_size());
8470 VisitOMPClauseWithPostUpdate(
C);
8471 Record.AddSourceLocation(
C->getLParenLoc());
8472 Record.AddSourceLocation(
C->getColonLoc());
8473 Record.push_back(
C->getModifier());
8474 Record.AddSourceLocation(
C->getModifierLoc());
8475 for (
auto *
VE :
C->varlist()) {
8478 for (
auto *
VE :
C->privates()) {
8481 for (
auto *
VE :
C->inits()) {
8484 for (
auto *
VE :
C->updates()) {
8487 for (
auto *
VE :
C->finals()) {
8491 Record.AddStmt(
C->getCalcStep());
8492 for (
auto *
VE :
C->used_expressions())
8496void OMPClauseWriter::VisitOMPAlignedClause(OMPAlignedClause *
C) {
8497 Record.push_back(
C->varlist_size());
8498 Record.AddSourceLocation(
C->getLParenLoc());
8499 Record.AddSourceLocation(
C->getColonLoc());
8500 for (
auto *
VE :
C->varlist())
8502 Record.AddStmt(
C->getAlignment());
8505void OMPClauseWriter::VisitOMPCopyinClause(OMPCopyinClause *
C) {
8506 Record.push_back(
C->varlist_size());
8507 Record.AddSourceLocation(
C->getLParenLoc());
8508 for (
auto *
VE :
C->varlist())
8510 for (
auto *E :
C->source_exprs())
8512 for (
auto *E :
C->destination_exprs())
8514 for (
auto *E :
C->assignment_ops())
8518void OMPClauseWriter::VisitOMPCopyprivateClause(OMPCopyprivateClause *
C) {
8519 Record.push_back(
C->varlist_size());
8520 Record.AddSourceLocation(
C->getLParenLoc());
8521 for (
auto *
VE :
C->varlist())
8523 for (
auto *E :
C->source_exprs())
8525 for (
auto *E :
C->destination_exprs())
8527 for (
auto *E :
C->assignment_ops())
8531void OMPClauseWriter::VisitOMPFlushClause(OMPFlushClause *
C) {
8532 Record.push_back(
C->varlist_size());
8533 Record.AddSourceLocation(
C->getLParenLoc());
8534 for (
auto *
VE :
C->varlist())
8538void OMPClauseWriter::VisitOMPDepobjClause(OMPDepobjClause *
C) {
8539 Record.AddStmt(
C->getDepobj());
8540 Record.AddSourceLocation(
C->getLParenLoc());
8543void OMPClauseWriter::VisitOMPDependClause(OMPDependClause *
C) {
8544 Record.push_back(
C->varlist_size());
8545 Record.push_back(
C->getNumLoops());
8546 Record.AddSourceLocation(
C->getLParenLoc());
8547 Record.AddStmt(
C->getModifier());
8548 Record.push_back(
C->getDependencyKind());
8549 Record.AddSourceLocation(
C->getDependencyLoc());
8550 Record.AddSourceLocation(
C->getColonLoc());
8551 Record.AddSourceLocation(
C->getOmpAllMemoryLoc());
8552 for (
auto *
VE :
C->varlist())
8554 for (
unsigned I = 0, E =
C->getNumLoops(); I < E; ++I)
8555 Record.AddStmt(
C->getLoopData(I));
8558void OMPClauseWriter::VisitOMPDeviceClause(OMPDeviceClause *
C) {
8559 VisitOMPClauseWithPreInit(
C);
8560 Record.writeEnum(
C->getModifier());
8561 Record.AddStmt(
C->getDevice());
8562 Record.AddSourceLocation(
C->getModifierLoc());
8563 Record.AddSourceLocation(
C->getLParenLoc());
8566void OMPClauseWriter::VisitOMPMapClause(OMPMapClause *
C) {
8567 Record.push_back(
C->varlist_size());
8568 Record.push_back(
C->getUniqueDeclarationsNum());
8569 Record.push_back(
C->getTotalComponentListNum());
8570 Record.push_back(
C->getTotalComponentsNum());
8571 Record.AddSourceLocation(
C->getLParenLoc());
8572 bool HasIteratorModifier =
false;
8574 Record.push_back(
C->getMapTypeModifier(I));
8575 Record.AddSourceLocation(
C->getMapTypeModifierLoc(I));
8576 if (
C->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator)
8577 HasIteratorModifier =
true;
8579 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8580 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8581 Record.push_back(
C->getMapType());
8582 Record.AddSourceLocation(
C->getMapLoc());
8583 Record.AddSourceLocation(
C->getColonLoc());
8584 for (
auto *E :
C->varlist())
8586 for (
auto *E :
C->mapperlists())
8588 if (HasIteratorModifier)
8589 Record.AddStmt(
C->getIteratorModifier());
8590 for (
auto *D :
C->all_decls())
8592 for (
auto N :
C->all_num_lists())
8594 for (
auto N :
C->all_lists_sizes())
8596 for (
auto &M :
C->all_components()) {
8597 Record.AddStmt(M.getAssociatedExpression());
8598 Record.AddDeclRef(M.getAssociatedDeclaration());
8603 Record.push_back(
C->varlist_size());
8604 Record.writeEnum(
C->getFirstAllocateModifier());
8605 Record.writeEnum(
C->getSecondAllocateModifier());
8606 Record.AddSourceLocation(
C->getLParenLoc());
8607 Record.AddSourceLocation(
C->getColonLoc());
8608 Record.AddStmt(
C->getAllocator());
8609 Record.AddStmt(
C->getAlignment());
8610 for (
auto *
VE :
C->varlist())
8614void OMPClauseWriter::VisitOMPNumTeamsClause(OMPNumTeamsClause *
C) {
8615 Record.push_back(
C->varlist_size());
8616 Record.writeEnum(
C->getModifier());
8617 Record.AddSourceLocation(
C->getModifierLoc());
8618 Record.AddStmt(
C->getModifierExpr());
8619 VisitOMPClauseWithPreInit(
C);
8620 Record.AddSourceLocation(
C->getLParenLoc());
8621 for (
auto *
VE :
C->varlist())
8625void OMPClauseWriter::VisitOMPThreadLimitClause(OMPThreadLimitClause *
C) {
8626 Record.push_back(
C->varlist_size());
8627 Record.writeEnum(
C->getModifier());
8628 Record.AddSourceLocation(
C->getModifierLoc());
8629 Record.AddStmt(
C->getModifierExpr());
8630 VisitOMPClauseWithPreInit(
C);
8631 Record.AddSourceLocation(
C->getLParenLoc());
8632 for (
auto *
VE :
C->varlist())
8636void OMPClauseWriter::VisitOMPPriorityClause(OMPPriorityClause *
C) {
8637 VisitOMPClauseWithPreInit(
C);
8638 Record.AddStmt(
C->getPriority());
8639 Record.AddSourceLocation(
C->getLParenLoc());
8642void OMPClauseWriter::VisitOMPGrainsizeClause(OMPGrainsizeClause *
C) {
8643 VisitOMPClauseWithPreInit(
C);
8644 Record.writeEnum(
C->getModifier());
8645 Record.AddStmt(
C->getGrainsize());
8646 Record.AddSourceLocation(
C->getModifierLoc());
8647 Record.AddSourceLocation(
C->getLParenLoc());
8650void OMPClauseWriter::VisitOMPNumTasksClause(OMPNumTasksClause *
C) {
8651 VisitOMPClauseWithPreInit(
C);
8652 Record.writeEnum(
C->getModifier());
8653 Record.AddStmt(
C->getNumTasks());
8654 Record.AddSourceLocation(
C->getModifierLoc());
8655 Record.AddSourceLocation(
C->getLParenLoc());
8658void OMPClauseWriter::VisitOMPHintClause(OMPHintClause *
C) {
8660 Record.AddSourceLocation(
C->getLParenLoc());
8663void OMPClauseWriter::VisitOMPDistScheduleClause(OMPDistScheduleClause *
C) {
8664 VisitOMPClauseWithPreInit(
C);
8665 Record.push_back(
C->getDistScheduleKind());
8666 Record.AddStmt(
C->getChunkSize());
8667 Record.AddSourceLocation(
C->getLParenLoc());
8668 Record.AddSourceLocation(
C->getDistScheduleKindLoc());
8669 Record.AddSourceLocation(
C->getCommaLoc());
8672void OMPClauseWriter::VisitOMPDefaultmapClause(OMPDefaultmapClause *
C) {
8673 Record.push_back(
C->getDefaultmapKind());
8674 Record.push_back(
C->getDefaultmapModifier());
8675 Record.AddSourceLocation(
C->getLParenLoc());
8676 Record.AddSourceLocation(
C->getDefaultmapModifierLoc());
8677 Record.AddSourceLocation(
C->getDefaultmapKindLoc());
8680void OMPClauseWriter::VisitOMPToClause(OMPToClause *
C) {
8681 Record.push_back(
C->varlist_size());
8682 Record.push_back(
C->getUniqueDeclarationsNum());
8683 Record.push_back(
C->getTotalComponentListNum());
8684 Record.push_back(
C->getTotalComponentsNum());
8685 Record.AddSourceLocation(
C->getLParenLoc());
8687 Record.push_back(
C->getMotionModifier(I));
8688 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
8689 if (
C->getMotionModifier(I) == OMPC_MOTION_MODIFIER_iterator)
8690 Record.AddStmt(
C->getIteratorModifier());
8692 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8693 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8694 Record.AddSourceLocation(
C->getColonLoc());
8695 for (
auto *E :
C->varlist())
8697 for (
auto *E :
C->mapperlists())
8699 for (
auto *D :
C->all_decls())
8701 for (
auto N :
C->all_num_lists())
8703 for (
auto N :
C->all_lists_sizes())
8705 for (
auto &M :
C->all_components()) {
8706 Record.AddStmt(M.getAssociatedExpression());
8707 Record.writeBool(M.isNonContiguous());
8708 Record.AddDeclRef(M.getAssociatedDeclaration());
8712void OMPClauseWriter::VisitOMPFromClause(OMPFromClause *
C) {
8713 Record.push_back(
C->varlist_size());
8714 Record.push_back(
C->getUniqueDeclarationsNum());
8715 Record.push_back(
C->getTotalComponentListNum());
8716 Record.push_back(
C->getTotalComponentsNum());
8717 Record.AddSourceLocation(
C->getLParenLoc());
8719 Record.push_back(
C->getMotionModifier(I));
8720 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
8721 if (
C->getMotionModifier(I) == OMPC_MOTION_MODIFIER_iterator)
8722 Record.AddStmt(
C->getIteratorModifier());
8724 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8725 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8726 Record.AddSourceLocation(
C->getColonLoc());
8727 for (
auto *E :
C->varlist())
8729 for (
auto *E :
C->mapperlists())
8731 for (
auto *D :
C->all_decls())
8733 for (
auto N :
C->all_num_lists())
8735 for (
auto N :
C->all_lists_sizes())
8737 for (
auto &M :
C->all_components()) {
8738 Record.AddStmt(M.getAssociatedExpression());
8739 Record.writeBool(M.isNonContiguous());
8740 Record.AddDeclRef(M.getAssociatedDeclaration());
8744void OMPClauseWriter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *
C) {
8745 Record.push_back(
C->varlist_size());
8746 Record.push_back(
C->getUniqueDeclarationsNum());
8747 Record.push_back(
C->getTotalComponentListNum());
8748 Record.push_back(
C->getTotalComponentsNum());
8749 Record.AddSourceLocation(
C->getLParenLoc());
8750 Record.writeEnum(
C->getFallbackModifier());
8751 Record.AddSourceLocation(
C->getFallbackModifierLoc());
8752 for (
auto *E :
C->varlist())
8754 for (
auto *
VE :
C->private_copies())
8756 for (
auto *
VE :
C->inits())
8758 for (
auto *D :
C->all_decls())
8760 for (
auto N :
C->all_num_lists())
8762 for (
auto N :
C->all_lists_sizes())
8764 for (
auto &M :
C->all_components()) {
8765 Record.AddStmt(M.getAssociatedExpression());
8766 Record.AddDeclRef(M.getAssociatedDeclaration());
8770void OMPClauseWriter::VisitOMPUseDeviceAddrClause(OMPUseDeviceAddrClause *
C) {
8771 Record.push_back(
C->varlist_size());
8772 Record.push_back(
C->getUniqueDeclarationsNum());
8773 Record.push_back(
C->getTotalComponentListNum());
8774 Record.push_back(
C->getTotalComponentsNum());
8775 Record.AddSourceLocation(
C->getLParenLoc());
8776 for (
auto *E :
C->varlist())
8778 for (
auto *D :
C->all_decls())
8780 for (
auto N :
C->all_num_lists())
8782 for (
auto N :
C->all_lists_sizes())
8784 for (
auto &M :
C->all_components()) {
8785 Record.AddStmt(M.getAssociatedExpression());
8786 Record.AddDeclRef(M.getAssociatedDeclaration());
8790void OMPClauseWriter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *
C) {
8791 Record.push_back(
C->varlist_size());
8792 Record.push_back(
C->getUniqueDeclarationsNum());
8793 Record.push_back(
C->getTotalComponentListNum());
8794 Record.push_back(
C->getTotalComponentsNum());
8795 Record.AddSourceLocation(
C->getLParenLoc());
8796 for (
auto *E :
C->varlist())
8798 for (
auto *D :
C->all_decls())
8800 for (
auto N :
C->all_num_lists())
8802 for (
auto N :
C->all_lists_sizes())
8804 for (
auto &M :
C->all_components()) {
8805 Record.AddStmt(M.getAssociatedExpression());
8806 Record.AddDeclRef(M.getAssociatedDeclaration());
8810void OMPClauseWriter::VisitOMPHasDeviceAddrClause(OMPHasDeviceAddrClause *
C) {
8811 Record.push_back(
C->varlist_size());
8812 Record.push_back(
C->getUniqueDeclarationsNum());
8813 Record.push_back(
C->getTotalComponentListNum());
8814 Record.push_back(
C->getTotalComponentsNum());
8815 Record.AddSourceLocation(
C->getLParenLoc());
8816 for (
auto *E :
C->varlist())
8818 for (
auto *D :
C->all_decls())
8820 for (
auto N :
C->all_num_lists())
8822 for (
auto N :
C->all_lists_sizes())
8824 for (
auto &M :
C->all_components()) {
8825 Record.AddStmt(M.getAssociatedExpression());
8826 Record.AddDeclRef(M.getAssociatedDeclaration());
8830void OMPClauseWriter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {}
8832void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
8833 OMPUnifiedSharedMemoryClause *) {}
8835void OMPClauseWriter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
8838OMPClauseWriter::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
8841void OMPClauseWriter::VisitOMPAtomicDefaultMemOrderClause(
8842 OMPAtomicDefaultMemOrderClause *
C) {
8843 Record.push_back(
C->getAtomicDefaultMemOrderKind());
8844 Record.AddSourceLocation(
C->getLParenLoc());
8845 Record.AddSourceLocation(
C->getAtomicDefaultMemOrderKindKwLoc());
8848void OMPClauseWriter::VisitOMPSelfMapsClause(OMPSelfMapsClause *) {}
8850void OMPClauseWriter::VisitOMPAtClause(OMPAtClause *
C) {
8851 Record.push_back(
C->getAtKind());
8852 Record.AddSourceLocation(
C->getLParenLoc());
8853 Record.AddSourceLocation(
C->getAtKindKwLoc());
8856void OMPClauseWriter::VisitOMPSeverityClause(OMPSeverityClause *
C) {
8857 Record.push_back(
C->getSeverityKind());
8858 Record.AddSourceLocation(
C->getLParenLoc());
8859 Record.AddSourceLocation(
C->getSeverityKindKwLoc());
8862void OMPClauseWriter::VisitOMPMessageClause(OMPMessageClause *
C) {
8863 VisitOMPClauseWithPreInit(
C);
8864 Record.AddStmt(
C->getMessageString());
8865 Record.AddSourceLocation(
C->getLParenLoc());
8868void OMPClauseWriter::VisitOMPNontemporalClause(OMPNontemporalClause *
C) {
8869 Record.push_back(
C->varlist_size());
8870 Record.AddSourceLocation(
C->getLParenLoc());
8871 for (
auto *
VE :
C->varlist())
8873 for (
auto *E :
C->private_refs())
8877void OMPClauseWriter::VisitOMPInclusiveClause(OMPInclusiveClause *
C) {
8878 Record.push_back(
C->varlist_size());
8879 Record.AddSourceLocation(
C->getLParenLoc());
8880 for (
auto *
VE :
C->varlist())
8884void OMPClauseWriter::VisitOMPExclusiveClause(OMPExclusiveClause *
C) {
8885 Record.push_back(
C->varlist_size());
8886 Record.AddSourceLocation(
C->getLParenLoc());
8887 for (
auto *
VE :
C->varlist())
8891void OMPClauseWriter::VisitOMPOrderClause(OMPOrderClause *
C) {
8892 Record.writeEnum(
C->getKind());
8893 Record.writeEnum(
C->getModifier());
8894 Record.AddSourceLocation(
C->getLParenLoc());
8895 Record.AddSourceLocation(
C->getKindKwLoc());
8896 Record.AddSourceLocation(
C->getModifierKwLoc());
8899void OMPClauseWriter::VisitOMPUsesAllocatorsClause(OMPUsesAllocatorsClause *
C) {
8900 Record.push_back(
C->getNumberOfAllocators());
8901 Record.AddSourceLocation(
C->getLParenLoc());
8902 for (
unsigned I = 0, E =
C->getNumberOfAllocators(); I < E; ++I) {
8903 OMPUsesAllocatorsClause::Data
Data =
C->getAllocatorData(I);
8911void OMPClauseWriter::VisitOMPAffinityClause(OMPAffinityClause *
C) {
8912 Record.push_back(
C->varlist_size());
8913 Record.AddSourceLocation(
C->getLParenLoc());
8914 Record.AddStmt(
C->getModifier());
8915 Record.AddSourceLocation(
C->getColonLoc());
8916 for (
Expr *E :
C->varlist())
8920void OMPClauseWriter::VisitOMPBindClause(OMPBindClause *
C) {
8921 Record.writeEnum(
C->getBindKind());
8922 Record.AddSourceLocation(
C->getLParenLoc());
8923 Record.AddSourceLocation(
C->getBindKindLoc());
8926void OMPClauseWriter::VisitOMPXDynCGroupMemClause(OMPXDynCGroupMemClause *
C) {
8927 VisitOMPClauseWithPreInit(
C);
8929 Record.AddSourceLocation(
C->getLParenLoc());
8932void OMPClauseWriter::VisitOMPDynGroupprivateClause(
8933 OMPDynGroupprivateClause *
C) {
8934 VisitOMPClauseWithPreInit(
C);
8935 Record.push_back(
C->getDynGroupprivateModifier());
8936 Record.push_back(
C->getDynGroupprivateFallbackModifier());
8938 Record.AddSourceLocation(
C->getLParenLoc());
8939 Record.AddSourceLocation(
C->getDynGroupprivateModifierLoc());
8940 Record.AddSourceLocation(
C->getDynGroupprivateFallbackModifierLoc());
8943void OMPClauseWriter::VisitOMPDoacrossClause(OMPDoacrossClause *
C) {
8944 Record.push_back(
C->varlist_size());
8945 Record.push_back(
C->getNumLoops());
8946 Record.AddSourceLocation(
C->getLParenLoc());
8947 Record.push_back(
C->getDependenceType());
8948 Record.AddSourceLocation(
C->getDependenceLoc());
8949 Record.AddSourceLocation(
C->getColonLoc());
8950 for (
auto *
VE :
C->varlist())
8952 for (
unsigned I = 0, E =
C->getNumLoops(); I < E; ++I)
8953 Record.AddStmt(
C->getLoopData(I));
8956void OMPClauseWriter::VisitOMPXAttributeClause(OMPXAttributeClause *
C) {
8957 Record.AddAttributes(
C->getAttrs());
8958 Record.AddSourceLocation(
C->getBeginLoc());
8959 Record.AddSourceLocation(
C->getLParenLoc());
8960 Record.AddSourceLocation(
C->getEndLoc());
8963void OMPClauseWriter::VisitOMPXBareClause(OMPXBareClause *
C) {}
8967 for (
const auto &
Set : TI->
Sets) {
8974 writeExprRef(
Selector.ScoreOrCondition);
8988 for (
unsigned I = 0, E =
Data->getNumClauses(); I < E; ++I)
8990 if (
Data->hasAssociatedStmt())
8992 for (
unsigned I = 0, E =
Data->getNumChildren(); I < E; ++I)
8998 for (
Expr *E :
C->getVarList())
9004 for (
Expr *E : Exprs)
9013 switch (
C->getClauseKind()) {
9023 AddStmt(
const_cast<Expr*
>(IC->getConditionExpr()));
9030 if (SC->isConditionExprClause()) {
9032 if (SC->hasConditionExpr())
9033 AddStmt(
const_cast<Expr *
>(SC->getConditionExpr()));
9036 for (
Expr *E : SC->getVarList())
9045 for (
Expr *E : NGC->getIntExprs())
9079 static_assert(
sizeof(R) == 1 *
sizeof(
int *));
9102 static_assert(
sizeof(R) == 2 *
sizeof(
int *));
9190 if (AC->hasIntExpr())
9198 if (
Expr *DNE = WC->getDevNumExpr())
9212 if (Arg.getIdentifierInfo())
9231 for (
auto &CombinerRecipe : R.CombinerRecipes) {
9259 for (
Expr *E : TC->getSizeExprs())
9267 for (
unsigned I = 0; I < GC->getNumExprs(); ++I) {
9269 AddStmt(
const_cast<Expr *
>(GC->getExpr(I).second));
9277 if (WC->hasIntExpr())
9285 if (VC->hasIntExpr())
9306 if (BC->isStringArgument())
9315 llvm_unreachable(
"Clause serialization not yet implemented");
9317 llvm_unreachable(
"Invalid Clause Kind");
9326 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.
This file declares semantic analysis functions specific to RISC-V.
static void EmitBlockID(unsigned ID, const char *Name, llvm::BitstreamWriter &Stream, RecordDataImpl &Record)
Emits a block ID in the BLOCKINFO block.
static void EmitRecordID(unsigned ID, const char *Name, llvm::BitstreamWriter &Stream, RecordDataImpl &Record)
Emits a record ID in the BLOCKINFO block.
Defines the clang::SourceLocation class and associated facilities.
Defines implementation details of the clang::SourceManager class.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TargetOptions class.
#define IMPORT(DERIVED, BASE)
#define BLOCK(DERIVED, BASE)
Defines the clang::TypeLoc interface and its subclasses.
TypePropertyCache< Private > Cache
C Language Family Type Representation.
Defines version macros and version-related utility functions for Clang.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Contains data for OpenMP directives: clauses, children expressions/statements (helpers for codegen) a...
llvm::SmallVector< OMPTraitSet, 2 > Sets
The outermost level of selector sets.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
QualType getRawCFConstantStringType() const
Get the structure type used to representation CFStrings, or NULL if it hasn't yet been built.
QualType getucontext_tType() const
Retrieve the C ucontext_t type.
FunctionDecl * getcudaGetParameterBufferDecl()
QualType getFILEType() const
Retrieve the C FILE type.
ArrayRef< Decl * > getModuleInitializers(Module *M)
Get the initializations to perform when importing a module, if any.
const LangOptions & getLangOpts() const
RawCommentList Comments
All comments in this translation unit.
TagDecl * MSTypeInfoTagDecl
QualType getjmp_bufType() const
Retrieve the C jmp_buf type.
QualType getsigjmp_bufType() const
Retrieve the C sigjmp_buf type.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
FunctionDecl * getcudaConfigureCallDecl()
import_range local_imports() const
FunctionDecl * getcudaLaunchDeviceDecl()
Reads an AST files chain containing the contents of a translation unit.
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
const serialization::reader::ModuleLocalLookupTable * getModuleLocalLookupTables(DeclContext *Primary) const
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
Decl * getKeyDeclaration(Decl *D)
Returns the first key declaration for the given declaration.
serialization::reader::LazySpecializationInfoLookupTable * getLoadedSpecializationsLookupTables(const Decl *D, bool IsPartial)
Get the loaded specializations lookup tables for D, if any.
const serialization::reader::DeclContextLookupTable * getTULocalLookupTables(DeclContext *Primary) const
An object for streaming information to a record.
void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
void AddCXXBaseSpecifiers(ArrayRef< CXXBaseSpecifier > Bases)
Emit a set of C++ base specifiers.
void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs)
Emit a template argument list.
uint64_t Emit(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, followed by its substatements, and return its offset.
void AddCXXTemporary(const CXXTemporary *Temp)
Emit a CXXTemporary.
void writeOMPTraitInfo(const OMPTraitInfo *TI)
Write an OMPTraitInfo object.
void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Emit a C++ base specifier.
void writeOMPClause(OMPClause *C)
void writeBool(bool Value)
void AddAPValue(const APValue &Value)
Emit an APvalue.
void AddUnresolvedSet(const ASTUnresolvedSet &Set)
Emit a UnresolvedSet structure.
void AddIdentifierRef(const IdentifierInfo *II)
Emit a reference to an identifier.
void AddStmt(Stmt *S)
Add the given statement or expression to the queue of statements to emit.
void AddDeclarationName(DeclarationName Name)
Emit a declaration name.
void AddTemplateArgumentLocInfo(const TemplateArgumentLoc &Arg)
Emits a template argument location info.
void AddTypeLoc(TypeLoc TL)
Emits source location information for a type. Does not emit the type.
void AddSelectorRef(Selector S)
Emit a Selector (which is a smart pointer reference).
void writeSourceLocation(SourceLocation Loc)
void AddOffset(uint64_t BitOffset)
Add a bit offset into the record.
void AddTypeRef(QualType T)
Emit a reference to a type.
void writeOpenACCClauseList(ArrayRef< const OpenACCClause * > Clauses)
Writes out a list of OpenACC clauses.
void push_back(uint64_t N)
Minimal vector-like interface.
void AddCXXCtorInitializers(ArrayRef< CXXCtorInitializer * > CtorInits)
Emit a CXXCtorInitializer array.
void AddTemplateParameterList(const TemplateParameterList *TemplateParams)
Emit a template parameter list.
void AddTemplateArgument(const TemplateArgument &Arg)
Emit a template argument.
void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc, DeclarationName Name)
void writeOpenACCIntExprList(ArrayRef< Expr * > Exprs)
void AddTemplateName(TemplateName Name)
Emit a template name.
void AddAPFloat(const llvm::APFloat &Value)
Emit a floating-point value.
void AddTypeSourceInfo(TypeSourceInfo *TInfo)
Emits a reference to a declarator info.
void AddQualifierInfo(const QualifierInfo &Info)
void writeUInt32(uint32_t Value)
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
void writeOMPChildren(OMPChildren *Data)
Writes data related to the OpenMP directives.
void AddConceptReference(const ConceptReference *CR)
void AddSourceRange(SourceRange Range)
Emit a source range.
void AddAPInt(const llvm::APInt &Value)
Emit an integral value.
void AddSourceLocation(SourceLocation Loc)
Emit a source location.
void writeOpenACCVarList(const OpenACCClauseWithVarList *C)
void AddAttributes(ArrayRef< const Attr * > Attrs)
Emit a list of attributes.
void AddASTTemplateArgumentListInfo(const ASTTemplateArgumentListInfo *ASTTemplArgList)
Emits an AST template argument list info.
void AddCXXDefinitionData(const CXXRecordDecl *D)
void AddVarDeclInit(const VarDecl *VD)
Emit information about the initializer of a VarDecl.
void writeStmtRef(const Stmt *S)
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg)
Emits a template argument location.
void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Emit a nested name specifier with source-location information.
void AddOpenACCRoutineDeclAttr(const OpenACCRoutineDeclAttr *A)
void writeOpenACCClause(const OpenACCClause *C)
Writes out a single OpenACC Clause.
void AddAttr(const Attr *A)
An UnresolvedSet-like class which uses the ASTContext's allocator.
UnresolvedSetIterator const_iterator
Writes an AST file containing the contents of a translation unit.
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
TemplateName getNamedConcept() const
SourceLocation getTemplateKWLoc() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isFileContext() const
DeclContextLookupResult lookup_result
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isLookupContext() const
Test whether the context supports looking up names.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
StoredDeclsMap * buildLookup()
Ensure the lookup structure is fully-built and return it.
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
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.
LangStandard::Kind LangStd
The used language standard.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
std::string CurrentModule
The name of the current module, of which the main source file is a part.
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
Record the location of a macro definition.
Encapsulates changes to the "macros namespace" (the location where the macro name became active,...
const MacroDirective * getPrevious() const
Get previous definition of the macro with the same name.
const MacroInfo * getMacroInfo() const
SourceLocation getLocation() const
Encapsulates the data about a macro definition (e.g.
bool isUsed() const
Return false if this macro is defined in the main file and has not yet been used.
bool isC99Varargs() const
SourceLocation getDefinitionEndLoc() const
Return the location of the last token in the macro.
ArrayRef< const IdentifierInfo * > params() const
unsigned getNumTokens() const
Return the number of tokens that this macro expands to.
unsigned getNumParams() const
const Token & getReplacementToken(unsigned Tok) const
bool isBuiltinMacro() const
Return true if this macro requires processing before expansion.
SourceLocation getDefinitionLoc() const
Return the location that the macro was defined at.
bool hasCommaPasting() const
bool isObjectLike() const
bool isUsedForHeaderGuard() const
Determine whether this macro was used for a header guard.
bool isGNUVarargs() const
SourceLocation getExpansionLoc() const
Expr * getAttrColumnOperand() const
The attribute's column operand, if it has one.
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Expr * getAttrRowOperand() const
The attribute's row operand, if it has one.
NestedNameSpecifierLoc getQualifierLoc() const
SourceLocation getStarLoc() const
The module cache used for compiling modules implicitly.
virtual void writeExtensionContents(Sema &SemaRef, llvm::BitstreamWriter &Stream)=0
Write the contents of the extension block into the given bitstream.
ModuleFileExtension * getExtension() const
Retrieve the module file extension with which this writer is associated.
virtual ModuleFileExtensionMetadata getExtensionMetadata() const =0
Retrieves the metadata for this module file extension.
StringRef str() const
Returns the plain module file name.
void resolveHeaderDirectives(const FileEntry *File) const
Resolve all lazy header directives for the specified file.
ArrayRef< KnownHeader > findResolvedModulesForHeader(FileEntryRef File) const
Like findAllModulesForHeader, but do not attempt to infer module ownership from umbrella headers if w...
FileID getModuleMapFileIDForUniquing(const Module *M) const
Get the module map file that (along with the module name) uniquely identifies this module.
FileID getContainingModuleMapFileID(const Module *Module) const
Retrieve the module map file containing the definition of the given module.
ModuleHeaderRole
Flags describing the role of a module header.
static ModuleHeaderRole headerKindToRole(Module::HeaderKind Kind)
Convert a header kind to a role. Requires Kind to not be HK_Excluded.
Describes a module or submodule.
unsigned IsExplicit
Whether this is an explicit submodule.
SmallVector< ExportDecl, 2 > Exports
The set of export declarations.
unsigned InferSubmodules
Whether we should infer submodules for this module based on the headers.
std::vector< std::string > ConfigMacros
The set of "configuration macros", which are macros that (intentionally) change how this module is bu...
SourceLocation DefinitionLoc
The location of the module definition.
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system.
Module * Parent
The parent of this module.
ModuleKind Kind
The kind of this module.
bool isUnimportable() const
Determine whether this module has been declared unimportable.
unsigned IsInferred
Whether this is an inferred submodule (module * { ... }).
unsigned IsSystem
Whether this is a "system" module (which assumes that all headers in it are system headers).
std::string Name
The name of this module.
llvm::iterator_range< submodule_iterator > submodules()
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "C"...
unsigned ModuleMapIsPrivate
Whether this module came from a "private" module map, found next to a regular (public) module map.
llvm::SmallVector< LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used.
std::optional< Header > getUmbrellaHeaderAsWritten() const
Retrieve the umbrella header as written.
SmallVector< Requirement, 2 > Requirements
The set of language features required to use this module.
llvm::SmallSetVector< const Module *, 2 > UndeclaredUses
When NoUndeclaredIncludes is true, the set of modules this module tried to import but didn't because ...
OptionalDirectoryEntryRef Directory
The build directory of this module.
llvm::SmallVector< ModuleRef, 2 > AffectingClangModules
The set of top-level modules that affected the compilation of this module, but were not imported.
unsigned NamedModuleHasInit
Whether this C++20 named modules doesn't need an initializer.
unsigned ConfigMacrosExhaustive
Whether the set of configuration macros is exhaustive.
ASTFileSignature Signature
The module signature.
ArrayRef< Header > getHeaders(HeaderKind HK) const
unsigned InferExportWildcard
Whether, when inferring submodules, the inferr submodules should export all modules they import (e....
ArrayRef< FileEntryRef > getTopHeaders(FileManager &FileMgr)
The top-level headers associated with this module.
std::optional< DirectoryName > getUmbrellaDirAsWritten() const
Retrieve the umbrella directory as written.
unsigned IsFramework
Whether this is a framework module.
std::string ExportAsModule
The module through which entities defined in this module will eventually be exposed,...
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
llvm::SmallVector< ModuleRef, 2 > Imports
The set of modules imported by this module, and on which this module depends.
std::vector< Conflict > Conflicts
The list of conflicts.
This represents a decl that may have a name.
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
NamespaceAndPrefixLoc getAsNamespaceAndPrefix() const
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
SourceRange getLocalSourceRange() const
Retrieve the source range covering just the last part of this nested-name-specifier,...
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Kind
The kind of specifier that completes this nested name specifier.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
This represents the 'align' clause in the 'pragma omp allocate' directive.
This represents clause 'allocate' in the 'pragma omp ...' directives.
This represents 'allocator' clause in the 'pragma omp ...' directive.
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc.
Class that handles pre-initialization statement for some clauses, like 'schedule',...
This is a basic class for representing single OpenMP clause.
This represents 'collapse' clause in the 'pragma omp ...' directive.
This represents the 'counts' clause in the 'pragma omp split' directive.
This represents 'default' clause in the 'pragma omp ...' directive.
This represents 'final' clause in the 'pragma omp ...' directive.
Representation of the 'full' clause of the 'pragma omp unroll' directive.
This represents 'if' clause in the 'pragma omp ...' directive.
This class represents the 'looprange' clause in the 'pragma omp fuse' directive.
This represents 'num_threads' clause in the 'pragma omp ...' directive.
Representation of the 'partial' clause of the 'pragma omp unroll' directive.
This class represents the 'permutation' clause in the 'pragma omp interchange' directive.
This represents 'safelen' clause in the 'pragma omp ...' directive.
This represents 'simdlen' clause in the 'pragma omp ...' directive.
This represents the 'sizes' clause in the 'pragma omp tile' directive.
This represents 'threadset' clause in the 'pragma omp task ...' directive.
ObjCCategoryDecl - Represents a category declaration.
Represents an ObjC class declaration.
filtered_category_iterator< isKnownCategory > known_categories_iterator
Iterator that walks over all of the known categories and extensions, including those that are hidden.
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
SourceLocation getNameEndLoc() const
SourceLocation getNameLoc() const
SourceLocation getStarLoc() const
bool hasBaseTypeAsWritten() const
SourceLocation getTypeArgsLAngleLoc() const
unsigned getNumTypeArgs() const
unsigned getNumProtocols() const
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
SourceLocation getProtocolRAngleLoc() const
SourceLocation getProtocolLoc(unsigned i) const
SourceLocation getProtocolLAngleLoc() const
SourceLocation getTypeArgsRAngleLoc() const
const VersionTuple & getVersion() const
unsigned getNumProtocols() const
SourceLocation getProtocolLoc(unsigned i) const
SourceLocation getProtocolLAngleLoc() const
SourceLocation getProtocolRAngleLoc() const
Represents a clause with one or more 'var' objects, represented as an expr, as its arguments.
This is the base type for all OpenACC Clauses.
SourceLocation getAttrLoc() const
SourceLocation getEllipsisLoc() const
SourceLocation getEllipsisLoc() const
SourceLocation getRParenLoc() const
SourceLocation getLParenLoc() const
Represents a parameter to a function.
SourceLocation getKWLoc() const
SourceLocation getStarLoc() const
MacroDefinitionRecord * findMacroDefinition(const MacroInfo *MI)
Retrieve the macro definition that corresponds to the given MacroInfo.
const std::vector< SourceRange > & getSkippedRanges()
Retrieve all ranges that got skipped while preprocessing.
iterator local_begin()
Begin iterator for local, non-loaded, preprocessed entities.
iterator local_end()
End iterator for local, non-loaded, preprocessed entities.
std::vector< std::string > MacroIncludes
std::vector< std::string > Includes
bool WriteCommentListToPCH
Whether to write comment locations into the PCH when building it.
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
bool DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
std::vector< std::pair< std::string, bool > > Macros
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
ArrayRef< ModuleMacro * > getLeafModuleMacros(const IdentifierInfo *II) const
Get the list of leaf (non-overridden) module macros for a name.
ArrayRef< PPConditionalInfo > getPreambleConditionalStack() const
bool isRecordingPreamble() const
MacroDirective * getLocalMacroDirectiveHistory(const IdentifierInfo *II) const
Given an identifier, return the latest non-imported macro directive for that identifier.
bool SawDateOrTime() const
Returns true if the preprocessor has seen a use of DATE or TIME in the file so far.
SourceManager & getSourceManager() const
std::optional< PreambleSkipInfo > getPreambleSkipInfo() const
bool hasRecordedPreamble() const
const TargetInfo & getTargetInfo() const
FileManager & getFileManager() const
bool alreadyIncluded(FileEntryRef File) const
Return true if this header has already been included.
FileID getPredefinesFileID() const
Returns the FileID for the preprocessor predefines.
HeaderSearch & getHeaderSearchInfo() const
SmallVector< SourceLocation, 64 > serializeSafeBufferOptOutMap() const
IdentifierTable & getIdentifierTable()
const PreprocessorOptions & getPreprocessorOpts() const
Retrieve the preprocessor options used to initialize this preprocessor.
const LangOptions & getLangOpts() const
PreprocessingRecord * getPreprocessingRecord() const
Retrieve the preprocessing record, or NULL if there is no preprocessing record.
DiagnosticsEngine & getDiagnostics() const
uint32_t getCounterValue() const
SourceLocation getPreambleRecordedPragmaAssumeNonNullLoc() const
Get the location of the recorded unterminated #pragma clang assume_nonnull begin in the preamble,...
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
A (possibly-)qualified type.
Wrapper of type source information for a type with non-trivial direct qualifiers.
SourceLocation getAmpAmpLoc() const
Represents a struct/union/class.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Smart pointer class that efficiently represents Objective-C method names.
const IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
void * getAsOpaquePtr() const
unsigned getNumArgs() const
void updateOutOfDateSelector(Selector Sel)
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
bool DeclareAndesVectorBuiltins
Indicate RISC-V Andes vector builtin functions enabled or not.
bool DeclareSiFiveVectorBuiltins
Indicate RISC-V SiFive vector builtin functions enabled or not.
bool DeclareRVVBuiltins
Indicate RISC-V vector builtin functions enabled or not.
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Sema - This implements semantic analysis and AST building for C.
DelegatingCtorDeclsType DelegatingCtorDecls
All the delegating constructors seen so far in the file, used for cycle detection at the end of the T...
Preprocessor & getPreprocessor() const
PragmaStack< FPOptionsOverride > FpPragmaStack
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimizeoff". If this location is invalid,...
FPOptionsOverride CurFPFeatureOverrides()
LateParsedTemplateMapT LateParsedTemplateMap
UnusedFileScopedDeclsType UnusedFileScopedDecls
The set of file scoped decls seen so far that have not been used and must warn if not used.
SmallVector< const Decl * > DeclsWithEffectsToVerify
All functions/lambdas/blocks which have bodies and which have a non-empty FunctionEffectsRef to be ve...
EnumDecl * getStdAlignValT() const
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate > > LateParsedTemplateMapT
CXXRecordDecl * getStdBadAlloc() const
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
llvm::DenseMap< CXXRecordDecl *, bool > VTablesUsed
The set of classes whose vtables have been used within this translation unit, and a bit that will be ...
PragmaStack< AlignPackInfo > AlignPackStack
llvm::SmallSetVector< Decl *, 4 > DeclsToCheckForDeferredDiags
Function or variable declarations to be checked for whether the deferred diagnostics should be emitte...
llvm::MapVector< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
const llvm::MapVector< FieldDecl *, DeleteLocs > & getMismatchingDeleteExpressions() const
Retrieves list of suspicious delete-expressions that will be checked at the end of translation unit.
OpenCLOptions & getOpenCLOptions()
NamespaceDecl * getStdNamespace() const
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
llvm::MapVector< IdentifierInfo *, llvm::SetVector< WeakInfo, llvm::SmallVector< WeakInfo, 1u >, llvm::SmallDenseSet< WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly > > > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
void getSortedUnusedLocalTypedefNameCandidates(SmallVectorImpl< const TypedefNameDecl * > &Sorted) const
Store UnusedLocalTypedefNameCandidates in Sorted in a deterministic order.
IdentifierResolver IdResolver
static RawLocEncoding encode(SourceLocation Loc, UIntTy BaseOffset, unsigned BaseModuleFileIndex)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
FileIDAndOffset getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
DiagnosticsEngine & getDiagnostics() const
SourceLocation::UIntTy getNextLocalOffset() const
bool isLocalSourceLocation(SourceLocation Loc) const
Returns true if Loc did not come from a PCH/Module.
OptionalFileEntryRef getFileEntryRefForID(FileID FID) const
Returns the FileEntryRef for the provided FileID.
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location,...
const SrcMgr::SLocEntry & getLocalSLocEntry(unsigned Index) const
Get a local SLocEntry. This is exposed for indexing.
FileManager & getFileManager() const
unsigned local_sloc_entry_size() const
Get the number of local SLocEntries we have.
SourceLocation getLocForEndOfFile(FileID FID) const
Return the source location corresponding to the last byte of the specified file.
FileID getMainFileID() const
Returns the FileID of the main source file.
unsigned getFileIDSize(FileID FID) const
The size of the SLocEntry that FID represents.
bool hasLineTable() const
Determine if the source manager has a line table.
bool isLoadedFileID(FileID FID) const
Returns true if FID came from a PCH/Module.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
LineTableInfo & getLineTable()
Retrieve the stored line table.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
OptionalFileEntryRef ContentsEntry
References the file which the contents were actually loaded from.
unsigned IsTransient
True if this file may be transient, that is, if it might not exist at some later point in time when t...
std::optional< llvm::MemoryBufferRef > getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM, SourceLocation Loc=SourceLocation()) const
Returns the memory buffer for the associated content.
unsigned BufferOverridden
Indicates whether the buffer itself was provided to override the actual file contents.
OptionalFileEntryRef OrigEntry
Reference to the file entry representing this ContentCache.
SourceLocation getExpansionLocStart() const
bool isExpansionTokenRange() const
SourceLocation getSpellingLoc() const
bool isMacroArgExpansion() const
SourceLocation getExpansionLocEnd() const
const ContentCache & getContentCache() const
SourceLocation::UIntTy getOffset() const
const FileInfo & getFile() const
const ExpansionInfo & getExpansion() const
An array of decls optimized for the common case of only containing one entry.
StringLiteral - This represents a string literal expression, e.g.
Represents the declaration of a struct/union/class/enum.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
SourceLocation getNameLoc() const
SourceLocation getElaboratedKeywordLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
TargetOptions & getTargetOpts() const
Retrieve the target options.
std::string Triple
The name of the target triple to compile for.
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings starting...
std::string ABI
If given, the name of the target ABI to use.
std::string TuneCPU
If given, the name of the target CPU to tune code for.
std::string CPU
If given, the name of the target CPU to generate code for.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line.
A template argument list.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
Location wrapper for a TemplateArgument.
SourceLocation getTemplateEllipsisLoc() const
TemplateArgumentLocInfo getLocInfo() const
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKWLoc() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
Stores a list of template parameters for a TemplateDecl and its derived classes.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
SourceLocation getTemplateLoc() const
unsigned getNumArgs() const
SourceLocation getLAngleLoc() const
TemplateArgumentLoc getArgLoc(unsigned i) const
SourceLocation getRAngleLoc() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKeywordLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
SourceLocation getElaboratedKeywordLoc() const
Token - This structure provides full information about a lexed token.
The top declaration context.
NamespaceDecl * getAnonymousNamespace() const
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
TypeSourceInfo * getUnmodifiedTInfo() const
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getNameLoc() const
TypeClass getTypeClass() const
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
SourceLocation getTypeofLoc() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
const APValue * getEvaluatedValue() const
Return the already-evaluated value of this variable's initializer, or nullptr if the value is not yet...
bool hasInitWithSideEffects() const
Checks whether this declaration has an initializer with side effects.
EvaluatedStmt * getEvaluatedStmt() const
const Expr * getInit() const
Declaration of a variable template.
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getNameLoc() const
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
SourceLocation getEllipsisLoc() const
Retrieve the source location of the ellipsis, whose presence indicates that the capture is a pack exp...
OverloadedOperatorKind getOperatorKind() const
IdentifierInfo * getIdentifier() const
Selector getSelector() const
Information about a module that has been loaded by the ASTReader.
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
unsigned LocalNumSubmodules
The number of submodules in this module.
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
unsigned Index
The index of this module in the list of modules.
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
SourceLocation::UIntTy SLocEntryBaseOffset
The base offset in the source manager's view of this module.
ModuleFileName FileName
The file name of the module file.
unsigned LocalNumSelectors
The number of selectors new to this file.
ModuleKind Kind
The type of this module.
std::string ModuleName
The name of the module.
A type index; the type ID with the qualifier bits removed.
uint32_t getModuleFileIndex() const
TypeID asTypeID(unsigned FastQuals) const
uint64_t getValue() const
SmallVector< LazySpecializationInfo, 4 > data_type
The lookup result is a list of global declaration IDs.
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
TypeCode
Record codes for each kind of type.
const unsigned int DECL_UPDATES
Record of updates for a declaration that was modified after being deserialized.
@ PREDEF_TYPE_AUTO_RREF_DEDUCT
The "auto &&" deduction type.
@ PREDEF_TYPE_NULL_ID
The NULL type.
@ PREDEF_TYPE_AUTO_DEDUCT
The "auto" deduction type.
@ CTOR_INITIALIZER_MEMBER
@ CTOR_INITIALIZER_DELEGATING
@ CTOR_INITIALIZER_INDIRECT_MEMBER
@ DECL_EMPTY
An EmptyDecl record.
@ DECL_CXX_BASE_SPECIFIERS
A record containing CXXBaseSpecifiers.
@ DECL_CXX_RECORD
A CXXRecordDecl record.
@ DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION
A VarTemplatePartialSpecializationDecl record.
@ DECL_OMP_ALLOCATE
An OMPAllocateDcl record.
@ DECL_MS_PROPERTY
A MSPropertyDecl record.
@ DECL_REQUIRES_EXPR_BODY
A RequiresExprBodyDecl record.
@ DECL_STATIC_ASSERT
A StaticAssertDecl record.
@ DECL_INDIRECTFIELD
A IndirectFieldDecl record.
@ DECL_TEMPLATE_TEMPLATE_PARM
A TemplateTemplateParmDecl record.
@ DECL_IMPORT
An ImportDecl recording a module import.
@ DECL_ACCESS_SPEC
An AccessSpecDecl record.
@ DECL_OBJC_TYPE_PARAM
An ObjCTypeParamDecl record.
@ DECL_OBJC_CATEGORY_IMPL
A ObjCCategoryImplDecl record.
@ DECL_ENUM_CONSTANT
An EnumConstantDecl record.
@ DECL_PARM_VAR
A ParmVarDecl record.
@ DECL_TYPEDEF
A TypedefDecl record.
@ DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack.
@ DECL_HLSL_BUFFER
A HLSLBufferDecl record.
@ DECL_NAMESPACE_ALIAS
A NamespaceAliasDecl record.
@ DECL_TYPEALIAS
A TypeAliasDecl record.
@ DECL_FUNCTION_TEMPLATE
A FunctionTemplateDecl record.
@ DECL_UNRESOLVED_USING_TYPENAME
An UnresolvedUsingTypenameDecl record.
@ DECL_CLASS_TEMPLATE_SPECIALIZATION
A ClassTemplateSpecializationDecl record.
@ DECL_FILE_SCOPE_ASM
A FileScopeAsmDecl record.
@ DECL_PARTIAL_SPECIALIZATIONS
@ DECL_CXX_CONSTRUCTOR
A CXXConstructorDecl record.
@ DECL_CXX_CONVERSION
A CXXConversionDecl record.
@ DECL_FIELD
A FieldDecl record.
@ DECL_LINKAGE_SPEC
A LinkageSpecDecl record.
@ DECL_CONTEXT_TU_LOCAL_VISIBLE
A record that stores the set of declarations that are only visible to the TU.
@ DECL_NAMESPACE
A NamespaceDecl record.
@ DECL_NON_TYPE_TEMPLATE_PARM
A NonTypeTemplateParmDecl record.
@ DECL_FUNCTION
A FunctionDecl record.
@ DECL_USING_DIRECTIVE
A UsingDirecitveDecl record.
@ DECL_RECORD
A RecordDecl record.
@ DECL_CONTEXT_LEXICAL
A record that stores the set of declarations that are lexically stored within a given DeclContext.
@ DECL_BLOCK
A BlockDecl record.
@ DECL_UNRESOLVED_USING_VALUE
An UnresolvedUsingValueDecl record.
@ DECL_TYPE_ALIAS_TEMPLATE
A TypeAliasTemplateDecl record.
@ DECL_CXX_CTOR_INITIALIZERS
A record containing CXXCtorInitializers.
@ DECL_OBJC_CATEGORY
A ObjCCategoryDecl record.
@ DECL_VAR
A VarDecl record.
@ DECL_USING
A UsingDecl record.
@ DECL_OBJC_PROTOCOL
A ObjCProtocolDecl record.
@ DECL_TEMPLATE_TYPE_PARM
A TemplateTypeParmDecl record.
@ DECL_VAR_TEMPLATE_SPECIALIZATION
A VarTemplateSpecializationDecl record.
@ DECL_OBJC_IMPLEMENTATION
A ObjCImplementationDecl record.
@ DECL_OBJC_COMPATIBLE_ALIAS
A ObjCCompatibleAliasDecl record.
@ DECL_FRIEND_TEMPLATE
A FriendTemplateDecl record.
@ DECL_PRAGMA_DETECT_MISMATCH
A PragmaDetectMismatchDecl record.
@ DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack.
@ DECL_OBJC_AT_DEFS_FIELD
A ObjCAtDefsFieldDecl record.
@ DECL_IMPLICIT_PARAM
An ImplicitParamDecl record.
@ DECL_FRIEND
A FriendDecl record.
@ DECL_CXX_METHOD
A CXXMethodDecl record.
@ DECL_EXPORT
An ExportDecl record.
@ DECL_PRAGMA_COMMENT
A PragmaCommentDecl record.
@ DECL_ENUM
An EnumDecl record.
@ DECL_CONTEXT_MODULE_LOCAL_VISIBLE
A record containing the set of declarations that are only visible from DeclContext in the same module...
@ DECL_OMP_DECLARE_REDUCTION
An OMPDeclareReductionDecl record.
@ DECL_OMP_THREADPRIVATE
An OMPThreadPrivateDecl record.
@ DECL_OBJC_METHOD
A ObjCMethodDecl record.
@ DECL_CXX_DESTRUCTOR
A CXXDestructorDecl record.
@ DECL_OMP_CAPTUREDEXPR
An OMPCapturedExprDecl record.
@ DECL_CLASS_TEMPLATE
A ClassTemplateDecl record.
@ DECL_USING_SHADOW
A UsingShadowDecl record.
@ DECL_CONCEPT
A ConceptDecl record.
@ DECL_OBJC_IVAR
A ObjCIvarDecl record.
@ DECL_OBJC_PROPERTY
A ObjCPropertyDecl record.
@ DECL_OBJC_INTERFACE
A ObjCInterfaceDecl record.
@ DECL_VAR_TEMPLATE
A VarTemplateDecl record.
@ DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION
A ClassTemplatePartialSpecializationDecl record.
@ DECL_CONTEXT_VISIBLE
A record that stores the set of declarations that are visible from a given DeclContext.
@ DECL_OBJC_PROPERTY_IMPL
A ObjCPropertyImplDecl record.
@ TYPE_EXT_QUAL
An ExtQualType record.
@ EXPR_DESIGNATED_INIT
A DesignatedInitExpr record.
@ EXPR_COMPOUND_LITERAL
A CompoundLiteralExpr record.
@ EXPR_OBJC_IVAR_REF_EXPR
An ObjCIvarRefExpr record.
@ EXPR_MEMBER
A MemberExpr record.
@ EXPR_CXX_TEMPORARY_OBJECT
A CXXTemporaryObjectExpr record.
@ EXPR_CXX_UNRESOLVED_LOOKUP
@ EXPR_COMPOUND_ASSIGN_OPERATOR
A CompoundAssignOperator record.
@ EXPR_EXPR_WITH_CLEANUPS
@ EXPR_CXX_STATIC_CAST
A CXXStaticCastExpr record.
@ EXPR_OBJC_STRING_LITERAL
An ObjCStringLiteral record.
@ EXPR_VA_ARG
A VAArgExpr record.
@ EXPR_CXX_OPERATOR_CALL
A CXXOperatorCallExpr record.
@ STMT_OBJC_AT_TRY
An ObjCAtTryStmt record.
@ EXPR_CXX_UNRESOLVED_CONSTRUCT
@ EXPR_FIXEDPOINT_LITERAL
@ STMT_DO
A DoStmt record.
@ STMT_OBJC_CATCH
An ObjCAtCatchStmt record.
@ STMT_IF
An IfStmt record.
@ EXPR_CXX_EXPRESSION_TRAIT
@ EXPR_STRING_LITERAL
A StringLiteral record.
@ EXPR_IMPLICIT_CAST
An ImplicitCastExpr record.
@ STMT_GCCASM
A GCC-style AsmStmt record.
@ EXPR_IMAGINARY_LITERAL
An ImaginaryLiteral record.
@ STMT_WHILE
A WhileStmt record.
@ EXPR_STMT
A StmtExpr record.
@ EXPR_CXX_REINTERPRET_CAST
A CXXReinterpretCastExpr record.
@ EXPR_DESIGNATED_INIT_UPDATE
A DesignatedInitUpdateExpr record.
@ STMT_OBJC_AT_SYNCHRONIZED
An ObjCAtSynchronizedStmt record.
@ EXPR_CXX_PSEUDO_DESTRUCTOR
@ EXPR_CHARACTER_LITERAL
A CharacterLiteral record.
@ EXPR_OBJC_ENCODE
An ObjCEncodeExpr record.
@ EXPR_CSTYLE_CAST
A CStyleCastExpr record.
@ EXPR_OBJC_BOXED_EXPRESSION
@ EXPR_OBJC_BOOL_LITERAL
An ObjCBoolLiteralExpr record.
@ EXPR_CXX_BIND_TEMPORARY
@ EXPR_EXT_VECTOR_ELEMENT
An ExtVectorElementExpr record.
@ STMT_RETURN
A ReturnStmt record.
@ STMT_OBJC_FOR_COLLECTION
An ObjCForCollectionStmt record.
@ STMT_CONTINUE
A ContinueStmt record.
@ EXPR_PREDEFINED
A PredefinedExpr record.
@ EXPR_CXX_BOOL_LITERAL
A CXXBoolLiteralExpr record.
@ EXPR_PAREN_LIST
A ParenListExpr record.
@ EXPR_CXX_PAREN_LIST_INIT
A CXXParenListInitExpr record.
@ STMT_COMPOUND
A CompoundStmt record.
@ STMT_FOR
A ForStmt record.
@ STMT_ATTRIBUTED
An AttributedStmt record.
@ EXPR_CXX_REWRITTEN_BINARY_OPERATOR
A CXXRewrittenBinaryOperator record.
@ STMT_GOTO
A GotoStmt record.
@ EXPR_NO_INIT
An NoInitExpr record.
@ EXPR_OBJC_ARRAY_LITERAL
@ EXPR_OBJC_PROTOCOL_EXPR
An ObjCProtocolExpr record.
@ EXPR_CXX_CONSTRUCT
A CXXConstructExpr record.
@ EXPR_OBJC_DICTIONARY_LITERAL
@ EXPR_CXX_DYNAMIC_CAST
A CXXDynamicCastExpr record.
@ STMT_CXX_TRY
A CXXTryStmt record.
@ EXPR_GENERIC_SELECTION
A GenericSelectionExpr record.
@ EXPR_CALL
A CallExpr record.
@ EXPR_GNU_NULL
A GNUNullExpr record.
@ EXPR_BINARY_CONDITIONAL_OPERATOR
@ EXPR_OBJC_PROPERTY_REF_EXPR
An ObjCPropertyRefExpr record.
@ EXPR_CXX_CONST_CAST
A CXXConstCastExpr record.
@ STMT_REF_PTR
A reference to a previously [de]serialized Stmt record.
@ EXPR_OBJC_MESSAGE_EXPR
An ObjCMessageExpr record.
@ EXPR_CXX_DEPENDENT_SCOPE_DECL_REF
@ STMT_CASE
A CaseStmt record.
@ EXPR_FUNCTION_PARM_PACK
@ STMT_STOP
A marker record that indicates that we are at the end of an expression.
@ EXPR_CXX_NULL_PTR_LITERAL
@ STMT_MSASM
A MS-style AsmStmt record.
@ EXPR_CONDITIONAL_OPERATOR
A ConditionOperator record.
@ EXPR_BINARY_OPERATOR
A BinaryOperator record.
@ EXPR_CXX_STD_INITIALIZER_LIST
A CXXStdInitializerListExpr record.
@ EXPR_SHUFFLE_VECTOR
A ShuffleVectorExpr record.
@ STMT_OBJC_FINALLY
An ObjCAtFinallyStmt record.
@ EXPR_OBJC_SELECTOR_EXPR
An ObjCSelectorExpr record.
@ EXPR_FLOATING_LITERAL
A FloatingLiteral record.
@ EXPR_CXX_DEPENDENT_SCOPE_MEMBER
@ STMT_NULL_PTR
A NULL expression.
@ STMT_DEFAULT
A DefaultStmt record.
@ EXPR_CHOOSE
A ChooseExpr record.
@ STMT_NULL
A NullStmt record.
@ EXPR_DECL_REF
A DeclRefExpr record.
@ EXPR_SUBST_NON_TYPE_TEMPLATE_PARM
@ EXPR_INIT_LIST
An InitListExpr record.
@ EXPR_IMPLICIT_VALUE_INIT
An ImplicitValueInitExpr record.
@ EXPR_PAREN
A ParenExpr record.
@ EXPR_DEPENDENT_TEMPLATE_ID
@ STMT_LABEL
A LabelStmt record.
@ EXPR_CXX_FUNCTIONAL_CAST
A CXXFunctionalCastExpr record.
@ EXPR_USER_DEFINED_LITERAL
A UserDefinedLiteral record.
@ EXPR_INTEGER_LITERAL
An IntegerLiteral record.
@ EXPR_MATERIALIZE_TEMPORARY
@ EXPR_CXX_MEMBER_CALL
A CXXMemberCallExpr record.
@ STMT_SWITCH
A SwitchStmt record.
@ STMT_DECL
A DeclStmt record.
@ EXPR_CXX_UNRESOLVED_MEMBER
@ EXPR_OBJC_KVC_REF_EXPR
UNUSED.
@ EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK
@ EXPR_CXX_SCALAR_VALUE_INIT
@ EXPR_SIZEOF_ALIGN_OF
A SizefAlignOfExpr record.
@ STMT_BREAK
A BreakStmt record.
@ STMT_OBJC_AT_THROW
An ObjCAtThrowStmt record.
@ EXPR_ADDR_LABEL
An AddrLabelExpr record.
@ STMT_CXX_FOR_RANGE
A CXXForRangeStmt record.
@ EXPR_CXX_ADDRSPACE_CAST
A CXXAddrspaceCastExpr record.
@ EXPR_ARRAY_SUBSCRIPT
An ArraySubscriptExpr record.
@ EXPR_UNARY_OPERATOR
A UnaryOperator record.
@ STMT_CXX_CATCH
A CXXCatchStmt record.
@ STMT_INDIRECT_GOTO
An IndirectGotoStmt record.
Defines the clang::TargetInfo interface.
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
bool isModuleMap(CharacteristicKind CK)
Determine whether a file characteristic is for a module map.
bool LE(InterpState &S, CodePtr OpPC)
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
GlobalDeclID LazySpecializationInfo
@ EXTENSION_METADATA
Metadata describing this particular extension.
@ SUBMODULE_EXCLUDED_HEADER
Specifies a header that has been explicitly excluded from this submodule.
@ SUBMODULE_TOPHEADER
Specifies a top-level header that falls into this (sub)module.
@ SUBMODULE_PRIVATE_TEXTUAL_HEADER
Specifies a header that is private to this submodule but must be textually included.
@ SUBMODULE_HEADER
Specifies a header that falls into this (sub)module.
@ SUBMODULE_EXPORT_AS
Specifies the name of the module that will eventually re-export the entities in this module.
@ SUBMODULE_UMBRELLA_DIR
Specifies an umbrella directory.
@ SUBMODULE_UMBRELLA_HEADER
Specifies the umbrella header used to create this module, if any.
@ SUBMODULE_REQUIRES
Specifies a required feature.
@ SUBMODULE_PRIVATE_HEADER
Specifies a header that is private to this submodule.
@ SUBMODULE_IMPORTS
Specifies the submodules that are imported by this submodule.
@ SUBMODULE_CONFLICT
Specifies a conflict with another module.
@ SUBMODULE_CHILD
Specifies a direct submodule by name and ID, enabling on-demand deserialization of children without l...
@ SUBMODULE_INITIALIZERS
Specifies some declarations with initializers that must be emitted to initialize the module.
@ SUBMODULE_END
Defines the end of a single submodule. Sentinel record without any data.
@ SUBMODULE_DEFINITION
Defines the major attributes of a submodule, including its name and parent.
@ SUBMODULE_LINK_LIBRARY
Specifies a library or framework to link against.
@ SUBMODULE_CONFIG_MACRO
Specifies a configuration macro for this module.
@ SUBMODULE_EXPORTS
Specifies the submodules that are re-exported from this submodule.
@ SUBMODULE_TEXTUAL_HEADER
Specifies a header that is part of the module but must be textually included.
@ SUBMODULE_AFFECTING_MODULES
Specifies affecting modules that were not imported.
TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT)
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
@ UserFiles
When the validation is done only for user files as an optimization.
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
@ FILE_SYSTEM_OPTIONS
Record code for the filesystem options table.
@ TARGET_OPTIONS
Record code for the target options table.
@ PREPROCESSOR_OPTIONS
Record code for the preprocessor options table.
@ HEADER_SEARCH_OPTIONS
Record code for the headers search options table.
@ CODEGEN_OPTIONS
Record code for the codegen options table.
@ LANGUAGE_OPTIONS
Record code for the language options table.
const unsigned int NUM_PREDEF_PP_ENTITY_IDS
The number of predefined preprocessed entity IDs.
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
@ SUBMODULE_BLOCK_ID
The block containing the submodule structure.
@ PREPROCESSOR_DETAIL_BLOCK_ID
The block containing the detailed preprocessing record.
@ AST_BLOCK_ID
The AST block, which acts as a container around the full AST block.
@ SOURCE_MANAGER_BLOCK_ID
The block containing information about the source manager.
@ CONTROL_BLOCK_ID
The control block, which contains all of the information that needs to be validated prior to committi...
@ DECLTYPES_BLOCK_ID
The block containing the definitions of all of the types and decls used within the AST file.
@ PREPROCESSOR_BLOCK_ID
The block containing information about the preprocessor.
@ COMMENTS_BLOCK_ID
The block containing comments.
@ UNHASHED_CONTROL_BLOCK_ID
A block with unhashed content.
@ EXTENSION_BLOCK_ID
A block containing a module file extension.
@ OPTIONS_BLOCK_ID
The block of configuration options, used to check that a module is being used in a configuration comp...
@ INPUT_FILES_BLOCK_ID
The block of input files, which were used as inputs to create this AST file.
unsigned StableHashForTemplateArguments(llvm::ArrayRef< TemplateArgument > Args)
Calculate a stable hash value for template arguments.
DeclIDBase::DeclID DeclID
An ID number that refers to a declaration in an AST file.
const unsigned VERSION_MINOR
AST file minor version number supported by this version of Clang.
@ SM_SLOC_FILE_ENTRY
Describes a source location entry (SLocEntry) for a file.
@ SM_SLOC_BUFFER_BLOB_COMPRESSED
Describes a zlib-compressed blob that contains the data for a buffer entry.
@ SM_SLOC_BUFFER_ENTRY
Describes a source location entry (SLocEntry) for a buffer.
@ SM_SLOC_BUFFER_BLOB
Describes a blob that contains the data for a buffer entry.
@ SM_SLOC_EXPANSION_ENTRY
Describes a source location entry (SLocEntry) for a macro expansion.
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
uint64_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
@ PP_TOKEN
Describes one token.
@ PP_MACRO_FUNCTION_LIKE
A function-like macro definition.
@ PP_MACRO_OBJECT_LIKE
An object-like macro definition.
@ PP_MACRO_DIRECTIVE_HISTORY
The macro directives history for a particular identifier.
@ PP_MODULE_MACRO
A macro directive exported by a module.
void numberAnonymousDeclsWithin(const DeclContext *DC, Fn Visit)
Visit each declaration within DC that needs an anonymous declaration number and call Visit with the d...
@ MODULE_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.
Top level wrappers for InstallAPI frontend operations.
@ NUM_OVERLOADED_OPERATORS
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
@ LCK_ByRef
Capturing by reference.
@ LCK_VLAType
Capturing variable-length array type.
@ LCK_StarThis
Capturing the *this object by copy.
@ LCK_This
Capturing the *this object by reference.
@ Auto
'auto' clause, allowed on 'loop' directives.
@ Bind
'bind' clause, allowed on routine constructs.
@ Gang
'gang' clause, allowed on 'loop' and Combined constructs.
@ Wait
'wait' clause, allowed on Compute, Data, 'update', and Combined constructs.
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ PCopyOut
'copyout' clause alias 'pcopyout'. Preserved for diagnostic purposes.
@ VectorLength
'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop', and 'kernels loop' constru...
@ Async
'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined constructs.
@ PresentOrCreate
'create' clause alias 'present_or_create'.
@ Collapse
'collapse' clause, allowed on 'loop' and Combined constructs.
@ NoHost
'nohost' clause, allowed on 'routine' directives.
@ PresentOrCopy
'copy' clause alias 'present_or_copy'. Preserved for diagnostic purposes.
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Copy
'copy' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ Worker
'worker' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ DeviceType
'device_type' clause, allowed on Compute, 'data', 'init', 'shutdown', 'set', update',...
@ DefaultAsync
'default_async' clause, allowed on 'set' construct.
@ Attach
'attach' clause, allowed on Compute and Combined constructs, plus 'data' and 'enter data'.
@ Shortloop
'shortloop' is represented in the ACC.td file, but isn't present in the standard.
@ NumGangs
'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs.
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...
@ Default
'default' clause, allowed on parallel, serial, kernel (and compound) constructs.
@ UseDevice
'use_device' clause, allowed on 'host_data' construct.
@ NoCreate
'no_create' clause, allowed on allowed on Compute and Combined constructs, plus 'data'.
@ PresentOrCopyOut
'copyout' clause alias 'present_or_copyout'.
@ Link
'link' clause, allowed on 'declare' construct.
@ Reduction
'reduction' clause, allowed on Parallel, Serial, Loop, and the combined constructs.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ CopyOut
'copyout' clause, allowed on Compute and Combined constructs, plus 'data', 'exit data',...
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
@ FirstPrivate
'firstprivate' clause, allowed on 'parallel', 'serial', 'parallel loop', and 'serial loop' constructs...
@ Host
'host' clause, allowed on 'update' construct.
@ PCopy
'copy' clause alias 'pcopy'. Preserved for diagnostic purposes.
@ Tile
'tile' clause, allowed on 'loop' and Combined constructs.
@ PCopyIn
'copyin' clause alias 'pcopyin'. Preserved for diagnostic purposes.
@ DeviceResident
'device_resident' clause, allowed on the 'declare' construct.
@ PCreate
'create' clause alias 'pcreate'. Preserved for diagnostic purposes.
@ Present
'present' clause, allowed on Compute and Combined constructs, plus 'data' and 'declare'.
@ DType
'dtype' clause, an alias for 'device_type', stored separately for diagnostic purposes.
@ CopyIn
'copyin' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ Device
'device' clause, allowed on the 'update' construct.
@ Independent
'independent' clause, allowed on 'loop' directives.
@ NumWorkers
'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs...
@ IfPresent
'if_present' clause, allowed on 'host_data' and 'update' directives.
@ Detach
'detach' clause, allowed on the 'exit data' construct.
@ Delete
'delete' clause, allowed on the 'exit data' construct.
@ PresentOrCopyIn
'copyin' clause alias 'present_or_copyin'.
@ Finalize
'finalize' clause, allowed on 'exit data' directive.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
IdentifierLoc DeviceTypeArgument
static constexpr unsigned NumberOfOMPMapClauseModifiers
Number of allowed map-type-modifiers.
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
@ Undefined
Keep undefined.
PredefinedDeclIDs
Predefined declaration IDs.
@ PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID
The internal '__NSConstantString' tag type.
@ PREDEF_DECL_TRANSLATION_UNIT_ID
The translation unit.
@ PREDEF_DECL_OBJC_CLASS_ID
The Objective-C 'Class' type.
@ PREDEF_DECL_BUILTIN_MS_GUID_ID
The predeclared '_GUID' struct.
@ PREDEF_DECL_BUILTIN_MS_TYPE_INFO_TAG_ID
The predeclared 'type_info' struct.
@ PREDEF_DECL_OBJC_INSTANCETYPE_ID
The internal 'instancetype' typedef.
@ PREDEF_DECL_OBJC_PROTOCOL_ID
The Objective-C 'Protocol' type.
@ PREDEF_DECL_UNSIGNED_INT_128_ID
The unsigned 128-bit integer type.
@ PREDEF_DECL_OBJC_SEL_ID
The Objective-C 'SEL' type.
@ PREDEF_DECL_INT_128_ID
The signed 128-bit integer type.
@ PREDEF_DECL_VA_LIST_TAG
The internal '__va_list_tag' struct, if any.
@ PREDEF_DECL_BUILTIN_MS_VA_LIST_ID
The internal '__builtin_ms_va_list' typedef.
@ PREDEF_DECL_CF_CONSTANT_STRING_ID
The internal '__NSConstantString' typedef.
@ PREDEF_DECL_BUILTIN_VA_LIST_ID
The internal '__builtin_va_list' typedef.
@ PREDEF_DECL_EXTERN_C_CONTEXT_ID
The extern "C" context.
@ PREDEF_DECL_OBJC_ID_ID
The Objective-C 'id' type.
@ PREDEF_DECL_BUILTIN_ZOS_VA_LIST_ID
The internal '__builtin_zos_va_list' typedef.
@ Property
The type of a property.
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
@ 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