77#include "llvm/ADT/APFloat.h"
78#include "llvm/ADT/APInt.h"
79#include "llvm/ADT/APSInt.h"
80#include "llvm/ADT/ArrayRef.h"
81#include "llvm/ADT/DenseMap.h"
82#include "llvm/ADT/Hashing.h"
83#include "llvm/ADT/PointerIntPair.h"
84#include "llvm/ADT/STLExtras.h"
85#include "llvm/ADT/ScopeExit.h"
86#include "llvm/ADT/SmallPtrSet.h"
87#include "llvm/ADT/SmallString.h"
88#include "llvm/ADT/SmallVector.h"
89#include "llvm/ADT/StringMap.h"
90#include "llvm/ADT/StringRef.h"
91#include "llvm/Bitstream/BitCodes.h"
92#include "llvm/Bitstream/BitstreamWriter.h"
93#include "llvm/Support/Casting.h"
94#include "llvm/Support/Compression.h"
95#include "llvm/Support/DJB.h"
96#include "llvm/Support/Endian.h"
97#include "llvm/Support/EndianStream.h"
98#include "llvm/Support/Error.h"
99#include "llvm/Support/ErrorHandling.h"
100#include "llvm/Support/LEB128.h"
101#include "llvm/Support/MemoryBuffer.h"
102#include "llvm/Support/OnDiskHashTable.h"
103#include "llvm/Support/Path.h"
104#include "llvm/Support/SHA1.h"
105#include "llvm/Support/TimeProfiler.h"
106#include "llvm/Support/VersionTuple.h"
107#include "llvm/Support/raw_ostream.h"
122using namespace clang;
125template <
typename T,
typename Allocator>
126static StringRef
bytes(
const std::vector<T, Allocator> &
v) {
127 if (
v.empty())
return StringRef();
128 return StringRef(
reinterpret_cast<const char*
>(&
v[0]),
129 sizeof(
T) *
v.size());
134 return StringRef(
reinterpret_cast<const char*
>(
v.data()),
135 sizeof(
T) *
v.size());
138static std::string
bytes(
const std::vector<bool> &
V) {
140 Str.reserve(
V.size() / 8);
141 for (
unsigned I = 0, E =
V.size(); I < E;) {
143 for (
unsigned Bit = 0; Bit < 8 && I < E; ++Bit, ++I)
156#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
157 case Type::CLASS_ID: return TYPE_##CODE_ID;
158#include "clang/Serialization/TypeBitCodes.def"
160 llvm_unreachable(
"shouldn't be serializing a builtin type this way");
162 llvm_unreachable(
"bad type kind");
167std::optional<std::set<const FileEntry *>>
178 std::set<const FileEntry *> ModuleMaps;
180 if (!ModuleMaps.insert(F).second)
188 if (!ModuleMaps.insert(F).second)
194 std::set<const Module *> ProcessedModules;
195 auto CollectIncludingMapsFromAncestors = [&](
const Module *M) {
197 if (!ProcessedModules.insert(Mod).second)
213 std::queue<const Module *> Q;
216 const Module *CurrentModule = Q.front();
219 CollectIncludingMapsFromAncestors(CurrentModule);
221 CollectIncludingMapsFromAncestors(ImportedModule);
223 CollectIncludingMapsFromAncestors(UndeclaredModule);
237 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
251 if (
const Module *M = KH.getModule())
252 CollectIncludingMapsFromAncestors(M);
265 : Writer(Writer), BasicWriter(Writer,
Record) {}
268 if (
T.hasLocalNonFastQualifiers()) {
275 const Type *typePtr =
T.getTypePtr();
290 Record.AddSourceLocation(Loc, Seq);
298#define ABSTRACT_TYPELOC(CLASS, PARENT)
299#define TYPELOC(CLASS, PARENT) \
300 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
301#include "clang/AST/TypeLocNodes.def"
369 VisitArrayTypeLoc(TL);
373 VisitArrayTypeLoc(TL);
377 VisitArrayTypeLoc(TL);
380void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
382 VisitArrayTypeLoc(TL);
385void TypeLocWriter::VisitDependentAddressSpaceTypeLoc(
389 addSourceLocation(
range.getBegin());
390 addSourceLocation(
range.getEnd());
394void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
403void TypeLocWriter::VisitDependentVectorTypeLoc(
415 addSourceLocation(
range.getBegin());
416 addSourceLocation(
range.getEnd());
421void TypeLocWriter::VisitDependentSizedMatrixTypeLoc(
425 addSourceLocation(
range.getBegin());
426 addSourceLocation(
range.getEnd());
437 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i)
442 VisitFunctionTypeLoc(TL);
446 VisitFunctionTypeLoc(TL);
511void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
516 Record.AddConceptReference(CR);
522void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
531void TypeLocWriter::VisitEnumTypeLoc(
EnumTypeLoc TL) {
551void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
556void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
561void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
567 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
596void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
604 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I)
640void TypeLocWriter::VisitPipeTypeLoc(
PipeTypeLoc TL) {
647void TypeLocWriter::VisitDependentBitIntTypeLoc(
652void ASTWriter::WriteTypeAbbrevs() {
653 using namespace llvm;
655 std::shared_ptr<BitCodeAbbrev> Abv;
658 Abv = std::make_shared<BitCodeAbbrev>();
660 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
661 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
662 TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
670 llvm::BitstreamWriter &Stream,
674 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID,
Record);
677 if (!Name || Name[0] == 0)
681 Record.push_back(*Name++);
682 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME,
Record);
686 llvm::BitstreamWriter &Stream,
691 Record.push_back(*Name++);
692 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME,
Record);
697#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
829void ASTWriter::WriteBlockInfoBlock() {
831 Stream.EnterBlockInfoBlock();
833#define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
834#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
837 BLOCK(CONTROL_BLOCK);
847 BLOCK(OPTIONS_BLOCK);
854 BLOCK(INPUT_FILES_BLOCK);
916 BLOCK(SOURCE_MANAGER_BLOCK);
924 BLOCK(PREPROCESSOR_BLOCK);
932 BLOCK(SUBMODULE_BLOCK);
954 BLOCK(COMMENTS_BLOCK);
958 BLOCK(DECLTYPES_BLOCK);
962 RECORD(TYPE_BLOCK_POINTER);
963 RECORD(TYPE_LVALUE_REFERENCE);
964 RECORD(TYPE_RVALUE_REFERENCE);
965 RECORD(TYPE_MEMBER_POINTER);
966 RECORD(TYPE_CONSTANT_ARRAY);
967 RECORD(TYPE_INCOMPLETE_ARRAY);
968 RECORD(TYPE_VARIABLE_ARRAY);
971 RECORD(TYPE_FUNCTION_NO_PROTO);
972 RECORD(TYPE_FUNCTION_PROTO);
978 RECORD(TYPE_OBJC_INTERFACE);
979 RECORD(TYPE_OBJC_OBJECT_POINTER);
982 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM);
983 RECORD(TYPE_UNRESOLVED_USING);
984 RECORD(TYPE_INJECTED_CLASS_NAME);
986 RECORD(TYPE_TEMPLATE_TYPE_PARM);
987 RECORD(TYPE_TEMPLATE_SPECIALIZATION);
988 RECORD(TYPE_DEPENDENT_NAME);
989 RECORD(TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION);
990 RECORD(TYPE_DEPENDENT_SIZED_ARRAY);
992 RECORD(TYPE_MACRO_QUALIFIED);
993 RECORD(TYPE_PACK_EXPANSION);
995 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK);
997 RECORD(TYPE_UNARY_TRANSFORM);
1001 RECORD(TYPE_OBJC_TYPE_PARAM);
1078 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
1084 BLOCK(EXTENSION_BLOCK);
1087 BLOCK(UNHASHED_CONTROL_BLOCK);
1106 return Changed | llvm::sys::path::remove_dots(Path);
1121 assert(
Filename &&
"No file name to adjust?");
1123 if (BaseDir.empty())
1128 for (;
Filename[Pos] && Pos < BaseDir.size(); ++Pos)
1138 if (!llvm::sys::path::is_separator(
Filename[Pos])) {
1139 if (!llvm::sys::path::is_separator(BaseDir.back()))
1156std::pair<ASTFileSignature, ASTFileSignature>
1157ASTWriter::createSignature()
const {
1158 StringRef AllBytes(Buffer.data(), Buffer.size());
1161 Hasher.update(AllBytes.slice(ASTBlockRange.first, ASTBlockRange.second));
1166 Hasher.update(AllBytes.slice(0, UnhashedControlBlockRange.first));
1169 AllBytes.slice(UnhashedControlBlockRange.second, ASTBlockRange.first));
1171 Hasher.update(AllBytes.slice(ASTBlockRange.second, StringRef::npos));
1174 return std::make_pair(ASTBlockHash, Signature);
1178 if (!WritingModule ||
1185 for (uint8_t Byte : S) {
1186 Stream.BackpatchByte(BitNo, Byte);
1193 std::tie(ASTBlockHash, Signature) = createSignature();
1195 BackpatchSignatureAt(ASTBlockHash, ASTBlockHashOffset);
1196 BackpatchSignatureAt(Signature, SignatureOffset);
1201void ASTWriter::writeUnhashedControlBlock(
Preprocessor &PP,
1203 using namespace llvm;
1206 Stream.FlushToWord();
1207 UnhashedControlBlockRange.first = Stream.GetCurrentBitNo() >> 3;
1214 if (WritingModule &&
1226 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1228 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1229 unsigned ASTBlockHashAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1231 Abbrev = std::make_shared<BitCodeAbbrev>();
1232 Abbrev->Add(BitCodeAbbrevOp(
SIGNATURE));
1233 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1234 unsigned SignatureAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1237 Stream.EmitRecordWithBlob(ASTBlockHashAbbrev,
Record, Blob);
1238 ASTBlockHashOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1242 Stream.EmitRecordWithBlob(SignatureAbbrev,
Record, Blob);
1243 SignatureOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1252 if (!HSOpts.ModulesSkipDiagnosticOptions) {
1253#define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name);
1254#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
1255 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name()));
1256#include "clang/Basic/DiagnosticOptions.def"
1258 for (
unsigned I = 0, N = DiagOpts.
Warnings.size(); I != N; ++I)
1261 for (
unsigned I = 0, N = DiagOpts.
Remarks.size(); I != N; ++I)
1270 if (!HSOpts.ModulesSkipHeaderSearchPaths) {
1272 Record.push_back(HSOpts.UserEntries.size());
1273 for (
unsigned I = 0, N = HSOpts.UserEntries.size(); I != N; ++I) {
1276 Record.push_back(
static_cast<unsigned>(Entry.
Group));
1282 Record.push_back(HSOpts.SystemHeaderPrefixes.size());
1283 for (
unsigned I = 0, N = HSOpts.SystemHeaderPrefixes.size(); I != N; ++I) {
1285 Record.push_back(HSOpts.SystemHeaderPrefixes[I].IsSystemHeader);
1289 Record.push_back(HSOpts.VFSOverlayFiles.size());
1290 for (StringRef VFSOverlayFile : HSOpts.VFSOverlayFiles)
1296 if (!HSOpts.ModulesSkipPragmaDiagnosticMappings)
1297 WritePragmaDiagnosticMappings(Diags, WritingModule);
1302 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1304 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1305 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1306 unsigned HSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1308 HSEntryUsage.size()};
1309 Stream.EmitRecordWithBlob(HSUsageAbbrevCode,
Record,
bytes(HSEntryUsage));
1315 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1316 Abbrev->Add(BitCodeAbbrevOp(
VFS_USAGE));
1317 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1318 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1319 unsigned VFSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1321 Stream.EmitRecordWithBlob(VFSUsageAbbrevCode,
Record,
bytes(VFSUsage));
1326 UnhashedControlBlockRange.second = Stream.GetCurrentBitNo() >> 3;
1331 StringRef isysroot) {
1332 using namespace llvm;
1338 auto MetadataAbbrev = std::make_shared<BitCodeAbbrev>();
1339 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1340 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1341 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1342 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1343 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1344 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1346 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1347 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1348 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1349 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1350 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev));
1351 assert((!WritingModule || isysroot.empty()) &&
1352 "writing module as a relocatable PCH?");
1357 CLANG_VERSION_MAJOR,
1358 CLANG_VERSION_MINOR,
1362 ASTHasCompilerErrors};
1363 Stream.EmitRecordWithBlob(MetadataAbbrevCode,
Record,
1367 if (WritingModule) {
1369 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1371 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1372 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1374 Stream.EmitRecordWithBlob(AbbrevCode,
Record, WritingModule->
Name);
1377 if (WritingModule && WritingModule->
Directory) {
1384 BaseDir.assign(CWD->getName());
1399 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1401 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1402 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1405 Stream.EmitRecordWithBlob(AbbrevCode,
Record, BaseDir);
1409 BaseDirectory.assign(BaseDir.begin(), BaseDir.end());
1410 }
else if (!isysroot.empty()) {
1412 BaseDirectory = std::string(isysroot);
1421 ? Map.getModuleMapFileForUniquing(WritingModule)
1422 ->getNameAsRequested()
1427 if (
auto *AdditionalModMaps =
1428 Map.getAdditionalModuleMapFiles(WritingModule)) {
1429 Record.push_back(AdditionalModMaps->size());
1431 AdditionalModMaps->end());
1451 if (!M.isDirectlyImported())
1454 Record.push_back((
unsigned)M.Kind);
1455 Record.push_back(M.StandardCXXModule);
1460 if (!M.StandardCXXModule) {
1463 Record.push_back(M.Signature ? 0 : M.File.getSize());
1465 llvm::append_range(
Record, M.Signature);
1470 if (!M.StandardCXXModule)
1482#define LANGOPT(Name, Bits, Default, Description) \
1483 Record.push_back(LangOpts.Name);
1484#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
1485 Record.push_back(static_cast<unsigned>(LangOpts.get##Name()));
1486#include "clang/Basic/LangOptions.def"
1487#define SANITIZER(NAME, ID) \
1488 Record.push_back(LangOpts.Sanitize.has(SanitizerKind::ID));
1489#include "clang/Basic/Sanitizers.def"
1529 for (
unsigned I = 0, N = TargetOpts.
Features.size(); I != N; ++I) {
1570 bool WriteMacros = !SkipMacros;
1571 Record.push_back(WriteMacros);
1575 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
1583 for (
unsigned I = 0, N = PPOpts.
Includes.size(); I != N; ++I)
1588 for (
unsigned I = 0, N = PPOpts.
MacroIncludes.size(); I != N; ++I)
1603 if (
auto MainFile =
SM.getFileEntryRefForID(
SM.getMainFileID())) {
1604 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1606 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1607 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1608 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
1620 WriteInputFiles(Context.SourceMgr,
1628struct InputFileEntry {
1632 bool BufferOverridden;
1635 uint32_t ContentHash[2];
1644 using namespace llvm;
1649 auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
1651 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1652 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1653 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1654 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1655 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1656 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1657 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1658 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
1659 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1660 unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
1663 auto IFHAbbrev = std::make_shared<BitCodeAbbrev>();
1665 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1666 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1667 unsigned IFHAbbrevCode = Stream.EmitAbbrev(std::move(IFHAbbrev));
1669 uint64_t InputFilesOffsetBase = Stream.GetCurrentBitNo();
1672 std::vector<InputFileEntry> UserFiles;
1673 std::vector<InputFileEntry> SystemFiles;
1677 assert(&SourceMgr.
getSLocEntry(FileID::get(I)) == SLoc);
1684 if (!
Cache->OrigEntry)
1688 if (!IsSLocAffecting[I])
1691 InputFileEntry Entry(*
Cache->OrigEntry);
1692 Entry.IsSystemFile =
isSystem(
File.getFileCharacteristic());
1693 Entry.IsTransient =
Cache->IsTransient;
1694 Entry.BufferOverridden =
Cache->BufferOverridden;
1695 Entry.IsTopLevel =
File.getIncludeLoc().isInvalid();
1698 auto ContentHash = hash_code(-1);
1702 auto MemBuff =
Cache->getBufferIfLoaded();
1704 ContentHash =
hash_value(MemBuff->getBuffer());
1707 << Entry.File.getName();
1709 auto CH = llvm::APInt(64, ContentHash);
1710 Entry.ContentHash[0] =
1711 static_cast<uint32_t
>(CH.getLoBits(32).getZExtValue());
1712 Entry.ContentHash[1] =
1713 static_cast<uint32_t
>(CH.getHiBits(32).getZExtValue());
1715 if (Entry.IsSystemFile)
1716 SystemFiles.push_back(Entry);
1718 UserFiles.push_back(Entry);
1722 auto SortedFiles = llvm::concat<InputFileEntry>(std::move(UserFiles),
1723 std::move(SystemFiles));
1725 unsigned UserFilesNum = 0;
1727 std::vector<uint64_t> InputFileOffsets;
1728 for (
const auto &Entry : SortedFiles) {
1729 uint32_t &InputFileID = InputFileIDs[Entry.File];
1730 if (InputFileID != 0)
1734 InputFileOffsets.push_back(Stream.GetCurrentBitNo() - InputFilesOffsetBase);
1736 InputFileID = InputFileOffsets.size();
1738 if (!Entry.IsSystemFile)
1750 if (Name == NameAsRequested)
1753 RecordData::value_type
Record[] = {
1755 InputFileOffsets.size(),
1758 Entry.BufferOverridden,
1762 NameAsRequested.size()};
1764 Stream.EmitRecordWithBlob(IFAbbrevCode,
Record,
1765 (NameAsRequested + Name).str());
1771 Entry.ContentHash[1]};
1772 Stream.EmitRecordWithAbbrev(IFHAbbrevCode,
Record);
1779 auto OffsetsAbbrev = std::make_shared<BitCodeAbbrev>();
1781 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1782 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1784 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1785 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(std::move(OffsetsAbbrev));
1789 InputFileOffsets.size(), UserFilesNum};
1790 Stream.EmitRecordWithBlob(OffsetsAbbrevCode,
Record,
bytes(InputFileOffsets));
1800 using namespace llvm;
1802 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1804 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1805 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1806 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1807 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1809 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1810 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1811 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
1812 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1813 return Stream.EmitAbbrev(std::move(Abbrev));
1819 using namespace llvm;
1821 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1823 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1824 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1825 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1826 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1827 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1828 return Stream.EmitAbbrev(std::move(Abbrev));
1835 using namespace llvm;
1837 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1841 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1842 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1843 return Stream.EmitAbbrev(std::move(Abbrev));
1849 using namespace llvm;
1851 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1853 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1854 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1855 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1856 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1857 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1858 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1859 return Stream.EmitAbbrev(std::move(Abbrev));
1864static std::pair<unsigned, unsigned>
1866 llvm::encodeULEB128(KeyLen, Out);
1867 llvm::encodeULEB128(DataLen, Out);
1868 return std::make_pair(KeyLen, DataLen);
1874 class HeaderFileInfoTrait {
1879 llvm::StringMap<unsigned> FrameworkNameOffset;
1882 HeaderFileInfoTrait(
ASTWriter &Writer) : Writer(Writer) {}
1889 using key_type_ref =
const key_type &;
1891 using UnresolvedModule =
1892 llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
1896 bool AlreadyIncluded;
1900 using data_type_ref =
const data_type &;
1909 return llvm::hash_combine(key.Size, key.ModTime);
1912 std::pair<unsigned, unsigned>
1913 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref
Data) {
1914 unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
1915 unsigned DataLen = 1 + 4 + 4;
1916 for (
auto ModInfo :
Data.KnownHeaders)
1919 if (
Data.Unresolved.getPointer())
1924 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
1925 using namespace llvm::support;
1927 endian::Writer
LE(Out, llvm::endianness::little);
1932 Out.write(key.Filename.data(), KeyLen);
1935 void EmitData(raw_ostream &Out, key_type_ref key,
1936 data_type_ref
Data,
unsigned DataLen) {
1937 using namespace llvm::support;
1939 endian::Writer
LE(Out, llvm::endianness::little);
1940 uint64_t Start = Out.tell(); (void)Start;
1942 unsigned char Flags = (
Data.AlreadyIncluded << 6)
1943 | (
Data.HFI.isImport << 5)
1945 Data.HFI.isPragmaOnce << 4)
1946 | (
Data.HFI.DirInfo << 1)
1947 |
Data.HFI.IndexHeaderMapHeader;
1948 LE.write<uint8_t>(Flags);
1950 if (!
Data.HFI.ControllingMacro)
1951 LE.write<uint32_t>(
Data.HFI.ControllingMacroID);
1955 unsigned Offset = 0;
1956 if (!
Data.HFI.Framework.empty()) {
1958 llvm::StringMap<unsigned>::iterator Pos
1959 = FrameworkNameOffset.find(
Data.HFI.Framework);
1960 if (Pos == FrameworkNameOffset.end()) {
1961 Offset = FrameworkStringData.size() + 1;
1962 FrameworkStringData.append(
Data.HFI.Framework);
1963 FrameworkStringData.push_back(0);
1965 FrameworkNameOffset[
Data.HFI.Framework] = Offset;
1967 Offset = Pos->second;
1969 LE.write<uint32_t>(Offset);
1973 uint32_t
Value = (ModID << 3) | (
unsigned)Role;
1974 assert((
Value >> 3) == ModID &&
"overflow in header module info");
1979 for (
auto ModInfo :
Data.KnownHeaders)
1980 EmitModule(ModInfo.getModule(), ModInfo.getRole());
1981 if (
Data.Unresolved.getPointer())
1982 EmitModule(
Data.Unresolved.getPointer(),
Data.Unresolved.getInt());
1984 assert(Out.tell() - Start == DataLen &&
"Wrong data length");
1987 const char *strings_begin()
const {
return FrameworkStringData.begin(); }
1988 const char *strings_end()
const {
return FrameworkStringData.end(); }
1996void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
1997 HeaderFileInfoTrait GeneratorTrait(*
this);
1998 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait>
Generator;
2000 unsigned NumHeaderSearchEntries = 0;
2007 if (WritingModule) {
2009 while (!Worklist.empty()) {
2010 Module *M = Worklist.pop_back_val();
2027 if (!
U.Size || (!
U.ModTime && IncludeTimestamps)) {
2028 PP->
Diag(
U.FileNameLoc, diag::err_module_no_size_mtime_for_header)
2036 llvm::sys::path::append(
Filename,
U.FileName);
2039 StringRef FilenameDup = strdup(
Filename.c_str());
2040 SavedStrings.push_back(FilenameDup.data());
2042 HeaderFileInfoTrait::key_type Key = {
2043 FilenameDup, *
U.Size, IncludeTimestamps ? *
U.ModTime : 0};
2044 HeaderFileInfoTrait::data_type
Data = {
2049 ++NumHeaderSearchEntries;
2052 Worklist.append(SubmodulesRange.begin(), SubmodulesRange.end());
2062 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
2081 Filename = StringRef(strdup(FilenameTmp.c_str()));
2082 SavedStrings.push_back(
Filename.data());
2087 HeaderFileInfoTrait::key_type Key = {
2090 HeaderFileInfoTrait::data_type
Data = {
2094 ++NumHeaderSearchEntries;
2099 uint32_t BucketOffset;
2101 using namespace llvm::support;
2103 llvm::raw_svector_ostream Out(TableData);
2105 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
2106 BucketOffset =
Generator.Emit(Out, GeneratorTrait);
2110 using namespace llvm;
2112 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2114 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2115 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2116 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2117 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2118 unsigned TableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2122 NumHeaderSearchEntries, TableData.size()};
2123 TableData.append(GeneratorTrait.strings_begin(),GeneratorTrait.strings_end());
2124 Stream.EmitRecordWithBlob(TableAbbrev,
Record, TableData);
2127 for (
unsigned I = 0, N = SavedStrings.size(); I != N; ++I)
2128 free(
const_cast<char *
>(SavedStrings[I]));
2131static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
2132 unsigned SLocBufferBlobCompressedAbbrv,
2133 unsigned SLocBufferBlobAbbrv) {
2134 using RecordDataType = ASTWriter::RecordData::value_type;
2139 if (llvm::compression::zstd::isAvailable()) {
2140 llvm::compression::zstd::compress(
2141 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer, 9);
2143 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2144 llvm::toStringRef(CompressedBuffer));
2147 if (llvm::compression::zlib::isAvailable()) {
2148 llvm::compression::zlib::compress(
2149 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer);
2151 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2152 llvm::toStringRef(CompressedBuffer));
2157 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv,
Record, Blob);
2168void ASTWriter::WriteSourceManagerBlock(
SourceManager &SourceMgr,
2174 const uint64_t SourceManagerBlockOffset = Stream.GetCurrentBitNo();
2180 unsigned SLocBufferBlobCompressedAbbrv =
2186 std::vector<uint32_t> SLocEntryOffsets;
2187 uint64_t SLocEntryOffsetsBase = Stream.GetCurrentBitNo();
2193 FileID FID = FileID::get(I);
2197 uint64_t Offset = Stream.GetCurrentBitNo() - SLocEntryOffsetsBase;
2198 assert((Offset >> 32) == 0 &&
"SLocEntry offset too large");
2204 if (
Cache->OrigEntry) {
2217 if (!IsSLocAffecting[I])
2219 SLocEntryOffsets.push_back(Offset);
2223 Record.push_back(
File.getFileCharacteristic());
2226 bool EmitBlob =
false;
2229 "Writing to AST an overridden file is not supported");
2232 assert(InputFileIDs[*Content->
OrigEntry] != 0 &&
"Missed file entry");
2235 Record.push_back(getAdjustedNumCreatedFIDs(FID));
2237 FileDeclIDsTy::iterator FDI = FileDeclIDs.find(FID);
2238 if (FDI != FileDeclIDs.end()) {
2239 Record.push_back(FDI->second->FirstDeclIndex);
2240 Record.push_back(FDI->second->DeclIDs.size());
2246 Stream.EmitRecordWithAbbrev(SLocFileAbbrv,
Record);
2257 std::optional<llvm::MemoryBufferRef> Buffer =
2259 StringRef Name = Buffer ? Buffer->getBufferIdentifier() :
"";
2260 Stream.EmitRecordWithBlob(SLocBufferAbbrv,
Record,
2261 StringRef(Name.data(), Name.size() + 1));
2268 std::optional<llvm::MemoryBufferRef> Buffer =
2271 Buffer = llvm::MemoryBufferRef(
"<<<INVALID BUFFER>>>",
"");
2272 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
2273 emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv,
2274 SLocBufferBlobAbbrv);
2279 SLocEntryOffsets.push_back(Offset);
2295 Record.push_back(getAdjustedOffset(NextOffset - SLoc->
getOffset()) - 1);
2296 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv,
Record);
2302 if (SLocEntryOffsets.empty())
2307 using namespace llvm;
2309 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2311 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2312 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2313 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2314 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2315 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2317 RecordData::value_type
Record[] = {
2320 SLocEntryOffsetsBase - SourceManagerBlockOffset};
2321 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev,
Record,
2322 bytes(SLocEntryOffsets));
2333 llvm::DenseMap<int, int> FilenameMap;
2334 FilenameMap[-1] = -1;
2335 for (
const auto &L : LineTable) {
2338 for (
auto &LE : L.second) {
2339 if (FilenameMap.insert(std::make_pair(
LE.FilenameID,
2340 FilenameMap.size() - 1)).second)
2347 for (
const auto &L : LineTable) {
2355 Record.push_back(L.second.size());
2356 for (
const auto &LE : L.second) {
2359 Record.push_back(FilenameMap[
LE.FilenameID]);
2360 Record.push_back((
unsigned)
LE.FileKind);
2361 Record.push_back(
LE.IncludeOffset);
2376 if (MI->isBuiltinMacro())
2392void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2393 uint64_t MacroOffsetsBase = Stream.GetCurrentBitNo();
2397 WritePreprocessorDetail(*PPRec, MacroOffsetsBase);
2412 if (AssumeNonNullLoc.
isValid()) {
2426 Record.push_back(SkipInfo->FoundNonSkipPortion);
2427 Record.push_back(SkipInfo->FoundElse);
2434 Record.push_back(Cond.WasSkipping);
2435 Record.push_back(Cond.FoundNonSkip);
2436 Record.push_back(Cond.FoundElse);
2460 if (
Id.second->hadMacroDefinition() &&
2461 (!
Id.second->isFromAST() ||
2462 Id.second->hasChangedSinceDeserialization()))
2463 MacroIdentifiers.push_back(
Id.second);
2466 llvm::sort(MacroIdentifiers, llvm::deref<std::less<>>());
2472 uint64_t StartOffset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2473 assert((StartOffset >> 32) == 0 &&
"Macro identifiers offset too large");
2476 bool EmittedModuleMacros =
false;
2493 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2495 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2496 Record.push_back(VisMD->isPublic());
2498 ModuleMacroRecord.push_back(getSubmoduleID(WritingModule));
2501 ModuleMacroRecord.clear();
2502 EmittedModuleMacros =
true;
2512 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2514 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2515 Record.push_back(VisMD->isPublic());
2522 llvm::DenseMap<ModuleMacro *, unsigned> Visits;
2523 while (!Worklist.empty()) {
2524 auto *
Macro = Worklist.pop_back_val();
2527 ModuleMacroRecord.push_back(getSubmoduleID(
Macro->getOwningModule()));
2529 for (
auto *M :
Macro->overrides())
2530 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2533 ModuleMacroRecord.clear();
2536 for (
auto *M :
Macro->overrides())
2537 if (++Visits[M] == M->getNumOverridingMacros())
2538 Worklist.push_back(M);
2540 EmittedModuleMacros =
true;
2543 if (
Record.empty() && !EmittedModuleMacros)
2546 IdentMacroDirectivesOffsetMap[Name] = StartOffset;
2557 std::vector<uint32_t> MacroOffsets;
2559 for (
unsigned I = 0, N = MacroInfosToEmit.size(); I != N; ++I) {
2564 if (ID < FirstMacroID) {
2565 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2570 unsigned Index =
ID - FirstMacroID;
2571 if (Index >= MacroOffsets.size())
2572 MacroOffsets.resize(Index + 1);
2574 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2575 assert((Offset >> 32) == 0 &&
"Macro offset too large");
2576 MacroOffsets[Index] = Offset;
2603 Stream.EmitRecord(Code,
Record);
2607 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2622 using namespace llvm;
2624 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2626 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2627 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2628 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2629 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2631 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2635 MacroOffsetsBase - ASTBlockStartOffset};
2636 Stream.EmitRecordWithBlob(MacroOffsetAbbrev,
Record,
bytes(MacroOffsets));
2641 uint64_t MacroOffsetsBase) {
2651 unsigned NumPreprocessingRecords = 0;
2652 using namespace llvm;
2655 unsigned InclusionAbbrev = 0;
2657 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2659 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2660 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2661 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2662 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2663 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2664 InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2667 unsigned FirstPreprocessorEntityID
2668 = (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0)
2670 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2675 (void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2678 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2679 assert((Offset >> 32) == 0 &&
"Preprocessed entity offset too large");
2680 PreprocessedEntityOffsets.push_back(
2681 PPEntityOffset(getAdjustedRange((*E)->getSourceRange()), Offset));
2683 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*E)) {
2685 MacroDefinitions[MD] = NextPreprocessorEntityID;
2692 if (
auto *ME = dyn_cast<MacroExpansion>(*E)) {
2693 Record.push_back(ME->isBuiltinMacro());
2694 if (ME->isBuiltinMacro())
2697 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2702 if (
auto *ID = dyn_cast<InclusionDirective>(*E)) {
2704 Record.push_back(
ID->getFileName().size());
2705 Record.push_back(
ID->wasInQuotes());
2706 Record.push_back(
static_cast<unsigned>(
ID->getKind()));
2707 Record.push_back(
ID->importedModule());
2709 Buffer +=
ID->getFileName();
2713 Buffer +=
ID->getFile()->getName();
2714 Stream.EmitRecordWithBlob(InclusionAbbrev,
Record, Buffer);
2718 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2723 if (NumPreprocessingRecords > 0) {
2724 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2727 using namespace llvm;
2729 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2731 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2732 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2733 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2736 FirstPreprocessorEntityID -
2738 Stream.EmitRecordWithBlob(PPEOffsetAbbrev,
Record,
2739 bytes(PreprocessedEntityOffsets));
2744 if (SkippedRanges.size() > 0) {
2745 std::vector<PPSkippedRange> SerializedSkippedRanges;
2746 SerializedSkippedRanges.reserve(SkippedRanges.size());
2747 for (
auto const& Range : SkippedRanges)
2748 SerializedSkippedRanges.emplace_back(Range);
2750 using namespace llvm;
2751 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2753 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2754 unsigned PPESkippedRangeAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2758 Stream.EmitRecordWithBlob(PPESkippedRangeAbbrev,
Record,
2759 bytes(SerializedSkippedRanges));
2767 auto Known = SubmoduleIDs.find(Mod);
2768 if (Known != SubmoduleIDs.end())
2769 return Known->second;
2772 if (Top != WritingModule &&
2774 !Top->fullModuleNameIs(StringRef(
getLangOpts().CurrentModule))))
2777 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2780unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2793 unsigned ChildModules = 0;
2797 return ChildModules + 1;
2800void ASTWriter::WriteSubmodules(
Module *WritingModule) {
2805 using namespace llvm;
2807 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2809 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2810 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2811 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
2812 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2813 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2814 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2815 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2816 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2817 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2818 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2819 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2820 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2821 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2822 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2823 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2824 unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2826 Abbrev = std::make_shared<BitCodeAbbrev>();
2828 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2829 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2831 Abbrev = std::make_shared<BitCodeAbbrev>();
2833 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2834 unsigned HeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2836 Abbrev = std::make_shared<BitCodeAbbrev>();
2838 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2839 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2841 Abbrev = std::make_shared<BitCodeAbbrev>();
2843 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2844 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2846 Abbrev = std::make_shared<BitCodeAbbrev>();
2848 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2849 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2850 unsigned RequiresAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2852 Abbrev = std::make_shared<BitCodeAbbrev>();
2854 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2855 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2857 Abbrev = std::make_shared<BitCodeAbbrev>();
2859 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2860 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2862 Abbrev = std::make_shared<BitCodeAbbrev>();
2864 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2865 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2867 Abbrev = std::make_shared<BitCodeAbbrev>();
2869 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2870 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2872 Abbrev = std::make_shared<BitCodeAbbrev>();
2874 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2875 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2876 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2878 Abbrev = std::make_shared<BitCodeAbbrev>();
2880 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2881 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2883 Abbrev = std::make_shared<BitCodeAbbrev>();
2885 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2886 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2887 unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2889 Abbrev = std::make_shared<BitCodeAbbrev>();
2891 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2892 unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2895 RecordData::value_type
Record[] = {
2901 std::queue<Module *> Q;
2902 Q.push(WritingModule);
2903 while (!Q.empty()) {
2906 unsigned ID = getSubmoduleID(Mod);
2910 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
2911 ParentID = SubmoduleIDs[Mod->
Parent];
2922 (RecordData::value_type)Mod->
Kind,
2934 Stream.EmitRecordWithBlob(DefinitionAbbrev,
Record, Mod->
Name);
2940 Stream.EmitRecordWithBlob(RequiresAbbrev,
Record, R.first);
2944 if (std::optional<Module::Header> UmbrellaHeader =
2947 Stream.EmitRecordWithBlob(UmbrellaAbbrev,
Record,
2948 UmbrellaHeader->NameAsWritten);
2949 }
else if (std::optional<Module::DirectoryName> UmbrellaDir =
2952 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev,
Record,
2953 UmbrellaDir->NameAsWritten);
2958 unsigned RecordKind;
2969 for (
auto &HL : HeaderLists) {
2970 RecordData::value_type
Record[] = {HL.RecordKind};
2971 for (
auto &H : Mod->
Headers[HL.HeaderKind])
2972 Stream.EmitRecordWithBlob(HL.Abbrev,
Record, H.NameAsWritten);
2981 Stream.EmitRecordWithBlob(TopHeaderAbbrev,
Record, HeaderName);
2989 Record.push_back(getSubmoduleID(I));
2997 Record.push_back(getSubmoduleID(I));
3004 for (
const auto &E : Mod->
Exports) {
3007 Record.push_back(getSubmoduleID(E.getPointer()));
3008 Record.push_back(E.getInt());
3023 Stream.EmitRecordWithBlob(LinkLibraryAbbrev,
Record, LL.Library);
3031 getSubmoduleID(
C.Other)};
3032 Stream.EmitRecordWithBlob(ConflictAbbrev,
Record,
C.Message);
3038 Stream.EmitRecordWithBlob(ConfigMacroAbbrev,
Record, CM);
3063 assert((NextSubmoduleID - FirstSubmoduleID ==
3065 "Wrong # of submodules; found a reference to a non-local, "
3066 "non-imported submodule?");
3071 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
3073 unsigned CurrID = 0;
3076 auto EncodeDiagStateFlags =
3077 [](
const DiagnosticsEngine::DiagState *DS) ->
unsigned {
3080 {(
unsigned)DS->IgnoreAllWarnings, (
unsigned)DS->EnableAllWarnings,
3081 (
unsigned)DS->WarningsAsErrors, (
unsigned)DS->ErrorsAsFatal,
3082 (
unsigned)DS->SuppressSystemWarnings})
3087 unsigned Flags = EncodeDiagStateFlags(
Diag.DiagStatesByLoc.FirstDiagState);
3090 auto AddDiagState = [&](
const DiagnosticsEngine::DiagState *State,
3091 bool IncludeNonPragmaStates) {
3094 assert(Flags == EncodeDiagStateFlags(State) &&
3095 "diag state flags vary in single AST file");
3099 assert(!IncludeNonPragmaStates ||
3100 State ==
Diag.DiagStatesByLoc.FirstDiagState);
3102 unsigned &DiagStateID = DiagStateIDMap[State];
3103 Record.push_back(DiagStateID);
3105 if (DiagStateID == 0) {
3106 DiagStateID = ++CurrID;
3110 auto SizeIdx =
Record.size();
3112 for (
const auto &I : *State) {
3114 if (!I.second.isPragma() && !IncludeNonPragmaStates)
3118 if (!I.second.isPragma() &&
3121 Mappings.push_back(I);
3125 llvm::sort(Mappings, [](
const auto &LHS,
const auto &RHS) {
3126 return LHS.first < RHS.first;
3129 for (
const auto &I : Mappings) {
3130 Record.push_back(I.first);
3131 Record.push_back(I.second.serialize());
3138 AddDiagState(
Diag.DiagStatesByLoc.FirstDiagState, isModule);
3141 auto NumLocationsIdx =
Record.size();
3145 unsigned NumLocations = 0;
3146 for (
auto &FileIDAndFile :
Diag.DiagStatesByLoc.Files) {
3147 if (!FileIDAndFile.first.isValid() ||
3148 !FileIDAndFile.second.HasLocalTransitions)
3154 Record.push_back(FileIDAndFile.second.StateTransitions.size());
3155 for (
auto &StatePoint : FileIDAndFile.second.StateTransitions) {
3156 Record.push_back(getAdjustedOffset(StatePoint.Offset));
3157 AddDiagState(StatePoint.State,
false);
3162 Record[NumLocationsIdx] = NumLocations;
3171 AddDiagState(
Diag.DiagStatesByLoc.CurDiagState,
false);
3184 IdxRef =
TypeIdx(NextTypeID++);
3187 assert(Idx.
getIndex() >= FirstTypeID &&
"Re-writing a type from a prior AST");
3190 uint64_t Offset = ASTTypeWriter(*this).write(
T) - DeclTypesBlockStartOffset;
3193 unsigned Index = Idx.
getIndex() - FirstTypeID;
3194 if (TypeOffsets.size() == Index)
3195 TypeOffsets.emplace_back(Offset);
3196 else if (TypeOffsets.size() < Index) {
3197 TypeOffsets.resize(Index + 1);
3198 TypeOffsets[Index].setBitOffset(Offset);
3200 llvm_unreachable(
"Types emitted in wrong order");
3222 uint64_t Offset = Stream.GetCurrentBitNo();
3224 for (
const auto *D : DC->
decls()) {
3228 KindDeclPairs.push_back(D->getKind());
3229 KindDeclPairs.push_back(
GetDeclRef(D).get());
3232 ++NumLexicalDeclContexts;
3234 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev,
Record,
3235 bytes(KindDeclPairs));
3239void ASTWriter::WriteTypeDeclOffsets() {
3240 using namespace llvm;
3243 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3245 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3246 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3247 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3248 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3252 Stream.EmitRecordWithBlob(TypeOffsetAbbrev,
Record,
bytes(TypeOffsets));
3256 Abbrev = std::make_shared<BitCodeAbbrev>();
3258 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3259 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3260 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3261 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3265 Stream.EmitRecordWithBlob(DeclOffsetAbbrev,
Record,
bytes(DeclOffsets));
3269void ASTWriter::WriteFileDeclIDsMap() {
3270 using namespace llvm;
3273 SortedFileDeclIDs.reserve(FileDeclIDs.size());
3274 for (
const auto &
P : FileDeclIDs)
3275 SortedFileDeclIDs.push_back(std::make_pair(
P.first,
P.second.get()));
3276 llvm::sort(SortedFileDeclIDs, llvm::less_first());
3280 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
3281 DeclIDInFileInfo &Info = *FileDeclEntry.second;
3282 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
3283 llvm::stable_sort(Info.DeclIDs);
3284 for (
auto &LocDeclEntry : Info.DeclIDs)
3285 FileGroupedDeclIDs.push_back(LocDeclEntry.second.get());
3288 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3290 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3291 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3292 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
3294 FileGroupedDeclIDs.size()};
3295 Stream.EmitRecordWithBlob(AbbrevCode,
Record,
bytes(FileGroupedDeclIDs));
3298void ASTWriter::WriteComments() {
3300 auto _ = llvm::make_scope_exit([
this] { Stream.ExitBlock(); });
3311 for (
const auto &FO : Context->
Comments.OrderedComments) {
3312 for (
const auto &OC : FO.second) {
3331class ASTMethodPoolTrait {
3336 using key_type_ref = key_type;
3342 using data_type_ref =
const data_type &;
3347 explicit ASTMethodPoolTrait(
ASTWriter &Writer) : Writer(Writer) {}
3353 std::pair<unsigned, unsigned>
3354 EmitKeyDataLength(raw_ostream& Out,
Selector Sel,
3355 data_type_ref Methods) {
3357 unsigned DataLen = 4 + 2 + 2;
3360 if (ShouldWriteMethodListNode(Method))
3361 DataLen +=
sizeof(
DeclID);
3364 if (ShouldWriteMethodListNode(Method))
3365 DataLen +=
sizeof(
DeclID);
3369 void EmitKey(raw_ostream& Out,
Selector Sel,
unsigned) {
3370 using namespace llvm::support;
3372 endian::Writer
LE(Out, llvm::endianness::little);
3374 assert((Start >> 32) == 0 &&
"Selector key offset too large");
3377 LE.write<uint16_t>(N);
3380 for (
unsigned I = 0; I != N; ++I)
3385 void EmitData(raw_ostream& Out, key_type_ref,
3386 data_type_ref Methods,
unsigned DataLen) {
3387 using namespace llvm::support;
3389 endian::Writer
LE(Out, llvm::endianness::little);
3390 uint64_t Start = Out.tell(); (void)Start;
3391 LE.write<uint32_t>(Methods.ID);
3392 unsigned NumInstanceMethods = 0;
3395 if (ShouldWriteMethodListNode(Method))
3396 ++NumInstanceMethods;
3398 unsigned NumFactoryMethods = 0;
3401 if (ShouldWriteMethodListNode(Method))
3402 ++NumFactoryMethods;
3404 unsigned InstanceBits = Methods.Instance.getBits();
3405 assert(InstanceBits < 4);
3406 unsigned InstanceHasMoreThanOneDeclBit =
3407 Methods.Instance.hasMoreThanOneDecl();
3408 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
3409 (InstanceHasMoreThanOneDeclBit << 2) |
3411 unsigned FactoryBits = Methods.Factory.getBits();
3412 assert(FactoryBits < 4);
3413 unsigned FactoryHasMoreThanOneDeclBit =
3414 Methods.Factory.hasMoreThanOneDecl();
3415 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
3416 (FactoryHasMoreThanOneDeclBit << 2) |
3418 LE.write<uint16_t>(FullInstanceBits);
3419 LE.write<uint16_t>(FullFactoryBits);
3422 if (ShouldWriteMethodListNode(Method))
3426 if (ShouldWriteMethodListNode(Method))
3429 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3434 return (
Node->getMethod() && !
Node->getMethod()->isFromASTFile());
3445void ASTWriter::WriteSelectors(
Sema &SemaRef) {
3446 using namespace llvm;
3451 unsigned NumTableEntries = 0;
3454 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait>
Generator;
3455 ASTMethodPoolTrait Trait(*
this);
3459 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
3460 for (
auto &SelectorAndID : SelectorIDs) {
3464 ASTMethodPoolTrait::data_type
Data = {
3470 Data.Instance = F->second.first;
3471 Data.Factory = F->second.second;
3475 if (Chain && ID < FirstSelectorID) {
3477 bool changed =
false;
3480 if (!M->getMethod()->isFromASTFile()) {
3488 if (!M->getMethod()->isFromASTFile()) {
3496 }
else if (
Data.Instance.getMethod() ||
Data.Factory.getMethod()) {
3505 uint32_t BucketOffset;
3507 using namespace llvm::support;
3509 ASTMethodPoolTrait Trait(*
this);
3510 llvm::raw_svector_ostream Out(MethodPool);
3512 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
3513 BucketOffset =
Generator.Emit(Out, Trait);
3517 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3519 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3520 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3521 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3522 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3528 Stream.EmitRecordWithBlob(MethodPoolAbbrev,
Record, MethodPool);
3532 Abbrev = std::make_shared<BitCodeAbbrev>();
3534 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3535 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3536 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3537 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3541 RecordData::value_type
Record[] = {
3544 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev,
Record,
3545 bytes(SelectorOffsets));
3551void ASTWriter::WriteReferencedSelectorsPool(
Sema &SemaRef) {
3552 using namespace llvm;
3564 Selector Sel = SelectorAndLocation.first;
3566 Writer.AddSelectorRef(Sel);
3588 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3590 if (!Redecl->isFromASTFile()) {
3594 if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
3597 return cast<NamedDecl>(Redecl);
3602 if (Redecl->getOwningModuleID() == 0)
3607 if (!
First->isFromASTFile())
3608 return cast<NamedDecl>(
First);
3618class ASTIdentifierTableTrait {
3631 bool IsInteresting =
3633 tok::NotableIdentifierKind::not_notable ||
3636 if (MacroOffset || II->
isPoisoned() || (!IsModule && IsInteresting) ||
3646 using key_type_ref = key_type;
3649 using data_type_ref = data_type;
3657 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3658 NeedDecls(!IsModule || !Writer.getLangOpts().
CPlusPlus),
3659 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3661 bool needDecls()
const {
return NeedDecls; }
3664 return llvm::djbHash(II->
getName());
3676 std::pair<unsigned, unsigned>
3686 if (InterestingIdentifierOffsets &&
3688 InterestingIdentifierOffsets->push_back(Out.tell());
3691 unsigned DataLen = 4;
3699 DataLen += std::distance(IdResolver.
begin(II), IdResolver.
end()) *
3705 void EmitKey(raw_ostream &Out,
const IdentifierInfo *II,
unsigned KeyLen) {
3711 using namespace llvm::support;
3713 endian::Writer
LE(Out, llvm::endianness::little);
3717 LE.write<uint32_t>(
ID << 1);
3721 LE.write<uint32_t>((
ID << 1) | 0x01);
3723 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
3724 LE.write<uint16_t>(Bits);
3726 bool HadMacroDefinition = MacroOffset != 0;
3727 Bits = (Bits << 1) |
unsigned(HadMacroDefinition);
3729 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
3732 LE.write<uint16_t>(Bits);
3734 if (HadMacroDefinition)
3735 LE.write<uint32_t>(MacroOffset);
3745 for (
NamedDecl *D : llvm::reverse(Decls))
3762 using namespace llvm;
3769 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait>
Generator;
3770 ASTIdentifierTableTrait Trait(*
this, PP, IdResolver, IsModule,
3771 IsModule ? &InterestingIdents :
nullptr);
3780 if (Trait.isInterestingNonMacroIdentifier(
ID.second))
3781 IIs.push_back(
ID.second);
3784 llvm::sort(IIs, llvm::deref<std::less<>>());
3790 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
3791 for (
auto IdentIDPair : IdentifierIDs) {
3794 assert(II &&
"NULL identifier in identifier table");
3798 if (ID >= FirstIdentID || !Chain || !II->
isFromAST() ||
3800 (Trait.needDecls() &&
3807 uint32_t BucketOffset;
3809 using namespace llvm::support;
3813 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
3814 BucketOffset =
Generator.Emit(Out, Trait);
3818 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3820 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3821 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3822 unsigned IDTableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3830 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3832 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3833 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3834 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3835 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3838 for (
unsigned I = 0, N = IdentifierOffsets.size(); I != N; ++I)
3839 assert(IdentifierOffsets[I] &&
"Missing identifier offset?");
3843 IdentifierOffsets.size(),
3845 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev,
Record,
3846 bytes(IdentifierOffsets));
3850 if (!InterestingIdents.empty())
3861class ASTDeclContextNameLookupTrait {
3867 using key_type_ref = key_type;
3870 using data_type = std::pair<unsigned, unsigned>;
3871 using data_type_ref =
const data_type &;
3876 explicit ASTDeclContextNameLookupTrait(
ASTWriter &Writer) : Writer(Writer) {}
3878 template<
typename Coll>
3879 data_type getData(
const Coll &Decls) {
3880 unsigned Start = DeclIDs.size();
3889 DeclIDs.push_back(Writer.
GetDeclRef(DeclForLocalLookup));
3891 return std::make_pair(Start, DeclIDs.size());
3895 unsigned Start = DeclIDs.size();
3900 return std::make_pair(Start, DeclIDs.size());
3903 static bool EqualKey(key_type_ref a, key_type_ref
b) {
3908 return Name.getHash();
3911 void EmitFileRef(raw_ostream &Out,
ModuleFile *F)
const {
3913 "have reference to loaded module file but no chain?");
3915 using namespace llvm::support;
3918 llvm::endianness::little);
3921 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
3923 data_type_ref Lookup) {
3924 unsigned KeyLen = 1;
3925 switch (Name.getKind()) {
3945 unsigned DataLen =
sizeof(
DeclID) * (Lookup.second - Lookup.first);
3951 using namespace llvm::support;
3953 endian::Writer
LE(Out, llvm::endianness::little);
3954 LE.write<uint8_t>(Name.getKind());
3955 switch (Name.getKind()) {
3968 "Invalid operator?");
3969 LE.write<uint8_t>(Name.getOperatorKind());
3978 llvm_unreachable(
"Invalid name kind?");
3981 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
3983 using namespace llvm::support;
3985 endian::Writer
LE(Out, llvm::endianness::little);
3986 uint64_t Start = Out.tell(); (void)Start;
3987 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
3989 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3997 return Result.hasExternalDecls() &&
3998 DC->hasNeedToReconcileExternalVisibleStorage();
4001bool ASTWriter::isLookupResultEntirelyExternalOrUnreachable(
4003 for (
auto *D :
Result.getLookupResult()) {
4005 if (LocalD->isFromASTFile())
4020ASTWriter::GenerateNameLookupTable(
const DeclContext *ConstDC,
4022 assert(!ConstDC->hasLazyLocalLexicalLookups() &&
4023 !ConstDC->hasLazyExternalLexicalLookups() &&
4024 "must call buildLookups first");
4032 ASTDeclContextNameLookupTrait>
Generator;
4033 ASTDeclContextNameLookupTrait Trait(*
this);
4045 auto &Name = Lookup.first;
4046 auto &
Result = Lookup.second;
4061 if ((GeneratingReducedBMI || isLookupResultExternal(
Result, DC)) &&
4062 isLookupResultEntirelyExternalOrUnreachable(
Result, DC))
4079 if (Lookup.second.getLookupResult().empty())
4082 switch (Lookup.first.getNameKind()) {
4084 Names.push_back(Lookup.first);
4088 assert(isa<CXXRecordDecl>(DC) &&
4089 "Cannot have a constructor name outside of a class!");
4090 ConstructorNameSet.insert(Name);
4094 assert(isa<CXXRecordDecl>(DC) &&
4095 "Cannot have a conversion function name outside of a class!");
4096 ConversionNameSet.insert(Name);
4104 if (
auto *D = dyn_cast<CXXRecordDecl>(DC)) {
4118 if (ConstructorNameSet.erase(ImplicitCtorName))
4119 Names.push_back(ImplicitCtorName);
4124 if (!ConstructorNameSet.empty() || !ConversionNameSet.empty())
4125 for (
Decl *ChildD : cast<CXXRecordDecl>(DC)->decls())
4126 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
4127 auto Name = ChildND->getDeclName();
4128 switch (Name.getNameKind()) {
4133 if (ConstructorNameSet.erase(Name))
4134 Names.push_back(Name);
4138 if (ConversionNameSet.erase(Name))
4139 Names.push_back(Name);
4143 if (ConstructorNameSet.empty() && ConversionNameSet.empty())
4147 assert(ConstructorNameSet.empty() &&
"Failed to find all of the visible "
4148 "constructors by walking all the "
4149 "lexical members of the context.");
4150 assert(ConversionNameSet.empty() &&
"Failed to find all of the visible "
4151 "conversion functions by walking all "
4152 "the lexical members of the context.");
4159 for (
auto &Name : Names)
4171 for (
auto &Name : Names) {
4174 switch (Name.getNameKind()) {
4192 if (!ConstructorDecls.empty())
4193 Generator.insert(ConstructorDecls.front()->getDeclName(),
4194 Trait.getData(ConstructorDecls), Trait);
4195 if (!ConversionDecls.empty())
4196 Generator.insert(ConversionDecls.front()->getDeclName(),
4197 Trait.getData(ConversionDecls), Trait);
4202 Generator.emit(LookupTable, Trait, Lookups ? &Lookups->Table :
nullptr);
4215 if (isa<NamespaceDecl>(DC) && Chain &&
4218 for (
auto *Prev = cast<NamespaceDecl>(DC)->getPreviousDecl(); Prev;
4219 Prev = Prev->getPreviousDecl())
4220 if (!Prev->isFromASTFile())
4233 LookupResults.reserve(Map->size());
4234 for (
auto &Entry : *Map)
4235 LookupResults.push_back(
4236 std::make_pair(Entry.first, Entry.second.getLookupResult()));
4239 llvm::sort(LookupResults, llvm::less_first());
4240 for (
auto &NameAndResult : LookupResults) {
4248 assert(
Result.empty() &&
"Cannot have a constructor or conversion "
4249 "function name in a namespace!");
4254 if (ND->isFromASTFile())
4284 uint64_t Offset = Stream.GetCurrentBitNo();
4286 if (!Map || Map->empty())
4291 GenerateNameLookupTable(DC, LookupTable);
4295 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev,
Record,
4297 ++NumVisibleDeclContexts;
4307void ASTWriter::WriteDeclContextVisibleUpdate(
const DeclContext *DC) {
4309 if (!Map || Map->empty())
4314 GenerateNameLookupTable(DC, LookupTable);
4318 if (isa<NamespaceDecl>(DC))
4324 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev,
Record, LookupTable);
4334void ASTWriter::WriteOpenCLExtensions(
Sema &SemaRef) {
4340 for (
const auto &I:Opts.OptMap) {
4342 auto V = I.getValue();
4343 Record.push_back(
V.Supported ? 1 : 0);
4344 Record.push_back(
V.Enabled ? 1 : 0);
4345 Record.push_back(
V.WithPragma ? 1 : 0);
4352void ASTWriter::WriteCUDAPragmas(
Sema &SemaRef) {
4353 if (SemaRef.
CUDA().ForceHostDeviceDepth > 0) {
4354 RecordData::value_type
Record[] = {SemaRef.
CUDA().ForceHostDeviceDepth};
4359void ASTWriter::WriteObjCCategories() {
4363 for (
unsigned I = 0, N = ObjCClassesWithCategories.size(); I != N; ++I) {
4365 unsigned StartIndex = Categories.size();
4370 Categories.push_back(0);
4374 Cat =
Class->known_categories_begin(),
4375 CatEnd =
Class->known_categories_end();
4376 Cat != CatEnd; ++Cat, ++Size) {
4382 Categories[StartIndex] =
Size;
4386 CategoriesMap.push_back(CatInfo);
4391 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
4394 using namespace llvm;
4396 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4398 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
4399 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4400 unsigned AbbrevID = Stream.EmitAbbrev(std::move(Abbrev));
4403 Stream.EmitRecordWithBlob(AbbrevID,
Record,
4404 reinterpret_cast<char *
>(CategoriesMap.data()),
4411void ASTWriter::WriteLateParsedTemplates(
Sema &SemaRef) {
4418 for (
auto &LPTMapEntry : LPTMap) {
4426 for (
const auto &Tok : LPT.
Toks) {
4434void ASTWriter::WriteOptimizePragmaOptions(
Sema &SemaRef) {
4442void ASTWriter::WriteMSStructPragmaOptions(
Sema &SemaRef) {
4450void ASTWriter::WriteMSPointersToMembersPragmaOptions(
Sema &SemaRef) {
4458void ASTWriter::WritePackPragmaOptions(
Sema &SemaRef) {
4478void ASTWriter::WriteFloatControlPragmaOptions(
Sema &SemaRef) {
4488 for (
const auto &StackEntry : SemaRef.
FpPragmaStack.Stack) {
4489 Record.push_back(StackEntry.Value.getAsOpaqueInt());
4497void ASTWriter::WriteModuleFileExtension(
Sema &SemaRef,
4503 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
4505 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4506 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4507 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4508 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4509 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4510 unsigned Abbrev = Stream.EmitAbbrev(std::move(Abv));
4516 Record.push_back(Metadata.MajorVersion);
4517 Record.push_back(Metadata.MinorVersion);
4518 Record.push_back(Metadata.BlockName.size());
4519 Record.push_back(Metadata.UserInfo.size());
4521 Buffer += Metadata.BlockName;
4522 Buffer += Metadata.UserInfo;
4523 Stream.EmitRecordWithBlob(Abbrev,
Record, Buffer);
4541 if (!A || (isa<PreferredNameAttr>(A) &&
4542 Writer->isWritingStdCXXNamedModules()))
4543 return Record.push_back(0);
4553 Record.push_back(A->getAttributeSpellingListIndexRaw());
4556#include "clang/Serialization/AttrPCHWrite.inc"
4562 for (
const auto *A : Attrs)
4576 case tok::annot_pragma_loop_hint: {
4580 Record.push_back(Info->Toks.size());
4581 for (
const auto &
T : Info->Toks)
4585 case tok::annot_pragma_pack: {
4588 Record.push_back(
static_cast<unsigned>(Info->Action));
4594 case tok::annot_pragma_openmp:
4595 case tok::annot_pragma_openmp_end:
4596 case tok::annot_pragma_unused:
4597 case tok::annot_pragma_openacc:
4598 case tok::annot_pragma_openacc_end:
4601 llvm_unreachable(
"missing serialization code for annotation token");
4612 Record.push_back(Str.size());
4617 assert(Context &&
"should have context when outputting path");
4620 StringRef PathStr(Path.data(), Path.size());
4621 if (PathStr ==
"<built-in>" || PathStr ==
"<command line>")
4628 const char *PathBegin = Path.data();
4629 const char *PathPtr =
4631 if (PathPtr != PathBegin) {
4632 Path.erase(Path.begin(), Path.begin() + (PathPtr - PathBegin));
4649 Stream.EmitRecordWithBlob(Abbrev,
Record, FilePath);
4654 Record.push_back(Version.getMajor());
4655 if (std::optional<unsigned> Minor = Version.getMinor())
4656 Record.push_back(*Minor + 1);
4659 if (std::optional<unsigned> Subminor = Version.getSubminor())
4660 Record.push_back(*Subminor + 1);
4668 IdentID ID = IdentifierIDs[II];
4671 if (ID >= FirstIdentID)
4672 IdentifierOffsets[ID - FirstIdentID] = Offset;
4678 unsigned ID = SelectorIDs[Sel];
4679 assert(ID &&
"Unknown selector");
4682 if (ID < FirstSelectorID)
4684 SelectorOffsets[ID - FirstSelectorID] = Offset;
4690 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
4691 bool IncludeTimestamps,
bool BuildingImplicitModule,
4692 bool GeneratingReducedBMI)
4693 : Stream(Stream), Buffer(Buffer), ModuleCache(ModuleCache),
4694 IncludeTimestamps(IncludeTimestamps),
4695 BuildingImplicitModule(BuildingImplicitModule),
4696 GeneratingReducedBMI(GeneratingReducedBMI) {
4697 for (
const auto &Ext : Extensions) {
4698 if (
auto Writer = Ext->createExtensionWriter(*
this))
4699 ModuleFileExtensionWriters.push_back(std::move(Writer));
4706 assert(WritingAST &&
"can't determine lang opts when not writing AST");
4715 Module *WritingModule, StringRef isysroot,
4716 bool ShouldCacheASTInMemory) {
4717 llvm::TimeTraceScope scope(
"WriteAST", OutputFile);
4720 ASTHasCompilerErrors =
4724 Stream.Emit((
unsigned)
'C', 8);
4725 Stream.Emit((
unsigned)
'P', 8);
4726 Stream.Emit((
unsigned)
'C', 8);
4727 Stream.Emit((
unsigned)
'H', 8);
4729 WriteBlockInfoBlock();
4733 this->WritingModule = WritingModule;
4734 ASTFileSignature Signature = WriteASTCore(SemaRef, isysroot, WritingModule);
4737 this->WritingModule =
nullptr;
4738 this->BaseDirectory.clear();
4741 if (ShouldCacheASTInMemory) {
4744 llvm::MemoryBuffer::getMemBufferCopy(
4745 StringRef(Buffer.begin(), Buffer.size())));
4750template<
typename Vector>
4752 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
4758template <
typename Vector>
4761 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
4767void ASTWriter::computeNonAffectingInputFiles() {
4771 IsSLocAffecting.resize(N,
true);
4776 auto AffectingModuleMaps = GetAffectingModuleMaps(*PP, WritingModule);
4778 unsigned FileIDAdjustment = 0;
4779 unsigned OffsetAdjustment = 0;
4781 NonAffectingFileIDAdjustments.reserve(N);
4782 NonAffectingOffsetAdjustments.reserve(N);
4784 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
4785 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
4787 for (
unsigned I = 1; I != N; ++I) {
4789 FileID FID = FileID::get(I);
4796 if (!
Cache->OrigEntry)
4804 if (!AffectingModuleMaps)
4808 if (llvm::is_contained(*AffectingModuleMaps, *
Cache->OrigEntry))
4811 IsSLocAffecting[I] =
false;
4813 FileIDAdjustment += 1;
4819 if (!NonAffectingFileIDs.empty() &&
4820 NonAffectingFileIDs.back().ID == FID.ID - 1) {
4821 NonAffectingFileIDs.back() = FID;
4823 NonAffectingFileIDAdjustments.back() = FileIDAdjustment;
4824 NonAffectingOffsetAdjustments.back() = OffsetAdjustment;
4828 NonAffectingFileIDs.push_back(FID);
4831 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
4832 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
4841 for (StringRef Path :
4844 for (
unsigned I = 1; I != N; ++I) {
4845 if (IsSLocAffecting[I]) {
4851 if (!
Cache->OrigEntry)
4854 Cache->OrigEntry->getNameAsRequested());
4860void ASTWriter::PrepareWritingSpecialDecls(
Sema &SemaRef) {
4863 bool isModule = WritingModule !=
nullptr;
4877 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
4881 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
4885 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
4890 RegisterPredefDecl(Context.MakeIntegerSeqDecl,
4892 RegisterPredefDecl(Context.CFConstantStringTypeDecl,
4894 RegisterPredefDecl(Context.CFConstantStringTagDecl,
4896 RegisterPredefDecl(Context.TypePackElementDecl,
4909 if (GeneratingReducedBMI) {
4920 if (
auto *ND = dyn_cast<NamedDecl>(D);
4928 if (GeneratingReducedBMI)
4951 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I)
4962 "There are local ones at end of translation unit!");
4975 for (
const auto &I : SemaRef.KnownNamespaces)
4982 for (
const auto &I : Undefined)
4988 for (
const auto &DeleteExprsInfo :
4995 for (
const auto *I : DeclsToEmitEvenIfUnreferenced)
4997 DeclsToEmitEvenIfUnreferenced.clear();
5009 llvm::sort(IIs, llvm::deref<std::less<>>());
5016 for (
auto *D : SemaRef.DeclsToCheckForDeferredDiags)
5020void ASTWriter::WriteSpecialDeclRecords(
Sema &SemaRef) {
5023 bool isModule = WritingModule !=
nullptr;
5026 if (!EagerlyDeserializedDecls.empty())
5029 if (!ModularCodegenDecls.empty())
5035 TentativeDefinitions);
5036 if (!TentativeDefinitions.empty())
5043 UnusedFileScopedDecls);
5044 if (!UnusedFileScopedDecls.empty())
5050 if (!ExtVectorDecls.empty())
5056 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I) {
5072 if (!UnusedLocalTypedefNameCandidates.empty())
5074 UnusedLocalTypedefNameCandidates);
5085 if (!PendingInstantiations.empty())
5091 auto AddEmittedDeclRefOrZero = [
this, &SemaDeclRefs](
Decl *D) {
5093 SemaDeclRefs.push_back(0);
5102 if (!SemaDeclRefs.empty())
5107 for (
auto *D : SemaRef.DeclsToCheckForDeferredDiags)
5110 if (!DeclsToCheckForDeferredDiags.empty())
5112 DeclsToCheckForDeferredDiags);
5118 AddDeclRef(CudaCallDecl, CUDASpecialDeclRefs);
5126 DelegatingCtorDecls);
5127 if (!DelegatingCtorDecls.empty())
5132 for (
const auto &I : SemaRef.KnownNamespaces) {
5136 if (!KnownNamespaces.empty())
5143 for (
const auto &I : Undefined) {
5150 if (!UndefinedButUsed.empty())
5157 for (
const auto &DeleteExprsInfo :
5162 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
5163 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
5164 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
5166 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
5170 if (!DeleteExprsToAnalyze.empty())
5176 using namespace llvm;
5178 bool isModule = WritingModule !=
nullptr;
5189 computeNonAffectingInputFiles();
5191 writeUnhashedControlBlock(PP, Context);
5197 for (
const auto &WeakUndeclaredIdentifierList :
5199 const IdentifierInfo *
const II = WeakUndeclaredIdentifierList.first;
5200 for (
const auto &WI : WeakUndeclaredIdentifierList.second) {
5207 PrepareWritingSpecialDecls(SemaRef);
5210 WriteControlBlock(PP, Context, isysroot);
5213 Stream.FlushToWord();
5214 ASTBlockRange.first = Stream.GetCurrentBitNo() >> 3;
5216 ASTBlockStartOffset = Stream.GetCurrentBitNo();
5233 for (
auto &SelectorAndID : SelectorIDs)
5234 AllSelectors.push_back(SelectorAndID.first);
5235 for (
auto &
Selector : AllSelectors)
5244 AddTypeRef(Context.ObjCIdRedefinitionType, SpecialTypes);
5245 AddTypeRef(Context.ObjCClassRedefinitionType, SpecialTypes);
5246 AddTypeRef(Context.ObjCSelRedefinitionType, SpecialTypes);
5269 auto Abbrev = std::make_shared<BitCodeAbbrev>();
5271 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
5272 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
5275 llvm::raw_svector_ostream Out(Buffer);
5277 using namespace llvm::support;
5279 endian::Writer
LE(Out, llvm::endianness::little);
5280 LE.write<uint8_t>(
static_cast<uint8_t
>(M.
Kind));
5282 LE.write<uint16_t>(Name.size());
5283 Out.write(Name.data(), Name.size());
5287 uint32_t
None = std::numeric_limits<uint32_t>::max();
5289 auto writeBaseIDOrNone = [&](
auto BaseID,
bool ShouldWrite) {
5290 assert(BaseID < std::numeric_limits<uint32_t>::max() &&
"base id too high");
5292 LE.write<uint32_t>(BaseID);
5294 LE.write<uint32_t>(
None);
5311 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev,
Record,
5312 Buffer.data(), Buffer.size());
5315 WriteDeclAndTypes(Context);
5317 WriteFileDeclIDsMap();
5320 WritePreprocessor(PP, isModule);
5322 WriteSelectors(SemaRef);
5323 WriteReferencedSelectorsPool(SemaRef);
5324 WriteLateParsedTemplates(SemaRef);
5325 WriteIdentifierTable(PP, SemaRef.
IdResolver, isModule);
5327 WriteOpenCLExtensions(SemaRef);
5328 WriteCUDAPragmas(SemaRef);
5332 WriteSubmodules(WritingModule);
5336 WriteSpecialDeclRecords(SemaRef);
5339 if (!WeakUndeclaredIdentifiers.empty())
5341 WeakUndeclaredIdentifiers);
5343 if (!WritingModule) {
5352 assert(SubmoduleIDs.contains(I->getImportedModule()));
5353 Imports.push_back(ModuleInfo(SubmoduleIDs[I->getImportedModule()],
5354 I->getImportedModule()));
5357 if (!Imports.empty()) {
5358 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
5361 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
5362 return A.ID == B.ID;
5366 llvm::sort(Imports, Cmp);
5367 Imports.erase(std::unique(Imports.begin(), Imports.end(),
Eq),
5371 for (
const auto &Import : Imports) {
5372 ImportedModules.push_back(
Import.ID);
5383 WriteObjCCategories();
5384 if(!WritingModule) {
5385 WriteOptimizePragmaOptions(SemaRef);
5386 WriteMSStructPragmaOptions(SemaRef);
5387 WriteMSPointersToMembersPragmaOptions(SemaRef);
5389 WritePackPragmaOptions(SemaRef);
5390 WriteFloatControlPragmaOptions(SemaRef);
5393 RecordData::value_type
Record[] = {
5394 NumStatements, NumMacros, NumLexicalDeclContexts, NumVisibleDeclContexts};
5397 Stream.FlushToWord();
5398 ASTBlockRange.second = Stream.GetCurrentBitNo() >> 3;
5401 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
5402 WriteModuleFileExtension(SemaRef, *ExtWriter);
5404 return backpatchSignature();
5407void ASTWriter::EnteringModulePurview() {
5410 if (GeneratingReducedBMI)
5411 DeclUpdatesFromGMF.swap(DeclUpdates);
5417void ASTWriter::AddedManglingNumber(
const Decl *D,
unsigned Number) {
5423void ASTWriter::AddedStaticLocalNumbers(
const Decl *D,
unsigned Number) {
5442void ASTWriter::WriteDeclAndTypes(
ASTContext &Context) {
5447 DeclTypesBlockStartOffset = Stream.GetCurrentBitNo();
5451 WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord);
5452 while (!DeclTypesToEmit.empty()) {
5453 DeclOrType DOT = DeclTypesToEmit.front();
5454 DeclTypesToEmit.pop();
5456 WriteType(DOT.getType());
5458 WriteDecl(Context, DOT.getDecl());
5460 }
while (!DeclUpdates.empty());
5462 DoneWritingDeclsAndTypes =
true;
5466 assert(DelayedNamespace.empty() || GeneratingReducedBMI);
5469 uint64_t LexicalOffset = WriteDeclContextLexicalBlock(Context, NS);
5470 uint64_t VisibleOffset = WriteDeclContextVisibleBlock(Context, NS);
5474 LexicalOffset -= DeclTypesBlockStartOffset;
5477 VisibleOffset -= DeclTypesBlockStartOffset;
5480 DelayedNamespaceRecord.push_back(LexicalOffset);
5481 DelayedNamespaceRecord.push_back(VisibleOffset);
5486 assert(DeclTypesToEmit.empty());
5487 assert(DeclUpdates.empty());
5492 WriteTypeDeclOffsets();
5493 if (!DeclUpdatesOffsetsRecord.empty())
5496 if (!DelayedNamespaceRecord.empty())
5498 DelayedNamespaceRecord);
5512 NewGlobalKindDeclPairs.push_back(D->
getKind());
5513 NewGlobalKindDeclPairs.push_back(
GetDeclRef(D).get());
5516 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
5518 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
5519 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
5522 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev,
Record,
5523 bytes(NewGlobalKindDeclPairs));
5525 Abv = std::make_shared<llvm::BitCodeAbbrev>();
5527 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5528 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
5529 UpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
5532 WriteDeclContextVisibleUpdate(TU);
5535 if (Context.ExternCContext)
5536 WriteDeclContextVisibleUpdate(Context.ExternCContext);
5539 for (
auto *DC : UpdatedDeclContexts)
5540 WriteDeclContextVisibleUpdate(DC);
5543void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
5544 if (DeclUpdates.empty())
5547 DeclUpdateMap LocalUpdates;
5548 LocalUpdates.swap(DeclUpdates);
5550 for (
auto &DeclUpdate : LocalUpdates) {
5551 const Decl *D = DeclUpdate.first;
5553 bool HasUpdatedBody =
false;
5554 bool HasAddedVarDefinition =
false;
5557 for (
auto &
Update : DeclUpdate.second) {
5563 HasUpdatedBody =
true;
5565 HasAddedVarDefinition =
true;
5573 assert(
Update.getDecl() &&
"no decl to add?");
5588 cast<ParmVarDecl>(
Update.getDecl())->getDefaultArg()));
5593 cast<FieldDecl>(
Update.getDecl())->getInClassInitializer());
5597 auto *RD = cast<CXXRecordDecl>(D);
5598 UpdatedDeclContexts.insert(RD->getPrimaryContext());
5599 Record.push_back(RD->isParamDestroyedInCallee());
5600 Record.push_back(llvm::to_underlying(RD->getArgPassingRestrictions()));
5601 Record.AddCXXDefinitionData(RD);
5602 Record.AddOffset(WriteDeclContextLexicalBlock(
5608 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
5609 Record.push_back(MSInfo->getTemplateSpecializationKind());
5610 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
5612 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
5613 Record.push_back(Spec->getTemplateSpecializationKind());
5614 Record.AddSourceLocation(Spec->getPointOfInstantiation());
5618 auto From = Spec->getInstantiatedFrom();
5619 if (
auto PartialSpec =
5622 Record.AddDeclRef(PartialSpec);
5623 Record.AddTemplateArgumentList(
5624 &Spec->getTemplateInstantiationArgs());
5629 Record.push_back(llvm::to_underlying(RD->getTagKind()));
5630 Record.AddSourceLocation(RD->getLocation());
5631 Record.AddSourceLocation(RD->getBeginLoc());
5632 Record.AddSourceRange(RD->getBraceRange());
5645 Record.AddStmt(cast<CXXDestructorDecl>(D)->getOperatorDeleteThisArg());
5651 Record.writeExceptionSpecInfo(prototype->getExceptionSpecInfo());
5669 D->
getAttr<OMPThreadPrivateDeclAttr>()->getRange());
5673 auto *A = D->
getAttr<OMPAllocateDeclAttr>();
5674 Record.push_back(A->getAllocatorType());
5675 Record.AddStmt(A->getAllocator());
5676 Record.AddStmt(A->getAlignment());
5677 Record.AddSourceRange(A->getRange());
5682 Record.push_back(D->
getAttr<OMPDeclareTargetDeclAttr>()->getMapType());
5684 D->
getAttr<OMPDeclareTargetDeclAttr>()->getRange());
5700 if (HasUpdatedBody) {
5701 const auto *Def = cast<FunctionDecl>(D);
5703 Record.push_back(Def->isInlined());
5704 Record.AddSourceLocation(Def->getInnerLocStart());
5705 Record.AddFunctionDefinition(Def);
5706 }
else if (HasAddedVarDefinition) {
5707 const auto *VD = cast<VarDecl>(D);
5709 Record.push_back(VD->isInline());
5710 Record.push_back(VD->isInlineSpecified());
5711 Record.AddVarDeclInit(VD);
5728 NonAffectingFileIDs.empty())
5730 auto It = llvm::lower_bound(NonAffectingFileIDs, FID);
5731 unsigned Idx = std::distance(NonAffectingFileIDs.begin(), It);
5732 unsigned Offset = NonAffectingFileIDAdjustments[Idx];
5733 return FileID::get(FID.getOpaqueValue() - Offset);
5736unsigned ASTWriter::getAdjustedNumCreatedFIDs(
FileID FID)
const {
5742 unsigned AdjustedNumCreatedFIDs = 0;
5743 for (
unsigned I = FID.ID, N = I + NumCreatedFIDs; I != N; ++I)
5744 if (IsSLocAffecting[I])
5745 ++AdjustedNumCreatedFIDs;
5746 return AdjustedNumCreatedFIDs;
5757 getAdjustedLocation(
Range.getEnd()));
5762 return Offset - getAdjustment(Offset);
5767 if (NonAffectingRanges.empty())
5773 if (Offset > NonAffectingRanges.back().getEnd().getOffset())
5774 return NonAffectingOffsetAdjustments.back();
5776 if (Offset < NonAffectingRanges.front().getBegin().getOffset())
5780 return Range.getEnd().getOffset() < Offset;
5783 auto It = llvm::lower_bound(NonAffectingRanges, Offset, Contains);
5784 unsigned Idx = std::distance(NonAffectingRanges.begin(), It);
5785 return NonAffectingOffsetAdjustments[Idx];
5789 Record.push_back(getAdjustedFileID(FID).getOpaqueValue());
5794 Loc = getAdjustedLocation(Loc);
5816 IdentID &ID = IdentifierIDs[II];
5832 MacroInfoToEmitData Info = { Name, MI, ID };
5833 MacroInfosToEmit.push_back(Info);
5842 assert(MacroIDs.contains(MI) &&
"Macro not emitted!");
5843 return MacroIDs[MI];
5847 return IdentMacroDirectivesOffsetMap.lookup(Name);
5851 Record->push_back(Writer->getSelectorRef(SelRef));
5860 if (SID == 0 && Chain) {
5864 SID = SelectorIDs[Sel];
5867 SID = NextSelectorID++;
5868 SelectorIDs[Sel] = SID;
5910 bool InfoHasSameExpr
5912 Record->push_back(InfoHasSameExpr);
5913 if (InfoHasSameExpr)
5931 TypeLocWriter TLW(*
this,
Seq);
5945 assert(!
T.getLocalFastQualifiers());
5949 if (DoneWritingDeclsAndTypes) {
5950 assert(0 &&
"New type seen after serializing all the types to emit!");
5957 DeclTypesToEmit.push(
T);
5968 assert(!
T.getLocalFastQualifiers());
5970 TypeIdxMap::const_iterator I = TypeIdxs.find(
T);
5971 assert(I != TypeIdxs.end() &&
"Type not emitted!");
5988 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
5995 if (
auto *
Iter = DeclUpdatesFromGMF.find(D);
5996 Iter != DeclUpdatesFromGMF.end()) {
5998 DeclUpdates[D].push_back(
Update);
5999 DeclUpdatesFromGMF.erase(
Iter);
6007 assert(!(
reinterpret_cast<uintptr_t>(D) & 0x01) &&
"Invalid decl pointer");
6009 if (ID.isInvalid()) {
6010 if (DoneWritingDeclsAndTypes) {
6011 assert(0 &&
"New decl seen after serializing all the decls to emit!");
6018 DeclTypesToEmit.push(
const_cast<Decl *
>(D));
6033 assert(DeclIDs.contains(D) &&
"Declaration not emitted!");
6040 assert(DoneWritingDeclsAndTypes &&
6041 "wasDeclEmitted should only be called after writing declarations");
6046 bool Emitted = DeclIDs.contains(D);
6047 assert((Emitted || GeneratingReducedBMI) &&
6048 "The declaration can only be omitted in reduced BMI.");
6053 assert(ID.isValid());
6067 if (isa<ParmVarDecl, TemplateTemplateParmDecl>(D))
6072 assert(
SM.isLocalSourceLocation(FileLoc));
6075 std::tie(FID, Offset) =
SM.getDecomposedLoc(FileLoc);
6078 assert(
SM.getSLocEntry(FID).isFile());
6079 assert(IsSLocAffecting[FID.ID]);
6081 std::unique_ptr<DeclIDInFileInfo> &Info = FileDeclIDs[FID];
6083 Info = std::make_unique<DeclIDInFileInfo>();
6085 std::pair<unsigned, LocalDeclID> LocDecl(Offset, ID);
6086 LocDeclIDsTy &Decls = Info->DeclIDs;
6087 Decls.push_back(LocDecl);
6092 "expected an anonymous declaration");
6096 auto It = AnonymousDeclarationNumbers.find(D);
6097 if (It == AnonymousDeclarationNumbers.end()) {
6100 AnonymousDeclarationNumbers[ND] = Number;
6103 It = AnonymousDeclarationNumbers.find(D);
6104 assert(It != AnonymousDeclarationNumbers.end() &&
6105 "declaration not found within its lexical context");
6113 switch (Name.getNameKind()) {
6160 NestedNames.push_back(NNS);
6164 Record->push_back(NestedNames.size());
6165 while(!NestedNames.empty()) {
6166 NNS = NestedNames.pop_back_val();
6208 assert(TemplateParams &&
"No TemplateParams!");
6214 for (
const auto &
P : *TemplateParams)
6220 Record->push_back(
false);
6227 assert(TemplateArgs &&
"No TemplateArgs!");
6229 for (
int i = 0, e = TemplateArgs->
size(); i != e; ++i)
6235 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
6247 I =
Set.begin(), E =
Set.end(); I != E; ++I) {
6249 Record->push_back(I.getAccess());
6257 Record->push_back(
Base.getAccessSpecifierAsWritten());
6258 Record->push_back(
Base.getInheritConstructors());
6271 for (
auto &
Base : Bases)
6289 for (
auto *
Init : CtorInits) {
6290 if (
Init->isBaseInitializer()) {
6294 }
else if (
Init->isDelegatingInitializer()) {
6297 }
else if (
Init->isMemberInitializer()){
6310 if (
Init->isWritten())
6324 auto &
Data = D->data();
6331 DefinitionBits.
addBit(ShouldSkipCheckingODR);
6333#define FIELD(Name, Width, Merge) \
6334 if (!DefinitionBits.canWriteNextNBits(Width)) { \
6335 Record->push_back(DefinitionBits); \
6336 DefinitionBits.reset(0); \
6338 DefinitionBits.addBits(Data.Name, Width);
6340#include "clang/AST/CXXRecordDeclDefinitionBits.def"
6343 Record->push_back(DefinitionBits);
6346 if (!ShouldSkipCheckingODR)
6351 bool ModulesDebugInfo =
6352 Writer->Context->getLangOpts().ModulesDebugInfo && !D->
isDependentType();
6353 Record->push_back(ModulesDebugInfo);
6354 if (ModulesDebugInfo)
6355 Writer->AddDeclRef(D, Writer->ModularCodegenDecls);
6360 Record->push_back(
Data.ComputedVisibleConversions);
6361 if (
Data.ComputedVisibleConversions)
6365 if (!
Data.IsLambda) {
6367 if (
Data.NumBases > 0)
6372 if (
Data.NumVBases > 0)
6377 auto &Lambda = D->getLambdaData();
6380 LambdaBits.
addBits(Lambda.DependencyKind, 2);
6381 LambdaBits.
addBit(Lambda.IsGenericLambda);
6382 LambdaBits.
addBits(Lambda.CaptureDefault, 2);
6383 LambdaBits.
addBits(Lambda.NumCaptures, 15);
6384 LambdaBits.
addBit(Lambda.HasKnownInternalLinkage);
6385 Record->push_back(LambdaBits);
6387 Record->push_back(Lambda.NumExplicitCaptures);
6388 Record->push_back(Lambda.ManglingNumber);
6393 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
6400 Record->push_back(CaptureBits);
6402 switch (
Capture.getCaptureKind()) {
6429 Val |= (ES->HasConstantInitialization ? 2 : 0);
6430 Val |= (ES->HasConstantDestruction ? 4 : 0);
6444void ASTWriter::ReaderInitialized(
ASTReader *Reader) {
6445 assert(Reader &&
"Cannot remove chain");
6446 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
6447 assert(FirstDeclID == NextDeclID &&
6448 FirstTypeID == NextTypeID &&
6449 FirstIdentID == NextIdentID &&
6450 FirstMacroID == NextMacroID &&
6451 FirstSubmoduleID == NextSubmoduleID &&
6452 FirstSelectorID == NextSelectorID &&
6453 "Setting chain after writing has started.");
6465 NextDeclID = FirstDeclID;
6466 NextTypeID = FirstTypeID;
6467 NextIdentID = FirstIdentID;
6468 NextMacroID = FirstMacroID;
6469 NextSelectorID = FirstSelectorID;
6470 NextSubmoduleID = FirstSubmoduleID;
6475 IdentID &StoredID = IdentifierIDs[II];
6482 MacroID &StoredID = MacroIDs[MI];
6507 assert(!MacroDefinitions.contains(MD));
6508 MacroDefinitions[MD] =
ID;
6512 assert(!SubmoduleIDs.contains(Mod));
6513 SubmoduleIDs[Mod] =
ID;
6516void ASTWriter::CompletedTagDefinition(
const TagDecl *D) {
6519 assert(!WritingAST &&
"Already writing the AST!");
6520 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
6522 if (RD->isFromASTFile()) {
6527 "completed a tag from another module but not by instantiation?");
6528 DeclUpdates[RD].push_back(
6543void ASTWriter::AddedVisibleDecl(
const DeclContext *DC,
const Decl *D) {
6546 "Should not add lookup results to non-lookup contexts!");
6549 if (isa<TranslationUnitDecl>(DC))
6557 !isa<FunctionTemplateDecl>(D))
6567 assert(!WritingAST &&
"Already writing the AST!");
6568 if (UpdatedDeclContexts.insert(DC) && !cast<Decl>(DC)->isFromASTFile()) {
6572 llvm::append_range(DeclsToEmitEvenIfUnreferenced, DC->
decls());
6574 DeclsToEmitEvenIfUnreferenced.push_back(D);
6586 if (!isa<CXXMethodDecl>(D))
6591 assert(!WritingAST &&
"Already writing the AST!");
6595void ASTWriter::ResolvedExceptionSpec(
const FunctionDecl *FD) {
6597 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
6604 ->castAs<FunctionProtoType>()
6605 ->getExceptionSpecType()))
6612 assert(!WritingAST &&
"Already writing the AST!");
6615 DeclUpdates[D].push_back(
6624 assert(!WritingAST &&
"Already writing the AST!");
6625 assert(
Delete &&
"Not given an operator delete");
6632void ASTWriter::CompletedImplicitDefinition(
const FunctionDecl *D) {
6634 assert(!WritingAST &&
"Already writing the AST!");
6642void ASTWriter::VariableDefinitionInstantiated(
const VarDecl *D) {
6644 assert(!WritingAST &&
"Already writing the AST!");
6651void ASTWriter::FunctionDefinitionInstantiated(
const FunctionDecl *D) {
6653 assert(!WritingAST &&
"Already writing the AST!");
6660void ASTWriter::InstantiationRequested(
const ValueDecl *D) {
6662 assert(!WritingAST &&
"Already writing the AST!");
6669 if (
auto *VD = dyn_cast<VarDecl>(D))
6670 POI = VD->getPointOfInstantiation();
6672 POI = cast<FunctionDecl>(D)->getPointOfInstantiation();
6676void ASTWriter::DefaultArgumentInstantiated(
const ParmVarDecl *D) {
6678 assert(!WritingAST &&
"Already writing the AST!");
6682 DeclUpdates[D].push_back(
6686void ASTWriter::DefaultMemberInitializerInstantiated(
const FieldDecl *D) {
6687 assert(!WritingAST &&
"Already writing the AST!");
6691 DeclUpdates[D].push_back(
6698 assert(!WritingAST &&
"Already writing the AST!");
6702 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
6703 ObjCClassesWithCategories.insert(
6707void ASTWriter::DeclarationMarkedUsed(
const Decl *D) {
6709 assert(!WritingAST &&
"Already writing the AST!");
6721void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(
const Decl *D) {
6723 assert(!WritingAST &&
"Already writing the AST!");
6730void ASTWriter::DeclarationMarkedOpenMPAllocate(
const Decl *D,
const Attr *A) {
6732 assert(!WritingAST &&
"Already writing the AST!");
6739void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
6742 assert(!WritingAST &&
"Already writing the AST!");
6746 DeclUpdates[D].push_back(
6750void ASTWriter::RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M) {
6752 assert(!WritingAST &&
"Already writing the AST!");
6757void ASTWriter::AddedAttributeToRecord(
const Attr *
Attr,
6760 assert(!WritingAST &&
"Already writing the AST!");
6761 if (!
Record->isFromASTFile())
6766void ASTWriter::AddedCXXTemplateSpecialization(
6768 assert(!WritingAST &&
"Already writing the AST!");
6775 DeclsToEmitEvenIfUnreferenced.push_back(D);
6778void ASTWriter::AddedCXXTemplateSpecialization(
6780 assert(!WritingAST &&
"Already writing the AST!");
6787 DeclsToEmitEvenIfUnreferenced.push_back(D);
6792 assert(!WritingAST &&
"Already writing the AST!");
6799 DeclsToEmitEvenIfUnreferenced.push_back(D);
6813#define GEN_CLANG_CLAUSE_CLASS
6814#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
6815#include "llvm/Frontend/OpenMP/OMP.inc"
6824 OMPClauseWriter(*this).writeClause(
C);
6827void OMPClauseWriter::writeClause(
OMPClause *
C) {
6828 Record.push_back(
unsigned(
C->getClauseKind()));
6830 Record.AddSourceLocation(
C->getBeginLoc());
6831 Record.AddSourceLocation(
C->getEndLoc());
6835 Record.push_back(uint64_t(
C->getCaptureRegion()));
6836 Record.AddStmt(
C->getPreInitStmt());
6840 VisitOMPClauseWithPreInit(
C);
6841 Record.AddStmt(
C->getPostUpdateExpr());
6844void OMPClauseWriter::VisitOMPIfClause(
OMPIfClause *
C) {
6845 VisitOMPClauseWithPreInit(
C);
6847 Record.AddSourceLocation(
C->getNameModifierLoc());
6848 Record.AddSourceLocation(
C->getColonLoc());
6849 Record.AddStmt(
C->getCondition());
6850 Record.AddSourceLocation(
C->getLParenLoc());
6854 VisitOMPClauseWithPreInit(
C);
6855 Record.AddStmt(
C->getCondition());
6856 Record.AddSourceLocation(
C->getLParenLoc());
6860 VisitOMPClauseWithPreInit(
C);
6861 Record.AddStmt(
C->getNumThreads());
6862 Record.AddSourceLocation(
C->getLParenLoc());
6866 Record.AddStmt(
C->getSafelen());
6867 Record.AddSourceLocation(
C->getLParenLoc());
6871 Record.AddStmt(
C->getSimdlen());
6872 Record.AddSourceLocation(
C->getLParenLoc());
6876 Record.push_back(
C->getNumSizes());
6877 for (
Expr *Size :
C->getSizesRefs())
6879 Record.AddSourceLocation(
C->getLParenLoc());
6885 Record.AddStmt(
C->getFactor());
6886 Record.AddSourceLocation(
C->getLParenLoc());
6890 Record.AddStmt(
C->getAllocator());
6891 Record.AddSourceLocation(
C->getLParenLoc());
6895 Record.AddStmt(
C->getNumForLoops());
6896 Record.AddSourceLocation(
C->getLParenLoc());
6900 Record.AddStmt(
C->getEventHandler());
6901 Record.AddSourceLocation(
C->getLParenLoc());
6905 Record.push_back(
unsigned(
C->getDefaultKind()));
6906 Record.AddSourceLocation(
C->getLParenLoc());
6907 Record.AddSourceLocation(
C->getDefaultKindKwLoc());
6911 Record.push_back(
unsigned(
C->getProcBindKind()));
6912 Record.AddSourceLocation(
C->getLParenLoc());
6913 Record.AddSourceLocation(
C->getProcBindKindKwLoc());
6917 VisitOMPClauseWithPreInit(
C);
6918 Record.push_back(
C->getScheduleKind());
6919 Record.push_back(
C->getFirstScheduleModifier());
6920 Record.push_back(
C->getSecondScheduleModifier());
6921 Record.AddStmt(
C->getChunkSize());
6922 Record.AddSourceLocation(
C->getLParenLoc());
6923 Record.AddSourceLocation(
C->getFirstScheduleModifierLoc());
6924 Record.AddSourceLocation(
C->getSecondScheduleModifierLoc());
6925 Record.AddSourceLocation(
C->getScheduleKindLoc());
6926 Record.AddSourceLocation(
C->getCommaLoc());
6930 Record.push_back(
C->getLoopNumIterations().size());
6931 Record.AddStmt(
C->getNumForLoops());
6932 for (
Expr *NumIter :
C->getLoopNumIterations())
6934 for (
unsigned I = 0, E =
C->getLoopNumIterations().size(); I <E; ++I)
6935 Record.AddStmt(
C->getLoopCounter(I));
6936 Record.AddSourceLocation(
C->getLParenLoc());
6950 Record.push_back(
C->isExtended() ? 1 : 0);
6951 if (
C->isExtended()) {
6952 Record.AddSourceLocation(
C->getLParenLoc());
6953 Record.AddSourceLocation(
C->getArgumentLoc());
6954 Record.writeEnum(
C->getDependencyKind());
6964 Record.AddSourceLocation(
C->getLParenLoc());
6965 Record.AddSourceLocation(
C->getFailParameterLoc());
6966 Record.writeEnum(
C->getFailParameter());
6988 Record.push_back(
C->varlist_size());
6989 for (
Expr *VE :
C->varlists())
6991 Record.writeBool(
C->getIsTarget());
6992 Record.writeBool(
C->getIsTargetSync());
6993 Record.AddSourceLocation(
C->getLParenLoc());
6994 Record.AddSourceLocation(
C->getVarLoc());
6998 Record.AddStmt(
C->getInteropVar());
6999 Record.AddSourceLocation(
C->getLParenLoc());
7000 Record.AddSourceLocation(
C->getVarLoc());
7004 Record.AddStmt(
C->getInteropVar());
7005 Record.AddSourceLocation(
C->getLParenLoc());
7006 Record.AddSourceLocation(
C->getVarLoc());
7010 VisitOMPClauseWithPreInit(
C);
7011 Record.AddStmt(
C->getCondition());
7012 Record.AddSourceLocation(
C->getLParenLoc());
7016 VisitOMPClauseWithPreInit(
C);
7017 Record.AddStmt(
C->getCondition());
7018 Record.AddSourceLocation(
C->getLParenLoc());
7022 VisitOMPClauseWithPreInit(
C);
7023 Record.AddStmt(
C->getThreadID());
7024 Record.AddSourceLocation(
C->getLParenLoc());
7028 Record.AddStmt(
C->getAlignment());
7029 Record.AddSourceLocation(
C->getLParenLoc());
7033 Record.push_back(
C->varlist_size());
7034 Record.AddSourceLocation(
C->getLParenLoc());
7035 for (
auto *VE :
C->varlists()) {
7038 for (
auto *VE :
C->private_copies()) {
7044 Record.push_back(
C->varlist_size());
7045 VisitOMPClauseWithPreInit(
C);
7046 Record.AddSourceLocation(
C->getLParenLoc());
7047 for (
auto *VE :
C->varlists()) {
7050 for (
auto *VE :
C->private_copies()) {
7053 for (
auto *VE :
C->inits()) {
7059 Record.push_back(
C->varlist_size());
7060 VisitOMPClauseWithPostUpdate(
C);
7061 Record.AddSourceLocation(
C->getLParenLoc());
7062 Record.writeEnum(
C->getKind());
7063 Record.AddSourceLocation(
C->getKindLoc());
7064 Record.AddSourceLocation(
C->getColonLoc());
7065 for (
auto *VE :
C->varlists())
7067 for (
auto *E :
C->private_copies())
7069 for (
auto *E :
C->source_exprs())
7071 for (
auto *E :
C->destination_exprs())
7073 for (
auto *E :
C->assignment_ops())
7078 Record.push_back(
C->varlist_size());
7079 Record.AddSourceLocation(
C->getLParenLoc());
7080 for (
auto *VE :
C->varlists())
7085 Record.push_back(
C->varlist_size());
7086 Record.writeEnum(
C->getModifier());
7087 VisitOMPClauseWithPostUpdate(
C);
7088 Record.AddSourceLocation(
C->getLParenLoc());
7089 Record.AddSourceLocation(
C->getModifierLoc());
7090 Record.AddSourceLocation(
C->getColonLoc());
7091 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
7092 Record.AddDeclarationNameInfo(
C->getNameInfo());
7093 for (
auto *VE :
C->varlists())
7095 for (
auto *VE :
C->privates())
7097 for (
auto *E :
C->lhs_exprs())
7099 for (
auto *E :
C->rhs_exprs())
7101 for (
auto *E :
C->reduction_ops())
7103 if (
C->getModifier() == clang::OMPC_REDUCTION_inscan) {
7104 for (
auto *E :
C->copy_ops())
7106 for (
auto *E :
C->copy_array_temps())
7108 for (
auto *E :
C->copy_array_elems())
7114 Record.push_back(
C->varlist_size());
7115 VisitOMPClauseWithPostUpdate(
C);
7116 Record.AddSourceLocation(
C->getLParenLoc());
7117 Record.AddSourceLocation(
C->getColonLoc());
7118 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
7119 Record.AddDeclarationNameInfo(
C->getNameInfo());
7120 for (
auto *VE :
C->varlists())
7122 for (
auto *VE :
C->privates())
7124 for (
auto *E :
C->lhs_exprs())
7126 for (
auto *E :
C->rhs_exprs())
7128 for (
auto *E :
C->reduction_ops())
7133 Record.push_back(
C->varlist_size());
7134 VisitOMPClauseWithPostUpdate(
C);
7135 Record.AddSourceLocation(
C->getLParenLoc());
7136 Record.AddSourceLocation(
C->getColonLoc());
7137 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
7138 Record.AddDeclarationNameInfo(
C->getNameInfo());
7139 for (
auto *VE :
C->varlists())
7141 for (
auto *VE :
C->privates())
7143 for (
auto *E :
C->lhs_exprs())
7145 for (
auto *E :
C->rhs_exprs())
7147 for (
auto *E :
C->reduction_ops())
7149 for (
auto *E :
C->taskgroup_descriptors())
7154 Record.push_back(
C->varlist_size());
7155 VisitOMPClauseWithPostUpdate(
C);
7156 Record.AddSourceLocation(
C->getLParenLoc());
7157 Record.AddSourceLocation(
C->getColonLoc());
7158 Record.push_back(
C->getModifier());
7159 Record.AddSourceLocation(
C->getModifierLoc());
7160 for (
auto *VE :
C->varlists()) {
7163 for (
auto *VE :
C->privates()) {
7166 for (
auto *VE :
C->inits()) {
7169 for (
auto *VE :
C->updates()) {
7172 for (
auto *VE :
C->finals()) {
7176 Record.AddStmt(
C->getCalcStep());
7177 for (
auto *VE :
C->used_expressions())
7182 Record.push_back(
C->varlist_size());
7183 Record.AddSourceLocation(
C->getLParenLoc());
7184 Record.AddSourceLocation(
C->getColonLoc());
7185 for (
auto *VE :
C->varlists())
7187 Record.AddStmt(
C->getAlignment());
7191 Record.push_back(
C->varlist_size());
7192 Record.AddSourceLocation(
C->getLParenLoc());
7193 for (
auto *VE :
C->varlists())
7195 for (
auto *E :
C->source_exprs())
7197 for (
auto *E :
C->destination_exprs())
7199 for (
auto *E :
C->assignment_ops())
7204 Record.push_back(
C->varlist_size());
7205 Record.AddSourceLocation(
C->getLParenLoc());
7206 for (
auto *VE :
C->varlists())
7208 for (
auto *E :
C->source_exprs())
7210 for (
auto *E :
C->destination_exprs())
7212 for (
auto *E :
C->assignment_ops())
7217 Record.push_back(
C->varlist_size());
7218 Record.AddSourceLocation(
C->getLParenLoc());
7219 for (
auto *VE :
C->varlists())
7224 Record.AddStmt(
C->getDepobj());
7225 Record.AddSourceLocation(
C->getLParenLoc());
7229 Record.push_back(
C->varlist_size());
7230 Record.push_back(
C->getNumLoops());
7231 Record.AddSourceLocation(
C->getLParenLoc());
7232 Record.AddStmt(
C->getModifier());
7233 Record.push_back(
C->getDependencyKind());
7234 Record.AddSourceLocation(
C->getDependencyLoc());
7235 Record.AddSourceLocation(
C->getColonLoc());
7236 Record.AddSourceLocation(
C->getOmpAllMemoryLoc());
7237 for (
auto *VE :
C->varlists())
7239 for (
unsigned I = 0, E =
C->getNumLoops(); I < E; ++I)
7240 Record.AddStmt(
C->getLoopData(I));
7244 VisitOMPClauseWithPreInit(
C);
7245 Record.writeEnum(
C->getModifier());
7246 Record.AddStmt(
C->getDevice());
7247 Record.AddSourceLocation(
C->getModifierLoc());
7248 Record.AddSourceLocation(
C->getLParenLoc());
7252 Record.push_back(
C->varlist_size());
7253 Record.push_back(
C->getUniqueDeclarationsNum());
7254 Record.push_back(
C->getTotalComponentListNum());
7255 Record.push_back(
C->getTotalComponentsNum());
7256 Record.AddSourceLocation(
C->getLParenLoc());
7257 bool HasIteratorModifier =
false;
7259 Record.push_back(
C->getMapTypeModifier(I));
7260 Record.AddSourceLocation(
C->getMapTypeModifierLoc(I));
7261 if (
C->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator)
7262 HasIteratorModifier =
true;
7264 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
7265 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
7266 Record.push_back(
C->getMapType());
7267 Record.AddSourceLocation(
C->getMapLoc());
7268 Record.AddSourceLocation(
C->getColonLoc());
7269 for (
auto *E :
C->varlists())
7271 for (
auto *E :
C->mapperlists())
7273 if (HasIteratorModifier)
7274 Record.AddStmt(
C->getIteratorModifier());
7275 for (
auto *D :
C->all_decls())
7277 for (
auto N :
C->all_num_lists())
7279 for (
auto N :
C->all_lists_sizes())
7281 for (
auto &M :
C->all_components()) {
7282 Record.AddStmt(M.getAssociatedExpression());
7283 Record.AddDeclRef(M.getAssociatedDeclaration());
7288 Record.push_back(
C->varlist_size());
7289 Record.AddSourceLocation(
C->getLParenLoc());
7290 Record.AddSourceLocation(
C->getColonLoc());
7291 Record.AddStmt(
C->getAllocator());
7292 for (
auto *VE :
C->varlists())
7297 VisitOMPClauseWithPreInit(
C);
7298 Record.AddStmt(
C->getNumTeams());
7299 Record.AddSourceLocation(
C->getLParenLoc());
7303 VisitOMPClauseWithPreInit(
C);
7304 Record.AddStmt(
C->getThreadLimit());
7305 Record.AddSourceLocation(
C->getLParenLoc());
7309 VisitOMPClauseWithPreInit(
C);
7310 Record.AddStmt(
C->getPriority());
7311 Record.AddSourceLocation(
C->getLParenLoc());
7315 VisitOMPClauseWithPreInit(
C);
7316 Record.writeEnum(
C->getModifier());
7317 Record.AddStmt(
C->getGrainsize());
7318 Record.AddSourceLocation(
C->getModifierLoc());
7319 Record.AddSourceLocation(
C->getLParenLoc());
7323 VisitOMPClauseWithPreInit(
C);
7324 Record.writeEnum(
C->getModifier());
7325 Record.AddStmt(
C->getNumTasks());
7326 Record.AddSourceLocation(
C->getModifierLoc());
7327 Record.AddSourceLocation(
C->getLParenLoc());
7332 Record.AddSourceLocation(
C->getLParenLoc());
7336 VisitOMPClauseWithPreInit(
C);
7337 Record.push_back(
C->getDistScheduleKind());
7338 Record.AddStmt(
C->getChunkSize());
7339 Record.AddSourceLocation(
C->getLParenLoc());
7340 Record.AddSourceLocation(
C->getDistScheduleKindLoc());
7341 Record.AddSourceLocation(
C->getCommaLoc());
7345 Record.push_back(
C->getDefaultmapKind());
7346 Record.push_back(
C->getDefaultmapModifier());
7347 Record.AddSourceLocation(
C->getLParenLoc());
7348 Record.AddSourceLocation(
C->getDefaultmapModifierLoc());
7349 Record.AddSourceLocation(
C->getDefaultmapKindLoc());
7352void OMPClauseWriter::VisitOMPToClause(
OMPToClause *
C) {
7353 Record.push_back(
C->varlist_size());
7354 Record.push_back(
C->getUniqueDeclarationsNum());
7355 Record.push_back(
C->getTotalComponentListNum());
7356 Record.push_back(
C->getTotalComponentsNum());
7357 Record.AddSourceLocation(
C->getLParenLoc());
7359 Record.push_back(
C->getMotionModifier(I));
7360 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
7362 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
7363 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
7364 Record.AddSourceLocation(
C->getColonLoc());
7365 for (
auto *E :
C->varlists())
7367 for (
auto *E :
C->mapperlists())
7369 for (
auto *D :
C->all_decls())
7371 for (
auto N :
C->all_num_lists())
7373 for (
auto N :
C->all_lists_sizes())
7375 for (
auto &M :
C->all_components()) {
7376 Record.AddStmt(M.getAssociatedExpression());
7377 Record.writeBool(M.isNonContiguous());
7378 Record.AddDeclRef(M.getAssociatedDeclaration());
7383 Record.push_back(
C->varlist_size());
7384 Record.push_back(
C->getUniqueDeclarationsNum());
7385 Record.push_back(
C->getTotalComponentListNum());
7386 Record.push_back(
C->getTotalComponentsNum());
7387 Record.AddSourceLocation(
C->getLParenLoc());
7389 Record.push_back(
C->getMotionModifier(I));
7390 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
7392 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
7393 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
7394 Record.AddSourceLocation(
C->getColonLoc());
7395 for (
auto *E :
C->varlists())
7397 for (
auto *E :
C->mapperlists())
7399 for (
auto *D :
C->all_decls())
7401 for (
auto N :
C->all_num_lists())
7403 for (
auto N :
C->all_lists_sizes())
7405 for (
auto &M :
C->all_components()) {
7406 Record.AddStmt(M.getAssociatedExpression());
7407 Record.writeBool(M.isNonContiguous());
7408 Record.AddDeclRef(M.getAssociatedDeclaration());
7413 Record.push_back(
C->varlist_size());
7414 Record.push_back(
C->getUniqueDeclarationsNum());
7415 Record.push_back(
C->getTotalComponentListNum());
7416 Record.push_back(
C->getTotalComponentsNum());
7417 Record.AddSourceLocation(
C->getLParenLoc());
7418 for (
auto *E :
C->varlists())
7420 for (
auto *VE :
C->private_copies())
7422 for (
auto *VE :
C->inits())
7424 for (
auto *D :
C->all_decls())
7426 for (
auto N :
C->all_num_lists())
7428 for (
auto N :
C->all_lists_sizes())
7430 for (
auto &M :
C->all_components()) {
7431 Record.AddStmt(M.getAssociatedExpression());
7432 Record.AddDeclRef(M.getAssociatedDeclaration());
7437 Record.push_back(
C->varlist_size());
7438 Record.push_back(
C->getUniqueDeclarationsNum());
7439 Record.push_back(
C->getTotalComponentListNum());
7440 Record.push_back(
C->getTotalComponentsNum());
7441 Record.AddSourceLocation(
C->getLParenLoc());
7442 for (
auto *E :
C->varlists())
7444 for (
auto *D :
C->all_decls())
7446 for (
auto N :
C->all_num_lists())
7448 for (
auto N :
C->all_lists_sizes())
7450 for (
auto &M :
C->all_components()) {
7451 Record.AddStmt(M.getAssociatedExpression());
7452 Record.AddDeclRef(M.getAssociatedDeclaration());
7457 Record.push_back(
C->varlist_size());
7458 Record.push_back(
C->getUniqueDeclarationsNum());
7459 Record.push_back(
C->getTotalComponentListNum());
7460 Record.push_back(
C->getTotalComponentsNum());
7461 Record.AddSourceLocation(
C->getLParenLoc());
7462 for (
auto *E :
C->varlists())
7464 for (
auto *D :
C->all_decls())
7466 for (
auto N :
C->all_num_lists())
7468 for (
auto N :
C->all_lists_sizes())
7470 for (
auto &M :
C->all_components()) {
7471 Record.AddStmt(M.getAssociatedExpression());
7472 Record.AddDeclRef(M.getAssociatedDeclaration());
7477 Record.push_back(
C->varlist_size());
7478 Record.push_back(
C->getUniqueDeclarationsNum());
7479 Record.push_back(
C->getTotalComponentListNum());
7480 Record.push_back(
C->getTotalComponentsNum());
7481 Record.AddSourceLocation(
C->getLParenLoc());
7482 for (
auto *E :
C->varlists())
7484 for (
auto *D :
C->all_decls())
7486 for (
auto N :
C->all_num_lists())
7488 for (
auto N :
C->all_lists_sizes())
7490 for (
auto &M :
C->all_components()) {
7491 Record.AddStmt(M.getAssociatedExpression());
7492 Record.AddDeclRef(M.getAssociatedDeclaration());
7498void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
7507void OMPClauseWriter::VisitOMPAtomicDefaultMemOrderClause(
7509 Record.push_back(
C->getAtomicDefaultMemOrderKind());
7510 Record.AddSourceLocation(
C->getLParenLoc());
7511 Record.AddSourceLocation(
C->getAtomicDefaultMemOrderKindKwLoc());
7514void OMPClauseWriter::VisitOMPAtClause(
OMPAtClause *
C) {
7515 Record.push_back(
C->getAtKind());
7516 Record.AddSourceLocation(
C->getLParenLoc());
7517 Record.AddSourceLocation(
C->getAtKindKwLoc());
7521 Record.push_back(
C->getSeverityKind());
7522 Record.AddSourceLocation(
C->getLParenLoc());
7523 Record.AddSourceLocation(
C->getSeverityKindKwLoc());
7527 Record.AddStmt(
C->getMessageString());
7528 Record.AddSourceLocation(
C->getLParenLoc());
7532 Record.push_back(
C->varlist_size());
7533 Record.AddSourceLocation(
C->getLParenLoc());
7534 for (
auto *VE :
C->varlists())
7536 for (
auto *E :
C->private_refs())
7541 Record.push_back(
C->varlist_size());
7542 Record.AddSourceLocation(
C->getLParenLoc());
7543 for (
auto *VE :
C->varlists())
7548 Record.push_back(
C->varlist_size());
7549 Record.AddSourceLocation(
C->getLParenLoc());
7550 for (
auto *VE :
C->varlists())
7555 Record.writeEnum(
C->getKind());
7556 Record.writeEnum(
C->getModifier());
7557 Record.AddSourceLocation(
C->getLParenLoc());
7558 Record.AddSourceLocation(
C->getKindKwLoc());
7559 Record.AddSourceLocation(
C->getModifierKwLoc());
7563 Record.push_back(
C->getNumberOfAllocators());
7564 Record.AddSourceLocation(
C->getLParenLoc());
7565 for (
unsigned I = 0, E =
C->getNumberOfAllocators(); I < E; ++I) {
7575 Record.push_back(
C->varlist_size());
7576 Record.AddSourceLocation(
C->getLParenLoc());
7577 Record.AddStmt(
C->getModifier());
7578 Record.AddSourceLocation(
C->getColonLoc());
7579 for (
Expr *E :
C->varlists())
7584 Record.writeEnum(
C->getBindKind());
7585 Record.AddSourceLocation(
C->getLParenLoc());
7586 Record.AddSourceLocation(
C->getBindKindLoc());
7590 VisitOMPClauseWithPreInit(
C);
7592 Record.AddSourceLocation(
C->getLParenLoc());
7596 Record.push_back(
C->varlist_size());
7597 Record.push_back(
C->getNumLoops());
7598 Record.AddSourceLocation(
C->getLParenLoc());
7599 Record.push_back(
C->getDependenceType());
7600 Record.AddSourceLocation(
C->getDependenceLoc());
7601 Record.AddSourceLocation(
C->getColonLoc());
7602 for (
auto *VE :
C->varlists())
7604 for (
unsigned I = 0, E =
C->getNumLoops(); I < E; ++I)
7605 Record.AddStmt(
C->getLoopData(I));
7609 Record.AddAttributes(
C->getAttrs());
7610 Record.AddSourceLocation(
C->getBeginLoc());
7611 Record.AddSourceLocation(
C->getLParenLoc());
7612 Record.AddSourceLocation(
C->getEndLoc());
7619 for (
const auto &
Set : TI->
Sets) {
7626 writeExprRef(
Selector.ScoreOrCondition);
7640 for (
unsigned I = 0, E =
Data->getNumClauses(); I < E; ++I)
7642 if (
Data->hasAssociatedStmt())
7644 for (
unsigned I = 0, E =
Data->getNumChildren(); I < E; ++I)
7653 switch (
C->getClauseKind()) {
7655 const auto *DC = cast<OpenACCDefaultClause>(
C);
7661 const auto *IC = cast<OpenACCIfClause>(
C);
7663 AddStmt(
const_cast<Expr *
>(IC->getConditionExpr()));
7667 const auto *SC = cast<OpenACCIfClause>(
C);
7670 if (SC->hasConditionExpr())
7671 AddStmt(
const_cast<Expr *
>(SC->getConditionExpr()));
7675 const auto *NGC = cast<OpenACCNumGangsClause>(
C);
7678 for (
Expr *E : NGC->getIntExprs())
7683 const auto *NWC = cast<OpenACCNumWorkersClause>(
C);
7689 const auto *NWC = cast<OpenACCVectorLengthClause>(
C);
7731 llvm_unreachable(
"Clause serialization not yet implemented");
7733 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 void AddLazyVectorDecls(ASTWriter &Writer, Vector &Vec)
static void AddLazyVectorEmiitedDecls(ASTWriter &Writer, Vector &Vec, ASTWriter::RecordData &Record)
static uint64_t EmitCXXCtorInitializers(ASTWriter &W, ArrayRef< CXXCtorInitializer * > CtorInits)
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 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 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(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 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 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.
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 BLOCK(DERIVED, BASE)
C Language Family Type Representation.
Defines version macros and version-related utility functions for Clang.
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 ...
SourceManager & getSourceManager()
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.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
FunctionDecl * getcudaConfigureCallDecl()
DiagnosticsEngine & getDiagnostics() const
const TargetInfo & getTargetInfo() const
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.
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
unsigned getTotalNumIdentifiers() const
Returns the number of identifiers found in the chain.
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 getTotalNumTypes() const
Returns the number of types 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()
unsigned getTotalNumMacros() const
Returns the number of macros found in the chain.
unsigned getTotalNumDecls() const
Returns the number of declarations 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 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 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.
ASTFileSignature WriteAST(Sema &SemaRef, StringRef OutputFile, Module *WritingModule, StringRef isysroot, bool ShouldCacheASTInMemory=false)
Write a precompiled header for the given semantic analysis.
serialization::TypeID getTypeID(QualType T) const
Determine the type ID of an already-emitted type.
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.
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.
uint32_t getMacroDirectivesOffset(const IdentifierInfo *Name)
void AddAlignPackInfo(const Sema::AlignPackInfo &Info, RecordDataImpl &Record)
Emit a AlignPackInfo.
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...
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.
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::TypeID GetOrCreateTypeID(QualType T)
Force a type to be emitted and get its ID.
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.
void AddTypeRef(QualType T, RecordDataImpl &Record)
Emit a reference to a type.
ASTReader * getChain() const
bool getDoneWritingDeclsAndTypes() const
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.
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
unsigned getAnonymousDeclarationNumber(const NamedDecl *D)
serialization::IdentID getIdentifierRef(const IdentifierInfo *II)
Get the unique number used to refer to the given identifier.
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.
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
Represents a base class of a C++ class.
Represents a C++ destructor within a class.
Represents a C++ struct/union/class.
unsigned getDeviceLambdaManglingNumber() const
Retrieve the device side mangling number.
unsigned getODRHash() const
Represents a C++ temporary.
const CXXDestructorDecl * getDestructor() const
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
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.
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 isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
GlobalDeclID getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
@ FOK_None
Not a friend object.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
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...
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.
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.
bool hasUncompilableErrorOccurred() const
Errors that actually prevent compilation, not those that are upgraded from a warning by -Werror.
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).
time_t getModificationTime() const
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Implements support for file system lookup, file system caching, and directory search management.
void trackVFSUsage(bool Active)
Enable or disable tracking of VFS usage.
llvm::vfs::FileSystem & getVirtualFileSystem() const
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
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.
SmallVector< Header, 2 > Headers[5]
The headers that are part of this 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.
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.
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 '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 'shedule', 'firstprivate' etc.
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 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 '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 '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 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' directive.
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
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
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
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.
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
static uint32_t getRawEncoding(const AlignPackInfo &Info)
llvm::DenseMap< Selector, Lists >::iterator iterator
iterator find(Selector Sel)
Sema - This implements semantic analysis and AST building for C.
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
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...
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.
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.
void updateOutOfDateSelector(Selector Sel)
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...
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
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 uint64_t encode(SourceLocation Loc, 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.
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.
SourceLocation getIncludeLoc(FileID FID) const
Returns the include location if FID is a #include'd file otherwise it returns an invalid location.
unsigned getFileIDSize(FileID FID) const
The size of the SLocEntry that FID represents.
bool hasLineTable() const
Determine if the source manager has a line table.
bool isLoadedFileID(FileID FID) const
Returns true if FID came from a PCH/Module.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
SrcMgr::CharacteristicKind getFileCharacteristic(SourceLocation Loc) const
Return the file characteristic of the specified source location, indicating whether this is a normal ...
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
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.
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
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::IdentID BaseIdentifierID
Base identifier ID for identifiers local to this module.
serialization::DeclID BaseDeclID
Base declaration ID for declarations local to this module.
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
serialization::TypeID BaseTypeIndex
Base type ID for types local to this module as represented in the global type ID space.
unsigned LocalNumIdentifiers
The number of identifiers in this AST file.
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 LocalNumSLocEntries
The number of source location entries in this AST file.
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
unsigned LocalNumTypes
The number of types in this AST file.
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 LocalNumDecls
The number of declarations 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.
Manages the set of modules loaded by an AST reader.
Writer for the on-disk hash table.
A type index; the type ID with the qualifier bits removed.
uint32_t getIndex() const
Class that performs name lookup into a DeclContext stored in an AST file.
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
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.
@ 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_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_PRAGMA_COMMENT
A PragmaCommentDecl record.
@ DECL_ENUM
An EnumDecl record.
@ 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)
@ EXTENSION_METADATA
Metadata describing this particular extension.
uint32_t TypeID
An ID number that refers to a type in an AST file.
@ 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.
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.
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
const unsigned VERSION_MINOR
AST file minor version number supported by this version of Clang.
@ SM_SLOC_FILE_ENTRY
Describes a source location entry (SLocEntry) for a file.
@ SM_SLOC_BUFFER_BLOB_COMPRESSED
Describes a zlib-compressed blob that contains the data for a buffer entry.
@ SM_SLOC_BUFFER_ENTRY
Describes a source location entry (SLocEntry) for a buffer.
@ SM_SLOC_BUFFER_BLOB
Describes a blob that contains the data for a buffer entry.
@ SM_SLOC_EXPANSION_ENTRY
Describes a source location entry (SLocEntry) for a macro expansion.
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
DeclIDBase::DeclID DeclID
An ID number that refers to a declaration in an AST file.
TypeID MakeTypeID(ASTContext &Context, QualType T, IdxForTypeTy IdxForType)
@ 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.
@ IMPORTS
Record code for the list of other AST files imported by this AST file.
@ 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...
@ 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.
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.
@ 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.
@ 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.
@ 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.
@ 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_TEMPLATE_SPECIALIZATION
@ 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.
@ 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'.
@ 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.
@ Collapse
'collapse' clause, allowed on 'loop' and Combined constructs.
@ NoHost
'nohost' clause, allowed on 'routine' directives.
@ 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
'copyin' 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'.
@ 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.
@ Tile
'tile' clause, allowed on 'loop' and Combined constructs.
@ DeviceResident
'device_resident' clause, allowed on the 'declare' construct.
@ 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.
@ Finalize
'finalize' clause, allowed on 'exit data' directive.
@ NUM_OVERLOADED_OPERATORS
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
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.
static constexpr unsigned NumberOfOMPMapClauseModifiers
Number of allowed map-type-modifiers.
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
PredefinedDeclIDs
Predefined declaration IDs.
@ PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID
The internal '__NSConstantString' tag type.
@ PREDEF_DECL_TRANSLATION_UNIT_ID
The translation unit.
@ PREDEF_DECL_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.
static constexpr unsigned NumberOfOMPMotionModifiers
Number of allowed motion-modifiers.
llvm::hash_code hash_value(const CustomizableOptional< T > &O)
for(const auto &A :T->param_types())
const FunctionProtoType * T
bool shouldSkipCheckingODR(const Decl *D)
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.
Source range/offset of a preprocessed entity.