78#include "llvm/ADT/APFloat.h"
79#include "llvm/ADT/APInt.h"
80#include "llvm/ADT/APSInt.h"
81#include "llvm/ADT/ArrayRef.h"
82#include "llvm/ADT/DenseMap.h"
83#include "llvm/ADT/Hashing.h"
84#include "llvm/ADT/PointerIntPair.h"
85#include "llvm/ADT/STLExtras.h"
86#include "llvm/ADT/ScopeExit.h"
87#include "llvm/ADT/SmallPtrSet.h"
88#include "llvm/ADT/SmallString.h"
89#include "llvm/ADT/SmallVector.h"
90#include "llvm/ADT/StringMap.h"
91#include "llvm/ADT/StringRef.h"
92#include "llvm/Bitstream/BitCodes.h"
93#include "llvm/Bitstream/BitstreamWriter.h"
94#include "llvm/Support/Casting.h"
95#include "llvm/Support/Compression.h"
96#include "llvm/Support/DJB.h"
97#include "llvm/Support/Endian.h"
98#include "llvm/Support/EndianStream.h"
99#include "llvm/Support/Error.h"
100#include "llvm/Support/ErrorHandling.h"
101#include "llvm/Support/LEB128.h"
102#include "llvm/Support/MemoryBuffer.h"
103#include "llvm/Support/OnDiskHashTable.h"
104#include "llvm/Support/Path.h"
105#include "llvm/Support/SHA1.h"
106#include "llvm/Support/TimeProfiler.h"
107#include "llvm/Support/VersionTuple.h"
108#include "llvm/Support/raw_ostream.h"
123using namespace clang;
126template <
typename T,
typename Allocator>
127static StringRef
bytes(
const std::vector<T, Allocator> &
v) {
128 if (
v.empty())
return StringRef();
129 return StringRef(
reinterpret_cast<const char*
>(&
v[0]),
130 sizeof(
T) *
v.size());
135 return StringRef(
reinterpret_cast<const char*
>(
v.data()),
136 sizeof(
T) *
v.size());
139static std::string
bytes(
const std::vector<bool> &
V) {
141 Str.reserve(
V.size() / 8);
142 for (
unsigned I = 0,
E =
V.size(); I <
E;) {
144 for (
unsigned Bit = 0; Bit < 8 && I <
E; ++Bit, ++I)
157#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
158 case Type::CLASS_ID: return TYPE_##CODE_ID;
159#include "clang/Serialization/TypeBitCodes.def"
161 llvm_unreachable(
"shouldn't be serializing a builtin type this way");
163 llvm_unreachable(
"bad type kind");
168std::optional<std::set<const FileEntry *>>
178 std::set<const FileEntry *> ModuleMaps;
179 std::set<const Module *> ProcessedModules;
180 auto CollectModuleMapsForHierarchy = [&](
const Module *M) {
181 M = M->getTopLevelModule();
183 if (!ProcessedModules.insert(M).second)
186 std::queue<const Module *> Q;
189 const Module *Mod = Q.front();
195 ModuleMaps.insert(*FE);
200 ModuleMaps.insert(*FE);
209 CollectModuleMapsForHierarchy(RootModule);
211 std::queue<const Module *> Q;
214 const Module *CurrentModule = Q.front();
218 CollectModuleMapsForHierarchy(ImportedModule);
220 CollectModuleMapsForHierarchy(UndeclaredModule);
234 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
248 if (
const Module *M = KH.getModule())
249 CollectModuleMapsForHierarchy(M);
280 : Writer(Writer), BasicWriter(Writer,
Record) {}
283 if (
T.hasLocalNonFastQualifiers()) {
290 const Type *typePtr =
T.getTypePtr();
313#define ABSTRACT_TYPELOC(CLASS, PARENT)
314#define TYPELOC(CLASS, PARENT) \
315 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
316#include "clang/AST/TypeLocNodes.def"
384 VisitArrayTypeLoc(TL);
388 VisitArrayTypeLoc(TL);
392 VisitArrayTypeLoc(TL);
395void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
397 VisitArrayTypeLoc(TL);
400void TypeLocWriter::VisitDependentAddressSpaceTypeLoc(
404 addSourceLocation(
range.getBegin());
405 addSourceLocation(
range.getEnd());
409void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
418void TypeLocWriter::VisitDependentVectorTypeLoc(
430 addSourceLocation(
range.getBegin());
431 addSourceLocation(
range.getEnd());
436void TypeLocWriter::VisitDependentSizedMatrixTypeLoc(
440 addSourceLocation(
range.getBegin());
441 addSourceLocation(
range.getEnd());
452 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i)
457 VisitFunctionTypeLoc(TL);
461 VisitFunctionTypeLoc(TL);
526void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
531 Record.AddConceptReference(CR);
537void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
546void TypeLocWriter::VisitEnumTypeLoc(
EnumTypeLoc TL) {
566void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
571void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
576void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
582 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
611void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
655void TypeLocWriter::VisitPipeTypeLoc(
PipeTypeLoc TL) {
662void TypeLocWriter::VisitDependentBitIntTypeLoc(
667void ASTWriter::WriteTypeAbbrevs() {
668 using namespace llvm;
670 std::shared_ptr<BitCodeAbbrev> Abv;
673 Abv = std::make_shared<BitCodeAbbrev>();
675 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
676 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
677 TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
685 llvm::BitstreamWriter &Stream,
689 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID,
Record);
692 if (!Name || Name[0] == 0)
696 Record.push_back(*Name++);
697 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME,
Record);
701 llvm::BitstreamWriter &Stream,
706 Record.push_back(*Name++);
707 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME,
Record);
712#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
844void ASTWriter::WriteBlockInfoBlock() {
846 Stream.EnterBlockInfoBlock();
848#define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
849#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
852 BLOCK(CONTROL_BLOCK);
862 BLOCK(OPTIONS_BLOCK);
869 BLOCK(INPUT_FILES_BLOCK);
933 BLOCK(SOURCE_MANAGER_BLOCK);
941 BLOCK(PREPROCESSOR_BLOCK);
949 BLOCK(SUBMODULE_BLOCK);
971 BLOCK(COMMENTS_BLOCK);
975 BLOCK(DECLTYPES_BLOCK);
979 RECORD(TYPE_BLOCK_POINTER);
980 RECORD(TYPE_LVALUE_REFERENCE);
981 RECORD(TYPE_RVALUE_REFERENCE);
982 RECORD(TYPE_MEMBER_POINTER);
983 RECORD(TYPE_CONSTANT_ARRAY);
984 RECORD(TYPE_INCOMPLETE_ARRAY);
985 RECORD(TYPE_VARIABLE_ARRAY);
988 RECORD(TYPE_FUNCTION_NO_PROTO);
989 RECORD(TYPE_FUNCTION_PROTO);
995 RECORD(TYPE_OBJC_INTERFACE);
996 RECORD(TYPE_OBJC_OBJECT_POINTER);
999 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM);
1000 RECORD(TYPE_UNRESOLVED_USING);
1001 RECORD(TYPE_INJECTED_CLASS_NAME);
1002 RECORD(TYPE_OBJC_OBJECT);
1003 RECORD(TYPE_TEMPLATE_TYPE_PARM);
1004 RECORD(TYPE_TEMPLATE_SPECIALIZATION);
1005 RECORD(TYPE_DEPENDENT_NAME);
1006 RECORD(TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION);
1007 RECORD(TYPE_DEPENDENT_SIZED_ARRAY);
1009 RECORD(TYPE_MACRO_QUALIFIED);
1010 RECORD(TYPE_PACK_EXPANSION);
1012 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK);
1014 RECORD(TYPE_UNARY_TRANSFORM);
1018 RECORD(TYPE_OBJC_TYPE_PARAM);
1096 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
1102 BLOCK(EXTENSION_BLOCK);
1105 BLOCK(UNHASHED_CONTROL_BLOCK);
1124 return Changed | llvm::sys::path::remove_dots(
Path);
1139 assert(
Filename &&
"No file name to adjust?");
1141 if (BaseDir.empty())
1146 for (;
Filename[Pos] && Pos < BaseDir.size(); ++Pos)
1156 if (!llvm::sys::path::is_separator(
Filename[Pos])) {
1157 if (!llvm::sys::path::is_separator(BaseDir.back()))
1174std::pair<ASTFileSignature, ASTFileSignature>
1175ASTWriter::createSignature()
const {
1176 StringRef AllBytes(Buffer.data(), Buffer.size());
1179 Hasher.update(AllBytes.slice(ASTBlockRange.first, ASTBlockRange.second));
1184 Hasher.update(AllBytes.slice(0, UnhashedControlBlockRange.first));
1187 AllBytes.slice(UnhashedControlBlockRange.second, ASTBlockRange.first));
1189 Hasher.update(AllBytes.slice(ASTBlockRange.second, StringRef::npos));
1192 return std::make_pair(ASTBlockHash, Signature);
1197 Hasher.update(StringRef(Buffer.data(), Buffer.size()));
1199 assert(WritingModule);
1204 for (
auto [ExportImported, _] : WritingModule->
Exports)
1205 Hasher.update(ExportImported->Signature);
1229 for (
Module *M : TouchedTopLevelModules)
1230 Hasher.update(M->Signature);
1237 for (uint8_t Byte : S) {
1238 Stream.BackpatchByte(BitNo, Byte);
1250 if (!WritingModule ||
1257 std::tie(ASTBlockHash, Signature) = createSignature();
1265void ASTWriter::writeUnhashedControlBlock(
Preprocessor &PP,
1267 using namespace llvm;
1270 Stream.FlushToWord();
1271 UnhashedControlBlockRange.first = Stream.GetCurrentBitNo() >> 3;
1294 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1296 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1297 unsigned ASTBlockHashAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1300 Stream.EmitRecordWithBlob(ASTBlockHashAbbrev,
Record, Blob);
1301 ASTBlockHashOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1305 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1306 Abbrev->Add(BitCodeAbbrevOp(
SIGNATURE));
1307 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1308 unsigned SignatureAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1311 Stream.EmitRecordWithBlob(SignatureAbbrev,
Record, Blob);
1312 SignatureOffset = Stream.GetCurrentBitNo() - Blob.size() * 8;
1321 if (!HSOpts.ModulesSkipDiagnosticOptions) {
1322#define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name);
1323#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
1324 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name()));
1325#include "clang/Basic/DiagnosticOptions.def"
1327 for (
unsigned I = 0, N = DiagOpts.
Warnings.size(); I != N; ++I)
1330 for (
unsigned I = 0, N = DiagOpts.
Remarks.size(); I != N; ++I)
1339 if (!HSOpts.ModulesSkipHeaderSearchPaths) {
1341 Record.push_back(HSOpts.UserEntries.size());
1342 for (
unsigned I = 0, N = HSOpts.UserEntries.size(); I != N; ++I) {
1345 Record.push_back(
static_cast<unsigned>(Entry.
Group));
1351 Record.push_back(HSOpts.SystemHeaderPrefixes.size());
1352 for (
unsigned I = 0, N = HSOpts.SystemHeaderPrefixes.size(); I != N; ++I) {
1354 Record.push_back(HSOpts.SystemHeaderPrefixes[I].IsSystemHeader);
1358 Record.push_back(HSOpts.VFSOverlayFiles.size());
1359 for (StringRef VFSOverlayFile : HSOpts.VFSOverlayFiles)
1365 if (!HSOpts.ModulesSkipPragmaDiagnosticMappings)
1366 WritePragmaDiagnosticMappings(Diags, WritingModule);
1371 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1373 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1374 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1375 unsigned HSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1377 HSEntryUsage.size()};
1378 Stream.EmitRecordWithBlob(HSUsageAbbrevCode,
Record,
bytes(HSEntryUsage));
1384 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1385 Abbrev->Add(BitCodeAbbrevOp(
VFS_USAGE));
1386 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1387 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1388 unsigned VFSUsageAbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1390 Stream.EmitRecordWithBlob(VFSUsageAbbrevCode,
Record,
bytes(VFSUsage));
1395 UnhashedControlBlockRange.second = Stream.GetCurrentBitNo() >> 3;
1400 StringRef isysroot) {
1401 using namespace llvm;
1407 auto MetadataAbbrev = std::make_shared<BitCodeAbbrev>();
1408 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1409 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1410 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1411 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1412 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1413 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1415 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1416 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1417 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1418 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1419 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev));
1420 assert((!WritingModule || isysroot.empty()) &&
1421 "writing module as a relocatable PCH?");
1426 CLANG_VERSION_MAJOR,
1427 CLANG_VERSION_MINOR,
1431 ASTHasCompilerErrors};
1432 Stream.EmitRecordWithBlob(MetadataAbbrevCode,
Record,
1436 if (WritingModule) {
1438 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1440 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1441 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1443 Stream.EmitRecordWithBlob(AbbrevCode,
Record, WritingModule->
Name);
1446 if (WritingModule && WritingModule->
Directory) {
1453 BaseDir.assign(CWD->getName());
1468 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1470 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1471 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1474 Stream.EmitRecordWithBlob(AbbrevCode,
Record, BaseDir);
1478 BaseDirectory.assign(BaseDir.begin(), BaseDir.end());
1479 }
else if (!isysroot.empty()) {
1481 BaseDirectory = std::string(isysroot);
1490 ? Map.getModuleMapFileForUniquing(WritingModule)
1491 ->getNameAsRequested()
1496 if (
auto *AdditionalModMaps =
1497 Map.getAdditionalModuleMapFiles(WritingModule)) {
1498 Record.push_back(AdditionalModMaps->size());
1500 AdditionalModMaps->end());
1520 if (!M.isDirectlyImported())
1523 Record.push_back((
unsigned)M.Kind);
1524 Record.push_back(M.StandardCXXModule);
1529 if (!M.StandardCXXModule) {
1532 Record.push_back(M.Signature ? 0 : M.File.getSize());
1534 llvm::append_range(
Record, M.Signature);
1539 if (!M.StandardCXXModule)
1551#define LANGOPT(Name, Bits, Default, Description) \
1552 Record.push_back(LangOpts.Name);
1553#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
1554 Record.push_back(static_cast<unsigned>(LangOpts.get##Name()));
1555#include "clang/Basic/LangOptions.def"
1556#define SANITIZER(NAME, ID) \
1557 Record.push_back(LangOpts.Sanitize.has(SanitizerKind::ID));
1558#include "clang/Basic/Sanitizers.def"
1598 for (
unsigned I = 0, N = TargetOpts.
Features.size(); I != N; ++I) {
1639 bool WriteMacros = !SkipMacros;
1640 Record.push_back(WriteMacros);
1644 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
1652 for (
unsigned I = 0, N = PPOpts.
Includes.size(); I != N; ++I)
1657 for (
unsigned I = 0, N = PPOpts.
MacroIncludes.size(); I != N; ++I)
1672 if (
auto MainFile =
SM.getFileEntryRefForID(
SM.getMainFileID())) {
1673 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1675 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1676 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1677 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
1689 WriteInputFiles(Context.SourceMgr,
1697struct InputFileEntry {
1701 bool BufferOverridden;
1716 assert(IncludeFID.
isValid() &&
"IncludeLoc in invalid file");
1717 if (!IsSLocAffecting[IncludeFID.ID])
1725 using namespace llvm;
1730 auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
1732 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1733 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1734 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1735 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1736 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1737 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1738 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1739 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
1740 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1741 unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
1744 auto IFHAbbrev = std::make_shared<BitCodeAbbrev>();
1746 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1747 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1748 unsigned IFHAbbrevCode = Stream.EmitAbbrev(std::move(IFHAbbrev));
1750 uint64_t InputFilesOffsetBase = Stream.GetCurrentBitNo();
1753 std::vector<InputFileEntry> UserFiles;
1754 std::vector<InputFileEntry> SystemFiles;
1758 assert(&SourceMgr.
getSLocEntry(FileID::get(I)) == SLoc);
1765 if (!
Cache->OrigEntry)
1769 if (!IsSLocAffecting[I])
1772 InputFileEntry Entry(*
Cache->OrigEntry);
1773 Entry.IsSystemFile =
isSystem(
File.getFileCharacteristic());
1774 Entry.IsTransient =
Cache->IsTransient;
1775 Entry.BufferOverridden =
Cache->BufferOverridden;
1776 Entry.IsTopLevel = getAffectingIncludeLoc(SourceMgr,
File).
isInvalid();
1783 auto MemBuff =
Cache->getBufferIfLoaded();
1785 ContentHash = xxh3_64bits(MemBuff->getBuffer());
1788 << Entry.File.getName();
1790 Entry.ContentHash[0] =
uint32_t(ContentHash);
1791 Entry.ContentHash[1] =
uint32_t(ContentHash >> 32);
1792 if (Entry.IsSystemFile)
1793 SystemFiles.push_back(Entry);
1795 UserFiles.push_back(Entry);
1799 auto SortedFiles = llvm::concat<InputFileEntry>(std::move(UserFiles),
1800 std::move(SystemFiles));
1802 unsigned UserFilesNum = 0;
1804 std::vector<uint64_t> InputFileOffsets;
1805 for (
const auto &Entry : SortedFiles) {
1806 uint32_t &InputFileID = InputFileIDs[Entry.File];
1807 if (InputFileID != 0)
1811 InputFileOffsets.push_back(Stream.GetCurrentBitNo() - InputFilesOffsetBase);
1813 InputFileID = InputFileOffsets.size();
1815 if (!Entry.IsSystemFile)
1827 if (Name == NameAsRequested)
1830 RecordData::value_type
Record[] = {
1832 InputFileOffsets.size(),
1835 Entry.BufferOverridden,
1839 NameAsRequested.size()};
1841 Stream.EmitRecordWithBlob(IFAbbrevCode,
Record,
1842 (NameAsRequested + Name).str());
1848 Entry.ContentHash[1]};
1849 Stream.EmitRecordWithAbbrev(IFHAbbrevCode,
Record);
1856 auto OffsetsAbbrev = std::make_shared<BitCodeAbbrev>();
1858 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1859 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1861 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1862 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(std::move(OffsetsAbbrev));
1866 InputFileOffsets.size(), UserFilesNum};
1867 Stream.EmitRecordWithBlob(OffsetsAbbrevCode,
Record,
bytes(InputFileOffsets));
1877 using namespace llvm;
1879 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1881 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1882 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1883 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1884 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1886 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1887 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1888 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
1889 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1890 return Stream.EmitAbbrev(std::move(Abbrev));
1896 using namespace llvm;
1898 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1900 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1901 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1902 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1903 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1904 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1905 return Stream.EmitAbbrev(std::move(Abbrev));
1912 using namespace llvm;
1914 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1918 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1919 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1920 return Stream.EmitAbbrev(std::move(Abbrev));
1926 using namespace llvm;
1928 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1930 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1931 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1932 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1933 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1934 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1935 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1936 return Stream.EmitAbbrev(std::move(Abbrev));
1941static std::pair<unsigned, unsigned>
1943 llvm::encodeULEB128(KeyLen, Out);
1944 llvm::encodeULEB128(DataLen, Out);
1945 return std::make_pair(KeyLen, DataLen);
1951 class HeaderFileInfoTrait {
1956 llvm::StringMap<unsigned> FrameworkNameOffset;
1959 HeaderFileInfoTrait(
ASTWriter &Writer) : Writer(Writer) {}
1966 using key_type_ref =
const key_type &;
1968 using UnresolvedModule =
1969 llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
1975 : HFI(HFI), AlreadyIncluded(AlreadyIncluded),
1979 bool AlreadyIncluded;
1983 using data_type_ref =
const data_type &;
1992 uint8_t buf[
sizeof(key.Size) +
sizeof(key.ModTime)];
1993 memcpy(buf, &key.Size,
sizeof(key.Size));
1994 memcpy(buf +
sizeof(key.Size), &key.ModTime,
sizeof(key.ModTime));
1995 return llvm::xxh3_64bits(buf);
1998 std::pair<unsigned, unsigned>
1999 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref
Data) {
2000 unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
2002 for (
auto ModInfo :
Data.KnownHeaders)
2005 if (
Data.Unresolved.getPointer())
2010 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
2011 using namespace llvm::support;
2013 endian::Writer
LE(Out, llvm::endianness::little);
2018 Out.write(key.Filename.data(), KeyLen);
2021 void EmitData(raw_ostream &Out, key_type_ref key,
2022 data_type_ref
Data,
unsigned DataLen) {
2023 using namespace llvm::support;
2025 endian::Writer
LE(Out, llvm::endianness::little);
2026 uint64_t Start = Out.tell(); (void)Start;
2028 unsigned char Flags = (
Data.AlreadyIncluded << 6)
2029 | (
Data.HFI.isImport << 5)
2031 Data.HFI.isPragmaOnce << 4)
2032 | (
Data.HFI.DirInfo << 1)
2033 |
Data.HFI.IndexHeaderMapHeader;
2034 LE.write<uint8_t>(Flags);
2036 if (
Data.HFI.LazyControllingMacro.isID())
2042 unsigned Offset = 0;
2043 if (!
Data.HFI.Framework.empty()) {
2045 llvm::StringMap<unsigned>::iterator Pos
2046 = FrameworkNameOffset.find(
Data.HFI.Framework);
2047 if (Pos == FrameworkNameOffset.end()) {
2048 Offset = FrameworkStringData.size() + 1;
2049 FrameworkStringData.append(
Data.HFI.Framework);
2050 FrameworkStringData.push_back(0);
2052 FrameworkNameOffset[
Data.HFI.Framework] = Offset;
2054 Offset = Pos->second;
2061 assert((
Value >> 3) == ModID &&
"overflow in header module info");
2066 for (
auto ModInfo :
Data.KnownHeaders)
2067 EmitModule(ModInfo.getModule(), ModInfo.getRole());
2068 if (
Data.Unresolved.getPointer())
2069 EmitModule(
Data.Unresolved.getPointer(),
Data.Unresolved.getInt());
2071 assert(Out.tell() - Start == DataLen &&
"Wrong data length");
2074 const char *strings_begin()
const {
return FrameworkStringData.begin(); }
2075 const char *strings_end()
const {
return FrameworkStringData.end(); }
2083void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
2084 HeaderFileInfoTrait GeneratorTrait(*
this);
2085 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait>
Generator;
2087 unsigned NumHeaderSearchEntries = 0;
2094 if (WritingModule) {
2096 while (!Worklist.empty()) {
2097 Module *M = Worklist.pop_back_val();
2114 if (!
U.Size || (!
U.ModTime && IncludeTimestamps)) {
2115 PP->
Diag(
U.FileNameLoc, diag::err_module_no_size_mtime_for_header)
2123 llvm::sys::path::append(
Filename,
U.FileName);
2126 StringRef FilenameDup = strdup(
Filename.c_str());
2127 SavedStrings.push_back(FilenameDup.data());
2129 HeaderFileInfoTrait::key_type Key = {
2130 FilenameDup, *
U.Size, IncludeTimestamps ? *
U.ModTime : 0};
2131 HeaderFileInfoTrait::data_type
Data = {
2136 ++NumHeaderSearchEntries;
2139 Worklist.append(SubmodulesRange.begin(), SubmodulesRange.end());
2149 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
2168 Filename = StringRef(strdup(FilenameTmp.c_str()));
2169 SavedStrings.push_back(
Filename.data());
2174 HeaderFileInfoTrait::key_type Key = {
2177 HeaderFileInfoTrait::data_type
Data = {
2181 ++NumHeaderSearchEntries;
2188 using namespace llvm::support;
2190 llvm::raw_svector_ostream Out(TableData);
2192 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
2193 BucketOffset =
Generator.Emit(Out, GeneratorTrait);
2197 using namespace llvm;
2199 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2201 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2202 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2203 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2204 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2205 unsigned TableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2209 NumHeaderSearchEntries, TableData.size()};
2210 TableData.append(GeneratorTrait.strings_begin(),GeneratorTrait.strings_end());
2211 Stream.EmitRecordWithBlob(TableAbbrev,
Record, TableData);
2214 for (
unsigned I = 0, N = SavedStrings.size(); I != N; ++I)
2215 free(
const_cast<char *
>(SavedStrings[I]));
2218static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
2219 unsigned SLocBufferBlobCompressedAbbrv,
2220 unsigned SLocBufferBlobAbbrv) {
2221 using RecordDataType = ASTWriter::RecordData::value_type;
2226 if (llvm::compression::zstd::isAvailable()) {
2227 llvm::compression::zstd::compress(
2228 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer, 9);
2230 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2231 llvm::toStringRef(CompressedBuffer));
2234 if (llvm::compression::zlib::isAvailable()) {
2235 llvm::compression::zlib::compress(
2236 llvm::arrayRefFromStringRef(Blob.drop_back(1)), CompressedBuffer);
2238 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv,
Record,
2239 llvm::toStringRef(CompressedBuffer));
2244 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv,
Record, Blob);
2255void ASTWriter::WriteSourceManagerBlock(
SourceManager &SourceMgr,
2261 const uint64_t SourceManagerBlockOffset = Stream.GetCurrentBitNo();
2267 unsigned SLocBufferBlobCompressedAbbrv =
2273 std::vector<uint32_t> SLocEntryOffsets;
2274 uint64_t SLocEntryOffsetsBase = Stream.GetCurrentBitNo();
2280 FileID FID = FileID::get(I);
2284 uint64_t Offset = Stream.GetCurrentBitNo() - SLocEntryOffsetsBase;
2285 assert((Offset >> 32) == 0 &&
"SLocEntry offset too large");
2291 if (
Cache->OrigEntry) {
2304 if (!IsSLocAffecting[I])
2306 SLocEntryOffsets.push_back(Offset);
2310 Record.push_back(
File.getFileCharacteristic());
2313 bool EmitBlob =
false;
2316 "Writing to AST an overridden file is not supported");
2319 assert(InputFileIDs[*Content->
OrigEntry] != 0 &&
"Missed file entry");
2322 Record.push_back(getAdjustedNumCreatedFIDs(FID));
2324 FileDeclIDsTy::iterator FDI = FileDeclIDs.find(FID);
2325 if (FDI != FileDeclIDs.end()) {
2326 Record.push_back(FDI->second->FirstDeclIndex);
2327 Record.push_back(FDI->second->DeclIDs.size());
2333 Stream.EmitRecordWithAbbrev(SLocFileAbbrv,
Record);
2344 std::optional<llvm::MemoryBufferRef> Buffer =
2346 StringRef Name = Buffer ? Buffer->getBufferIdentifier() :
"";
2347 Stream.EmitRecordWithBlob(SLocBufferAbbrv,
Record,
2348 StringRef(Name.data(), Name.size() + 1));
2355 std::optional<llvm::MemoryBufferRef> Buffer =
2358 Buffer = llvm::MemoryBufferRef(
"<<<INVALID BUFFER>>>",
"");
2359 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
2360 emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv,
2361 SLocBufferBlobAbbrv);
2366 SLocEntryOffsets.push_back(Offset);
2382 Record.push_back(getAdjustedOffset(NextOffset - SLoc->
getOffset()) - 1);
2383 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv,
Record);
2389 if (SLocEntryOffsets.empty())
2394 using namespace llvm;
2396 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2398 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2399 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2400 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2401 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2402 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2404 RecordData::value_type
Record[] = {
2407 SLocEntryOffsetsBase - SourceManagerBlockOffset};
2408 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev,
Record,
2409 bytes(SLocEntryOffsets));
2420 llvm::DenseMap<int, int> FilenameMap;
2421 FilenameMap[-1] = -1;
2422 for (
const auto &L : LineTable) {
2425 for (
auto &LE : L.second) {
2426 if (FilenameMap.insert(std::make_pair(
LE.FilenameID,
2427 FilenameMap.size() - 1)).second)
2434 for (
const auto &L : LineTable) {
2442 Record.push_back(L.second.size());
2443 for (
const auto &LE : L.second) {
2446 Record.push_back(FilenameMap[
LE.FilenameID]);
2447 Record.push_back((
unsigned)
LE.FileKind);
2448 Record.push_back(
LE.IncludeOffset);
2463 if (MI->isBuiltinMacro())
2479void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2480 uint64_t MacroOffsetsBase = Stream.GetCurrentBitNo();
2484 WritePreprocessorDetail(*PPRec, MacroOffsetsBase);
2499 if (AssumeNonNullLoc.
isValid()) {
2513 Record.push_back(SkipInfo->FoundNonSkipPortion);
2514 Record.push_back(SkipInfo->FoundElse);
2521 Record.push_back(Cond.WasSkipping);
2522 Record.push_back(Cond.FoundNonSkip);
2523 Record.push_back(Cond.FoundElse);
2553 if (
Id.second->hadMacroDefinition() &&
2554 (!
Id.second->isFromAST() ||
2555 Id.second->hasChangedSinceDeserialization()))
2556 MacroIdentifiers.push_back(
Id.second);
2559 llvm::sort(MacroIdentifiers, llvm::deref<std::less<>>());
2565 uint64_t StartOffset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2566 assert((StartOffset >> 32) == 0 &&
"Macro identifiers offset too large");
2569 bool EmittedModuleMacros =
false;
2586 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2588 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2589 Record.push_back(VisMD->isPublic());
2591 ModuleMacroRecord.push_back(getSubmoduleID(WritingModule));
2594 ModuleMacroRecord.clear();
2595 EmittedModuleMacros =
true;
2605 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2607 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2608 Record.push_back(VisMD->isPublic());
2615 llvm::DenseMap<ModuleMacro *, unsigned> Visits;
2616 while (!Worklist.empty()) {
2617 auto *
Macro = Worklist.pop_back_val();
2620 ModuleMacroRecord.push_back(getSubmoduleID(
Macro->getOwningModule()));
2622 for (
auto *M :
Macro->overrides())
2623 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2626 ModuleMacroRecord.clear();
2629 for (
auto *M :
Macro->overrides())
2630 if (++Visits[M] == M->getNumOverridingMacros())
2631 Worklist.push_back(M);
2633 EmittedModuleMacros =
true;
2636 if (
Record.empty() && !EmittedModuleMacros)
2639 IdentMacroDirectivesOffsetMap[Name] = StartOffset;
2650 std::vector<uint32_t> MacroOffsets;
2652 for (
unsigned I = 0, N = MacroInfosToEmit.size(); I != N; ++I) {
2657 if (ID < FirstMacroID) {
2658 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2663 unsigned Index =
ID - FirstMacroID;
2664 if (Index >= MacroOffsets.size())
2665 MacroOffsets.resize(Index + 1);
2667 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2668 assert((Offset >> 32) == 0 &&
"Macro offset too large");
2669 MacroOffsets[Index] = Offset;
2696 Stream.EmitRecord(Code,
Record);
2700 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2715 using namespace llvm;
2717 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2719 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2720 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2721 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
2722 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2724 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2728 MacroOffsetsBase - ASTBlockStartOffset};
2729 Stream.EmitRecordWithBlob(MacroOffsetAbbrev,
Record,
bytes(MacroOffsets));
2734 uint64_t MacroOffsetsBase) {
2744 unsigned NumPreprocessingRecords = 0;
2745 using namespace llvm;
2748 unsigned InclusionAbbrev = 0;
2750 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2752 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2753 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2754 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2755 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2756 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2757 InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2760 unsigned FirstPreprocessorEntityID
2761 = (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0)
2763 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2768 (void)++
E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2771 uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
2772 assert((Offset >> 32) == 0 &&
"Preprocessed entity offset too large");
2773 SourceRange R = getAdjustedRange((*E)->getSourceRange());
2774 PreprocessedEntityOffsets.emplace_back(
2778 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*
E)) {
2780 MacroDefinitions[MD] = NextPreprocessorEntityID;
2787 if (
auto *ME = dyn_cast<MacroExpansion>(*
E)) {
2788 Record.push_back(ME->isBuiltinMacro());
2789 if (ME->isBuiltinMacro())
2792 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2797 if (
auto *ID = dyn_cast<InclusionDirective>(*
E)) {
2799 Record.push_back(
ID->getFileName().size());
2800 Record.push_back(
ID->wasInQuotes());
2801 Record.push_back(
static_cast<unsigned>(
ID->getKind()));
2802 Record.push_back(
ID->importedModule());
2804 Buffer +=
ID->getFileName();
2808 Buffer +=
ID->getFile()->getName();
2809 Stream.EmitRecordWithBlob(InclusionAbbrev,
Record, Buffer);
2813 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2818 if (NumPreprocessingRecords > 0) {
2819 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2822 using namespace llvm;
2824 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2826 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2827 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2828 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2831 FirstPreprocessorEntityID -
2833 Stream.EmitRecordWithBlob(PPEOffsetAbbrev,
Record,
2834 bytes(PreprocessedEntityOffsets));
2839 if (SkippedRanges.size() > 0) {
2840 std::vector<PPSkippedRange> SerializedSkippedRanges;
2841 SerializedSkippedRanges.reserve(SkippedRanges.size());
2842 for (
auto const&
Range : SkippedRanges)
2843 SerializedSkippedRanges.emplace_back(
2847 using namespace llvm;
2848 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2850 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2851 unsigned PPESkippedRangeAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2855 Stream.EmitRecordWithBlob(PPESkippedRangeAbbrev,
Record,
2856 bytes(SerializedSkippedRanges));
2864 auto Known = SubmoduleIDs.find(Mod);
2865 if (Known != SubmoduleIDs.end())
2866 return Known->second;
2869 if (Top != WritingModule &&
2871 !Top->fullModuleNameIs(StringRef(
getLangOpts().CurrentModule))))
2874 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2877unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2890 unsigned ChildModules = 0;
2894 return ChildModules + 1;
2897void ASTWriter::WriteSubmodules(
Module *WritingModule) {
2902 using namespace llvm;
2904 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2906 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2907 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2908 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
2909 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2910 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2911 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2912 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2913 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2914 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2915 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2916 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2917 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2918 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2919 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2920 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2921 unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2923 Abbrev = std::make_shared<BitCodeAbbrev>();
2925 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2926 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2928 Abbrev = std::make_shared<BitCodeAbbrev>();
2930 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2931 unsigned HeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2933 Abbrev = std::make_shared<BitCodeAbbrev>();
2935 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2936 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2938 Abbrev = std::make_shared<BitCodeAbbrev>();
2940 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2941 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2943 Abbrev = std::make_shared<BitCodeAbbrev>();
2945 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2946 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2947 unsigned RequiresAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2949 Abbrev = std::make_shared<BitCodeAbbrev>();
2951 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2952 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2954 Abbrev = std::make_shared<BitCodeAbbrev>();
2956 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2957 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2959 Abbrev = std::make_shared<BitCodeAbbrev>();
2961 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2962 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2964 Abbrev = std::make_shared<BitCodeAbbrev>();
2966 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2967 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2969 Abbrev = std::make_shared<BitCodeAbbrev>();
2971 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2972 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2973 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2975 Abbrev = std::make_shared<BitCodeAbbrev>();
2977 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2978 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2980 Abbrev = std::make_shared<BitCodeAbbrev>();
2982 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2983 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2984 unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2986 Abbrev = std::make_shared<BitCodeAbbrev>();
2988 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2989 unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2992 RecordData::value_type
Record[] = {
2998 std::queue<Module *> Q;
2999 Q.push(WritingModule);
3000 while (!Q.empty()) {
3003 unsigned ID = getSubmoduleID(Mod);
3007 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
3008 ParentID = SubmoduleIDs[Mod->
Parent];
3019 (RecordData::value_type)Mod->
Kind,
3031 Stream.EmitRecordWithBlob(DefinitionAbbrev,
Record, Mod->
Name);
3037 Stream.EmitRecordWithBlob(RequiresAbbrev,
Record, R.FeatureName);
3041 if (std::optional<Module::Header> UmbrellaHeader =
3044 Stream.EmitRecordWithBlob(UmbrellaAbbrev,
Record,
3045 UmbrellaHeader->NameAsWritten);
3046 }
else if (std::optional<Module::DirectoryName> UmbrellaDir =
3049 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev,
Record,
3050 UmbrellaDir->NameAsWritten);
3055 unsigned RecordKind;
3066 for (
auto &HL : HeaderLists) {
3067 RecordData::value_type
Record[] = {HL.RecordKind};
3068 for (
auto &H : Mod->
Headers[HL.HeaderKind])
3069 Stream.EmitRecordWithBlob(HL.Abbrev,
Record, H.NameAsWritten);
3078 Stream.EmitRecordWithBlob(TopHeaderAbbrev,
Record, HeaderName);
3086 Record.push_back(getSubmoduleID(I));
3094 Record.push_back(getSubmoduleID(I));
3101 for (
const auto &
E : Mod->
Exports) {
3104 Record.push_back(getSubmoduleID(
E.getPointer()));
3120 Stream.EmitRecordWithBlob(LinkLibraryAbbrev,
Record, LL.Library);
3128 getSubmoduleID(
C.Other)};
3129 Stream.EmitRecordWithBlob(ConflictAbbrev,
Record,
C.Message);
3135 Stream.EmitRecordWithBlob(ConfigMacroAbbrev,
Record, CM);
3160 assert((NextSubmoduleID - FirstSubmoduleID ==
3162 "Wrong # of submodules; found a reference to a non-local, "
3163 "non-imported submodule?");
3168 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
3170 unsigned CurrID = 0;
3173 auto EncodeDiagStateFlags =
3174 [](
const DiagnosticsEngine::DiagState *DS) ->
unsigned {
3177 {(
unsigned)DS->IgnoreAllWarnings, (
unsigned)DS->EnableAllWarnings,
3178 (
unsigned)DS->WarningsAsErrors, (
unsigned)DS->ErrorsAsFatal,
3179 (
unsigned)DS->SuppressSystemWarnings})
3184 unsigned Flags = EncodeDiagStateFlags(
Diag.DiagStatesByLoc.FirstDiagState);
3187 auto AddDiagState = [&](
const DiagnosticsEngine::DiagState *State,
3188 bool IncludeNonPragmaStates) {
3191 assert(Flags == EncodeDiagStateFlags(State) &&
3192 "diag state flags vary in single AST file");
3196 assert(!IncludeNonPragmaStates ||
3197 State ==
Diag.DiagStatesByLoc.FirstDiagState);
3199 unsigned &DiagStateID = DiagStateIDMap[State];
3200 Record.push_back(DiagStateID);
3202 if (DiagStateID == 0) {
3203 DiagStateID = ++CurrID;
3207 auto SizeIdx =
Record.size();
3209 for (
const auto &I : *State) {
3211 if (!I.second.isPragma() && !IncludeNonPragmaStates)
3215 if (!I.second.isPragma() &&
3218 Mappings.push_back(I);
3222 llvm::sort(Mappings, llvm::less_first());
3224 for (
const auto &I : Mappings) {
3225 Record.push_back(I.first);
3226 Record.push_back(I.second.serialize());
3233 AddDiagState(
Diag.DiagStatesByLoc.FirstDiagState, isModule);
3236 auto NumLocationsIdx =
Record.size();
3240 unsigned NumLocations = 0;
3241 for (
auto &FileIDAndFile :
Diag.DiagStatesByLoc.Files) {
3242 if (!FileIDAndFile.first.isValid() ||
3243 !FileIDAndFile.second.HasLocalTransitions)
3249 Record.push_back(FileIDAndFile.second.StateTransitions.size());
3250 for (
auto &StatePoint : FileIDAndFile.second.StateTransitions) {
3251 Record.push_back(getAdjustedOffset(StatePoint.Offset));
3252 AddDiagState(StatePoint.State,
false);
3257 Record[NumLocationsIdx] = NumLocations;
3266 AddDiagState(
Diag.DiagStatesByLoc.CurDiagState,
false);
3279 IdxRef =
TypeIdx(0, NextTypeID++);
3283 assert(Idx.
getValue() >= FirstTypeID &&
"Writing predefined type");
3286 uint64_t Offset = ASTTypeWriter(*this).write(
T) - DeclTypesBlockStartOffset;
3290 if (TypeOffsets.size() == Index)
3291 TypeOffsets.emplace_back(Offset);
3292 else if (TypeOffsets.size() < Index) {
3293 TypeOffsets.resize(Index + 1);
3294 TypeOffsets[Index].set(Offset);
3296 llvm_unreachable(
"Types emitted in wrong order");
3305 auto *ND = dyn_cast<NamedDecl>(
D);
3329 uint64_t Offset = Stream.GetCurrentBitNo();
3331 for (
const auto *
D : DC->
decls()) {
3344 KindDeclPairs.push_back(
D->
getKind());
3345 KindDeclPairs.push_back(
GetDeclRef(
D).getRawValue());
3348 ++NumLexicalDeclContexts;
3350 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev,
Record,
3351 bytes(KindDeclPairs));
3355void ASTWriter::WriteTypeDeclOffsets() {
3356 using namespace llvm;
3359 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3361 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3362 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3363 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3366 Stream.EmitRecordWithBlob(TypeOffsetAbbrev,
Record,
bytes(TypeOffsets));
3370 Abbrev = std::make_shared<BitCodeAbbrev>();
3372 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3373 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3374 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3377 Stream.EmitRecordWithBlob(DeclOffsetAbbrev,
Record,
bytes(DeclOffsets));
3381void ASTWriter::WriteFileDeclIDsMap() {
3382 using namespace llvm;
3385 SortedFileDeclIDs.reserve(FileDeclIDs.size());
3386 for (
const auto &
P : FileDeclIDs)
3387 SortedFileDeclIDs.push_back(std::make_pair(
P.first,
P.second.get()));
3388 llvm::sort(SortedFileDeclIDs, llvm::less_first());
3392 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
3393 DeclIDInFileInfo &Info = *FileDeclEntry.second;
3394 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
3395 llvm::stable_sort(Info.DeclIDs);
3396 for (
auto &LocDeclEntry : Info.DeclIDs)
3397 FileGroupedDeclIDs.push_back(LocDeclEntry.second.getRawValue());
3400 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3402 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3403 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3404 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
3406 FileGroupedDeclIDs.size()};
3407 Stream.EmitRecordWithBlob(AbbrevCode,
Record,
bytes(FileGroupedDeclIDs));
3410void ASTWriter::WriteComments() {
3412 auto _ = llvm::make_scope_exit([
this] { Stream.ExitBlock(); });
3423 for (
const auto &FO : Context->
Comments.OrderedComments) {
3424 for (
const auto &OC : FO.second) {
3443class ASTMethodPoolTrait {
3448 using key_type_ref = key_type;
3454 using data_type_ref =
const data_type &;
3459 explicit ASTMethodPoolTrait(
ASTWriter &Writer) : Writer(Writer) {}
3465 std::pair<unsigned, unsigned>
3466 EmitKeyDataLength(raw_ostream& Out,
Selector Sel,
3467 data_type_ref Methods) {
3471 unsigned DataLen = 4 + 2 + 2;
3474 if (ShouldWriteMethodListNode(Method))
3475 DataLen +=
sizeof(
DeclID);
3478 if (ShouldWriteMethodListNode(Method))
3479 DataLen +=
sizeof(
DeclID);
3483 void EmitKey(raw_ostream& Out,
Selector Sel,
unsigned) {
3484 using namespace llvm::support;
3486 endian::Writer
LE(Out, llvm::endianness::little);
3488 assert((Start >> 32) == 0 &&
"Selector key offset too large");
3491 LE.write<uint16_t>(N);
3494 for (
unsigned I = 0; I != N; ++I)
3499 void EmitData(raw_ostream& Out, key_type_ref,
3500 data_type_ref Methods,
unsigned DataLen) {
3501 using namespace llvm::support;
3503 endian::Writer
LE(Out, llvm::endianness::little);
3504 uint64_t Start = Out.tell(); (void)Start;
3506 unsigned NumInstanceMethods = 0;
3509 if (ShouldWriteMethodListNode(Method))
3510 ++NumInstanceMethods;
3512 unsigned NumFactoryMethods = 0;
3515 if (ShouldWriteMethodListNode(Method))
3516 ++NumFactoryMethods;
3518 unsigned InstanceBits = Methods.Instance.getBits();
3519 assert(InstanceBits < 4);
3520 unsigned InstanceHasMoreThanOneDeclBit =
3521 Methods.Instance.hasMoreThanOneDecl();
3522 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
3523 (InstanceHasMoreThanOneDeclBit << 2) |
3525 unsigned FactoryBits = Methods.Factory.getBits();
3526 assert(FactoryBits < 4);
3527 unsigned FactoryHasMoreThanOneDeclBit =
3528 Methods.Factory.hasMoreThanOneDecl();
3529 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
3530 (FactoryHasMoreThanOneDeclBit << 2) |
3532 LE.write<uint16_t>(FullInstanceBits);
3533 LE.write<uint16_t>(FullFactoryBits);
3536 if (ShouldWriteMethodListNode(Method))
3540 if (ShouldWriteMethodListNode(Method))
3543 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3548 return (
Node->getMethod() && !
Node->getMethod()->isFromASTFile());
3559void ASTWriter::WriteSelectors(
Sema &SemaRef) {
3560 using namespace llvm;
3565 unsigned NumTableEntries = 0;
3568 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait>
Generator;
3569 ASTMethodPoolTrait Trait(*
this);
3573 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
3574 for (
auto &SelectorAndID : SelectorIDs) {
3579 ASTMethodPoolTrait::data_type
Data = {
3585 Data.Instance = F->second.first;
3586 Data.Factory = F->second.second;
3590 if (Chain && ID < FirstSelectorID) {
3592 bool changed =
false;
3595 if (!M->getMethod()->isFromASTFile()) {
3603 if (!M->getMethod()->isFromASTFile()) {
3611 }
else if (
Data.Instance.getMethod() ||
Data.Factory.getMethod()) {
3622 using namespace llvm::support;
3624 ASTMethodPoolTrait Trait(*
this);
3625 llvm::raw_svector_ostream Out(MethodPool);
3627 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
3628 BucketOffset =
Generator.Emit(Out, Trait);
3632 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3634 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3635 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3636 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3637 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3643 Stream.EmitRecordWithBlob(MethodPoolAbbrev,
Record, MethodPool);
3647 Abbrev = std::make_shared<BitCodeAbbrev>();
3649 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3650 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3651 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3652 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3656 RecordData::value_type
Record[] = {
3659 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev,
Record,
3660 bytes(SelectorOffsets));
3666void ASTWriter::WriteReferencedSelectorsPool(
Sema &SemaRef) {
3667 using namespace llvm;
3679 Selector Sel = SelectorAndLocation.first;
3681 Writer.AddSelectorRef(Sel);
3703 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3705 if (!Redecl->isFromASTFile()) {
3709 if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
3712 return cast<NamedDecl>(Redecl);
3717 if (Redecl->getOwningModuleID() == 0)
3722 if (!
First->isFromASTFile())
3723 return cast<NamedDecl>(
First);
3733bool IsInterestingIdentifier(
const IdentifierInfo *II, uint64_t MacroOffset,
3734 bool IsModule,
bool IsCPlusPlus) {
3735 bool NeedDecls = !IsModule || !IsCPlusPlus;
3737 bool IsInteresting =
3741 if (MacroOffset || II->
isPoisoned() || (!IsModule && IsInteresting) ||
3752 bool IsCPlusPlus = Writer.
getLangOpts().CPlusPlus;
3753 return IsInterestingIdentifier(II, 0, IsModule, IsCPlusPlus);
3756class ASTIdentifierTableTrait {
3769 return IsInterestingIdentifier(II, MacroOffset, IsModule,
3775 using key_type_ref = key_type;
3778 using data_type_ref = data_type;
3786 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3787 NeedDecls(!IsModule || !Writer.getLangOpts().
CPlusPlus),
3788 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3790 bool needDecls()
const {
return NeedDecls; }
3793 return llvm::djbHash(II->
getName());
3801 std::pair<unsigned, unsigned>
3811 if (InterestingIdentifierOffsets &&
3813 InterestingIdentifierOffsets->push_back(Out.tell());
3824 DataLen += std::distance(IdResolver.
begin(II), IdResolver.
end()) *
3830 void EmitKey(raw_ostream &Out,
const IdentifierInfo *II,
unsigned KeyLen) {
3836 using namespace llvm::support;
3838 endian::Writer
LE(Out, llvm::endianness::little);
3848 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
3849 LE.write<uint16_t>(Bits);
3851 bool HadMacroDefinition = MacroOffset != 0;
3852 Bits = (Bits << 1) |
unsigned(HadMacroDefinition);
3854 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
3857 LE.write<uint16_t>(Bits);
3859 if (HadMacroDefinition)
3891 using namespace llvm;
3898 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait>
Generator;
3899 ASTIdentifierTableTrait Trait(*
this, PP, IdResolver, IsModule,
3900 IsModule ? &InterestingIdents :
nullptr);
3904 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
3905 for (
auto IdentIDPair : IdentifierIDs) {
3908 assert(II &&
"NULL identifier in identifier table");
3913 (Trait.needDecls() &&
3922 using namespace llvm::support;
3926 endian::write<uint32_t>(Out, 0, llvm::endianness::little);
3927 BucketOffset =
Generator.Emit(Out, Trait);
3931 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3933 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3934 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3935 unsigned IDTableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3943 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3945 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3946 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3947 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3950 for (
unsigned I = 0, N = IdentifierOffsets.size(); I != N; ++I)
3951 assert(IdentifierOffsets[I] &&
"Missing identifier offset?");
3955 IdentifierOffsets.size()};
3956 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev,
Record,
3957 bytes(IdentifierOffsets));
3961 if (!InterestingIdents.empty())
3966 PendingEmittingVTables.push_back(RD);
3976class ASTDeclContextNameLookupTrait {
3982 using key_type_ref = key_type;
3985 using data_type = std::pair<unsigned, unsigned>;
3986 using data_type_ref =
const data_type &;
3991 explicit ASTDeclContextNameLookupTrait(
ASTWriter &Writer) : Writer(Writer) {}
3993 template<
typename Coll>
3994 data_type getData(
const Coll &Decls) {
3995 unsigned Start = DeclIDs.size();
4011 DeclIDs.push_back(Writer.
GetDeclRef(DeclForLocalLookup));
4013 return std::make_pair(Start, DeclIDs.size());
4017 unsigned Start = DeclIDs.size();
4022 return std::make_pair(Start, DeclIDs.size());
4025 static bool EqualKey(key_type_ref a, key_type_ref
b) {
4030 return Name.getHash();
4033 void EmitFileRef(raw_ostream &Out,
ModuleFile *F)
const {
4035 "have reference to loaded module file but no chain?");
4037 using namespace llvm::support;
4040 llvm::endianness::little);
4043 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
4045 data_type_ref Lookup) {
4046 unsigned KeyLen = 1;
4047 switch (Name.getKind()) {
4069 unsigned DataLen =
sizeof(
DeclID) * (Lookup.second - Lookup.first);
4075 using namespace llvm::support;
4077 endian::Writer
LE(Out, llvm::endianness::little);
4078 LE.write<uint8_t>(Name.getKind());
4079 switch (Name.getKind()) {
4092 "Invalid operator?");
4093 LE.write<uint8_t>(Name.getOperatorKind());
4102 llvm_unreachable(
"Invalid name kind?");
4105 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
4107 using namespace llvm::support;
4109 endian::Writer
LE(Out, llvm::endianness::little);
4110 uint64_t Start = Out.tell(); (void)Start;
4111 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
4113 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
4121 return Result.hasExternalDecls() &&
4122 DC->hasNeedToReconcileExternalVisibleStorage();
4131 for (
auto *
D :
Result.getLookupResult()) {
4133 if (LocalD->isFromASTFile())
4152ASTWriter::GenerateNameLookupTable(
const DeclContext *ConstDC,
4154 assert(!ConstDC->hasLazyLocalLexicalLookups() &&
4155 !ConstDC->hasLazyExternalLexicalLookups() &&
4156 "must call buildLookups first");
4164 ASTDeclContextNameLookupTrait>
Generator;
4165 ASTDeclContextNameLookupTrait Trait(*
this);
4177 auto &Name = Lookup.first;
4178 auto &
Result = Lookup.second;
4193 if ((GeneratingReducedBMI || isLookupResultExternal(
Result, DC)) &&
4211 if (Lookup.second.getLookupResult().empty())
4214 switch (Lookup.first.getNameKind()) {
4216 Names.push_back(Lookup.first);
4220 assert(isa<CXXRecordDecl>(DC) &&
4221 "Cannot have a constructor name outside of a class!");
4222 ConstructorNameSet.insert(Name);
4226 assert(isa<CXXRecordDecl>(DC) &&
4227 "Cannot have a conversion function name outside of a class!");
4228 ConversionNameSet.insert(Name);
4236 if (
auto *
D = dyn_cast<CXXRecordDecl>(DC)) {
4250 if (ConstructorNameSet.erase(ImplicitCtorName))
4251 Names.push_back(ImplicitCtorName);
4256 if (!ConstructorNameSet.empty() || !ConversionNameSet.empty())
4257 for (
Decl *ChildD : cast<CXXRecordDecl>(DC)->decls())
4258 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
4259 auto Name = ChildND->getDeclName();
4260 switch (Name.getNameKind()) {
4265 if (ConstructorNameSet.erase(Name))
4266 Names.push_back(Name);
4270 if (ConversionNameSet.erase(Name))
4271 Names.push_back(Name);
4275 if (ConstructorNameSet.empty() && ConversionNameSet.empty())
4279 assert(ConstructorNameSet.empty() &&
"Failed to find all of the visible "
4280 "constructors by walking all the "
4281 "lexical members of the context.");
4282 assert(ConversionNameSet.empty() &&
"Failed to find all of the visible "
4283 "conversion functions by walking all "
4284 "the lexical members of the context.");
4291 for (
auto &Name : Names)
4303 for (
auto &Name : Names) {
4306 switch (Name.getNameKind()) {
4324 if (!ConstructorDecls.empty())
4325 Generator.insert(ConstructorDecls.front()->getDeclName(),
4326 Trait.getData(ConstructorDecls), Trait);
4327 if (!ConversionDecls.empty())
4328 Generator.insert(ConversionDecls.front()->getDeclName(),
4329 Trait.getData(ConversionDecls), Trait);
4334 Generator.emit(LookupTable, Trait, Lookups ? &Lookups->Table :
nullptr);
4347 if (isa<NamespaceDecl>(DC) && Chain &&
4350 for (
auto *Prev = cast<NamespaceDecl>(DC)->getPreviousDecl(); Prev;
4351 Prev = Prev->getPreviousDecl())
4352 if (!Prev->isFromASTFile())
4365 LookupResults.reserve(Map->size());
4366 for (
auto &Entry : *Map)
4367 LookupResults.push_back(
4368 std::make_pair(Entry.first, Entry.second.getLookupResult()));
4371 llvm::sort(LookupResults, llvm::less_first());
4372 for (
auto &NameAndResult : LookupResults) {
4380 assert(
Result.empty() &&
"Cannot have a constructor or conversion "
4381 "function name in a namespace!");
4386 if (ND->isFromASTFile())
4394 if (GeneratingReducedBMI && !ND->isFromExplicitGlobalModule() &&
4422 uint64_t Offset = Stream.GetCurrentBitNo();
4424 if (!Map || Map->empty())
4429 GenerateNameLookupTable(DC, LookupTable);
4433 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev,
Record,
4435 ++NumVisibleDeclContexts;
4445void ASTWriter::WriteDeclContextVisibleUpdate(
const DeclContext *DC) {
4447 if (!Map || Map->empty())
4452 GenerateNameLookupTable(DC, LookupTable);
4456 if (isa<NamespaceDecl>(DC))
4462 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev,
Record, LookupTable);
4472void ASTWriter::WriteOpenCLExtensions(
Sema &SemaRef) {
4478 for (
const auto &I:Opts.OptMap) {
4480 auto V = I.getValue();
4481 Record.push_back(
V.Supported ? 1 : 0);
4482 Record.push_back(
V.Enabled ? 1 : 0);
4483 Record.push_back(
V.WithPragma ? 1 : 0);
4490void ASTWriter::WriteCUDAPragmas(
Sema &SemaRef) {
4491 if (SemaRef.
CUDA().ForceHostDeviceDepth > 0) {
4492 RecordData::value_type
Record[] = {SemaRef.
CUDA().ForceHostDeviceDepth};
4497void ASTWriter::WriteObjCCategories() {
4501 for (
unsigned I = 0, N = ObjCClassesWithCategories.size(); I != N; ++I) {
4503 unsigned StartIndex = Categories.size();
4508 Categories.push_back(0);
4512 Cat =
Class->known_categories_begin(),
4513 CatEnd =
Class->known_categories_end();
4514 Cat != CatEnd; ++Cat, ++Size) {
4520 Categories[StartIndex] =
Size;
4524 CategoriesMap.push_back(CatInfo);
4529 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
4532 using namespace llvm;
4534 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4536 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
4537 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4538 unsigned AbbrevID = Stream.EmitAbbrev(std::move(Abbrev));
4541 Stream.EmitRecordWithBlob(AbbrevID,
Record,
4542 reinterpret_cast<char *
>(CategoriesMap.data()),
4549void ASTWriter::WriteLateParsedTemplates(
Sema &SemaRef) {
4556 for (
auto &LPTMapEntry : LPTMap) {
4564 for (
const auto &Tok : LPT.
Toks) {
4572void ASTWriter::WriteOptimizePragmaOptions(
Sema &SemaRef) {
4580void ASTWriter::WriteMSStructPragmaOptions(
Sema &SemaRef) {
4588void ASTWriter::WriteMSPointersToMembersPragmaOptions(
Sema &SemaRef) {
4596void ASTWriter::WritePackPragmaOptions(
Sema &SemaRef) {
4616void ASTWriter::WriteFloatControlPragmaOptions(
Sema &SemaRef) {
4626 for (
const auto &StackEntry : SemaRef.
FpPragmaStack.Stack) {
4627 Record.push_back(StackEntry.Value.getAsOpaqueInt());
4635void ASTWriter::WriteModuleFileExtension(
Sema &SemaRef,
4641 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
4643 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4644 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4645 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4646 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4647 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4648 unsigned Abbrev = Stream.EmitAbbrev(std::move(Abv));
4654 Record.push_back(Metadata.MajorVersion);
4655 Record.push_back(Metadata.MinorVersion);
4656 Record.push_back(Metadata.BlockName.size());
4657 Record.push_back(Metadata.UserInfo.size());
4659 Buffer += Metadata.BlockName;
4660 Buffer += Metadata.UserInfo;
4661 Stream.EmitRecordWithBlob(Abbrev,
Record, Buffer);
4679 if (!A || (isa<PreferredNameAttr>(A) &&
4680 Writer->isWritingStdCXXNamedModules()))
4681 return Record.push_back(0);
4691 Record.push_back(A->getAttributeSpellingListIndexRaw());
4694#include "clang/Serialization/AttrPCHWrite.inc"
4700 for (
const auto *A : Attrs)
4714 case tok::annot_pragma_loop_hint: {
4718 Record.push_back(Info->Toks.size());
4719 for (
const auto &
T : Info->Toks)
4723 case tok::annot_pragma_pack: {
4726 Record.push_back(
static_cast<unsigned>(Info->Action));
4732 case tok::annot_pragma_openmp:
4733 case tok::annot_pragma_openmp_end:
4734 case tok::annot_pragma_unused:
4735 case tok::annot_pragma_openacc:
4736 case tok::annot_pragma_openacc_end:
4737 case tok::annot_repl_input_end:
4740 llvm_unreachable(
"missing serialization code for annotation token");
4751 Record.push_back(Str.size());
4756 assert(Context &&
"should have context when outputting path");
4759 StringRef PathStr(
Path.data(),
Path.size());
4760 if (PathStr ==
"<built-in>" || PathStr ==
"<command line>")
4767 const char *PathBegin =
Path.data();
4768 const char *PathPtr =
4770 if (PathPtr != PathBegin) {
4771 Path.erase(
Path.begin(),
Path.begin() + (PathPtr - PathBegin));
4788 Stream.EmitRecordWithBlob(Abbrev,
Record, FilePath);
4793 Record.push_back(Version.getMajor());
4794 if (std::optional<unsigned> Minor = Version.getMinor())
4795 Record.push_back(*Minor + 1);
4798 if (std::optional<unsigned> Subminor = Version.getSubminor())
4799 Record.push_back(*Subminor + 1);
4817 assert(ID < IdentifierOffsets.size());
4818 IdentifierOffsets[ID] = Offset;
4824 unsigned ID = SelectorIDs[Sel];
4825 assert(ID &&
"Unknown selector");
4828 if (ID < FirstSelectorID)
4830 SelectorOffsets[ID - FirstSelectorID] = Offset;
4836 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
4837 bool IncludeTimestamps,
bool BuildingImplicitModule,
4838 bool GeneratingReducedBMI)
4839 : Stream(Stream), Buffer(Buffer), ModuleCache(ModuleCache),
4840 IncludeTimestamps(IncludeTimestamps),
4841 BuildingImplicitModule(BuildingImplicitModule),
4842 GeneratingReducedBMI(GeneratingReducedBMI) {
4843 for (
const auto &Ext : Extensions) {
4844 if (
auto Writer = Ext->createExtensionWriter(*
this))
4845 ModuleFileExtensionWriters.push_back(std::move(Writer));
4852 assert(WritingAST &&
"can't determine lang opts when not writing AST");
4857 return IncludeTimestamps ?
E->getModificationTime() : 0;
4861 Module *WritingModule, StringRef isysroot,
4862 bool ShouldCacheASTInMemory) {
4863 llvm::TimeTraceScope scope(
"WriteAST", OutputFile);
4866 ASTHasCompilerErrors =
4870 Stream.Emit((
unsigned)
'C', 8);
4871 Stream.Emit((
unsigned)
'P', 8);
4872 Stream.Emit((
unsigned)
'C', 8);
4873 Stream.Emit((
unsigned)
'H', 8);
4875 WriteBlockInfoBlock();
4879 this->WritingModule = WritingModule;
4880 ASTFileSignature Signature = WriteASTCore(SemaRef, isysroot, WritingModule);
4883 this->WritingModule =
nullptr;
4884 this->BaseDirectory.clear();
4887 if (ShouldCacheASTInMemory) {
4890 llvm::MemoryBuffer::getMemBufferCopy(
4891 StringRef(Buffer.begin(), Buffer.size())));
4896template<
typename Vector>
4898 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true),
E = Vec.end();
4904template <
typename Vector>
4907 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true),
E = Vec.end();
4913void ASTWriter::computeNonAffectingInputFiles() {
4917 IsSLocAffecting.resize(N,
true);
4922 auto AffectingModuleMaps = GetAffectingModuleMaps(*PP, WritingModule);
4924 unsigned FileIDAdjustment = 0;
4925 unsigned OffsetAdjustment = 0;
4927 NonAffectingFileIDAdjustments.reserve(N);
4928 NonAffectingOffsetAdjustments.reserve(N);
4930 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
4931 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
4933 for (
unsigned I = 1; I != N; ++I) {
4935 FileID FID = FileID::get(I);
4942 if (!
Cache->OrigEntry)
4950 if (!AffectingModuleMaps)
4954 if (llvm::is_contained(*AffectingModuleMaps, *
Cache->OrigEntry))
4957 IsSLocAffecting[I] =
false;
4959 FileIDAdjustment += 1;
4965 if (!NonAffectingFileIDs.empty() &&
4966 NonAffectingFileIDs.back().ID == FID.ID - 1) {
4967 NonAffectingFileIDs.back() = FID;
4969 NonAffectingFileIDAdjustments.back() = FileIDAdjustment;
4970 NonAffectingOffsetAdjustments.back() = OffsetAdjustment;
4974 NonAffectingFileIDs.push_back(FID);
4977 NonAffectingFileIDAdjustments.push_back(FileIDAdjustment);
4978 NonAffectingOffsetAdjustments.push_back(OffsetAdjustment);
4987 for (StringRef
Path :
4990 for (
unsigned I = 1; I != N; ++I) {
4991 if (IsSLocAffecting[I]) {
4997 if (!
Cache->OrigEntry)
5000 Cache->OrigEntry->getNameAsRequested());
5006void ASTWriter::PrepareWritingSpecialDecls(
Sema &SemaRef) {
5009 bool isModule = WritingModule !=
nullptr;
5016 PredefinedDecls.insert(
D);
5024 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
5028 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
5032 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
5037 RegisterPredefDecl(Context.MakeIntegerSeqDecl,
5039 RegisterPredefDecl(Context.CFConstantStringTypeDecl,
5041 RegisterPredefDecl(Context.CFConstantStringTagDecl,
5043 RegisterPredefDecl(Context.TypePackElementDecl,
5056 if (GeneratingReducedBMI) {
5082 if (GeneratingReducedBMI)
5105 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I)
5116 "There are local ones at end of translation unit!");
5129 for (
const auto &I : SemaRef.KnownNamespaces)
5136 for (
const auto &I : Undefined)
5142 for (
const auto &DeleteExprsInfo :
5149 for (
const auto *I : DeclsToEmitEvenIfUnreferenced)
5151 DeclsToEmitEvenIfUnreferenced.clear();
5163 llvm::sort(IIs, llvm::deref<std::less<>>());
5170 for (
auto *
D : SemaRef.DeclsToCheckForDeferredDiags)
5178 PendingEmittingVTables.clear();
5181void ASTWriter::WriteSpecialDeclRecords(
Sema &SemaRef) {
5184 bool isModule = WritingModule !=
nullptr;
5187 if (!EagerlyDeserializedDecls.empty())
5190 if (!ModularCodegenDecls.empty())
5196 TentativeDefinitions);
5197 if (!TentativeDefinitions.empty())
5204 UnusedFileScopedDecls);
5205 if (!UnusedFileScopedDecls.empty())
5211 if (!ExtVectorDecls.empty())
5217 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I) {
5233 if (!UnusedLocalTypedefNameCandidates.empty())
5235 UnusedLocalTypedefNameCandidates);
5246 if (!PendingInstantiations.empty())
5252 auto AddEmittedDeclRefOrZero = [
this, &SemaDeclRefs](
Decl *
D) {
5254 SemaDeclRefs.push_back(0);
5263 if (!SemaDeclRefs.empty())
5268 for (
auto *
D : SemaRef.DeclsToCheckForDeferredDiags)
5271 if (!DeclsToCheckForDeferredDiags.empty())
5273 DeclsToCheckForDeferredDiags);
5279 AddDeclRef(CudaCallDecl, CUDASpecialDeclRefs);
5287 DelegatingCtorDecls);
5288 if (!DelegatingCtorDecls.empty())
5293 for (
const auto &I : SemaRef.KnownNamespaces) {
5297 if (!KnownNamespaces.empty())
5304 for (
const auto &I : Undefined) {
5311 if (!UndefinedButUsed.empty())
5318 for (
const auto &DeleteExprsInfo :
5323 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
5324 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
5325 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
5327 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
5331 if (!DeleteExprsToAnalyze.empty())
5342 if (!VTablesToEmit.empty())
5348 using namespace llvm;
5350 bool isModule = WritingModule !=
nullptr;
5361 computeNonAffectingInputFiles();
5363 writeUnhashedControlBlock(PP, Context);
5376 IdentifierIDs.clear();
5389 if (IsInterestingNonMacroIdentifier(
ID.second, *
this))
5390 IIs.push_back(
ID.second);
5393 llvm::sort(IIs, llvm::deref<std::less<>>());
5401 for (
const auto &WeakUndeclaredIdentifierList :
5403 const IdentifierInfo *
const II = WeakUndeclaredIdentifierList.first;
5404 for (
const auto &WI : WeakUndeclaredIdentifierList.second) {
5417 AddTypeRef(Context.ObjCIdRedefinitionType, SpecialTypes);
5418 AddTypeRef(Context.ObjCClassRedefinitionType, SpecialTypes);
5419 AddTypeRef(Context.ObjCSelRedefinitionType, SpecialTypes);
5422 PrepareWritingSpecialDecls(SemaRef);
5425 WriteControlBlock(PP, Context, isysroot);
5428 Stream.FlushToWord();
5429 ASTBlockRange.first = Stream.GetCurrentBitNo() >> 3;
5431 ASTBlockStartOffset = Stream.GetCurrentBitNo();
5448 for (
auto &SelectorAndID : SelectorIDs)
5449 AllSelectors.push_back(SelectorAndID.first);
5450 for (
auto &
Selector : AllSelectors)
5473 auto Abbrev = std::make_shared<BitCodeAbbrev>();
5475 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
5476 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
5479 llvm::raw_svector_ostream Out(Buffer);
5481 using namespace llvm::support;
5483 endian::Writer
LE(Out, llvm::endianness::little);
5484 LE.write<uint8_t>(
static_cast<uint8_t
>(M.
Kind));
5486 LE.write<uint16_t>(Name.size());
5487 Out.write(Name.data(), Name.size());
5493 auto writeBaseIDOrNone = [&](
auto BaseID,
bool ShouldWrite) {
5494 assert(BaseID < std::numeric_limits<uint32_t>::max() &&
"base id too high");
5511 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev,
Record,
5512 Buffer.data(), Buffer.size());
5515 WriteDeclAndTypes(Context);
5517 WriteFileDeclIDsMap();
5520 WritePreprocessor(PP, isModule);
5522 WriteSelectors(SemaRef);
5523 WriteReferencedSelectorsPool(SemaRef);
5524 WriteLateParsedTemplates(SemaRef);
5525 WriteIdentifierTable(PP, SemaRef.
IdResolver, isModule);
5527 WriteOpenCLExtensions(SemaRef);
5528 WriteCUDAPragmas(SemaRef);
5532 WriteSubmodules(WritingModule);
5536 WriteSpecialDeclRecords(SemaRef);
5539 if (!WeakUndeclaredIdentifiers.empty())
5541 WeakUndeclaredIdentifiers);
5543 if (!WritingModule) {
5552 assert(SubmoduleIDs.contains(I->getImportedModule()));
5553 Imports.push_back(ModuleInfo(SubmoduleIDs[I->getImportedModule()],
5554 I->getImportedModule()));
5557 if (!Imports.empty()) {
5558 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
5561 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
5562 return A.ID == B.ID;
5566 llvm::sort(Imports, Cmp);
5567 Imports.erase(std::unique(Imports.begin(), Imports.end(),
Eq),
5571 for (
const auto &Import : Imports) {
5572 ImportedModules.push_back(
Import.ID);
5583 WriteObjCCategories();
5584 if(!WritingModule) {
5585 WriteOptimizePragmaOptions(SemaRef);
5586 WriteMSStructPragmaOptions(SemaRef);
5587 WriteMSPointersToMembersPragmaOptions(SemaRef);
5589 WritePackPragmaOptions(SemaRef);
5590 WriteFloatControlPragmaOptions(SemaRef);
5593 RecordData::value_type
Record[] = {
5594 NumStatements, NumMacros, NumLexicalDeclContexts, NumVisibleDeclContexts};
5597 Stream.FlushToWord();
5598 ASTBlockRange.second = Stream.GetCurrentBitNo() >> 3;
5601 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
5602 WriteModuleFileExtension(SemaRef, *ExtWriter);
5604 return backpatchSignature();
5607void ASTWriter::EnteringModulePurview() {
5610 if (GeneratingReducedBMI)
5611 DeclUpdatesFromGMF.swap(DeclUpdates);
5617void ASTWriter::AddedManglingNumber(
const Decl *
D,
unsigned Number) {
5623void ASTWriter::AddedStaticLocalNumbers(
const Decl *
D,
unsigned Number) {
5642void ASTWriter::WriteDeclAndTypes(
ASTContext &Context) {
5647 DeclTypesBlockStartOffset = Stream.GetCurrentBitNo();
5651 WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord);
5652 while (!DeclTypesToEmit.empty()) {
5653 DeclOrType DOT = DeclTypesToEmit.front();
5654 DeclTypesToEmit.pop();
5656 WriteType(DOT.getType());
5658 WriteDecl(Context, DOT.getDecl());
5660 }
while (!DeclUpdates.empty());
5662 DoneWritingDeclsAndTypes =
true;
5666 assert(DelayedNamespace.empty() || GeneratingReducedBMI);
5669 uint64_t LexicalOffset = WriteDeclContextLexicalBlock(Context, NS);
5670 uint64_t VisibleOffset = WriteDeclContextVisibleBlock(Context, NS);
5674 LexicalOffset -= DeclTypesBlockStartOffset;
5677 VisibleOffset -= DeclTypesBlockStartOffset;
5680 DelayedNamespaceRecord.push_back(LexicalOffset);
5681 DelayedNamespaceRecord.push_back(VisibleOffset);
5686 assert(DeclTypesToEmit.empty());
5687 assert(DeclUpdates.empty());
5692 WriteTypeDeclOffsets();
5693 if (!DeclUpdatesOffsetsRecord.empty())
5696 if (!DelayedNamespaceRecord.empty())
5698 DelayedNamespaceRecord);
5712 NewGlobalKindDeclPairs.push_back(
D->
getKind());
5713 NewGlobalKindDeclPairs.push_back(
GetDeclRef(
D).getRawValue());
5716 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
5718 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
5719 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
5722 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev,
Record,
5723 bytes(NewGlobalKindDeclPairs));
5725 Abv = std::make_shared<llvm::BitCodeAbbrev>();
5727 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
5728 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
5729 UpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
5732 WriteDeclContextVisibleUpdate(TU);
5735 if (Context.ExternCContext)
5736 WriteDeclContextVisibleUpdate(Context.ExternCContext);
5739 for (
auto *DC : UpdatedDeclContexts)
5740 WriteDeclContextVisibleUpdate(DC);
5743void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
5744 if (DeclUpdates.empty())
5747 DeclUpdateMap LocalUpdates;
5748 LocalUpdates.swap(DeclUpdates);
5750 for (
auto &DeclUpdate : LocalUpdates) {
5751 const Decl *
D = DeclUpdate.first;
5753 bool HasUpdatedBody =
false;
5754 bool HasAddedVarDefinition =
false;
5757 for (
auto &
Update : DeclUpdate.second) {
5763 HasUpdatedBody =
true;
5765 HasAddedVarDefinition =
true;
5773 assert(
Update.getDecl() &&
"no decl to add?");
5788 cast<ParmVarDecl>(
Update.getDecl())->getDefaultArg());
5793 cast<FieldDecl>(
Update.getDecl())->getInClassInitializer());
5797 auto *RD = cast<CXXRecordDecl>(
D);
5798 UpdatedDeclContexts.insert(RD->getPrimaryContext());
5799 Record.push_back(RD->isParamDestroyedInCallee());
5800 Record.push_back(llvm::to_underlying(RD->getArgPassingRestrictions()));
5801 Record.AddCXXDefinitionData(RD);
5802 Record.AddOffset(WriteDeclContextLexicalBlock(*Context, RD));
5807 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
5808 Record.push_back(MSInfo->getTemplateSpecializationKind());
5809 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
5811 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
5812 Record.push_back(Spec->getTemplateSpecializationKind());
5813 Record.AddSourceLocation(Spec->getPointOfInstantiation());
5817 auto From = Spec->getInstantiatedFrom();
5818 if (
auto PartialSpec =
5821 Record.AddDeclRef(PartialSpec);
5822 Record.AddTemplateArgumentList(
5823 &Spec->getTemplateInstantiationArgs());
5828 Record.push_back(llvm::to_underlying(RD->getTagKind()));
5829 Record.AddSourceLocation(RD->getLocation());
5830 Record.AddSourceLocation(RD->getBeginLoc());
5831 Record.AddSourceRange(RD->getBraceRange());
5844 Record.AddStmt(cast<CXXDestructorDecl>(
D)->getOperatorDeleteThisArg());
5850 Record.writeExceptionSpecInfo(prototype->getExceptionSpecInfo());
5868 D->
getAttr<OMPThreadPrivateDeclAttr>()->getRange());
5872 auto *A =
D->
getAttr<OMPAllocateDeclAttr>();
5873 Record.push_back(A->getAllocatorType());
5874 Record.AddStmt(A->getAllocator());
5875 Record.AddStmt(A->getAlignment());
5876 Record.AddSourceRange(A->getRange());
5881 Record.push_back(
D->
getAttr<OMPDeclareTargetDeclAttr>()->getMapType());
5883 D->
getAttr<OMPDeclareTargetDeclAttr>()->getRange());
5899 if (HasUpdatedBody) {
5900 const auto *Def = cast<FunctionDecl>(
D);
5902 Record.push_back(Def->isInlined());
5903 Record.AddSourceLocation(Def->getInnerLocStart());
5904 Record.AddFunctionDefinition(Def);
5905 }
else if (HasAddedVarDefinition) {
5906 const auto *VD = cast<VarDecl>(
D);
5908 Record.push_back(VD->isInline());
5909 Record.push_back(VD->isInlineSpecified());
5910 Record.AddVarDeclInit(VD);
5927 NonAffectingFileIDs.empty())
5929 auto It = llvm::lower_bound(NonAffectingFileIDs, FID);
5930 unsigned Idx = std::distance(NonAffectingFileIDs.begin(), It);
5931 unsigned Offset = NonAffectingFileIDAdjustments[Idx];
5932 return FileID::get(FID.getOpaqueValue() - Offset);
5935unsigned ASTWriter::getAdjustedNumCreatedFIDs(
FileID FID)
const {
5941 unsigned AdjustedNumCreatedFIDs = 0;
5942 for (
unsigned I = FID.ID, N = I + NumCreatedFIDs; I != N; ++I)
5943 if (IsSLocAffecting[I])
5944 ++AdjustedNumCreatedFIDs;
5945 return AdjustedNumCreatedFIDs;
5961 return Offset - getAdjustment(Offset);
5966 if (NonAffectingRanges.empty())
5972 if (Offset > NonAffectingRanges.back().getEnd().getOffset())
5973 return NonAffectingOffsetAdjustments.back();
5975 if (Offset < NonAffectingRanges.front().getBegin().getOffset())
5982 auto It = llvm::lower_bound(NonAffectingRanges, Offset, Contains);
5983 unsigned Idx = std::distance(NonAffectingRanges.begin(), It);
5984 return NonAffectingOffsetAdjustments[Idx];
5988 Record.push_back(getAdjustedFileID(FID).getOpaqueValue());
5993 unsigned BaseOffset = 0;
5994 unsigned ModuleFileIndex = 0;
6001 SourceManager::MaxLoadedOffset -
Loc.getOffset() - 1);
6002 assert(SLocMapI !=
getChain()->GlobalSLocOffsetMap.end() &&
6003 "Corrupted global sloc offset map");
6008 ModuleFileIndex = F->
Index + 1;
6017 Loc = getAdjustedLocation(
Loc);
6055 MacroInfoToEmitData Info = { Name, MI, ID };
6056 MacroInfosToEmit.push_back(Info);
6065 assert(MacroIDs.contains(MI) &&
"Macro not emitted!");
6066 return MacroIDs[MI];
6070 return IdentMacroDirectivesOffsetMap.lookup(Name);
6074 Record->push_back(Writer->getSelectorRef(SelRef));
6083 if (SID == 0 && Chain) {
6087 SID = SelectorIDs[Sel];
6090 SID = NextSelectorID++;
6091 SelectorIDs[Sel] = SID;
6133 bool InfoHasSameExpr
6135 Record->push_back(InfoHasSameExpr);
6136 if (InfoHasSameExpr)
6154 TypeLocWriter TLW(*
this,
Seq);
6163template <
typename IdxForTypeTy>
6165 IdxForTypeTy IdxForType) {
6169 unsigned FastQuals =
T.getLocalFastQualifiers();
6170 T.removeLocalFastQualifiers();
6172 if (
T.hasLocalNonFastQualifiers())
6173 return IdxForType(
T).asTypeID(FastQuals);
6175 assert(!
T.hasLocalQualifiers());
6177 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(
T.getTypePtr()))
6185 return IdxForType(
T).asTypeID(FastQuals);
6193 assert(!
T.getLocalFastQualifiers());
6197 if (DoneWritingDeclsAndTypes) {
6198 assert(0 &&
"New type seen after serializing all the types to emit!");
6204 Idx =
TypeIdx(0, NextTypeID++);
6205 DeclTypesToEmit.push(
T);
6223 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
6230 if (
auto *
Iter = DeclUpdatesFromGMF.find(
D);
6231 Iter != DeclUpdatesFromGMF.end()) {
6233 DeclUpdates[
D].push_back(
Update);
6234 DeclUpdatesFromGMF.erase(
Iter);
6246 assert(!(
reinterpret_cast<uintptr_t>(
D) & 0x01) &&
"Invalid decl pointer");
6248 if (ID.isInvalid()) {
6249 if (DoneWritingDeclsAndTypes) {
6250 assert(0 &&
"New decl seen after serializing all the decls to emit!");
6257 DeclTypesToEmit.push(
const_cast<Decl *
>(
D));
6272 assert(DeclIDs.contains(
D) &&
"Declaration not emitted!");
6279 assert(DoneWritingDeclsAndTypes &&
6280 "wasDeclEmitted should only be called after writing declarations");
6285 bool Emitted = DeclIDs.contains(
D);
6287 GeneratingReducedBMI) &&
6288 "The declaration within modules can only be omitted in reduced BMI.");
6293 assert(ID.isValid());
6307 if (isa<ParmVarDecl, TemplateTemplateParmDecl>(
D))
6312 assert(
SM.isLocalSourceLocation(FileLoc));
6315 std::tie(FID, Offset) =
SM.getDecomposedLoc(FileLoc);
6318 assert(
SM.getSLocEntry(FID).isFile());
6319 assert(IsSLocAffecting[FID.ID]);
6321 std::unique_ptr<DeclIDInFileInfo> &Info = FileDeclIDs[FID];
6323 Info = std::make_unique<DeclIDInFileInfo>();
6325 std::pair<unsigned, LocalDeclID> LocDecl(Offset, ID);
6326 LocDeclIDsTy &Decls = Info->DeclIDs;
6327 Decls.push_back(LocDecl);
6332 "expected an anonymous declaration");
6336 auto It = AnonymousDeclarationNumbers.find(
D);
6337 if (It == AnonymousDeclarationNumbers.end()) {
6340 AnonymousDeclarationNumbers[ND] = Number;
6343 It = AnonymousDeclarationNumbers.find(
D);
6344 assert(It != AnonymousDeclarationNumbers.end() &&
6345 "declaration not found within its lexical context");
6353 switch (Name.getNameKind()) {
6400 NestedNames.push_back(NNS);
6404 Record->push_back(NestedNames.size());
6405 while(!NestedNames.empty()) {
6406 NNS = NestedNames.pop_back_val();
6448 assert(TemplateParams &&
"No TemplateParams!");
6454 for (
const auto &
P : *TemplateParams)
6460 Record->push_back(
false);
6467 assert(TemplateArgs &&
"No TemplateArgs!");
6469 for (
int i = 0, e = TemplateArgs->
size(); i != e; ++i)
6475 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
6487 I =
Set.begin(),
E =
Set.end(); I !=
E; ++I) {
6489 Record->push_back(I.getAccess());
6497 Record->push_back(
Base.getAccessSpecifierAsWritten());
6498 Record->push_back(
Base.getInheritConstructors());
6511 for (
auto &
Base : Bases)
6529 for (
auto *
Init : CtorInits) {
6530 if (
Init->isBaseInitializer()) {
6534 }
else if (
Init->isDelegatingInitializer()) {
6537 }
else if (
Init->isMemberInitializer()){
6550 if (
Init->isWritten())
6564 auto &
Data =
D->data();
6570#define FIELD(Name, Width, Merge) \
6571 if (!DefinitionBits.canWriteNextNBits(Width)) { \
6572 Record->push_back(DefinitionBits); \
6573 DefinitionBits.reset(0); \
6575 DefinitionBits.addBits(Data.Name, Width);
6577#include "clang/AST/CXXRecordDeclDefinitionBits.def"
6580 Record->push_back(DefinitionBits);
6584 Record->push_back(
D->getODRHash());
6586 bool ModulesCodegen =
6587 !
D->isDependentType() &&
6588 (Writer->Context->getLangOpts().ModulesDebugInfo ||
6590 Record->push_back(ModulesCodegen);
6592 Writer->AddDeclRef(
D, Writer->ModularCodegenDecls);
6597 Record->push_back(
Data.ComputedVisibleConversions);
6598 if (
Data.ComputedVisibleConversions)
6602 if (!
Data.IsLambda) {
6604 if (
Data.NumBases > 0)
6609 if (
Data.NumVBases > 0)
6614 auto &Lambda =
D->getLambdaData();
6617 LambdaBits.
addBits(Lambda.DependencyKind, 2);
6618 LambdaBits.
addBit(Lambda.IsGenericLambda);
6619 LambdaBits.
addBits(Lambda.CaptureDefault, 2);
6620 LambdaBits.
addBits(Lambda.NumCaptures, 15);
6621 LambdaBits.
addBit(Lambda.HasKnownInternalLinkage);
6622 Record->push_back(LambdaBits);
6624 Record->push_back(Lambda.NumExplicitCaptures);
6625 Record->push_back(Lambda.ManglingNumber);
6626 Record->push_back(
D->getDeviceLambdaManglingNumber());
6630 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
6637 Record->push_back(CaptureBits);
6639 switch (
Capture.getCaptureKind()) {
6666 Val |= (ES->HasConstantInitialization ? 2 : 0);
6667 Val |= (ES->HasConstantDestruction ? 4 : 0);
6681void ASTWriter::ReaderInitialized(
ASTReader *Reader) {
6682 assert(Reader &&
"Cannot remove chain");
6683 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
6684 assert(FirstDeclID == NextDeclID &&
6685 FirstTypeID == NextTypeID &&
6686 FirstIdentID == NextIdentID &&
6687 FirstMacroID == NextMacroID &&
6688 FirstSubmoduleID == NextSubmoduleID &&
6689 FirstSelectorID == NextSelectorID &&
6690 "Setting chain after writing has started.");
6699 NextMacroID = FirstMacroID;
6700 NextSelectorID = FirstSelectorID;
6701 NextSubmoduleID = FirstSubmoduleID;
6711 unsigned OriginalModuleFileIndex = StoredID >> 32;
6715 if (OriginalModuleFileIndex == 0 && StoredID)
6726 MacroID &StoredID = MacroIDs[MI];
6749 if (ModuleFileIndex == 0 && StoredIdx.
getValue())
6761 PredefinedDecls.insert(
D);
6773 assert(!MacroDefinitions.contains(MD));
6774 MacroDefinitions[MD] =
ID;
6778 assert(!SubmoduleIDs.contains(Mod));
6779 SubmoduleIDs[Mod] =
ID;
6782void ASTWriter::CompletedTagDefinition(
const TagDecl *
D) {
6784 assert(
D->isCompleteDefinition());
6785 assert(!WritingAST &&
"Already writing the AST!");
6786 if (
auto *RD = dyn_cast<CXXRecordDecl>(
D)) {
6788 if (RD->isFromASTFile()) {
6793 "completed a tag from another module but not by instantiation?");
6794 DeclUpdates[RD].push_back(
6812 "Should not add lookup results to non-lookup contexts!");
6815 if (isa<TranslationUnitDecl>(DC))
6823 !isa<FunctionTemplateDecl>(
D))
6833 assert(!WritingAST &&
"Already writing the AST!");
6834 if (UpdatedDeclContexts.insert(DC) && !cast<Decl>(DC)->isFromASTFile()) {
6838 llvm::append_range(DeclsToEmitEvenIfUnreferenced, DC->
decls());
6840 DeclsToEmitEvenIfUnreferenced.push_back(
D);
6852 if (!isa<CXXMethodDecl>(
D))
6857 assert(!WritingAST &&
"Already writing the AST!");
6861void ASTWriter::ResolvedExceptionSpec(
const FunctionDecl *FD) {
6863 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
6870 ->castAs<FunctionProtoType>()
6871 ->getExceptionSpecType()))
6878 assert(!WritingAST &&
"Already writing the AST!");
6881 DeclUpdates[
D].push_back(
6890 assert(!WritingAST &&
"Already writing the AST!");
6891 assert(
Delete &&
"Not given an operator delete");
6898void ASTWriter::CompletedImplicitDefinition(
const FunctionDecl *
D) {
6900 assert(!WritingAST &&
"Already writing the AST!");
6908void ASTWriter::VariableDefinitionInstantiated(
const VarDecl *
D) {
6910 assert(!WritingAST &&
"Already writing the AST!");
6917void ASTWriter::FunctionDefinitionInstantiated(
const FunctionDecl *
D) {
6919 assert(!WritingAST &&
"Already writing the AST!");
6926void ASTWriter::InstantiationRequested(
const ValueDecl *
D) {
6928 assert(!WritingAST &&
"Already writing the AST!");
6935 if (
auto *VD = dyn_cast<VarDecl>(
D))
6936 POI = VD->getPointOfInstantiation();
6938 POI = cast<FunctionDecl>(
D)->getPointOfInstantiation();
6942void ASTWriter::DefaultArgumentInstantiated(
const ParmVarDecl *
D) {
6944 assert(!WritingAST &&
"Already writing the AST!");
6948 DeclUpdates[
D].push_back(
6952void ASTWriter::DefaultMemberInitializerInstantiated(
const FieldDecl *
D) {
6953 assert(!WritingAST &&
"Already writing the AST!");
6957 DeclUpdates[
D].push_back(
6964 assert(!WritingAST &&
"Already writing the AST!");
6968 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
6969 ObjCClassesWithCategories.insert(
6973void ASTWriter::DeclarationMarkedUsed(
const Decl *
D) {
6975 assert(!WritingAST &&
"Already writing the AST!");
6987void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(
const Decl *
D) {
6989 assert(!WritingAST &&
"Already writing the AST!");
6996void ASTWriter::DeclarationMarkedOpenMPAllocate(
const Decl *
D,
const Attr *A) {
6998 assert(!WritingAST &&
"Already writing the AST!");
7005void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(
const Decl *
D,
7008 assert(!WritingAST &&
"Already writing the AST!");
7012 DeclUpdates[
D].push_back(
7018 assert(!WritingAST &&
"Already writing the AST!");
7023void ASTWriter::AddedAttributeToRecord(
const Attr *
Attr,
7026 assert(!WritingAST &&
"Already writing the AST!");
7027 if (!
Record->isFromASTFile())
7032void ASTWriter::AddedCXXTemplateSpecialization(
7034 assert(!WritingAST &&
"Already writing the AST!");
7041 DeclsToEmitEvenIfUnreferenced.push_back(
D);
7044void ASTWriter::AddedCXXTemplateSpecialization(
7046 assert(!WritingAST &&
"Already writing the AST!");
7053 DeclsToEmitEvenIfUnreferenced.push_back(
D);
7058 assert(!WritingAST &&
"Already writing the AST!");
7065 DeclsToEmitEvenIfUnreferenced.push_back(
D);
7079#define GEN_CLANG_CLAUSE_CLASS
7080#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
7081#include "llvm/Frontend/OpenMP/OMP.inc"
7090 OMPClauseWriter(*this).writeClause(
C);
7093void OMPClauseWriter::writeClause(
OMPClause *
C) {
7094 Record.push_back(
unsigned(
C->getClauseKind()));
7096 Record.AddSourceLocation(
C->getBeginLoc());
7097 Record.AddSourceLocation(
C->getEndLoc());
7101 Record.push_back(uint64_t(
C->getCaptureRegion()));
7102 Record.AddStmt(
C->getPreInitStmt());
7106 VisitOMPClauseWithPreInit(
C);
7107 Record.AddStmt(
C->getPostUpdateExpr());
7110void OMPClauseWriter::VisitOMPIfClause(
OMPIfClause *
C) {
7111 VisitOMPClauseWithPreInit(
C);
7113 Record.AddSourceLocation(
C->getNameModifierLoc());
7114 Record.AddSourceLocation(
C->getColonLoc());
7115 Record.AddStmt(
C->getCondition());
7116 Record.AddSourceLocation(
C->getLParenLoc());
7120 VisitOMPClauseWithPreInit(
C);
7121 Record.AddStmt(
C->getCondition());
7122 Record.AddSourceLocation(
C->getLParenLoc());
7126 VisitOMPClauseWithPreInit(
C);
7127 Record.AddStmt(
C->getNumThreads());
7128 Record.AddSourceLocation(
C->getLParenLoc());
7132 Record.AddStmt(
C->getSafelen());
7133 Record.AddSourceLocation(
C->getLParenLoc());
7137 Record.AddStmt(
C->getSimdlen());
7138 Record.AddSourceLocation(
C->getLParenLoc());
7142 Record.push_back(
C->getNumSizes());
7143 for (
Expr *Size :
C->getSizesRefs())
7145 Record.AddSourceLocation(
C->getLParenLoc());
7151 Record.AddStmt(
C->getFactor());
7152 Record.AddSourceLocation(
C->getLParenLoc());
7156 Record.AddStmt(
C->getAllocator());
7157 Record.AddSourceLocation(
C->getLParenLoc());
7161 Record.AddStmt(
C->getNumForLoops());
7162 Record.AddSourceLocation(
C->getLParenLoc());
7166 Record.AddStmt(
C->getEventHandler());
7167 Record.AddSourceLocation(
C->getLParenLoc());
7171 Record.push_back(
unsigned(
C->getDefaultKind()));
7172 Record.AddSourceLocation(
C->getLParenLoc());
7173 Record.AddSourceLocation(
C->getDefaultKindKwLoc());
7177 Record.push_back(
unsigned(
C->getProcBindKind()));
7178 Record.AddSourceLocation(
C->getLParenLoc());
7179 Record.AddSourceLocation(
C->getProcBindKindKwLoc());
7183 VisitOMPClauseWithPreInit(
C);
7184 Record.push_back(
C->getScheduleKind());
7185 Record.push_back(
C->getFirstScheduleModifier());
7186 Record.push_back(
C->getSecondScheduleModifier());
7187 Record.AddStmt(
C->getChunkSize());
7188 Record.AddSourceLocation(
C->getLParenLoc());
7189 Record.AddSourceLocation(
C->getFirstScheduleModifierLoc());
7190 Record.AddSourceLocation(
C->getSecondScheduleModifierLoc());
7191 Record.AddSourceLocation(
C->getScheduleKindLoc());
7192 Record.AddSourceLocation(
C->getCommaLoc());
7196 Record.push_back(
C->getLoopNumIterations().size());
7197 Record.AddStmt(
C->getNumForLoops());
7198 for (
Expr *NumIter :
C->getLoopNumIterations())
7200 for (
unsigned I = 0,
E =
C->getLoopNumIterations().size(); I <
E; ++I)
7201 Record.AddStmt(
C->getLoopCounter(I));
7202 Record.AddSourceLocation(
C->getLParenLoc());
7216 Record.push_back(
C->isExtended() ? 1 : 0);
7217 if (
C->isExtended()) {
7218 Record.AddSourceLocation(
C->getLParenLoc());
7219 Record.AddSourceLocation(
C->getArgumentLoc());
7220 Record.writeEnum(
C->getDependencyKind());
7230 Record.AddSourceLocation(
C->getLParenLoc());
7231 Record.AddSourceLocation(
C->getFailParameterLoc());
7232 Record.writeEnum(
C->getFailParameter());
7240 Record.push_back(
static_cast<uint64_t>(
C->getDirectiveKinds().size()));
7241 Record.AddSourceLocation(
C->getLParenLoc());
7242 for (
auto K :
C->getDirectiveKinds()) {
7249 Record.AddSourceLocation(
C->getLParenLoc());
7253 Record.push_back(
static_cast<uint64_t>(
C->getDirectiveKinds().size()));
7254 Record.AddSourceLocation(
C->getLParenLoc());
7255 for (
auto K :
C->getDirectiveKinds()) {
7262void OMPClauseWriter::VisitOMPNoOpenMPRoutinesClause(
7282 Record.push_back(
C->varlist_size());
7283 for (
Expr *VE :
C->varlist())
7285 Record.writeBool(
C->getIsTarget());
7286 Record.writeBool(
C->getIsTargetSync());
7287 Record.AddSourceLocation(
C->getLParenLoc());
7288 Record.AddSourceLocation(
C->getVarLoc());
7292 Record.AddStmt(
C->getInteropVar());
7293 Record.AddSourceLocation(
C->getLParenLoc());
7294 Record.AddSourceLocation(
C->getVarLoc());
7298 Record.AddStmt(
C->getInteropVar());
7299 Record.AddSourceLocation(
C->getLParenLoc());
7300 Record.AddSourceLocation(
C->getVarLoc());
7304 VisitOMPClauseWithPreInit(
C);
7305 Record.AddStmt(
C->getCondition());
7306 Record.AddSourceLocation(
C->getLParenLoc());
7310 VisitOMPClauseWithPreInit(
C);
7311 Record.AddStmt(
C->getCondition());
7312 Record.AddSourceLocation(
C->getLParenLoc());
7316 VisitOMPClauseWithPreInit(
C);
7317 Record.AddStmt(
C->getThreadID());
7318 Record.AddSourceLocation(
C->getLParenLoc());
7322 Record.AddStmt(
C->getAlignment());
7323 Record.AddSourceLocation(
C->getLParenLoc());
7327 Record.push_back(
C->varlist_size());
7328 Record.AddSourceLocation(
C->getLParenLoc());
7329 for (
auto *VE :
C->varlist()) {
7332 for (
auto *VE :
C->private_copies()) {
7338 Record.push_back(
C->varlist_size());
7339 VisitOMPClauseWithPreInit(
C);
7340 Record.AddSourceLocation(
C->getLParenLoc());
7341 for (
auto *VE :
C->varlist()) {
7344 for (
auto *VE :
C->private_copies()) {
7347 for (
auto *VE :
C->inits()) {
7353 Record.push_back(
C->varlist_size());
7354 VisitOMPClauseWithPostUpdate(
C);
7355 Record.AddSourceLocation(
C->getLParenLoc());
7356 Record.writeEnum(
C->getKind());
7357 Record.AddSourceLocation(
C->getKindLoc());
7358 Record.AddSourceLocation(
C->getColonLoc());
7359 for (
auto *VE :
C->varlist())
7361 for (
auto *
E :
C->private_copies())
7363 for (
auto *
E :
C->source_exprs())
7365 for (
auto *
E :
C->destination_exprs())
7367 for (
auto *
E :
C->assignment_ops())
7372 Record.push_back(
C->varlist_size());
7373 Record.AddSourceLocation(
C->getLParenLoc());
7374 for (
auto *VE :
C->varlist())
7379 Record.push_back(
C->varlist_size());
7380 Record.writeEnum(
C->getModifier());
7381 VisitOMPClauseWithPostUpdate(
C);
7382 Record.AddSourceLocation(
C->getLParenLoc());
7383 Record.AddSourceLocation(
C->getModifierLoc());
7384 Record.AddSourceLocation(
C->getColonLoc());
7385 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
7386 Record.AddDeclarationNameInfo(
C->getNameInfo());
7387 for (
auto *VE :
C->varlist())
7389 for (
auto *VE :
C->privates())
7391 for (
auto *
E :
C->lhs_exprs())
7393 for (
auto *
E :
C->rhs_exprs())
7395 for (
auto *
E :
C->reduction_ops())
7397 if (
C->getModifier() == clang::OMPC_REDUCTION_inscan) {
7398 for (
auto *
E :
C->copy_ops())
7400 for (
auto *
E :
C->copy_array_temps())
7402 for (
auto *
E :
C->copy_array_elems())
7408 Record.push_back(
C->varlist_size());
7409 VisitOMPClauseWithPostUpdate(
C);
7410 Record.AddSourceLocation(
C->getLParenLoc());
7411 Record.AddSourceLocation(
C->getColonLoc());
7412 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
7413 Record.AddDeclarationNameInfo(
C->getNameInfo());
7414 for (
auto *VE :
C->varlist())
7416 for (
auto *VE :
C->privates())
7418 for (
auto *
E :
C->lhs_exprs())
7420 for (
auto *
E :
C->rhs_exprs())
7422 for (
auto *
E :
C->reduction_ops())
7427 Record.push_back(
C->varlist_size());
7428 VisitOMPClauseWithPostUpdate(
C);
7429 Record.AddSourceLocation(
C->getLParenLoc());
7430 Record.AddSourceLocation(
C->getColonLoc());
7431 Record.AddNestedNameSpecifierLoc(
C->getQualifierLoc());
7432 Record.AddDeclarationNameInfo(
C->getNameInfo());
7433 for (
auto *VE :
C->varlist())
7435 for (
auto *VE :
C->privates())
7437 for (
auto *
E :
C->lhs_exprs())
7439 for (
auto *
E :
C->rhs_exprs())
7441 for (
auto *
E :
C->reduction_ops())
7443 for (
auto *
E :
C->taskgroup_descriptors())
7448 Record.push_back(
C->varlist_size());
7449 VisitOMPClauseWithPostUpdate(
C);
7450 Record.AddSourceLocation(
C->getLParenLoc());
7451 Record.AddSourceLocation(
C->getColonLoc());
7452 Record.push_back(
C->getModifier());
7453 Record.AddSourceLocation(
C->getModifierLoc());
7454 for (
auto *VE :
C->varlist()) {
7457 for (
auto *VE :
C->privates()) {
7460 for (
auto *VE :
C->inits()) {
7463 for (
auto *VE :
C->updates()) {
7466 for (
auto *VE :
C->finals()) {
7470 Record.AddStmt(
C->getCalcStep());
7471 for (
auto *VE :
C->used_expressions())
7476 Record.push_back(
C->varlist_size());
7477 Record.AddSourceLocation(
C->getLParenLoc());
7478 Record.AddSourceLocation(
C->getColonLoc());
7479 for (
auto *VE :
C->varlist())
7481 Record.AddStmt(
C->getAlignment());
7485 Record.push_back(
C->varlist_size());
7486 Record.AddSourceLocation(
C->getLParenLoc());
7487 for (
auto *VE :
C->varlist())
7489 for (
auto *
E :
C->source_exprs())
7491 for (
auto *
E :
C->destination_exprs())
7493 for (
auto *
E :
C->assignment_ops())
7498 Record.push_back(
C->varlist_size());
7499 Record.AddSourceLocation(
C->getLParenLoc());
7500 for (
auto *VE :
C->varlist())
7502 for (
auto *
E :
C->source_exprs())
7504 for (
auto *
E :
C->destination_exprs())
7506 for (
auto *
E :
C->assignment_ops())
7511 Record.push_back(
C->varlist_size());
7512 Record.AddSourceLocation(
C->getLParenLoc());
7513 for (
auto *VE :
C->varlist())
7518 Record.AddStmt(
C->getDepobj());
7519 Record.AddSourceLocation(
C->getLParenLoc());
7523 Record.push_back(
C->varlist_size());
7524 Record.push_back(
C->getNumLoops());
7525 Record.AddSourceLocation(
C->getLParenLoc());
7526 Record.AddStmt(
C->getModifier());
7527 Record.push_back(
C->getDependencyKind());
7528 Record.AddSourceLocation(
C->getDependencyLoc());
7529 Record.AddSourceLocation(
C->getColonLoc());
7530 Record.AddSourceLocation(
C->getOmpAllMemoryLoc());
7531 for (
auto *VE :
C->varlist())
7533 for (
unsigned I = 0,
E =
C->getNumLoops(); I <
E; ++I)
7534 Record.AddStmt(
C->getLoopData(I));
7538 VisitOMPClauseWithPreInit(
C);
7539 Record.writeEnum(
C->getModifier());
7540 Record.AddStmt(
C->getDevice());
7541 Record.AddSourceLocation(
C->getModifierLoc());
7542 Record.AddSourceLocation(
C->getLParenLoc());
7546 Record.push_back(
C->varlist_size());
7547 Record.push_back(
C->getUniqueDeclarationsNum());
7548 Record.push_back(
C->getTotalComponentListNum());
7549 Record.push_back(
C->getTotalComponentsNum());
7550 Record.AddSourceLocation(
C->getLParenLoc());
7551 bool HasIteratorModifier =
false;
7553 Record.push_back(
C->getMapTypeModifier(I));
7554 Record.AddSourceLocation(
C->getMapTypeModifierLoc(I));
7555 if (
C->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator)
7556 HasIteratorModifier =
true;
7558 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
7559 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
7560 Record.push_back(
C->getMapType());
7561 Record.AddSourceLocation(
C->getMapLoc());
7562 Record.AddSourceLocation(
C->getColonLoc());
7563 for (
auto *
E :
C->varlist())
7565 for (
auto *
E :
C->mapperlists())
7567 if (HasIteratorModifier)
7568 Record.AddStmt(
C->getIteratorModifier());
7569 for (
auto *
D :
C->all_decls())
7571 for (
auto N :
C->all_num_lists())
7573 for (
auto N :
C->all_lists_sizes())
7575 for (
auto &M :
C->all_components()) {
7576 Record.AddStmt(M.getAssociatedExpression());
7577 Record.AddDeclRef(M.getAssociatedDeclaration());
7582 Record.push_back(
C->varlist_size());
7583 Record.AddSourceLocation(
C->getLParenLoc());
7584 Record.AddSourceLocation(
C->getColonLoc());
7585 Record.AddStmt(
C->getAllocator());
7586 for (
auto *VE :
C->varlist())
7591 Record.push_back(
C->varlist_size());
7592 VisitOMPClauseWithPreInit(
C);
7593 Record.AddSourceLocation(
C->getLParenLoc());
7594 for (
auto *VE :
C->varlist())
7599 Record.push_back(
C->varlist_size());
7600 VisitOMPClauseWithPreInit(
C);
7601 Record.AddSourceLocation(
C->getLParenLoc());
7602 for (
auto *VE :
C->varlist())
7607 VisitOMPClauseWithPreInit(
C);
7608 Record.AddStmt(
C->getPriority());
7609 Record.AddSourceLocation(
C->getLParenLoc());
7613 VisitOMPClauseWithPreInit(
C);
7614 Record.writeEnum(
C->getModifier());
7615 Record.AddStmt(
C->getGrainsize());
7616 Record.AddSourceLocation(
C->getModifierLoc());
7617 Record.AddSourceLocation(
C->getLParenLoc());
7621 VisitOMPClauseWithPreInit(
C);
7622 Record.writeEnum(
C->getModifier());
7623 Record.AddStmt(
C->getNumTasks());
7624 Record.AddSourceLocation(
C->getModifierLoc());
7625 Record.AddSourceLocation(
C->getLParenLoc());
7630 Record.AddSourceLocation(
C->getLParenLoc());
7634 VisitOMPClauseWithPreInit(
C);
7635 Record.push_back(
C->getDistScheduleKind());
7636 Record.AddStmt(
C->getChunkSize());
7637 Record.AddSourceLocation(
C->getLParenLoc());
7638 Record.AddSourceLocation(
C->getDistScheduleKindLoc());
7639 Record.AddSourceLocation(
C->getCommaLoc());
7643 Record.push_back(
C->getDefaultmapKind());
7644 Record.push_back(
C->getDefaultmapModifier());
7645 Record.AddSourceLocation(
C->getLParenLoc());
7646 Record.AddSourceLocation(
C->getDefaultmapModifierLoc());
7647 Record.AddSourceLocation(
C->getDefaultmapKindLoc());
7650void OMPClauseWriter::VisitOMPToClause(
OMPToClause *
C) {
7651 Record.push_back(
C->varlist_size());
7652 Record.push_back(
C->getUniqueDeclarationsNum());
7653 Record.push_back(
C->getTotalComponentListNum());
7654 Record.push_back(
C->getTotalComponentsNum());
7655 Record.AddSourceLocation(
C->getLParenLoc());
7657 Record.push_back(
C->getMotionModifier(I));
7658 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
7660 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
7661 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
7662 Record.AddSourceLocation(
C->getColonLoc());
7663 for (
auto *
E :
C->varlist())
7665 for (
auto *
E :
C->mapperlists())
7667 for (
auto *
D :
C->all_decls())
7669 for (
auto N :
C->all_num_lists())
7671 for (
auto N :
C->all_lists_sizes())
7673 for (
auto &M :
C->all_components()) {
7674 Record.AddStmt(M.getAssociatedExpression());
7675 Record.writeBool(M.isNonContiguous());
7676 Record.AddDeclRef(M.getAssociatedDeclaration());
7681 Record.push_back(
C->varlist_size());
7682 Record.push_back(
C->getUniqueDeclarationsNum());
7683 Record.push_back(
C->getTotalComponentListNum());
7684 Record.push_back(
C->getTotalComponentsNum());
7685 Record.AddSourceLocation(
C->getLParenLoc());
7687 Record.push_back(
C->getMotionModifier(I));
7688 Record.AddSourceLocation(
C->getMotionModifierLoc(I));
7690 Record.AddNestedNameSpecifierLoc(
C->getMapperQualifierLoc());
7691 Record.AddDeclarationNameInfo(
C->getMapperIdInfo());
7692 Record.AddSourceLocation(
C->getColonLoc());
7693 for (
auto *
E :
C->varlist())
7695 for (
auto *
E :
C->mapperlists())
7697 for (
auto *
D :
C->all_decls())
7699 for (
auto N :
C->all_num_lists())
7701 for (
auto N :
C->all_lists_sizes())
7703 for (
auto &M :
C->all_components()) {
7704 Record.AddStmt(M.getAssociatedExpression());
7705 Record.writeBool(M.isNonContiguous());
7706 Record.AddDeclRef(M.getAssociatedDeclaration());
7711 Record.push_back(
C->varlist_size());
7712 Record.push_back(
C->getUniqueDeclarationsNum());
7713 Record.push_back(
C->getTotalComponentListNum());
7714 Record.push_back(
C->getTotalComponentsNum());
7715 Record.AddSourceLocation(
C->getLParenLoc());
7716 for (
auto *
E :
C->varlist())
7718 for (
auto *VE :
C->private_copies())
7720 for (
auto *VE :
C->inits())
7722 for (
auto *
D :
C->all_decls())
7724 for (
auto N :
C->all_num_lists())
7726 for (
auto N :
C->all_lists_sizes())
7728 for (
auto &M :
C->all_components()) {
7729 Record.AddStmt(M.getAssociatedExpression());
7730 Record.AddDeclRef(M.getAssociatedDeclaration());
7735 Record.push_back(
C->varlist_size());
7736 Record.push_back(
C->getUniqueDeclarationsNum());
7737 Record.push_back(
C->getTotalComponentListNum());
7738 Record.push_back(
C->getTotalComponentsNum());
7739 Record.AddSourceLocation(
C->getLParenLoc());
7740 for (
auto *
E :
C->varlist())
7742 for (
auto *
D :
C->all_decls())
7744 for (
auto N :
C->all_num_lists())
7746 for (
auto N :
C->all_lists_sizes())
7748 for (
auto &M :
C->all_components()) {
7749 Record.AddStmt(M.getAssociatedExpression());
7750 Record.AddDeclRef(M.getAssociatedDeclaration());
7755 Record.push_back(
C->varlist_size());
7756 Record.push_back(
C->getUniqueDeclarationsNum());
7757 Record.push_back(
C->getTotalComponentListNum());
7758 Record.push_back(
C->getTotalComponentsNum());
7759 Record.AddSourceLocation(
C->getLParenLoc());
7760 for (
auto *
E :
C->varlist())
7762 for (
auto *
D :
C->all_decls())
7764 for (
auto N :
C->all_num_lists())
7766 for (
auto N :
C->all_lists_sizes())
7768 for (
auto &M :
C->all_components()) {
7769 Record.AddStmt(M.getAssociatedExpression());
7770 Record.AddDeclRef(M.getAssociatedDeclaration());
7775 Record.push_back(
C->varlist_size());
7776 Record.push_back(
C->getUniqueDeclarationsNum());
7777 Record.push_back(
C->getTotalComponentListNum());
7778 Record.push_back(
C->getTotalComponentsNum());
7779 Record.AddSourceLocation(
C->getLParenLoc());
7780 for (
auto *
E :
C->varlist())
7782 for (
auto *
D :
C->all_decls())
7784 for (
auto N :
C->all_num_lists())
7786 for (
auto N :
C->all_lists_sizes())
7788 for (
auto &M :
C->all_components()) {
7789 Record.AddStmt(M.getAssociatedExpression());
7790 Record.AddDeclRef(M.getAssociatedDeclaration());
7796void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
7805void OMPClauseWriter::VisitOMPAtomicDefaultMemOrderClause(
7807 Record.push_back(
C->getAtomicDefaultMemOrderKind());
7808 Record.AddSourceLocation(
C->getLParenLoc());
7809 Record.AddSourceLocation(
C->getAtomicDefaultMemOrderKindKwLoc());
7812void OMPClauseWriter::VisitOMPAtClause(
OMPAtClause *
C) {
7813 Record.push_back(
C->getAtKind());
7814 Record.AddSourceLocation(
C->getLParenLoc());
7815 Record.AddSourceLocation(
C->getAtKindKwLoc());
7819 Record.push_back(
C->getSeverityKind());
7820 Record.AddSourceLocation(
C->getLParenLoc());
7821 Record.AddSourceLocation(
C->getSeverityKindKwLoc());
7825 Record.AddStmt(
C->getMessageString());
7826 Record.AddSourceLocation(
C->getLParenLoc());
7830 Record.push_back(
C->varlist_size());
7831 Record.AddSourceLocation(
C->getLParenLoc());
7832 for (
auto *VE :
C->varlist())
7834 for (
auto *
E :
C->private_refs())
7839 Record.push_back(
C->varlist_size());
7840 Record.AddSourceLocation(
C->getLParenLoc());
7841 for (
auto *VE :
C->varlist())
7846 Record.push_back(
C->varlist_size());
7847 Record.AddSourceLocation(
C->getLParenLoc());
7848 for (
auto *VE :
C->varlist())
7853 Record.writeEnum(
C->getKind());
7854 Record.writeEnum(
C->getModifier());
7855 Record.AddSourceLocation(
C->getLParenLoc());
7856 Record.AddSourceLocation(
C->getKindKwLoc());
7857 Record.AddSourceLocation(
C->getModifierKwLoc());
7861 Record.push_back(
C->getNumberOfAllocators());
7862 Record.AddSourceLocation(
C->getLParenLoc());
7863 for (
unsigned I = 0,
E =
C->getNumberOfAllocators(); I <
E; ++I) {
7873 Record.push_back(
C->varlist_size());
7874 Record.AddSourceLocation(
C->getLParenLoc());
7875 Record.AddStmt(
C->getModifier());
7876 Record.AddSourceLocation(
C->getColonLoc());
7877 for (
Expr *
E :
C->varlist())
7882 Record.writeEnum(
C->getBindKind());
7883 Record.AddSourceLocation(
C->getLParenLoc());
7884 Record.AddSourceLocation(
C->getBindKindLoc());
7888 VisitOMPClauseWithPreInit(
C);
7890 Record.AddSourceLocation(
C->getLParenLoc());
7894 Record.push_back(
C->varlist_size());
7895 Record.push_back(
C->getNumLoops());
7896 Record.AddSourceLocation(
C->getLParenLoc());
7897 Record.push_back(
C->getDependenceType());
7898 Record.AddSourceLocation(
C->getDependenceLoc());
7899 Record.AddSourceLocation(
C->getColonLoc());
7900 for (
auto *VE :
C->varlist())
7902 for (
unsigned I = 0,
E =
C->getNumLoops(); I <
E; ++I)
7903 Record.AddStmt(
C->getLoopData(I));
7907 Record.AddAttributes(
C->getAttrs());
7908 Record.AddSourceLocation(
C->getBeginLoc());
7909 Record.AddSourceLocation(
C->getLParenLoc());
7910 Record.AddSourceLocation(
C->getEndLoc());
7917 for (
const auto &
Set : TI->
Sets) {
7924 writeExprRef(
Selector.ScoreOrCondition);
7938 for (
unsigned I = 0,
E =
Data->getNumClauses(); I <
E; ++I)
7940 if (
Data->hasAssociatedStmt())
7942 for (
unsigned I = 0,
E =
Data->getNumChildren(); I <
E; ++I)
7948 for (
Expr *
E :
C->getVarList())
7954 for (
Expr *
E : Exprs)
7963 switch (
C->getClauseKind()) {
7965 const auto *DC = cast<OpenACCDefaultClause>(
C);
7971 const auto *IC = cast<OpenACCIfClause>(
C);
7973 AddStmt(
const_cast<Expr*
>(IC->getConditionExpr()));
7977 const auto *SC = cast<OpenACCSelfClause>(
C);
7980 if (SC->hasConditionExpr())
7981 AddStmt(
const_cast<Expr*
>(SC->getConditionExpr()));
7985 const auto *NGC = cast<OpenACCNumGangsClause>(
C);
7988 for (
Expr *
E : NGC->getIntExprs())
7993 const auto *NWC = cast<OpenACCNumWorkersClause>(
C);
7999 const auto *NWC = cast<OpenACCVectorLengthClause>(
C);
8005 const auto *PC = cast<OpenACCPrivateClause>(
C);
8011 const auto *FPC = cast<OpenACCFirstPrivateClause>(
C);
8017 const auto *AC = cast<OpenACCAttachClause>(
C);
8023 const auto *DPC = cast<OpenACCDevicePtrClause>(
C);
8029 const auto *NCC = cast<OpenACCNoCreateClause>(
C);
8035 const auto *PC = cast<OpenACCPresentClause>(
C);
8043 const auto *CC = cast<OpenACCCopyClause>(
C);
8051 const auto *CIC = cast<OpenACCCopyInClause>(
C);
8060 const auto *COC = cast<OpenACCCopyOutClause>(
C);
8069 const auto *CC = cast<OpenACCCreateClause>(
C);
8076 const auto *AC = cast<OpenACCAsyncClause>(
C);
8079 if (AC->hasIntExpr())
8084 const auto *WC = cast<OpenACCWaitClause>(
C);
8087 if (
Expr *DNE = WC->getDevNumExpr())
8096 const auto *DTC = cast<OpenACCDeviceTypeClause>(
C);
8108 const auto *RC = cast<OpenACCReductionClause>(
C);
8140 llvm_unreachable(
"Clause serialization not yet implemented");
8142 llvm_unreachable(
"Invalid Clause Kind");
Defines the clang::ASTContext interface.
static bool isInterestingIdentifier(ASTReader &Reader, const IdentifierInfo &II, bool IsModule)
Whether the given identifier is "interesting".
static NamedDecl * getDeclForLocalLookup(const LangOptions &LangOpts, NamedDecl *D)
Determine the declaration that should be put into the name lookup table to represent the given declar...
static unsigned CreateSLocBufferAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a buffer.
static bool isLookupResultNotInteresting(ASTWriter &Writer, StoredDeclsList &Result)
Returns ture if all of the lookup result are either external, not emitted or predefined.
static void AddLazyVectorDecls(ASTWriter &Writer, Vector &Vec)
static bool IsInternalDeclFromFileContext(const Decl *D)
static TypeID MakeTypeID(ASTContext &Context, QualType T, IdxForTypeTy IdxForType)
static void AddLazyVectorEmiitedDecls(ASTWriter &Writer, Vector &Vec, ASTWriter::RecordData &Record)
static 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 void BackpatchSignatureAt(llvm::BitstreamWriter &Stream, const ASTFileSignature &S, uint64_t BitNo)
static const char * adjustFilenameForRelocatableAST(const char *Filename, StringRef BaseDir)
Adjusts the given filename to only write out the portion of the filename that is not part of the syst...
static bool isLocalIdentifierID(IdentifierID ID)
If the.
static unsigned getNumberOfModules(Module *Mod)
Compute the number of modules within the given tree (including the given module).
static bool isImportedDeclContext(ASTReader *Chain, const Decl *D)
static TypeCode getTypeCodeForTypeClass(Type::TypeClass id)
static void AddStmtsExprs(llvm::BitstreamWriter &Stream, ASTWriter::RecordDataImpl &Record)
static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob, unsigned SLocBufferBlobCompressedAbbrv, unsigned SLocBufferBlobAbbrv)
static uint64_t EmitCXXBaseSpecifiers(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.
This file declares semantic analysis for Objective-C.
static void EmitBlockID(unsigned ID, const char *Name, llvm::BitstreamWriter &Stream, RecordDataImpl &Record)
Emits a block ID in the BLOCKINFO block.
static void EmitRecordID(unsigned ID, const char *Name, llvm::BitstreamWriter &Stream, RecordDataImpl &Record)
Emits a record ID in the BLOCKINFO block.
Defines the clang::SourceLocation class and associated facilities.
Defines implementation details of the clang::SourceManager class.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TargetOptions class.
#define BLOCK(DERIVED, BASE)
C Language Family Type Representation.
Defines version macros and version-related utility functions for Clang.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
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.
QualType AutoRRefDeductTy
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.
void forEachImportedKeyDecl(const Decl *D, Fn Visit)
Run a callback on each imported key declaration of D.
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
Decl * getKeyDeclaration(Decl *D)
Returns the first key declaration for the given declaration.
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
bool isProcessingUpdateRecords()
unsigned getTotalNumMacros() const
Returns the number of macros found in the chain.
An object for streaming information to a record.
void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
void AddCXXBaseSpecifiers(ArrayRef< CXXBaseSpecifier > Bases)
Emit a set of C++ base specifiers.
void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs)
Emit a template argument list.
uint64_t Emit(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, followed by its substatements, and return its offset.
void AddCXXTemporary(const CXXTemporary *Temp)
Emit a CXXTemporary.
void writeOMPTraitInfo(const OMPTraitInfo *TI)
Write an OMPTraitInfo object.
void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Emit a C++ base specifier.
void writeOMPClause(OMPClause *C)
void writeBool(bool Value)
void AddAPValue(const APValue &Value)
Emit an APvalue.
void AddUnresolvedSet(const ASTUnresolvedSet &Set)
Emit a UnresolvedSet structure.
void AddIdentifierRef(const IdentifierInfo *II)
Emit a reference to an identifier.
void AddStmt(Stmt *S)
Add the given statement or expression to the queue of statements to emit.
void AddDeclarationName(DeclarationName Name)
Emit a declaration name.
void AddSelectorRef(Selector S)
Emit a Selector (which is a smart pointer reference).
void AddSourceRange(SourceRange Range, LocSeq *Seq=nullptr)
Emit a source range.
void writeSourceLocation(SourceLocation Loc)
void AddOffset(uint64_t BitOffset)
Add a bit offset into the record.
void AddTypeRef(QualType T)
Emit a reference to a type.
void writeQualType(QualType T)
void writeOpenACCClauseList(ArrayRef< const OpenACCClause * > Clauses)
Writes out a list of OpenACC clauses.
void AddSourceLocation(SourceLocation Loc, LocSeq *Seq=nullptr)
Emit a source location.
void push_back(uint64_t N)
Minimal vector-like interface.
void AddTypeLoc(TypeLoc TL, LocSeq *Seq=nullptr)
Emits source location information for a type. Does not emit the type.
void AddCXXCtorInitializers(ArrayRef< CXXCtorInitializer * > CtorInits)
Emit a CXXCtorInitializer array.
void AddTemplateParameterList(const TemplateParameterList *TemplateParams)
Emit a template parameter list.
void AddTemplateArgument(const TemplateArgument &Arg)
Emit a template argument.
void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc, DeclarationName Name)
void writeOpenACCIntExprList(ArrayRef< Expr * > Exprs)
void AddAPFloat(const llvm::APFloat &Value)
Emit a floating-point value.
void AddTypeSourceInfo(TypeSourceInfo *TInfo)
Emits a reference to a declarator info.
void AddQualifierInfo(const QualifierInfo &Info)
void writeUInt32(uint32_t Value)
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
void writeOMPChildren(OMPChildren *Data)
Writes data related to the OpenMP directives.
void AddConceptReference(const ConceptReference *CR)
void AddAPInt(const llvm::APInt &Value)
Emit an integral value.
void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, const TemplateArgumentLocInfo &Arg)
Emits a template argument location info.
void writeOpenACCVarList(const OpenACCClauseWithVarList *C)
void AddAttributes(ArrayRef< const Attr * > Attrs)
Emit a list of attributes.
void AddASTTemplateArgumentListInfo(const ASTTemplateArgumentListInfo *ASTTemplArgList)
Emits an AST template argument list info.
void AddCXXDefinitionData(const CXXRecordDecl *D)
void AddVarDeclInit(const VarDecl *VD)
Emit information about the initializer of a VarDecl.
void writeStmtRef(const Stmt *S)
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg)
Emits a template argument location.
void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Emit a nested name specifier with source-location information.
void writeOpenACCClause(const OpenACCClause *C)
Writes out a single OpenACC Clause.
void AddAttr(const Attr *A)
An UnresolvedSet-like class which uses the ASTContext's allocator.
Writes an AST file containing the contents of a translation unit.
serialization::MacroID getMacroID(MacroInfo *MI)
Determine the ID of an already-emitted macro.
ASTFileSignature WriteAST(Sema &SemaRef, StringRef OutputFile, Module *WritingModule, StringRef isysroot, bool ShouldCacheASTInMemory=false)
Write a precompiled header for the given semantic analysis.
void AddEmittedDeclRef(const Decl *D, RecordDataImpl &Record)
void AddSourceRange(SourceRange Range, RecordDataImpl &Record, LocSeq *Seq=nullptr)
Emit a source range.
bool isWritingStdCXXNamedModules() const
void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record, StringRef Path)
Emit the current record with the given path as a blob.
void AddFileID(FileID FID, RecordDataImpl &Record)
Emit a FileID.
bool isDeclPredefined(const Decl *D) const
void AddPath(StringRef Path, RecordDataImpl &Record)
Add a path to the given record.
unsigned getTypeExtQualAbbrev() const
void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record)
Add a version tuple to the given record.
bool isGeneratingReducedBMI() const
uint32_t getMacroDirectivesOffset(const IdentifierInfo *Name)
void AddAlignPackInfo(const Sema::AlignPackInfo &Info, RecordDataImpl &Record)
Emit a AlignPackInfo.
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.
bool isWritingModule() const
LocalDeclID GetDeclRef(const Decl *D)
Force a declaration to be emitted and get its local ID to the module file been writing.
LocalDeclID getDeclID(const Decl *D)
Determine the local declaration ID of an already-emitted declaration.
void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record)
Emit a reference to an identifier.
serialization::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
serialization::IdentifierID getIdentifierRef(const IdentifierInfo *II)
Get the unique number used to refer to the given identifier.
void handleVTable(CXXRecordDecl *RD)
unsigned getLocalOrImportedSubmoduleID(const Module *Mod)
Retrieve or create a submodule ID for this module, or return 0 if the submodule is neither local (a s...
void AddToken(const Token &Tok, RecordDataImpl &Record)
Emit a token.
serialization::SelectorID getSelectorRef(Selector Sel)
Get the unique number used to refer to the given selector.
SourceLocationEncoding::RawLocEncoding getRawSourceLocationEncoding(SourceLocation Loc, LocSeq *Seq=nullptr)
Return the raw encodings for source locations.
ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl< char > &Buffer, InMemoryModuleCache &ModuleCache, ArrayRef< std::shared_ptr< ModuleFileExtension > > Extensions, bool IncludeTimestamps=true, bool BuildingImplicitModule=false, bool GeneratingReducedBMI=false)
Create a new precompiled header writer that outputs to the given bitstream.
SmallVector< uint64_t, 64 > RecordData
unsigned getAnonymousDeclarationNumber(const NamedDecl *D)
const LangOptions & getLangOpts() const
void SetSelectorOffset(Selector Sel, uint32_t Offset)
Note that the selector Sel occurs at the given offset within the method pool/selector table.
bool PreparePathForOutput(SmallVectorImpl< char > &Path)
Convert a path from this build process into one that is appropriate for emission in the module file.
void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset)
Note that the identifier II occurs at the given offset within the identifier table.
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
Wrapper for source info for array parameter types.
Wrapper for source info for arrays.
SourceLocation getLBracketLoc() const
Expr * getSizeExpr() const
SourceLocation getRBracketLoc() const
SourceLocation getRParenLoc() const
SourceLocation getKWLoc() const
SourceLocation getLParenLoc() const
Attr - This represents one attribute.
attr::Kind getKind() const
SourceLocation getScopeLoc() const
SourceRange getRange() const
const IdentifierInfo * getScopeName() const
bool isRegularKeywordAttribute() const
const IdentifierInfo * getAttrName() const
Kind getParsedKind() const
Type source information for an attributed type.
const Attr * getAttr() const
The type attribute.
SourceLocation getRParenLoc() const
bool isDecltypeAuto() const
bool isConstrained() const
ConceptReference * getConceptReference() const
Type source information for an btf_tag attributed type.
A simple helper class to pack several bits in order into (a) 32 bit integer(s).
void addBits(uint32_t Value, uint32_t BitsWidth)
Wrapper for source info for block pointers.
SourceLocation getCaretLoc() const
Wrapper for source info for builtin types.
SourceLocation getBuiltinLoc() const
TypeSpecifierType getWrittenTypeSpec() const
TypeSpecifierWidth getWrittenWidthSpec() const
bool needsExtraLocalData() const
TypeSpecifierSign getWrittenSignSpec() const
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
Represents a C++ destructor within a class.
Represents a C++ struct/union/class.
Represents a C++ temporary.
const CXXDestructorDecl * getDestructor() const
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
A reference to a concept and its template args, as it appears in the code.
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
NamedDecl * getFoundDecl() const
const DeclarationNameInfo & getConceptNameInfo() const
ConceptDecl * getNamedConcept() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
SourceLocation getTemplateKWLoc() const
Wrapper for source info for pointers decayed from arrays and functions.
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isFileContext() const
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isLookupContext() const
Test whether the context supports looking up names.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
StoredDeclsMap * buildLookup()
Ensure the lookup structure is fully-built and return it.
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
StoredDeclsMap * getLookupPtr() const
Retrieve the internal representation of the lookup structure.
DeclID getRawValue() const
A helper iterator adaptor to convert the iterators to SmallVector<SomeDeclID> to the iterators to Sma...
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool isInNamedModule() const
Whether this declaration comes from a named module.
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
@ FOK_None
Not a friend object.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
bool 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.
GlobalDeclID getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
DeclarationNameLoc - Additional source/type location info for a declaration name.
SourceLocation getCXXLiteralOperatorNameLoc() const
Return the location of the literal operator name (without the operator keyword).
TypeSourceInfo * getNamedTypeInfo() const
Returns the source type info.
SourceRange getCXXOperatorNameRange() const
Return the range of the operator name (without the operator keyword).
The name of a declaration.
@ CXXConversionFunctionName
SourceLocation getDecltypeLoc() const
SourceLocation getRParenLoc() const
SourceLocation getTemplateNameLoc() const
Expr * getAttrExprOperand() const
The attribute's expression operand, if it has one.
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
NestedNameSpecifierLoc getQualifierLoc() const
SourceLocation getNameLoc() const
SourceLocation getElaboratedKeywordLoc() const
SourceLocation getNameLoc() const
unsigned getNumArgs() const
SourceLocation getTemplateNameLoc() const
SourceLocation getLAngleLoc() const
SourceLocation getTemplateKeywordLoc() const
TemplateArgumentLoc getArgLoc(unsigned i) const
SourceLocation getRAngleLoc() const
SourceLocation getElaboratedKeywordLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
SourceLocation getNameLoc() const
static DiagnosticMapping getDefaultMapping(unsigned DiagID)
Get the default mapping for this diagnostic.
Options for controlling the compiler diagnostics engine.
std::vector< std::string > Remarks
The list of -R... options used to alter the diagnostic mappings, with the prefixes removed.
std::vector< std::string > Warnings
The list of -W... options used to alter the diagnostic mappings, with the prefixes removed.
Concrete class used by the front-end to report problems and issues.
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).
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.
OptionalFileEntryRef getContainingModuleMapFile(const Module *Module) const
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...
OptionalFileEntryRef getModuleMapFileForUniquing(const Module *M) const
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.
bool isNamedModule() const
Does this Module is a named module of a standard named module?
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
std::vector< Conflict > Conflicts
The list of conflicts.
This represents a decl that may have a name.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
SourceRange getLocalSourceRange() const
Retrieve the source range covering just the last part of this nested-name-specifier,...
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
SpecifierKind
The kind of specifier that completes this nested name specifier.
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
@ TypeSpec
A type, stored as a Type*.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Identifier
An identifier, stored as an IdentifierInfo*.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace, stored as a NamespaceDecl*.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
This represents the 'absent' clause in the '#pragma omp assume' directive.
This represents 'acq_rel' clause in the '#pragma omp atomic|flush' directives.
This represents 'acquire' clause in the '#pragma omp atomic|flush' directives.
This represents clause 'affinity' in the '#pragma omp task'-based directives.
This represents the 'align' clause in the '#pragma omp allocate' directive.
This represents clause 'aligned' in the '#pragma omp ...' directives.
This represents clause 'allocate' in the '#pragma omp ...' directives.
This represents 'allocator' clause in the '#pragma omp ...' directive.
This represents 'at' clause in the '#pragma omp error' directive.
This represents 'atomic_default_mem_order' clause in the '#pragma omp requires' directive.
This represents 'bind' clause in the '#pragma omp ...' directives.
This represents 'capture' clause in the '#pragma omp atomic' directive.
Contains data for OpenMP directives: clauses, children expressions/statements (helpers for codegen) a...
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc.
Class that handles pre-initialization statement for some clauses, like 'schedule',...
This is a basic class for representing single OpenMP clause.
This represents 'collapse' clause in the '#pragma omp ...' directive.
This represents 'compare' clause in the '#pragma omp atomic' directive.
This represents the 'contains' clause in the '#pragma omp assume' directive.
This represents clause 'copyin' in the '#pragma omp ...' directives.
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
This represents 'default' clause in the '#pragma omp ...' directive.
This represents 'defaultmap' clause in the '#pragma omp ...' directive.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
This represents implicit clause 'depobj' for the '#pragma omp depobj' directive.
This represents 'destroy' clause in the '#pragma omp depobj' directive or the '#pragma omp interop' d...
This represents 'detach' clause in the '#pragma omp task' directive.
This represents 'device' clause in the '#pragma omp ...' directive.
This represents 'dist_schedule' clause in the '#pragma omp ...' directive.
This represents the 'doacross' clause for the '#pragma omp ordered' directive.
This represents 'dynamic_allocators' clause in the '#pragma omp requires' directive.
This represents clause 'exclusive' in the '#pragma omp scan' directive.
This represents 'fail' clause in the '#pragma omp atomic' directive.
This represents 'filter' clause in the '#pragma omp ...' directive.
This represents 'final' clause in the '#pragma omp ...' directive.
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
This represents implicit clause 'flush' for the '#pragma omp flush' directive.
This represents clause 'from' in the '#pragma omp ...' directives.
Representation of the 'full' clause of the '#pragma omp unroll' directive.
This represents 'grainsize' clause in the '#pragma omp ...' directive.
This represents clause 'has_device_ptr' in the '#pragma omp ...' directives.
This represents 'hint' clause in the '#pragma omp ...' directive.
This represents the 'holds' clause in the '#pragma omp assume' directive.
This represents 'if' clause in the '#pragma omp ...' directive.
This represents clause 'in_reduction' in the '#pragma omp task' directives.
This represents clause 'inclusive' in the '#pragma omp scan' directive.
This represents the 'init' clause in '#pragma omp ...' directives.
This represents clause 'is_device_ptr' in the '#pragma omp ...' directives.
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
This represents clause 'linear' in the '#pragma omp ...' directives.
This represents clause 'map' in the '#pragma omp ...' directives.
This represents 'mergeable' clause in the '#pragma omp ...' directive.
This represents 'message' clause in the '#pragma omp error' directive.
This represents the 'no_openmp' clause in the '#pragma omp assume' directive.
This represents the 'no_openmp_routines' clause in the '#pragma omp assume' directive.
This represents the 'no_parallelism' clause in the '#pragma omp assume' directive.
This represents 'nocontext' clause in the '#pragma omp ...' directive.
This represents 'nogroup' clause in the '#pragma omp ...' directive.
This represents clause 'nontemporal' in the '#pragma omp ...' directives.
This represents 'novariants' clause in the '#pragma omp ...' directive.
This represents 'nowait' clause in the '#pragma omp ...' directive.
This represents 'num_tasks' clause in the '#pragma omp ...' directive.
This represents 'num_teams' clause in the '#pragma omp ...' directive.
This represents 'num_threads' clause in the '#pragma omp ...' directive.
This represents 'order' clause in the '#pragma omp ...' directive.
This represents 'ordered' clause in the '#pragma omp ...' directive.
Representation of the 'partial' clause of the '#pragma omp unroll' directive.
This 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
Represents a clause with one or more 'var' objects, represented as an expr, as its arguments.
This is the base type for all OpenACC Clauses.
OpenCL supported extensions and optional core features.
SourceLocation getEllipsisLoc() const
SourceLocation getEllipsisLoc() const
SourceLocation getRParenLoc() const
SourceLocation getLParenLoc() const
Represents a parameter to a function.
SourceLocation getKWLoc() const
Wrapper for source info for pointers.
SourceLocation getStarLoc() const
Iteration over the preprocessed entities.
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
MacroDefinitionRecord * findMacroDefinition(const MacroInfo *MI)
Retrieve the macro definition that corresponds to the given MacroInfo.
const std::vector< SourceRange > & getSkippedRanges()
Retrieve all ranges that got skipped while preprocessing.
iterator local_begin()
Begin iterator for local, non-loaded, preprocessed entities.
iterator local_end()
End iterator for local, non-loaded, preprocessed entities.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
std::vector< std::string > MacroIncludes
std::vector< std::string > Includes
bool WriteCommentListToPCH
Whether to write comment locations into the PCH when building it.
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
bool DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
std::vector< std::pair< std::string, bool > > Macros
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
ArrayRef< ModuleMacro * > getLeafModuleMacros(const IdentifierInfo *II) const
Get the list of leaf (non-overridden) module macros for a name.
ArrayRef< PPConditionalInfo > getPreambleConditionalStack() const
SourceLocation getModuleImportLoc(Module *M) const
bool isRecordingPreamble() const
MacroDirective * getLocalMacroDirectiveHistory(const IdentifierInfo *II) const
Given an identifier, return the latest non-imported macro directive for that identifier.
bool SawDateOrTime() const
Returns true if the preprocessor has seen a use of DATE or TIME in the file so far.
unsigned getCounterValue() const
SourceManager & getSourceManager() const
std::optional< PreambleSkipInfo > getPreambleSkipInfo() const
bool hasRecordedPreamble() const
FileManager & getFileManager() const
PreprocessorOptions & getPreprocessorOpts() const
Retrieve the preprocessor options used to initialize this preprocessor.
bool alreadyIncluded(FileEntryRef File) const
Return true if this header has already been included.
FileID getPredefinesFileID() const
Returns the FileID for the preprocessor predefines.
HeaderSearch & getHeaderSearchInfo() const
SmallVector< SourceLocation, 64 > serializeSafeBufferOptOutMap() const
IdentifierTable & getIdentifierTable()
const LangOptions & getLangOpts() const
PreprocessingRecord * getPreprocessingRecord() const
Retrieve the preprocessing record, or NULL if there is no preprocessing record.
DiagnosticsEngine & getDiagnostics() const
SourceLocation getPreambleRecordedPragmaAssumeNonNullLoc() const
Get the location of the recorded unterminated #pragma clang assume_nonnull begin in the preamble,...
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
A (possibly-)qualified type.
Wrapper of type source information for a type with non-trivial direct qualifiers.
The collection of all-type qualifiers we support.
SourceLocation getAmpAmpLoc() const
Represents a struct/union/class.
Wrapper for source info for record types.
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
iterator find(Selector Sel)
llvm::DenseMap< Selector, Lists >::iterator iterator
void updateOutOfDateSelector(Selector Sel)
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Sema - This implements semantic analysis and AST building for C.
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
DelegatingCtorDeclsType DelegatingCtorDecls
All the delegating constructors seen so far in the file, used for cycle detection at the end of the T...
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.
llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate > > LateParsedTemplateMapT
CXXRecordDecl * getStdBadAlloc() const
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
llvm::DenseMap< CXXRecordDecl *, bool > VTablesUsed
The set of classes whose vtables have been used within this translation unit, and a bit that will be ...
PragmaStack< AlignPackInfo > AlignPackStack
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
const llvm::MapVector< FieldDecl *, DeleteLocs > & getMismatchingDeleteExpressions() const
Retrieves list of suspicious delete-expressions that will be checked at the end of translation unit.
OpenCLOptions & getOpenCLOptions()
NamespaceDecl * getStdNamespace() const
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
llvm::MapVector< IdentifierInfo *, llvm::SetVector< WeakInfo, llvm::SmallVector< WeakInfo, 1u >, llvm::SmallDenseSet< WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly > > > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
IdentifierResolver IdResolver
static RawLocEncoding encode(SourceLocation Loc, UIntTy BaseOffset, unsigned BaseModuleFileIndex, SourceLocationSequence *=nullptr)
This object establishes a SourceLocationSequence.
Serialized encoding of a sequence of SourceLocations.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
SourceLocation::UIntTy getNextLocalOffset() const
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.
unsigned getFileIDSize(FileID FID) const
The size of the SLocEntry that FID represents.
bool hasLineTable() const
Determine if the source manager has a line table.
bool isLoadedSourceLocation(SourceLocation Loc) const
Returns true if Loc came from a PCH/Module.
bool isLoadedFileID(FileID FID) const
Returns true if FID came from a PCH/Module.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
LineTableInfo & getLineTable()
Retrieve the stored line table.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
One instance of this struct is kept for every file loaded or used.
OptionalFileEntryRef ContentsEntry
References the file which the contents were actually loaded from.
unsigned IsTransient
True if this file may be transient, that is, if it might not exist at some later point in time when t...
std::optional< llvm::MemoryBufferRef > getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM, SourceLocation Loc=SourceLocation()) const
Returns the memory buffer for the associated content.
unsigned BufferOverridden
Indicates whether the buffer itself was provided to override the actual file contents.
OptionalFileEntryRef OrigEntry
Reference to the file entry representing this ContentCache.
Each ExpansionInfo encodes the expansion location - where the token was ultimately expanded,...
SourceLocation getExpansionLocStart() const
bool isExpansionTokenRange() const
SourceLocation getSpellingLoc() const
bool isMacroArgExpansion() const
SourceLocation getExpansionLocEnd() const
Information about a FileID, basically just the logical file that it represents and include stack info...
const ContentCache & getContentCache() const
This is a discriminated union of FileInfo and ExpansionInfo.
SourceLocation::UIntTy getOffset() const
const FileInfo & getFile() const
const ExpansionInfo & getExpansion() const
An array of decls optimized for the common case of only containing one entry.
Wrapper for substituted template type parameters.
Wrapper for substituted template type parameters.
Represents the declaration of a struct/union/class/enum.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Exposes information about the current target.
Options for controlling the target.
std::string Triple
The name of the target triple to compile for.
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings starting...
std::string ABI
If given, the name of the target ABI to use.
std::string TuneCPU
If given, the name of the target CPU to tune code for.
std::string CPU
If given, the name of the target CPU to generate code for.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line.
A template argument list.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
Location wrapper for a TemplateArgument.
TemplateArgumentLocInfo getLocInfo() const
const TemplateArgument & getArgument() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
ArgKind
The kind of template argument we're storing.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
Stores a list of template parameters for a TemplateDecl and its derived classes.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
SourceLocation getTemplateLoc() const
unsigned getNumArgs() const
SourceLocation getLAngleLoc() const
TemplateArgumentLoc getArgLoc(unsigned i) const
SourceLocation getRAngleLoc() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKeywordLoc() const
Wrapper for template type parameters.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
unsigned getFlags() const
Return the internal represtation of the flags.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
unsigned getLength() const
SourceLocation getAnnotationEndLoc() const
void * getAnnotationValue() const
tok::TokenKind getKind() const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
The top declaration context.
NamespaceDecl * getAnonymousNamespace() const
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
TypeSourceInfo * getUnmodifiedTInfo() const
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getNameLoc() const
The base class of the type hierarchy.
TypeClass getTypeClass() const
Base class for declarations which introduce a typedef-name.
Wrapper for source info for typedefs.
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
SourceLocation getTypeofLoc() const
The iterator over UnresolvedSets.
Wrapper for source info for unresolved typename using decls.
Wrapper for source info for types used via transparent aliases.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
EvaluatedStmt * getEvaluatedStmt() const
const Expr * getInit() const
APValue * getEvaluatedValue() const
Return the already-evaluated value of this variable's initializer, or NULL if the value is not yet kn...
Declaration of a variable template.
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getNameLoc() const
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
SourceLocation getEllipsisLoc() const
Retrieve the source location of the ellipsis, whose presence indicates that the capture is a pack exp...
void writeQualifiers(Qualifiers value)
A key used when looking up entities by DeclarationName.
Information about a module that has been loaded by the ASTReader.
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
unsigned LocalNumSubmodules
The number of submodules in this module.
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
unsigned NumPreprocessedEntities
unsigned Index
The index of this module in the list of modules.
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
std::string FileName
The file name of the module file.
SourceLocation::UIntTy SLocEntryBaseOffset
The base offset in the source manager's view of this module.
unsigned LocalNumMacros
The number of macros in this AST file.
unsigned LocalNumSelectors
The number of selectors new to this file.
ModuleKind Kind
The type of this module.
std::string ModuleName
The name of the module.
serialization::MacroID BaseMacroID
Base macro ID for macros local to this module.
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 getModuleFileIndex() const
TypeID asTypeID(unsigned FastQuals) const
uint64_t getValue() 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.
TypeCode
Record codes for each kind of type.
const unsigned int DECL_UPDATES
Record of updates for a declaration that was modified after being deserialized.
@ PREDEF_TYPE_AUTO_RREF_DEDUCT
The "auto &&" deduction type.
@ PREDEF_TYPE_NULL_ID
The NULL type.
@ PREDEF_TYPE_AUTO_DEDUCT
The "auto" deduction type.
@ CTOR_INITIALIZER_MEMBER
@ CTOR_INITIALIZER_DELEGATING
@ CTOR_INITIALIZER_INDIRECT_MEMBER
@ DECL_EMPTY
An EmptyDecl record.
@ DECL_CXX_BASE_SPECIFIERS
A record containing CXXBaseSpecifiers.
@ DECL_CXX_RECORD
A CXXRecordDecl record.
@ DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION
A VarTemplatePartialSpecializationDecl record.
@ DECL_OMP_ALLOCATE
An OMPAllocateDcl record.
@ DECL_MS_PROPERTY
A MSPropertyDecl record.
@ DECL_REQUIRES_EXPR_BODY
A RequiresExprBodyDecl record.
@ DECL_STATIC_ASSERT
A StaticAssertDecl record.
@ DECL_INDIRECTFIELD
A IndirectFieldDecl record.
@ DECL_TEMPLATE_TEMPLATE_PARM
A TemplateTemplateParmDecl record.
@ DECL_IMPORT
An ImportDecl recording a module import.
@ DECL_ACCESS_SPEC
An AccessSpecDecl record.
@ DECL_OBJC_TYPE_PARAM
An ObjCTypeParamDecl record.
@ DECL_OBJC_CATEGORY_IMPL
A ObjCCategoryImplDecl record.
@ DECL_ENUM_CONSTANT
An EnumConstantDecl record.
@ DECL_PARM_VAR
A ParmVarDecl record.
@ DECL_TYPEDEF
A TypedefDecl record.
@ DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack.
@ DECL_HLSL_BUFFER
A HLSLBufferDecl record.
@ DECL_NAMESPACE_ALIAS
A NamespaceAliasDecl record.
@ DECL_TYPEALIAS
A TypeAliasDecl record.
@ DECL_FUNCTION_TEMPLATE
A FunctionTemplateDecl record.
@ DECL_UNRESOLVED_USING_TYPENAME
An UnresolvedUsingTypenameDecl record.
@ DECL_CLASS_TEMPLATE_SPECIALIZATION
A ClassTemplateSpecializationDecl record.
@ DECL_FILE_SCOPE_ASM
A FileScopeAsmDecl record.
@ DECL_CXX_CONSTRUCTOR
A CXXConstructorDecl record.
@ DECL_CXX_CONVERSION
A CXXConversionDecl record.
@ DECL_FIELD
A FieldDecl record.
@ DECL_LINKAGE_SPEC
A LinkageSpecDecl record.
@ DECL_NAMESPACE
A NamespaceDecl record.
@ DECL_NON_TYPE_TEMPLATE_PARM
A NonTypeTemplateParmDecl record.
@ DECL_FUNCTION
A FunctionDecl record.
@ DECL_USING_DIRECTIVE
A UsingDirecitveDecl record.
@ DECL_RECORD
A RecordDecl record.
@ DECL_CONTEXT_LEXICAL
A record that stores the set of declarations that are lexically stored within a given DeclContext.
@ DECL_BLOCK
A BlockDecl record.
@ DECL_UNRESOLVED_USING_VALUE
An UnresolvedUsingValueDecl record.
@ DECL_TYPE_ALIAS_TEMPLATE
A TypeAliasTemplateDecl record.
@ DECL_CXX_CTOR_INITIALIZERS
A record containing CXXCtorInitializers.
@ DECL_OBJC_CATEGORY
A ObjCCategoryDecl record.
@ DECL_VAR
A VarDecl record.
@ DECL_USING
A UsingDecl record.
@ DECL_OBJC_PROTOCOL
A ObjCProtocolDecl record.
@ DECL_TEMPLATE_TYPE_PARM
A TemplateTypeParmDecl record.
@ DECL_VAR_TEMPLATE_SPECIALIZATION
A VarTemplateSpecializationDecl record.
@ DECL_OBJC_IMPLEMENTATION
A ObjCImplementationDecl record.
@ DECL_OBJC_COMPATIBLE_ALIAS
A ObjCCompatibleAliasDecl record.
@ DECL_FRIEND_TEMPLATE
A FriendTemplateDecl record.
@ DECL_PRAGMA_DETECT_MISMATCH
A PragmaDetectMismatchDecl record.
@ DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack.
@ DECL_OBJC_AT_DEFS_FIELD
A ObjCAtDefsFieldDecl record.
@ DECL_IMPLICIT_PARAM
An ImplicitParamDecl record.
@ DECL_FRIEND
A FriendDecl record.
@ DECL_CXX_METHOD
A CXXMethodDecl record.
@ DECL_EXPORT
An ExportDecl record.
@ DECL_PRAGMA_COMMENT
A PragmaCommentDecl record.
@ DECL_ENUM
An EnumDecl record.
@ DECL_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)
uint64_t TypeID
An ID number that refers to a type in an AST file.
@ EXTENSION_METADATA
Metadata describing this particular extension.
@ SUBMODULE_EXCLUDED_HEADER
Specifies a header that has been explicitly excluded from this submodule.
@ SUBMODULE_TOPHEADER
Specifies a top-level header that falls into this (sub)module.
@ SUBMODULE_PRIVATE_TEXTUAL_HEADER
Specifies a header that is private to this submodule but must be textually included.
@ SUBMODULE_HEADER
Specifies a header that falls into this (sub)module.
@ SUBMODULE_EXPORT_AS
Specifies the name of the module that will eventually re-export the entities in this module.
@ SUBMODULE_UMBRELLA_DIR
Specifies an umbrella directory.
@ SUBMODULE_UMBRELLA_HEADER
Specifies the umbrella header used to create this module, if any.
@ SUBMODULE_METADATA
Metadata for submodules as a whole.
@ SUBMODULE_REQUIRES
Specifies a required feature.
@ SUBMODULE_PRIVATE_HEADER
Specifies a header that is private to this submodule.
@ SUBMODULE_IMPORTS
Specifies the submodules that are imported by this submodule.
@ SUBMODULE_CONFLICT
Specifies a conflict with another module.
@ SUBMODULE_INITIALIZERS
Specifies some declarations with initializers that must be emitted to initialize the module.
@ SUBMODULE_DEFINITION
Defines the major attributes of a submodule, including its name and parent.
@ SUBMODULE_LINK_LIBRARY
Specifies a library or framework to link against.
@ SUBMODULE_CONFIG_MACRO
Specifies a configuration macro for this module.
@ SUBMODULE_EXPORTS
Specifies the submodules that are re-exported from this submodule.
@ SUBMODULE_TEXTUAL_HEADER
Specifies a header that is part of the module but must be textually included.
@ SUBMODULE_AFFECTING_MODULES
Specifies affecting modules that were not imported.
TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT)
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
@ FILE_SYSTEM_OPTIONS
Record code for the filesystem options table.
@ TARGET_OPTIONS
Record code for the target options table.
@ PREPROCESSOR_OPTIONS
Record code for the preprocessor options table.
@ HEADER_SEARCH_OPTIONS
Record code for the headers search options table.
@ LANGUAGE_OPTIONS
Record code for the language options table.
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
const unsigned int NUM_PREDEF_PP_ENTITY_IDS
The number of predefined preprocessed entity IDs.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
@ SUBMODULE_BLOCK_ID
The block containing the submodule structure.
@ PREPROCESSOR_DETAIL_BLOCK_ID
The block containing the detailed preprocessing record.
@ AST_BLOCK_ID
The AST block, which acts as a container around the full AST block.
@ SOURCE_MANAGER_BLOCK_ID
The block containing information about the source manager.
@ CONTROL_BLOCK_ID
The control block, which contains all of the information that needs to be validated prior to committi...
@ DECLTYPES_BLOCK_ID
The block containing the definitions of all of the types and decls used within the AST file.
@ PREPROCESSOR_BLOCK_ID
The block containing information about the preprocessor.
@ COMMENTS_BLOCK_ID
The block containing comments.
@ UNHASHED_CONTROL_BLOCK_ID
A block with unhashed content.
@ EXTENSION_BLOCK_ID
A block containing a module file extension.
@ OPTIONS_BLOCK_ID
The block of configuration options, used to check that a module is being used in a configuration comp...
@ INPUT_FILES_BLOCK_ID
The block of input files, which were used as inputs to create this AST file.
const unsigned VERSION_MINOR
AST file minor version number supported by this version of Clang.
@ SM_SLOC_FILE_ENTRY
Describes a source location entry (SLocEntry) for a file.
@ SM_SLOC_BUFFER_BLOB_COMPRESSED
Describes a zlib-compressed blob that contains the data for a buffer entry.
@ SM_SLOC_BUFFER_ENTRY
Describes a source location entry (SLocEntry) for a buffer.
@ SM_SLOC_BUFFER_BLOB
Describes a blob that contains the data for a buffer entry.
@ SM_SLOC_EXPANSION_ENTRY
Describes a source location entry (SLocEntry) for a macro expansion.
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
DeclIDBase::DeclID DeclID
An ID number that refers to a declaration in an AST file.
@ PP_TOKEN
Describes one token.
@ PP_MACRO_FUNCTION_LIKE
A function-like macro definition.
@ PP_MACRO_OBJECT_LIKE
An object-like macro definition.
@ PP_MACRO_DIRECTIVE_HISTORY
The macro directives history for a particular identifier.
@ PP_MODULE_MACRO
A macro directive exported by a module.
void numberAnonymousDeclsWithin(const DeclContext *DC, Fn Visit)
Visit each declaration within DC that needs an anonymous declaration number and call Visit with the d...
@ MODULE_MAP_FILE
Record code for the module map file that was used to build this AST file.
@ MODULE_DIRECTORY
Record code for the module build directory.
@ 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.
uint64_t IdentifierID
An ID number that refers to an identifier in an AST file.
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
@ DECL_UPDATE_OFFSETS
Record for offsets of DECL_UPDATES records for declarations that were modified after being deserializ...
@ STATISTICS
Record code for the extra statistics we gather while generating an AST file.
@ FLOAT_CONTROL_PRAGMA_OPTIONS
Record code for #pragma float_control options.
@ KNOWN_NAMESPACES
Record code for the set of known namespaces, which are used for typo correction.
@ SPECIAL_TYPES
Record code for the set of non-builtin, special types.
@ PENDING_IMPLICIT_INSTANTIATIONS
Record code for pending implicit instantiations.
@ TYPE_OFFSET
Record code for the offsets of each type.
@ DELEGATING_CTORS
The list of delegating constructor declarations.
@ PP_ASSUME_NONNULL_LOC
ID 66 used to be the list of included files.
@ EXT_VECTOR_DECLS
Record code for the set of ext_vector type names.
@ OPENCL_EXTENSIONS
Record code for enabled OpenCL extensions.
@ FP_PRAGMA_OPTIONS
Record code for floating point #pragma options.
@ PP_UNSAFE_BUFFER_USAGE
Record code for #pragma clang unsafe_buffer_usage begin/end.
@ 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.
@ VTABLES_TO_EMIT
Record code for vtables to emit.
@ 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'.
@ PCopyOut
'copyout' clause alias 'pcopyout'. Preserved for diagnostic purposes.
@ VectorLength
'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop', and 'kernels loop' constru...
@ Async
'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined constructs.
@ PresentOrCreate
'create' clause alias 'present_or_create'.
@ Collapse
'collapse' clause, allowed on 'loop' and Combined constructs.
@ NoHost
'nohost' clause, allowed on 'routine' directives.
@ PresentOrCopy
'copy' clause alias 'present_or_copy'. Preserved for diagnostic purposes.
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Copy
'copy' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ Worker
'worker' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ DeviceType
'device_type' clause, allowed on Compute, 'data', 'init', 'shutdown', 'set', update',...
@ DefaultAsync
'default_async' clause, allowed on 'set' construct.
@ Attach
'attach' clause, allowed on Compute and Combined constructs, plus 'data' and 'enter data'.
@ NumGangs
'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs.
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...
@ Default
'default' clause, allowed on parallel, serial, kernel (and compound) constructs.
@ UseDevice
'use_device' clause, allowed on 'host_data' construct.
@ NoCreate
'no_create' clause, allowed on allowed on Compute and Combined constructs, plus 'data'.
@ PresentOrCopyOut
'copyout' clause alias 'present_or_copyout'.
@ Link
'link' clause, allowed on 'declare' construct.
@ Reduction
'reduction' clause, allowed on Parallel, Serial, Loop, and the combined constructs.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ CopyOut
'copyout' clause, allowed on Compute and Combined constructs, plus 'data', 'exit data',...
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
@ FirstPrivate
'firstprivate' clause, allowed on 'parallel', 'serial', 'parallel loop', and 'serial loop' constructs...
@ Host
'host' clause, allowed on 'update' construct.
@ PCopy
'copy' clause alias 'pcopy'. Preserved for diagnostic purposes.
@ Tile
'tile' clause, allowed on 'loop' and Combined constructs.
@ PCopyIn
'copyin' clause alias 'pcopyin'. Preserved for diagnostic purposes.
@ DeviceResident
'device_resident' clause, allowed on the 'declare' construct.
@ PCreate
'create' clause alias 'pcreate'. Preserved for diagnostic purposes.
@ Present
'present' clause, allowed on Compute and Combined constructs, plus 'data' and 'declare'.
@ DType
'dtype' clause, an alias for 'device_type', stored separately for diagnostic purposes.
@ CopyIn
'copyin' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ Device
'device' clause, allowed on the 'update' construct.
@ Independent
'independent' clause, allowed on 'loop' directives.
@ NumWorkers
'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs...
@ IfPresent
'if_present' clause, allowed on 'host_data' and 'update' directives.
@ Detach
'detach' clause, allowed on the 'exit data' construct.
@ Delete
'delete' clause, allowed on the 'exit data' construct.
@ PresentOrCopyIn
'copyin' clause alias 'present_or_copyin'.
@ Finalize
'finalize' clause, allowed on 'exit data' directive.
@ 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.
@ 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.
std::pair< IdentifierInfo *, SourceLocation > DeviceTypeArgument
static constexpr unsigned NumberOfOMPMotionModifiers
Number of allowed motion-modifiers.
for(const auto &A :T->param_types())
const FunctionProtoType * T
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
@ None
The alignment was not explicit in code.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Diagnostic wrappers for TextAPI types for error reporting.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
The signature of a module, which is a hash of the AST content.
static ASTFileSignature create(std::array< uint8_t, 20 > Bytes)
static ASTFileSignature createDummy()
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
const DeclarationNameLoc & getInfo() const
Structure used to store a statement, the constant value to which it was evaluated (if any),...
Contains a late templated function.
FPOptions FPO
Floating-point options in the point of definition.
Decl * D
The template function declaration to be late parsed.
Data for list of allocators.
a linked list of methods with the same selector name but different signatures.
ObjCMethodList * getNext() const
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
TemplateParameterList ** TemplParamLists
A new-allocated array of size NumTemplParamLists, containing pointers to the "outer" template paramet...
NestedNameSpecifierLoc QualifierLoc
unsigned NumTemplParamLists
The number of "outer" template parameter lists.
Location information for a TemplateArgument.
SourceLocation getTemplateEllipsisLoc() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
TypeSourceInfo * getAsTypeSourceInfo() const
SourceLocation getTemplateNameLoc() const
Describes the categories of an Objective-C class.