81#include "llvm/ADT/APFloat.h"
82#include "llvm/ADT/APInt.h"
83#include "llvm/ADT/APSInt.h"
84#include "llvm/ADT/ArrayRef.h"
85#include "llvm/ADT/DenseMap.h"
86#include "llvm/ADT/DenseSet.h"
87#include "llvm/ADT/Hashing.h"
88#include "llvm/ADT/PointerIntPair.h"
89#include "llvm/ADT/STLExtras.h"
90#include "llvm/ADT/ScopeExit.h"
91#include "llvm/ADT/SmallPtrSet.h"
92#include "llvm/ADT/SmallString.h"
93#include "llvm/ADT/SmallVector.h"
94#include "llvm/ADT/StringMap.h"
95#include "llvm/ADT/StringRef.h"
96#include "llvm/Bitstream/BitCodes.h"
97#include "llvm/Bitstream/BitstreamWriter.h"
98#include "llvm/Support/Casting.h"
99#include "llvm/Support/Compression.h"
100#include "llvm/Support/DJB.h"
101#include "llvm/Support/Endian.h"
102#include "llvm/Support/EndianStream.h"
103#include "llvm/Support/Error.h"
104#include "llvm/Support/ErrorHandling.h"
105#include "llvm/Support/LEB128.h"
106#include "llvm/Support/MemoryBuffer.h"
107#include "llvm/Support/OnDiskHashTable.h"
108#include "llvm/Support/Path.h"
109#include "llvm/Support/SHA1.h"
110#include "llvm/Support/TimeProfiler.h"
111#include "llvm/Support/VersionTuple.h"
112#include "llvm/Support/raw_ostream.h"
127using namespace clang;
130template <
typename T,
typename Allocator>
131static StringRef
bytes(
const std::vector<T, Allocator> &
v) {
132 if (
v.empty())
return StringRef();
133 return StringRef(
reinterpret_cast<const char*
>(&
v[0]),
134 sizeof(
T) *
v.size());
139 return StringRef(
reinterpret_cast<const char*
>(
v.data()),
140 sizeof(
T) *
v.size());
143static std::string
bytes(
const std::vector<bool> &
V) {
145 Str.reserve(
V.size() / 8);
146 for (
unsigned I = 0,
E =
V.size(); I <
E;) {
148 for (
unsigned Bit = 0; Bit < 8 && I <
E; ++Bit, ++I)
161#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
162 case Type::CLASS_ID: return TYPE_##CODE_ID;
163#include "clang/Serialization/TypeBitCodes.def"
165 llvm_unreachable(
"shouldn't be serializing a builtin type this way");
167 llvm_unreachable(
"bad type kind");
172struct AffectingModuleMaps {
173 llvm::DenseSet<FileID> DefinitionFileIDs;
174 llvm::DenseSet<const FileEntry *> DefinitionFiles;
177std::optional<AffectingModuleMaps>
190 enum AffectedReason :
bool {
191 AR_TextualHeader = 0,
192 AR_ImportOrTextualHeader = 1,
194 auto AssignMostImportant = [](AffectedReason &LHS, AffectedReason RHS) {
195 LHS = std::max(LHS, RHS);
197 llvm::DenseMap<FileID, AffectedReason> ModuleMaps;
198 llvm::DenseMap<const Module *, AffectedReason> ProcessedModules;
199 auto CollectModuleMapsForHierarchy = [&](
const Module *M,
200 AffectedReason Reason) {
206 if (
auto [It, Inserted] = ProcessedModules.insert({M, Reason});
207 !Inserted && Reason <= It->second) {
213 std::queue<const Module *> Q;
216 const Module *Mod = Q.front();
222 AssignMostImportant(ModuleMaps[F], Reason);
227 AssignMostImportant(ModuleMaps[UniqF], Reason);
236 CollectModuleMapsForHierarchy(RootModule, AR_ImportOrTextualHeader);
238 std::queue<const Module *> Q;
241 const Module *CurrentModule = Q.front();
245 CollectModuleMapsForHierarchy(ImportedModule, AR_ImportOrTextualHeader);
247 CollectModuleMapsForHierarchy(UndeclaredModule, AR_ImportOrTextualHeader);
261 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
275 if (
const Module *M = KH.getModule())
276 CollectModuleMapsForHierarchy(M, AR_TextualHeader);
297 llvm::DenseSet<const FileEntry *> ModuleFileEntries;
298 llvm::DenseSet<FileID> ModuleFileIDs;
299 for (
auto [FID, Reason] : ModuleMaps) {
300 if (Reason == AR_ImportOrTextualHeader)
301 ModuleFileIDs.insert(FID);
302 if (
auto *FE =
SM.getFileEntryForID(FID))
303 ModuleFileEntries.insert(FE);
306 AffectingModuleMaps R;
307 R.DefinitionFileIDs = std::move(ModuleFileIDs);
308 R.DefinitionFiles = std::move(ModuleFileEntries);
319 : Writer(Writer), BasicWriter(Context, Writer,
Record) {}
322 if (
T.hasLocalNonFastQualifiers()) {
329 const Type *typePtr =
T.getTypePtr();
352#define ABSTRACT_TYPELOC(CLASS, PARENT)
353#define TYPELOC(CLASS, PARENT) \
354 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
355#include "clang/AST/TypeLocNodes.def"
423 VisitArrayTypeLoc(TL);
427 VisitArrayTypeLoc(TL);
431 VisitArrayTypeLoc(TL);
434void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
436 VisitArrayTypeLoc(TL);
439void TypeLocWriter::VisitDependentAddressSpaceTypeLoc(
443 addSourceLocation(
range.getBegin());
444 addSourceLocation(
range.getEnd());
448void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
457void TypeLocWriter::VisitDependentVectorTypeLoc(
469 addSourceLocation(
range.getBegin());
470 addSourceLocation(
range.getEnd());
475void TypeLocWriter::VisitDependentSizedMatrixTypeLoc(
479 addSourceLocation(
range.getBegin());
480 addSourceLocation(
range.getEnd());
491 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i)
496 VisitFunctionTypeLoc(TL);
500 VisitFunctionTypeLoc(TL);
565void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
570 Record.AddConceptReference(CR);
576void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
585void TypeLocWriter::VisitEnumTypeLoc(
EnumTypeLoc TL) {
601void TypeLocWriter::VisitHLSLAttributedResourceTypeLoc(
610void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
615void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
620void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
626 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
655void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
699void TypeLocWriter::VisitPipeTypeLoc(
PipeTypeLoc TL) {
706void TypeLocWriter::VisitDependentBitIntTypeLoc(
711void ASTWriter::WriteTypeAbbrevs() {
712 using namespace llvm;
714 std::shared_ptr<BitCodeAbbrev> Abv;
717 Abv = std::make_shared<BitCodeAbbrev>();
719 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
720 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
721 TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
729 llvm::BitstreamWriter &Stream,
733 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID,
Record);
736 if (!Name || Name[0] == 0)
740 Record.push_back(*Name++);
741 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME,
Record);
745 llvm::BitstreamWriter &Stream,
750 Record.push_back(*Name++);
751 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME,
Record);
756#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
888void ASTWriter::WriteBlockInfoBlock() {
890 Stream.EnterBlockInfoBlock();
892#define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
893#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
896 BLOCK(CONTROL_BLOCK);
906 BLOCK(OPTIONS_BLOCK);
913 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);
1044 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM);
1045 RECORD(TYPE_UNRESOLVED_USING);
1046 RECORD(TYPE_INJECTED_CLASS_NAME);
1047 RECORD(TYPE_OBJC_OBJECT);
1048 RECORD(TYPE_TEMPLATE_TYPE_PARM);
1049 RECORD(TYPE_TEMPLATE_SPECIALIZATION);
1050 RECORD(TYPE_DEPENDENT_NAME);
1051 RECORD(TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION);
1052 RECORD(TYPE_DEPENDENT_SIZED_ARRAY);
1054 RECORD(TYPE_MACRO_QUALIFIED);
1055 RECORD(TYPE_PACK_EXPANSION);
1057 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK);
1059 RECORD(TYPE_UNARY_TRANSFORM);
1063 RECORD(TYPE_OBJC_TYPE_PARAM);
1142 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
1148 BLOCK(EXTENSION_BLOCK);
1151 BLOCK(UNHASHED_CONTROL_BLOCK);
1172 return Changed | llvm::sys::path::remove_dots(
Path);
1187 assert(
Filename &&
"No file name to adjust?");
1189 if (BaseDir.empty())
1194 for (;
Filename[Pos] && Pos < BaseDir.size(); ++Pos)
1204 if (!llvm::sys::path::is_separator(
Filename[Pos])) {
1205 if (!llvm::sys::path::is_separator(BaseDir.back()))
1222std::pair<ASTFileSignature, ASTFileSignature>
1223ASTWriter::createSignature()
const {
1224 StringRef AllBytes(Buffer.data(), Buffer.size());
1227 Hasher.update(AllBytes.slice(ASTBlockRange.first, ASTBlockRange.second));
1232 Hasher.update(AllBytes.slice(0, UnhashedControlBlockRange.first));
1235 AllBytes.slice(UnhashedControlBlockRange.second, ASTBlockRange.first));
1237 Hasher.update(AllBytes.slice(ASTBlockRange.second, StringRef::npos));
1240 return std::make_pair(ASTBlockHash, Signature);
1245 Hasher.update(StringRef(Buffer.data(), Buffer.size()));
1247 assert(WritingModule);
1252 for (
auto [ExportImported, _] : WritingModule->
Exports)
1253 Hasher.update(ExportImported->Signature);
1277 for (
Module *M : TouchedTopLevelModules)
1285 for (uint8_t Byte : S) {
1286 Stream.BackpatchByte(BitNo, Byte);
1298 if (!WritingModule ||
1305 std::tie(ASTBlockHash, Signature) = createSignature();
1313void ASTWriter::writeUnhashedControlBlock(
Preprocessor &PP) {
1314 using namespace llvm;
1317 Stream.FlushToWord();
1318 UnhashedControlBlockRange.first = Stream.GetCurrentBitNo() >> 3;
1341 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1343 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1344 unsigned ASTBlockHashAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1347 Stream.EmitRecordWithBlob(ASTBlockHashAbbrev,
Record, Blob);
1348 ASTBlockHashOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1352 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1353 Abbrev->Add(BitCodeAbbrevOp(
SIGNATURE));
1354 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1355 unsigned SignatureAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1358 Stream.EmitRecordWithBlob(SignatureAbbrev,
Record, Blob);
1359 SignatureOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1368 if (!HSOpts.ModulesSkipDiagnosticOptions) {
1369#define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name);
1370#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
1371 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name()));
1372#include "clang/Basic/DiagnosticOptions.def"
1374 for (
unsigned I = 0, N = DiagOpts.
Warnings.size(); I != N; ++I)
1377 for (
unsigned I = 0, N = DiagOpts.
Remarks.size(); I != N; ++I)
1386 if (!HSOpts.ModulesSkipHeaderSearchPaths) {
1388 Record.push_back(HSOpts.UserEntries.size());
1389 for (
unsigned I = 0, N = HSOpts.UserEntries.size(); I != N; ++I) {
1392 Record.push_back(
static_cast<unsigned>(Entry.
Group));
1398 Record.push_back(HSOpts.SystemHeaderPrefixes.size());
1399 for (
unsigned I = 0, N = HSOpts.SystemHeaderPrefixes.size(); I != N; ++I) {
1401 Record.push_back(HSOpts.SystemHeaderPrefixes[I].IsSystemHeader);
1405 Record.push_back(HSOpts.VFSOverlayFiles.size());
1406 for (StringRef VFSOverlayFile : HSOpts.VFSOverlayFiles)
1412 if (!HSOpts.ModulesSkipPragmaDiagnosticMappings)
1413 WritePragmaDiagnosticMappings(Diags, WritingModule);
1418 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1420 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1421 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1422 unsigned HSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1424 HSEntryUsage.size()};
1425 Stream.EmitRecordWithBlob(HSUsageAbbrevCode,
Record,
bytes(HSEntryUsage));
1431 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1432 Abbrev->Add(BitCodeAbbrevOp(
VFS_USAGE));
1433 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1434 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1435 unsigned VFSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1437 Stream.EmitRecordWithBlob(VFSUsageAbbrevCode,
Record,
bytes(VFSUsage));
1442 UnhashedControlBlockRange.second = Stream.GetCurrentBitNo() >> 3;
1446void ASTWriter::WriteControlBlock(
Preprocessor &PP, StringRef isysroot) {
1447 using namespace llvm;
1456 auto MetadataAbbrev = std::make_shared<BitCodeAbbrev>();
1457 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1458 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
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, 1));
1464 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::Blob));
1468 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev));
1469 assert((!WritingModule || isysroot.empty()) &&
1470 "writing module as a relocatable PCH?");
1475 CLANG_VERSION_MAJOR,
1476 CLANG_VERSION_MINOR,
1480 ASTHasCompilerErrors};
1481 Stream.EmitRecordWithBlob(MetadataAbbrevCode,
Record,
1485 if (WritingModule) {
1487 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1489 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1490 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1492 Stream.EmitRecordWithBlob(AbbrevCode,
Record, WritingModule->
Name);
1495 if (WritingModule && WritingModule->
Directory) {
1500 BaseDir.assign(CWD->getName());
1515 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1517 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1518 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1521 Stream.EmitRecordWithBlob(AbbrevCode,
Record, BaseDir);
1525 BaseDirectory.assign(BaseDir.begin(), BaseDir.end());
1526 }
else if (!isysroot.empty()) {
1528 BaseDirectory = std::string(isysroot);
1537 ? Map.getModuleMapFileForUniquing(WritingModule)
1538 ->getNameAsRequested()
1543 if (
auto *AdditionalModMaps =
1544 Map.getAdditionalModuleMapFiles(WritingModule)) {
1545 Record.push_back(AdditionalModMaps->size());
1547 AdditionalModMaps->end());
1562 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1563 Abbrev->Add(BitCodeAbbrevOp(
IMPORT));
1564 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1565 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1566 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1567 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1568 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1569 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1570 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1571 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1572 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1578 if (!M.isDirectlyImported())
1588 Record.push_back(M.StandardCXXModule);
1592 if (M.StandardCXXModule) {
1607 Stream.EmitRecordWithBlob(AbbrevCode,
Record, Blob);
1617#define LANGOPT(Name, Bits, Default, Description) \
1618 Record.push_back(LangOpts.Name);
1619#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
1620 Record.push_back(static_cast<unsigned>(LangOpts.get##Name()));
1621#include "clang/Basic/LangOptions.def"
1622#define SANITIZER(NAME, ID) \
1623 Record.push_back(LangOpts.Sanitize.has(SanitizerKind::ID));
1624#include "clang/Basic/Sanitizers.def"
1664 for (
unsigned I = 0, N = TargetOpts.
Features.size(); I != N; ++I) {
1704 bool WriteMacros = !SkipMacros;
1705 Record.push_back(WriteMacros);
1709 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
1717 for (
unsigned I = 0, N = PPOpts.
Includes.size(); I != N; ++I)
1722 for (
unsigned I = 0, N = PPOpts.
MacroIncludes.size(); I != N; ++I)
1738 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1740 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1741 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1742 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
1761struct InputFileEntry {
1765 bool BufferOverridden;
1780 assert(IncludeFID.
isValid() &&
"IncludeLoc in invalid file");
1781 if (!IsSLocAffecting[IncludeFID.ID])
1789 using namespace llvm;
1794 auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
1796 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1797 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1798 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1799 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1800 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1801 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1802 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1803 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
1804 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1805 unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
1808 auto IFHAbbrev = std::make_shared<BitCodeAbbrev>();
1810 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1811 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1812 unsigned IFHAbbrevCode = Stream.EmitAbbrev(std::move(IFHAbbrev));
1814 uint64_t InputFilesOffsetBase = Stream.GetCurrentBitNo();
1817 std::vector<InputFileEntry> UserFiles;
1818 std::vector<InputFileEntry> SystemFiles;
1822 assert(&SourceMgr.
getSLocEntry(FileID::get(I)) == SLoc);
1829 if (!
Cache->OrigEntry)
1833 if (!IsSLocFileEntryAffecting[I])
1836 InputFileEntry Entry(*
Cache->OrigEntry);
1837 Entry.IsSystemFile =
isSystem(
File.getFileCharacteristic());
1838 Entry.IsTransient =
Cache->IsTransient;
1839 Entry.BufferOverridden =
Cache->BufferOverridden;
1842 Entry.IsTopLevel = IncludeFileID.
isInvalid() || IncludeFileID.ID < 0 ||
1843 !IsSLocFileEntryAffecting[IncludeFileID.ID];
1850 auto MemBuff =
Cache->getBufferIfLoaded();
1852 ContentHash = xxh3_64bits(MemBuff->getBuffer());
1855 << Entry.File.getName();
1857 Entry.ContentHash[0] =
uint32_t(ContentHash);
1858 Entry.ContentHash[1] =
uint32_t(ContentHash >> 32);
1859 if (Entry.IsSystemFile)
1860 SystemFiles.push_back(Entry);
1862 UserFiles.push_back(Entry);
1866 auto SortedFiles = llvm::concat<InputFileEntry>(std::move(UserFiles),
1867 std::move(SystemFiles));
1869 unsigned UserFilesNum = 0;
1871 std::vector<uint64_t> InputFileOffsets;
1872 for (
const auto &Entry : SortedFiles) {
1873 uint32_t &InputFileID = InputFileIDs[Entry.File];
1874 if (InputFileID != 0)
1878 InputFileOffsets.push_back(Stream.GetCurrentBitNo() - InputFilesOffsetBase);
1880 InputFileID = InputFileOffsets.size();
1882 if (!Entry.IsSystemFile)
1894 if (Name == NameAsRequested)
1897 RecordData::value_type
Record[] = {
1899 InputFileOffsets.size(),
1902 Entry.BufferOverridden,
1906 NameAsRequested.size()};
1908 Stream.EmitRecordWithBlob(IFAbbrevCode,
Record,
1909 (NameAsRequested + Name).str());
1915 Entry.ContentHash[1]};
1916 Stream.EmitRecordWithAbbrev(IFHAbbrevCode,
Record);
1923 auto OffsetsAbbrev = std::make_shared<BitCodeAbbrev>();
1925 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1926 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1928 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1929 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(std::move(OffsetsAbbrev));
1933 InputFileOffsets.size(), UserFilesNum};
1934 Stream.EmitRecordWithBlob(OffsetsAbbrevCode,
Record,
bytes(InputFileOffsets));
1944 using namespace llvm;
1946 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1948 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1949 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1950 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1951 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1953 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1954 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1955 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
1956 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1957 return Stream.EmitAbbrev(std::move(Abbrev));
1963 using namespace llvm;
1965 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1967 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1968 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1969 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1970 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1971 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1972 return Stream.EmitAbbrev(std::move(Abbrev));
1979 using namespace llvm;
1981 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1985 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1986 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1987 return Stream.EmitAbbrev(std::move(Abbrev));
1993 using namespace llvm;
1995 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1997 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1998 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1999 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2000 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2001 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2002 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2003 return Stream.EmitAbbrev(std::move(Abbrev));
2008static std::pair<unsigned, unsigned>
2010 llvm::encodeULEB128(KeyLen, Out);
2011 llvm::encodeULEB128(DataLen, Out);
2012 return std::make_pair(KeyLen, DataLen);
2018 class HeaderFileInfoTrait {
2022 HeaderFileInfoTrait(
ASTWriter &Writer) : Writer(Writer) {}
2029 using key_type_ref =
const key_type &;
2031 using UnresolvedModule =
2032 llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
2038 : HFI(HFI), AlreadyIncluded(AlreadyIncluded),
2042 bool AlreadyIncluded;
2046 using data_type_ref =
const data_type &;
2055 uint8_t buf[
sizeof(key.Size) +
sizeof(key.ModTime)];
2056 memcpy(buf, &key.Size,
sizeof(key.Size));
2057 memcpy(buf +
sizeof(key.Size), &key.ModTime,
sizeof(key.ModTime));
2058 return llvm::xxh3_64bits(buf);
2061 std::pair<unsigned, unsigned>
2062 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref
Data) {
2063 unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
2065 for (
auto ModInfo :
Data.KnownHeaders)
2068 if (
Data.Unresolved.getPointer())
2073 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
2074 using namespace llvm::support;
2076 endian::Writer
LE(Out, llvm::endianness::little);
2081 Out.write(key.Filename.data(), KeyLen);
2084 void EmitData(raw_ostream &Out, key_type_ref key,
2085 data_type_ref
Data,
unsigned DataLen) {
2086 using namespace llvm::support;
2088 endian::Writer
LE(Out, llvm::endianness::little);
2089 uint64_t Start = Out.tell(); (void)Start;
2091 unsigned char Flags = (
Data.AlreadyIncluded << 6)
2092 | (
Data.HFI.isImport << 5)
2094 Data.HFI.isPragmaOnce << 4)
2095 | (
Data.HFI.DirInfo << 1);
2096 LE.write<uint8_t>(Flags);
2098 if (
Data.HFI.LazyControllingMacro.isID())
2107 assert((
Value >> 3) == ModID &&
"overflow in header module info");
2112 for (
auto ModInfo :
Data.KnownHeaders)
2113 EmitModule(ModInfo.getModule(), ModInfo.getRole());
2114 if (
Data.Unresolved.getPointer())
2115 EmitModule(
Data.Unresolved.getPointer(),
Data.Unresolved.getInt());
2117 assert(Out.tell() - Start == DataLen &&
"Wrong data length");
2126void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
2127 HeaderFileInfoTrait GeneratorTrait(*
this);
2128 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait>
Generator;
2130 unsigned NumHeaderSearchEntries = 0;
2137 if (WritingModule) {
2139 while (!Worklist.empty()) {
2140 Module *M = Worklist.pop_back_val();
2157 if (!
U.Size || (!
U.ModTime && IncludeTimestamps)) {
2158 PP->
Diag(
U.FileNameLoc, diag::err_module_no_size_mtime_for_header)
2166 llvm::sys::path::append(
Filename,
U.FileName);
2169 StringRef FilenameDup = strdup(
Filename.c_str());
2170 SavedStrings.push_back(FilenameDup.data());
2172 HeaderFileInfoTrait::key_type Key = {
2173 FilenameDup, *
U.Size, IncludeTimestamps ? *
U.ModTime : 0};
2174 HeaderFileInfoTrait::data_type
Data = {
2179 ++NumHeaderSearchEntries;
2182 Worklist.append(SubmodulesRange.begin(), SubmodulesRange.end());
2192 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
2211 Filename = StringRef(strdup(FilenameTmp.c_str()));
2212 SavedStrings.push_back(
Filename.data());
2217 HeaderFileInfoTrait::key_type Key = {
2220 HeaderFileInfoTrait::data_type
Data = {
2224 ++NumHeaderSearchEntries;
2231 using namespace llvm::support;
2233 llvm::raw_svector_ostream Out(TableData);
2235 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
2236 BucketOffset =
Generator.Emit(Out, GeneratorTrait);
2240 using namespace llvm;
2242 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2244 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2245 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2246 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2247 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2248 unsigned TableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2252 NumHeaderSearchEntries, TableData.size()};
2253 Stream.EmitRecordWithBlob(TableAbbrev,
Record, TableData);
2256 for (
unsigned I = 0, N = SavedStrings.size(); I != N; ++I)
2257 free(
const_cast<char *
>(SavedStrings[I]));
2260static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
2261 unsigned SLocBufferBlobCompressedAbbrv,
2262 unsigned SLocBufferBlobAbbrv) {
2263 using RecordDataType = ASTWriter::RecordData::value_type;
2268 if (llvm::compression::zstd::isAvailable()) {
2269 llvm::compression::zstd::compress(
2270 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer, 9);
2272 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2273 llvm::toStringRef(CompressedBuffer));
2276 if (llvm::compression::zlib::isAvailable()) {
2277 llvm::compression::zlib::compress(
2278 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer);
2280 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2281 llvm::toStringRef(CompressedBuffer));
2286 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv,
Record, Blob);
2297void ASTWriter::WriteSourceManagerBlock(
SourceManager &SourceMgr) {
2302 const uint64_t SourceManagerBlockOffset = Stream.GetCurrentBitNo();
2308 unsigned SLocBufferBlobCompressedAbbrv =
2314 std::vector<uint32_t> SLocEntryOffsets;
2315 uint64_t SLocEntryOffsetsBase = Stream.GetCurrentBitNo();
2321 FileID FID = FileID::get(I);
2325 uint64_t Offset = Stream.GetCurrentBitNo() - SLocEntryOffsetsBase;
2326 assert((Offset >> 32) == 0 &&
"SLocEntry offset too large");
2332 if (
Cache->OrigEntry) {
2345 if (!IsSLocAffecting[I])
2347 SLocEntryOffsets.push_back(Offset);
2351 Record.push_back(
File.getFileCharacteristic());
2354 bool EmitBlob =
false;
2357 "Writing to AST an overridden file is not supported");
2360 assert(InputFileIDs[*Content->
OrigEntry] != 0 &&
"Missed file entry");
2363 Record.push_back(getAdjustedNumCreatedFIDs(FID));
2365 FileDeclIDsTy::iterator FDI = FileDeclIDs.find(FID);
2366 if (FDI != FileDeclIDs.end()) {
2367 Record.push_back(FDI->second->FirstDeclIndex);
2368 Record.push_back(FDI->second->DeclIDs.size());
2374 Stream.EmitRecordWithAbbrev(SLocFileAbbrv,
Record);
2385 std::optional<llvm::MemoryBufferRef> Buffer = Content->
getBufferOrNone(
2387 StringRef Name = Buffer ? Buffer->getBufferIdentifier() :
"";
2388 Stream.EmitRecordWithBlob(SLocBufferAbbrv,
Record,
2389 StringRef(Name.data(), Name.size() + 1));
2396 std::optional<llvm::MemoryBufferRef> Buffer = Content->
getBufferOrNone(
2399 Buffer = llvm::MemoryBufferRef(
"<<<INVALID BUFFER>>>",
"");
2400 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
2401 emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv,
2402 SLocBufferBlobAbbrv);
2407 SLocEntryOffsets.push_back(Offset);
2423 Record.push_back(getAdjustedOffset(NextOffset - SLoc->
getOffset()) - 1);
2424 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv,
Record);
2430 if (SLocEntryOffsets.empty())
2435 using namespace llvm;
2437 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2439 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2440 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2441 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2442 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2443 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2445 RecordData::value_type
Record[] = {
2448 SLocEntryOffsetsBase - SourceManagerBlockOffset};
2449 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev,
Record,
2450 bytes(SLocEntryOffsets));
2461 llvm::DenseMap<int, int> FilenameMap;
2462 FilenameMap[-1] = -1;
2463 for (
const auto &L : LineTable) {
2466 for (
auto &LE : L.second) {
2467 if (FilenameMap.insert(std::make_pair(
LE.FilenameID,
2468 FilenameMap.size() - 1)).second)
2475 for (
const auto &L : LineTable) {
2483 Record.push_back(L.second.size());
2484 for (
const auto &LE : L.second) {
2487 Record.push_back(FilenameMap[
LE.FilenameID]);
2488 Record.push_back((
unsigned)
LE.FileKind);
2489 Record.push_back(
LE.IncludeOffset);
2504 if (MI->isBuiltinMacro())
2520void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2521 uint64_t MacroOffsetsBase = Stream.GetCurrentBitNo();
2525 WritePreprocessorDetail(*PPRec, MacroOffsetsBase);
2540 if (AssumeNonNullLoc.
isValid()) {
2554 Record.push_back(SkipInfo->FoundNonSkipPortion);
2555 Record.push_back(SkipInfo->FoundElse);
2562 Record.push_back(Cond.WasSkipping);
2563 Record.push_back(Cond.FoundNonSkip);
2564 Record.push_back(Cond.FoundElse);
2594 if (
Id.second->hadMacroDefinition() &&
2595 (!
Id.second->isFromAST() ||
2596 Id.second->hasChangedSinceDeserialization()))
2597 MacroIdentifiers.push_back(
Id.second);
2600 llvm::sort(MacroIdentifiers, llvm::deref<std::less<>>());
2606 uint64_t StartOffset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2607 assert((StartOffset >> 32) == 0 &&
"Macro identifiers offset too large");
2610 bool EmittedModuleMacros =
false;
2627 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2629 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2630 Record.push_back(VisMD->isPublic());
2632 ModuleMacroRecord.push_back(getSubmoduleID(WritingModule));
2635 ModuleMacroRecord.clear();
2636 EmittedModuleMacros =
true;
2646 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2648 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2649 Record.push_back(VisMD->isPublic());
2656 llvm::DenseMap<ModuleMacro *, unsigned> Visits;
2657 while (!Worklist.empty()) {
2658 auto *
Macro = Worklist.pop_back_val();
2661 ModuleMacroRecord.push_back(getSubmoduleID(
Macro->getOwningModule()));
2663 for (
auto *M :
Macro->overrides())
2664 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2667 ModuleMacroRecord.clear();
2670 for (
auto *M :
Macro->overrides())
2671 if (++Visits[M] == M->getNumOverridingMacros())
2672 Worklist.push_back(M);
2674 EmittedModuleMacros =
true;
2677 if (
Record.empty() && !EmittedModuleMacros)
2680 IdentMacroDirectivesOffsetMap[Name] = StartOffset;
2691 std::vector<uint32_t> MacroOffsets;
2693 for (
unsigned I = 0, N = MacroInfosToEmit.size(); I != N; ++I) {
2698 if (ID < FirstMacroID) {
2699 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2704 unsigned Index =
ID - FirstMacroID;
2705 if (Index >= MacroOffsets.size())
2706 MacroOffsets.resize(Index + 1);
2708 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2709 assert((Offset >> 32) == 0 &&
"Macro offset too large");
2710 MacroOffsets[Index] = Offset;
2737 Stream.EmitRecord(Code,
Record);
2741 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2756 using namespace llvm;
2758 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2760 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2761 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2762 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2763 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2765 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2769 MacroOffsetsBase - ASTBlockStartOffset};
2770 Stream.EmitRecordWithBlob(MacroOffsetAbbrev,
Record,
bytes(MacroOffsets));
2775 uint64_t MacroOffsetsBase) {
2785 unsigned NumPreprocessingRecords = 0;
2786 using namespace llvm;
2789 unsigned InclusionAbbrev = 0;
2791 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2793 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2794 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2795 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2796 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2797 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2798 InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2801 unsigned FirstPreprocessorEntityID
2802 = (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0)
2804 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2809 (void)++
E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2812 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2813 assert((Offset >> 32) == 0 &&
"Preprocessed entity offset too large");
2814 SourceRange R = getAdjustedRange((*E)->getSourceRange());
2815 PreprocessedEntityOffsets.emplace_back(
2819 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*
E)) {
2821 MacroDefinitions[MD] = NextPreprocessorEntityID;
2828 if (
auto *ME = dyn_cast<MacroExpansion>(*
E)) {
2829 Record.push_back(ME->isBuiltinMacro());
2830 if (ME->isBuiltinMacro())
2833 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2838 if (
auto *ID = dyn_cast<InclusionDirective>(*
E)) {
2840 Record.push_back(
ID->getFileName().size());
2841 Record.push_back(
ID->wasInQuotes());
2842 Record.push_back(
static_cast<unsigned>(
ID->getKind()));
2843 Record.push_back(
ID->importedModule());
2845 Buffer +=
ID->getFileName();
2849 Buffer +=
ID->getFile()->getName();
2850 Stream.EmitRecordWithBlob(InclusionAbbrev,
Record, Buffer);
2854 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2859 if (NumPreprocessingRecords > 0) {
2860 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2863 using namespace llvm;
2865 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2867 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2868 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2869 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2872 FirstPreprocessorEntityID -
2874 Stream.EmitRecordWithBlob(PPEOffsetAbbrev,
Record,
2875 bytes(PreprocessedEntityOffsets));
2880 if (SkippedRanges.size() > 0) {
2881 std::vector<PPSkippedRange> SerializedSkippedRanges;
2882 SerializedSkippedRanges.reserve(SkippedRanges.size());
2883 for (
auto const&
Range : SkippedRanges)
2884 SerializedSkippedRanges.emplace_back(
2888 using namespace llvm;
2889 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2891 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2892 unsigned PPESkippedRangeAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2896 Stream.EmitRecordWithBlob(PPESkippedRangeAbbrev,
Record,
2897 bytes(SerializedSkippedRanges));
2905 auto Known = SubmoduleIDs.find(Mod);
2906 if (Known != SubmoduleIDs.end())
2907 return Known->second;
2910 if (Top != WritingModule &&
2912 !Top->fullModuleNameIs(StringRef(
getLangOpts().CurrentModule))))
2915 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2918unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2931 unsigned ChildModules = 0;
2935 return ChildModules + 1;
2938void ASTWriter::WriteSubmodules(
Module *WritingModule,
ASTContext *Context) {
2943 using namespace llvm;
2945 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2947 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2948 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2949 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
2950 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2951 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4));
2952 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2953 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2954 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2955 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2956 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2957 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2958 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2959 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2960 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2961 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2962 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2963 unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2965 Abbrev = std::make_shared<BitCodeAbbrev>();
2967 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2968 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2970 Abbrev = std::make_shared<BitCodeAbbrev>();
2972 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2973 unsigned HeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2975 Abbrev = std::make_shared<BitCodeAbbrev>();
2977 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2978 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2980 Abbrev = std::make_shared<BitCodeAbbrev>();
2982 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2983 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2985 Abbrev = std::make_shared<BitCodeAbbrev>();
2987 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2988 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2989 unsigned RequiresAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2991 Abbrev = std::make_shared<BitCodeAbbrev>();
2993 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2994 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2996 Abbrev = std::make_shared<BitCodeAbbrev>();
2998 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2999 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3001 Abbrev = std::make_shared<BitCodeAbbrev>();
3003 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3004 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3006 Abbrev = std::make_shared<BitCodeAbbrev>();
3008 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3009 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3011 Abbrev = std::make_shared<BitCodeAbbrev>();
3013 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
3014 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3015 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3017 Abbrev = std::make_shared<BitCodeAbbrev>();
3019 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3020 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3022 Abbrev = std::make_shared<BitCodeAbbrev>();
3024 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3025 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3026 unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3028 Abbrev = std::make_shared<BitCodeAbbrev>();
3030 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3031 unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3034 RecordData::value_type
Record[] = {
3040 std::queue<Module *> Q;
3041 Q.push(WritingModule);
3042 while (!Q.empty()) {
3045 unsigned ID = getSubmoduleID(Mod);
3049 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
3050 ParentID = SubmoduleIDs[Mod->
Parent];
3057 FileID UnadjustedInferredFID;
3060 int InferredFID = getAdjustedFileID(UnadjustedInferredFID).getOpaqueValue();
3067 (RecordData::value_type)Mod->
Kind,
3069 (RecordData::value_type)InferredFID,
3080 Stream.EmitRecordWithBlob(DefinitionAbbrev,
Record, Mod->
Name);
3086 Stream.EmitRecordWithBlob(RequiresAbbrev,
Record, R.FeatureName);
3090 if (std::optional<Module::Header> UmbrellaHeader =
3093 Stream.EmitRecordWithBlob(UmbrellaAbbrev,
Record,
3094 UmbrellaHeader->NameAsWritten);
3095 }
else if (std::optional<Module::DirectoryName> UmbrellaDir =
3098 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev,
Record,
3099 UmbrellaDir->NameAsWritten);
3104 unsigned RecordKind;
3115 for (
const auto &HL : HeaderLists) {
3116 RecordData::value_type
Record[] = {HL.RecordKind};
3117 for (
const auto &H : Mod->
getHeaders(HL.HeaderKind))
3118 Stream.EmitRecordWithBlob(HL.Abbrev,
Record, H.NameAsWritten);
3127 Stream.EmitRecordWithBlob(TopHeaderAbbrev,
Record, HeaderName);
3135 Record.push_back(getSubmoduleID(I));
3143 Record.push_back(getSubmoduleID(I));
3150 for (
const auto &
E : Mod->
Exports) {
3153 Record.push_back(getSubmoduleID(
E.getPointer()));
3169 Stream.EmitRecordWithBlob(LinkLibraryAbbrev,
Record, LL.Library);
3177 getSubmoduleID(
C.Other)};
3178 Stream.EmitRecordWithBlob(ConflictAbbrev,
Record,
C.Message);
3184 Stream.EmitRecordWithBlob(ConfigMacroAbbrev,
Record, CM);
3211 assert((NextSubmoduleID - FirstSubmoduleID ==
3213 "Wrong # of submodules; found a reference to a non-local, "
3214 "non-imported submodule?");
3219 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
3221 unsigned CurrID = 0;
3224 auto EncodeDiagStateFlags =
3225 [](
const DiagnosticsEngine::DiagState *DS) ->
unsigned {
3228 {(
unsigned)DS->IgnoreAllWarnings, (
unsigned)DS->EnableAllWarnings,
3229 (
unsigned)DS->WarningsAsErrors, (
unsigned)DS->ErrorsAsFatal,
3230 (
unsigned)DS->SuppressSystemWarnings})
3235 unsigned Flags = EncodeDiagStateFlags(
Diag.DiagStatesByLoc.FirstDiagState);
3238 auto AddDiagState = [&](
const DiagnosticsEngine::DiagState *State,
3239 bool IncludeNonPragmaStates) {
3242 assert(Flags == EncodeDiagStateFlags(State) &&
3243 "diag state flags vary in single AST file");
3247 assert(!IncludeNonPragmaStates ||
3248 State ==
Diag.DiagStatesByLoc.FirstDiagState);
3250 unsigned &DiagStateID = DiagStateIDMap[State];
3251 Record.push_back(DiagStateID);
3253 if (DiagStateID == 0) {
3254 DiagStateID = ++CurrID;
3258 auto SizeIdx =
Record.size();
3260 for (
const auto &I : *State) {
3262 if (!I.second.isPragma() && !IncludeNonPragmaStates)
3266 if (!I.second.isPragma() &&
3269 Mappings.push_back(I);
3273 llvm::sort(Mappings, llvm::less_first());
3275 for (
const auto &I : Mappings) {
3276 Record.push_back(I.first);
3277 Record.push_back(I.second.serialize());
3284 AddDiagState(
Diag.DiagStatesByLoc.FirstDiagState, isModule);
3287 auto NumLocationsIdx =
Record.size();
3291 unsigned NumLocations = 0;
3292 for (
auto &FileIDAndFile :
Diag.DiagStatesByLoc.Files) {
3293 if (!FileIDAndFile.first.isValid() ||
3294 !FileIDAndFile.second.HasLocalTransitions)
3300 Record.push_back(FileIDAndFile.second.StateTransitions.size());
3301 for (
auto &StatePoint : FileIDAndFile.second.StateTransitions) {
3302 Record.push_back(getAdjustedOffset(StatePoint.Offset));
3303 AddDiagState(StatePoint.State,
false);
3308 Record[NumLocationsIdx] = NumLocations;
3317 AddDiagState(
Diag.DiagStatesByLoc.CurDiagState,
false);
3330 IdxRef =
TypeIdx(0, NextTypeID++);
3334 assert(Idx.
getValue() >= FirstTypeID &&
"Writing predefined type");
3338 ASTTypeWriter(Context, *
this).write(
T) - DeclTypesBlockStartOffset;
3342 if (TypeOffsets.size() == Index)
3343 TypeOffsets.emplace_back(Offset);
3344 else if (TypeOffsets.size() < Index) {
3345 TypeOffsets.resize(Index + 1);
3346 TypeOffsets[Index].set(Offset);
3348 llvm_unreachable(
"Types emitted in wrong order");
3357 auto *ND = dyn_cast<NamedDecl>(
D);
3381 uint64_t Offset = Stream.GetCurrentBitNo();
3383 for (
const auto *
D : DC->
decls()) {
3396 KindDeclPairs.push_back(
D->
getKind());
3397 KindDeclPairs.push_back(
GetDeclRef(
D).getRawValue());
3400 ++NumLexicalDeclContexts;
3402 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev,
Record,
3403 bytes(KindDeclPairs));
3407void ASTWriter::WriteTypeDeclOffsets() {
3408 using namespace llvm;
3411 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3413 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3414 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3415 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3418 Stream.EmitRecordWithBlob(TypeOffsetAbbrev,
Record,
bytes(TypeOffsets));
3422 Abbrev = std::make_shared<BitCodeAbbrev>();
3424 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3425 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3426 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3429 Stream.EmitRecordWithBlob(DeclOffsetAbbrev,
Record,
bytes(DeclOffsets));
3433void ASTWriter::WriteFileDeclIDsMap() {
3434 using namespace llvm;
3437 SortedFileDeclIDs.reserve(FileDeclIDs.size());
3438 for (
const auto &
P : FileDeclIDs)
3439 SortedFileDeclIDs.push_back(std::make_pair(
P.first,
P.second.get()));
3440 llvm::sort(SortedFileDeclIDs, llvm::less_first());
3444 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
3445 DeclIDInFileInfo &Info = *FileDeclEntry.second;
3446 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
3447 llvm::stable_sort(Info.DeclIDs);
3448 for (
auto &LocDeclEntry : Info.DeclIDs)
3449 FileGroupedDeclIDs.push_back(LocDeclEntry.second.getRawValue());
3452 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3454 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3455 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3456 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
3458 FileGroupedDeclIDs.size()};
3459 Stream.EmitRecordWithBlob(AbbrevCode,
Record,
bytes(FileGroupedDeclIDs));
3462void ASTWriter::WriteComments(
ASTContext &Context) {
3464 auto _ = llvm::make_scope_exit([
this] { Stream.ExitBlock(); });
3475 for (
const auto &FO : Context.
Comments.OrderedComments) {
3476 for (
const auto &OC : FO.second) {
3495class ASTMethodPoolTrait {
3500 using key_type_ref = key_type;
3506 using data_type_ref =
const data_type &;
3511 explicit ASTMethodPoolTrait(
ASTWriter &Writer) : Writer(Writer) {}
3517 std::pair<unsigned, unsigned>
3518 EmitKeyDataLength(raw_ostream& Out,
Selector Sel,
3519 data_type_ref Methods) {
3523 unsigned DataLen = 4 + 2 + 2;
3526 if (ShouldWriteMethodListNode(Method))
3527 DataLen +=
sizeof(
DeclID);
3530 if (ShouldWriteMethodListNode(Method))
3531 DataLen +=
sizeof(
DeclID);
3535 void EmitKey(raw_ostream& Out,
Selector Sel,
unsigned) {
3536 using namespace llvm::support;
3538 endian::Writer
LE(Out, llvm::endianness::little);
3540 assert((Start >> 32) == 0 &&
"Selector key offset too large");
3543 LE.write<uint16_t>(N);
3546 for (
unsigned I = 0; I != N; ++I)
3551 void EmitData(raw_ostream& Out, key_type_ref,
3552 data_type_ref Methods,
unsigned DataLen) {
3553 using namespace llvm::support;
3555 endian::Writer
LE(Out, llvm::endianness::little);
3556 uint64_t Start = Out.tell(); (void)Start;
3558 unsigned NumInstanceMethods = 0;
3561 if (ShouldWriteMethodListNode(Method))
3562 ++NumInstanceMethods;
3564 unsigned NumFactoryMethods = 0;
3567 if (ShouldWriteMethodListNode(Method))
3568 ++NumFactoryMethods;
3570 unsigned InstanceBits = Methods.Instance.getBits();
3571 assert(InstanceBits < 4);
3572 unsigned InstanceHasMoreThanOneDeclBit =
3573 Methods.Instance.hasMoreThanOneDecl();
3574 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
3575 (InstanceHasMoreThanOneDeclBit << 2) |
3577 unsigned FactoryBits = Methods.Factory.getBits();
3578 assert(FactoryBits < 4);
3579 unsigned FactoryHasMoreThanOneDeclBit =
3580 Methods.Factory.hasMoreThanOneDecl();
3581 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
3582 (FactoryHasMoreThanOneDeclBit << 2) |
3584 LE.write<uint16_t>(FullInstanceBits);
3585 LE.write<uint16_t>(FullFactoryBits);
3588 if (ShouldWriteMethodListNode(Method))
3592 if (ShouldWriteMethodListNode(Method))
3595 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3600 return (
Node->getMethod() && !
Node->getMethod()->isFromASTFile());
3611void ASTWriter::WriteSelectors(
Sema &SemaRef) {
3612 using namespace llvm;
3617 unsigned NumTableEntries = 0;
3620 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait>
Generator;
3621 ASTMethodPoolTrait Trait(*
this);
3625 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
3626 for (
auto &SelectorAndID : SelectorIDs) {
3629 SemaObjC::GlobalMethodPool::iterator F =
3631 ASTMethodPoolTrait::data_type
Data = {
3637 Data.Instance = F->second.first;
3638 Data.Factory = F->second.second;
3642 if (Chain && ID < FirstSelectorID) {
3644 bool changed =
false;
3647 if (!M->getMethod()->isFromASTFile()) {
3655 if (!M->getMethod()->isFromASTFile()) {
3663 }
else if (
Data.Instance.getMethod() ||
Data.Factory.getMethod()) {
3674 using namespace llvm::support;
3676 ASTMethodPoolTrait Trait(*
this);
3677 llvm::raw_svector_ostream Out(MethodPool);
3679 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
3680 BucketOffset =
Generator.Emit(Out, Trait);
3684 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3686 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3687 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3688 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3689 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3695 Stream.EmitRecordWithBlob(MethodPoolAbbrev,
Record, MethodPool);
3699 Abbrev = std::make_shared<BitCodeAbbrev>();
3701 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3702 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3703 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3704 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3708 RecordData::value_type
Record[] = {
3711 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev,
Record,
3712 bytes(SelectorOffsets));
3718void ASTWriter::WriteReferencedSelectorsPool(
Sema &SemaRef) {
3719 using namespace llvm;
3731 Selector Sel = SelectorAndLocation.first;
3733 Writer.AddSelectorRef(Sel);
3755 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3757 if (!Redecl->isFromASTFile()) {
3761 if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
3764 return cast<NamedDecl>(Redecl);
3769 if (Redecl->getOwningModuleID() == 0)
3774 if (!
First->isFromASTFile())
3775 return cast<NamedDecl>(
First);
3785bool IsInterestingIdentifier(
const IdentifierInfo *II, uint64_t MacroOffset,
3786 bool IsModule,
bool IsCPlusPlus) {
3787 bool NeedDecls = !IsModule || !IsCPlusPlus;
3789 bool IsInteresting =
3793 if (MacroOffset || II->
isPoisoned() || (!IsModule && IsInteresting) ||
3804 bool IsCPlusPlus = Writer.
getLangOpts().CPlusPlus;
3805 return IsInterestingIdentifier(II, 0, IsModule, IsCPlusPlus);
3808class ASTIdentifierTableTrait {
3821 return IsInterestingIdentifier(II, MacroOffset, IsModule,
3827 using key_type_ref = key_type;
3830 using data_type_ref = data_type;
3838 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3839 NeedDecls(!IsModule || !Writer.getLangOpts().
CPlusPlus),
3840 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3842 bool needDecls()
const {
return NeedDecls; }
3845 return llvm::djbHash(II->
getName());
3853 std::pair<unsigned, unsigned>
3863 if (InterestingIdentifierOffsets &&
3865 InterestingIdentifierOffsets->push_back(Out.tell());
3875 if (NeedDecls && IdResolver)
3876 DataLen += std::distance(IdResolver->
begin(II), IdResolver->
end()) *
3882 void EmitKey(raw_ostream &Out,
const IdentifierInfo *II,
unsigned KeyLen) {
3888 using namespace llvm::support;
3890 endian::Writer
LE(Out, llvm::endianness::little);
3900 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
3901 LE.write<uint16_t>(Bits);
3903 bool HadMacroDefinition = MacroOffset != 0;
3904 Bits = (Bits << 1) |
unsigned(HadMacroDefinition);
3906 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
3909 LE.write<uint16_t>(Bits);
3911 if (HadMacroDefinition)
3914 if (NeedDecls && IdResolver) {
3943 using namespace llvm;
3950 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait>
Generator;
3951 ASTIdentifierTableTrait Trait(*
this, PP, IdResolver, IsModule,
3952 IsModule ? &InterestingIdents :
nullptr);
3956 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
3957 for (
auto IdentIDPair : IdentifierIDs) {
3960 assert(II &&
"NULL identifier in identifier table");
3965 (Trait.needDecls() &&
3974 using namespace llvm::support;
3978 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
3979 BucketOffset =
Generator.Emit(Out, Trait);
3983 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3985 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3986 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3987 unsigned IDTableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3995 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3997 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3998 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3999 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4002 for (
unsigned I = 0, N = IdentifierOffsets.size(); I != N; ++I)
4003 assert(IdentifierOffsets[I] &&
"Missing identifier offset?");
4007 IdentifierOffsets.size()};
4008 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev,
Record,
4009 bytes(IdentifierOffsets));
4013 if (!InterestingIdents.empty())
4021 PendingEmittingVTables.push_back(RD);
4030class ASTDeclContextNameLookupTraitBase {
4038 using data_type = std::pair<unsigned, unsigned>;
4039 using data_type_ref =
const data_type &;
4045 explicit ASTDeclContextNameLookupTraitBase(
ASTWriter &Writer)
4050 unsigned Start = DeclIDs.size();
4055 return std::make_pair(Start, DeclIDs.size());
4058 void EmitFileRef(raw_ostream &Out,
ModuleFile *F)
const {
4060 "have reference to loaded module file but no chain?");
4062 using namespace llvm::support;
4065 llvm::endianness::little);
4068 std::pair<unsigned, unsigned> EmitKeyDataLengthBase(raw_ostream &Out,
4070 data_type_ref Lookup) {
4071 unsigned KeyLen = 1;
4072 switch (Name.getKind()) {
4094 unsigned DataLen =
sizeof(
DeclID) * (Lookup.second - Lookup.first);
4096 return {KeyLen, DataLen};
4100 using namespace llvm::support;
4102 endian::Writer
LE(Out, llvm::endianness::little);
4103 LE.write<uint8_t>(Name.getKind());
4104 switch (Name.getKind()) {
4117 "Invalid operator?");
4118 LE.write<uint8_t>(Name.getOperatorKind());
4127 llvm_unreachable(
"Invalid name kind?");
4130 void EmitDataBase(raw_ostream &Out, data_type Lookup,
unsigned DataLen) {
4131 using namespace llvm::support;
4133 endian::Writer
LE(Out, llvm::endianness::little);
4134 uint64_t Start = Out.tell(); (void)Start;
4135 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
4137 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
4141class ModuleLocalNameLookupTrait :
public ASTDeclContextNameLookupTraitBase {
4143 using primary_module_hash_type =
unsigned;
4145 using key_type = std::pair<DeclarationNameKey, primary_module_hash_type>;
4146 using key_type_ref = key_type;
4148 explicit ModuleLocalNameLookupTrait(
ASTWriter &Writer)
4149 : ASTDeclContextNameLookupTraitBase(Writer) {}
4151 data_type getData(
const DeclIDsTy &LocalIDs) {
4152 unsigned Start = DeclIDs.size();
4153 for (
auto ID : LocalIDs)
4154 DeclIDs.push_back(
ID);
4155 return std::make_pair(Start, DeclIDs.size());
4158 static bool EqualKey(key_type_ref a, key_type_ref
b) {
return a ==
b; }
4161 llvm::FoldingSetNodeID
ID;
4162 ID.AddInteger(Key.first.getHash());
4163 ID.AddInteger(Key.second);
4164 return ID.computeStableHash();
4167 std::pair<unsigned, unsigned>
4168 EmitKeyDataLength(raw_ostream &Out, key_type Key, data_type_ref Lookup) {
4169 auto [KeyLen, DataLen] = EmitKeyDataLengthBase(Out, Key.first, Lookup);
4170 KeyLen +=
sizeof(Key.second);
4174 void EmitKey(raw_ostream &Out, key_type Key,
unsigned) {
4175 EmitKeyBase(Out, Key.first);
4176 llvm::support::endian::Writer
LE(Out, llvm::endianness::little);
4177 LE.write<primary_module_hash_type>(Key.second);
4180 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4182 EmitDataBase(Out, Lookup, DataLen);
4191 return isModuleLocalDecl(
Parent);
4195 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
D))
4196 if (
auto *CDGD = dyn_cast<CXXDeductionGuideDecl>(FTD->getTemplatedDecl()))
4197 return isModuleLocalDecl(CDGD->getDeducedTemplate());
4206class ASTDeclContextNameLookupTrait :
public ASTDeclContextNameLookupTraitBase {
4208 using ModuleLocalDeclsMapTy =
4209 llvm::DenseMap<ModuleLocalNameLookupTrait::key_type, DeclIDsTy>;
4212 ModuleLocalDeclsMapTy ModuleLocalDeclsMap;
4216 using key_type_ref = key_type;
4218 explicit ASTDeclContextNameLookupTrait(
ASTWriter &Writer)
4219 : ASTDeclContextNameLookupTraitBase(Writer) {}
4221 template <
typename Coll> data_type getData(
const Coll &Decls) {
4222 unsigned Start = DeclIDs.size();
4240 if (isModuleLocalDecl(
D)) {
4241 if (std::optional<unsigned> PrimaryModuleHash =
4243 auto Key = std::make_pair(
D->getDeclName(), *PrimaryModuleHash);
4244 auto Iter = ModuleLocalDeclsMap.find(Key);
4245 if (
Iter == ModuleLocalDeclsMap.end())
4246 ModuleLocalDeclsMap.insert({Key, DeclIDsTy{
ID}});
4248 Iter->second.push_back(
ID);
4253 DeclIDs.push_back(
ID);
4255 return std::make_pair(Start, DeclIDs.size());
4258 const ModuleLocalDeclsMapTy &getModuleLocalDecls() {
4259 return ModuleLocalDeclsMap;
4262 static bool EqualKey(key_type_ref a, key_type_ref
b) {
return a ==
b; }
4264 hash_value_type
ComputeHash(key_type Name) {
return Name.getHash(); }
4266 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
4268 data_type_ref Lookup) {
4269 auto [KeyLen, DataLen] = EmitKeyDataLengthBase(Out, Name, Lookup);
4274 return EmitKeyBase(Out, Name);
4277 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4279 EmitDataBase(Out, Lookup, DataLen);
4286class LazySpecializationInfoLookupTrait {
4292 using key_type_ref = key_type;
4295 using data_type = std::pair<unsigned, unsigned>;
4296 using data_type_ref =
const data_type &;
4301 explicit LazySpecializationInfoLookupTrait(
ASTWriter &Writer)
4304 template <
typename Col,
typename Col2>
4305 data_type getData(Col &&
C, Col2 &ExistingInfo) {
4306 unsigned Start = Specs.size();
4314 Specs.push_back(Info);
4315 return std::make_pair(Start, Specs.size());
4318 data_type ImportData(
4320 unsigned Start = Specs.size();
4321 for (
auto ID : FromReader)
4322 Specs.push_back(
ID);
4323 return std::make_pair(Start, Specs.size());
4326 static bool EqualKey(key_type_ref a, key_type_ref
b) {
return a ==
b; }
4328 hash_value_type
ComputeHash(key_type Name) {
return Name; }
4330 void EmitFileRef(raw_ostream &Out,
ModuleFile *F)
const {
4332 "have reference to loaded module file but no chain?");
4334 using namespace llvm::support;
4336 llvm::endianness::little);
4339 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
4341 data_type_ref Lookup) {
4343 unsigned KeyLen = 4;
4345 (Lookup.second - Lookup.first);
4350 void EmitKey(raw_ostream &Out, key_type HashValue,
unsigned) {
4351 using namespace llvm::support;
4353 endian::Writer
LE(Out, llvm::endianness::little);
4357 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4359 using namespace llvm::support;
4361 endian::Writer
LE(Out, llvm::endianness::little);
4364 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I) {
4365 LE.write<
DeclID>(Specs[I].getRawValue());
4367 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
4371unsigned CalculateODRHashForSpecs(
const Decl *Spec) {
4373 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Spec))
4374 Args = CTSD->getTemplateArgs().asArray();
4375 else if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Spec))
4376 Args = VTSD->getTemplateArgs().asArray();
4377 else if (
auto *FD = dyn_cast<FunctionDecl>(Spec))
4378 Args = FD->getTemplateSpecializationArgs()->asArray();
4380 llvm_unreachable(
"New Specialization Kind?");
4386void ASTWriter::GenerateSpecializationInfoLookupTable(
4393 LazySpecializationInfoLookupTrait>
4395 LazySpecializationInfoLookupTrait Trait(*
this);
4397 llvm::DenseMap<unsigned, llvm::SmallVector<const NamedDecl *, 4>>
4403 auto Iter = SpecializationMaps.find(HashedValue);
4404 if (
Iter == SpecializationMaps.end())
4405 Iter = SpecializationMaps
4406 .try_emplace(HashedValue,
4417 for (
auto &[HashValue, Specs] : SpecializationMaps) {
4428 ExisitingSpecs = Lookups->Table.find(HashValue);
4430 Generator.insert(HashValue, Trait.getData(Specs, ExisitingSpecs), Trait);
4433 Generator.emit(LookupTable, Trait, Lookups ? &Lookups->Table :
nullptr);
4436uint64_t ASTWriter::WriteSpecializationInfoLookupTable(
4441 GenerateSpecializationInfoLookupTable(
D, Specializations, LookupTable,
4444 uint64_t Offset = Stream.GetCurrentBitNo();
4445 RecordData::value_type
Record[] = {
static_cast<RecordData::value_type
>(
4447 Stream.EmitRecordWithBlob(IsPartial ? DeclPartialSpecializationsAbbrev
4448 : DeclSpecializationsAbbrev,
4456 return Result.hasExternalDecls() &&
4457 DC->hasNeedToReconcileExternalVisibleStorage();
4466 for (
auto *
D :
Result.getLookupResult()) {
4468 if (LocalD->isFromASTFile())
4486void ASTWriter::GenerateNameLookupTable(
4490 assert(!ConstDC->hasLazyLocalLexicalLookups() &&
4491 !ConstDC->hasLazyExternalLexicalLookups() &&
4492 "must call buildLookups first");
4500 ASTDeclContextNameLookupTrait>
Generator;
4501 ASTDeclContextNameLookupTrait Trait(*
this);
4513 auto &Name = Lookup.first;
4514 auto &
Result = Lookup.second;
4529 if ((GeneratingReducedBMI || isLookupResultExternal(
Result, DC)) &&
4547 if (Lookup.second.getLookupResult().empty())
4550 switch (Lookup.first.getNameKind()) {
4552 Names.push_back(Lookup.first);
4556 assert(isa<CXXRecordDecl>(DC) &&
4557 "Cannot have a constructor name outside of a class!");
4558 ConstructorNameSet.insert(Name);
4562 assert(isa<CXXRecordDecl>(DC) &&
4563 "Cannot have a conversion function name outside of a class!");
4564 ConversionNameSet.insert(Name);
4572 if (
auto *
D = dyn_cast<CXXRecordDecl>(DC)) {
4586 if (ConstructorNameSet.erase(ImplicitCtorName))
4587 Names.push_back(ImplicitCtorName);
4592 if (!ConstructorNameSet.empty() || !ConversionNameSet.empty())
4593 for (
Decl *ChildD : cast<CXXRecordDecl>(DC)->decls())
4594 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
4595 auto Name = ChildND->getDeclName();
4596 switch (Name.getNameKind()) {
4601 if (ConstructorNameSet.erase(Name))
4602 Names.push_back(Name);
4606 if (ConversionNameSet.erase(Name))
4607 Names.push_back(Name);
4611 if (ConstructorNameSet.empty() && ConversionNameSet.empty())
4615 assert(ConstructorNameSet.empty() &&
"Failed to find all of the visible "
4616 "constructors by walking all the "
4617 "lexical members of the context.");
4618 assert(ConversionNameSet.empty() &&
"Failed to find all of the visible "
4619 "conversion functions by walking all "
4620 "the lexical members of the context.");
4627 for (
auto &Name : Names)
4639 for (
auto &Name : Names) {
4642 switch (Name.getNameKind()) {
4660 if (!ConstructorDecls.empty())
4661 Generator.insert(ConstructorDecls.front()->getDeclName(),
4662 Trait.getData(ConstructorDecls), Trait);
4663 if (!ConversionDecls.empty())
4664 Generator.insert(ConversionDecls.front()->getDeclName(),
4665 Trait.getData(ConversionDecls), Trait);
4670 Generator.emit(LookupTable, Trait, Lookups ? &Lookups->Table :
nullptr);
4672 const auto &ModuleLocalDecls = Trait.getModuleLocalDecls();
4673 if (ModuleLocalDecls.empty())
4677 ModuleLocalNameLookupTrait>
4678 ModuleLocalLookupGenerator;
4679 ModuleLocalNameLookupTrait ModuleLocalTrait(*
this);
4681 for (
const auto &ModuleLocalIter : ModuleLocalDecls) {
4682 const auto &Key = ModuleLocalIter.first;
4683 const auto &IDs = ModuleLocalIter.second;
4684 ModuleLocalLookupGenerator.insert(Key, ModuleLocalTrait.getData(IDs),
4688 auto *ModuleLocalLookups =
4690 ModuleLocalLookupGenerator.emit(
4691 ModuleLocalLookupTable, ModuleLocalTrait,
4692 ModuleLocalLookups ? &ModuleLocalLookups->Table :
nullptr);
4700void ASTWriter::WriteDeclContextVisibleBlock(
ASTContext &Context,
4702 uint64_t &VisibleBlockOffset,
4703 uint64_t &ModuleLocalBlockOffset) {
4707 if (isa<NamespaceDecl>(DC) && Chain &&
4710 for (
auto *Prev = cast<NamespaceDecl>(DC)->getPreviousDecl(); Prev;
4711 Prev = Prev->getPreviousDecl())
4712 if (!Prev->isFromASTFile())
4725 LookupResults.reserve(Map->size());
4726 for (
auto &Entry : *Map)
4727 LookupResults.push_back(
4728 std::make_pair(Entry.first, Entry.second.getLookupResult()));
4731 llvm::sort(LookupResults, llvm::less_first());
4732 for (
auto &NameAndResult : LookupResults) {
4740 assert(
Result.empty() &&
"Cannot have a constructor or conversion "
4741 "function name in a namespace!");
4783 if (!Map || Map->empty())
4786 VisibleBlockOffset = Stream.GetCurrentBitNo();
4790 GenerateNameLookupTable(Context, DC, LookupTable, ModuleLocalLookupTable);
4794 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev,
Record,
4796 ++NumVisibleDeclContexts;
4798 if (ModuleLocalLookupTable.empty())
4801 ModuleLocalBlockOffset = Stream.GetCurrentBitNo();
4802 assert(ModuleLocalBlockOffset > VisibleBlockOffset);
4804 RecordData::value_type ModuleLocalRecord[] = {
4806 Stream.EmitRecordWithBlob(DeclModuleLocalVisibleLookupAbbrev,
4807 ModuleLocalRecord, ModuleLocalLookupTable);
4808 ++NumModuleLocalDeclContexts;
4817void ASTWriter::WriteDeclContextVisibleUpdate(
ASTContext &Context,
4820 if (!Map || Map->empty())
4826 GenerateNameLookupTable(Context, DC, LookupTable, ModuleLocalLookupTable);
4830 if (isa<NamespaceDecl>(DC))
4836 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev,
Record, LookupTable);
4838 if (ModuleLocalLookupTable.empty())
4842 RecordData::value_type ModuleLocalRecord[] = {
4844 Stream.EmitRecordWithBlob(ModuleLocalUpdateVisibleAbbrev, ModuleLocalRecord,
4845 ModuleLocalLookupTable);
4855void ASTWriter::WriteOpenCLExtensions(
Sema &SemaRef) {
4861 for (
const auto &I:Opts.OptMap) {
4863 auto V = I.getValue();
4864 Record.push_back(
V.Supported ? 1 : 0);
4865 Record.push_back(
V.Enabled ? 1 : 0);
4866 Record.push_back(
V.WithPragma ? 1 : 0);
4873void ASTWriter::WriteCUDAPragmas(
Sema &SemaRef) {
4874 if (SemaRef.
CUDA().ForceHostDeviceDepth > 0) {
4875 RecordData::value_type
Record[] = {SemaRef.
CUDA().ForceHostDeviceDepth};
4880void ASTWriter::WriteObjCCategories() {
4884 for (
unsigned I = 0, N = ObjCClassesWithCategories.size(); I != N; ++I) {
4886 unsigned StartIndex = Categories.size();
4891 Categories.push_back(0);
4895 Cat =
Class->known_categories_begin(),
4896 CatEnd =
Class->known_categories_end();
4897 Cat != CatEnd; ++Cat, ++Size) {
4903 Categories[StartIndex] =
Size;
4907 CategoriesMap.push_back(CatInfo);
4912 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
4915 using namespace llvm;
4917 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4919 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
4920 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4921 unsigned AbbrevID = Stream.EmitAbbrev(std::move(Abbrev));
4924 Stream.EmitRecordWithBlob(AbbrevID,
Record,
4925 reinterpret_cast<char *
>(CategoriesMap.data()),
4932void ASTWriter::WriteLateParsedTemplates(
Sema &SemaRef) {
4939 for (
auto &LPTMapEntry : LPTMap) {
4947 for (
const auto &Tok : LPT.
Toks) {
4955void ASTWriter::WriteOptimizePragmaOptions(
Sema &SemaRef) {
4963void ASTWriter::WriteMSStructPragmaOptions(
Sema &SemaRef) {
4971void ASTWriter::WriteMSPointersToMembersPragmaOptions(
Sema &SemaRef) {
4979void ASTWriter::WritePackPragmaOptions(
Sema &SemaRef) {
4999void ASTWriter::WriteFloatControlPragmaOptions(
Sema &SemaRef) {
5009 for (
const auto &StackEntry : SemaRef.
FpPragmaStack.Stack) {
5010 Record.push_back(StackEntry.Value.getAsOpaqueInt());
5019void ASTWriter::WriteDeclsWithEffectsToVerify(
Sema &SemaRef) {
5029void ASTWriter::WriteModuleFileExtension(
Sema &SemaRef,
5035 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
5037 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5038 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5039 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5040 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5041 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
5042 unsigned Abbrev = Stream.EmitAbbrev(std::move(Abv));
5048 Record.push_back(Metadata.MajorVersion);
5049 Record.push_back(Metadata.MinorVersion);
5050 Record.push_back(Metadata.BlockName.size());
5051 Record.push_back(Metadata.UserInfo.size());
5053 Buffer += Metadata.BlockName;
5054 Buffer += Metadata.UserInfo;
5055 Stream.EmitRecordWithBlob(Abbrev,
Record, Buffer);
5073 if (!A || (isa<PreferredNameAttr>(A) &&
5074 Writer->isWritingStdCXXNamedModules()))
5075 return Record.push_back(0);
5085 Record.push_back(A->getAttributeSpellingListIndexRaw());
5088#include "clang/Serialization/AttrPCHWrite.inc"
5094 for (
const auto *A : Attrs)
5108 case tok::annot_pragma_loop_hint: {
5112 Record.push_back(Info->Toks.size());
5113 for (
const auto &
T : Info->Toks)
5117 case tok::annot_pragma_pack: {
5120 Record.push_back(
static_cast<unsigned>(Info->Action));
5126 case tok::annot_pragma_openmp:
5127 case tok::annot_pragma_openmp_end:
5128 case tok::annot_pragma_unused:
5129 case tok::annot_pragma_openacc:
5130 case tok::annot_pragma_openacc_end:
5131 case tok::annot_repl_input_end:
5134 llvm_unreachable(
"missing serialization code for annotation token");
5145 Record.push_back(Str.size());
5151 Record.push_back(Str.size());
5152 Blob.insert(Blob.end(), Str.begin(), Str.end());
5156 assert(WritingAST &&
"can't prepare path for output when not writing AST");
5159 StringRef PathStr(
Path.data(),
Path.size());
5160 if (PathStr ==
"<built-in>" || PathStr ==
"<command line>")
5166 const char *PathBegin =
Path.data();
5167 const char *PathPtr =
5169 if (PathPtr != PathBegin) {
5170 Path.erase(
Path.begin(),
Path.begin() + (PathPtr - PathBegin));
5194 Stream.EmitRecordWithBlob(Abbrev,
Record, FilePath);
5199 Record.push_back(Version.getMajor());
5200 if (std::optional<unsigned> Minor = Version.getMinor())
5201 Record.push_back(*Minor + 1);
5204 if (std::optional<unsigned> Subminor = Version.getSubminor())
5205 Record.push_back(*Subminor + 1);
5223 assert(ID < IdentifierOffsets.size());
5224 IdentifierOffsets[ID] = Offset;
5230 unsigned ID = SelectorIDs[Sel];
5231 assert(ID &&
"Unknown selector");
5234 if (ID < FirstSelectorID)
5236 SelectorOffsets[ID - FirstSelectorID] = Offset;
5242 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
5243 bool IncludeTimestamps,
bool BuildingImplicitModule,
5244 bool GeneratingReducedBMI)
5245 : Stream(Stream), Buffer(Buffer), ModuleCache(ModuleCache),
5246 IncludeTimestamps(IncludeTimestamps),
5247 BuildingImplicitModule(BuildingImplicitModule),
5248 GeneratingReducedBMI(GeneratingReducedBMI) {
5249 for (
const auto &Ext : Extensions) {
5250 if (
auto Writer = Ext->createExtensionWriter(*
this))
5251 ModuleFileExtensionWriters.push_back(std::move(Writer));
5258 assert(WritingAST &&
"can't determine lang opts when not writing AST");
5263 return IncludeTimestamps ?
E->getModificationTime() : 0;
5268 StringRef OutputFile,
Module *WritingModule,
5269 StringRef isysroot,
bool ShouldCacheASTInMemory) {
5270 llvm::TimeTraceScope scope(
"WriteAST", OutputFile);
5273 Sema *SemaPtr = Subject.dyn_cast<
Sema *>();
5275 SemaPtr ? SemaPtr->
getPreprocessor() : *cast<Preprocessor *>(Subject);
5277 ASTHasCompilerErrors = PPRef.getDiagnostics().hasUncompilableErrorOccurred();
5280 Stream.Emit((
unsigned)
'C', 8);
5281 Stream.Emit((
unsigned)
'P', 8);
5282 Stream.Emit((
unsigned)
'C', 8);
5283 Stream.Emit((
unsigned)
'H', 8);
5285 WriteBlockInfoBlock();
5288 this->WritingModule = WritingModule;
5289 ASTFileSignature Signature = WriteASTCore(SemaPtr, isysroot, WritingModule);
5291 this->WritingModule =
nullptr;
5292 this->BaseDirectory.clear();
5296 if (WritingModule && PPRef.getHeaderSearchInfo()
5297 .getHeaderSearchOpts()
5298 .ModulesValidateOncePerBuildSession)
5301 if (ShouldCacheASTInMemory) {
5304 llvm::MemoryBuffer::getMemBufferCopy(
5305 StringRef(Buffer.begin(), Buffer.size())));
5310template<
typename Vector>
5312 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true),
E = Vec.end();
5318template <
typename Vector>
5321 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true),
E = Vec.end();
5327void ASTWriter::computeNonAffectingInputFiles() {
5331 IsSLocAffecting.resize(N,
true);
5332 IsSLocFileEntryAffecting.resize(N,
true);
5337 auto AffectingModuleMaps = GetAffectingModuleMaps(*PP, WritingModule);
5339 unsigned FileIDAdjustment = 0;
5340 unsigned OffsetAdjustment = 0;
5342 NonAffectingFileIDAdjustments.reserve(N);
5343 NonAffectingOffsetAdjustments.reserve(N);
5345 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
5346 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
5348 for (
unsigned I = 1; I != N; ++I) {
5350 FileID FID = FileID::get(I);
5357 if (!
Cache->OrigEntry)
5365 if (!AffectingModuleMaps)
5369 if (AffectingModuleMaps->DefinitionFileIDs.contains(FID))
5372 IsSLocAffecting[I] =
false;
5373 IsSLocFileEntryAffecting[I] =
5374 AffectingModuleMaps->DefinitionFiles.contains(*
Cache->OrigEntry);
5376 FileIDAdjustment += 1;
5382 if (!NonAffectingFileIDs.empty() &&
5383 NonAffectingFileIDs.back().ID == FID.ID - 1) {
5384 NonAffectingFileIDs.back() = FID;
5386 NonAffectingFileIDAdjustments.back() = FileIDAdjustment;
5387 NonAffectingOffsetAdjustments.back() = OffsetAdjustment;
5391 NonAffectingFileIDs.push_back(FID);
5394 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
5395 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
5404 for (StringRef
Path :
5407 for (
unsigned I = 1; I != N; ++I) {
5408 if (IsSLocAffecting[I]) {
5414 if (!
Cache->OrigEntry)
5417 Cache->OrigEntry->getNameAsRequested());
5423void ASTWriter::PrepareWritingSpecialDecls(
Sema &SemaRef) {
5426 bool isModule = WritingModule !=
nullptr;
5433 PredefinedDecls.insert(
D);
5441 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
5445 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
5449 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
5454 RegisterPredefDecl(Context.MakeIntegerSeqDecl,
5456 RegisterPredefDecl(Context.CFConstantStringTypeDecl,
5458 RegisterPredefDecl(Context.CFConstantStringTagDecl,
5460 RegisterPredefDecl(Context.TypePackElementDecl,
5474 if (GeneratingReducedBMI) {
5500 if (GeneratingReducedBMI)
5523 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I)
5534 "There are local ones at end of translation unit!");
5547 for (
const auto &I : SemaRef.KnownNamespaces)
5554 for (
const auto &I : Undefined)
5560 for (
const auto &DeleteExprsInfo :
5567 for (
const auto *I : DeclsToEmitEvenIfUnreferenced)
5569 DeclsToEmitEvenIfUnreferenced.clear();
5581 llvm::sort(IIs, llvm::deref<std::less<>>());
5588 for (
auto *
D : SemaRef.DeclsToCheckForDeferredDiags)
5596 PendingEmittingVTables.clear();
5599void ASTWriter::WriteSpecialDeclRecords(
Sema &SemaRef) {
5602 bool isModule = WritingModule !=
nullptr;
5605 if (!EagerlyDeserializedDecls.empty())
5608 if (!ModularCodegenDecls.empty())
5614 TentativeDefinitions);
5615 if (!TentativeDefinitions.empty())
5622 UnusedFileScopedDecls);
5623 if (!UnusedFileScopedDecls.empty())
5629 if (!ExtVectorDecls.empty())
5635 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I) {
5651 if (!UnusedLocalTypedefNameCandidates.empty())
5653 UnusedLocalTypedefNameCandidates);
5664 if (!PendingInstantiations.empty())
5670 auto AddEmittedDeclRefOrZero = [
this, &SemaDeclRefs](
Decl *
D) {
5672 SemaDeclRefs.push_back(0);
5681 if (!SemaDeclRefs.empty())
5686 for (
auto *
D : SemaRef.DeclsToCheckForDeferredDiags)
5689 if (!DeclsToCheckForDeferredDiags.empty())
5691 DeclsToCheckForDeferredDiags);
5697 AddDeclRef(CudaCallDecl, CUDASpecialDeclRefs);
5705 DelegatingCtorDecls);
5706 if (!DelegatingCtorDecls.empty())
5711 for (
const auto &I : SemaRef.KnownNamespaces) {
5715 if (!KnownNamespaces.empty())
5722 for (
const auto &I : Undefined) {
5729 if (!UndefinedButUsed.empty())
5736 for (
const auto &DeleteExprsInfo :
5741 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
5742 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
5743 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
5745 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
5749 if (!DeleteExprsToAnalyze.empty())
5760 if (!VTablesToEmit.empty())
5766 using namespace llvm;
5768 bool isModule = WritingModule !=
nullptr;
5776 computeNonAffectingInputFiles();
5778 writeUnhashedControlBlock(*PP);
5791 IdentifierIDs.clear();
5804 if (IsInterestingNonMacroIdentifier(
ID.second, *
this))
5805 IIs.push_back(
ID.second);
5808 llvm::sort(IIs, llvm::deref<std::less<>>());
5817 for (
const auto &WeakUndeclaredIdentifierList :
5819 const IdentifierInfo *
const II = WeakUndeclaredIdentifierList.first;
5820 for (
const auto &WI : WeakUndeclaredIdentifierList.second) {
5836 AddTypeRef(Context, Context.ObjCIdRedefinitionType, SpecialTypes);
5837 AddTypeRef(Context, Context.ObjCClassRedefinitionType, SpecialTypes);
5838 AddTypeRef(Context, Context.ObjCSelRedefinitionType, SpecialTypes);
5843 PrepareWritingSpecialDecls(*SemaPtr);
5846 WriteControlBlock(*PP, isysroot);
5849 Stream.FlushToWord();
5850 ASTBlockRange.first = Stream.GetCurrentBitNo() >> 3;
5852 ASTBlockStartOffset = Stream.GetCurrentBitNo();
5870 for (
auto &SelectorAndID : SelectorIDs)
5871 AllSelectors.push_back(SelectorAndID.first);
5872 for (
auto &
Selector : AllSelectors)
5896 auto Abbrev = std::make_shared<BitCodeAbbrev>();
5898 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
5899 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
5902 llvm::raw_svector_ostream Out(Buffer);
5904 using namespace llvm::support;
5906 endian::Writer
LE(Out, llvm::endianness::little);
5907 LE.write<uint8_t>(
static_cast<uint8_t
>(M.
Kind));
5909 LE.write<uint16_t>(Name.size());
5910 Out.write(Name.data(), Name.size());
5916 auto writeBaseIDOrNone = [&](
auto BaseID,
bool ShouldWrite) {
5917 assert(BaseID < std::numeric_limits<uint32_t>::max() &&
"base id too high");
5934 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev,
Record,
5935 Buffer.data(), Buffer.size());
5939 WriteDeclAndTypes(SemaPtr->
Context);
5941 WriteFileDeclIDsMap();
5944 WriteComments(SemaPtr->
Context);
5945 WritePreprocessor(*PP, isModule);
5948 WriteSelectors(*SemaPtr);
5949 WriteReferencedSelectorsPool(*SemaPtr);
5950 WriteLateParsedTemplates(*SemaPtr);
5952 WriteIdentifierTable(*PP, SemaPtr ? &SemaPtr->
IdResolver :
nullptr, isModule);
5955 WriteOpenCLExtensions(*SemaPtr);
5956 WriteCUDAPragmas(*SemaPtr);
5961 WriteSubmodules(WritingModule, SemaPtr ? &SemaPtr->
Context :
nullptr);
5966 WriteSpecialDeclRecords(*SemaPtr);
5969 if (!WeakUndeclaredIdentifiers.empty())
5971 WeakUndeclaredIdentifiers);
5973 if (!WritingModule) {
5983 assert(SubmoduleIDs.contains(I->getImportedModule()));
5984 Imports.push_back(ModuleInfo(SubmoduleIDs[I->getImportedModule()],
5985 I->getImportedModule()));
5989 if (!Imports.empty()) {
5990 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
5993 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
5994 return A.ID == B.ID;
5998 llvm::sort(Imports, Cmp);
5999 Imports.erase(std::unique(Imports.begin(), Imports.end(),
Eq),
6003 for (
const auto &Import : Imports) {
6004 ImportedModules.push_back(
Import.ID);
6015 WriteObjCCategories();
6017 if (!WritingModule) {
6018 WriteOptimizePragmaOptions(*SemaPtr);
6019 WriteMSStructPragmaOptions(*SemaPtr);
6020 WriteMSPointersToMembersPragmaOptions(*SemaPtr);
6022 WritePackPragmaOptions(*SemaPtr);
6023 WriteFloatControlPragmaOptions(*SemaPtr);
6024 WriteDeclsWithEffectsToVerify(*SemaPtr);
6028 RecordData::value_type
Record[] = {
6029 NumStatements, NumMacros, NumLexicalDeclContexts, NumVisibleDeclContexts,
6030 NumModuleLocalDeclContexts};
6033 Stream.FlushToWord();
6034 ASTBlockRange.second = Stream.GetCurrentBitNo() >> 3;
6038 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
6039 WriteModuleFileExtension(*SemaPtr, *ExtWriter);
6041 return backpatchSignature();
6044void ASTWriter::EnteringModulePurview() {
6047 if (GeneratingReducedBMI)
6048 DeclUpdatesFromGMF.swap(DeclUpdates);
6054void ASTWriter::AddedManglingNumber(
const Decl *
D,
unsigned Number) {
6060void ASTWriter::AddedStaticLocalNumbers(
const Decl *
D,
unsigned Number) {
6079void ASTWriter::WriteDeclAndTypes(
ASTContext &Context) {
6084 DeclTypesBlockStartOffset = Stream.GetCurrentBitNo();
6088 WriteDeclUpdatesBlocks(Context, DeclUpdatesOffsetsRecord);
6089 while (!DeclTypesToEmit.empty()) {
6090 DeclOrType DOT = DeclTypesToEmit.front();
6091 DeclTypesToEmit.pop();
6093 WriteType(Context, DOT.getType());
6095 WriteDecl(Context, DOT.getDecl());
6097 }
while (!DeclUpdates.empty());
6099 DoneWritingDeclsAndTypes =
true;
6103 assert(DelayedNamespace.empty() || GeneratingReducedBMI);
6106 uint64_t LexicalOffset = WriteDeclContextLexicalBlock(Context, NS);
6109 WriteDeclContextVisibleBlock(Context, NS, VisibleOffset, ModuleLocalOffset);
6113 LexicalOffset -= DeclTypesBlockStartOffset;
6116 VisibleOffset -= DeclTypesBlockStartOffset;
6118 if (ModuleLocalOffset)
6119 ModuleLocalOffset -= DeclTypesBlockStartOffset;
6122 DelayedNamespaceRecord.push_back(LexicalOffset);
6123 DelayedNamespaceRecord.push_back(VisibleOffset);
6124 DelayedNamespaceRecord.push_back(ModuleLocalOffset);
6129 assert(DeclTypesToEmit.empty());
6130 assert(DeclUpdates.empty());
6135 WriteTypeDeclOffsets();
6136 if (!DeclUpdatesOffsetsRecord.empty())
6139 if (!DelayedNamespaceRecord.empty())
6141 DelayedNamespaceRecord);
6143 if (!RelatedDeclsMap.empty()) {
6147 for (
const auto &Pair : RelatedDeclsMap) {
6148 RelatedDeclsMapRecord.push_back(Pair.first.getRawValue());
6149 RelatedDeclsMapRecord.push_back(Pair.second.size());
6150 for (
const auto &Lambda : Pair.second)
6151 RelatedDeclsMapRecord.push_back(Lambda.getRawValue());
6154 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6156 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Array));
6157 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6158 unsigned FunctionToLambdaMapAbbrev = Stream.EmitAbbrev(std::move(Abv));
6160 FunctionToLambdaMapAbbrev);
6163 if (!SpecializationsUpdates.empty()) {
6164 WriteSpecializationsUpdates(
false);
6165 SpecializationsUpdates.clear();
6168 if (!PartialSpecializationsUpdates.empty()) {
6169 WriteSpecializationsUpdates(
true);
6170 PartialSpecializationsUpdates.clear();
6185 NewGlobalKindDeclPairs.push_back(
D->
getKind());
6186 NewGlobalKindDeclPairs.push_back(
GetDeclRef(
D).getRawValue());
6189 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6191 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6192 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
6195 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev,
Record,
6196 bytes(NewGlobalKindDeclPairs));
6198 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6200 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6201 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6202 UpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6204 Abv = std::make_shared<llvm::BitCodeAbbrev>();
6206 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6207 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6208 ModuleLocalUpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
6211 WriteDeclContextVisibleUpdate(Context, TU);
6214 if (Context.ExternCContext)
6215 WriteDeclContextVisibleUpdate(Context, Context.ExternCContext);
6218 for (
auto *DC : UpdatedDeclContexts)
6219 WriteDeclContextVisibleUpdate(Context, DC);
6222void ASTWriter::WriteSpecializationsUpdates(
bool IsPartial) {
6226 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
6228 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
6229 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
6230 auto UpdateSpecializationAbbrev = Stream.EmitAbbrev(std::move(Abv));
6233 IsPartial ? PartialSpecializationsUpdates : SpecializationsUpdates;
6234 for (
auto &SpecializationUpdate : SpecUpdates) {
6235 const NamedDecl *
D = SpecializationUpdate.first;
6238 GenerateSpecializationInfoLookupTable(
D, SpecializationUpdate.second,
6239 LookupTable, IsPartial);
6242 RecordData::value_type
Record[] = {
6243 static_cast<RecordData::value_type
>(
RecordType),
6245 Stream.EmitRecordWithBlob(UpdateSpecializationAbbrev,
Record, LookupTable);
6249void ASTWriter::WriteDeclUpdatesBlocks(
ASTContext &Context,
6250 RecordDataImpl &OffsetsRecord) {
6251 if (DeclUpdates.empty())
6254 DeclUpdateMap LocalUpdates;
6255 LocalUpdates.swap(DeclUpdates);
6257 for (
auto &DeclUpdate : LocalUpdates) {
6258 const Decl *
D = DeclUpdate.first;
6260 bool HasUpdatedBody =
false;
6261 bool HasAddedVarDefinition =
false;
6264 for (
auto &
Update : DeclUpdate.second) {
6270 HasUpdatedBody =
true;
6272 HasAddedVarDefinition =
true;
6279 assert(
Update.getDecl() &&
"no decl to add?");
6293 cast<ParmVarDecl>(
Update.getDecl())->getDefaultArg());
6298 cast<FieldDecl>(
Update.getDecl())->getInClassInitializer());
6302 auto *RD = cast<CXXRecordDecl>(
D);
6303 UpdatedDeclContexts.insert(RD->getPrimaryContext());
6304 Record.push_back(RD->isParamDestroyedInCallee());
6305 Record.push_back(llvm::to_underlying(RD->getArgPassingRestrictions()));
6306 Record.AddCXXDefinitionData(RD);
6307 Record.AddOffset(WriteDeclContextLexicalBlock(Context, RD));
6312 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
6313 Record.push_back(MSInfo->getTemplateSpecializationKind());
6314 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
6316 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
6317 Record.push_back(Spec->getTemplateSpecializationKind());
6318 Record.AddSourceLocation(Spec->getPointOfInstantiation());
6322 auto From = Spec->getInstantiatedFrom();
6323 if (
auto PartialSpec =
6326 Record.AddDeclRef(PartialSpec);
6327 Record.AddTemplateArgumentList(
6328 &Spec->getTemplateInstantiationArgs());
6333 Record.push_back(llvm::to_underlying(RD->getTagKind()));
6334 Record.AddSourceLocation(RD->getLocation());
6335 Record.AddSourceLocation(RD->getBeginLoc());
6336 Record.AddSourceRange(RD->getBraceRange());
6349 Record.AddStmt(cast<CXXDestructorDecl>(
D)->getOperatorDeleteThisArg());
6355 Record.writeExceptionSpecInfo(prototype->getExceptionSpecInfo());
6373 D->
getAttr<OMPThreadPrivateDeclAttr>()->getRange());
6377 auto *A =
D->
getAttr<OMPAllocateDeclAttr>();
6378 Record.push_back(A->getAllocatorType());
6379 Record.AddStmt(A->getAllocator());
6380 Record.AddStmt(A->getAlignment());
6381 Record.AddSourceRange(A->getRange());
6386 Record.push_back(
D->
getAttr<OMPDeclareTargetDeclAttr>()->getMapType());
6388 D->
getAttr<OMPDeclareTargetDeclAttr>()->getRange());
6404 if (HasUpdatedBody) {
6405 const auto *Def = cast<FunctionDecl>(
D);
6407 Record.push_back(Def->isInlined());
6408 Record.AddSourceLocation(Def->getInnerLocStart());
6409 Record.AddFunctionDefinition(Def);
6410 }
else if (HasAddedVarDefinition) {
6411 const auto *VD = cast<VarDecl>(
D);
6413 Record.push_back(VD->isInline());
6414 Record.push_back(VD->isInlineSpecified());
6415 Record.AddVarDeclInit(VD);
6432 NonAffectingFileIDs.empty())
6434 auto It = llvm::lower_bound(NonAffectingFileIDs, FID);
6435 unsigned Idx = std::distance(NonAffectingFileIDs.begin(), It);
6436 unsigned Offset = NonAffectingFileIDAdjustments[Idx];
6437 return FileID::get(FID.getOpaqueValue() - Offset);
6440unsigned ASTWriter::getAdjustedNumCreatedFIDs(
FileID FID)
const {
6446 unsigned AdjustedNumCreatedFIDs = 0;
6447 for (
unsigned I = FID.ID, N = I + NumCreatedFIDs; I != N; ++I)
6448 if (IsSLocAffecting[I])
6449 ++AdjustedNumCreatedFIDs;
6450 return AdjustedNumCreatedFIDs;
6466 return Offset - getAdjustment(Offset);
6471 if (NonAffectingRanges.empty())
6477 if (Offset > NonAffectingRanges.back().getEnd().getOffset())
6478 return NonAffectingOffsetAdjustments.back();
6480 if (Offset < NonAffectingRanges.front().getBegin().getOffset())
6487 auto It = llvm::lower_bound(NonAffectingRanges, Offset, Contains);
6488 unsigned Idx = std::distance(NonAffectingRanges.begin(), It);
6489 return NonAffectingOffsetAdjustments[Idx];
6493 Record.push_back(getAdjustedFileID(FID).getOpaqueValue());
6498 unsigned BaseOffset = 0;
6499 unsigned ModuleFileIndex = 0;
6505 SourceManager::MaxLoadedOffset -
Loc.getOffset() - 1);
6506 assert(SLocMapI !=
getChain()->GlobalSLocOffsetMap.end() &&
6507 "Corrupted global sloc offset map");
6512 ModuleFileIndex = F->
Index + 1;
6521 Loc = getAdjustedLocation(
Loc);
6559 MacroInfoToEmitData Info = { Name, MI, ID };
6560 MacroInfosToEmit.push_back(Info);
6569 assert(MacroIDs.contains(MI) &&
"Macro not emitted!");
6570 return MacroIDs[MI];
6574 return IdentMacroDirectivesOffsetMap.lookup(Name);
6578 Record->push_back(Writer->getSelectorRef(SelRef));
6587 if (SID == 0 && Chain) {
6591 SID = SelectorIDs[Sel];
6594 SID = NextSelectorID++;
6595 SelectorIDs[Sel] = SID;
6637 bool InfoHasSameExpr
6639 Record->push_back(InfoHasSameExpr);
6640 if (InfoHasSameExpr)
6658 TypeLocWriter TLW(*
this,
Seq);
6668template <
typename IdxForTypeTy>
6670 IdxForTypeTy IdxForType) {
6674 unsigned FastQuals =
T.getLocalFastQualifiers();
6675 T.removeLocalFastQualifiers();
6677 if (
T.hasLocalNonFastQualifiers())
6678 return IdxForType(
T).asTypeID(FastQuals);
6680 assert(!
T.hasLocalQualifiers());
6682 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(
T.getTypePtr()))
6690 return IdxForType(
T).asTypeID(FastQuals);
6697 assert(!
T.getLocalFastQualifiers());
6701 if (DoneWritingDeclsAndTypes) {
6702 assert(0 &&
"New type seen after serializing all the types to emit!");
6708 Idx =
TypeIdx(0, NextTypeID++);
6709 DeclTypesToEmit.push(
T);
6727 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
6734 if (
auto *
Iter = DeclUpdatesFromGMF.find(
D);
6735 Iter != DeclUpdatesFromGMF.end()) {
6737 DeclUpdates[
D].push_back(
Update);
6738 DeclUpdatesFromGMF.erase(
Iter);
6750 assert(!(
reinterpret_cast<uintptr_t>(
D) & 0x01) &&
"Invalid decl pointer");
6752 if (ID.isInvalid()) {
6753 if (DoneWritingDeclsAndTypes) {
6754 assert(0 &&
"New decl seen after serializing all the decls to emit!");
6761 DeclTypesToEmit.push(
const_cast<Decl *
>(
D));
6776 assert(DeclIDs.contains(
D) &&
"Declaration not emitted!");
6783 assert(DoneWritingDeclsAndTypes &&
6784 "wasDeclEmitted should only be called after writing declarations");
6789 bool Emitted = DeclIDs.contains(
D);
6791 GeneratingReducedBMI) &&
6792 "The declaration within modules can only be omitted in reduced BMI.");
6797 assert(ID.isValid());
6811 if (isa<ParmVarDecl, TemplateTemplateParmDecl>(
D))
6816 assert(
SM.isLocalSourceLocation(FileLoc));
6819 std::tie(FID, Offset) =
SM.getDecomposedLoc(FileLoc);
6822 assert(
SM.getSLocEntry(FID).isFile());
6823 assert(IsSLocAffecting[FID.ID]);
6825 std::unique_ptr<DeclIDInFileInfo> &Info = FileDeclIDs[FID];
6827 Info = std::make_unique<DeclIDInFileInfo>();
6829 std::pair<unsigned, LocalDeclID> LocDecl(Offset, ID);
6830 LocDeclIDsTy &Decls = Info->DeclIDs;
6831 Decls.push_back(LocDecl);
6836 "expected an anonymous declaration");
6840 auto It = AnonymousDeclarationNumbers.find(
D);
6841 if (It == AnonymousDeclarationNumbers.end()) {
6844 AnonymousDeclarationNumbers[ND] = Number;
6847 It = AnonymousDeclarationNumbers.find(
D);
6848 assert(It != AnonymousDeclarationNumbers.end() &&
6849 "declaration not found within its lexical context");
6857 switch (Name.getNameKind()) {
6904 NestedNames.push_back(NNS);
6908 Record->push_back(NestedNames.size());
6909 while(!NestedNames.empty()) {
6910 NNS = NestedNames.pop_back_val();
6952 assert(TemplateParams &&
"No TemplateParams!");
6958 for (
const auto &
P : *TemplateParams)
6964 Record->push_back(
false);
6971 assert(TemplateArgs &&
"No TemplateArgs!");
6973 for (
int i = 0, e = TemplateArgs->
size(); i != e; ++i)
6979 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
6991 I =
Set.begin(),
E =
Set.end(); I !=
E; ++I) {
6993 Record->push_back(I.getAccess());
7001 Record->push_back(
Base.getAccessSpecifierAsWritten());
7002 Record->push_back(
Base.getInheritConstructors());
7015 for (
auto &
Base : Bases)
7033 for (
auto *
Init : CtorInits) {
7034 if (
Init->isBaseInitializer()) {
7038 }
else if (
Init->isDelegatingInitializer()) {
7041 }
else if (
Init->isMemberInitializer()){
7054 if (
Init->isWritten())
7068 auto &
Data =
D->data();
7074#define FIELD(Name, Width, Merge) \
7075 if (!DefinitionBits.canWriteNextNBits(Width)) { \
7076 Record->push_back(DefinitionBits); \
7077 DefinitionBits.reset(0); \
7079 DefinitionBits.addBits(Data.Name, Width);
7081#include "clang/AST/CXXRecordDeclDefinitionBits.def"
7084 Record->push_back(DefinitionBits);
7088 Record->push_back(
D->getODRHash());
7090 bool ModulesCodegen =
7091 !
D->isDependentType() &&
7093 Record->push_back(ModulesCodegen);
7095 Writer->AddDeclRef(
D, Writer->ModularCodegenDecls);
7100 Record->push_back(
Data.ComputedVisibleConversions);
7101 if (
Data.ComputedVisibleConversions)
7105 if (!
Data.IsLambda) {
7107 if (
Data.NumBases > 0)
7112 if (
Data.NumVBases > 0)
7117 auto &Lambda =
D->getLambdaData();
7120 LambdaBits.
addBits(Lambda.DependencyKind, 2);
7121 LambdaBits.
addBit(Lambda.IsGenericLambda);
7122 LambdaBits.
addBits(Lambda.CaptureDefault, 2);
7123 LambdaBits.
addBits(Lambda.NumCaptures, 15);
7124 LambdaBits.
addBit(Lambda.HasKnownInternalLinkage);
7125 Record->push_back(LambdaBits);
7127 Record->push_back(Lambda.NumExplicitCaptures);
7128 Record->push_back(Lambda.ManglingNumber);
7129 Record->push_back(
D->getDeviceLambdaManglingNumber());
7133 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
7140 Record->push_back(CaptureBits);
7142 switch (
Capture.getCaptureKind()) {
7169 Val |= (ES->HasConstantInitialization ? 2 : 0);
7170 Val |= (ES->HasConstantDestruction ? 4 : 0);
7184void ASTWriter::ReaderInitialized(
ASTReader *Reader) {
7185 assert(Reader &&
"Cannot remove chain");
7186 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
7187 assert(FirstDeclID == NextDeclID &&
7188 FirstTypeID == NextTypeID &&
7189 FirstIdentID == NextIdentID &&
7190 FirstMacroID == NextMacroID &&
7191 FirstSubmoduleID == NextSubmoduleID &&
7192 FirstSelectorID == NextSelectorID &&
7193 "Setting chain after writing has started.");
7202 NextMacroID = FirstMacroID;
7203 NextSelectorID = FirstSelectorID;
7204 NextSubmoduleID = FirstSubmoduleID;
7214 unsigned OriginalModuleFileIndex = StoredID >> 32;
7218 if (OriginalModuleFileIndex == 0 && StoredID)
7229 MacroID &StoredID = MacroIDs[MI];
7252 if (ModuleFileIndex == 0 && StoredIdx.
getValue())
7264 PredefinedDecls.insert(
D);
7276 assert(!MacroDefinitions.contains(MD));
7277 MacroDefinitions[MD] =
ID;
7281 assert(!SubmoduleIDs.contains(Mod));
7282 SubmoduleIDs[Mod] =
ID;
7285void ASTWriter::CompletedTagDefinition(
const TagDecl *
D) {
7287 assert(
D->isCompleteDefinition());
7288 assert(!WritingAST &&
"Already writing the AST!");
7289 if (
auto *RD = dyn_cast<CXXRecordDecl>(
D)) {
7291 if (RD->isFromASTFile()) {
7296 "completed a tag from another module but not by instantiation?");
7297 DeclUpdates[RD].push_back(
7315 "Should not add lookup results to non-lookup contexts!");
7318 if (isa<TranslationUnitDecl>(DC))
7326 !isa<FunctionTemplateDecl>(
D))
7336 assert(!WritingAST &&
"Already writing the AST!");
7337 if (UpdatedDeclContexts.insert(DC) && !cast<Decl>(DC)->isFromASTFile()) {
7341 llvm::append_range(DeclsToEmitEvenIfUnreferenced, DC->
decls());
7343 DeclsToEmitEvenIfUnreferenced.push_back(
D);
7355 if (!isa<CXXMethodDecl>(
D))
7360 assert(!WritingAST &&
"Already writing the AST!");
7364void ASTWriter::ResolvedExceptionSpec(
const FunctionDecl *FD) {
7366 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
7373 ->castAs<FunctionProtoType>()
7374 ->getExceptionSpecType()))
7381 assert(!WritingAST &&
"Already writing the AST!");
7384 DeclUpdates[
D].push_back(
7393 assert(!WritingAST &&
"Already writing the AST!");
7394 assert(
Delete &&
"Not given an operator delete");
7401void ASTWriter::CompletedImplicitDefinition(
const FunctionDecl *
D) {
7403 assert(!WritingAST &&
"Already writing the AST!");
7408 if (!
D->doesThisDeclarationHaveABody())
7415void ASTWriter::VariableDefinitionInstantiated(
const VarDecl *
D) {
7417 assert(!WritingAST &&
"Already writing the AST!");
7424void ASTWriter::FunctionDefinitionInstantiated(
const FunctionDecl *
D) {
7426 assert(!WritingAST &&
"Already writing the AST!");
7431 if (!
D->doesThisDeclarationHaveABody())
7437void ASTWriter::InstantiationRequested(
const ValueDecl *
D) {
7439 assert(!WritingAST &&
"Already writing the AST!");
7446 if (
auto *VD = dyn_cast<VarDecl>(
D))
7447 POI = VD->getPointOfInstantiation();
7449 POI = cast<FunctionDecl>(
D)->getPointOfInstantiation();
7453void ASTWriter::DefaultArgumentInstantiated(
const ParmVarDecl *
D) {
7455 assert(!WritingAST &&
"Already writing the AST!");
7459 DeclUpdates[
D].push_back(
7463void ASTWriter::DefaultMemberInitializerInstantiated(
const FieldDecl *
D) {
7464 assert(!WritingAST &&
"Already writing the AST!");
7468 DeclUpdates[
D].push_back(
7475 assert(!WritingAST &&
"Already writing the AST!");
7479 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
7480 ObjCClassesWithCategories.insert(
7484void ASTWriter::DeclarationMarkedUsed(
const Decl *
D) {
7486 assert(!WritingAST &&
"Already writing the AST!");
7498void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(
const Decl *
D) {
7500 assert(!WritingAST &&
"Already writing the AST!");
7507void ASTWriter::DeclarationMarkedOpenMPAllocate(
const Decl *
D,
const Attr *A) {
7509 assert(!WritingAST &&
"Already writing the AST!");
7516void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(
const Decl *
D,
7519 assert(!WritingAST &&
"Already writing the AST!");
7523 DeclUpdates[
D].push_back(
7529 assert(!WritingAST &&
"Already writing the AST!");
7534void ASTWriter::AddedAttributeToRecord(
const Attr *
Attr,
7537 assert(!WritingAST &&
"Already writing the AST!");
7538 if (!
Record->isFromASTFile())
7543void ASTWriter::AddedCXXTemplateSpecialization(
7545 assert(!WritingAST &&
"Already writing the AST!");
7552 DeclsToEmitEvenIfUnreferenced.push_back(
D);
7555void ASTWriter::AddedCXXTemplateSpecialization(
7557 assert(!WritingAST &&
"Already writing the AST!");
7564 DeclsToEmitEvenIfUnreferenced.push_back(
D);
7569 assert(!WritingAST &&
"Already writing the AST!");
7576 DeclsToEmitEvenIfUnreferenced.push_back(
D);
7590#define GEN_CLANG_CLAUSE_CLASS
7591#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
7592#include "llvm/Frontend/OpenMP/OMP.inc"
7601 OMPClauseWriter(*this).writeClause(
C);
7604void OMPClauseWriter::writeClause(
OMPClause *
C) {
7605 Record.push_back(
unsigned(
C->getClauseKind()));
7607 Record.AddSourceLocation(
C->getBeginLoc());
7608 Record.AddSourceLocation(
C->getEndLoc());
7612 Record.push_back(uint64_t(
C->getCaptureRegion()));
7613 Record.AddStmt(
C->getPreInitStmt());
7617 VisitOMPClauseWithPreInit(
C);
7618 Record.AddStmt(
C->getPostUpdateExpr());
7621void OMPClauseWriter::VisitOMPIfClause(
OMPIfClause *
C) {
7622 VisitOMPClauseWithPreInit(
C);
7624 Record.AddSourceLocation(
C->getNameModifierLoc());
7625 Record.AddSourceLocation(
C->getColonLoc());
7626 Record.AddStmt(
C->getCondition());
7627 Record.AddSourceLocation(
C->getLParenLoc());
7631 VisitOMPClauseWithPreInit(
C);
7632 Record.AddStmt(
C->getCondition());
7633 Record.AddSourceLocation(
C->getLParenLoc());
7637 VisitOMPClauseWithPreInit(
C);
7638 Record.AddStmt(
C->getNumThreads());
7639 Record.AddSourceLocation(
C->getLParenLoc());
7643 Record.AddStmt(
C->getSafelen());
7644 Record.AddSourceLocation(
C->getLParenLoc());
7648 Record.AddStmt(
C->getSimdlen());
7649 Record.AddSourceLocation(
C->getLParenLoc());
7653 Record.push_back(
C->getNumSizes());
7654 for (
Expr *Size :
C->getSizesRefs())
7656 Record.AddSourceLocation(
C->getLParenLoc());
7660 Record.push_back(
C->getNumLoops());
7661 for (
Expr *Size :
C->getArgsRefs())
7663 Record.AddSourceLocation(
C->getLParenLoc());
7669 Record.AddStmt(
C->getFactor());
7670 Record.AddSourceLocation(
C->getLParenLoc());
7674 Record.AddStmt(
C->getAllocator());
7675 Record.AddSourceLocation(
C->getLParenLoc());
7679 Record.AddStmt(
C->getNumForLoops());
7680 Record.AddSourceLocation(
C->getLParenLoc());
7684 Record.AddStmt(
C->getEventHandler());
7685 Record.AddSourceLocation(
C->getLParenLoc());
7689 Record.push_back(
unsigned(
C->getDefaultKind()));
7690 Record.AddSourceLocation(
C->getLParenLoc());
7691 Record.AddSourceLocation(
C->getDefaultKindKwLoc());
7695 Record.push_back(
unsigned(
C->getProcBindKind()));
7696 Record.AddSourceLocation(
C->getLParenLoc());
7697 Record.AddSourceLocation(
C->getProcBindKindKwLoc());
7701 VisitOMPClauseWithPreInit(
C);
7702 Record.push_back(
C->getScheduleKind());
7703 Record.push_back(
C->getFirstScheduleModifier());
7704 Record.push_back(
C->getSecondScheduleModifier());
7705 Record.AddStmt(
C->getChunkSize());
7706 Record.AddSourceLocation(
C->getLParenLoc());
7707 Record.AddSourceLocation(
C->getFirstScheduleModifierLoc());
7708 Record.AddSourceLocation(
C->getSecondScheduleModifierLoc());
7709 Record.AddSourceLocation(
C->getScheduleKindLoc());
7710 Record.AddSourceLocation(
C->getCommaLoc());
7714 Record.push_back(
C->getLoopNumIterations().size());
7715 Record.AddStmt(
C->getNumForLoops());
7716 for (
Expr *NumIter :
C->getLoopNumIterations())
7718 for (
unsigned I = 0,
E =
C->getLoopNumIterations().size(); I <
E; ++I)
7719 Record.AddStmt(
C->getLoopCounter(I));
7720 Record.AddSourceLocation(
C->getLParenLoc());
7734 Record.push_back(
C->isExtended() ? 1 : 0);
7735 if (
C->isExtended()) {
7736 Record.AddSourceLocation(
C->getLParenLoc());
7737 Record.AddSourceLocation(
C->getArgumentLoc());
7738 Record.writeEnum(
C->getDependencyKind());
7748 Record.AddSourceLocation(
C->getLParenLoc());
7749 Record.AddSourceLocation(
C->getFailParameterLoc());
7750 Record.writeEnum(
C->getFailParameter());
7758 Record.push_back(
static_cast<uint64_t>(
C->getDirectiveKinds().size()));
7759 Record.AddSourceLocation(
C->getLParenLoc());
7760 for (
auto K :
C->getDirectiveKinds()) {
7767 Record.AddSourceLocation(
C->getLParenLoc());
7771 Record.push_back(
static_cast<uint64_t>(
C->getDirectiveKinds().size()));
7772 Record.AddSourceLocation(
C->getLParenLoc());
7773 for (
auto K :
C->getDirectiveKinds()) {
7780void OMPClauseWriter::VisitOMPNoOpenMPRoutinesClause(
7800 Record.push_back(
C->varlist_size());
7801 for (
Expr *VE :
C->varlist())
7803 Record.writeBool(
C->getIsTarget());
7804 Record.writeBool(
C->getIsTargetSync());
7805 Record.AddSourceLocation(
C->getLParenLoc());
7806 Record.AddSourceLocation(
C->getVarLoc());
7810 Record.AddStmt(
C->getInteropVar());
7811 Record.AddSourceLocation(
C->getLParenLoc());
7812 Record.AddSourceLocation(
C->getVarLoc());
7816 Record.AddStmt(
C->getInteropVar());
7817 Record.AddSourceLocation(
C->getLParenLoc());
7818 Record.AddSourceLocation(
C->getVarLoc());
7822 VisitOMPClauseWithPreInit(
C);
7823 Record.AddStmt(
C->getCondition());
7824 Record.AddSourceLocation(
C->getLParenLoc());
7828 VisitOMPClauseWithPreInit(
C);
7829 Record.AddStmt(
C->getCondition());
7830 Record.AddSourceLocation(
C->getLParenLoc());
7834 VisitOMPClauseWithPreInit(
C);
7835 Record.AddStmt(
C->getThreadID());
7836 Record.AddSourceLocation(
C->getLParenLoc());
7840 Record.AddStmt(
C->getAlignment());
7841 Record.AddSourceLocation(
C->getLParenLoc());
7845 Record.push_back(
C->varlist_size());
7846 Record.AddSourceLocation(
C->getLParenLoc());
7847 for (
auto *VE :
C->varlist()) {
7850 for (
auto *VE :
C->private_copies()) {
7856 Record.push_back(
C->varlist_size());
7857 VisitOMPClauseWithPreInit(
C);
7858 Record.AddSourceLocation(
C->getLParenLoc());
7859 for (
auto *VE :
C->varlist()) {
7862 for (
auto *VE :
C->private_copies()) {
7865 for (
auto *VE :
C->inits()) {
7871 Record.push_back(
C->varlist_size());
7872 VisitOMPClauseWithPostUpdate(
C);
7873 Record.AddSourceLocation(
C->getLParenLoc());
7874 Record.writeEnum(
C->getKind());
7875 Record.AddSourceLocation(
C->getKindLoc());
7876 Record.AddSourceLocation(
C->getColonLoc());
7877 for (
auto *VE :
C->varlist())
7879 for (
auto *
E :
C->private_copies())
7881 for (
auto *
E :
C->source_exprs())
7883 for (
auto *
E :
C->destination_exprs())
7885 for (
auto *
E :
C->assignment_ops())
7890 Record.push_back(
C->varlist_size());
7891 Record.AddSourceLocation(
C->getLParenLoc());
7892 for (
auto *VE :
C->varlist())
7897 Record.push_back(
C->varlist_size());
7898 Record.writeEnum(
C->getModifier());
7899 VisitOMPClauseWithPostUpdate(
C);
7900 Record.AddSourceLocation(
C->getLParenLoc());
7901 Record.AddSourceLocation(
C->getModifierLoc());
7902 Record.AddSourceLocation(
C->getColonLoc());
7903 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
7904 Record.AddDeclarationNameInfo(
C->getNameInfo());
7905 for (
auto *VE :
C->varlist())
7907 for (
auto *VE :
C->privates())
7909 for (
auto *
E :
C->lhs_exprs())
7911 for (
auto *
E :
C->rhs_exprs())
7913 for (
auto *
E :
C->reduction_ops())
7915 if (
C->getModifier() == clang::OMPC_REDUCTION_inscan) {
7916 for (
auto *
E :
C->copy_ops())
7918 for (
auto *
E :
C->copy_array_temps())
7920 for (
auto *
E :
C->copy_array_elems())
7926 Record.push_back(
C->varlist_size());
7927 VisitOMPClauseWithPostUpdate(
C);
7928 Record.AddSourceLocation(
C->getLParenLoc());
7929 Record.AddSourceLocation(
C->getColonLoc());
7930 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
7931 Record.AddDeclarationNameInfo(
C->getNameInfo());
7932 for (
auto *VE :
C->varlist())
7934 for (
auto *VE :
C->privates())
7936 for (
auto *
E :
C->lhs_exprs())
7938 for (
auto *
E :
C->rhs_exprs())
7940 for (
auto *
E :
C->reduction_ops())
7945 Record.push_back(
C->varlist_size());
7946 VisitOMPClauseWithPostUpdate(
C);
7947 Record.AddSourceLocation(
C->getLParenLoc());
7948 Record.AddSourceLocation(
C->getColonLoc());
7949 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
7950 Record.AddDeclarationNameInfo(
C->getNameInfo());
7951 for (
auto *VE :
C->varlist())
7953 for (
auto *VE :
C->privates())
7955 for (
auto *
E :
C->lhs_exprs())
7957 for (
auto *
E :
C->rhs_exprs())
7959 for (
auto *
E :
C->reduction_ops())
7961 for (
auto *
E :
C->taskgroup_descriptors())
7966 Record.push_back(
C->varlist_size());
7967 VisitOMPClauseWithPostUpdate(
C);
7968 Record.AddSourceLocation(
C->getLParenLoc());
7969 Record.AddSourceLocation(
C->getColonLoc());
7970 Record.push_back(
C->getModifier());
7971 Record.AddSourceLocation(
C->getModifierLoc());
7972 for (
auto *VE :
C->varlist()) {
7975 for (
auto *VE :
C->privates()) {
7978 for (
auto *VE :
C->inits()) {
7981 for (
auto *VE :
C->updates()) {
7984 for (
auto *VE :
C->finals()) {
7988 Record.AddStmt(
C->getCalcStep());
7989 for (
auto *VE :
C->used_expressions())
7994 Record.push_back(
C->varlist_size());
7995 Record.AddSourceLocation(
C->getLParenLoc());
7996 Record.AddSourceLocation(
C->getColonLoc());
7997 for (
auto *VE :
C->varlist())
7999 Record.AddStmt(
C->getAlignment());
8003 Record.push_back(
C->varlist_size());
8004 Record.AddSourceLocation(
C->getLParenLoc());
8005 for (
auto *VE :
C->varlist())
8007 for (
auto *
E :
C->source_exprs())
8009 for (
auto *
E :
C->destination_exprs())
8011 for (
auto *
E :
C->assignment_ops())
8016 Record.push_back(
C->varlist_size());
8017 Record.AddSourceLocation(
C->getLParenLoc());
8018 for (
auto *VE :
C->varlist())
8020 for (
auto *
E :
C->source_exprs())
8022 for (
auto *
E :
C->destination_exprs())
8024 for (
auto *
E :
C->assignment_ops())
8029 Record.push_back(
C->varlist_size());
8030 Record.AddSourceLocation(
C->getLParenLoc());
8031 for (
auto *VE :
C->varlist())
8036 Record.AddStmt(
C->getDepobj());
8037 Record.AddSourceLocation(
C->getLParenLoc());
8041 Record.push_back(
C->varlist_size());
8042 Record.push_back(
C->getNumLoops());
8043 Record.AddSourceLocation(
C->getLParenLoc());
8044 Record.AddStmt(
C->getModifier());
8045 Record.push_back(
C->getDependencyKind());
8046 Record.AddSourceLocation(
C->getDependencyLoc());
8047 Record.AddSourceLocation(
C->getColonLoc());
8048 Record.AddSourceLocation(
C->getOmpAllMemoryLoc());
8049 for (
auto *VE :
C->varlist())
8051 for (
unsigned I = 0,
E =
C->getNumLoops(); I <
E; ++I)
8052 Record.AddStmt(
C->getLoopData(I));
8056 VisitOMPClauseWithPreInit(
C);
8057 Record.writeEnum(
C->getModifier());
8058 Record.AddStmt(
C->getDevice());
8059 Record.AddSourceLocation(
C->getModifierLoc());
8060 Record.AddSourceLocation(
C->getLParenLoc());
8064 Record.push_back(
C->varlist_size());
8065 Record.push_back(
C->getUniqueDeclarationsNum());
8066 Record.push_back(
C->getTotalComponentListNum());
8067 Record.push_back(
C->getTotalComponentsNum());
8068 Record.AddSourceLocation(
C->getLParenLoc());
8069 bool HasIteratorModifier =
false;
8071 Record.push_back(
C->getMapTypeModifier(I));
8072 Record.AddSourceLocation(
C->getMapTypeModifierLoc(I));
8073 if (
C->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator)
8074 HasIteratorModifier =
true;
8076 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8077 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8078 Record.push_back(
C->getMapType());
8079 Record.AddSourceLocation(
C->getMapLoc());
8080 Record.AddSourceLocation(
C->getColonLoc());
8081 for (
auto *
E :
C->varlist())
8083 for (
auto *
E :
C->mapperlists())
8085 if (HasIteratorModifier)
8086 Record.AddStmt(
C->getIteratorModifier());
8087 for (
auto *
D :
C->all_decls())
8089 for (
auto N :
C->all_num_lists())
8091 for (
auto N :
C->all_lists_sizes())
8093 for (
auto &M :
C->all_components()) {
8094 Record.AddStmt(M.getAssociatedExpression());
8095 Record.AddDeclRef(M.getAssociatedDeclaration());
8100 Record.push_back(
C->varlist_size());
8101 Record.writeEnum(
C->getFirstAllocateModifier());
8102 Record.writeEnum(
C->getSecondAllocateModifier());
8103 Record.AddSourceLocation(
C->getLParenLoc());
8104 Record.AddSourceLocation(
C->getColonLoc());
8105 Record.AddStmt(
C->getAllocator());
8106 Record.AddStmt(
C->getAlignment());
8107 for (
auto *VE :
C->varlist())
8112 Record.push_back(
C->varlist_size());
8113 VisitOMPClauseWithPreInit(
C);
8114 Record.AddSourceLocation(
C->getLParenLoc());
8115 for (
auto *VE :
C->varlist())
8120 Record.push_back(
C->varlist_size());
8121 VisitOMPClauseWithPreInit(
C);
8122 Record.AddSourceLocation(
C->getLParenLoc());
8123 for (
auto *VE :
C->varlist())
8128 VisitOMPClauseWithPreInit(
C);
8129 Record.AddStmt(
C->getPriority());
8130 Record.AddSourceLocation(
C->getLParenLoc());
8134 VisitOMPClauseWithPreInit(
C);
8135 Record.writeEnum(
C->getModifier());
8136 Record.AddStmt(
C->getGrainsize());
8137 Record.AddSourceLocation(
C->getModifierLoc());
8138 Record.AddSourceLocation(
C->getLParenLoc());
8142 VisitOMPClauseWithPreInit(
C);
8143 Record.writeEnum(
C->getModifier());
8144 Record.AddStmt(
C->getNumTasks());
8145 Record.AddSourceLocation(
C->getModifierLoc());
8146 Record.AddSourceLocation(
C->getLParenLoc());
8151 Record.AddSourceLocation(
C->getLParenLoc());
8155 VisitOMPClauseWithPreInit(
C);
8156 Record.push_back(
C->getDistScheduleKind());
8157 Record.AddStmt(
C->getChunkSize());
8158 Record.AddSourceLocation(
C->getLParenLoc());
8159 Record.AddSourceLocation(
C->getDistScheduleKindLoc());
8160 Record.AddSourceLocation(
C->getCommaLoc());
8164 Record.push_back(
C->getDefaultmapKind());
8165 Record.push_back(
C->getDefaultmapModifier());
8166 Record.AddSourceLocation(
C->getLParenLoc());
8167 Record.AddSourceLocation(
C->getDefaultmapModifierLoc());
8168 Record.AddSourceLocation(
C->getDefaultmapKindLoc());
8171void OMPClauseWriter::VisitOMPToClause(
OMPToClause *
C) {
8172 Record.push_back(
C->varlist_size());
8173 Record.push_back(
C->getUniqueDeclarationsNum());
8174 Record.push_back(
C->getTotalComponentListNum());
8175 Record.push_back(
C->getTotalComponentsNum());
8176 Record.AddSourceLocation(
C->getLParenLoc());
8178 Record.push_back(
C->getMotionModifier(I));
8179 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
8181 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8182 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8183 Record.AddSourceLocation(
C->getColonLoc());
8184 for (
auto *
E :
C->varlist())
8186 for (
auto *
E :
C->mapperlists())
8188 for (
auto *
D :
C->all_decls())
8190 for (
auto N :
C->all_num_lists())
8192 for (
auto N :
C->all_lists_sizes())
8194 for (
auto &M :
C->all_components()) {
8195 Record.AddStmt(M.getAssociatedExpression());
8196 Record.writeBool(M.isNonContiguous());
8197 Record.AddDeclRef(M.getAssociatedDeclaration());
8202 Record.push_back(
C->varlist_size());
8203 Record.push_back(
C->getUniqueDeclarationsNum());
8204 Record.push_back(
C->getTotalComponentListNum());
8205 Record.push_back(
C->getTotalComponentsNum());
8206 Record.AddSourceLocation(
C->getLParenLoc());
8208 Record.push_back(
C->getMotionModifier(I));
8209 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
8211 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
8212 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
8213 Record.AddSourceLocation(
C->getColonLoc());
8214 for (
auto *
E :
C->varlist())
8216 for (
auto *
E :
C->mapperlists())
8218 for (
auto *
D :
C->all_decls())
8220 for (
auto N :
C->all_num_lists())
8222 for (
auto N :
C->all_lists_sizes())
8224 for (
auto &M :
C->all_components()) {
8225 Record.AddStmt(M.getAssociatedExpression());
8226 Record.writeBool(M.isNonContiguous());
8227 Record.AddDeclRef(M.getAssociatedDeclaration());
8232 Record.push_back(
C->varlist_size());
8233 Record.push_back(
C->getUniqueDeclarationsNum());
8234 Record.push_back(
C->getTotalComponentListNum());
8235 Record.push_back(
C->getTotalComponentsNum());
8236 Record.AddSourceLocation(
C->getLParenLoc());
8237 for (
auto *
E :
C->varlist())
8239 for (
auto *VE :
C->private_copies())
8241 for (
auto *VE :
C->inits())
8243 for (
auto *
D :
C->all_decls())
8245 for (
auto N :
C->all_num_lists())
8247 for (
auto N :
C->all_lists_sizes())
8249 for (
auto &M :
C->all_components()) {
8250 Record.AddStmt(M.getAssociatedExpression());
8251 Record.AddDeclRef(M.getAssociatedDeclaration());
8256 Record.push_back(
C->varlist_size());
8257 Record.push_back(
C->getUniqueDeclarationsNum());
8258 Record.push_back(
C->getTotalComponentListNum());
8259 Record.push_back(
C->getTotalComponentsNum());
8260 Record.AddSourceLocation(
C->getLParenLoc());
8261 for (
auto *
E :
C->varlist())
8263 for (
auto *
D :
C->all_decls())
8265 for (
auto N :
C->all_num_lists())
8267 for (
auto N :
C->all_lists_sizes())
8269 for (
auto &M :
C->all_components()) {
8270 Record.AddStmt(M.getAssociatedExpression());
8271 Record.AddDeclRef(M.getAssociatedDeclaration());
8276 Record.push_back(
C->varlist_size());
8277 Record.push_back(
C->getUniqueDeclarationsNum());
8278 Record.push_back(
C->getTotalComponentListNum());
8279 Record.push_back(
C->getTotalComponentsNum());
8280 Record.AddSourceLocation(
C->getLParenLoc());
8281 for (
auto *
E :
C->varlist())
8283 for (
auto *
D :
C->all_decls())
8285 for (
auto N :
C->all_num_lists())
8287 for (
auto N :
C->all_lists_sizes())
8289 for (
auto &M :
C->all_components()) {
8290 Record.AddStmt(M.getAssociatedExpression());
8291 Record.AddDeclRef(M.getAssociatedDeclaration());
8296 Record.push_back(
C->varlist_size());
8297 Record.push_back(
C->getUniqueDeclarationsNum());
8298 Record.push_back(
C->getTotalComponentListNum());
8299 Record.push_back(
C->getTotalComponentsNum());
8300 Record.AddSourceLocation(
C->getLParenLoc());
8301 for (
auto *
E :
C->varlist())
8303 for (
auto *
D :
C->all_decls())
8305 for (
auto N :
C->all_num_lists())
8307 for (
auto N :
C->all_lists_sizes())
8309 for (
auto &M :
C->all_components()) {
8310 Record.AddStmt(M.getAssociatedExpression());
8311 Record.AddDeclRef(M.getAssociatedDeclaration());
8317void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
8326void OMPClauseWriter::VisitOMPAtomicDefaultMemOrderClause(
8328 Record.push_back(
C->getAtomicDefaultMemOrderKind());
8329 Record.AddSourceLocation(
C->getLParenLoc());
8330 Record.AddSourceLocation(
C->getAtomicDefaultMemOrderKindKwLoc());
8333void OMPClauseWriter::VisitOMPAtClause(
OMPAtClause *
C) {
8334 Record.push_back(
C->getAtKind());
8335 Record.AddSourceLocation(
C->getLParenLoc());
8336 Record.AddSourceLocation(
C->getAtKindKwLoc());
8340 Record.push_back(
C->getSeverityKind());
8341 Record.AddSourceLocation(
C->getLParenLoc());
8342 Record.AddSourceLocation(
C->getSeverityKindKwLoc());
8346 Record.AddStmt(
C->getMessageString());
8347 Record.AddSourceLocation(
C->getLParenLoc());
8351 Record.push_back(
C->varlist_size());
8352 Record.AddSourceLocation(
C->getLParenLoc());
8353 for (
auto *VE :
C->varlist())
8355 for (
auto *
E :
C->private_refs())
8360 Record.push_back(
C->varlist_size());
8361 Record.AddSourceLocation(
C->getLParenLoc());
8362 for (
auto *VE :
C->varlist())
8367 Record.push_back(
C->varlist_size());
8368 Record.AddSourceLocation(
C->getLParenLoc());
8369 for (
auto *VE :
C->varlist())
8374 Record.writeEnum(
C->getKind());
8375 Record.writeEnum(
C->getModifier());
8376 Record.AddSourceLocation(
C->getLParenLoc());
8377 Record.AddSourceLocation(
C->getKindKwLoc());
8378 Record.AddSourceLocation(
C->getModifierKwLoc());
8382 Record.push_back(
C->getNumberOfAllocators());
8383 Record.AddSourceLocation(
C->getLParenLoc());
8384 for (
unsigned I = 0,
E =
C->getNumberOfAllocators(); I <
E; ++I) {
8394 Record.push_back(
C->varlist_size());
8395 Record.AddSourceLocation(
C->getLParenLoc());
8396 Record.AddStmt(
C->getModifier());
8397 Record.AddSourceLocation(
C->getColonLoc());
8398 for (
Expr *
E :
C->varlist())
8403 Record.writeEnum(
C->getBindKind());
8404 Record.AddSourceLocation(
C->getLParenLoc());
8405 Record.AddSourceLocation(
C->getBindKindLoc());
8409 VisitOMPClauseWithPreInit(
C);
8411 Record.AddSourceLocation(
C->getLParenLoc());
8415 Record.push_back(
C->varlist_size());
8416 Record.push_back(
C->getNumLoops());
8417 Record.AddSourceLocation(
C->getLParenLoc());
8418 Record.push_back(
C->getDependenceType());
8419 Record.AddSourceLocation(
C->getDependenceLoc());
8420 Record.AddSourceLocation(
C->getColonLoc());
8421 for (
auto *VE :
C->varlist())
8423 for (
unsigned I = 0,
E =
C->getNumLoops(); I <
E; ++I)
8424 Record.AddStmt(
C->getLoopData(I));
8428 Record.AddAttributes(
C->getAttrs());
8429 Record.AddSourceLocation(
C->getBeginLoc());
8430 Record.AddSourceLocation(
C->getLParenLoc());
8431 Record.AddSourceLocation(
C->getEndLoc());
8438 for (
const auto &
Set : TI->
Sets) {
8445 writeExprRef(
Selector.ScoreOrCondition);
8459 for (
unsigned I = 0,
E =
Data->getNumClauses(); I <
E; ++I)
8461 if (
Data->hasAssociatedStmt())
8463 for (
unsigned I = 0,
E =
Data->getNumChildren(); I <
E; ++I)
8469 for (
Expr *
E :
C->getVarList())
8475 for (
Expr *
E : Exprs)
8484 switch (
C->getClauseKind()) {
8486 const auto *DC = cast<OpenACCDefaultClause>(
C);
8492 const auto *IC = cast<OpenACCIfClause>(
C);
8494 AddStmt(
const_cast<Expr*
>(IC->getConditionExpr()));
8498 const auto *SC = cast<OpenACCSelfClause>(
C);
8501 if (SC->isConditionExprClause()) {
8503 if (SC->hasConditionExpr())
8504 AddStmt(
const_cast<Expr *
>(SC->getConditionExpr()));
8507 for (
Expr *
E : SC->getVarList())
8513 const auto *NGC = cast<OpenACCNumGangsClause>(
C);
8516 for (
Expr *
E : NGC->getIntExprs())
8521 const auto *DNC = cast<OpenACCDeviceNumClause>(
C);
8527 const auto *DAC = cast<OpenACCDefaultAsyncClause>(
C);
8533 const auto *NWC = cast<OpenACCNumWorkersClause>(
C);
8539 const auto *NWC = cast<OpenACCVectorLengthClause>(
C);
8545 const auto *PC = cast<OpenACCPrivateClause>(
C);
8551 const auto *HC = cast<OpenACCHostClause>(
C);
8557 const auto *DC = cast<OpenACCDeviceClause>(
C);
8563 const auto *FPC = cast<OpenACCFirstPrivateClause>(
C);
8569 const auto *AC = cast<OpenACCAttachClause>(
C);
8575 const auto *DC = cast<OpenACCDetachClause>(
C);
8581 const auto *DC = cast<OpenACCDeleteClause>(
C);
8587 const auto *UDC = cast<OpenACCUseDeviceClause>(
C);
8593 const auto *DPC = cast<OpenACCDevicePtrClause>(
C);
8599 const auto *NCC = cast<OpenACCNoCreateClause>(
C);
8605 const auto *PC = cast<OpenACCPresentClause>(
C);
8613 const auto *CC = cast<OpenACCCopyClause>(
C);
8621 const auto *CIC = cast<OpenACCCopyInClause>(
C);
8630 const auto *COC = cast<OpenACCCopyOutClause>(
C);
8639 const auto *CC = cast<OpenACCCreateClause>(
C);
8646 const auto *AC = cast<OpenACCAsyncClause>(
C);
8649 if (AC->hasIntExpr())
8654 const auto *WC = cast<OpenACCWaitClause>(
C);
8657 if (
Expr *DNE = WC->getDevNumExpr())
8666 const auto *DTC = cast<OpenACCDeviceTypeClause>(
C);
8678 const auto *RC = cast<OpenACCReductionClause>(
C);
8693 const auto *CC = cast<OpenACCCollapseClause>(
C);
8700 const auto *TC = cast<OpenACCTileClause>(
C);
8703 for (
Expr *
E : TC->getSizeExprs())
8708 const auto *GC = cast<OpenACCGangClause>(
C);
8711 for (
unsigned I = 0; I < GC->getNumExprs(); ++I) {
8713 AddStmt(
const_cast<Expr *
>(GC->getExpr(I).second));
8718 const auto *WC = cast<OpenACCWorkerClause>(
C);
8721 if (WC->hasIntExpr())
8726 const auto *VC = cast<OpenACCVectorClause>(
C);
8729 if (VC->hasIntExpr())
8739 llvm_unreachable(
"Clause serialization not yet implemented");
8741 llvm_unreachable(
"Invalid Clause Kind");
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 ture 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.
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
DeclarationNameTable DeclarationNames
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.
QualType getRecordType(const RecordDecl *Decl) const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
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.
QualType getjmp_bufType() const
Retrieve the C jmp_buf type.
QualType getsigjmp_bufType() const
Retrieve the C sigjmp_buf type.
QualType AutoRRefDeductTy
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
Reads an AST files chain containing the contents of a translation unit.
ModuleManager & getModuleManager()
Retrieve the module manager.
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
const serialization::reader::ModuleLocalLookupTable * getModuleLocalLookupTables(DeclContext *Primary) const
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
void forEachImportedKeyDecl(const Decl *D, Fn Visit)
Run a callback on each imported key declaration of D.
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
Decl * getKeyDeclaration(Decl *D)
Returns the first key declaration for the given declaration.
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
bool isProcessingUpdateRecords()
serialization::reader::LazySpecializationInfoLookupTable * getLoadedSpecializationsLookupTables(const Decl *D, bool IsPartial)
Get the loaded specializations lookup tables for D, if any.
unsigned getTotalNumMacros() const
Returns the number of macros found in the chain.
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 AddSelectorRef(Selector S)
Emit a Selector (which is a smart pointer reference).
void AddSourceRange(SourceRange Range, LocSeq *Seq=nullptr)
Emit a source range.
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 writeQualType(QualType T)
void writeOpenACCClauseList(ArrayRef< const OpenACCClause * > Clauses)
Writes out a list of OpenACC clauses.
void AddSourceLocation(SourceLocation Loc, LocSeq *Seq=nullptr)
Emit a source location.
void push_back(uint64_t N)
Minimal vector-like interface.
void AddTypeLoc(TypeLoc TL, LocSeq *Seq=nullptr)
Emits source location information for a type. Does not emit the type.
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 AddAPInt(const llvm::APInt &Value)
Emit an integral value.
void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, const TemplateArgumentLocInfo &Arg)
Emits a template argument location info.
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 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.
Writes an AST file containing the contents of a translation unit.
serialization::MacroID getMacroID(MacroInfo *MI)
Determine the ID of an already-emitted macro.
void AddEmittedDeclRef(const Decl *D, RecordDataImpl &Record)
void AddSourceRange(SourceRange Range, RecordDataImpl &Record, LocSeq *Seq=nullptr)
Emit a source range.
bool isWritingStdCXXNamedModules() const
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.
unsigned getTypeExtQualAbbrev() const
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)? This is the case for...
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.
LocalDeclID getDeclID(const Decl *D)
Determine the local declaration ID of an already-emitted declaration.
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.
void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record, LocSeq *Seq=nullptr)
Emit a source location.
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.
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.
serialization::SelectorID getSelectorRef(Selector Sel)
Get the unique number used to refer to the given selector.
SourceLocationEncoding::RawLocEncoding getRawSourceLocationEncoding(SourceLocation Loc, LocSeq *Seq=nullptr)
Return the raw encodings for source locations.
ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl< char > &Buffer, InMemoryModuleCache &ModuleCache, 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.
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)
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 array parameter types.
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
Type source information for an attributed type.
const Attr * getAttr() const
The type attribute.
SourceLocation getRParenLoc() const
bool isDecltypeAuto() const
bool isConstrained() const
ConceptReference * getConceptReference() const
Type source information for an btf_tag attributed type.
A simple helper class to pack several bits in order into (a) 32 bit integer(s).
void addBits(uint32_t Value, uint32_t BitsWidth)
Wrapper for source info for block pointers.
SourceLocation getCaretLoc() const
Wrapper for source info for builtin types.
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.
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...
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
ConceptDecl * getNamedConcept() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
SourceLocation getTemplateKWLoc() const
Wrapper for source info for pointers decayed from arrays and functions.
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isFileContext() const
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
A helper iterator adaptor to convert the iterators to SmallVector<SomeDeclID> to the iterators to Sma...
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 ...
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
SourceLocation getDecltypeLoc() const
SourceLocation getRParenLoc() const
SourceLocation getTemplateNameLoc() 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
unsigned getNumArgs() const
SourceLocation getTemplateNameLoc() const
SourceLocation getLAngleLoc() const
SourceLocation getTemplateKeywordLoc() const
TemplateArgumentLoc getArgLoc(unsigned i) const
SourceLocation getRAngleLoc() const
SourceLocation getElaboratedKeywordLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
SourceLocation getNameLoc() const
static DiagnosticMapping getDefaultMapping(unsigned DiagID)
Get the default mapping for this diagnostic.
Options for controlling the compiler diagnostics engine.
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.
Concrete class used by the front-end to report problems and issues.
StringRef getName() const
SourceLocation getElaboratedKeywordLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
Wrapper for source info for enum types.
This represents one expression.
Represents difference between two FPOptions values.
storage_type getAsOpaqueInt() const
storage_type getAsOpaqueInt() const
Represents a member of a struct/union/class.
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
StringRef getName() const
The name of this FileEntry.
Cached information about one file (either on disk or in the virtual file system).
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
void GetUniqueIDMapping(SmallVectorImpl< OptionalFileEntryRef > &UIDToFiles) const
Produce an array mapping from the unique IDs assigned to each file to the corresponding FileEntryRef.
bool makeAbsolutePath(SmallVectorImpl< char > &Path) const
Makes Path absolute taking into account FileSystemOptions and the working directory option.
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.
Keeps track of options that affect how file operations are performed.
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.
Represents a prototype with parameter type info, e.g.
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
Type source information for HLSL attributed resource type.
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 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.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
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'.
Implements an efficient mapping from strings to IdentifierInfo nodes.
In-memory cache for modules.
llvm::MemoryBuffer & addBuiltPCM(llvm::StringRef Filename, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Store a just-built PCM under the Filename.
Wrapper for source info for injected class names of class templates.
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 ...
Used to hold and unique data used to represent #line information.
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.
Wrapper for source info for member pointers.
TypeSourceInfo * getClassTInfo() const
SourceLocation getStarLoc() const
Abstract base class that writes a module file extension block into a module file.
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.
std::string PresumedModuleMapFile
The presumed file name for the module map defining this module.
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.
bool isHeaderUnit() const
Is this module a header unit.
@ ModuleMapModule
This is a module that was defined by a module map and built out of header files.
unsigned IsFramework
Whether this is a framework module.
std::string ExportAsModule
The module through which entities defined in this module will eventually be exposed,...
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
bool isNamedModule() const
Does this Module is a named module of a standard named module?
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.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
SourceRange getLocalSourceRange() const
Retrieve the source range covering just the last part of this nested-name-specifier,...
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
SpecifierKind
The kind of specifier that completes this nested name specifier.
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
@ TypeSpec
A type, stored as a Type*.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Identifier
An identifier, stored as an IdentifierInfo*.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace, stored as a NamespaceDecl*.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
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' d...
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 '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 represents clause 'map' in the '#pragma omp ...' directives.
This represents 'mergeable' clause in the '#pragma omp ...' directive.
This represents 'message' clause in the '#pragma omp error' directive.
This represents the 'no_openmp' clause in the '#pragma omp assume' directive.
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 'seq_cst' clause in the '#pragma omp atomic|flush' directives.
This represents 'severity' clause in the '#pragma omp error' directive.
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 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.
Iterator that walks over the list of categories, filtering out those that do not meet specific criter...
Represents an ObjC class declaration.
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
Wrapper for source info for ObjC interfaces.
SourceLocation getNameEndLoc() const
SourceLocation getNameLoc() const
Wraps an ObjCPointerType with source location information.
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
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
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.
OpenCL supported extensions and optional core features.
SourceLocation getEllipsisLoc() const
SourceLocation getEllipsisLoc() const
SourceLocation getRParenLoc() const
SourceLocation getLParenLoc() const
Represents a parameter to a function.
SourceLocation getKWLoc() const
Wrapper for source info for pointers.
SourceLocation getStarLoc() const
Iteration over the preprocessed entities.
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
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.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
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
SourceLocation getModuleImportLoc(Module *M) 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.
unsigned getCounterValue() const
SourceManager & getSourceManager() const
std::optional< PreambleSkipInfo > getPreambleSkipInfo() const
bool hasRecordedPreamble() const
const TargetInfo & getTargetInfo() const
FileManager & getFileManager() const
PreprocessorOptions & getPreprocessorOpts() const
Retrieve the preprocessor options used to initialize this preprocessor.
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 LangOptions & getLangOpts() const
PreprocessingRecord * getPreprocessingRecord() const
Retrieve the preprocessing record, or NULL if there is no preprocessing record.
DiagnosticsEngine & getDiagnostics() 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.
The collection of all-type qualifiers we support.
SourceLocation getAmpAmpLoc() const
Represents a struct/union/class.
Wrapper for source info for record types.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
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".
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 optimize off". 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
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, SourceLocationSequence *=nullptr)
This object establishes a SourceLocationSequence.
Serialized encoding of a sequence of SourceLocations.
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 isLoadedSourceLocation(SourceLocation Loc) const
Returns true if Loc came from a PCH/Module.
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
One instance of this struct is kept for every file loaded or used.
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.
Each ExpansionInfo encodes the expansion location - where the token was ultimately expanded,...
SourceLocation getExpansionLocStart() const
bool isExpansionTokenRange() const
SourceLocation getSpellingLoc() const
bool isMacroArgExpansion() const
SourceLocation getExpansionLocEnd() const
Information about a FileID, basically just the logical file that it represents and include stack info...
const ContentCache & getContentCache() const
This is a discriminated union of FileInfo and ExpansionInfo.
SourceLocation::UIntTy getOffset() const
const FileInfo & getFile() const
const ExpansionInfo & getExpansion() const
An array of decls optimized for the common case of only containing one entry.
Wrapper for substituted template type parameters.
Wrapper for substituted template type parameters.
Represents the declaration of a struct/union/class/enum.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Exposes information about the current target.
Options for controlling the target.
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.
TemplateArgumentLocInfo getLocInfo() const
const TemplateArgument & getArgument() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
ArgKind
The kind of template argument we're storing.
@ 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
Wrapper for template type parameters.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
unsigned getFlags() const
Return the internal represtation of the flags.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
unsigned getLength() const
SourceLocation getAnnotationEndLoc() const
void * getAnnotationValue() const
tok::TokenKind getKind() const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
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
The base class of the type hierarchy.
TypeClass getTypeClass() const
Base class for declarations which introduce a typedef-name.
Wrapper for source info for typedefs.
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
SourceLocation getTypeofLoc() const
The iterator over UnresolvedSets.
Wrapper for source info for unresolved typename using decls.
Wrapper for source info for types used via transparent aliases.
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.
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...
void writeQualifiers(Qualifiers value)
A key used when looking up entities by DeclarationName.
Information about a module that has been loaded by the ASTReader.
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
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 NumPreprocessedEntities
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 LocalNumMacros
The number of macros in this AST file.
unsigned LocalNumSelectors
The number of selectors new to this file.
ModuleKind Kind
The type of this module.
std::string ModuleName
The name of the module.
serialization::MacroID BaseMacroID
Base macro ID for macros local to this module.
Writer for the on-disk hash table.
A type index; the type ID with the qualifier bits removed.
uint32_t getModuleFileIndex() const
TypeID asTypeID(unsigned FastQuals) const
uint64_t getValue() const
Class that performs name lookup into a DeclContext stored in an AST file.
Class that performs lookup to specialized decls.
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_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)
GlobalDeclID LazySpecializationInfo
uint64_t TypeID
An ID number that refers to a type in an AST file.
@ 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)
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
@ 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.
@ LANGUAGE_OPTIONS
Record code for the language options table.
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
const unsigned int NUM_PREDEF_PP_ENTITY_IDS
The number of predefined preprocessed entity IDs.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
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.
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.
DeclIDBase::DeclID DeclID
An ID number that refers to a declaration in an AST file.
@ 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.
@ 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...
void updateModuleTimestamp(StringRef ModuleFilename)
@ 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.
uint64_t IdentifierID
An ID number that refers to an identifier in an AST file.
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
@ 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.
@ 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.
@ 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.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
unsigned ComputeHash(Selector Sel)
@ UPD_CXX_RESOLVED_DTOR_DELETE
@ UPD_CXX_INSTANTIATED_DEFAULT_MEMBER_INITIALIZER
@ UPD_CXX_DEDUCED_RETURN_TYPE
@ UPD_CXX_ADDED_IMPLICIT_MEMBER
@ UPD_DECL_MARKED_OPENMP_DECLARETARGET
@ UPD_CXX_POINT_OF_INSTANTIATION
@ UPD_CXX_RESOLVED_EXCEPTION_SPEC
@ UPD_CXX_ADDED_FUNCTION_DEFINITION
@ UPD_DECL_MARKED_OPENMP_THREADPRIVATE
@ UPD_STATIC_LOCAL_NUMBER
@ UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT
@ UPD_ADDED_ATTR_TO_RECORD
@ UPD_DECL_MARKED_OPENMP_ALLOCATE
@ UPD_CXX_ADDED_ANONYMOUS_NAMESPACE
@ UPD_CXX_INSTANTIATED_CLASS_DEFINITION
@ UPD_CXX_ADDED_VAR_DEFINITION
The JSON file list parser is used to communicate input to InstallAPI.
@ NUM_OVERLOADED_OPERATORS
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
@ LCK_ByRef
Capturing by reference.
@ LCK_VLAType
Capturing variable-length array type.
@ LCK_StarThis
Capturing the *this object by copy.
@ LCK_This
Capturing the *this object by reference.
@ Auto
'auto' clause, allowed on 'loop' directives.
@ Bind
'bind' clause, allowed on routine constructs.
@ Gang
'gang' clause, allowed on 'loop' and Combined constructs.
@ Wait
'wait' clause, allowed on Compute, Data, 'update', and Combined constructs.
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ PCopyOut
'copyout' clause alias 'pcopyout'. Preserved for diagnostic purposes.
@ VectorLength
'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop', and 'kernels loop' constru...
@ Async
'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined constructs.
@ PresentOrCreate
'create' clause alias 'present_or_create'.
@ Collapse
'collapse' clause, allowed on 'loop' and Combined constructs.
@ NoHost
'nohost' clause, allowed on 'routine' directives.
@ PresentOrCopy
'copy' clause alias 'present_or_copy'. Preserved for diagnostic purposes.
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Copy
'copy' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ Worker
'worker' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ DeviceType
'device_type' clause, allowed on Compute, 'data', 'init', 'shutdown', 'set', update',...
@ DefaultAsync
'default_async' clause, allowed on 'set' construct.
@ Attach
'attach' clause, allowed on Compute and Combined constructs, plus 'data' and 'enter data'.
@ 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.
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_COMMON_TYPE_ID
The internal '__builtin_common_type' template.
@ PREDEF_DECL_TRANSLATION_UNIT_ID
The translation unit.
@ PREDEF_DECL_TYPE_PACK_ELEMENT_ID
The internal '__type_pack_element' template.
@ PREDEF_DECL_OBJC_CLASS_ID
The Objective-C 'Class' type.
@ PREDEF_DECL_BUILTIN_MS_GUID_ID
The predeclared '_GUID' struct.
@ PREDEF_DECL_OBJC_INSTANCETYPE_ID
The internal 'instancetype' typedef.
@ PREDEF_DECL_OBJC_PROTOCOL_ID
The Objective-C 'Protocol' type.
@ PREDEF_DECL_UNSIGNED_INT_128_ID
The unsigned 128-bit integer type.
@ PREDEF_DECL_OBJC_SEL_ID
The Objective-C 'SEL' type.
@ PREDEF_DECL_INT_128_ID
The signed 128-bit integer type.
@ PREDEF_DECL_VA_LIST_TAG
The internal '__va_list_tag' struct, if any.
@ PREDEF_DECL_BUILTIN_MS_VA_LIST_ID
The internal '__builtin_ms_va_list' typedef.
@ PREDEF_DECL_CF_CONSTANT_STRING_ID
The internal '__NSConstantString' typedef.
@ PREDEF_DECL_BUILTIN_VA_LIST_ID
The internal '__builtin_va_list' typedef.
@ PREDEF_DECL_EXTERN_C_CONTEXT_ID
The extern "C" context.
@ PREDEF_DECL_OBJC_ID_ID
The Objective-C 'id' type.
@ PREDEF_DECL_MAKE_INTEGER_SEQ_ID
The internal '__make_integer_seq' template.
@ Property
The type of a property.
@ Result
The result type of a method or function.
bool CanElideDeclDef(const Decl *D)
If we can elide the definition of.
std::pair< IdentifierInfo *, SourceLocation > DeviceTypeArgument
static constexpr unsigned NumberOfOMPMotionModifiers
Number of allowed motion-modifiers.
std::optional< unsigned > getPrimaryModuleHash(const Module *M)
Calculate a hash value for the primary module name of the given module.
for(const auto &A :T->param_types())
const FunctionProtoType * T
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
@ None
The alignment was not explicit in code.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
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),...
Contains a late templated function.
FPOptions FPO
Floating-point options in the point of definition.
Decl * D
The template function declaration to be late parsed.
Data for list of allocators.
a linked list of methods with the same selector name but different signatures.
ObjCMethodList * getNext() 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.
SourceLocation getTemplateEllipsisLoc() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
TypeSourceInfo * getAsTypeSourceInfo() const
SourceLocation getTemplateNameLoc() const
Describes the categories of an Objective-C class.