82#include "llvm/ADT/APFloat.h"
83#include "llvm/ADT/APInt.h"
84#include "llvm/ADT/ArrayRef.h"
85#include "llvm/ADT/DenseMap.h"
86#include "llvm/ADT/DenseSet.h"
87#include "llvm/ADT/PointerIntPair.h"
88#include "llvm/ADT/STLExtras.h"
89#include "llvm/ADT/ScopeExit.h"
90#include "llvm/ADT/SmallPtrSet.h"
91#include "llvm/ADT/SmallString.h"
92#include "llvm/ADT/SmallVector.h"
93#include "llvm/ADT/StringRef.h"
94#include "llvm/Bitstream/BitCodes.h"
95#include "llvm/Bitstream/BitstreamWriter.h"
96#include "llvm/Support/Compression.h"
97#include "llvm/Support/DJB.h"
98#include "llvm/Support/EndianStream.h"
99#include "llvm/Support/ErrorHandling.h"
100#include "llvm/Support/LEB128.h"
101#include "llvm/Support/MemoryBuffer.h"
102#include "llvm/Support/OnDiskHashTable.h"
103#include "llvm/Support/Path.h"
104#include "llvm/Support/SHA1.h"
105#include "llvm/Support/TimeProfiler.h"
106#include "llvm/Support/VersionTuple.h"
107#include "llvm/Support/raw_ostream.h"
122using namespace clang;
125template <
typename T,
typename Allocator>
126static StringRef
bytes(
const std::vector<T, Allocator> &v) {
127 if (v.empty())
return StringRef();
128 return StringRef(
reinterpret_cast<const char*
>(&v[0]),
129 sizeof(
T) * v.size());
134 return StringRef(
reinterpret_cast<const char*
>(v.data()),
135 sizeof(
T) * v.size());
138static std::string
bytes(
const std::vector<bool> &
V) {
140 Str.reserve(
V.size() / 8);
141 for (
unsigned I = 0, E =
V.size(); I < E;) {
143 for (
unsigned Bit = 0; Bit < 8 && I < E; ++Bit, ++I)
156#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
157 case Type::CLASS_ID: return TYPE_##CODE_ID;
158#include "clang/Serialization/TypeBitCodes.def"
160 llvm_unreachable(
"shouldn't be serializing a builtin type this way");
162 llvm_unreachable(
"bad type kind");
167struct AffectingModuleMaps {
168 llvm::DenseSet<FileID> DefinitionFileIDs;
169 llvm::DenseSet<const FileEntry *> DefinitionFiles;
172std::optional<AffectingModuleMaps>
185 enum AffectedReason :
bool {
186 AR_TextualHeader = 0,
187 AR_ImportOrTextualHeader = 1,
189 auto AssignMostImportant = [](AffectedReason &LHS, AffectedReason RHS) {
190 LHS = std::max(LHS, RHS);
192 llvm::DenseMap<FileID, AffectedReason> ModuleMaps;
193 llvm::DenseMap<const Module *, AffectedReason> ProcessedModules;
194 auto CollectModuleMapsForHierarchy = [&](
const Module *M,
195 AffectedReason Reason) {
201 if (
auto [It, Inserted] = ProcessedModules.insert({M, Reason});
202 !Inserted && Reason <= It->second) {
208 std::queue<const Module *> Q;
211 const Module *Mod = Q.front();
217 AssignMostImportant(ModuleMaps[F], Reason);
222 AssignMostImportant(ModuleMaps[UniqF], Reason);
231 CollectModuleMapsForHierarchy(RootModule, AR_ImportOrTextualHeader);
233 std::queue<const Module *> Q;
236 const Module *CurrentModule = Q.front();
240 CollectModuleMapsForHierarchy(ImportedModule, AR_ImportOrTextualHeader);
242 CollectModuleMapsForHierarchy(UndeclaredModule, AR_ImportOrTextualHeader);
256 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
270 if (
const Module *M = KH.getModule())
271 CollectModuleMapsForHierarchy(M, AR_TextualHeader);
292 llvm::DenseSet<const FileEntry *> ModuleFileEntries;
293 llvm::DenseSet<FileID> ModuleFileIDs;
294 for (
auto [FID, Reason] : ModuleMaps) {
295 if (Reason == AR_ImportOrTextualHeader)
296 ModuleFileIDs.insert(FID);
297 if (
auto *FE =
SM.getFileEntryForID(FID))
298 ModuleFileEntries.insert(FE);
301 AffectingModuleMaps R;
302 R.DefinitionFileIDs = std::move(ModuleFileIDs);
303 R.DefinitionFiles = std::move(ModuleFileEntries);
310 ASTRecordWriter BasicWriter;
313 ASTTypeWriter(ASTContext &Context, ASTWriter &Writer)
314 : Writer(Writer), BasicWriter(Context, Writer, Record) {}
317 if (
T.hasLocalNonFastQualifiers()) {
318 Qualifiers Qs =
T.getLocalQualifiers();
319 BasicWriter.writeQualType(
T.getLocalUnqualifiedType());
320 BasicWriter.writeQualifiers(Qs);
321 return BasicWriter.Emit(
TYPE_EXT_QUAL, Writer.getTypeExtQualAbbrev());
324 const Type *typePtr =
T.getTypePtr();
325 serialization::AbstractTypeWriter<ASTRecordWriter> atw(BasicWriter);
333 ASTRecordWriter &Record;
335 void addSourceLocation(SourceLocation Loc) { Record.AddSourceLocation(Loc); }
336 void addSourceRange(SourceRange Range) { Record.AddSourceRange(Range); }
339 TypeLocWriter(ASTRecordWriter &Record) : Record(Record) {}
341#define ABSTRACT_TYPELOC(CLASS, PARENT)
342#define TYPELOC(CLASS, PARENT) \
343 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
344#include "clang/AST/TypeLocNodes.def"
357void TypeLocWriter::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
367void TypeLocWriter::VisitComplexTypeLoc(ComplexTypeLoc TL) {
371void TypeLocWriter::VisitPointerTypeLoc(PointerTypeLoc TL) {
375void TypeLocWriter::VisitDecayedTypeLoc(DecayedTypeLoc TL) {
379void TypeLocWriter::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
383void TypeLocWriter::VisitArrayParameterTypeLoc(ArrayParameterTypeLoc TL) {
387void TypeLocWriter::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
391void TypeLocWriter::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
395void TypeLocWriter::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
399void TypeLocWriter::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
404void TypeLocWriter::VisitArrayTypeLoc(ArrayTypeLoc TL) {
412void TypeLocWriter::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) {
413 VisitArrayTypeLoc(TL);
416void TypeLocWriter::VisitIncompleteArrayTypeLoc(IncompleteArrayTypeLoc TL) {
417 VisitArrayTypeLoc(TL);
420void TypeLocWriter::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
421 VisitArrayTypeLoc(TL);
424void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
425 DependentSizedArrayTypeLoc TL) {
426 VisitArrayTypeLoc(TL);
429void TypeLocWriter::VisitDependentAddressSpaceTypeLoc(
430 DependentAddressSpaceTypeLoc TL) {
433 addSourceLocation(
range.getBegin());
434 addSourceLocation(
range.getEnd());
438void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
439 DependentSizedExtVectorTypeLoc TL) {
443void TypeLocWriter::VisitVectorTypeLoc(VectorTypeLoc TL) {
447void TypeLocWriter::VisitDependentVectorTypeLoc(
448 DependentVectorTypeLoc TL) {
452void TypeLocWriter::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
456void TypeLocWriter::VisitConstantMatrixTypeLoc(ConstantMatrixTypeLoc TL) {
459 addSourceLocation(
range.getBegin());
460 addSourceLocation(
range.getEnd());
465void TypeLocWriter::VisitDependentSizedMatrixTypeLoc(
466 DependentSizedMatrixTypeLoc TL) {
469 addSourceLocation(
range.getBegin());
470 addSourceLocation(
range.getEnd());
475void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
481 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i)
485void TypeLocWriter::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {
486 VisitFunctionTypeLoc(TL);
489void TypeLocWriter::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) {
490 VisitFunctionTypeLoc(TL);
493void TypeLocWriter::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
499void TypeLocWriter::VisitUsingTypeLoc(UsingTypeLoc TL) {
505void TypeLocWriter::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
511void TypeLocWriter::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
520void TypeLocWriter::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
526void TypeLocWriter::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
533void TypeLocWriter::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
538void TypeLocWriter::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
561void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
566 Record.AddConceptReference(CR);
572void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
573 DeducedTemplateSpecializationTypeLoc TL) {
579void TypeLocWriter::VisitTagTypeLoc(TagTypeLoc TL) {
585void TypeLocWriter::VisitRecordTypeLoc(RecordTypeLoc TL) {
589void TypeLocWriter::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
593void TypeLocWriter::VisitEnumTypeLoc(EnumTypeLoc TL) { VisitTagTypeLoc(TL); }
595void TypeLocWriter::VisitAttributedTypeLoc(AttributedTypeLoc TL) {
599void TypeLocWriter::VisitCountAttributedTypeLoc(CountAttributedTypeLoc TL) {
603void TypeLocWriter::VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
607void TypeLocWriter::VisitHLSLAttributedResourceTypeLoc(
608 HLSLAttributedResourceTypeLoc TL) {
612void TypeLocWriter::VisitHLSLInlineSpirvTypeLoc(HLSLInlineSpirvTypeLoc TL) {
616void TypeLocWriter::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
620void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
621 SubstTemplateTypeParmTypeLoc TL) {
625void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
626 SubstTemplateTypeParmPackTypeLoc TL) {
630void TypeLocWriter::VisitSubstBuiltinTemplatePackTypeLoc(
631 SubstBuiltinTemplatePackTypeLoc TL) {
635void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
636 TemplateSpecializationTypeLoc TL) {
643 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
647void TypeLocWriter::VisitParenTypeLoc(ParenTypeLoc TL) {
652void TypeLocWriter::VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
656void TypeLocWriter::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
662void TypeLocWriter::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) {
666void TypeLocWriter::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
671void TypeLocWriter::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
683void TypeLocWriter::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
687void TypeLocWriter::VisitAtomicTypeLoc(AtomicTypeLoc TL) {
693void TypeLocWriter::VisitPipeTypeLoc(PipeTypeLoc TL) {
696void TypeLocWriter::VisitBitIntTypeLoc(clang::BitIntTypeLoc TL) {
699void TypeLocWriter::VisitDependentBitIntTypeLoc(
700 clang::DependentBitIntTypeLoc TL) {
704void TypeLocWriter::VisitPredefinedSugarTypeLoc(
705 clang::PredefinedSugarTypeLoc TL) {
709void ASTWriter::WriteTypeAbbrevs() {
710 using namespace llvm;
712 std::shared_ptr<BitCodeAbbrev> Abv;
715 Abv = std::make_shared<BitCodeAbbrev>();
717 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
718 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
719 TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
727 llvm::BitstreamWriter &Stream,
731 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID,
Record);
734 if (!Name || Name[0] == 0)
738 Record.push_back(*Name++);
739 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME,
Record);
743 llvm::BitstreamWriter &Stream,
748 Record.push_back(*Name++);
749 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME,
Record);
754#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
886void ASTWriter::WriteBlockInfoBlock() {
888 Stream.EnterBlockInfoBlock();
890#define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
891#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
894 BLOCK(CONTROL_BLOCK);
904 BLOCK(OPTIONS_BLOCK);
912 BLOCK(INPUT_FILES_BLOCK);
978 BLOCK(SOURCE_MANAGER_BLOCK);
986 BLOCK(PREPROCESSOR_BLOCK);
994 BLOCK(SUBMODULE_BLOCK);
1016 BLOCK(COMMENTS_BLOCK);
1020 BLOCK(DECLTYPES_BLOCK);
1024 RECORD(TYPE_BLOCK_POINTER);
1025 RECORD(TYPE_LVALUE_REFERENCE);
1026 RECORD(TYPE_RVALUE_REFERENCE);
1027 RECORD(TYPE_MEMBER_POINTER);
1028 RECORD(TYPE_CONSTANT_ARRAY);
1029 RECORD(TYPE_INCOMPLETE_ARRAY);
1030 RECORD(TYPE_VARIABLE_ARRAY);
1033 RECORD(TYPE_FUNCTION_NO_PROTO);
1034 RECORD(TYPE_FUNCTION_PROTO);
1036 RECORD(TYPE_TYPEOF_EXPR);
1040 RECORD(TYPE_OBJC_INTERFACE);
1041 RECORD(TYPE_OBJC_OBJECT_POINTER);
1043 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM);
1044 RECORD(TYPE_UNRESOLVED_USING);
1045 RECORD(TYPE_INJECTED_CLASS_NAME);
1046 RECORD(TYPE_OBJC_OBJECT);
1047 RECORD(TYPE_TEMPLATE_TYPE_PARM);
1048 RECORD(TYPE_TEMPLATE_SPECIALIZATION);
1049 RECORD(TYPE_DEPENDENT_NAME);
1050 RECORD(TYPE_DEPENDENT_SIZED_ARRAY);
1052 RECORD(TYPE_MACRO_QUALIFIED);
1053 RECORD(TYPE_PACK_EXPANSION);
1055 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK);
1056 RECORD(TYPE_SUBST_BUILTIN_TEMPLATE_PACK);
1058 RECORD(TYPE_UNARY_TRANSFORM);
1062 RECORD(TYPE_OBJC_TYPE_PARAM);
1143 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
1149 BLOCK(EXTENSION_BLOCK);
1152 BLOCK(UNHASHED_CONTROL_BLOCK);
1172 bool Changed =
FileMgr.makeAbsolutePath(Path);
1173 return Changed | llvm::sys::path::remove_dots(Path);
1188 assert(Filename &&
"No file name to adjust?");
1190 if (BaseDir.empty())
1195 for (; Filename[Pos] && Pos < BaseDir.size(); ++Pos)
1196 if (Filename[Pos] != BaseDir[Pos])
1205 if (!llvm::sys::path::is_separator(Filename[Pos])) {
1206 if (!llvm::sys::path::is_separator(BaseDir.back()))
1220 return Filename + Pos;
1223std::pair<ASTFileSignature, ASTFileSignature>
1224ASTWriter::createSignature()
const {
1225 StringRef AllBytes(Buffer.data(), Buffer.size());
1228 Hasher.update(AllBytes.slice(ASTBlockRange.first, ASTBlockRange.second));
1233 Hasher.update(AllBytes.slice(0, UnhashedControlBlockRange.first));
1236 AllBytes.slice(UnhashedControlBlockRange.second, ASTBlockRange.first));
1238 Hasher.update(AllBytes.substr(ASTBlockRange.second));
1241 return std::make_pair(ASTBlockHash, Signature);
1244ASTFileSignature ASTWriter::createSignatureForNamedModule()
const {
1246 Hasher.update(StringRef(Buffer.data(), Buffer.size()));
1248 assert(WritingModule);
1249 assert(WritingModule->isNamedModule());
1253 for (
auto [ExportImported, _] : WritingModule->Exports)
1254 Hasher.update(ExportImported->Signature);
1278 for (
Module *M : TouchedTopLevelModules)
1286 for (uint8_t Byte : S) {
1287 Stream.BackpatchByte(BitNo, Byte);
1292ASTFileSignature ASTWriter::backpatchSignature() {
1293 if (isWritingStdCXXNamedModules()) {
1294 ASTFileSignature Signature = createSignatureForNamedModule();
1299 if (!WritingModule ||
1304 ASTFileSignature ASTBlockHash;
1305 ASTFileSignature Signature;
1306 std::tie(ASTBlockHash, Signature) = createSignature();
1314void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP) {
1315 using namespace llvm;
1318 Stream.FlushToWord();
1319 UnhashedControlBlockRange.first = Stream.GetCurrentBitNo() >> 3;
1327 if (isWritingStdCXXNamedModules() ||
1338 SmallString<128> Blob{Dummy.begin(), Dummy.end()};
1341 if (!isWritingStdCXXNamedModules()) {
1342 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1344 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1345 unsigned ASTBlockHashAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1348 Stream.EmitRecordWithBlob(ASTBlockHashAbbrev,
Record, Blob);
1349 ASTBlockHashOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1353 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1354 Abbrev->Add(BitCodeAbbrevOp(
SIGNATURE));
1355 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1356 unsigned SignatureAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1359 Stream.EmitRecordWithBlob(SignatureAbbrev,
Record, Blob);
1360 SignatureOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1369 if (!HSOpts.ModulesSkipDiagnosticOptions) {
1370#define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name);
1371#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
1372 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name()));
1373#include "clang/Basic/DiagnosticOptions.def"
1375 for (
unsigned I = 0, N = DiagOpts.
Warnings.size(); I != N; ++I)
1378 for (
unsigned I = 0, N = DiagOpts.
Remarks.size(); I != N; ++I)
1387 if (!HSOpts.ModulesSkipHeaderSearchPaths) {
1389 Record.push_back(HSOpts.UserEntries.size());
1390 for (
unsigned I = 0, N = HSOpts.UserEntries.size(); I != N; ++I) {
1391 const HeaderSearchOptions::Entry &Entry = HSOpts.UserEntries[I];
1393 Record.push_back(
static_cast<unsigned>(Entry.
Group));
1399 Record.push_back(HSOpts.SystemHeaderPrefixes.size());
1400 for (
unsigned I = 0, N = HSOpts.SystemHeaderPrefixes.size(); I != N; ++I) {
1401 AddString(HSOpts.SystemHeaderPrefixes[I].Prefix,
Record);
1402 Record.push_back(HSOpts.SystemHeaderPrefixes[I].IsSystemHeader);
1406 Record.push_back(HSOpts.VFSOverlayFiles.size());
1407 for (StringRef VFSOverlayFile : HSOpts.VFSOverlayFiles)
1408 AddString(VFSOverlayFile,
Record);
1413 if (!HSOpts.ModulesSkipPragmaDiagnosticMappings)
1414 WritePragmaDiagnosticMappings(Diags, WritingModule);
1419 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1421 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1422 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1423 unsigned HSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1425 HSEntryUsage.size()};
1426 Stream.EmitRecordWithBlob(HSUsageAbbrevCode,
Record,
bytes(HSEntryUsage));
1432 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1433 Abbrev->Add(BitCodeAbbrevOp(
VFS_USAGE));
1434 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1435 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1436 unsigned VFSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1438 Stream.EmitRecordWithBlob(VFSUsageAbbrevCode,
Record,
bytes(VFSUsage));
1443 UnhashedControlBlockRange.second = Stream.GetCurrentBitNo() >> 3;
1447void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
1448 using namespace llvm;
1457 auto MetadataAbbrev = std::make_shared<BitCodeAbbrev>();
1458 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1459 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1460 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1461 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1462 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1463 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1465 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1466 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1467 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1468 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1469 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev));
1470 assert((!WritingModule || isysroot.empty()) &&
1471 "writing module as a relocatable PCH?");
1476 CLANG_VERSION_MAJOR,
1477 CLANG_VERSION_MINOR,
1479 isWritingStdCXXNamedModules(),
1481 ASTHasCompilerErrors};
1482 Stream.EmitRecordWithBlob(MetadataAbbrevCode,
Record,
1486 if (WritingModule) {
1488 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1490 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1491 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1493 Stream.EmitRecordWithBlob(AbbrevCode,
Record, WritingModule->Name);
1495 auto BaseDir = [&]() -> std::optional<SmallString<128>> {
1501 if (WritingModule->Directory) {
1502 return WritingModule->Directory->getName();
1504 return std::nullopt;
1516 WritingModule->Directory->getName() !=
".")) {
1518 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1520 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1521 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1524 Stream.EmitRecordWithBlob(AbbrevCode,
Record, *BaseDir);
1528 BaseDirectory.assign(BaseDir->begin(), BaseDir->end());
1529 }
else if (!isysroot.empty()) {
1531 BaseDirectory = std::string(isysroot);
1536 if (WritingModule && WritingModule->Kind == Module::ModuleMapModule) {
1540 AddPath(WritingModule->PresumedModuleMapFile.empty()
1541 ? Map.getModuleMapFileForUniquing(WritingModule)
1542 ->getNameAsRequested()
1543 : StringRef(WritingModule->PresumedModuleMapFile),
1547 if (
auto *AdditionalModMaps =
1548 Map.getAdditionalModuleMapFiles(WritingModule)) {
1549 Record.push_back(AdditionalModMaps->size());
1550 SmallVector<FileEntryRef, 1> ModMaps(AdditionalModMaps->begin(),
1551 AdditionalModMaps->end());
1552 llvm::sort(ModMaps, [](FileEntryRef A, FileEntryRef B) {
1555 for (FileEntryRef F : ModMaps)
1556 AddPath(F.getName(),
Record);
1566 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1567 Abbrev->Add(BitCodeAbbrevOp(
IMPORT));
1568 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1569 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1570 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1571 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1572 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1573 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1574 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1575 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1576 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1578 SmallString<128> Blob;
1580 for (ModuleFile &M : Chain->getModuleManager()) {
1582 if (!M.isDirectlyImported())
1590 AddSourceLocation(M.ImportLoc,
Record);
1591 AddStringBlob(M.ModuleName,
Record, Blob);
1592 Record.push_back(M.StandardCXXModule);
1596 if (M.StandardCXXModule) {
1608 AddPathBlob(M.FileName,
Record, Blob);
1611 Stream.EmitRecordWithBlob(AbbrevCode,
Record, Blob);
1621#define LANGOPT(Name, Bits, Default, Compatibility, Description) \
1622 Record.push_back(LangOpts.Name);
1623#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
1624 Record.push_back(static_cast<unsigned>(LangOpts.get##Name()));
1625#include "clang/Basic/LangOptions.def"
1626#define SANITIZER(NAME, ID) \
1627 Record.push_back(LangOpts.Sanitize.has(SanitizerKind::ID));
1628#include "clang/Basic/Sanitizers.def"
1649 AddString(
T.getTriple(),
Record);
1657 using CK = CodeGenOptions::CompatibilityKind;
1659 const CodeGenOptions &CGOpts = getCodeGenOpts();
1660#define CODEGENOPT(Name, Bits, Default, Compatibility) \
1661 if constexpr (CK::Compatibility != CK::Benign) \
1662 Record.push_back(static_cast<unsigned>(CGOpts.Name));
1663#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility) \
1664 if constexpr (CK::Compatibility != CK::Benign) \
1665 Record.push_back(static_cast<unsigned>(CGOpts.get##Name()));
1666#define DEBUGOPT(Name, Bits, Default, Compatibility)
1667#define VALUE_DEBUGOPT(Name, Bits, Default, Compatibility)
1668#define ENUM_DEBUGOPT(Name, Type, Bits, Default, Compatibility)
1669#include "clang/Basic/CodeGenOptions.def"
1685 for (
unsigned I = 0, N = TargetOpts.
Features.size(); I != N; ++I) {
1698 const HeaderSearchOptions &HSOpts =
1701 SmallString<256> HSOpts_ModuleCachePath;
1703 HSOpts_ModuleCachePath);
1707 AddString(HSOpts_ModuleCachePath,
Record);
1729 bool WriteMacros = !SkipMacros;
1730 Record.push_back(WriteMacros);
1734 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
1742 for (
unsigned I = 0, N = PPOpts.
Includes.size(); I != N; ++I)
1747 for (
unsigned I = 0, N = PPOpts.
MacroIncludes.size(); I != N; ++I)
1763 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1765 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1766 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1767 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
1772 EmitRecordWithPath(FileAbbrevCode,
Record, MainFile->getName());
1779 WriteInputFiles(SourceMgr);
1786struct InputFileEntry {
1790 bool BufferOverridden;
1797 void trySetContentHash(
1799 llvm::function_ref<std::optional<llvm::MemoryBufferRef>()> GetMemBuff) {
1808 auto MemBuff = GetMemBuff();
1810 PP.
Diag(SourceLocation(), diag::err_module_unable_to_hash_content)
1815 uint64_t Hash = xxh3_64bits(MemBuff->getBuffer());
1817 ContentHash[1] =
uint32_t(Hash >> 32);
1823SourceLocation ASTWriter::getAffectingIncludeLoc(
const SourceManager &SourceMgr,
1824 const SrcMgr::FileInfo &
File) {
1825 SourceLocation IncludeLoc =
File.getIncludeLoc();
1827 FileID IncludeFID = SourceMgr.
getFileID(IncludeLoc);
1828 assert(IncludeFID.
isValid() &&
"IncludeLoc in invalid file");
1829 if (!IsSLocAffecting[IncludeFID.ID])
1830 IncludeLoc = SourceLocation();
1835void ASTWriter::WriteInputFiles(SourceManager &SourceMgr) {
1836 using namespace llvm;
1841 auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
1843 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1844 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1845 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1846 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1847 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1848 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1849 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1850 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
1851 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1852 unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
1855 auto IFHAbbrev = std::make_shared<BitCodeAbbrev>();
1857 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1858 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1859 unsigned IFHAbbrevCode = Stream.EmitAbbrev(std::move(IFHAbbrev));
1861 uint64_t InputFilesOffsetBase = Stream.GetCurrentBitNo();
1864 std::vector<InputFileEntry> UserFiles;
1865 std::vector<InputFileEntry> SystemFiles;
1869 assert(&SourceMgr.
getSLocEntry(FileID::get(I)) == SLoc);
1876 if (!
Cache->OrigEntry)
1880 if (!IsSLocFileEntryAffecting[I])
1883 InputFileEntry Entry(*
Cache->OrigEntry);
1884 Entry.IsSystemFile =
isSystem(
File.getFileCharacteristic());
1885 Entry.IsTransient =
Cache->IsTransient;
1886 Entry.BufferOverridden =
Cache->BufferOverridden;
1888 FileID IncludeFileID = SourceMgr.
getFileID(
File.getIncludeLoc());
1889 Entry.IsTopLevel = IncludeFileID.
isInvalid() || IncludeFileID.ID < 0 ||
1890 !IsSLocFileEntryAffecting[IncludeFileID.ID];
1893 Entry.trySetContentHash(*PP, [&] {
return Cache->getBufferIfLoaded(); });
1895 if (Entry.IsSystemFile)
1896 SystemFiles.push_back(Entry);
1898 UserFiles.push_back(Entry);
1905 if (!Sysroot.empty()) {
1906 SmallString<128> SDKSettingsJSON = Sysroot;
1907 llvm::sys::path::append(SDKSettingsJSON,
"SDKSettings.json");
1910 InputFileEntry Entry(*FE);
1911 Entry.IsSystemFile =
true;
1912 Entry.IsTransient =
false;
1913 Entry.BufferOverridden =
false;
1914 Entry.IsTopLevel =
true;
1915 Entry.IsModuleMap =
false;
1916 std::unique_ptr<MemoryBuffer> MB;
1917 Entry.trySetContentHash(*PP, [&]() -> std::optional<MemoryBufferRef> {
1919 MB = std::move(*MBOrErr);
1920 return MB->getMemBufferRef();
1922 return std::nullopt;
1924 SystemFiles.push_back(Entry);
1929 auto SortedFiles = llvm::concat<InputFileEntry>(std::move(UserFiles),
1930 std::move(SystemFiles));
1932 unsigned UserFilesNum = 0;
1934 std::vector<uint64_t> InputFileOffsets;
1935 for (
const auto &Entry : SortedFiles) {
1936 uint32_t &InputFileID = InputFileIDs[Entry.File];
1937 if (InputFileID != 0)
1941 InputFileOffsets.push_back(Stream.GetCurrentBitNo() - InputFilesOffsetBase);
1943 InputFileID = InputFileOffsets.size();
1945 if (!Entry.IsSystemFile)
1951 SmallString<128> NameAsRequested = Entry.File.getNameAsRequested();
1952 SmallString<128> Name = Entry.File.getName();
1954 PreparePathForOutput(NameAsRequested);
1955 PreparePathForOutput(Name);
1957 if (Name == NameAsRequested)
1960 RecordData::value_type
Record[] = {
1962 InputFileOffsets.size(),
1964 (
uint64_t)getTimestampForOutput(Entry.File),
1965 Entry.BufferOverridden,
1969 NameAsRequested.size()};
1971 Stream.EmitRecordWithBlob(IFAbbrevCode,
Record,
1972 (NameAsRequested + Name).str());
1978 Entry.ContentHash[1]};
1979 Stream.EmitRecordWithAbbrev(IFHAbbrevCode,
Record);
1986 auto OffsetsAbbrev = std::make_shared<BitCodeAbbrev>();
1988 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1989 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1991 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1992 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(std::move(OffsetsAbbrev));
1996 InputFileOffsets.size(), UserFilesNum};
1997 Stream.EmitRecordWithBlob(OffsetsAbbrevCode,
Record,
bytes(InputFileOffsets));
2007 using namespace llvm;
2009 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2011 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2012 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2013 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
2014 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2016 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2017 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2018 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
2019 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2020 return Stream.EmitAbbrev(std::move(Abbrev));
2026 using namespace llvm;
2028 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2030 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2031 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2032 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
2033 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2034 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2035 return Stream.EmitAbbrev(std::move(Abbrev));
2042 using namespace llvm;
2044 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2048 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2049 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2050 return Stream.EmitAbbrev(std::move(Abbrev));
2056 using namespace llvm;
2058 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2060 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2061 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2062 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2063 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2064 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2065 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2066 return Stream.EmitAbbrev(std::move(Abbrev));
2071static std::pair<unsigned, unsigned>
2073 llvm::encodeULEB128(KeyLen, Out);
2074 llvm::encodeULEB128(DataLen, Out);
2075 return std::make_pair(KeyLen, DataLen);
2081 class HeaderFileInfoTrait {
2085 HeaderFileInfoTrait(ASTWriter &Writer) : Writer(Writer) {}
2092 using key_type_ref =
const key_type &;
2094 using UnresolvedModule =
2095 llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
2098 data_type(
const HeaderFileInfo &HFI,
bool AlreadyIncluded,
2099 ArrayRef<ModuleMap::KnownHeader> KnownHeaders,
2101 : HFI(HFI), AlreadyIncluded(AlreadyIncluded),
2105 bool AlreadyIncluded;
2106 SmallVector<ModuleMap::KnownHeader, 1> KnownHeaders;
2109 using data_type_ref =
const data_type &;
2111 using hash_value_type = unsigned;
2112 using offset_type = unsigned;
2118 uint8_t buf[
sizeof(key.Size) +
sizeof(key.ModTime)];
2119 memcpy(buf, &key.Size,
sizeof(key.Size));
2120 memcpy(buf +
sizeof(key.Size), &key.ModTime,
sizeof(key.ModTime));
2121 return llvm::xxh3_64bits(buf);
2124 std::pair<unsigned, unsigned>
2125 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref
Data) {
2126 unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
2128 for (
auto ModInfo :
Data.KnownHeaders)
2131 if (
Data.Unresolved.getPointer())
2136 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
2137 using namespace llvm::support;
2139 endian::Writer
LE(Out, llvm::endianness::little);
2144 Out.write(key.Filename.data(), KeyLen);
2147 void EmitData(raw_ostream &Out, key_type_ref key,
2148 data_type_ref
Data,
unsigned DataLen) {
2149 using namespace llvm::support;
2151 endian::Writer
LE(Out, llvm::endianness::little);
2154 unsigned char Flags = (
Data.AlreadyIncluded << 6)
2155 | (
Data.HFI.isImport << 5)
2157 Data.HFI.isPragmaOnce << 4)
2158 | (
Data.HFI.DirInfo << 1);
2159 LE.write<uint8_t>(Flags);
2161 if (
Data.HFI.LazyControllingMacro.isID())
2170 assert((
Value >> 3) == ModID &&
"overflow in header module info");
2175 for (
auto ModInfo :
Data.KnownHeaders)
2176 EmitModule(ModInfo.getModule(), ModInfo.getRole());
2177 if (
Data.Unresolved.getPointer())
2178 EmitModule(
Data.Unresolved.getPointer(),
Data.Unresolved.getInt());
2180 assert(
Out.tell() - Start == DataLen &&
"Wrong data length");
2189void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
2190 HeaderFileInfoTrait GeneratorTrait(*
this);
2191 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait>
Generator;
2192 SmallVector<const char *, 4> SavedStrings;
2193 unsigned NumHeaderSearchEntries = 0;
2199 const HeaderFileInfo
Empty;
2200 if (WritingModule) {
2201 llvm::SmallVector<Module *, 16> Worklist(1, WritingModule);
2202 while (!Worklist.empty()) {
2203 Module *M = Worklist.pop_back_val();
2220 if (!U.Size || (!U.ModTime && IncludeTimestamps)) {
2221 PP->
Diag(U.FileNameLoc, diag::err_module_no_size_mtime_for_header)
2222 << WritingModule->getFullModuleName() << U.Size.has_value()
2229 llvm::sys::path::append(Filename, U.FileName);
2230 PreparePathForOutput(Filename);
2232 StringRef FilenameDup = strdup(Filename.c_str());
2233 SavedStrings.push_back(FilenameDup.data());
2235 HeaderFileInfoTrait::key_type Key = {
2236 FilenameDup, *U.Size, IncludeTimestamps ? *U.ModTime : 0};
2237 HeaderFileInfoTrait::data_type
Data = {
2242 ++NumHeaderSearchEntries;
2245 Worklist.append(SubmodulesRange.begin(), SubmodulesRange.end());
2249 SmallVector<OptionalFileEntryRef, 16> FilesByUID;
2255 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
2269 StringRef Filename =
File->getName();
2270 SmallString<128> FilenameTmp(Filename);
2271 if (PreparePathForOutput(FilenameTmp)) {
2274 Filename = StringRef(strdup(FilenameTmp.c_str()));
2275 SavedStrings.push_back(Filename.data());
2280 HeaderFileInfoTrait::key_type Key = {
2281 Filename,
File->getSize(), getTimestampForOutput(*
File)
2283 HeaderFileInfoTrait::data_type
Data = {
2287 ++NumHeaderSearchEntries;
2291 SmallString<4096> TableData;
2294 using namespace llvm::support;
2296 llvm::raw_svector_ostream
Out(TableData);
2298 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
2299 BucketOffset =
Generator.Emit(Out, GeneratorTrait);
2303 using namespace llvm;
2305 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2307 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2308 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2309 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2310 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2311 unsigned TableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2315 NumHeaderSearchEntries, TableData.size()};
2316 Stream.EmitRecordWithBlob(TableAbbrev,
Record, TableData);
2319 for (
unsigned I = 0, N = SavedStrings.size(); I != N; ++I)
2320 free(
const_cast<char *
>(SavedStrings[I]));
2323static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
2324 unsigned SLocBufferBlobCompressedAbbrv,
2325 unsigned SLocBufferBlobAbbrv) {
2326 using RecordDataType = ASTWriter::RecordData::value_type;
2331 if (llvm::compression::zstd::isAvailable()) {
2332 llvm::compression::zstd::compress(
2333 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer, 9);
2335 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2336 llvm::toStringRef(CompressedBuffer));
2339 if (llvm::compression::zlib::isAvailable()) {
2340 llvm::compression::zlib::compress(
2341 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer);
2343 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2344 llvm::toStringRef(CompressedBuffer));
2349 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv,
Record, Blob);
2360void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
2365 const uint64_t SourceManagerBlockOffset = Stream.GetCurrentBitNo();
2371 unsigned SLocBufferBlobCompressedAbbrv =
2377 std::vector<uint32_t> SLocEntryOffsets;
2378 uint64_t SLocEntryOffsetsBase = Stream.GetCurrentBitNo();
2384 FileID FID = FileID::get(I);
2388 uint64_t Offset = Stream.GetCurrentBitNo() - SLocEntryOffsetsBase;
2389 assert((Offset >> 32) == 0 &&
"SLocEntry offset too large");
2395 if (
Cache->OrigEntry) {
2408 if (!IsSLocAffecting[I])
2410 SLocEntryOffsets.push_back(Offset);
2413 AddSourceLocation(getAffectingIncludeLoc(SourceMgr,
File),
Record);
2414 Record.push_back(
File.getFileCharacteristic());
2417 bool EmitBlob =
false;
2420 "Writing to AST an overridden file is not supported");
2423 assert(InputFileIDs[*Content->
OrigEntry] != 0 &&
"Missed file entry");
2426 Record.push_back(getAdjustedNumCreatedFIDs(FID));
2428 FileDeclIDsTy::iterator FDI = FileDeclIDs.find(FID);
2429 if (FDI != FileDeclIDs.end()) {
2430 Record.push_back(FDI->second->FirstDeclIndex);
2431 Record.push_back(FDI->second->DeclIDs.size());
2437 Stream.EmitRecordWithAbbrev(SLocFileAbbrv,
Record);
2448 std::optional<llvm::MemoryBufferRef> Buffer = Content->
getBufferOrNone(
2450 StringRef Name = Buffer ? Buffer->getBufferIdentifier() :
"";
2451 Stream.EmitRecordWithBlob(SLocBufferAbbrv,
Record,
2452 StringRef(Name.data(), Name.size() + 1));
2459 std::optional<llvm::MemoryBufferRef> Buffer = Content->
getBufferOrNone(
2462 Buffer = llvm::MemoryBufferRef(
"<<<INVALID BUFFER>>>",
"");
2463 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
2464 emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv,
2465 SLocBufferBlobAbbrv);
2469 const SrcMgr::ExpansionInfo &Expansion = SLoc->
getExpansion();
2470 SLocEntryOffsets.push_back(Offset);
2485 Record.push_back(getAdjustedOffset(NextOffset - SLoc->
getOffset()) - 1);
2486 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv,
Record);
2492 if (SLocEntryOffsets.empty())
2497 using namespace llvm;
2499 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2501 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2502 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2503 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2504 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2505 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2507 RecordData::value_type
Record[] = {
2510 SLocEntryOffsetsBase - SourceManagerBlockOffset};
2511 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev,
Record,
2512 bytes(SLocEntryOffsets));
2523 llvm::DenseMap<int, int> FilenameMap;
2524 FilenameMap[-1] = -1;
2525 for (
const auto &L : LineTable) {
2528 for (
auto &LE : L.second) {
2529 if (FilenameMap.insert(std::make_pair(
LE.FilenameID,
2530 FilenameMap.size() - 1)).second)
2531 AddPath(LineTable.getFilename(
LE.FilenameID),
Record);
2537 for (
const auto &L : LineTable) {
2542 AddFileID(L.first,
Record);
2545 Record.push_back(L.second.size());
2546 for (
const auto &LE : L.second) {
2549 Record.push_back(FilenameMap[
LE.FilenameID]);
2550 Record.push_back((
unsigned)
LE.FileKind);
2551 Record.push_back(
LE.IncludeOffset);
2566 if (MI->isBuiltinMacro())
2582void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2583 uint64_t MacroOffsetsBase = Stream.GetCurrentBitNo();
2587 WritePreprocessorDetail(*PPRec, MacroOffsetsBase);
2590 RecordData ModuleMacroRecord;
2600 SourceLocation AssumeNonNullLoc =
2602 if (AssumeNonNullLoc.
isValid()) {
2604 AddSourceLocation(AssumeNonNullLoc,
Record);
2614 AddSourceLocation(SkipInfo->HashTokenLoc,
Record);
2615 AddSourceLocation(SkipInfo->IfTokenLoc,
Record);
2616 Record.push_back(SkipInfo->FoundNonSkipPortion);
2617 Record.push_back(SkipInfo->FoundElse);
2618 AddSourceLocation(SkipInfo->ElseLoc,
Record);
2634 AddSourceLocation(S,
Record);
2644 PP.
Diag(SourceLocation(), diag::warn_module_uses_date_time) << IsModule;
2651 SmallVector<const IdentifierInfo *, 128> MacroIdentifiers;
2654 if (!isWritingStdCXXNamedModules())
2656 if (Id.second->hadMacroDefinition() &&
2657 (!Id.second->isFromAST() ||
2658 Id.second->hasChangedSinceDeserialization()))
2659 MacroIdentifiers.push_back(Id.second);
2662 llvm::sort(MacroIdentifiers, llvm::deref<std::less<>>());
2666 for (
const IdentifierInfo *Name : MacroIdentifiers) {
2668 uint64_t StartOffset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2669 assert((StartOffset >> 32) == 0 &&
"Macro identifiers offset too large");
2672 bool EmittedModuleMacros =
false;
2680 if (IsModule && WritingModule->isHeaderUnit()) {
2689 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2690 Record.push_back(getMacroRef(DefMD->getInfo(), Name));
2691 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2692 Record.push_back(VisMD->isPublic());
2694 ModuleMacroRecord.push_back(getSubmoduleID(WritingModule));
2695 AddMacroRef(MD->
getMacroInfo(), Name, ModuleMacroRecord);
2697 ModuleMacroRecord.clear();
2698 EmittedModuleMacros =
true;
2708 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2709 Record.push_back(getMacroRef(DefMD->getInfo(), Name));
2710 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2711 Record.push_back(VisMD->isPublic());
2717 SmallVector<ModuleMacro *, 8> Worklist(Leafs);
2718 llvm::DenseMap<ModuleMacro *, unsigned> Visits;
2719 while (!Worklist.empty()) {
2720 auto *
Macro = Worklist.pop_back_val();
2723 ModuleMacroRecord.push_back(getSubmoduleID(
Macro->getOwningModule()));
2724 AddMacroRef(
Macro->getMacroInfo(), Name, ModuleMacroRecord);
2725 for (
auto *M :
Macro->overrides())
2726 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2729 ModuleMacroRecord.clear();
2732 for (
auto *M :
Macro->overrides())
2733 if (++Visits[M] == M->getNumOverridingMacros())
2734 Worklist.push_back(M);
2736 EmittedModuleMacros =
true;
2739 if (
Record.empty() && !EmittedModuleMacros)
2742 IdentMacroDirectivesOffsetMap[Name] = StartOffset;
2753 std::vector<uint32_t> MacroOffsets;
2755 for (
unsigned I = 0, N = MacroInfosToEmit.size(); I != N; ++I) {
2756 const IdentifierInfo *Name = MacroInfosToEmit[I].Name;
2757 MacroInfo *MI = MacroInfosToEmit[I].MI;
2760 if (ID < FirstMacroID) {
2761 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2766 unsigned Index =
ID - FirstMacroID;
2767 if (Index >= MacroOffsets.size())
2768 MacroOffsets.resize(Index + 1);
2770 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2771 assert((Offset >> 32) == 0 &&
"Macro offset too large");
2772 MacroOffsets[Index] = Offset;
2774 AddIdentifierRef(Name,
Record);
2790 for (
const IdentifierInfo *Param : MI->
params())
2791 AddIdentifierRef(Param,
Record);
2799 Stream.EmitRecord(Code,
Record);
2803 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2818 using namespace llvm;
2820 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2822 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2823 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2824 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2826 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2829 MacroOffsetsBase - ASTBlockStartOffset};
2830 Stream.EmitRecordWithBlob(MacroOffsetAbbrev,
Record,
bytes(MacroOffsets));
2834void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec,
2835 uint64_t MacroOffsetsBase) {
2839 SmallVector<PPEntityOffset, 64> PreprocessedEntityOffsets;
2845 unsigned NumPreprocessingRecords = 0;
2846 using namespace llvm;
2849 unsigned InclusionAbbrev = 0;
2851 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2853 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2854 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2855 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2856 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2857 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2858 InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2862 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2864 for (PreprocessingRecord::iterator E = PPRec.
local_begin(),
2867 (
void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2870 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2871 assert((Offset >> 32) == 0 &&
"Preprocessed entity offset too large");
2872 SourceRange R = getAdjustedRange((*E)->getSourceRange());
2873 PreprocessedEntityOffsets.emplace_back(
2874 getRawSourceLocationEncoding(R.
getBegin()),
2875 getRawSourceLocationEncoding(R.
getEnd()), Offset);
2877 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*E)) {
2879 MacroDefinitions[MD] = NextPreprocessorEntityID;
2881 AddIdentifierRef(MD->getName(),
Record);
2886 if (
auto *ME = dyn_cast<MacroExpansion>(*E)) {
2887 Record.push_back(ME->isBuiltinMacro());
2888 if (ME->isBuiltinMacro())
2889 AddIdentifierRef(ME->getName(),
Record);
2891 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2896 if (
auto *ID = dyn_cast<InclusionDirective>(*E)) {
2898 Record.push_back(
ID->getFileName().size());
2899 Record.push_back(
ID->wasInQuotes());
2900 Record.push_back(
static_cast<unsigned>(
ID->getKind()));
2901 Record.push_back(
ID->importedModule());
2902 SmallString<64> Buffer;
2903 Buffer +=
ID->getFileName();
2907 Buffer +=
ID->getFile()->getName();
2908 Stream.EmitRecordWithBlob(InclusionAbbrev,
Record, Buffer);
2912 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2917 if (NumPreprocessingRecords > 0) {
2918 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2921 using namespace llvm;
2923 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2925 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2926 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2929 Stream.EmitRecordWithBlob(PPEOffsetAbbrev,
Record,
2930 bytes(PreprocessedEntityOffsets));
2935 if (SkippedRanges.size() > 0) {
2936 std::vector<PPSkippedRange> SerializedSkippedRanges;
2937 SerializedSkippedRanges.reserve(SkippedRanges.size());
2938 for (
auto const& Range : SkippedRanges)
2939 SerializedSkippedRanges.emplace_back(
2940 getRawSourceLocationEncoding(
Range.getBegin()),
2941 getRawSourceLocationEncoding(
Range.getEnd()));
2943 using namespace llvm;
2944 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2946 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2947 unsigned PPESkippedRangeAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2951 Stream.EmitRecordWithBlob(PPESkippedRangeAbbrev,
Record,
2952 bytes(SerializedSkippedRanges));
2960 auto Known = SubmoduleIDs.find(Mod);
2961 if (Known != SubmoduleIDs.end())
2962 return Known->second;
2965 if (Top != WritingModule &&
2967 !Top->fullModuleNameIs(StringRef(
getLangOpts().CurrentModule))))
2970 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2973unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2974 unsigned ID = getLocalOrImportedSubmoduleID(Mod);
2986 unsigned ChildModules = 0;
2990 return ChildModules + 1;
2993void ASTWriter::WriteSubmodules(
Module *WritingModule, ASTContext *Context) {
2998 using namespace llvm;
3000 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3002 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3003 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3004 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
3005 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
3006 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4));
3007 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3008 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3009 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3010 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3011 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3012 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3013 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3014 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3015 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3016 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3017 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3018 unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3020 Abbrev = std::make_shared<BitCodeAbbrev>();
3022 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3023 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3025 Abbrev = std::make_shared<BitCodeAbbrev>();
3027 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3028 unsigned HeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3030 Abbrev = std::make_shared<BitCodeAbbrev>();
3032 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3033 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3035 Abbrev = std::make_shared<BitCodeAbbrev>();
3037 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3038 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3040 Abbrev = std::make_shared<BitCodeAbbrev>();
3042 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3043 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3044 unsigned RequiresAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3046 Abbrev = std::make_shared<BitCodeAbbrev>();
3048 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3049 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3051 Abbrev = std::make_shared<BitCodeAbbrev>();
3053 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3054 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3056 Abbrev = std::make_shared<BitCodeAbbrev>();
3058 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3059 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3061 Abbrev = std::make_shared<BitCodeAbbrev>();
3063 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3064 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3066 Abbrev = std::make_shared<BitCodeAbbrev>();
3068 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3069 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3070 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3072 Abbrev = std::make_shared<BitCodeAbbrev>();
3074 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3075 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3077 Abbrev = std::make_shared<BitCodeAbbrev>();
3079 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3080 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3081 unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3083 Abbrev = std::make_shared<BitCodeAbbrev>();
3085 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3086 unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3089 RecordData::value_type
Record[] = {
3095 std::queue<Module *> Q;
3096 Q.push(WritingModule);
3097 while (!Q.empty()) {
3100 unsigned ID = getSubmoduleID(Mod);
3104 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
3105 ParentID = SubmoduleIDs[Mod->
Parent];
3109 getRawSourceLocationEncoding(getAdjustedLocation(Mod->
DefinitionLoc));
3112 FileID UnadjustedInferredFID;
3115 int InferredFID = getAdjustedFileID(UnadjustedInferredFID).getOpaqueValue();
3122 (RecordData::value_type)Mod->
Kind,
3124 (RecordData::value_type)InferredFID,
3135 Stream.EmitRecordWithBlob(DefinitionAbbrev,
Record, Mod->
Name);
3141 Stream.EmitRecordWithBlob(RequiresAbbrev,
Record, R.FeatureName);
3145 if (std::optional<Module::Header> UmbrellaHeader =
3148 Stream.EmitRecordWithBlob(UmbrellaAbbrev,
Record,
3149 UmbrellaHeader->NameAsWritten);
3150 }
else if (std::optional<Module::DirectoryName> UmbrellaDir =
3153 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev,
Record,
3154 UmbrellaDir->NameAsWritten);
3159 unsigned RecordKind;
3161 Module::HeaderKind HeaderKind;
3167 Module::HK_PrivateTextual},
3170 for (
const auto &HL : HeaderLists) {
3171 RecordData::value_type
Record[] = {HL.RecordKind};
3172 for (
const auto &H : Mod->
getHeaders(HL.HeaderKind))
3173 Stream.EmitRecordWithBlob(HL.Abbrev,
Record, H.NameAsWritten);
3180 SmallString<128> HeaderName(H.getName());
3181 PreparePathForOutput(HeaderName);
3182 Stream.EmitRecordWithBlob(TopHeaderAbbrev,
Record, HeaderName);
3190 Record.push_back(getSubmoduleID(I));
3198 Record.push_back(getSubmoduleID(I));
3205 for (
const auto &E : Mod->
Exports) {
3208 Record.push_back(getSubmoduleID(E.getPointer()));
3209 Record.push_back(E.getInt());
3224 Stream.EmitRecordWithBlob(LinkLibraryAbbrev,
Record, LL.Library);
3232 getSubmoduleID(
C.Other)};
3233 Stream.EmitRecordWithBlob(ConflictAbbrev,
Record,
C.Message);
3239 Stream.EmitRecordWithBlob(ConfigMacroAbbrev,
Record, CM);
3244 if (Context && !GeneratingReducedBMI) {
3247 if (wasDeclEmitted(D))
3248 AddDeclRef(D, Inits);
3266 assert((NextSubmoduleID - FirstSubmoduleID ==
3268 "Wrong # of submodules; found a reference to a non-local, "
3269 "non-imported submodule?");
3272void ASTWriter::WritePragmaDiagnosticMappings(
const DiagnosticsEngine &
Diag,
3274 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
3276 unsigned CurrID = 0;
3279 auto EncodeDiagStateFlags =
3280 [](
const DiagnosticsEngine::DiagState *DS) ->
unsigned {
3281 unsigned Result = (unsigned)DS->ExtBehavior;
3283 {(unsigned)DS->IgnoreAllWarnings, (
unsigned)DS->EnableAllWarnings,
3284 (unsigned)DS->WarningsAsErrors, (
unsigned)DS->ErrorsAsFatal,
3285 (unsigned)DS->SuppressSystemWarnings})
3290 unsigned Flags = EncodeDiagStateFlags(
Diag.DiagStatesByLoc.FirstDiagState);
3293 auto AddDiagState = [&](
const DiagnosticsEngine::DiagState *State,
3294 bool IncludeNonPragmaStates) {
3297 assert(Flags == EncodeDiagStateFlags(State) &&
3298 "diag state flags vary in single AST file");
3302 assert(!IncludeNonPragmaStates ||
3303 State ==
Diag.DiagStatesByLoc.FirstDiagState);
3305 unsigned &DiagStateID = DiagStateIDMap[State];
3306 Record.push_back(DiagStateID);
3308 if (DiagStateID == 0) {
3309 DiagStateID = ++CurrID;
3310 SmallVector<std::pair<unsigned, DiagnosticMapping>> Mappings;
3313 auto SizeIdx =
Record.size();
3315 for (
const auto &I : *State) {
3317 if (!I.second.isPragma() && !IncludeNonPragmaStates)
3321 if (!I.second.isPragma() &&
3322 I.second ==
Diag.getDiagnosticIDs()->getDefaultMapping(I.first))
3324 Mappings.push_back(I);
3328 llvm::sort(Mappings, llvm::less_first());
3330 for (
const auto &I : Mappings) {
3331 Record.push_back(I.first);
3332 Record.push_back(I.second.serialize());
3339 AddDiagState(
Diag.DiagStatesByLoc.FirstDiagState, isModule);
3342 auto NumLocationsIdx =
Record.size();
3346 unsigned NumLocations = 0;
3347 for (
auto &FileIDAndFile :
Diag.DiagStatesByLoc.Files) {
3348 if (!FileIDAndFile.first.isValid() ||
3349 !FileIDAndFile.second.HasLocalTransitions)
3353 AddFileID(FileIDAndFile.first,
Record);
3355 Record.push_back(FileIDAndFile.second.StateTransitions.size());
3356 for (
auto &StatePoint : FileIDAndFile.second.StateTransitions) {
3357 Record.push_back(getAdjustedOffset(StatePoint.Offset));
3358 AddDiagState(StatePoint.State,
false);
3363 Record[NumLocationsIdx] = NumLocations;
3371 AddSourceLocation(
Diag.DiagStatesByLoc.CurDiagStateLoc,
Record);
3372 AddDiagState(
Diag.DiagStatesByLoc.CurDiagState,
false);
3382void ASTWriter::WriteType(ASTContext &Context, QualType
T) {
3383 TypeIdx &IdxRef = TypeIdxs[
T];
3385 IdxRef = TypeIdx(0, NextTypeID++);
3386 TypeIdx Idx = IdxRef;
3389 assert(Idx.
getValue() >= FirstTypeID &&
"Writing predefined type");
3393 ASTTypeWriter(Context, *
this).write(
T) - DeclTypesBlockStartOffset;
3397 if (TypeOffsets.size() == Index)
3398 TypeOffsets.emplace_back(Offset);
3399 else if (TypeOffsets.size() < Index) {
3400 TypeOffsets.resize(Index + 1);
3401 TypeOffsets[Index].set(Offset);
3403 llvm_unreachable(
"Types emitted in wrong order");
3412 auto *ND = dyn_cast<NamedDecl>(D);
3427uint64_t ASTWriter::WriteDeclContextLexicalBlock(ASTContext &Context,
3428 const DeclContext *DC) {
3436 uint64_t Offset = Stream.GetCurrentBitNo();
3437 SmallVector<DeclID, 128> KindDeclPairs;
3438 for (
const auto *D : DC->
decls()) {
3439 if (DoneWritingDeclsAndTypes && !wasDeclEmitted(D))
3447 if (GeneratingReducedBMI && !D->isFromExplicitGlobalModule() &&
3451 KindDeclPairs.push_back(D->getKind());
3452 KindDeclPairs.push_back(GetDeclRef(D).getRawValue());
3455 ++NumLexicalDeclContexts;
3457 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev,
Record,
3458 bytes(KindDeclPairs));
3462void ASTWriter::WriteTypeDeclOffsets() {
3463 using namespace llvm;
3466 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3468 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3469 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3470 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3473 Stream.EmitRecordWithBlob(TypeOffsetAbbrev,
Record,
bytes(TypeOffsets));
3477 Abbrev = std::make_shared<BitCodeAbbrev>();
3479 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3480 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3481 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3484 Stream.EmitRecordWithBlob(DeclOffsetAbbrev,
Record,
bytes(DeclOffsets));
3488void ASTWriter::WriteFileDeclIDsMap() {
3489 using namespace llvm;
3491 SmallVector<std::pair<FileID, DeclIDInFileInfo *>, 64> SortedFileDeclIDs;
3492 SortedFileDeclIDs.reserve(FileDeclIDs.size());
3493 for (
const auto &P : FileDeclIDs)
3494 SortedFileDeclIDs.push_back(std::make_pair(P.first, P.second.get()));
3495 llvm::sort(SortedFileDeclIDs, llvm::less_first());
3498 SmallVector<DeclID, 256> FileGroupedDeclIDs;
3499 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
3500 DeclIDInFileInfo &Info = *FileDeclEntry.second;
3501 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
3502 llvm::stable_sort(Info.DeclIDs);
3503 for (
auto &LocDeclEntry : Info.DeclIDs)
3504 FileGroupedDeclIDs.push_back(LocDeclEntry.second.getRawValue());
3507 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3509 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3510 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3511 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
3513 FileGroupedDeclIDs.size()};
3514 Stream.EmitRecordWithBlob(AbbrevCode,
Record,
bytes(FileGroupedDeclIDs));
3517void ASTWriter::WriteComments(ASTContext &Context) {
3519 llvm::scope_exit _([
this] { Stream.ExitBlock(); });
3526 if (isWritingStdCXXNamedModules())
3530 for (
const auto &FO : Context.
Comments.OrderedComments) {
3531 for (
const auto &OC : FO.second) {
3532 const RawComment *I = OC.second;
3550class ASTMethodPoolTrait {
3554 using key_type = Selector;
3555 using key_type_ref = key_type;
3559 ObjCMethodList Instance, Factory;
3561 using data_type_ref =
const data_type &;
3563 using hash_value_type = unsigned;
3564 using offset_type = unsigned;
3566 explicit ASTMethodPoolTrait(ASTWriter &Writer) : Writer(Writer) {}
3568 static hash_value_type
ComputeHash(Selector Sel) {
3572 std::pair<unsigned, unsigned>
3573 EmitKeyDataLength(raw_ostream& Out, Selector Sel,
3574 data_type_ref Methods) {
3578 unsigned DataLen = 4 + 2 + 2;
3579 for (
const ObjCMethodList *
Method = &Methods.Instance;
Method;
3581 if (ShouldWriteMethodListNode(
Method))
3582 DataLen +=
sizeof(
DeclID);
3583 for (
const ObjCMethodList *
Method = &Methods.Factory;
Method;
3585 if (ShouldWriteMethodListNode(
Method))
3586 DataLen +=
sizeof(
DeclID);
3590 void EmitKey(raw_ostream& Out, Selector Sel,
unsigned) {
3591 using namespace llvm::support;
3593 endian::Writer
LE(Out, llvm::endianness::little);
3595 assert((Start >> 32) == 0 &&
"Selector key offset too large");
3598 LE.write<uint16_t>(N);
3601 for (
unsigned I = 0; I != N; ++I)
3606 void EmitData(raw_ostream& Out, key_type_ref,
3607 data_type_ref Methods,
unsigned DataLen) {
3608 using namespace llvm::support;
3610 endian::Writer
LE(Out, llvm::endianness::little);
3613 unsigned NumInstanceMethods = 0;
3614 for (
const ObjCMethodList *
Method = &Methods.Instance;
Method;
3616 if (ShouldWriteMethodListNode(
Method))
3617 ++NumInstanceMethods;
3619 unsigned NumFactoryMethods = 0;
3620 for (
const ObjCMethodList *
Method = &Methods.Factory;
Method;
3622 if (ShouldWriteMethodListNode(
Method))
3623 ++NumFactoryMethods;
3625 unsigned InstanceBits = Methods.Instance.getBits();
3626 assert(InstanceBits < 4);
3627 unsigned InstanceHasMoreThanOneDeclBit =
3628 Methods.Instance.hasMoreThanOneDecl();
3629 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
3630 (InstanceHasMoreThanOneDeclBit << 2) |
3632 unsigned FactoryBits = Methods.Factory.getBits();
3633 assert(FactoryBits < 4);
3634 unsigned FactoryHasMoreThanOneDeclBit =
3635 Methods.Factory.hasMoreThanOneDecl();
3636 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
3637 (FactoryHasMoreThanOneDeclBit << 2) |
3639 LE.write<uint16_t>(FullInstanceBits);
3640 LE.write<uint16_t>(FullFactoryBits);
3641 for (
const ObjCMethodList *
Method = &Methods.Instance;
Method;
3643 if (ShouldWriteMethodListNode(
Method))
3645 for (
const ObjCMethodList *
Method = &Methods.Factory;
Method;
3647 if (ShouldWriteMethodListNode(
Method))
3650 assert(
Out.tell() - Start == DataLen &&
"Data length is wrong");
3654 static bool ShouldWriteMethodListNode(
const ObjCMethodList *Node) {
3666void ASTWriter::WriteSelectors(Sema &SemaRef) {
3667 using namespace llvm;
3672 unsigned NumTableEntries = 0;
3675 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait>
Generator;
3676 ASTMethodPoolTrait Trait(*
this);
3680 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
3681 for (
auto &SelectorAndID : SelectorIDs) {
3682 Selector S = SelectorAndID.first;
3684 SemaObjC::GlobalMethodPool::iterator F =
3686 ASTMethodPoolTrait::data_type
Data = {
3692 Data.Instance = F->second.first;
3693 Data.Factory = F->second.second;
3697 if (Chain && ID < FirstSelectorID) {
3699 bool changed =
false;
3700 for (ObjCMethodList *M = &
Data.Instance; M && M->getMethod();
3702 if (!M->getMethod()->isFromASTFile()) {
3708 for (ObjCMethodList *M = &
Data.Factory; M && M->getMethod();
3710 if (!M->getMethod()->isFromASTFile()) {
3718 }
else if (
Data.Instance.getMethod() ||
Data.Factory.getMethod()) {
3726 SmallString<4096> MethodPool;
3729 using namespace llvm::support;
3731 ASTMethodPoolTrait Trait(*
this);
3732 llvm::raw_svector_ostream
Out(MethodPool);
3734 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
3735 BucketOffset =
Generator.Emit(Out, Trait);
3739 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3741 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3742 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3743 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3744 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3750 Stream.EmitRecordWithBlob(MethodPoolAbbrev,
Record, MethodPool);
3754 Abbrev = std::make_shared<BitCodeAbbrev>();
3756 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3757 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3758 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3759 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3763 RecordData::value_type
Record[] = {
3766 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev,
Record,
3767 bytes(SelectorOffsets));
3773void ASTWriter::WriteReferencedSelectorsPool(Sema &SemaRef) {
3774 using namespace llvm;
3786 Selector Sel = SelectorAndLocation.first;
3787 SourceLocation Loc = SelectorAndLocation.second;
3788 Writer.AddSelectorRef(Sel);
3810 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3812 if (!Redecl->isFromASTFile()) {
3816 if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
3824 if (Redecl->getOwningModuleID() == 0)
3829 if (!
First->isFromASTFile())
3840bool IsInterestingIdentifier(
const IdentifierInfo *II, uint64_t MacroOffset,
3841 bool IsModule,
bool IsCPlusPlus) {
3842 bool NeedDecls = !IsModule || !IsCPlusPlus;
3844 bool IsInteresting =
3851 II->
isPoisoned() || (!IsModule && IsInteresting) ||
3859bool IsInterestingNonMacroIdentifier(
const IdentifierInfo *II,
3860 ASTWriter &Writer) {
3862 bool IsCPlusPlus = Writer.
getLangOpts().CPlusPlus;
3863 return IsInterestingIdentifier(II, 0, IsModule, IsCPlusPlus);
3866class ASTIdentifierTableTrait {
3869 IdentifierResolver *IdResolver;
3879 return IsInterestingIdentifier(II, MacroOffset, IsModule,
3884 using key_type =
const IdentifierInfo *;
3885 using key_type_ref = key_type;
3888 using data_type_ref = data_type;
3890 using hash_value_type = unsigned;
3891 using offset_type = unsigned;
3893 ASTIdentifierTableTrait(ASTWriter &Writer, Preprocessor &PP,
3894 IdentifierResolver *IdResolver,
bool IsModule,
3896 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3897 NeedDecls(!IsModule || !Writer.getLangOpts().
CPlusPlus),
3898 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3900 bool needDecls()
const {
return NeedDecls; }
3902 static hash_value_type
ComputeHash(
const IdentifierInfo* II) {
3903 return llvm::djbHash(II->
getName());
3911 std::pair<unsigned, unsigned>
3912 EmitKeyDataLength(raw_ostream &Out,
const IdentifierInfo *II,
IdentifierID ID) {
3921 if (InterestingIdentifierOffsets &&
3923 InterestingIdentifierOffsets->push_back(
Out.tell());
3934 if (NeedDecls && IdResolver)
3935 DataLen += std::distance(IdResolver->
begin(II), IdResolver->
end()) *
3941 void EmitKey(raw_ostream &Out,
const IdentifierInfo *II,
unsigned KeyLen) {
3945 void EmitData(raw_ostream &Out,
const IdentifierInfo *II,
IdentifierID ID,
3947 using namespace llvm::support;
3949 endian::Writer
LE(Out, llvm::endianness::little);
3959 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
3960 LE.write<uint16_t>(Bits);
3962 bool HasMacroDefinition =
3965 Bits = (Bits << 1) |
unsigned(HasMacroDefinition);
3967 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
3970 LE.write<uint16_t>(Bits);
3972 if (HasMacroDefinition)
3975 if (NeedDecls && IdResolver) {
3982 SmallVector<NamedDecl *, 16> Decls(IdResolver->
decls(II));
3983 for (NamedDecl *D : llvm::reverse(Decls))
4001void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
4002 IdentifierResolver *IdResolver,
4004 using namespace llvm;
4006 RecordData InterestingIdents;
4011 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait>
Generator;
4012 ASTIdentifierTableTrait Trait(*
this, PP, IdResolver, IsModule,
4013 IsModule ? &InterestingIdents :
nullptr);
4017 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
4018 for (
auto IdentIDPair : IdentifierIDs) {
4019 const IdentifierInfo *II = IdentIDPair.first;
4021 assert(II &&
"NULL identifier in identifier table");
4026 (Trait.needDecls() &&
4032 SmallString<4096> IdentifierTable;
4035 using namespace llvm::support;
4037 llvm::raw_svector_ostream
Out(IdentifierTable);
4039 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
4040 BucketOffset =
Generator.Emit(Out, Trait);
4044 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4046 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
4047 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4048 unsigned IDTableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4052 Stream.EmitRecordWithBlob(IDTableAbbrev,
Record, IdentifierTable);
4056 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4058 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
4059 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4060 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4063 for (
unsigned I = 0, N = IdentifierOffsets.size(); I != N; ++I)
4064 assert(IdentifierOffsets[I] &&
"Missing identifier offset?");
4068 IdentifierOffsets.size()};
4069 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev,
Record,
4070 bytes(IdentifierOffsets));
4074 if (!InterestingIdents.empty())
4082 PendingEmittingVTables.push_back(RD);
4086 TouchedModuleFiles.insert(MF);
4095class ASTDeclContextNameLookupTraitBase {
4103 using data_type = std::pair<unsigned, unsigned>;
4104 using data_type_ref =
const data_type &;
4109 explicit ASTDeclContextNameLookupTraitBase(
ASTWriter &Writer)
4112 data_type getData(
const DeclIDsTy &LocalIDs) {
4113 unsigned Start = DeclIDs.size();
4114 for (
auto ID : LocalIDs)
4115 DeclIDs.push_back(ID);
4116 return std::make_pair(Start, DeclIDs.size());
4119 data_type ImportData(
const reader::ASTDeclContextNameLookupTrait::data_type &FromReader) {
4120 unsigned Start = DeclIDs.size();
4123 DeclIDIterator<GlobalDeclID, LocalDeclID>(FromReader.begin()),
4124 DeclIDIterator<GlobalDeclID, LocalDeclID>(FromReader.end()));
4125 return std::make_pair(Start, DeclIDs.size());
4128 void EmitFileRef(raw_ostream &Out, ModuleFile *F)
const {
4130 "have reference to loaded module file but no chain?");
4132 using namespace llvm::support;
4135 llvm::endianness::little);
4138 std::pair<unsigned, unsigned> EmitKeyDataLengthBase(raw_ostream &Out,
4139 DeclarationNameKey Name,
4140 data_type_ref Lookup) {
4141 unsigned KeyLen = 1;
4164 unsigned DataLen =
sizeof(
DeclID) * (Lookup.second - Lookup.first);
4166 return {KeyLen, DataLen};
4169 void EmitKeyBase(raw_ostream &Out, DeclarationNameKey Name) {
4170 using namespace llvm::support;
4172 endian::Writer
LE(Out, llvm::endianness::little);
4187 "Invalid operator?");
4197 llvm_unreachable(
"Invalid name kind?");
4200 void EmitDataBase(raw_ostream &Out, data_type Lookup,
unsigned DataLen) {
4201 using namespace llvm::support;
4203 endian::Writer
LE(Out, llvm::endianness::little);
4205 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
4207 assert(
Out.tell() - Start == DataLen &&
"Data length is wrong");
4211class ModuleLevelNameLookupTrait :
public ASTDeclContextNameLookupTraitBase {
4213 using primary_module_hash_type = unsigned;
4215 using key_type = std::pair<DeclarationNameKey, primary_module_hash_type>;
4216 using key_type_ref = key_type;
4218 explicit ModuleLevelNameLookupTrait(ASTWriter &Writer)
4219 : ASTDeclContextNameLookupTraitBase(Writer) {}
4221 static bool EqualKey(key_type_ref a, key_type_ref
b) {
return a ==
b; }
4224 llvm::FoldingSetNodeID
ID;
4225 ID.AddInteger(Key.first.getHash());
4226 ID.AddInteger(Key.second);
4227 return ID.computeStableHash();
4230 std::pair<unsigned, unsigned>
4231 EmitKeyDataLength(raw_ostream &Out, key_type Key, data_type_ref Lookup) {
4232 auto [KeyLen, DataLen] = EmitKeyDataLengthBase(Out, Key.first, Lookup);
4233 KeyLen +=
sizeof(Key.second);
4237 void EmitKey(raw_ostream &Out, key_type Key,
unsigned) {
4238 EmitKeyBase(Out, Key.first);
4239 llvm::support::endian::Writer
LE(Out, llvm::endianness::little);
4240 LE.write<primary_module_hash_type>(Key.second);
4243 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4245 EmitDataBase(Out, Lookup, DataLen);
4249class ASTDeclContextNameTrivialLookupTrait
4250 :
public ASTDeclContextNameLookupTraitBase {
4252 using key_type = DeclarationNameKey;
4253 using key_type_ref = key_type;
4256 using ASTDeclContextNameLookupTraitBase::ASTDeclContextNameLookupTraitBase;
4258 using ASTDeclContextNameLookupTraitBase::getData;
4260 static bool EqualKey(key_type_ref a, key_type_ref
b) {
return a ==
b; }
4262 hash_value_type
ComputeHash(key_type Name) {
return Name.getHash(); }
4264 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
4265 DeclarationNameKey Name,
4266 data_type_ref Lookup) {
4267 auto [KeyLen, DataLen] = EmitKeyDataLengthBase(Out, Name, Lookup);
4271 void EmitKey(raw_ostream &Out, DeclarationNameKey Name,
unsigned) {
4272 return EmitKeyBase(Out, Name);
4275 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4277 EmitDataBase(Out, Lookup, DataLen);
4281static bool isModuleLocalDecl(NamedDecl *D) {
4286 return isModuleLocalDecl(Parent);
4290 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
4291 if (
auto *CDGD = dyn_cast<CXXDeductionGuideDecl>(FTD->getTemplatedDecl()))
4292 return isModuleLocalDecl(CDGD->getDeducedTemplate());
4308static bool isTULocalInNamedModules(NamedDecl *D) {
4331class ASTDeclContextNameLookupTrait
4332 :
public ASTDeclContextNameTrivialLookupTrait {
4334 using TULocalDeclsMapTy = llvm::DenseMap<key_type, DeclIDsTy>;
4336 using ModuleLevelDeclsMapTy =
4337 llvm::DenseMap<ModuleLevelNameLookupTrait::key_type, DeclIDsTy>;
4340 enum class LookupVisibility {
4350 LookupVisibility getLookupVisibility(NamedDecl *D)
const {
4353 return LookupVisibility::GenerallyVisibile;
4355 if (isModuleLocalDecl(D))
4356 return LookupVisibility::ModuleLocalVisible;
4357 if (isTULocalInNamedModules(D))
4358 return LookupVisibility::TULocal;
4370 if (
auto *ECD = dyn_cast<EnumConstantDecl>(D);
4371 ECD && DC.
isFileContext() && ECD->getTopLevelOwningNamedModule()) {
4376 return Found->isInvisibleOutsideTheOwningModule();
4378 return ECD->isFromExplicitGlobalModule() ||
4379 ECD->isInAnonymousNamespace()
4380 ? LookupVisibility::TULocal
4381 : LookupVisibility::ModuleLocalVisible;
4384 return LookupVisibility::GenerallyVisibile;
4388 ModuleLevelDeclsMapTy ModuleLocalDeclsMap;
4389 TULocalDeclsMapTy TULocalDeclsMap;
4392 using ASTDeclContextNameTrivialLookupTrait::
4393 ASTDeclContextNameTrivialLookupTrait;
4395 ASTDeclContextNameLookupTrait(ASTWriter &Writer, DeclContext &DC)
4396 : ASTDeclContextNameTrivialLookupTrait(Writer), DC(DC) {}
4398 template <
typename Coll> data_type getData(
const Coll &Decls) {
4399 unsigned Start = DeclIDs.size();
4400 for (NamedDecl *D : Decls) {
4401 NamedDecl *DeclForLocalLookup =
4417 switch (getLookupVisibility(DeclForLocalLookup)) {
4418 case LookupVisibility::ModuleLocalVisible:
4419 if (UnsignedOrNone PrimaryModuleHash =
4421 auto Key = std::make_pair(D->
getDeclName(), *PrimaryModuleHash);
4422 auto Iter = ModuleLocalDeclsMap.find(Key);
4423 if (Iter == ModuleLocalDeclsMap.end())
4424 ModuleLocalDeclsMap.insert({Key, DeclIDsTy{
ID}});
4426 Iter->second.push_back(ID);
4430 case LookupVisibility::TULocal: {
4431 auto Iter = TULocalDeclsMap.find(D->
getDeclName());
4432 if (Iter == TULocalDeclsMap.end())
4435 Iter->second.push_back(ID);
4438 case LookupVisibility::GenerallyVisibile:
4443 DeclIDs.push_back(ID);
4445 return std::make_pair(Start, DeclIDs.size());
4448 const ModuleLevelDeclsMapTy &getModuleLocalDecls() {
4449 return ModuleLocalDeclsMap;
4452 const TULocalDeclsMapTy &getTULocalDecls() {
return TULocalDeclsMap; }
4458class LazySpecializationInfoLookupTrait {
4460 llvm::SmallVector<serialization::reader::LazySpecializationInfo, 64> Specs;
4463 using key_type = unsigned;
4464 using key_type_ref = key_type;
4467 using data_type = std::pair<unsigned, unsigned>;
4468 using data_type_ref =
const data_type &;
4470 using hash_value_type = unsigned;
4471 using offset_type = unsigned;
4473 explicit LazySpecializationInfoLookupTrait(ASTWriter &Writer)
4476 template <
typename Col,
typename Col2>
4477 data_type getData(Col &&
C, Col2 &ExistingInfo) {
4478 unsigned Start = Specs.size();
4481 const_cast<NamedDecl *
>(D));
4486 Specs.push_back(Info);
4487 return std::make_pair(Start, Specs.size());
4490 data_type ImportData(
4492 unsigned Start = Specs.size();
4493 for (
auto ID : FromReader)
4494 Specs.push_back(ID);
4495 return std::make_pair(Start, Specs.size());
4498 static bool EqualKey(key_type_ref a, key_type_ref
b) {
return a ==
b; }
4500 hash_value_type
ComputeHash(key_type Name) {
return Name; }
4502 void EmitFileRef(raw_ostream &Out, ModuleFile *F)
const {
4504 "have reference to loaded module file but no chain?");
4506 using namespace llvm::support;
4509 llvm::endianness::little);
4512 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
4514 data_type_ref Lookup) {
4516 unsigned KeyLen = 4;
4518 (Lookup.second - Lookup.first);
4523 void EmitKey(raw_ostream &Out, key_type HashValue,
unsigned) {
4524 using namespace llvm::support;
4526 endian::Writer
LE(Out, llvm::endianness::little);
4530 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4532 using namespace llvm::support;
4534 endian::Writer
LE(Out, llvm::endianness::little);
4537 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I) {
4538 LE.write<
DeclID>(Specs[I].getRawValue());
4540 assert(
Out.tell() - Start == DataLen &&
"Data length is wrong");
4544unsigned CalculateODRHashForSpecs(
const Decl *Spec) {
4545 ArrayRef<TemplateArgument> Args;
4546 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Spec))
4547 Args = CTSD->getTemplateArgs().asArray();
4548 else if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Spec))
4549 Args = VTSD->getTemplateArgs().asArray();
4550 else if (
auto *FD = dyn_cast<FunctionDecl>(Spec))
4551 Args = FD->getTemplateSpecializationArgs()->asArray();
4553 llvm_unreachable(
"New Specialization Kind?");
4559void ASTWriter::GenerateSpecializationInfoLookupTable(
4560 const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
4561 llvm::SmallVectorImpl<char> &LookupTable,
bool IsPartial) {
4565 MultiOnDiskHashTableGenerator<reader::LazySpecializationInfoLookupTrait,
4566 LazySpecializationInfoLookupTrait>
4568 LazySpecializationInfoLookupTrait Trait(*
this);
4570 llvm::MapVector<unsigned, llvm::SmallVector<const NamedDecl *, 4>>
4576 auto Iter = SpecializationMaps.find(HashedValue);
4577 if (Iter == SpecializationMaps.end())
4578 Iter = SpecializationMaps
4579 .try_emplace(HashedValue,
4580 llvm::SmallVector<const NamedDecl *, 4>())
4587 Chain ? Chain->getLoadedSpecializationsLookupTables(D, IsPartial)
4590 for (
auto &[HashValue, Specs] : SpecializationMaps) {
4591 SmallVector<serialization::reader::LazySpecializationInfo, 16>
4601 ExisitingSpecs = Lookups->Table.find(HashValue);
4603 Generator.insert(HashValue, Trait.getData(Specs, ExisitingSpecs), Trait);
4606 Generator.emit(LookupTable, Trait, Lookups ? &Lookups->Table :
nullptr);
4609uint64_t ASTWriter::WriteSpecializationInfoLookupTable(
4610 const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
4613 llvm::SmallString<4096> LookupTable;
4614 GenerateSpecializationInfoLookupTable(D, Specializations, LookupTable,
4617 uint64_t Offset = Stream.GetCurrentBitNo();
4618 RecordData::value_type
Record[] = {
static_cast<RecordData::value_type
>(
4620 Stream.EmitRecordWithBlob(IsPartial ? DeclPartialSpecializationsAbbrev
4621 : DeclSpecializationsAbbrev,
4633 for (
auto *D : Result.getLookupResult()) {
4635 if (LocalD->isFromASTFile())
4653void ASTWriter::GenerateNameLookupTable(
4654 ASTContext &Context,
const DeclContext *ConstDC,
4655 llvm::SmallVectorImpl<char> &LookupTable,
4656 llvm::SmallVectorImpl<char> &ModuleLocalLookupTable,
4657 llvm::SmallVectorImpl<char> &TULookupTable) {
4658 assert(!ConstDC->hasLazyLocalLexicalLookups() &&
4659 !ConstDC->hasLazyExternalLexicalLookups() &&
4660 "must call buildLookups first");
4663 auto *DC =
const_cast<DeclContext*
>(ConstDC);
4667 MultiOnDiskHashTableGenerator<reader::ASTDeclContextNameLookupTrait,
4668 ASTDeclContextNameLookupTrait>
4670 ASTDeclContextNameLookupTrait Trait(*
this, *DC);
4675 SmallVector<DeclarationName, 16> Names;
4679 bool IncludeConstructorNames =
false;
4680 bool IncludeConversionNames =
false;
4707 if (
Result.getLookupResult().empty())
4710 switch (Name.getNameKind()) {
4712 Names.push_back(Name);
4716 IncludeConstructorNames =
true;
4720 IncludeConversionNames =
true;
4728 if (IncludeConstructorNames || IncludeConversionNames) {
4733 llvm::SmallPtrSet<DeclarationName, 8> AddedNames;
4735 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
4736 auto Name = ChildND->getDeclName();
4737 switch (Name.getNameKind()) {
4742 if (!IncludeConstructorNames)
4747 if (!IncludeConversionNames)
4751 if (AddedNames.insert(Name).second)
4752 Names.push_back(Name);
4760 for (
auto &Name : Names)
4767 SmallVector<NamedDecl *, 8> ConstructorDecls;
4768 SmallVector<NamedDecl *, 8> ConversionDecls;
4772 for (
auto &Name : Names) {
4775 switch (Name.getNameKind()) {
4793 if (!ConstructorDecls.empty())
4794 Generator.insert(ConstructorDecls.front()->getDeclName(),
4795 Trait.getData(ConstructorDecls), Trait);
4796 if (!ConversionDecls.empty())
4797 Generator.insert(ConversionDecls.front()->getDeclName(),
4798 Trait.getData(ConversionDecls), Trait);
4802 auto *Lookups = Chain ? Chain->getLoadedLookupTables(DC) :
nullptr;
4803 Generator.emit(LookupTable, Trait, Lookups ? &Lookups->Table :
nullptr);
4805 const auto &ModuleLocalDecls = Trait.getModuleLocalDecls();
4806 if (!ModuleLocalDecls.empty()) {
4807 MultiOnDiskHashTableGenerator<reader::ModuleLocalNameLookupTrait,
4808 ModuleLevelNameLookupTrait>
4809 ModuleLocalLookupGenerator;
4810 ModuleLevelNameLookupTrait ModuleLocalTrait(*
this);
4812 for (
const auto &ModuleLocalIter : ModuleLocalDecls) {
4813 const auto &Key = ModuleLocalIter.first;
4814 const auto &IDs = ModuleLocalIter.second;
4815 ModuleLocalLookupGenerator.insert(Key, ModuleLocalTrait.getData(IDs),
4819 auto *ModuleLocalLookups =
4820 Chain ? Chain->getModuleLocalLookupTables(DC) :
nullptr;
4821 ModuleLocalLookupGenerator.emit(
4822 ModuleLocalLookupTable, ModuleLocalTrait,
4823 ModuleLocalLookups ? &ModuleLocalLookups->Table :
nullptr);
4826 const auto &TULocalDecls = Trait.getTULocalDecls();
4827 if (!TULocalDecls.empty() && !isGeneratingReducedBMI()) {
4828 MultiOnDiskHashTableGenerator<reader::ASTDeclContextNameLookupTrait,
4829 ASTDeclContextNameTrivialLookupTrait>
4831 ASTDeclContextNameTrivialLookupTrait TULocalTrait(*
this);
4833 for (
const auto &TULocalIter : TULocalDecls) {
4834 const auto &Key = TULocalIter.first;
4835 const auto &IDs = TULocalIter.second;
4836 TULookupGenerator.insert(Key, TULocalTrait.getData(IDs), TULocalTrait);
4839 auto *TULocalLookups = Chain ? Chain->getTULocalLookupTables(DC) :
nullptr;
4840 TULookupGenerator.emit(TULookupTable, TULocalTrait,
4841 TULocalLookups ? &TULocalLookups->Table :
nullptr);
4850void ASTWriter::WriteDeclContextVisibleBlock(
4851 ASTContext &Context, DeclContext *DC, VisibleLookupBlockOffsets &Offsets) {
4858 Chain->getKeyDeclaration(
cast<Decl>(DC))->isFromASTFile()) {
4861 Prev = Prev->getPreviousDecl())
4862 if (!Prev->isFromASTFile())
4872 SmallVector<std::pair<DeclarationName, DeclContext::lookup_result>, 16>
4875 LookupResults.reserve(Map->size());
4876 for (
auto &Entry : *Map)
4877 LookupResults.push_back(
4878 std::make_pair(Entry.first, Entry.second.getLookupResult()));
4881 llvm::sort(LookupResults, llvm::less_first());
4882 for (
auto &NameAndResult : LookupResults) {
4883 DeclarationName Name = NameAndResult.first;
4890 assert(
Result.empty() &&
"Cannot have a constructor or conversion "
4891 "function name in a namespace!");
4895 for (NamedDecl *ND :
Result) {
4899 if (DoneWritingDeclsAndTypes && !wasDeclEmitted(ND))
4933 if (!Map || Map->empty())
4938 SmallString<4096> LookupTable;
4939 SmallString<4096> ModuleLocalLookupTable;
4940 SmallString<4096> TULookupTable;
4941 GenerateNameLookupTable(Context, DC, LookupTable, ModuleLocalLookupTable,
4946 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev,
Record,
4948 ++NumVisibleDeclContexts;
4950 if (!ModuleLocalLookupTable.empty()) {
4954 RecordData::value_type ModuleLocalRecord[] = {
4956 Stream.EmitRecordWithBlob(DeclModuleLocalVisibleLookupAbbrev,
4957 ModuleLocalRecord, ModuleLocalLookupTable);
4958 ++NumModuleLocalDeclContexts;
4961 if (!TULookupTable.empty()) {
4964 RecordData::value_type TULocalDeclsRecord[] = {
4966 Stream.EmitRecordWithBlob(DeclTULocalLookupAbbrev, TULocalDeclsRecord,
4968 ++NumTULocalDeclContexts;
4978void ASTWriter::WriteDeclContextVisibleUpdate(ASTContext &Context,
4979 const DeclContext *DC) {
4981 if (!Map || Map->empty())
4985 SmallString<4096> LookupTable;
4986 SmallString<4096> ModuleLocalLookupTable;
4987 SmallString<4096> TULookupTable;
4988 GenerateNameLookupTable(Context, DC, LookupTable, ModuleLocalLookupTable,
4999 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev,
Record, LookupTable);
5001 if (!ModuleLocalLookupTable.empty()) {
5003 RecordData::value_type ModuleLocalRecord[] = {
5005 Stream.EmitRecordWithBlob(ModuleLocalUpdateVisibleAbbrev, ModuleLocalRecord,
5006 ModuleLocalLookupTable);
5009 if (!TULookupTable.empty()) {
5010 RecordData::value_type GMFRecord[] = {
5012 Stream.EmitRecordWithBlob(TULocalUpdateVisibleAbbrev, GMFRecord,
5018void ASTWriter::WriteFPPragmaOptions(
const FPOptionsOverride &Opts) {
5024void ASTWriter::WriteOpenCLExtensions(Sema &SemaRef) {
5030 for (
const auto &I:Opts.OptMap) {
5031 AddString(I.getKey(),
Record);
5032 auto V = I.getValue();
5033 Record.push_back(
V.Supported ? 1 : 0);
5034 Record.push_back(
V.Enabled ? 1 : 0);
5035 Record.push_back(
V.WithPragma ? 1 : 0);
5042void ASTWriter::WriteCUDAPragmas(Sema &SemaRef) {
5043 if (SemaRef.
CUDA().ForceHostDeviceDepth > 0) {
5044 RecordData::value_type
Record[] = {SemaRef.
CUDA().ForceHostDeviceDepth};
5049void ASTWriter::WriteObjCCategories() {
5050 if (ObjCClassesWithCategories.empty())
5053 SmallVector<ObjCCategoriesInfo, 2> CategoriesMap;
5054 RecordData Categories;
5056 for (
unsigned I = 0, N = ObjCClassesWithCategories.size(); I != N; ++I) {
5058 unsigned StartIndex = Categories.size();
5060 ObjCInterfaceDecl *
Class = ObjCClassesWithCategories[I];
5063 Categories.push_back(0);
5067 Cat =
Class->known_categories_begin(),
5068 CatEnd =
Class->known_categories_end();
5069 Cat != CatEnd; ++Cat, ++Size) {
5070 assert(getDeclID(*Cat).isValid() &&
"Bogus category");
5071 AddDeclRef(*Cat, Categories);
5075 Categories[StartIndex] =
Size;
5078 ObjCCategoriesInfo CatInfo = { getDeclID(
Class), StartIndex };
5079 CategoriesMap.push_back(CatInfo);
5084 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
5087 using namespace llvm;
5089 auto Abbrev = std::make_shared<BitCodeAbbrev>();
5091 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
5092 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
5093 unsigned AbbrevID = Stream.EmitAbbrev(std::move(Abbrev));
5096 Stream.EmitRecordWithBlob(AbbrevID,
Record,
5097 reinterpret_cast<char *
>(CategoriesMap.data()),
5098 CategoriesMap.size() *
sizeof(ObjCCategoriesInfo));
5104void ASTWriter::WriteLateParsedTemplates(Sema &SemaRef) {
5111 for (
auto &LPTMapEntry : LPTMap) {
5112 const FunctionDecl *FD = LPTMapEntry.first;
5113 LateParsedTemplate &LPT = *LPTMapEntry.second;
5119 for (
const auto &
Tok : LPT.
Toks) {
5127void ASTWriter::WriteOptimizePragmaOptions(Sema &SemaRef) {
5130 AddSourceLocation(PragmaLoc,
Record);
5135void ASTWriter::WriteMSStructPragmaOptions(Sema &SemaRef) {
5143void ASTWriter::WriteMSPointersToMembersPragmaOptions(Sema &SemaRef) {
5151void ASTWriter::WritePackPragmaOptions(Sema &SemaRef) {
5162 AddAlignPackInfo(StackEntry.Value,
Record);
5163 AddSourceLocation(StackEntry.PragmaLocation,
Record);
5164 AddSourceLocation(StackEntry.PragmaPushLocation,
Record);
5165 AddString(StackEntry.StackSlotLabel,
Record);
5171void ASTWriter::WriteFloatControlPragmaOptions(Sema &SemaRef) {
5181 for (
const auto &StackEntry : SemaRef.
FpPragmaStack.Stack) {
5182 Record.push_back(StackEntry.Value.getAsOpaqueInt());
5183 AddSourceLocation(StackEntry.PragmaLocation,
Record);
5184 AddSourceLocation(StackEntry.PragmaPushLocation,
Record);
5185 AddString(StackEntry.StackSlotLabel,
Record);
5191void ASTWriter::WriteDeclsWithEffectsToVerify(Sema &SemaRef) {
5201void ASTWriter::WriteModuleFileExtension(Sema &SemaRef,
5202 ModuleFileExtensionWriter &Writer) {
5207 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
5209 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5210 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5211 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5212 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5213 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
5214 unsigned Abbrev = Stream.EmitAbbrev(std::move(Abv));
5220 Record.push_back(Metadata.MajorVersion);
5221 Record.push_back(Metadata.MinorVersion);
5222 Record.push_back(Metadata.BlockName.size());
5223 Record.push_back(Metadata.UserInfo.size());
5224 SmallString<64> Buffer;
5225 Buffer += Metadata.BlockName;
5226 Buffer += Metadata.UserInfo;
5227 Stream.EmitRecordWithBlob(Abbrev,
Record, Buffer);
5236void ASTWriter::WriteRISCVIntrinsicPragmas(Sema &SemaRef) {
5251 auto &Record = *
this;
5257 Writer->isWritingStdCXXHeaderUnit())))
5258 return Record.push_back(0);
5260 Record.push_back(A->
getKind() + 1);
5264 Record.AddSourceRange(A->
getRange());
5268 Record.push_back(A->getAttributeSpellingListIndexRaw());
5271#include "clang/Serialization/AttrPCHWrite.inc"
5277 for (
const auto *A : Attrs)
5288 if (
Tok.isAnnotation()) {
5290 switch (
Tok.getKind()) {
5291 case tok::annot_pragma_loop_hint: {
5295 Record.push_back(Info->Toks.size());
5296 for (
const auto &
T : Info->Toks)
5300 case tok::annot_pragma_pack: {
5303 Record.push_back(
static_cast<unsigned>(Info->Action));
5309 case tok::annot_pragma_openmp:
5310 case tok::annot_pragma_openmp_end:
5311 case tok::annot_pragma_unused:
5312 case tok::annot_pragma_openacc:
5313 case tok::annot_pragma_openacc_end:
5314 case tok::annot_repl_input_end:
5317 llvm_unreachable(
"missing serialization code for annotation token");
5328 Record.push_back(Str.size());
5329 llvm::append_range(
Record, Str);
5334 Record.push_back(Str.size());
5335 llvm::append_range(Blob, Str);
5339 assert(WritingAST &&
"can't prepare path for output when not writing AST");
5342 StringRef PathStr(Path.data(), Path.size());
5343 if (PathStr ==
"<built-in>" || PathStr ==
"<command line>")
5349 const char *PathBegin = Path.data();
5350 const char *PathPtr =
5352 if (PathPtr != PathBegin) {
5353 Path.erase(Path.begin(), Path.begin() + (PathPtr - PathBegin));
5377 Stream.EmitRecordWithBlob(Abbrev,
Record, FilePath);
5382 Record.push_back(Version.getMajor());
5383 if (std::optional<unsigned> Minor = Version.getMinor())
5384 Record.push_back(*Minor + 1);
5387 if (std::optional<unsigned> Subminor = Version.getSubminor())
5388 Record.push_back(*Subminor + 1);
5406 assert(ID < IdentifierOffsets.size());
5407 IdentifierOffsets[ID] = Offset;
5413 unsigned ID = SelectorIDs[Sel];
5414 assert(ID &&
"Unknown selector");
5417 if (ID < FirstSelectorID)
5419 SelectorOffsets[ID - FirstSelectorID] = Offset;
5425 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
5426 bool IncludeTimestamps,
bool BuildingImplicitModule,
5427 bool GeneratingReducedBMI)
5428 : Stream(Stream), Buffer(Buffer), ModCache(ModCache),
5429 CodeGenOpts(CodeGenOpts), IncludeTimestamps(IncludeTimestamps),
5430 BuildingImplicitModule(BuildingImplicitModule),
5431 GeneratingReducedBMI(GeneratingReducedBMI) {
5432 for (
const auto &Ext : Extensions) {
5433 if (
auto Writer = Ext->createExtensionWriter(*
this))
5434 ModuleFileExtensionWriters.push_back(std::move(Writer));
5441 assert(WritingAST &&
"can't determine lang opts when not writing AST");
5442 return PP->getLangOpts();
5451 StringRef OutputFile,
Module *WritingModule,
5452 StringRef isysroot,
bool ShouldCacheASTInMemory) {
5453 llvm::TimeTraceScope scope(
"WriteAST", OutputFile);
5456 Sema *SemaPtr = dyn_cast<Sema *>(Subject);
5463 Stream.Emit((
unsigned)
'C', 8);
5464 Stream.Emit((
unsigned)
'P', 8);
5465 Stream.Emit((
unsigned)
'C', 8);
5466 Stream.Emit((
unsigned)
'H', 8);
5468 WriteBlockInfoBlock();
5471 this->WritingModule = WritingModule;
5472 ASTFileSignature Signature = WriteASTCore(SemaPtr, isysroot, WritingModule);
5474 this->WritingModule =
nullptr;
5475 this->BaseDirectory.clear();
5479 if (ShouldCacheASTInMemory) {
5481 ModCache.getInMemoryModuleCache().addBuiltPCM(
5482 OutputFile, llvm::MemoryBuffer::getMemBufferCopy(
5483 StringRef(Buffer.begin(), Buffer.size())));
5488template<
typename Vector>
5490 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
5496template <
typename Vector>
5499 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
5505void ASTWriter::computeNonAffectingInputFiles() {
5506 SourceManager &SrcMgr = PP->getSourceManager();
5509 IsSLocAffecting.resize(N,
true);
5510 IsSLocFileEntryAffecting.resize(N,
true);
5515 auto AffectingModuleMaps = GetAffectingModuleMaps(*PP, WritingModule);
5517 unsigned FileIDAdjustment = 0;
5518 unsigned OffsetAdjustment = 0;
5520 NonAffectingFileIDAdjustments.reserve(N);
5521 NonAffectingOffsetAdjustments.reserve(N);
5523 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
5524 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
5526 for (
unsigned I = 1; I != N; ++I) {
5528 FileID FID = FileID::get(I);
5535 if (!
Cache->OrigEntry)
5543 if (!AffectingModuleMaps)
5547 if (AffectingModuleMaps->DefinitionFileIDs.contains(FID))
5550 IsSLocAffecting[I] =
false;
5551 IsSLocFileEntryAffecting[I] =
5552 AffectingModuleMaps->DefinitionFiles.contains(*
Cache->OrigEntry);
5554 FileIDAdjustment += 1;
5560 if (!NonAffectingFileIDs.empty() &&
5561 NonAffectingFileIDs.back().ID == FID.ID - 1) {
5562 NonAffectingFileIDs.back() = FID;
5564 NonAffectingFileIDAdjustments.back() = FileIDAdjustment;
5565 NonAffectingOffsetAdjustments.back() = OffsetAdjustment;
5569 NonAffectingFileIDs.push_back(FID);
5572 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
5573 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
5576 if (!PP->getHeaderSearchInfo().getHeaderSearchOpts().ModulesIncludeVFSUsage)
5579 FileManager &FileMgr = PP->getFileManager();
5582 for (StringRef Path :
5583 PP->getHeaderSearchInfo().getHeaderSearchOpts().VFSOverlayFiles)
5585 for (
unsigned I = 1; I != N; ++I) {
5586 if (IsSLocAffecting[I]) {
5592 if (!
Cache->OrigEntry)
5595 Cache->OrigEntry->getNameAsRequested());
5601void ASTWriter::PrepareWritingSpecialDecls(
Sema &SemaRef) {
5602 ASTContext &Context = SemaRef.
Context;
5604 bool isModule = WritingModule !=
nullptr;
5611 PredefinedDecls.insert(D);
5619 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
5623 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
5627 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
5634 RegisterPredefDecl(Context.CFConstantStringTypeDecl,
5636 RegisterPredefDecl(Context.CFConstantStringTagDecl,
5638#define BuiltinTemplate(BTName) \
5639 RegisterPredefDecl(Context.Decl##BTName, PREDEF_DECL##BTName##_ID);
5640#include "clang/Basic/BuiltinTemplates.inc"
5652 if (GeneratingReducedBMI) {
5678 if (GeneratingReducedBMI)
5700 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I)
5711 "There are local ones at end of translation unit!");
5729 for (
const auto &I : SemaRef.KnownNamespaces)
5734 SmallVector<std::pair<NamedDecl *, SourceLocation>, 16>
Undefined;
5742 for (
const auto &DeleteExprsInfo :
5749 for (
const auto *I : DeclsToEmitEvenIfUnreferenced)
5751 DeclsToEmitEvenIfUnreferenced.clear();
5756 llvm::SmallVector<const IdentifierInfo*, 256> IIs;
5758 const IdentifierInfo *II =
ID.second;
5764 llvm::sort(IIs, llvm::deref<std::less<>>());
5766 for (
const IdentifierInfo *II : IIs)
5777 for (CXXRecordDecl *RD : PendingEmittingVTables)
5780 PendingEmittingVTables.clear();
5783void ASTWriter::WriteSpecialDeclRecords(
Sema &SemaRef) {
5784 ASTContext &Context = SemaRef.
Context;
5786 bool isModule = WritingModule !=
nullptr;
5789 if (!EagerlyDeserializedDecls.empty())
5792 if (!ModularCodegenDecls.empty())
5798 TentativeDefinitions);
5799 if (!TentativeDefinitions.empty())
5806 UnusedFileScopedDecls);
5807 if (!UnusedFileScopedDecls.empty())
5813 if (!ExtVectorDecls.empty())
5819 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I) {
5820 CXXRecordDecl *D = SemaRef.
VTableUses[I].first;
5835 if (!UnusedLocalTypedefNameCandidates.empty())
5837 UnusedLocalTypedefNameCandidates);
5839 if (!GeneratingReducedBMI) {
5849 if (!PendingInstantiations.empty())
5853 auto AddEmittedDeclRefOrZero = [
this](
RecordData &Refs,
Decl *D) {
5867 if (!SemaDeclRefs.empty())
5875 if (!DeclsToCheckForDeferredDiags.empty())
5877 DeclsToCheckForDeferredDiags);
5884 CudaCallDecl || CudaGetParamDecl || CudaLaunchDecl) {
5885 AddEmittedDeclRefOrZero(CUDASpecialDeclRefs, CudaCallDecl);
5886 AddEmittedDeclRefOrZero(CUDASpecialDeclRefs, CudaGetParamDecl);
5887 AddEmittedDeclRefOrZero(CUDASpecialDeclRefs, CudaLaunchDecl);
5895 DelegatingCtorDecls);
5896 if (!DelegatingCtorDecls.empty())
5901 for (
const auto &I : SemaRef.KnownNamespaces) {
5905 if (!KnownNamespaces.empty())
5910 SmallVector<std::pair<NamedDecl *, SourceLocation>, 16>
Undefined;
5919 if (!UndefinedButUsed.empty())
5926 for (
const auto &DeleteExprsInfo :
5931 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
5932 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
5933 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
5935 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
5939 if (!DeleteExprsToAnalyze.empty())
5943 for (CXXRecordDecl *RD : PendingEmittingVTables) {
5950 if (!VTablesToEmit.empty())
5956 using namespace llvm;
5958 bool isModule = WritingModule !=
nullptr;
5962 Chain->finalizeForWriting();
5966 computeNonAffectingInputFiles();
5968 writeUnhashedControlBlock(*PP);
5981 IdentifierIDs.clear();
5992 SmallVector<const IdentifierInfo *, 128> IIs;
5993 for (
const auto &ID : PP->getIdentifierTable())
5994 if (IsInterestingNonMacroIdentifier(
ID.second, *
this))
5995 IIs.push_back(
ID.second);
5998 llvm::sort(IIs, llvm::deref<std::less<>>());
5999 for (
const IdentifierInfo *II : IIs)
6007 for (
const auto &WeakUndeclaredIdentifierList :
6009 const IdentifierInfo *
const II = WeakUndeclaredIdentifierList.first;
6010 for (
const auto &WI : WeakUndeclaredIdentifierList.second) {
6021 ASTContext &Context = SemaPtr->
Context;
6026 AddTypeRef(Context, Context.ObjCIdRedefinitionType, SpecialTypes);
6027 AddTypeRef(Context, Context.ObjCClassRedefinitionType, SpecialTypes);
6028 AddTypeRef(Context, Context.ObjCSelRedefinitionType, SpecialTypes);
6033 PrepareWritingSpecialDecls(*SemaPtr);
6036 WriteControlBlock(*PP, isysroot);
6039 Stream.FlushToWord();
6040 ASTBlockRange.first = Stream.GetCurrentBitNo() >> 3;
6042 ASTBlockStartOffset = Stream.GetCurrentBitNo();
6059 llvm::SmallVector<Selector, 256> AllSelectors;
6060 for (
auto &SelectorAndID : SelectorIDs)
6061 AllSelectors.push_back(SelectorAndID.first);
6062 for (
auto &Selector : AllSelectors)
6086 auto Abbrev = std::make_shared<BitCodeAbbrev>();
6088 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
6089 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
6090 SmallString<2048> Buffer;
6092 llvm::raw_svector_ostream
Out(Buffer);
6093 for (ModuleFile &M : Chain->ModuleMgr) {
6094 using namespace llvm::support;
6096 endian::Writer
LE(Out, llvm::endianness::little);
6097 LE.write<uint8_t>(
static_cast<uint8_t
>(M.
Kind));
6099 LE.write<uint16_t>(Name.size());
6100 Out.write(Name.data(), Name.size());
6106 auto writeBaseIDOrNone = [&](
auto BaseID,
bool ShouldWrite) {
6107 assert(BaseID < std::numeric_limits<uint32_t>::max() &&
"base id too high");
6121 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev,
Record,
6122 Buffer.data(), Buffer.size());
6126 WriteDeclAndTypes(SemaPtr->
Context);
6128 WriteFileDeclIDsMap();
6129 WriteSourceManagerBlock(PP->getSourceManager());
6131 WriteComments(SemaPtr->
Context);
6132 WritePreprocessor(*PP, isModule);
6133 WriteHeaderSearch(PP->getHeaderSearchInfo());
6135 WriteSelectors(*SemaPtr);
6136 WriteReferencedSelectorsPool(*SemaPtr);
6137 WriteLateParsedTemplates(*SemaPtr);
6139 WriteIdentifierTable(*PP, SemaPtr ? &SemaPtr->
IdResolver :
nullptr, isModule);
6142 WriteOpenCLExtensions(*SemaPtr);
6143 WriteCUDAPragmas(*SemaPtr);
6144 WriteRISCVIntrinsicPragmas(*SemaPtr);
6149 WriteSubmodules(WritingModule, SemaPtr ? &SemaPtr->
Context :
nullptr);
6154 WriteSpecialDeclRecords(*SemaPtr);
6157 if (!WeakUndeclaredIdentifiers.empty())
6159 WeakUndeclaredIdentifiers);
6161 if (!WritingModule) {
6166 ModuleInfo(uint64_t ID,
Module *M) :
ID(
ID), M(M) {}
6168 llvm::SmallVector<ModuleInfo, 64> Imports;
6171 assert(SubmoduleIDs.contains(I->getImportedModule()));
6172 Imports.push_back(ModuleInfo(SubmoduleIDs[I->getImportedModule()],
6173 I->getImportedModule()));
6177 if (!Imports.empty()) {
6178 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
6181 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
6182 return A.ID == B.ID;
6186 llvm::sort(Imports, Cmp);
6187 Imports.erase(llvm::unique(Imports, Eq), Imports.end());
6190 for (
const auto &Import : Imports) {
6191 ImportedModules.push_back(
Import.ID);
6202 WriteObjCCategories();
6204 if (!WritingModule) {
6205 WriteOptimizePragmaOptions(*SemaPtr);
6206 WriteMSStructPragmaOptions(*SemaPtr);
6207 WriteMSPointersToMembersPragmaOptions(*SemaPtr);
6209 WritePackPragmaOptions(*SemaPtr);
6210 WriteFloatControlPragmaOptions(*SemaPtr);
6211 WriteDeclsWithEffectsToVerify(*SemaPtr);
6215 RecordData::value_type
Record[] = {NumStatements,
6217 NumLexicalDeclContexts,
6218 NumVisibleDeclContexts,
6219 NumModuleLocalDeclContexts,
6220 NumTULocalDeclContexts};
6223 Stream.FlushToWord();
6224 ASTBlockRange.second = Stream.GetCurrentBitNo() >> 3;
6228 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
6229 WriteModuleFileExtension(*SemaPtr, *ExtWriter);
6231 return backpatchSignature();
6237 if (GeneratingReducedBMI)
6238 DeclUpdatesFromGMF.swap(DeclUpdates);
6244void ASTWriter::AddedManglingNumber(
const Decl *D,
unsigned Number) {
6248 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::ManglingNumber, Number));
6250void ASTWriter::AddedStaticLocalNumbers(
const Decl *D,
unsigned Number) {
6254 DeclUpdates[D].push_back(
6255 DeclUpdate(DeclUpdateKind::StaticLocalNumber, Number));
6264 ASTWriter::UpdateRecord &
Record = DeclUpdates[TU];
6267 DeclUpdate(DeclUpdateKind::CXXAddedAnonymousNamespace, NS));
6271void ASTWriter::WriteDeclAndTypes(
ASTContext &Context) {
6276 DeclTypesBlockStartOffset = Stream.GetCurrentBitNo();
6280 WriteDeclUpdatesBlocks(Context, DeclUpdatesOffsetsRecord);
6281 while (!DeclTypesToEmit.empty()) {
6282 DeclOrType DOT = DeclTypesToEmit.front();
6283 DeclTypesToEmit.pop();
6285 WriteType(Context, DOT.getType());
6287 WriteDecl(Context, DOT.getDecl());
6289 }
while (!DeclUpdates.empty());
6291 DoneWritingDeclsAndTypes =
true;
6295 assert(DelayedNamespace.empty() || GeneratingReducedBMI);
6297 for (NamespaceDecl *NS : DelayedNamespace) {
6298 LookupBlockOffsets Offsets;
6300 Offsets.
LexicalOffset = WriteDeclContextLexicalBlock(Context, NS);
6301 WriteDeclContextVisibleBlock(Context, NS, Offsets);
6322 assert(DeclTypesToEmit.empty());
6323 assert(DeclUpdates.empty());
6328 WriteTypeDeclOffsets();
6329 if (!DeclUpdatesOffsetsRecord.empty())
6332 if (!DelayedNamespaceRecord.empty())
6334 DelayedNamespaceRecord);
6336 if (!RelatedDeclsMap.empty()) {
6340 for (
const auto &Pair : RelatedDeclsMap) {
6341 RelatedDeclsMapRecord.push_back(Pair.first.getRawValue());
6342 RelatedDeclsMapRecord.push_back(Pair.second.size());
6343 for (
const auto &Lambda : Pair.second)
6344 RelatedDeclsMapRecord.push_back(Lambda.getRawValue());
6347 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6349 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Array));
6350 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6351 unsigned FunctionToLambdaMapAbbrev = Stream.EmitAbbrev(std::move(Abv));
6353 FunctionToLambdaMapAbbrev);
6356 if (!SpecializationsUpdates.empty()) {
6357 WriteSpecializationsUpdates(
false);
6358 SpecializationsUpdates.clear();
6361 if (!PartialSpecializationsUpdates.empty()) {
6362 WriteSpecializationsUpdates(
true);
6363 PartialSpecializationsUpdates.clear();
6369 SmallVector<DeclID, 128> NewGlobalKindDeclPairs;
6378 NewGlobalKindDeclPairs.push_back(D->
getKind());
6379 NewGlobalKindDeclPairs.push_back(
GetDeclRef(D).getRawValue());
6382 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6384 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6385 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
6388 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev,
Record,
6389 bytes(NewGlobalKindDeclPairs));
6391 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6393 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6394 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6395 UpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6397 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6399 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6400 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6401 ModuleLocalUpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6403 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6405 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6406 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6407 TULocalUpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6410 WriteDeclContextVisibleUpdate(Context, TU);
6413 if (Context.ExternCContext)
6414 WriteDeclContextVisibleUpdate(Context, Context.ExternCContext);
6417 for (
auto *DC : UpdatedDeclContexts)
6418 WriteDeclContextVisibleUpdate(Context, DC);
6421void ASTWriter::WriteSpecializationsUpdates(
bool IsPartial) {
6425 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6426 Abv->Add(llvm::BitCodeAbbrevOp(RecordType));
6427 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6428 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6429 auto UpdateSpecializationAbbrev = Stream.EmitAbbrev(std::move(Abv));
6432 IsPartial ? PartialSpecializationsUpdates : SpecializationsUpdates;
6433 for (
auto &SpecializationUpdate : SpecUpdates) {
6434 const NamedDecl *D = SpecializationUpdate.first;
6436 llvm::SmallString<4096> LookupTable;
6437 GenerateSpecializationInfoLookupTable(D, SpecializationUpdate.second,
6438 LookupTable, IsPartial);
6441 RecordData::value_type
Record[] = {
6442 static_cast<RecordData::value_type
>(RecordType),
6444 Stream.EmitRecordWithBlob(UpdateSpecializationAbbrev,
Record, LookupTable);
6448void ASTWriter::WriteDeclUpdatesBlocks(
ASTContext &Context,
6449 RecordDataImpl &OffsetsRecord) {
6450 if (DeclUpdates.empty())
6453 DeclUpdateMap LocalUpdates;
6454 LocalUpdates.swap(DeclUpdates);
6456 for (
auto &DeclUpdate : LocalUpdates) {
6457 const Decl *D = DeclUpdate.first;
6459 bool HasUpdatedBody =
false;
6460 bool HasAddedVarDefinition =
false;
6463 for (
auto &
Update : DeclUpdate.second) {
6468 if (Kind == DeclUpdateKind::CXXAddedFunctionDefinition)
6469 HasUpdatedBody =
true;
6470 else if (Kind == DeclUpdateKind::CXXAddedVarDefinition)
6471 HasAddedVarDefinition =
true;
6473 Record.push_back(llvm::to_underlying(Kind));
6476 case DeclUpdateKind::CXXAddedImplicitMember:
6477 case DeclUpdateKind::CXXAddedAnonymousNamespace:
6478 assert(
Update.getDecl() &&
"no decl to add?");
6481 case DeclUpdateKind::CXXAddedFunctionDefinition:
6482 case DeclUpdateKind::CXXAddedVarDefinition:
6485 case DeclUpdateKind::CXXPointOfInstantiation:
6490 case DeclUpdateKind::CXXInstantiatedDefaultArgument:
6495 case DeclUpdateKind::CXXInstantiatedDefaultMemberInitializer:
6500 case DeclUpdateKind::CXXInstantiatedClassDefinition: {
6502 UpdatedDeclContexts.insert(RD->getPrimaryContext());
6503 Record.push_back(RD->isParamDestroyedInCallee());
6504 Record.push_back(llvm::to_underlying(RD->getArgPassingRestrictions()));
6505 Record.AddCXXDefinitionData(RD);
6506 Record.AddOffset(WriteDeclContextLexicalBlock(Context, RD));
6511 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
6512 Record.push_back(MSInfo->getTemplateSpecializationKind());
6513 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
6516 Record.push_back(Spec->getTemplateSpecializationKind());
6517 Record.AddSourceLocation(Spec->getPointOfInstantiation());
6521 auto From = Spec->getInstantiatedFrom();
6522 if (
auto PartialSpec =
6523 From.dyn_cast<ClassTemplatePartialSpecializationDecl*>()) {
6525 Record.AddDeclRef(PartialSpec);
6526 Record.AddTemplateArgumentList(
6527 &Spec->getTemplateInstantiationArgs());
6532 Record.push_back(llvm::to_underlying(RD->getTagKind()));
6533 Record.AddSourceLocation(RD->getLocation());
6534 Record.AddSourceLocation(RD->getBeginLoc());
6535 Record.AddSourceRange(RD->getBraceRange());
6546 case DeclUpdateKind::CXXResolvedDtorDelete:
6551 case DeclUpdateKind::CXXResolvedDtorGlobDelete:
6555 case DeclUpdateKind::CXXResolvedDtorArrayDelete:
6559 case DeclUpdateKind::CXXResolvedDtorGlobArrayDelete:
6563 case DeclUpdateKind::CXXResolvedExceptionSpec: {
6566 Record.writeExceptionSpecInfo(prototype->getExceptionSpecInfo());
6570 case DeclUpdateKind::CXXDeducedReturnType:
6574 case DeclUpdateKind::DeclMarkedUsed:
6577 case DeclUpdateKind::ManglingNumber:
6578 case DeclUpdateKind::StaticLocalNumber:
6582 case DeclUpdateKind::DeclMarkedOpenMPThreadPrivate:
6584 D->
getAttr<OMPThreadPrivateDeclAttr>()->getRange());
6587 case DeclUpdateKind::DeclMarkedOpenMPAllocate: {
6588 auto *A = D->
getAttr<OMPAllocateDeclAttr>();
6589 Record.push_back(A->getAllocatorType());
6590 Record.AddStmt(A->getAllocator());
6591 Record.AddStmt(A->getAlignment());
6592 Record.AddSourceRange(A->getRange());
6596 case DeclUpdateKind::DeclMarkedOpenMPDeclareTarget:
6597 Record.push_back(D->
getAttr<OMPDeclareTargetDeclAttr>()->getMapType());
6599 D->
getAttr<OMPDeclareTargetDeclAttr>()->getRange());
6602 case DeclUpdateKind::DeclExported:
6606 case DeclUpdateKind::AddedAttrToRecord:
6607 Record.AddAttributes(llvm::ArrayRef(
Update.getAttr()));
6615 if (HasUpdatedBody) {
6618 llvm::to_underlying(DeclUpdateKind::CXXAddedFunctionDefinition));
6619 Record.push_back(Def->isInlined());
6620 Record.AddSourceLocation(Def->getInnerLocStart());
6621 Record.AddFunctionDefinition(Def);
6622 }
else if (HasAddedVarDefinition) {
6625 llvm::to_underlying(DeclUpdateKind::CXXAddedVarDefinition));
6626 Record.push_back(VD->isInline());
6627 Record.push_back(VD->isInlineSpecified());
6628 Record.AddVarDeclInit(VD);
6645 NonAffectingFileIDs.empty())
6647 auto It = llvm::lower_bound(NonAffectingFileIDs, FID);
6648 unsigned Idx = std::distance(NonAffectingFileIDs.begin(), It);
6649 unsigned Offset = NonAffectingFileIDAdjustments[Idx];
6650 return FileID::get(FID.getOpaqueValue() - Offset);
6653unsigned ASTWriter::getAdjustedNumCreatedFIDs(
FileID FID)
const {
6659 unsigned AdjustedNumCreatedFIDs = 0;
6660 for (
unsigned I = FID.ID, N = I + NumCreatedFIDs; I != N; ++I)
6661 if (IsSLocAffecting[I])
6662 ++AdjustedNumCreatedFIDs;
6663 return AdjustedNumCreatedFIDs;
6673 return SourceRange(getAdjustedLocation(
Range.getBegin()),
6674 getAdjustedLocation(
Range.getEnd()));
6679 return Offset - getAdjustment(Offset);
6684 if (NonAffectingRanges.empty())
6687 if (PP->getSourceManager().isLoadedOffset(Offset))
6690 if (Offset > NonAffectingRanges.back().getEnd().getOffset())
6691 return NonAffectingOffsetAdjustments.back();
6693 if (Offset < NonAffectingRanges.front().getBegin().getOffset())
6697 return Range.getEnd().getOffset() < Offset;
6700 auto It = llvm::lower_bound(NonAffectingRanges, Offset, Contains);
6701 unsigned Idx = std::distance(NonAffectingRanges.begin(), It);
6702 return NonAffectingOffsetAdjustments[Idx];
6706 Record.push_back(getAdjustedFileID(FID).getOpaqueValue());
6712 unsigned ModuleFileIndex = 0;
6715 if (PP->getSourceManager().isLoadedSourceLocation(Loc) && Loc.
isValid()) {
6718 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
6719 assert(SLocMapI !=
getChain()->GlobalSLocOffsetMap.end() &&
6720 "Corrupted global sloc offset map");
6725 ModuleFileIndex = F->
Index + 1;
6733 Loc = getAdjustedLocation(Loc);
6770 MacroInfoToEmitData Info = { Name, MI, ID };
6771 MacroInfosToEmit.push_back(Info);
6777 return IdentMacroDirectivesOffsetMap.lookup(Name);
6781 Record->push_back(Writer->getSelectorRef(SelRef));
6790 if (SID == 0 && Chain) {
6793 Chain->LoadSelector(Sel);
6794 SID = SelectorIDs[Sel];
6797 SID = NextSelectorID++;
6798 SelectorIDs[Sel] = SID;
6840 bool InfoHasSameExpr
6842 Record->push_back(InfoHasSameExpr);
6843 if (InfoHasSameExpr)
6860 TypeLocWriter TLW(*
this);
6870template <
typename IdxForTypeTy>
6872 IdxForTypeTy IdxForType) {
6876 unsigned FastQuals =
T.getLocalFastQualifiers();
6877 T.removeLocalFastQualifiers();
6879 if (
T.hasLocalNonFastQualifiers())
6880 return IdxForType(
T).asTypeID(FastQuals);
6882 assert(!
T.hasLocalQualifiers());
6884 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(
T.getTypePtr()))
6887 if (
T == Context.AutoDeductTy)
6889 if (
T == Context.AutoRRefDeductTy)
6892 return IdxForType(
T).asTypeID(FastQuals);
6899 assert(!
T.getLocalFastQualifiers());
6903 if (DoneWritingDeclsAndTypes) {
6904 assert(0 &&
"New type seen after serializing all the types to emit!");
6910 Idx =
TypeIdx(0, NextTypeID++);
6911 DeclTypesToEmit.push(
T);
6928 Record.push_back(MacroRef >> 32);
6929 Record.push_back(MacroRef & llvm::maskTrailingOnes<MacroID>(32));
6944 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
6951 if (
auto *Iter = DeclUpdatesFromGMF.find(D);
6952 Iter != DeclUpdatesFromGMF.end()) {
6953 for (DeclUpdate &
Update : Iter->second)
6954 DeclUpdates[D].push_back(
Update);
6955 DeclUpdatesFromGMF.erase(Iter);
6967 assert(!(
reinterpret_cast<uintptr_t>(D) & 0x01) &&
"Invalid decl pointer");
6969 if (ID.isInvalid()) {
6970 if (DoneWritingDeclsAndTypes) {
6971 assert(0 &&
"New decl seen after serializing all the decls to emit!");
6978 DeclTypesToEmit.push(
const_cast<Decl *
>(D));
6993 assert(DeclIDs.contains(D) &&
"Declaration not emitted!");
7000 assert(DoneWritingDeclsAndTypes &&
7001 "wasDeclEmitted should only be called after writing declarations");
7006 bool Emitted = DeclIDs.contains(D);
7008 GeneratingReducedBMI) &&
7009 "The declaration within modules can only be omitted in reduced BMI.");
7014 assert(ID.isValid());
7033 assert(
SM.isLocalSourceLocation(FileLoc));
7034 auto [FID, Offset] =
SM.getDecomposedLoc(FileLoc);
7037 assert(
SM.getSLocEntry(FID).isFile());
7038 assert(IsSLocAffecting[FID.ID]);
7040 std::unique_ptr<DeclIDInFileInfo> &Info = FileDeclIDs[FID];
7042 Info = std::make_unique<DeclIDInFileInfo>();
7044 std::pair<unsigned, LocalDeclID> LocDecl(Offset, ID);
7045 LocDeclIDsTy &Decls = Info->DeclIDs;
7046 Decls.push_back(LocDecl);
7051 "expected an anonymous declaration");
7055 auto It = AnonymousDeclarationNumbers.find(D);
7056 if (It == AnonymousDeclarationNumbers.end()) {
7059 AnonymousDeclarationNumbers[ND] = Number;
7062 It = AnonymousDeclarationNumbers.find(D);
7063 assert(It != AnonymousDeclarationNumbers.end() &&
7064 "declaration not found within its lexical context");
7119 while (QualifierLoc) {
7120 NestedNames.push_back(QualifierLoc);
7124 Record->push_back(NestedNames.size());
7125 while(!NestedNames.empty()) {
7126 QualifierLoc = NestedNames.pop_back_val();
7129 Record->push_back(llvm::to_underlying(Kind));
7132 AddDeclRef(Qualifier.getAsNamespaceAndPrefix().Namespace);
7154 llvm_unreachable(
"unexpected null nested name specifier");
7161 assert(TemplateParams &&
"No TemplateParams!");
7166 Record->push_back(TemplateParams->
size());
7167 for (
const auto &P : *TemplateParams)
7170 Record->push_back(
true);
7173 Record->push_back(
false);
7180 assert(TemplateArgs &&
"No TemplateArgs!");
7181 Record->push_back(TemplateArgs->
size());
7182 for (
int i = 0, e = TemplateArgs->
size(); i != e; ++i)
7188 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
7198 Record->push_back(
Set.size());
7200 I =
Set.begin(), E =
Set.end(); I != E; ++I) {
7202 Record->push_back(I.getAccess());
7208 Record->push_back(
Base.isVirtual());
7209 Record->push_back(
Base.isBaseOfClass());
7210 Record->push_back(
Base.getAccessSpecifierAsWritten());
7211 Record->push_back(
Base.getInheritConstructors());
7224 for (
auto &
Base : Bases)
7242 for (
auto *
Init : CtorInits) {
7243 if (
Init->isBaseInitializer()) {
7247 }
else if (
Init->isDelegatingInitializer()) {
7250 }
else if (
Init->isMemberInitializer()){
7263 if (
Init->isWritten())
7277 auto &
Data = D->data();
7279 Record->push_back(
Data.IsLambda);
7283#define FIELD(Name, Width, Merge) \
7284 if (!DefinitionBits.canWriteNextNBits(Width)) { \
7285 Record->push_back(DefinitionBits); \
7286 DefinitionBits.reset(0); \
7288 DefinitionBits.addBits(Data.Name, Width);
7290#include "clang/AST/CXXRecordDeclDefinitionBits.def"
7293 Record->push_back(DefinitionBits);
7299 bool ModulesCodegen =
7304 Record->push_back(ModulesCodegen);
7306 Writer->AddDeclRef(D, Writer->ModularCodegenDecls);
7311 Record->push_back(
Data.ComputedVisibleConversions);
7312 if (
Data.ComputedVisibleConversions)
7316 if (!
Data.IsLambda) {
7317 Record->push_back(
Data.NumBases);
7318 if (
Data.NumBases > 0)
7322 Record->push_back(
Data.NumVBases);
7323 if (
Data.NumVBases > 0)
7328 auto &Lambda = D->getLambdaData();
7331 LambdaBits.
addBits(Lambda.DependencyKind, 2);
7332 LambdaBits.
addBit(Lambda.IsGenericLambda);
7333 LambdaBits.
addBits(Lambda.CaptureDefault, 2);
7334 LambdaBits.
addBits(Lambda.NumCaptures, 15);
7335 LambdaBits.
addBit(Lambda.HasKnownInternalLinkage);
7336 Record->push_back(LambdaBits);
7338 Record->push_back(Lambda.NumExplicitCaptures);
7339 Record->push_back(Lambda.ManglingNumber);
7344 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
7351 Record->push_back(CaptureBits);
7353 switch (
Capture.getCaptureKind()) {
7383 assert(ES->CheckedForSideEffects);
7384 Val |= (ES->HasConstantInitialization ? 2 : 0);
7385 Val |= (ES->HasConstantDestruction ? 4 : 0);
7399void ASTWriter::ReaderInitialized(
ASTReader *Reader) {
7400 assert(Reader &&
"Cannot remove chain");
7401 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
7402 assert(FirstDeclID == NextDeclID &&
7403 FirstTypeID == NextTypeID &&
7404 FirstIdentID == NextIdentID &&
7405 FirstMacroID == NextMacroID &&
7406 FirstSubmoduleID == NextSubmoduleID &&
7407 FirstSelectorID == NextSelectorID &&
7408 "Setting chain after writing has started.");
7414 NextSelectorID = FirstSelectorID;
7415 NextSubmoduleID = FirstSubmoduleID;
7425 unsigned OriginalModuleFileIndex = StoredID >> 32;
7429 if (OriginalModuleFileIndex == 0 && StoredID)
7440 MacroID &StoredID = MacroIDs[MI];
7441 unsigned OriginalModuleFileIndex = StoredID >> 32;
7444 if (OriginalModuleFileIndex == 0 && StoredID)
7453void ASTWriter::TypeRead(TypeIdx Idx,
QualType T) {
7465 TypeIdx &StoredIdx = TypeIdxs[
T];
7471 if (ModuleFileIndex == 0 && StoredIdx.
getValue())
7482 DeclIDs[D] = LocalDeclID(ID);
7483 PredefinedDecls.insert(D);
7495 assert(!MacroDefinitions.contains(MD));
7496 MacroDefinitions[MD] =
ID;
7500 assert(!SubmoduleIDs.contains(Mod));
7501 SubmoduleIDs[Mod] =
ID;
7504void ASTWriter::CompletedTagDefinition(
const TagDecl *D) {
7505 if (Chain && Chain->isProcessingUpdateRecords())
return;
7507 assert(!WritingAST &&
"Already writing the AST!");
7508 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
7510 if (RD->isFromASTFile()) {
7515 "completed a tag from another module but not by instantiation?");
7516 DeclUpdates[RD].push_back(
7517 DeclUpdate(DeclUpdateKind::CXXInstantiatedClassDefinition));
7531void ASTWriter::AddedVisibleDecl(
const DeclContext *DC,
const Decl *D) {
7532 if (Chain && Chain->isProcessingUpdateRecords())
return;
7534 "Should not add lookup results to non-lookup contexts!");
7555 assert(!WritingAST &&
"Already writing the AST!");
7556 if (UpdatedDeclContexts.insert(DC) && !
cast<Decl>(DC)->isFromASTFile()) {
7560 llvm::append_range(DeclsToEmitEvenIfUnreferenced, DC->
decls());
7562 DeclsToEmitEvenIfUnreferenced.push_back(D);
7566 if (Chain && Chain->isProcessingUpdateRecords())
return;
7579 assert(!WritingAST &&
"Already writing the AST!");
7580 DeclUpdates[RD].push_back(
7581 DeclUpdate(DeclUpdateKind::CXXAddedImplicitMember, D));
7584void ASTWriter::ResolvedExceptionSpec(
const FunctionDecl *FD) {
7585 if (Chain && Chain->isProcessingUpdateRecords())
return;
7586 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
7588 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
7593 ->castAs<FunctionProtoType>()
7594 ->getExceptionSpecType()))
7595 DeclUpdates[D].push_back(DeclUpdateKind::CXXResolvedExceptionSpec);
7600 if (Chain && Chain->isProcessingUpdateRecords())
return;
7601 assert(!WritingAST &&
"Already writing the AST!");
7603 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
7604 DeclUpdates[D].push_back(
7605 DeclUpdate(DeclUpdateKind::CXXDeducedReturnType, ReturnType));
7612 if (Chain && Chain->isProcessingUpdateRecords())
return;
7613 assert(!WritingAST &&
"Already writing the AST!");
7614 assert(
Delete &&
"Not given an operator delete");
7616 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7617 DeclUpdates[D].push_back(
7618 DeclUpdate(DeclUpdateKind::CXXResolvedDtorDelete,
Delete));
7624 if (Chain && Chain->isProcessingUpdateRecords())
7626 assert(!WritingAST &&
"Already writing the AST!");
7627 assert(GlobDelete &&
"Not given an operator delete");
7630 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7631 DeclUpdates[D].push_back(
7632 DeclUpdate(DeclUpdateKind::CXXResolvedDtorGlobDelete, GlobDelete));
7638 if (Chain && Chain->isProcessingUpdateRecords())
7640 assert(!WritingAST &&
"Already writing the AST!");
7641 assert(ArrayDelete &&
"Not given an operator delete");
7644 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7645 DeclUpdates[D].push_back(
7646 DeclUpdate(DeclUpdateKind::CXXResolvedDtorArrayDelete, ArrayDelete));
7650void ASTWriter::ResolvedOperatorGlobArrayDelete(
7652 if (Chain && Chain->isProcessingUpdateRecords())
7654 assert(!WritingAST &&
"Already writing the AST!");
7655 assert(GlobArrayDelete &&
"Not given an operator delete");
7658 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
7659 DeclUpdates[D].push_back(DeclUpdate(
7660 DeclUpdateKind::CXXResolvedDtorGlobArrayDelete, GlobArrayDelete));
7664void ASTWriter::CompletedImplicitDefinition(
const FunctionDecl *D) {
7665 if (Chain && Chain->isProcessingUpdateRecords())
return;
7666 assert(!WritingAST &&
"Already writing the AST!");
7675 DeclUpdates[D].push_back(
7676 DeclUpdate(DeclUpdateKind::CXXAddedFunctionDefinition));
7679void ASTWriter::VariableDefinitionInstantiated(
const VarDecl *D) {
7680 if (Chain && Chain->isProcessingUpdateRecords())
return;
7681 assert(!WritingAST &&
"Already writing the AST!");
7685 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::CXXAddedVarDefinition));
7688void ASTWriter::FunctionDefinitionInstantiated(
const FunctionDecl *D) {
7689 if (Chain && Chain->isProcessingUpdateRecords())
return;
7690 assert(!WritingAST &&
"Already writing the AST!");
7698 DeclUpdates[D].push_back(
7699 DeclUpdate(DeclUpdateKind::CXXAddedFunctionDefinition));
7702void ASTWriter::InstantiationRequested(
const ValueDecl *D) {
7703 if (Chain && Chain->isProcessingUpdateRecords())
return;
7704 assert(!WritingAST &&
"Already writing the AST!");
7711 if (
auto *VD = dyn_cast<VarDecl>(D))
7712 POI = VD->getPointOfInstantiation();
7715 DeclUpdates[D].push_back(
7716 DeclUpdate(DeclUpdateKind::CXXPointOfInstantiation, POI));
7719void ASTWriter::DefaultArgumentInstantiated(
const ParmVarDecl *D) {
7720 if (Chain && Chain->isProcessingUpdateRecords())
return;
7721 assert(!WritingAST &&
"Already writing the AST!");
7725 DeclUpdates[D].push_back(
7726 DeclUpdate(DeclUpdateKind::CXXInstantiatedDefaultArgument, D));
7729void ASTWriter::DefaultMemberInitializerInstantiated(
const FieldDecl *D) {
7730 assert(!WritingAST &&
"Already writing the AST!");
7734 DeclUpdates[D].push_back(
7735 DeclUpdate(DeclUpdateKind::CXXInstantiatedDefaultMemberInitializer, D));
7740 if (Chain && Chain->isProcessingUpdateRecords())
return;
7741 assert(!WritingAST &&
"Already writing the AST!");
7745 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
7746 ObjCClassesWithCategories.insert(
7750void ASTWriter::DeclarationMarkedUsed(
const Decl *D) {
7751 if (Chain && Chain->isProcessingUpdateRecords())
return;
7752 assert(!WritingAST &&
"Already writing the AST!");
7761 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::DeclMarkedUsed));
7764void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(
const Decl *D) {
7765 if (Chain && Chain->isProcessingUpdateRecords())
return;
7766 assert(!WritingAST &&
"Already writing the AST!");
7770 DeclUpdates[D].push_back(
7771 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPThreadPrivate));
7774void ASTWriter::DeclarationMarkedOpenMPAllocate(
const Decl *D,
const Attr *A) {
7775 if (Chain && Chain->isProcessingUpdateRecords())
return;
7776 assert(!WritingAST &&
"Already writing the AST!");
7780 DeclUpdates[D].push_back(
7781 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPAllocate, A));
7784void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
7786 if (Chain && Chain->isProcessingUpdateRecords())
return;
7787 assert(!WritingAST &&
"Already writing the AST!");
7791 DeclUpdates[D].push_back(
7792 DeclUpdate(DeclUpdateKind::DeclMarkedOpenMPDeclareTarget, Attr));
7795void ASTWriter::RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M) {
7796 if (Chain && Chain->isProcessingUpdateRecords())
return;
7797 assert(!WritingAST &&
"Already writing the AST!");
7799 DeclUpdates[D].push_back(DeclUpdate(DeclUpdateKind::DeclExported, M));
7802void ASTWriter::AddedAttributeToRecord(
const Attr *
Attr,
7804 if (Chain && Chain->isProcessingUpdateRecords())
return;
7805 assert(!WritingAST &&
"Already writing the AST!");
7806 if (!
Record->isFromASTFile())
7808 DeclUpdates[
Record].push_back(
7809 DeclUpdate(DeclUpdateKind::AddedAttrToRecord, Attr));
7812void ASTWriter::AddedCXXTemplateSpecialization(
7814 assert(!WritingAST &&
"Already writing the AST!");
7818 if (Chain && Chain->isProcessingUpdateRecords())
7821 DeclsToEmitEvenIfUnreferenced.push_back(D);
7824void ASTWriter::AddedCXXTemplateSpecialization(
7826 assert(!WritingAST &&
"Already writing the AST!");
7830 if (Chain && Chain->isProcessingUpdateRecords())
7833 DeclsToEmitEvenIfUnreferenced.push_back(D);
7838 assert(!WritingAST &&
"Already writing the AST!");
7842 if (Chain && Chain->isProcessingUpdateRecords())
7845 DeclsToEmitEvenIfUnreferenced.push_back(D);
7859#define GEN_CLANG_CLAUSE_CLASS
7860#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
7861#include "llvm/Frontend/OpenMP/OMP.inc"
7870 OMPClauseWriter(*this).writeClause(
C);
7873void OMPClauseWriter::writeClause(
OMPClause *
C) {
7874 Record.push_back(
unsigned(
C->getClauseKind()));
7876 Record.AddSourceLocation(
C->getBeginLoc());
7877 Record.AddSourceLocation(
C->getEndLoc());
7881 Record.push_back(uint64_t(
C->getCaptureRegion()));
7882 Record.AddStmt(
C->getPreInitStmt());
7886 VisitOMPClauseWithPreInit(
C);
7887 Record.AddStmt(
C->getPostUpdateExpr());
7890void OMPClauseWriter::VisitOMPIfClause(
OMPIfClause *
C) {
7891 VisitOMPClauseWithPreInit(
C);
7893 Record.AddSourceLocation(
C->getNameModifierLoc());
7894 Record.AddSourceLocation(
C->getColonLoc());
7895 Record.AddStmt(
C->getCondition());
7896 Record.AddSourceLocation(
C->getLParenLoc());
7900 VisitOMPClauseWithPreInit(
C);
7901 Record.AddStmt(
C->getCondition());
7902 Record.AddSourceLocation(
C->getLParenLoc());
7906 VisitOMPClauseWithPreInit(
C);
7907 Record.writeEnum(
C->getModifier());
7908 Record.AddStmt(
C->getNumThreads());
7909 Record.AddSourceLocation(
C->getModifierLoc());
7910 Record.AddSourceLocation(
C->getLParenLoc());
7914 Record.AddStmt(
C->getSafelen());
7915 Record.AddSourceLocation(
C->getLParenLoc());
7919 Record.AddStmt(
C->getSimdlen());
7920 Record.AddSourceLocation(
C->getLParenLoc());
7924 Record.push_back(
C->getNumSizes());
7925 for (
Expr *Size :
C->getSizesRefs())
7927 Record.AddSourceLocation(
C->getLParenLoc());
7931 Record.push_back(
C->getNumLoops());
7932 for (
Expr *Size :
C->getArgsRefs())
7934 Record.AddSourceLocation(
C->getLParenLoc());
7940 Record.AddStmt(
C->getFactor());
7941 Record.AddSourceLocation(
C->getLParenLoc());
7945 Record.AddStmt(
C->getFirst());
7946 Record.AddStmt(
C->getCount());
7947 Record.AddSourceLocation(
C->getLParenLoc());
7948 Record.AddSourceLocation(
C->getFirstLoc());
7949 Record.AddSourceLocation(
C->getCountLoc());
7953 Record.AddStmt(
C->getAllocator());
7954 Record.AddSourceLocation(
C->getLParenLoc());
7958 Record.AddStmt(
C->getNumForLoops());
7959 Record.AddSourceLocation(
C->getLParenLoc());
7963 Record.AddStmt(
C->getEventHandler());
7964 Record.AddSourceLocation(
C->getLParenLoc());
7968 Record.push_back(
unsigned(
C->getDefaultKind()));
7969 Record.AddSourceLocation(
C->getLParenLoc());
7970 Record.AddSourceLocation(
C->getDefaultKindKwLoc());
7971 Record.push_back(
unsigned(
C->getDefaultVC()));
7972 Record.AddSourceLocation(
C->getDefaultVCLoc());
7976 Record.AddSourceLocation(
C->getLParenLoc());
7977 Record.AddSourceLocation(
C->getThreadsetKindLoc());
7978 Record.writeEnum(
C->getThreadsetKind());
7982 Record.push_back(
unsigned(
C->getProcBindKind()));
7983 Record.AddSourceLocation(
C->getLParenLoc());
7984 Record.AddSourceLocation(
C->getProcBindKindKwLoc());
7988 VisitOMPClauseWithPreInit(
C);
7989 Record.push_back(
C->getScheduleKind());
7990 Record.push_back(
C->getFirstScheduleModifier());
7991 Record.push_back(
C->getSecondScheduleModifier());
7992 Record.AddStmt(
C->getChunkSize());
7993 Record.AddSourceLocation(
C->getLParenLoc());
7994 Record.AddSourceLocation(
C->getFirstScheduleModifierLoc());
7995 Record.AddSourceLocation(
C->getSecondScheduleModifierLoc());
7996 Record.AddSourceLocation(
C->getScheduleKindLoc());
7997 Record.AddSourceLocation(
C->getCommaLoc());
8001 Record.push_back(
C->getLoopNumIterations().size());
8002 Record.AddStmt(
C->getNumForLoops());
8003 for (
Expr *NumIter :
C->getLoopNumIterations())
8005 for (
unsigned I = 0, E =
C->getLoopNumIterations().size(); I <E; ++I)
8006 Record.AddStmt(
C->getLoopCounter(I));
8007 Record.AddSourceLocation(
C->getLParenLoc());
8011 Record.AddStmt(
C->getCondition());
8012 Record.AddSourceLocation(
C->getLParenLoc());
8024 Record.push_back(
C->isExtended() ? 1 : 0);
8025 if (
C->isExtended()) {
8026 Record.AddSourceLocation(
C->getLParenLoc());
8027 Record.AddSourceLocation(
C->getArgumentLoc());
8028 Record.writeEnum(
C->getDependencyKind());
8038 Record.AddSourceLocation(
C->getLParenLoc());
8039 Record.AddSourceLocation(
C->getFailParameterLoc());
8040 Record.writeEnum(
C->getFailParameter());
8048 Record.push_back(
static_cast<uint64_t>(
C->getDirectiveKinds().size()));
8049 Record.AddSourceLocation(
C->getLParenLoc());
8050 for (
auto K :
C->getDirectiveKinds()) {
8057 Record.AddSourceLocation(
C->getLParenLoc());
8061 Record.push_back(
static_cast<uint64_t>(
C->getDirectiveKinds().size()));
8062 Record.AddSourceLocation(
C->getLParenLoc());
8063 for (
auto K :
C->getDirectiveKinds()) {
8070void OMPClauseWriter::VisitOMPNoOpenMPRoutinesClause(
8073void OMPClauseWriter::VisitOMPNoOpenMPConstructsClause(
8093 Record.push_back(
C->varlist_size());
8096 Record.writeBool(
C->getIsTarget());
8097 Record.writeBool(
C->getIsTargetSync());
8098 Record.AddSourceLocation(
C->getLParenLoc());
8099 Record.AddSourceLocation(
C->getVarLoc());
8103 Record.AddStmt(
C->getInteropVar());
8104 Record.AddSourceLocation(
C->getLParenLoc());
8105 Record.AddSourceLocation(
C->getVarLoc());
8109 Record.AddStmt(
C->getInteropVar());
8110 Record.AddSourceLocation(
C->getLParenLoc());
8111 Record.AddSourceLocation(
C->getVarLoc());
8115 VisitOMPClauseWithPreInit(
C);
8116 Record.AddStmt(
C->getCondition());
8117 Record.AddSourceLocation(
C->getLParenLoc());
8121 VisitOMPClauseWithPreInit(
C);
8122 Record.AddStmt(
C->getCondition());
8123 Record.AddSourceLocation(
C->getLParenLoc());
8127 VisitOMPClauseWithPreInit(
C);
8128 Record.AddStmt(
C->getThreadID());
8129 Record.AddSourceLocation(
C->getLParenLoc());
8133 Record.AddStmt(
C->getAlignment());
8134 Record.AddSourceLocation(
C->getLParenLoc());
8138 Record.push_back(
C->varlist_size());
8139 Record.AddSourceLocation(
C->getLParenLoc());
8140 for (
auto *
VE :
C->varlist()) {
8143 for (
auto *
VE :
C->private_copies()) {
8149 Record.push_back(
C->varlist_size());
8150 VisitOMPClauseWithPreInit(
C);
8151 Record.AddSourceLocation(
C->getLParenLoc());
8152 for (
auto *
VE :
C->varlist()) {
8155 for (
auto *
VE :
C->private_copies()) {
8158 for (
auto *
VE :
C->inits()) {
8164 Record.push_back(
C->varlist_size());
8165 VisitOMPClauseWithPostUpdate(
C);
8166 Record.AddSourceLocation(
C->getLParenLoc());
8167 Record.writeEnum(
C->getKind());
8168 Record.AddSourceLocation(
C->getKindLoc());
8169 Record.AddSourceLocation(
C->getColonLoc());
8170 for (
auto *
VE :
C->varlist())
8172 for (
auto *E :
C->private_copies())
8174 for (
auto *E :
C->source_exprs())
8176 for (
auto *E :
C->destination_exprs())
8178 for (
auto *E :
C->assignment_ops())
8183 Record.push_back(
C->varlist_size());
8184 Record.AddSourceLocation(
C->getLParenLoc());
8185 for (
auto *
VE :
C->varlist())
8190 Record.push_back(
C->varlist_size());
8191 Record.writeEnum(
C->getModifier());
8192 VisitOMPClauseWithPostUpdate(
C);
8193 Record.AddSourceLocation(
C->getLParenLoc());
8194 Record.AddSourceLocation(
C->getModifierLoc());
8195 Record.AddSourceLocation(
C->getColonLoc());
8196 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
8197 Record.AddDeclarationNameInfo(
C->getNameInfo());
8198 for (
auto *
VE :
C->varlist())
8200 for (
auto *
VE :
C->privates())
8202 for (
auto *E :
C->lhs_exprs())
8204 for (
auto *E :
C->rhs_exprs())
8206 for (
auto *E :
C->reduction_ops())
8208 if (
C->getModifier() == clang::OMPC_REDUCTION_inscan) {
8209 for (
auto *E :
C->copy_ops())
8211 for (
auto *E :
C->copy_array_temps())
8213 for (
auto *E :
C->copy_array_elems())
8216 auto PrivateFlags =
C->private_var_reduction_flags();
8217 Record.push_back(std::distance(PrivateFlags.begin(), PrivateFlags.end()));
8218 for (
bool Flag : PrivateFlags)
8223 Record.push_back(
C->varlist_size());
8224 VisitOMPClauseWithPostUpdate(
C);
8225 Record.AddSourceLocation(
C->getLParenLoc());
8226 Record.AddSourceLocation(
C->getColonLoc());
8227 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
8228 Record.AddDeclarationNameInfo(
C->getNameInfo());
8229 for (
auto *
VE :
C->varlist())
8231 for (
auto *
VE :
C->privates())
8233 for (
auto *E :
C->lhs_exprs())
8235 for (
auto *E :
C->rhs_exprs())
8237 for (
auto *E :
C->reduction_ops())
8242 Record.push_back(
C->varlist_size());
8243 VisitOMPClauseWithPostUpdate(
C);
8244 Record.AddSourceLocation(
C->getLParenLoc());
8245 Record.AddSourceLocation(
C->getColonLoc());
8246 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
8247 Record.AddDeclarationNameInfo(
C->getNameInfo());
8248 for (
auto *
VE :
C->varlist())
8250 for (
auto *
VE :
C->privates())
8252 for (
auto *E :
C->lhs_exprs())
8254 for (
auto *E :
C->rhs_exprs())
8256 for (
auto *E :
C->reduction_ops())
8258 for (
auto *E :
C->taskgroup_descriptors())
8263 Record.push_back(
C->varlist_size());
8264 VisitOMPClauseWithPostUpdate(
C);
8265 Record.AddSourceLocation(
C->getLParenLoc());
8266 Record.AddSourceLocation(
C->getColonLoc());
8267 Record.push_back(
C->getModifier());
8268 Record.AddSourceLocation(
C->getModifierLoc());
8269 for (
auto *
VE :
C->varlist()) {
8272 for (
auto *
VE :
C->privates()) {
8275 for (
auto *
VE :
C->inits()) {
8278 for (
auto *
VE :
C->updates()) {
8281 for (
auto *
VE :
C->finals()) {
8285 Record.AddStmt(
C->getCalcStep());
8286 for (
auto *
VE :
C->used_expressions())
8291 Record.push_back(
C->varlist_size());
8292 Record.AddSourceLocation(
C->getLParenLoc());
8293 Record.AddSourceLocation(
C->getColonLoc());
8294 for (
auto *
VE :
C->varlist())
8296 Record.AddStmt(
C->getAlignment());
8300 Record.push_back(
C->varlist_size());
8301 Record.AddSourceLocation(
C->getLParenLoc());
8302 for (
auto *
VE :
C->varlist())
8304 for (
auto *E :
C->source_exprs())
8306 for (
auto *E :
C->destination_exprs())
8308 for (
auto *E :
C->assignment_ops())
8313 Record.push_back(
C->varlist_size());
8314 Record.AddSourceLocation(
C->getLParenLoc());
8315 for (
auto *
VE :
C->varlist())
8317 for (
auto *E :
C->source_exprs())
8319 for (
auto *E :
C->destination_exprs())
8321 for (
auto *E :
C->assignment_ops())
8326 Record.push_back(
C->varlist_size());
8327 Record.AddSourceLocation(
C->getLParenLoc());
8328 for (
auto *
VE :
C->varlist())
8333 Record.AddStmt(
C->getDepobj());
8334 Record.AddSourceLocation(
C->getLParenLoc());
8338 Record.push_back(
C->varlist_size());
8339 Record.push_back(
C->getNumLoops());
8340 Record.AddSourceLocation(
C->getLParenLoc());
8341 Record.AddStmt(
C->getModifier());
8342 Record.push_back(
C->getDependencyKind());
8343 Record.AddSourceLocation(
C->getDependencyLoc());
8344 Record.AddSourceLocation(
C->getColonLoc());
8345 Record.AddSourceLocation(
C->getOmpAllMemoryLoc());
8346 for (
auto *
VE :
C->varlist())
8348 for (
unsigned I = 0, E =
C->getNumLoops(); I < E; ++I)
8349 Record.AddStmt(
C->getLoopData(I));
8353 VisitOMPClauseWithPreInit(
C);
8354 Record.writeEnum(
C->getModifier());
8355 Record.AddStmt(
C->getDevice());
8356 Record.AddSourceLocation(
C->getModifierLoc());
8357 Record.AddSourceLocation(
C->getLParenLoc());
8361 Record.push_back(
C->varlist_size());
8362 Record.push_back(
C->getUniqueDeclarationsNum());
8363 Record.push_back(
C->getTotalComponentListNum());
8364 Record.push_back(
C->getTotalComponentsNum());
8365 Record.AddSourceLocation(
C->getLParenLoc());
8366 bool HasIteratorModifier =
false;
8368 Record.push_back(
C->getMapTypeModifier(I));
8369 Record.AddSourceLocation(
C->getMapTypeModifierLoc(I));
8370 if (
C->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator)
8371 HasIteratorModifier =
true;
8373 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8374 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8375 Record.push_back(
C->getMapType());
8376 Record.AddSourceLocation(
C->getMapLoc());
8377 Record.AddSourceLocation(
C->getColonLoc());
8378 for (
auto *E :
C->varlist())
8380 for (
auto *E :
C->mapperlists())
8382 if (HasIteratorModifier)
8383 Record.AddStmt(
C->getIteratorModifier());
8384 for (
auto *D :
C->all_decls())
8386 for (
auto N :
C->all_num_lists())
8388 for (
auto N :
C->all_lists_sizes())
8390 for (
auto &M :
C->all_components()) {
8391 Record.AddStmt(M.getAssociatedExpression());
8392 Record.AddDeclRef(M.getAssociatedDeclaration());
8397 Record.push_back(
C->varlist_size());
8398 Record.writeEnum(
C->getFirstAllocateModifier());
8399 Record.writeEnum(
C->getSecondAllocateModifier());
8400 Record.AddSourceLocation(
C->getLParenLoc());
8401 Record.AddSourceLocation(
C->getColonLoc());
8402 Record.AddStmt(
C->getAllocator());
8403 Record.AddStmt(
C->getAlignment());
8404 for (
auto *
VE :
C->varlist())
8409 Record.push_back(
C->varlist_size());
8410 VisitOMPClauseWithPreInit(
C);
8411 Record.AddSourceLocation(
C->getLParenLoc());
8412 for (
auto *
VE :
C->varlist())
8417 Record.push_back(
C->varlist_size());
8418 VisitOMPClauseWithPreInit(
C);
8419 Record.AddSourceLocation(
C->getLParenLoc());
8420 for (
auto *
VE :
C->varlist())
8425 VisitOMPClauseWithPreInit(
C);
8426 Record.AddStmt(
C->getPriority());
8427 Record.AddSourceLocation(
C->getLParenLoc());
8431 VisitOMPClauseWithPreInit(
C);
8432 Record.writeEnum(
C->getModifier());
8433 Record.AddStmt(
C->getGrainsize());
8434 Record.AddSourceLocation(
C->getModifierLoc());
8435 Record.AddSourceLocation(
C->getLParenLoc());
8439 VisitOMPClauseWithPreInit(
C);
8440 Record.writeEnum(
C->getModifier());
8441 Record.AddStmt(
C->getNumTasks());
8442 Record.AddSourceLocation(
C->getModifierLoc());
8443 Record.AddSourceLocation(
C->getLParenLoc());
8448 Record.AddSourceLocation(
C->getLParenLoc());
8452 VisitOMPClauseWithPreInit(
C);
8453 Record.push_back(
C->getDistScheduleKind());
8454 Record.AddStmt(
C->getChunkSize());
8455 Record.AddSourceLocation(
C->getLParenLoc());
8456 Record.AddSourceLocation(
C->getDistScheduleKindLoc());
8457 Record.AddSourceLocation(
C->getCommaLoc());
8461 Record.push_back(
C->getDefaultmapKind());
8462 Record.push_back(
C->getDefaultmapModifier());
8463 Record.AddSourceLocation(
C->getLParenLoc());
8464 Record.AddSourceLocation(
C->getDefaultmapModifierLoc());
8465 Record.AddSourceLocation(
C->getDefaultmapKindLoc());
8468void OMPClauseWriter::VisitOMPToClause(
OMPToClause *
C) {
8469 Record.push_back(
C->varlist_size());
8470 Record.push_back(
C->getUniqueDeclarationsNum());
8471 Record.push_back(
C->getTotalComponentListNum());
8472 Record.push_back(
C->getTotalComponentsNum());
8473 Record.AddSourceLocation(
C->getLParenLoc());
8475 Record.push_back(
C->getMotionModifier(I));
8476 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
8477 if (
C->getMotionModifier(I) == OMPC_MOTION_MODIFIER_iterator)
8478 Record.AddStmt(
C->getIteratorModifier());
8480 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8481 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8482 Record.AddSourceLocation(
C->getColonLoc());
8483 for (
auto *E :
C->varlist())
8485 for (
auto *E :
C->mapperlists())
8487 for (
auto *D :
C->all_decls())
8489 for (
auto N :
C->all_num_lists())
8491 for (
auto N :
C->all_lists_sizes())
8493 for (
auto &M :
C->all_components()) {
8494 Record.AddStmt(M.getAssociatedExpression());
8495 Record.writeBool(M.isNonContiguous());
8496 Record.AddDeclRef(M.getAssociatedDeclaration());
8501 Record.push_back(
C->varlist_size());
8502 Record.push_back(
C->getUniqueDeclarationsNum());
8503 Record.push_back(
C->getTotalComponentListNum());
8504 Record.push_back(
C->getTotalComponentsNum());
8505 Record.AddSourceLocation(
C->getLParenLoc());
8507 Record.push_back(
C->getMotionModifier(I));
8508 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
8509 if (
C->getMotionModifier(I) == OMPC_MOTION_MODIFIER_iterator)
8510 Record.AddStmt(
C->getIteratorModifier());
8512 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8513 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8514 Record.AddSourceLocation(
C->getColonLoc());
8515 for (
auto *E :
C->varlist())
8517 for (
auto *E :
C->mapperlists())
8519 for (
auto *D :
C->all_decls())
8521 for (
auto N :
C->all_num_lists())
8523 for (
auto N :
C->all_lists_sizes())
8525 for (
auto &M :
C->all_components()) {
8526 Record.AddStmt(M.getAssociatedExpression());
8527 Record.writeBool(M.isNonContiguous());
8528 Record.AddDeclRef(M.getAssociatedDeclaration());
8533 Record.push_back(
C->varlist_size());
8534 Record.push_back(
C->getUniqueDeclarationsNum());
8535 Record.push_back(
C->getTotalComponentListNum());
8536 Record.push_back(
C->getTotalComponentsNum());
8537 Record.AddSourceLocation(
C->getLParenLoc());
8538 for (
auto *E :
C->varlist())
8540 for (
auto *
VE :
C->private_copies())
8542 for (
auto *
VE :
C->inits())
8544 for (
auto *D :
C->all_decls())
8546 for (
auto N :
C->all_num_lists())
8548 for (
auto N :
C->all_lists_sizes())
8550 for (
auto &M :
C->all_components()) {
8551 Record.AddStmt(M.getAssociatedExpression());
8552 Record.AddDeclRef(M.getAssociatedDeclaration());
8557 Record.push_back(
C->varlist_size());
8558 Record.push_back(
C->getUniqueDeclarationsNum());
8559 Record.push_back(
C->getTotalComponentListNum());
8560 Record.push_back(
C->getTotalComponentsNum());
8561 Record.AddSourceLocation(
C->getLParenLoc());
8562 for (
auto *E :
C->varlist())
8564 for (
auto *D :
C->all_decls())
8566 for (
auto N :
C->all_num_lists())
8568 for (
auto N :
C->all_lists_sizes())
8570 for (
auto &M :
C->all_components()) {
8571 Record.AddStmt(M.getAssociatedExpression());
8572 Record.AddDeclRef(M.getAssociatedDeclaration());
8577 Record.push_back(
C->varlist_size());
8578 Record.push_back(
C->getUniqueDeclarationsNum());
8579 Record.push_back(
C->getTotalComponentListNum());
8580 Record.push_back(
C->getTotalComponentsNum());
8581 Record.AddSourceLocation(
C->getLParenLoc());
8582 for (
auto *E :
C->varlist())
8584 for (
auto *D :
C->all_decls())
8586 for (
auto N :
C->all_num_lists())
8588 for (
auto N :
C->all_lists_sizes())
8590 for (
auto &M :
C->all_components()) {
8591 Record.AddStmt(M.getAssociatedExpression());
8592 Record.AddDeclRef(M.getAssociatedDeclaration());
8597 Record.push_back(
C->varlist_size());
8598 Record.push_back(
C->getUniqueDeclarationsNum());
8599 Record.push_back(
C->getTotalComponentListNum());
8600 Record.push_back(
C->getTotalComponentsNum());
8601 Record.AddSourceLocation(
C->getLParenLoc());
8602 for (
auto *E :
C->varlist())
8604 for (
auto *D :
C->all_decls())
8606 for (
auto N :
C->all_num_lists())
8608 for (
auto N :
C->all_lists_sizes())
8610 for (
auto &M :
C->all_components()) {
8611 Record.AddStmt(M.getAssociatedExpression());
8612 Record.AddDeclRef(M.getAssociatedDeclaration());
8618void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
8627void OMPClauseWriter::VisitOMPAtomicDefaultMemOrderClause(
8629 Record.push_back(
C->getAtomicDefaultMemOrderKind());
8630 Record.AddSourceLocation(
C->getLParenLoc());
8631 Record.AddSourceLocation(
C->getAtomicDefaultMemOrderKindKwLoc());
8636void OMPClauseWriter::VisitOMPAtClause(
OMPAtClause *
C) {
8637 Record.push_back(
C->getAtKind());
8638 Record.AddSourceLocation(
C->getLParenLoc());
8639 Record.AddSourceLocation(
C->getAtKindKwLoc());
8643 Record.push_back(
C->getSeverityKind());
8644 Record.AddSourceLocation(
C->getLParenLoc());
8645 Record.AddSourceLocation(
C->getSeverityKindKwLoc());
8649 VisitOMPClauseWithPreInit(
C);
8650 Record.AddStmt(
C->getMessageString());
8651 Record.AddSourceLocation(
C->getLParenLoc());
8655 Record.push_back(
C->varlist_size());
8656 Record.AddSourceLocation(
C->getLParenLoc());
8657 for (
auto *
VE :
C->varlist())
8659 for (
auto *E :
C->private_refs())
8664 Record.push_back(
C->varlist_size());
8665 Record.AddSourceLocation(
C->getLParenLoc());
8666 for (
auto *
VE :
C->varlist())
8671 Record.push_back(
C->varlist_size());
8672 Record.AddSourceLocation(
C->getLParenLoc());
8673 for (
auto *
VE :
C->varlist())
8678 Record.writeEnum(
C->getKind());
8679 Record.writeEnum(
C->getModifier());
8680 Record.AddSourceLocation(
C->getLParenLoc());
8681 Record.AddSourceLocation(
C->getKindKwLoc());
8682 Record.AddSourceLocation(
C->getModifierKwLoc());
8686 Record.push_back(
C->getNumberOfAllocators());
8687 Record.AddSourceLocation(
C->getLParenLoc());
8688 for (
unsigned I = 0, E =
C->getNumberOfAllocators(); I < E; ++I) {
8698 Record.push_back(
C->varlist_size());
8699 Record.AddSourceLocation(
C->getLParenLoc());
8700 Record.AddStmt(
C->getModifier());
8701 Record.AddSourceLocation(
C->getColonLoc());
8702 for (
Expr *E :
C->varlist())
8707 Record.writeEnum(
C->getBindKind());
8708 Record.AddSourceLocation(
C->getLParenLoc());
8709 Record.AddSourceLocation(
C->getBindKindLoc());
8713 VisitOMPClauseWithPreInit(
C);
8715 Record.AddSourceLocation(
C->getLParenLoc());
8718void OMPClauseWriter::VisitOMPDynGroupprivateClause(
8720 VisitOMPClauseWithPreInit(
C);
8721 Record.push_back(
C->getDynGroupprivateModifier());
8722 Record.push_back(
C->getDynGroupprivateFallbackModifier());
8724 Record.AddSourceLocation(
C->getLParenLoc());
8725 Record.AddSourceLocation(
C->getDynGroupprivateModifierLoc());
8726 Record.AddSourceLocation(
C->getDynGroupprivateFallbackModifierLoc());
8730 Record.push_back(
C->varlist_size());
8731 Record.push_back(
C->getNumLoops());
8732 Record.AddSourceLocation(
C->getLParenLoc());
8733 Record.push_back(
C->getDependenceType());
8734 Record.AddSourceLocation(
C->getDependenceLoc());
8735 Record.AddSourceLocation(
C->getColonLoc());
8736 for (
auto *
VE :
C->varlist())
8738 for (
unsigned I = 0, E =
C->getNumLoops(); I < E; ++I)
8739 Record.AddStmt(
C->getLoopData(I));
8743 Record.AddAttributes(
C->getAttrs());
8744 Record.AddSourceLocation(
C->getBeginLoc());
8745 Record.AddSourceLocation(
C->getLParenLoc());
8746 Record.AddSourceLocation(
C->getEndLoc());
8753 for (
const auto &
Set : TI->
Sets) {
8760 writeExprRef(
Selector.ScoreOrCondition);
8774 for (
unsigned I = 0, E =
Data->getNumClauses(); I < E; ++I)
8776 if (
Data->hasAssociatedStmt())
8778 for (
unsigned I = 0, E =
Data->getNumChildren(); I < E; ++I)
8784 for (
Expr *E :
C->getVarList())
8790 for (
Expr *E : Exprs)
8799 switch (
C->getClauseKind()) {
8809 AddStmt(
const_cast<Expr*
>(IC->getConditionExpr()));
8816 if (SC->isConditionExprClause()) {
8818 if (SC->hasConditionExpr())
8819 AddStmt(
const_cast<Expr *
>(SC->getConditionExpr()));
8822 for (
Expr *E : SC->getVarList())
8831 for (
Expr *E : NGC->getIntExprs())
8865 static_assert(
sizeof(R) == 1 *
sizeof(
int *));
8888 static_assert(
sizeof(R) == 2 *
sizeof(
int *));
8976 if (AC->hasIntExpr())
8984 if (
Expr *DNE = WC->getDevNumExpr())
8998 if (Arg.getIdentifierInfo())
9017 for (
auto &CombinerRecipe : R.CombinerRecipes) {
9045 for (
Expr *E : TC->getSizeExprs())
9053 for (
unsigned I = 0; I < GC->getNumExprs(); ++I) {
9055 AddStmt(
const_cast<Expr *
>(GC->getExpr(I).second));
9063 if (WC->hasIntExpr())
9071 if (VC->hasIntExpr())
9092 if (BC->isStringArgument())
9101 llvm_unreachable(
"Clause serialization not yet implemented");
9103 llvm_unreachable(
"Invalid Clause Kind");
9112 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 unsigned getNumberOfModules(Module *Mod)
Compute the number of modules within the given tree (including the given module).
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 bool cleanPathForOutput(FileManager &FileMgr, SmallVectorImpl< char > &Path)
Prepares a path for being written to an AST file by converting it to an absolute path and removing ne...
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.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the LambdaCapture class.
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
Defines the clang::LangOptions interface.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Target Target
llvm::MachO::Record Record
Defines the clang::MacroInfo and clang::MacroDirective classes.
Defines the clang::Module class, which describes a module in the source code.
Defines types useful for describing an Objective-C runtime.
Defines some OpenACC-specific enums and functions.
Defines the clang::OpenCLOptions class.
This file defines OpenMP AST classes for clauses.
Defines the clang::Preprocessor interface.
This file declares semantic analysis for CUDA constructs.
This file declares semantic analysis for Objective-C.
static void EmitBlockID(unsigned ID, const char *Name, llvm::BitstreamWriter &Stream, RecordDataImpl &Record)
Emits a block ID in the BLOCKINFO block.
static void EmitRecordID(unsigned ID, const char *Name, llvm::BitstreamWriter &Stream, RecordDataImpl &Record)
Emits a record ID in the BLOCKINFO block.
Defines the clang::SourceLocation class and associated facilities.
Defines implementation details of the clang::SourceManager class.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TargetOptions class.
#define IMPORT(DERIVED, BASE)
#define BLOCK(DERIVED, BASE)
Defines the clang::TypeLoc interface and its subclasses.
TypePropertyCache< Private > Cache
C Language Family Type Representation.
Defines version macros and version-related utility functions for Clang.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
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()
virtual void EnteringModulePurview()
The parser find the named module declaration.
Reads an AST files chain containing the contents of a translation unit.
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.
An object for streaming information to a record.
void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
void AddCXXBaseSpecifiers(ArrayRef< CXXBaseSpecifier > Bases)
Emit a set of C++ base specifiers.
void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs)
Emit a template argument list.
uint64_t Emit(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, followed by its substatements, and return its offset.
void AddCXXTemporary(const CXXTemporary *Temp)
Emit a CXXTemporary.
void writeOMPTraitInfo(const OMPTraitInfo *TI)
Write an OMPTraitInfo object.
void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Emit a C++ base specifier.
void writeOMPClause(OMPClause *C)
void writeBool(bool Value)
void AddAPValue(const APValue &Value)
Emit an APvalue.
void AddUnresolvedSet(const ASTUnresolvedSet &Set)
Emit a UnresolvedSet structure.
void AddIdentifierRef(const IdentifierInfo *II)
Emit a reference to an identifier.
void AddStmt(Stmt *S)
Add the given statement or expression to the queue of statements to emit.
void AddDeclarationName(DeclarationName Name)
Emit a declaration name.
void AddTemplateArgumentLocInfo(const TemplateArgumentLoc &Arg)
Emits a template argument location info.
void AddTypeLoc(TypeLoc TL)
Emits source location information for a type. Does not emit the type.
void AddSelectorRef(Selector S)
Emit a Selector (which is a smart pointer reference).
void writeSourceLocation(SourceLocation Loc)
void AddOffset(uint64_t BitOffset)
Add a bit offset into the record.
void AddTypeRef(QualType T)
Emit a reference to a type.
void writeOpenACCClauseList(ArrayRef< const OpenACCClause * > Clauses)
Writes out a list of OpenACC clauses.
void push_back(uint64_t N)
Minimal vector-like interface.
void AddCXXCtorInitializers(ArrayRef< CXXCtorInitializer * > CtorInits)
Emit a CXXCtorInitializer array.
void AddTemplateParameterList(const TemplateParameterList *TemplateParams)
Emit a template parameter list.
void AddTemplateArgument(const TemplateArgument &Arg)
Emit a template argument.
void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc, DeclarationName Name)
void writeOpenACCIntExprList(ArrayRef< Expr * > Exprs)
void AddAPFloat(const llvm::APFloat &Value)
Emit a floating-point value.
void AddTypeSourceInfo(TypeSourceInfo *TInfo)
Emits a reference to a declarator info.
void AddQualifierInfo(const QualifierInfo &Info)
void writeUInt32(uint32_t Value)
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
void writeOMPChildren(OMPChildren *Data)
Writes data related to the OpenMP directives.
void AddConceptReference(const ConceptReference *CR)
void AddSourceRange(SourceRange Range)
Emit a source range.
void AddAPInt(const llvm::APInt &Value)
Emit an integral value.
void AddSourceLocation(SourceLocation Loc)
Emit a source location.
void writeOpenACCVarList(const OpenACCClauseWithVarList *C)
void AddAttributes(ArrayRef< const Attr * > Attrs)
Emit a list of attributes.
void AddASTTemplateArgumentListInfo(const ASTTemplateArgumentListInfo *ASTTemplArgList)
Emits an AST template argument list info.
void AddCXXDefinitionData(const CXXRecordDecl *D)
void AddVarDeclInit(const VarDecl *VD)
Emit information about the initializer of a VarDecl.
void writeStmtRef(const Stmt *S)
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg)
Emits a template argument location.
void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Emit a nested name specifier with source-location information.
void AddOpenACCRoutineDeclAttr(const OpenACCRoutineDeclAttr *A)
void writeOpenACCClause(const OpenACCClause *C)
Writes out a single OpenACC Clause.
void AddAttr(const Attr *A)
An UnresolvedSet-like class which uses the ASTContext's allocator.
UnresolvedSetIterator const_iterator
Writes an AST file containing the contents of a translation unit.
void AddEmittedDeclRef(const Decl *D, RecordDataImpl &Record)
friend class ASTRecordWriter
bool isWritingStdCXXNamedModules() const
ArrayRef< uint64_t > RecordDataRef
void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record, StringRef Path)
Emit the current record with the given path as a blob.
void AddFileID(FileID FID, RecordDataImpl &Record)
Emit a FileID.
bool isDeclPredefined(const Decl *D) const
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)
bool IsLocalDecl(const Decl *D)
Is this a local declaration (that is, one that will be written to our AST file)?
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.
time_t getTimestampForOutput(const FileEntry *E) const
Get a timestamp for output into the AST file.
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.
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.
ASTFileSignature WriteAST(llvm::PointerUnion< Sema *, Preprocessor * > Subject, StringRef OutputFile, Module *WritingModule, StringRef isysroot, bool ShouldCacheASTInMemory=false)
Write a precompiled header or a module with the AST produced by the Sema object, or a dependency scan...
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.
void handleVTable(CXXRecordDecl *RD)
unsigned getLocalOrImportedSubmoduleID(const Module *Mod)
Retrieve or create a submodule ID for this module, or return 0 if the submodule is neither local (a s...
void AddToken(const Token &Tok, RecordDataImpl &Record)
Emit a token.
void AddLookupOffsets(const LookupBlockOffsets &Offsets, RecordDataImpl &Record)
serialization::SelectorID getSelectorRef(Selector Sel)
Get the unique number used to refer to the given selector.
SmallVector< uint64_t, 64 > RecordData
serialization::TypeID GetOrCreateTypeID(ASTContext &Context, QualType T)
Force a type to be emitted and get its ID.
unsigned getAnonymousDeclarationNumber(const NamedDecl *D)
void AddMacroRef(MacroInfo *MI, const IdentifierInfo *Name, RecordDataImpl &Record)
Emit a reference to a macro.
const LangOptions & getLangOpts() const
void SetSelectorOffset(Selector Sel, uint32_t Offset)
Note that the selector Sel occurs at the given offset within the method pool/selector table.
bool PreparePathForOutput(SmallVectorImpl< char > &Path)
Convert a path from this build process into one that is appropriate for emission in the module file.
void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset)
Note that the identifier II occurs at the given offset within the identifier table.
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
void AddStringBlob(StringRef Str, RecordDataImpl &Record, SmallVectorImpl< char > &Blob)
Wrapper for source info for arrays.
SourceLocation getLBracketLoc() const
Expr * getSizeExpr() const
SourceLocation getRBracketLoc() const
SourceLocation getRParenLoc() const
SourceLocation getKWLoc() const
SourceLocation getLParenLoc() const
Attr - This represents one attribute.
attr::Kind getKind() const
SourceLocation getScopeLoc() const
SourceRange getRange() const
const IdentifierInfo * getScopeName() const
bool isRegularKeywordAttribute() const
const IdentifierInfo * getAttrName() const
Kind getParsedKind() const
const Attr * getAttr() const
The type attribute.
SourceLocation getRParenLoc() const
bool isDecltypeAuto() const
bool isConstrained() const
ConceptReference * getConceptReference() const
A simple helper class to pack several bits in order into (a) 32 bit integer(s).
void addBits(uint32_t Value, uint32_t BitsWidth)
SourceLocation getCaretLoc() const
SourceLocation getBuiltinLoc() const
TypeSpecifierType getWrittenTypeSpec() const
TypeSpecifierWidth getWrittenWidthSpec() const
bool needsExtraLocalData() const
TypeSpecifierSign getWrittenSignSpec() const
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
Represents a C++ destructor within a class.
Represents a C++ struct/union/class.
unsigned getDeviceLambdaManglingNumber() const
Retrieve the device side mangling number.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
unsigned getODRHash() const
Represents a C++ temporary.
const CXXDestructorDecl * getDestructor() const
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
A reference to a concept and its template args, as it appears in the code.
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
NamedDecl * getFoundDecl() const
const DeclarationNameInfo & getConceptNameInfo() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
TemplateDecl * getNamedConcept() const
SourceLocation getTemplateKWLoc() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isFileContext() const
DeclContextLookupResult lookup_result
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isLookupContext() const
Test whether the context supports looking up names.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
StoredDeclsMap * buildLookup()
Ensure the lookup structure is fully-built and return it.
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
StoredDeclsMap * getLookupPtr() const
Retrieve the internal representation of the lookup structure.
DeclID getRawValue() const
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Module * getTopLevelOwningNamedModule() const
Get the top level owning named module that owns this declaration if any.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool isInNamedModule() const
Whether this declaration comes from a named module.
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
@ FOK_None
Not a friend object.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
bool isFromExplicitGlobalModule() const
Whether this declaration comes from explicit global module.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
DeclContext * getNonTransparentDeclContext()
Return the non transparent context.
SourceLocation getLocation() const
DeclContext * getDeclContext()
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
GlobalDeclID getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
DeclarationNameLoc - Additional source/type location info for a declaration name.
SourceLocation getCXXLiteralOperatorNameLoc() const
Return the location of the literal operator name (without the operator keyword).
TypeSourceInfo * getNamedTypeInfo() const
Returns the source type info.
SourceRange getCXXOperatorNameRange() const
Return the range of the operator name (without the operator keyword).
The name of a declaration.
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
SourceLocation getDecltypeLoc() const
SourceLocation getRParenLoc() const
SourceLocation getElaboratedKeywordLoc() const
SourceLocation getTemplateNameLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
Expr * getAttrExprOperand() const
The attribute's expression operand, if it has one.
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
NestedNameSpecifierLoc getQualifierLoc() const
SourceLocation getNameLoc() const
SourceLocation getElaboratedKeywordLoc() const
SourceLocation getNameLoc() const
SourceLocation getNameLoc() const
std::vector< std::string > Remarks
The list of -R... options used to alter the diagnostic mappings, with the prefixes removed.
std::vector< std::string > Warnings
The list of -W... options used to alter the diagnostic mappings, with the prefixes removed.
DiagnosticOptions & getDiagnosticOptions() const
Retrieve the diagnostic options.
bool hasUncompilableErrorOccurred() const
Errors that actually prevent compilation, not those that are upgraded from a warning by -Werror.
StringRef getName() const
SourceLocation getElaboratedKeywordLoc() const
SourceLocation getNameLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
This represents one expression.
storage_type getAsOpaqueInt() const
storage_type getAsOpaqueInt() const
Represents a member of a struct/union/class.
StringRef getName() const
The name of this FileEntry.
Cached information about one file (either on disk or in the virtual file system).
time_t getModificationTime() const
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Implements support for file system lookup, file system caching, and directory search management.
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,...
OptionalFileEntryRef getOptionalFileRef(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Get a FileEntryRef if it exists, without doing anything on error.
void GetUniqueIDMapping(SmallVectorImpl< OptionalFileEntryRef > &UIDToFiles) const
Produce an array mapping from the unique IDs assigned to each file to the corresponding FileEntryRef.
FileSystemOptions & getFileSystemOpts()
Returns the current file system options.
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'.
SourceLocation getAmpLoc() const
Describes the capture of a variable or of this, or of a C++1y init-capture.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
clang::ObjCRuntime ObjCRuntime
CommentOptions CommentOpts
Options for parsing comments.
std::string OMPHostIRFile
Name of the IR file that contains the result of the OpenMP target host code generation.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
std::string CurrentModule
The name of the current module, of which the main source file is a part.
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
Record the location of a macro definition.
Encapsulates changes to the "macros namespace" (the location where the macro name became active,...
const MacroDirective * getPrevious() const
Get previous definition of the macro with the same name.
const MacroInfo * getMacroInfo() const
SourceLocation getLocation() const
Encapsulates the data about a macro definition (e.g.
bool isUsed() const
Return false if this macro is defined in the main file and has not yet been used.
bool isC99Varargs() const
SourceLocation getDefinitionEndLoc() const
Return the location of the last token in the macro.
ArrayRef< const IdentifierInfo * > params() const
unsigned getNumTokens() const
Return the number of tokens that this macro expands to.
unsigned getNumParams() const
const Token & getReplacementToken(unsigned Tok) const
bool isBuiltinMacro() const
Return true if this macro requires processing before expansion.
SourceLocation getDefinitionLoc() const
Return the location that the macro was defined at.
bool hasCommaPasting() const
bool isObjectLike() const
bool isUsedForHeaderGuard() const
Determine whether this macro was used for a header guard.
bool isGNUVarargs() const
SourceLocation getExpansionLoc() const
Expr * getAttrColumnOperand() const
The attribute's column operand, if it has one.
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Expr * getAttrRowOperand() const
The attribute's row operand, if it has one.
NestedNameSpecifierLoc getQualifierLoc() const
SourceLocation getStarLoc() const
The module cache used for compiling modules implicitly.
virtual void writeExtensionContents(Sema &SemaRef, llvm::BitstreamWriter &Stream)=0
Write the contents of the extension block into the given bitstream.
ModuleFileExtension * getExtension() const
Retrieve the module file extension with which this writer is associated.
virtual ModuleFileExtensionMetadata getExtensionMetadata() const =0
Retrieves the metadata for this module file extension.
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 * { ... }).
llvm::SmallSetVector< Module *, 2 > Imports
The set of modules imported by this module, and on which this module depends.
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.
unsigned NamedModuleHasInit
Whether this C++20 named modules doesn't need an initializer.
llvm::SmallSetVector< Module *, 2 > AffectingClangModules
The set of top-level modules that affected the compilation of this module, but were not imported.
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.
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 'absent' clause in the 'pragma omp assume' directive.
This represents 'acq_rel' clause in the 'pragma omp atomic|flush' directives.
This represents 'acquire' clause in the 'pragma omp atomic|flush' directives.
This represents clause 'affinity' in the 'pragma omp task'-based directives.
This represents the 'align' clause in the 'pragma omp allocate' directive.
This represents clause 'aligned' in the 'pragma omp ...' directives.
This represents clause 'allocate' in the 'pragma omp ...' directives.
This represents 'allocator' clause in the 'pragma omp ...' directive.
This represents 'at' clause in the 'pragma omp error' directive.
This represents 'atomic_default_mem_order' clause in the 'pragma omp requires' directive.
This represents 'bind' clause in the 'pragma omp ...' directives.
This represents 'capture' clause in the 'pragma omp atomic' directive.
Contains data for OpenMP directives: clauses, children expressions/statements (helpers for codegen) a...
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 'compare' clause in the 'pragma omp atomic' directive.
This represents the 'contains' clause in the 'pragma omp assume' directive.
This represents clause 'copyin' in the 'pragma omp ...' directives.
This represents clause 'copyprivate' in the 'pragma omp ...' directives.
This represents 'default' clause in the 'pragma omp ...' directive.
This represents 'defaultmap' clause in the 'pragma omp ...' directive.
This represents implicit clause 'depend' for the 'pragma omp task' directive.
This represents implicit clause 'depobj' for the 'pragma omp depobj' directive.
This represents 'destroy' clause in the 'pragma omp depobj' directive or the 'pragma omp interop' dir...
This represents 'detach' clause in the 'pragma omp task' directive.
This represents 'device' clause in the 'pragma omp ...' directive.
This represents 'dist_schedule' clause in the 'pragma omp ...' directive.
This represents the 'doacross' clause for the 'pragma omp ordered' directive.
This represents 'dyn_groupprivate' clause in 'pragma omp target ...' and 'pragma omp teams ....
This represents 'dynamic_allocators' clause in the 'pragma omp requires' directive.
This represents clause 'exclusive' in the 'pragma omp scan' directive.
This represents 'fail' clause in the 'pragma omp atomic' directive.
This represents 'filter' clause in the 'pragma omp ...' directive.
This represents 'final' clause in the 'pragma omp ...' directive.
This represents clause 'firstprivate' in the 'pragma omp ...' directives.
This represents implicit clause 'flush' for the 'pragma omp flush' directive.
This represents clause 'from' in the 'pragma omp ...' directives.
Representation of the 'full' clause of the 'pragma omp unroll' directive.
This represents 'grainsize' clause in the 'pragma omp ...' directive.
This represents clause 'has_device_ptr' in the 'pragma omp ...' directives.
This represents 'hint' clause in the 'pragma omp ...' directive.
This represents the 'holds' clause in the 'pragma omp assume' directive.
This represents 'if' clause in the 'pragma omp ...' directive.
This represents clause 'in_reduction' in the 'pragma omp task' directives.
This represents clause 'inclusive' in the 'pragma omp scan' directive.
This represents the 'init' clause in 'pragma omp ...' directives.
This represents clause 'is_device_ptr' in the 'pragma omp ...' directives.
This represents clause 'lastprivate' in the 'pragma omp ...' directives.
This represents clause 'linear' in the 'pragma omp ...' directives.
This class represents the 'looprange' clause in the 'pragma omp fuse' directive.
This represents clause 'map' in the 'pragma omp ...' directives.
This represents 'mergeable' clause in the 'pragma omp ...' directive.
This represents the 'message' clause in the 'pragma omp error' and the 'pragma omp parallel' directiv...
This represents the 'no_openmp' clause in the 'pragma omp assume' directive.
This represents the 'no_openmp_constructs' clause in the.
This represents the 'no_openmp_routines' clause in the 'pragma omp assume' directive.
This represents the 'no_parallelism' clause in the 'pragma omp assume' directive.
This represents 'nocontext' clause in the 'pragma omp ...' directive.
This represents 'nogroup' clause in the 'pragma omp ...' directive.
This represents clause 'nontemporal' in the 'pragma omp ...' directives.
This represents 'novariants' clause in the 'pragma omp ...' directive.
This represents 'nowait' clause in the 'pragma omp ...' directive.
This represents 'num_tasks' clause in the 'pragma omp ...' directive.
This represents 'num_teams' clause in the 'pragma omp ...' directive.
This represents 'num_threads' clause in the 'pragma omp ...' directive.
This represents 'order' clause in the 'pragma omp ...' directive.
This represents 'ordered' 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 'priority' clause in the 'pragma omp ...' directive.
This represents clause 'private' in the 'pragma omp ...' directives.
This represents 'proc_bind' clause in the 'pragma omp ...' directive.
This represents 'read' clause in the 'pragma omp atomic' directive.
This represents clause 'reduction' in the 'pragma omp ...' directives.
This represents 'relaxed' clause in the 'pragma omp atomic' directives.
This represents 'release' clause in the 'pragma omp atomic|flush' directives.
This represents 'reverse_offload' clause in the 'pragma omp requires' directive.
This represents 'simd' clause in the 'pragma omp ...' directive.
This represents 'safelen' clause in the 'pragma omp ...' directive.
This represents 'schedule' clause in the 'pragma omp ...' directive.
This represents 'self_maps' clause in the 'pragma omp requires' directive.
This represents 'seq_cst' clause in the 'pragma omp atomic|flush' directives.
This represents the 'severity' clause in the 'pragma omp error' and the 'pragma omp parallel' directi...
This represents clause 'shared' in the 'pragma omp ...' directives.
This represents 'simdlen' clause in the 'pragma omp ...' directive.
This represents the 'sizes' clause in the 'pragma omp tile' directive.
This represents clause 'task_reduction' in the 'pragma omp taskgroup' directives.
This represents 'thread_limit' clause in the 'pragma omp ...' directive.
This represents 'threads' clause in the 'pragma omp ...' directive.
This represents 'threadset' clause in the 'pragma omp task ...' directive.
This represents clause 'to' in the 'pragma omp ...' directives.
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
llvm::SmallVector< OMPTraitSet, 2 > Sets
The outermost level of selector sets.
This represents 'unified_address' clause in the 'pragma omp requires' directive.
This represents 'unified_shared_memory' clause in the 'pragma omp requires' directive.
This represents 'untied' clause in the 'pragma omp ...' directive.
This represents 'update' clause in the 'pragma omp atomic' directive.
This represents the 'use' clause in 'pragma omp ...' directives.
This represents clause 'use_device_addr' in the 'pragma omp ...' directives.
This represents clause 'use_device_ptr' in the 'pragma omp ...' directives.
This represents clause 'uses_allocators' in the 'pragma omp target'-based directives.
This represents 'weak' clause in the 'pragma omp atomic' directives.
This represents 'write' clause in the 'pragma omp atomic' directive.
This represents 'ompx_attribute' clause in a directive that might generate an outlined function.
This represents 'ompx_bare' clause in the 'pragma omp target teams ...' directive.
This represents 'ompx_dyn_cgroup_mem' clause in the 'pragma omp target ...' directive.
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 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.
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
DelegatingCtorDeclsType DelegatingCtorDecls
All the delegating constructors seen so far in the file, used for cycle detection at the end of the T...
Preprocessor & getPreprocessor() const
PragmaStack< FPOptionsOverride > FpPragmaStack
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimizeoff". If this location is invalid,...
FPOptionsOverride CurFPFeatureOverrides()
LateParsedTemplateMapT LateParsedTemplateMap
UnusedFileScopedDeclsType UnusedFileScopedDecls
The set of file scoped decls seen so far that have not been used and must warn if not used.
SmallVector< const Decl * > DeclsWithEffectsToVerify
All functions/lambdas/blocks which have bodies and which have a non-empty FunctionEffectsRef to be ve...
EnumDecl * getStdAlignValT() const
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate > > LateParsedTemplateMapT
CXXRecordDecl * getStdBadAlloc() const
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
llvm::DenseMap< CXXRecordDecl *, bool > VTablesUsed
The set of classes whose vtables have been used within this translation unit, and a bit that will be ...
PragmaStack< AlignPackInfo > AlignPackStack
llvm::SmallSetVector< Decl *, 4 > DeclsToCheckForDeferredDiags
Function or variable declarations to be checked for whether the deferred diagnostics should be emitte...
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
const llvm::MapVector< FieldDecl *, DeleteLocs > & getMismatchingDeleteExpressions() const
Retrieves list of suspicious delete-expressions that will be checked at the end of translation unit.
OpenCLOptions & getOpenCLOptions()
NamespaceDecl * getStdNamespace() const
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
llvm::MapVector< IdentifierInfo *, llvm::SetVector< WeakInfo, llvm::SmallVector< WeakInfo, 1u >, llvm::SmallDenseSet< WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly > > > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
IdentifierResolver IdResolver
static RawLocEncoding encode(SourceLocation Loc, UIntTy BaseOffset, unsigned BaseModuleFileIndex)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
DiagnosticsEngine & getDiagnostics() const
SourceLocation::UIntTy getNextLocalOffset() const
OptionalFileEntryRef getFileEntryRefForID(FileID FID) const
Returns the FileEntryRef for the provided FileID.
const SrcMgr::SLocEntry & getLocalSLocEntry(unsigned Index) const
Get a local SLocEntry. This is exposed for indexing.
FileManager & getFileManager() const
unsigned local_sloc_entry_size() const
Get the number of local SLocEntries we have.
SourceLocation getLocForEndOfFile(FileID FID) const
Return the source location corresponding to the last byte of the specified file.
FileID getMainFileID() const
Returns the FileID of the main source file.
unsigned getFileIDSize(FileID FID) const
The size of the SLocEntry that FID represents.
bool hasLineTable() const
Determine if the source manager has a line table.
bool isLoadedFileID(FileID FID) const
Returns true if FID came from a PCH/Module.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
LineTableInfo & getLineTable()
Retrieve the stored line table.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
OptionalFileEntryRef ContentsEntry
References the file which the contents were actually loaded from.
unsigned IsTransient
True if this file may be transient, that is, if it might not exist at some later point in time when t...
std::optional< llvm::MemoryBufferRef > getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM, SourceLocation Loc=SourceLocation()) const
Returns the memory buffer for the associated content.
unsigned BufferOverridden
Indicates whether the buffer itself was provided to override the actual file contents.
OptionalFileEntryRef OrigEntry
Reference to the file entry representing this ContentCache.
SourceLocation getExpansionLocStart() const
bool isExpansionTokenRange() const
SourceLocation getSpellingLoc() const
bool isMacroArgExpansion() const
SourceLocation getExpansionLocEnd() const
const ContentCache & getContentCache() const
SourceLocation::UIntTy getOffset() const
const FileInfo & getFile() const
const ExpansionInfo & getExpansion() const
An array of decls optimized for the common case of only containing one entry.
StringLiteral - This represents a string literal expression, e.g.
Represents the declaration of a struct/union/class/enum.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
SourceLocation getNameLoc() const
SourceLocation getElaboratedKeywordLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
TargetOptions & getTargetOpts() const
Retrieve the target options.
std::string Triple
The name of the target triple to compile for.
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings starting...
std::string ABI
If given, the name of the target ABI to use.
std::string TuneCPU
If given, the name of the target CPU to tune code for.
std::string CPU
If given, the name of the target CPU to generate code for.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line.
A template argument list.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
Location wrapper for a TemplateArgument.
SourceLocation getTemplateEllipsisLoc() const
TemplateArgumentLocInfo getLocInfo() const
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKWLoc() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
Stores a list of template parameters for a TemplateDecl and its derived classes.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
SourceLocation getTemplateLoc() const
unsigned getNumArgs() const
SourceLocation getLAngleLoc() const
TemplateArgumentLoc getArgLoc(unsigned i) const
SourceLocation getRAngleLoc() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKeywordLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
SourceLocation getElaboratedKeywordLoc() const
Token - This structure provides full information about a lexed token.
The top declaration context.
NamespaceDecl * getAnonymousNamespace() const
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
TypeSourceInfo * getUnmodifiedTInfo() const
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getNameLoc() const
TypeClass getTypeClass() const
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
SourceLocation getTypeofLoc() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
bool hasInitWithSideEffects() const
Checks whether this declaration has an initializer with side effects.
EvaluatedStmt * getEvaluatedStmt() const
const Expr * getInit() const
APValue * getEvaluatedValue() const
Return the already-evaluated value of this variable's initializer, or NULL if the value is not yet kn...
Declaration of a variable template.
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getNameLoc() const
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
SourceLocation getEllipsisLoc() const
Retrieve the source location of the ellipsis, whose presence indicates that the capture is a pack exp...
OverloadedOperatorKind getOperatorKind() const
IdentifierInfo * getIdentifier() const
Selector getSelector() const
Information about a module that has been loaded by the ASTReader.
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
unsigned LocalNumSubmodules
The number of submodules in this module.
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
unsigned Index
The index of this module in the list of modules.
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
std::string FileName
The file name of the module file.
SourceLocation::UIntTy SLocEntryBaseOffset
The base offset in the source manager's view of this module.
unsigned LocalNumSelectors
The number of selectors new to this file.
ModuleKind Kind
The type of this module.
std::string ModuleName
The name of the module.
A type index; the type ID with the qualifier bits removed.
uint32_t getModuleFileIndex() const
TypeID asTypeID(unsigned FastQuals) const
uint64_t getValue() const
SmallVector< LazySpecializationInfo, 4 > data_type
The lookup result is a list of global declaration IDs.
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
TypeCode
Record codes for each kind of type.
const unsigned int DECL_UPDATES
Record of updates for a declaration that was modified after being deserialized.
@ PREDEF_TYPE_AUTO_RREF_DEDUCT
The "auto &&" deduction type.
@ PREDEF_TYPE_NULL_ID
The NULL type.
@ PREDEF_TYPE_AUTO_DEDUCT
The "auto" deduction type.
@ CTOR_INITIALIZER_MEMBER
@ CTOR_INITIALIZER_DELEGATING
@ CTOR_INITIALIZER_INDIRECT_MEMBER
@ DECL_EMPTY
An EmptyDecl record.
@ DECL_CXX_BASE_SPECIFIERS
A record containing CXXBaseSpecifiers.
@ DECL_CXX_RECORD
A CXXRecordDecl record.
@ DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION
A VarTemplatePartialSpecializationDecl record.
@ DECL_OMP_ALLOCATE
An OMPAllocateDcl record.
@ DECL_MS_PROPERTY
A MSPropertyDecl record.
@ DECL_REQUIRES_EXPR_BODY
A RequiresExprBodyDecl record.
@ DECL_STATIC_ASSERT
A StaticAssertDecl record.
@ DECL_INDIRECTFIELD
A IndirectFieldDecl record.
@ DECL_TEMPLATE_TEMPLATE_PARM
A TemplateTemplateParmDecl record.
@ DECL_IMPORT
An ImportDecl recording a module import.
@ DECL_ACCESS_SPEC
An AccessSpecDecl record.
@ DECL_OBJC_TYPE_PARAM
An ObjCTypeParamDecl record.
@ DECL_OBJC_CATEGORY_IMPL
A ObjCCategoryImplDecl record.
@ DECL_ENUM_CONSTANT
An EnumConstantDecl record.
@ DECL_PARM_VAR
A ParmVarDecl record.
@ DECL_TYPEDEF
A TypedefDecl record.
@ DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack.
@ DECL_HLSL_BUFFER
A HLSLBufferDecl record.
@ DECL_NAMESPACE_ALIAS
A NamespaceAliasDecl record.
@ DECL_TYPEALIAS
A TypeAliasDecl record.
@ DECL_FUNCTION_TEMPLATE
A FunctionTemplateDecl record.
@ DECL_UNRESOLVED_USING_TYPENAME
An UnresolvedUsingTypenameDecl record.
@ DECL_CLASS_TEMPLATE_SPECIALIZATION
A ClassTemplateSpecializationDecl record.
@ DECL_FILE_SCOPE_ASM
A FileScopeAsmDecl record.
@ DECL_PARTIAL_SPECIALIZATIONS
@ DECL_CXX_CONSTRUCTOR
A CXXConstructorDecl record.
@ DECL_CXX_CONVERSION
A CXXConversionDecl record.
@ DECL_FIELD
A FieldDecl record.
@ DECL_LINKAGE_SPEC
A LinkageSpecDecl record.
@ DECL_CONTEXT_TU_LOCAL_VISIBLE
A record that stores the set of declarations that are only visible to the TU.
@ DECL_NAMESPACE
A NamespaceDecl record.
@ DECL_NON_TYPE_TEMPLATE_PARM
A NonTypeTemplateParmDecl record.
@ DECL_FUNCTION
A FunctionDecl record.
@ DECL_USING_DIRECTIVE
A UsingDirecitveDecl record.
@ DECL_RECORD
A RecordDecl record.
@ DECL_CONTEXT_LEXICAL
A record that stores the set of declarations that are lexically stored within a given DeclContext.
@ DECL_BLOCK
A BlockDecl record.
@ DECL_UNRESOLVED_USING_VALUE
An UnresolvedUsingValueDecl record.
@ DECL_TYPE_ALIAS_TEMPLATE
A TypeAliasTemplateDecl record.
@ DECL_CXX_CTOR_INITIALIZERS
A record containing CXXCtorInitializers.
@ DECL_OBJC_CATEGORY
A ObjCCategoryDecl record.
@ DECL_VAR
A VarDecl record.
@ DECL_USING
A UsingDecl record.
@ DECL_OBJC_PROTOCOL
A ObjCProtocolDecl record.
@ DECL_TEMPLATE_TYPE_PARM
A TemplateTypeParmDecl record.
@ DECL_VAR_TEMPLATE_SPECIALIZATION
A VarTemplateSpecializationDecl record.
@ DECL_OBJC_IMPLEMENTATION
A ObjCImplementationDecl record.
@ DECL_OBJC_COMPATIBLE_ALIAS
A ObjCCompatibleAliasDecl record.
@ DECL_FRIEND_TEMPLATE
A FriendTemplateDecl record.
@ DECL_PRAGMA_DETECT_MISMATCH
A PragmaDetectMismatchDecl record.
@ DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack.
@ DECL_OBJC_AT_DEFS_FIELD
A ObjCAtDefsFieldDecl record.
@ DECL_IMPLICIT_PARAM
An ImplicitParamDecl record.
@ DECL_FRIEND
A FriendDecl record.
@ DECL_CXX_METHOD
A CXXMethodDecl record.
@ DECL_EXPORT
An ExportDecl record.
@ DECL_PRAGMA_COMMENT
A PragmaCommentDecl record.
@ DECL_ENUM
An EnumDecl record.
@ DECL_CONTEXT_MODULE_LOCAL_VISIBLE
A record containing the set of declarations that are only visible from DeclContext in the same module...
@ DECL_OMP_DECLARE_REDUCTION
An OMPDeclareReductionDecl record.
@ DECL_OMP_THREADPRIVATE
An OMPThreadPrivateDecl record.
@ DECL_OBJC_METHOD
A ObjCMethodDecl record.
@ DECL_CXX_DESTRUCTOR
A CXXDestructorDecl record.
@ DECL_OMP_CAPTUREDEXPR
An OMPCapturedExprDecl record.
@ DECL_CLASS_TEMPLATE
A ClassTemplateDecl record.
@ DECL_USING_SHADOW
A UsingShadowDecl record.
@ DECL_CONCEPT
A ConceptDecl record.
@ DECL_OBJC_IVAR
A ObjCIvarDecl record.
@ DECL_OBJC_PROPERTY
A ObjCPropertyDecl record.
@ DECL_OBJC_INTERFACE
A ObjCInterfaceDecl record.
@ DECL_VAR_TEMPLATE
A VarTemplateDecl record.
@ DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION
A ClassTemplatePartialSpecializationDecl record.
@ DECL_CONTEXT_VISIBLE
A record that stores the set of declarations that are visible from a given DeclContext.
@ DECL_OBJC_PROPERTY_IMPL
A ObjCPropertyImplDecl record.
@ TYPE_EXT_QUAL
An ExtQualType record.
@ EXPR_DESIGNATED_INIT
A DesignatedInitExpr record.
@ EXPR_COMPOUND_LITERAL
A CompoundLiteralExpr record.
@ EXPR_OBJC_IVAR_REF_EXPR
An ObjCIvarRefExpr record.
@ EXPR_MEMBER
A MemberExpr record.
@ EXPR_CXX_TEMPORARY_OBJECT
A CXXTemporaryObjectExpr record.
@ EXPR_CXX_UNRESOLVED_LOOKUP
@ EXPR_COMPOUND_ASSIGN_OPERATOR
A CompoundAssignOperator record.
@ EXPR_EXPR_WITH_CLEANUPS
@ EXPR_CXX_STATIC_CAST
A CXXStaticCastExpr record.
@ EXPR_OBJC_STRING_LITERAL
An ObjCStringLiteral record.
@ EXPR_VA_ARG
A VAArgExpr record.
@ EXPR_CXX_OPERATOR_CALL
A CXXOperatorCallExpr record.
@ STMT_OBJC_AT_TRY
An ObjCAtTryStmt record.
@ EXPR_CXX_UNRESOLVED_CONSTRUCT
@ EXPR_FIXEDPOINT_LITERAL
@ STMT_DO
A DoStmt record.
@ STMT_OBJC_CATCH
An ObjCAtCatchStmt record.
@ STMT_IF
An IfStmt record.
@ EXPR_CXX_EXPRESSION_TRAIT
@ EXPR_STRING_LITERAL
A StringLiteral record.
@ EXPR_IMPLICIT_CAST
An ImplicitCastExpr record.
@ STMT_GCCASM
A GCC-style AsmStmt record.
@ EXPR_IMAGINARY_LITERAL
An ImaginaryLiteral record.
@ STMT_WHILE
A WhileStmt record.
@ EXPR_STMT
A StmtExpr record.
@ EXPR_CXX_REINTERPRET_CAST
A CXXReinterpretCastExpr record.
@ EXPR_DESIGNATED_INIT_UPDATE
A DesignatedInitUpdateExpr record.
@ STMT_OBJC_AT_SYNCHRONIZED
An ObjCAtSynchronizedStmt record.
@ EXPR_CXX_PSEUDO_DESTRUCTOR
@ EXPR_CHARACTER_LITERAL
A CharacterLiteral record.
@ EXPR_OBJC_ENCODE
An ObjCEncodeExpr record.
@ EXPR_CSTYLE_CAST
A CStyleCastExpr record.
@ EXPR_OBJC_BOXED_EXPRESSION
@ EXPR_OBJC_BOOL_LITERAL
An ObjCBoolLiteralExpr record.
@ EXPR_CXX_BIND_TEMPORARY
@ EXPR_EXT_VECTOR_ELEMENT
An ExtVectorElementExpr record.
@ STMT_RETURN
A ReturnStmt record.
@ STMT_OBJC_FOR_COLLECTION
An ObjCForCollectionStmt record.
@ STMT_CONTINUE
A ContinueStmt record.
@ EXPR_PREDEFINED
A PredefinedExpr record.
@ EXPR_CXX_BOOL_LITERAL
A CXXBoolLiteralExpr record.
@ EXPR_PAREN_LIST
A ParenListExpr record.
@ EXPR_CXX_PAREN_LIST_INIT
A CXXParenListInitExpr record.
@ STMT_COMPOUND
A CompoundStmt record.
@ STMT_FOR
A ForStmt record.
@ STMT_ATTRIBUTED
An AttributedStmt record.
@ EXPR_CXX_REWRITTEN_BINARY_OPERATOR
A CXXRewrittenBinaryOperator record.
@ STMT_GOTO
A GotoStmt record.
@ EXPR_NO_INIT
An NoInitExpr record.
@ EXPR_OBJC_ARRAY_LITERAL
@ EXPR_OBJC_PROTOCOL_EXPR
An ObjCProtocolExpr record.
@ EXPR_CXX_CONSTRUCT
A CXXConstructExpr record.
@ EXPR_OBJC_DICTIONARY_LITERAL
@ EXPR_CXX_DYNAMIC_CAST
A CXXDynamicCastExpr record.
@ STMT_CXX_TRY
A CXXTryStmt record.
@ EXPR_GENERIC_SELECTION
A GenericSelectionExpr record.
@ EXPR_CALL
A CallExpr record.
@ EXPR_GNU_NULL
A GNUNullExpr record.
@ EXPR_BINARY_CONDITIONAL_OPERATOR
@ EXPR_OBJC_PROPERTY_REF_EXPR
An ObjCPropertyRefExpr record.
@ EXPR_CXX_CONST_CAST
A CXXConstCastExpr record.
@ STMT_REF_PTR
A reference to a previously [de]serialized Stmt record.
@ EXPR_OBJC_MESSAGE_EXPR
An ObjCMessageExpr record.
@ EXPR_CXX_DEPENDENT_SCOPE_DECL_REF
@ STMT_CASE
A CaseStmt record.
@ EXPR_FUNCTION_PARM_PACK
@ STMT_STOP
A marker record that indicates that we are at the end of an expression.
@ EXPR_CXX_NULL_PTR_LITERAL
@ STMT_MSASM
A MS-style AsmStmt record.
@ EXPR_CONDITIONAL_OPERATOR
A ConditionOperator record.
@ EXPR_BINARY_OPERATOR
A BinaryOperator record.
@ EXPR_CXX_STD_INITIALIZER_LIST
A CXXStdInitializerListExpr record.
@ EXPR_SHUFFLE_VECTOR
A ShuffleVectorExpr record.
@ STMT_OBJC_FINALLY
An ObjCAtFinallyStmt record.
@ EXPR_OBJC_SELECTOR_EXPR
An ObjCSelectorExpr record.
@ EXPR_FLOATING_LITERAL
A FloatingLiteral record.
@ EXPR_CXX_DEPENDENT_SCOPE_MEMBER
@ STMT_NULL_PTR
A NULL expression.
@ STMT_DEFAULT
A DefaultStmt record.
@ EXPR_CHOOSE
A ChooseExpr record.
@ STMT_NULL
A NullStmt record.
@ EXPR_DECL_REF
A DeclRefExpr record.
@ EXPR_SUBST_NON_TYPE_TEMPLATE_PARM
@ EXPR_INIT_LIST
An InitListExpr record.
@ EXPR_IMPLICIT_VALUE_INIT
An ImplicitValueInitExpr record.
@ EXPR_PAREN
A ParenExpr record.
@ STMT_LABEL
A LabelStmt record.
@ EXPR_CXX_FUNCTIONAL_CAST
A CXXFunctionalCastExpr record.
@ EXPR_USER_DEFINED_LITERAL
A UserDefinedLiteral record.
@ EXPR_INTEGER_LITERAL
An IntegerLiteral record.
@ EXPR_MATERIALIZE_TEMPORARY
@ EXPR_CXX_MEMBER_CALL
A CXXMemberCallExpr record.
@ STMT_SWITCH
A SwitchStmt record.
@ STMT_DECL
A DeclStmt record.
@ EXPR_CXX_UNRESOLVED_MEMBER
@ EXPR_OBJC_KVC_REF_EXPR
UNUSED.
@ EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK
@ EXPR_CXX_SCALAR_VALUE_INIT
@ EXPR_SIZEOF_ALIGN_OF
A SizefAlignOfExpr record.
@ STMT_BREAK
A BreakStmt record.
@ STMT_OBJC_AT_THROW
An ObjCAtThrowStmt record.
@ EXPR_ADDR_LABEL
An AddrLabelExpr record.
@ STMT_CXX_FOR_RANGE
A CXXForRangeStmt record.
@ EXPR_CXX_ADDRSPACE_CAST
A CXXAddrspaceCastExpr record.
@ EXPR_ARRAY_SUBSCRIPT
An ArraySubscriptExpr record.
@ EXPR_UNARY_OPERATOR
A UnaryOperator record.
@ STMT_CXX_CATCH
A CXXCatchStmt record.
@ STMT_INDIRECT_GOTO
An IndirectGotoStmt record.
Defines the clang::TargetInfo interface.
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
bool isModuleMap(CharacteristicKind CK)
Determine whether a file characteristic is for a module map.
bool LE(InterpState &S, CodePtr OpPC)
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
GlobalDeclID LazySpecializationInfo
@ EXTENSION_METADATA
Metadata describing this particular extension.
@ SUBMODULE_EXCLUDED_HEADER
Specifies a header that has been explicitly excluded from this submodule.
@ SUBMODULE_TOPHEADER
Specifies a top-level header that falls into this (sub)module.
@ SUBMODULE_PRIVATE_TEXTUAL_HEADER
Specifies a header that is private to this submodule but must be textually included.
@ SUBMODULE_HEADER
Specifies a header that falls into this (sub)module.
@ SUBMODULE_EXPORT_AS
Specifies the name of the module that will eventually re-export the entities in this module.
@ SUBMODULE_UMBRELLA_DIR
Specifies an umbrella directory.
@ SUBMODULE_UMBRELLA_HEADER
Specifies the umbrella header used to create this module, if any.
@ SUBMODULE_METADATA
Metadata for submodules as a whole.
@ 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_INITIALIZERS
Specifies some declarations with initializers that must be emitted to initialize the module.
@ 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.
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.
@ 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.
@ RELATED_DECLS_MAP
Record code for related declarations that have to be deserialized together from the same module.
@ UPDATE_VISIBLE
Record code for an update to a decl context's lookup table.
@ CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH
Number of unmatched pragma clang cuda_force_host_device begin directives we've seen.
@ MACRO_OFFSET
Record code for the table of offsets of each macro ID.
@ PPD_ENTITIES_OFFSETS
Record code for the table of offsets to entries in the preprocessing record.
@ RISCV_VECTOR_INTRINSICS_PRAGMA
Record code for pragma clang riscv intrinsic vector.
@ OPENCL_EXTENSION_DECLS
Record code for declarations associated with OpenCL extensions.
@ VTABLES_TO_EMIT
Record code for vtables to emit.
@ UPDATE_MODULE_LOCAL_VISIBLE
@ IDENTIFIER_OFFSET
Record code for the table of offsets of each identifier ID.
@ OBJC_CATEGORIES
Record code for the array of Objective-C categories (including extensions).
@ METHOD_POOL
Record code for the Objective-C method pool,.
@ DELAYED_NAMESPACE_LEXICAL_VISIBLE_RECORD
Record code for lexical and visible block for delayed namespace in reduced BMI.
@ PP_CONDITIONAL_STACK
The stack of open ifs/ifdefs recorded in a preamble.
@ REFERENCED_SELECTOR_POOL
Record code for referenced selector pool.
@ SOURCE_LOCATION_OFFSETS
Record code for the table of offsets into the block of source-location information.
@ WEAK_UNDECLARED_IDENTIFIERS
Record code for weak undeclared identifiers.
@ UNDEFINED_BUT_USED
Record code for undefined but used functions and variables that need a definition in this TU.
@ FILE_SORTED_DECLS
Record code for a file sorted array of DeclIDs in a module.
@ MSSTRUCT_PRAGMA_OPTIONS
Record code for #pragma ms_struct options.
@ TENTATIVE_DEFINITIONS
Record code for the array of tentative definitions.
@ UPDATE_TU_LOCAL_VISIBLE
@ UNUSED_FILESCOPED_DECLS
Record code for the array of unused file scoped decls.
@ ALIGN_PACK_PRAGMA_OPTIONS
Record code for #pragma align/pack options.
@ IMPORTED_MODULES
Record code for an array of all of the (sub)modules that were imported by the AST file.
@ SELECTOR_OFFSETS
Record code for the table of offsets into the Objective-C method pool.
@ UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES
Record code for potentially unused local typedef names.
@ OPENCL_EXTENSION_TYPES
Record code for types associated with OpenCL extensions.
@ EAGERLY_DESERIALIZED_DECLS
Record code for the array of eagerly deserialized decls.
@ INTERESTING_IDENTIFIERS
A list of "interesting" identifiers.
@ HEADER_SEARCH_TABLE
Record code for header search information.
@ OBJC_CATEGORIES_MAP
Record code for map of Objective-C class definition IDs to the ObjC categories in a module that are a...
@ METADATA_OLD_FORMAT
This is so that older clang versions, before the introduction of the control block,...
@ CUDA_SPECIAL_DECL_REFS
Record code for special CUDA declarations.
@ TU_UPDATE_LEXICAL
Record code for an update to the TU's lexically contained declarations.
@ PPD_SKIPPED_RANGES
A table of skipped ranges within the preprocessing record.
@ IDENTIFIER_TABLE
Record code for the identifier table.
@ SEMA_DECL_REFS
Record code for declarations that Sema keeps references of.
@ OPTIMIZE_PRAGMA_OPTIONS
Record code for #pragma optimize options.
@ MODULE_OFFSET_MAP
Record code for the remapping information used to relate loaded modules to the various offsets and ID...
@ POINTERS_TO_MEMBERS_PRAGMA_OPTIONS
Record code for #pragma ms_struct options.
unsigned ComputeHash(Selector Sel)
uint64_t IdentifierID
An ID number that refers to an identifier in an AST file.
The JSON file list parser is used to communicate input to InstallAPI.
@ NUM_OVERLOADED_OPERATORS
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
CustomizableOptional< FileEntryRef > OptionalFileEntryRef
@ 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.
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...
PredefinedDeclIDs
Predefined declaration IDs.
@ PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID
The internal '__NSConstantString' tag type.
@ PREDEF_DECL_TRANSLATION_UNIT_ID
The translation unit.
@ PREDEF_DECL_OBJC_CLASS_ID
The Objective-C 'Class' type.
@ PREDEF_DECL_BUILTIN_MS_GUID_ID
The predeclared '_GUID' struct.
@ PREDEF_DECL_BUILTIN_MS_TYPE_INFO_TAG_ID
The predeclared 'type_info' struct.
@ PREDEF_DECL_OBJC_INSTANCETYPE_ID
The internal 'instancetype' typedef.
@ PREDEF_DECL_OBJC_PROTOCOL_ID
The Objective-C 'Protocol' type.
@ PREDEF_DECL_UNSIGNED_INT_128_ID
The unsigned 128-bit integer type.
@ PREDEF_DECL_OBJC_SEL_ID
The Objective-C 'SEL' type.
@ PREDEF_DECL_INT_128_ID
The signed 128-bit integer type.
@ PREDEF_DECL_VA_LIST_TAG
The internal '__va_list_tag' struct, if any.
@ PREDEF_DECL_BUILTIN_MS_VA_LIST_ID
The internal '__builtin_ms_va_list' typedef.
@ PREDEF_DECL_CF_CONSTANT_STRING_ID
The internal '__NSConstantString' typedef.
@ PREDEF_DECL_BUILTIN_VA_LIST_ID
The internal '__builtin_va_list' typedef.
@ PREDEF_DECL_EXTERN_C_CONTEXT_ID
The extern "C" context.
@ PREDEF_DECL_OBJC_ID_ID
The Objective-C 'id' type.
@ Property
The type of a property.
@ Result
The result type of a method or function.
const FunctionProtoType * T
void normalizeModuleCachePath(FileManager &FileMgr, StringRef Path, SmallVectorImpl< char > &NormalizedPath)
@ 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...
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
Data for list of allocators.
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