73 #include "llvm/ADT/APFloat.h" 74 #include "llvm/ADT/APInt.h" 75 #include "llvm/ADT/APSInt.h" 76 #include "llvm/ADT/ArrayRef.h" 77 #include "llvm/ADT/DenseMap.h" 78 #include "llvm/ADT/Hashing.h" 79 #include "llvm/ADT/Optional.h" 80 #include "llvm/ADT/PointerIntPair.h" 81 #include "llvm/ADT/STLExtras.h" 82 #include "llvm/ADT/SmallSet.h" 83 #include "llvm/ADT/SmallString.h" 84 #include "llvm/ADT/SmallVector.h" 85 #include "llvm/ADT/StringExtras.h" 86 #include "llvm/ADT/StringMap.h" 87 #include "llvm/ADT/StringRef.h" 88 #include "llvm/Bitcode/BitCodes.h" 89 #include "llvm/Bitcode/BitstreamWriter.h" 90 #include "llvm/Support/Casting.h" 91 #include "llvm/Support/Compression.h" 92 #include "llvm/Support/Endian.h" 93 #include "llvm/Support/EndianStream.h" 94 #include "llvm/Support/Error.h" 95 #include "llvm/Support/ErrorHandling.h" 96 #include "llvm/Support/MemoryBuffer.h" 97 #include "llvm/Support/OnDiskHashTable.h" 98 #include "llvm/Support/Path.h" 99 #include "llvm/Support/SHA1.h" 100 #include "llvm/Support/raw_ostream.h" 115 using namespace clang;
118 template <
typename T,
typename Allocator>
119 static StringRef
bytes(
const std::vector<T, Allocator> &
v) {
120 if (v.empty())
return StringRef();
121 return StringRef(reinterpret_cast<const char*>(&v[0]),
122 sizeof(
T) * v.size());
125 template <
typename T>
127 return StringRef(reinterpret_cast<const char*>(v.data()),
128 sizeof(
T) * v.size());
145 unsigned AbbrevToUse = 0;
149 : Writer(Writer), Record(Writer, Record) {}
152 return Record.
Emit(Code, AbbrevToUse);
161 AbbrevToUse = Writer.TypeExtQualAbbrev;
166 #define TYPE(Class, Base) \ 167 case Type::Class: Visit##Class##Type(cast<Class##Type>(T)); break; 168 #define ABSTRACT_TYPE(Class, Base) 169 #include "clang/AST/TypeNodes.def" 176 void VisitTagType(
const TagType *T);
178 #define TYPE(Class, Base) void Visit##Class##Type(const Class##Type *T); 179 #define ABSTRACT_TYPE(Class, Base) 180 #include "clang/AST/TypeNodes.def" 185 void ASTTypeWriter::VisitBuiltinType(
const BuiltinType *
T) {
186 llvm_unreachable(
"Built-in types are never serialized");
189 void ASTTypeWriter::VisitComplexType(
const ComplexType *
T) {
194 void ASTTypeWriter::VisitPointerType(
const PointerType *T) {
199 void ASTTypeWriter::VisitDecayedType(
const DecayedType *T) {
204 void ASTTypeWriter::VisitAdjustedType(
const AdjustedType *T) {
257 void ASTTypeWriter::VisitVectorType(
const VectorType *T) {
264 void ASTTypeWriter::VisitExtVectorType(
const ExtVectorType *T) {
276 Record.push_back(C.
getCC());
285 VisitFunctionType(T);
307 VisitFunctionType(T);
316 for (
unsigned I = 0, N = T->
getNumParams(); I != N; ++I)
320 for (
unsigned I = 0, N = T->
getNumParams(); I != N; ++I)
333 Record.AddDeclRef(T->
getDecl());
337 void ASTTypeWriter::VisitTypedefType(
const TypedefType *T) {
338 Record.AddDeclRef(T->
getDecl());
344 void ASTTypeWriter::VisitTypeOfExprType(
const TypeOfExprType *T) {
349 void ASTTypeWriter::VisitTypeOfType(
const TypeOfType *T) {
354 void ASTTypeWriter::VisitDecltypeType(
const DecltypeType *T) {
367 void ASTTypeWriter::VisitAutoType(
const AutoType *T) {
375 void ASTTypeWriter::VisitDeducedTemplateSpecializationType(
388 "Cannot serialize in the middle of a type definition");
391 void ASTTypeWriter::VisitRecordType(
const RecordType *T) {
396 void ASTTypeWriter::VisitEnumType(
const EnumType *T) {
401 void ASTTypeWriter::VisitAttributedType(
const AttributedType *T) {
409 ASTTypeWriter::VisitSubstTemplateTypeParmType(
417 ASTTypeWriter::VisitSubstTemplateTypeParmPackType(
425 ASTTypeWriter::VisitTemplateSpecializationType(
430 for (
const auto &ArgI : *T)
431 Record.AddTemplateArgument(ArgI);
432 Record.AddTypeRef(T->isTypeAlias() ? T->getAliasedType()
433 : T->isCanonicalUnqualified()
435 : T->getCanonicalTypeInternal());
448 ASTTypeWriter::VisitDependentSizedExtVectorType(
457 ASTTypeWriter::VisitDependentAddressSpaceType(
470 Record.AddDeclRef(T->
getDecl());
485 ASTTypeWriter::VisitDependentTemplateSpecializationType(
491 for (
const auto &I : *T)
492 Record.AddTemplateArgument(I);
499 Record.push_back(*NumExpansions + 1);
505 void ASTTypeWriter::VisitParenType(
const ParenType *T) {
510 void ASTTypeWriter::VisitElaboratedType(
const ElaboratedType *T) {
529 Record.AddDeclRef(T->
getDecl());
531 for (
const auto *I : T->
quals())
532 Record.AddDeclRef(I);
536 void ASTTypeWriter::VisitObjCObjectType(
const ObjCObjectType *T) {
540 Record.AddTypeRef(TypeArg);
542 for (
const auto *I : T->
quals())
543 Record.AddDeclRef(I);
555 ASTTypeWriter::VisitAtomicType(
const AtomicType *T) {
561 ASTTypeWriter::VisitPipeType(
const PipeType *T) {
575 #define ABSTRACT_TYPELOC(CLASS, PARENT) 576 #define TYPELOC(CLASS, PARENT) \ 577 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc); 578 #include "clang/AST/TypeLocNodes.def" 621 Record.AddSourceLocation(TL.
getAmpLoc());
633 void TypeLocWriter::VisitArrayTypeLoc(
ArrayTypeLoc TL) {
642 VisitArrayTypeLoc(TL);
646 VisitArrayTypeLoc(TL);
650 VisitArrayTypeLoc(TL);
653 void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
655 VisitArrayTypeLoc(TL);
658 void TypeLocWriter::VisitDependentAddressSpaceTypeLoc(
662 Record.AddSourceLocation(range.
getBegin());
663 Record.AddSourceLocation(range.
getEnd());
667 void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
686 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i)
691 VisitFunctionTypeLoc(TL);
695 VisitFunctionTypeLoc(TL);
733 Record.AddSourceLocation(TL.
getKWLoc());
739 void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
743 void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
752 void TypeLocWriter::VisitEnumTypeLoc(
EnumTypeLoc TL) {
760 Record.AddSourceLocation(range.
getBegin());
761 Record.AddSourceLocation(range.
getEnd());
765 Record.push_back(operand ? 1 : 0);
766 if (operand) Record.AddStmt(operand);
776 void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
781 void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
786 void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
792 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
797 void TypeLocWriter::VisitParenTypeLoc(
ParenTypeLoc TL) {
817 void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
825 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I)
855 Record.AddSourceLocation(TL.
getKWLoc());
860 void TypeLocWriter::VisitPipeTypeLoc(
PipeTypeLoc TL) {
861 Record.AddSourceLocation(TL.
getKWLoc());
864 void ASTWriter::WriteTypeAbbrevs() {
865 using namespace llvm;
867 std::shared_ptr<BitCodeAbbrev> Abv;
870 Abv = std::make_shared<BitCodeAbbrev>();
872 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
873 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
874 TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
877 Abv = std::make_shared<BitCodeAbbrev>();
880 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
881 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
882 Abv->Add(BitCodeAbbrevOp(0));
883 Abv->Add(BitCodeAbbrevOp(0));
884 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
885 Abv->Add(BitCodeAbbrevOp(0));
886 Abv->Add(BitCodeAbbrevOp(0));
888 Abv->Add(BitCodeAbbrevOp(0));
889 Abv->Add(BitCodeAbbrevOp(0));
890 Abv->Add(BitCodeAbbrevOp(0));
891 Abv->Add(BitCodeAbbrevOp(0));
892 Abv->Add(BitCodeAbbrevOp(
EST_None));
893 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
894 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
895 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
896 TypeFunctionProtoAbbrev = Stream.EmitAbbrev(std::move(Abv));
904 llvm::BitstreamWriter &Stream,
907 Record.push_back(ID);
908 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);
911 if (!Name || Name[0] == 0)
915 Record.push_back(*Name++);
916 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME, Record);
920 llvm::BitstreamWriter &Stream,
923 Record.push_back(ID);
925 Record.push_back(*Name++);
926 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, Record);
931 #define RECORD(X) EmitRecordID(X, #X, Stream, Record) 1058 void ASTWriter::WriteBlockInfoBlock() {
1060 Stream.EnterBlockInfoBlock();
1062 #define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record) 1063 #define RECORD(X) EmitRecordID(X, #X, Stream, Record) 1066 BLOCK(CONTROL_BLOCK);
1077 BLOCK(OPTIONS_BLOCK);
1084 BLOCK(INPUT_FILES_BLOCK);
1142 BLOCK(SOURCE_MANAGER_BLOCK);
1150 BLOCK(PREPROCESSOR_BLOCK);
1158 BLOCK(SUBMODULE_BLOCK);
1179 BLOCK(COMMENTS_BLOCK);
1183 BLOCK(DECLTYPES_BLOCK);
1300 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
1306 BLOCK(EXTENSION_BLOCK);
1309 BLOCK(UNHASHED_CONTROL_BLOCK);
1326 return Changed | llvm::sys::path::remove_dots(Path);
1341 assert(Filename &&
"No file name to adjust?");
1343 if (BaseDir.empty())
1348 for (; Filename[Pos] && Pos < BaseDir.size(); ++Pos)
1349 if (Filename[Pos] != BaseDir[Pos])
1358 if (!llvm::sys::path::is_separator(Filename[Pos])) {
1359 if (!llvm::sys::path::is_separator(BaseDir.back()))
1373 return Filename + Pos;
1380 auto Hash = Hasher.result();
1384 auto LShift = [&](
unsigned char Val,
unsigned Shift) {
1385 return (uint32_t)Val <<
Shift;
1387 for (
int I = 0; I != 5; ++I)
1388 Signature[I] = LShift(Hash[I * 4 + 0], 24) | LShift(Hash[I * 4 + 1], 16) |
1389 LShift(Hash[I * 4 + 2], 8) | LShift(Hash[I * 4 + 3], 0);
1397 Stream.FlushToWord();
1398 auto StartOfUnhashedControl = Stream.GetCurrentBitNo() >> 3;
1406 if (WritingModule &&
1408 Signature = createSignature(StringRef(Buffer.begin(), StartOfUnhashedControl));
1409 Record.append(Signature.begin(), Signature.end());
1417 #define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name); 1418 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ 1419 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name())); 1420 #include "clang/Basic/DiagnosticOptions.def" 1421 Record.push_back(DiagOpts.
Warnings.size());
1422 for (
unsigned I = 0, N = DiagOpts.
Warnings.size(); I != N; ++I)
1423 AddString(DiagOpts.
Warnings[I], Record);
1424 Record.push_back(DiagOpts.
Remarks.size());
1425 for (
unsigned I = 0, N = DiagOpts.
Remarks.size(); I != N; ++I)
1426 AddString(DiagOpts.
Remarks[I], Record);
1432 WritePragmaDiagnosticMappings(Diags, WritingModule);
1442 const std::string &OutputFile) {
1443 using namespace llvm;
1449 auto MetadataAbbrev = std::make_shared<BitCodeAbbrev>();
1450 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1451 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1452 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1453 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1454 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1455 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1456 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1457 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1458 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1459 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev));
1460 assert((!WritingModule || isysroot.empty()) &&
1461 "writing module as a relocatable PCH?");
1464 CLANG_VERSION_MAJOR, CLANG_VERSION_MINOR,
1465 !isysroot.empty(), IncludeTimestamps,
1466 ASTHasCompilerErrors};
1467 Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
1471 if (WritingModule) {
1473 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1475 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1476 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1478 Stream.EmitRecordWithBlob(AbbrevCode, Record, WritingModule->Name);
1481 if (WritingModule && WritingModule->Directory) {
1491 WritingModule->Directory->getName() != StringRef(
".")) {
1493 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1495 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1496 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1499 Stream.EmitRecordWithBlob(AbbrevCode, Record, BaseDir);
1503 BaseDirectory.assign(BaseDir.begin(), BaseDir.end());
1504 }
else if (!isysroot.empty()) {
1506 BaseDirectory = isysroot;
1514 AddPath(WritingModule->PresumedModuleMapFile.empty()
1515 ? Map.getModuleMapFileForUniquing(WritingModule)->getName()
1516 : StringRef(WritingModule->PresumedModuleMapFile),
1520 if (
auto *AdditionalModMaps =
1521 Map.getAdditionalModuleMapFiles(WritingModule)) {
1522 Record.push_back(AdditionalModMaps->size());
1523 for (
const FileEntry *F : *AdditionalModMaps)
1524 AddPath(F->getName(), Record);
1526 Record.push_back(0);
1539 if (!M.isDirectlyImported())
1542 Record.push_back((
unsigned)M.Kind);
1543 AddSourceLocation(M.ImportLoc, Record);
1547 Record.push_back(M.Signature ? 0 : M.File->getSize());
1548 Record.push_back(M.Signature ? 0 : getTimestampForOutput(M.File));
1550 for (
auto I : M.Signature)
1551 Record.push_back(I);
1553 AddString(M.ModuleName, Record);
1554 AddPath(M.FileName, Record);
1556 Stream.EmitRecord(
IMPORTS, Record);
1565 #define LANGOPT(Name, Bits, Default, Description) \ 1566 Record.push_back(LangOpts.Name); 1567 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 1568 Record.push_back(static_cast<unsigned>(LangOpts.get##Name())); 1569 #include "clang/Basic/LangOptions.def" 1570 #define SANITIZER(NAME, ID) \ 1571 Record.push_back(LangOpts.Sanitize.has(SanitizerKind::ID)); 1572 #include "clang/Basic/Sanitizers.def" 1576 AddString(Feature, Record);
1586 AddString(I, Record);
1593 AddString(T.getTriple(), Record);
1603 AddString(TargetOpts.
Triple, Record);
1604 AddString(TargetOpts.
CPU, Record);
1605 AddString(TargetOpts.
ABI, Record);
1610 Record.push_back(TargetOpts.
Features.size());
1611 for (
unsigned I = 0, N = TargetOpts.
Features.size(); I != N; ++I) {
1612 AddString(TargetOpts.
Features[I], Record);
1627 AddString(HSOpts.
Sysroot, Record);
1631 for (
unsigned I = 0, N = HSOpts.
UserEntries.size(); I != N; ++I) {
1633 AddString(Entry.
Path, Record);
1634 Record.push_back(static_cast<unsigned>(Entry.
Group));
1665 Record.push_back(PPOpts.
Macros.size());
1666 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
1667 AddString(PPOpts.
Macros[I].first, Record);
1668 Record.push_back(PPOpts.
Macros[I].second);
1672 Record.push_back(PPOpts.
Includes.size());
1673 for (
unsigned I = 0, N = PPOpts.
Includes.size(); I != N; ++I)
1674 AddString(PPOpts.
Includes[I], Record);
1678 for (
unsigned I = 0, N = PPOpts.
MacroIncludes.size(); I != N; ++I)
1695 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1697 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1698 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1699 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
1704 EmitRecordWithPath(FileAbbrevCode, Record, MainFile->getName());
1712 if (!OutputFile.empty() && OutputFile !=
"-") {
1713 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1715 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1716 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1721 StringRef origDir = llvm::sys::path::parent_path(OutputPath);
1724 Stream.EmitRecordWithBlob(AbbrevCode, Record, origDir);
1727 WriteInputFiles(Context.SourceMgr,
1736 struct InputFileEntry {
1740 bool BufferOverridden;
1741 bool IsTopLevelModuleMap;
1749 using namespace llvm;
1754 auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
1756 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1757 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1758 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1759 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1760 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1761 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1762 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1763 unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
1767 std::deque<InputFileEntry> SortedFiles;
1771 assert(&SourceMgr.
getSLocEntry(FileID::get(I)) == SLoc);
1781 InputFileEntry Entry;
1789 SortedFiles.push_back(Entry);
1791 SortedFiles.push_front(Entry);
1794 unsigned UserFilesNum = 0;
1796 std::vector<uint64_t> InputFileOffsets;
1797 for (
const auto &Entry : SortedFiles) {
1798 uint32_t &InputFileID = InputFileIDs[Entry.File];
1799 if (InputFileID != 0)
1803 InputFileOffsets.push_back(Stream.GetCurrentBitNo());
1805 InputFileID = InputFileOffsets.size();
1807 if (!Entry.IsSystemFile)
1812 RecordData::value_type Record[] = {
1814 InputFileOffsets.size(),
1815 (uint64_t)Entry.File->getSize(),
1816 (uint64_t)getTimestampForOutput(Entry.File),
1817 Entry.BufferOverridden,
1819 Entry.IsTopLevelModuleMap};
1821 EmitRecordWithPath(IFAbbrevCode, Record, Entry.File->getName());
1827 auto OffsetsAbbrev = std::make_shared<BitCodeAbbrev>();
1829 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1830 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1832 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1833 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(std::move(OffsetsAbbrev));
1837 InputFileOffsets.size(), UserFilesNum};
1838 Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record,
bytes(InputFileOffsets));
1848 using namespace llvm;
1850 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1852 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1853 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1854 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1855 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1857 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1858 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1859 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
1860 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1861 return Stream.EmitAbbrev(std::move(Abbrev));
1867 using namespace llvm;
1869 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1871 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1872 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1873 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1874 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1875 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1876 return Stream.EmitAbbrev(std::move(Abbrev));
1883 using namespace llvm;
1885 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1889 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1890 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1891 return Stream.EmitAbbrev(std::move(Abbrev));
1897 using namespace llvm;
1899 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1901 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1902 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1903 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1904 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1905 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1906 return Stream.EmitAbbrev(std::move(Abbrev));
1912 class HeaderFileInfoTrait {
1917 llvm::StringMap<unsigned> FrameworkNameOffset;
1920 HeaderFileInfoTrait(
ASTWriter &Writer) : Writer(Writer) {}
1927 using key_type_ref =
const key_type &;
1929 using UnresolvedModule =
1930 llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
1935 UnresolvedModule Unresolved;
1937 using data_type_ref =
const data_type &;
1939 using hash_value_type = unsigned;
1940 using offset_type = unsigned;
1949 std::pair<unsigned, unsigned>
1950 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) {
1951 using namespace llvm::support;
1953 endian::Writer<little> LE(Out);
1954 unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
1955 LE.write<uint16_t>(KeyLen);
1956 unsigned DataLen = 1 + 2 + 4 + 4;
1957 for (
auto ModInfo : Data.KnownHeaders)
1960 if (Data.Unresolved.getPointer())
1962 LE.write<uint8_t>(DataLen);
1963 return std::make_pair(KeyLen, DataLen);
1966 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
1967 using namespace llvm::support;
1969 endian::Writer<little> LE(Out);
1970 LE.write<uint64_t>(key.Size);
1972 LE.write<uint64_t>(key.ModTime);
1974 Out.write(key.Filename.data(), KeyLen);
1977 void EmitData(raw_ostream &Out, key_type_ref key,
1978 data_type_ref Data,
unsigned DataLen) {
1979 using namespace llvm::support;
1981 endian::Writer<little> LE(Out);
1982 uint64_t Start = Out.tell(); (void)Start;
1984 unsigned char Flags = (Data.HFI.isImport << 5)
1985 | (Data.HFI.isPragmaOnce << 4)
1986 | (Data.HFI.DirInfo << 1)
1987 | Data.HFI.IndexHeaderMapHeader;
1988 LE.write<uint8_t>(Flags);
1989 LE.write<uint16_t>(Data.HFI.NumIncludes);
1991 if (!Data.HFI.ControllingMacro)
1992 LE.write<uint32_t>(Data.HFI.ControllingMacroID);
1997 if (!Data.HFI.Framework.empty()) {
1999 llvm::StringMap<unsigned>::iterator Pos
2000 = FrameworkNameOffset.find(Data.HFI.Framework);
2001 if (Pos == FrameworkNameOffset.end()) {
2002 Offset = FrameworkStringData.size() + 1;
2003 FrameworkStringData.append(Data.HFI.Framework.begin(),
2004 Data.HFI.Framework.end());
2005 FrameworkStringData.push_back(0);
2007 FrameworkNameOffset[Data.HFI.Framework] =
Offset;
2009 Offset = Pos->second;
2011 LE.write<uint32_t>(
Offset);
2015 uint32_t
Value = (ModID << 2) | (
unsigned)Role;
2016 assert((Value >> 2) == ModID &&
"overflow in header module info");
2017 LE.write<uint32_t>(
Value);
2023 for (
auto ModInfo : Data.KnownHeaders)
2024 EmitModule(ModInfo.getModule(), ModInfo.getRole());
2025 if (Data.Unresolved.getPointer())
2026 EmitModule(Data.Unresolved.getPointer(), Data.Unresolved.getInt());
2028 assert(Out.tell() - Start == DataLen &&
"Wrong data length");
2031 const char *strings_begin()
const {
return FrameworkStringData.begin(); }
2032 const char *strings_end()
const {
return FrameworkStringData.end(); }
2040 void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
2041 HeaderFileInfoTrait GeneratorTrait(*
this);
2042 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait> Generator;
2044 unsigned NumHeaderSearchEntries = 0;
2051 if (WritingModule) {
2053 while (!Worklist.empty()) {
2054 Module *M = Worklist.pop_back_val();
2070 if (!U.Size || (!U.ModTime && IncludeTimestamps)) {
2071 PP->
Diag(U.FileNameLoc, diag::err_module_no_size_mtime_for_header)
2072 << WritingModule->getFullModuleName() << U.Size.hasValue()
2079 llvm::sys::path::append(
Filename, U.FileName);
2082 StringRef FilenameDup = strdup(
Filename.c_str());
2083 SavedStrings.push_back(FilenameDup.data());
2085 HeaderFileInfoTrait::key_type Key = {
2086 FilenameDup, *U.Size, IncludeTimestamps ? *U.ModTime : 0
2088 HeaderFileInfoTrait::data_type Data = {
2093 Generator.insert(Key, Data, GeneratorTrait);
2094 ++NumHeaderSearchEntries;
2107 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
2108 const FileEntry *File = FilesByUID[UID];
2126 if (PreparePathForOutput(FilenameTmp)) {
2129 Filename = StringRef(strdup(FilenameTmp.c_str()));
2130 SavedStrings.push_back(Filename.data());
2133 HeaderFileInfoTrait::key_type Key = {
2136 HeaderFileInfoTrait::data_type Data = {
2139 Generator.insert(Key, Data, GeneratorTrait);
2140 ++NumHeaderSearchEntries;
2145 uint32_t BucketOffset;
2147 using namespace llvm::support;
2149 llvm::raw_svector_ostream Out(TableData);
2151 endian::Writer<little>(Out).write<uint32_t>(0);
2152 BucketOffset = Generator.Emit(Out, GeneratorTrait);
2156 using namespace llvm;
2158 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2160 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2161 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2162 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2163 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2164 unsigned TableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2168 NumHeaderSearchEntries, TableData.size()};
2169 TableData.append(GeneratorTrait.strings_begin(),GeneratorTrait.strings_end());
2170 Stream.EmitRecordWithBlob(TableAbbrev, Record, TableData);
2173 for (
unsigned I = 0, N = SavedStrings.size(); I != N; ++I)
2174 free(const_cast<char *>(SavedStrings[I]));
2177 static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
2178 unsigned SLocBufferBlobCompressedAbbrv,
2179 unsigned SLocBufferBlobAbbrv) {
2180 using RecordDataType = ASTWriter::RecordData::value_type;
2185 if (llvm::zlib::isAvailable()) {
2186 llvm::Error E = llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer);
2190 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record,
2194 llvm::consumeError(std::move(E));
2198 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob);
2209 void ASTWriter::WriteSourceManagerBlock(
SourceManager &SourceMgr,
2220 unsigned SLocBufferBlobCompressedAbbrv =
2226 std::vector<uint32_t> SLocEntryOffsets;
2227 RecordData PreloadSLocs;
2233 FileID FID = FileID::get(I);
2237 SLocEntryOffsets.push_back(Stream.GetCurrentBitNo());
2250 Record.push_back(Code);
2253 Record.push_back(SLoc->
getOffset() - 2);
2261 bool EmitBlob =
false;
2264 "Writing to AST an overridden file is not supported");
2267 assert(InputFileIDs[Content->
OrigEntry] != 0 &&
"Missed file entry");
2268 Record.push_back(InputFileIDs[Content->
OrigEntry]);
2270 Record.push_back(File.NumCreatedFIDs);
2272 FileDeclIDsTy::iterator FDI = FileDeclIDs.find(FID);
2273 if (FDI != FileDeclIDs.end()) {
2274 Record.push_back(FDI->second->FirstDeclIndex);
2275 Record.push_back(FDI->second->DeclIDs.size());
2277 Record.push_back(0);
2278 Record.push_back(0);
2281 Stream.EmitRecordWithAbbrev(SLocFileAbbrv, Record);
2292 const llvm::MemoryBuffer *Buffer
2294 StringRef Name = Buffer->getBufferIdentifier();
2295 Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
2296 StringRef(Name.data(), Name.size() + 1));
2299 if (Name ==
"<built-in>")
2300 PreloadSLocs.push_back(SLocEntryOffsets.size());
2306 const llvm::MemoryBuffer *Buffer =
2308 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
2309 emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv,
2310 SLocBufferBlobAbbrv);
2326 Record.push_back(NextOffset - SLoc->
getOffset() - 1);
2327 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv, Record);
2333 if (SLocEntryOffsets.empty())
2338 using namespace llvm;
2340 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2342 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2343 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2344 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2345 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2347 RecordData::value_type Record[] = {
2350 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
2351 bytes(SLocEntryOffsets));
2365 llvm::DenseMap<int, int> FilenameMap;
2366 FilenameMap[-1] = -1;
2367 for (
const auto &L : LineTable) {
2370 for (
auto &LE : L.second) {
2371 if (FilenameMap.insert(std::make_pair(LE.FilenameID,
2372 FilenameMap.size() - 1)).second)
2373 AddPath(LineTable.getFilename(LE.FilenameID), Record);
2376 Record.push_back(0);
2379 for (
const auto &L : LineTable) {
2385 Record.push_back(L.first.ID);
2388 Record.push_back(L.second.size());
2389 for (
const auto &LE : L.second) {
2390 Record.push_back(LE.FileOffset);
2391 Record.push_back(LE.LineNo);
2392 Record.push_back(FilenameMap[LE.FilenameID]);
2393 Record.push_back((
unsigned)LE.FileKind);
2394 Record.push_back(LE.IncludeOffset);
2409 if (MI->isBuiltinMacro())
2425 void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2428 WritePreprocessorDetail(*PPRec);
2431 RecordData ModuleMacroRecord;
2442 if (SkipInfo.hasValue()) {
2443 Record.push_back(
true);
2444 AddSourceLocation(SkipInfo->HashTokenLoc, Record);
2445 AddSourceLocation(SkipInfo->IfTokenLoc, Record);
2446 Record.push_back(SkipInfo->FoundNonSkipPortion);
2447 Record.push_back(SkipInfo->FoundElse);
2448 AddSourceLocation(SkipInfo->ElseLoc, Record);
2450 Record.push_back(
false);
2453 AddSourceLocation(Cond.IfLoc, Record);
2454 Record.push_back(Cond.WasSkipping);
2455 Record.push_back(Cond.FoundNonSkip);
2456 Record.push_back(Cond.FoundElse);
2477 if (
Id.second->hadMacroDefinition() &&
2478 (!
Id.second->isFromAST() ||
2479 Id.second->hasChangedSinceDeserialization()))
2480 MacroIdentifiers.push_back(
Id.second);
2483 std::sort(MacroIdentifiers.begin(), MacroIdentifiers.end(),
2484 llvm::less_ptr<IdentifierInfo>());
2490 auto StartOffset = Stream.GetCurrentBitNo();
2500 Record.push_back(MD->
getKind());
2501 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2502 Record.push_back(getMacroRef(DefMD->getInfo(), Name));
2503 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2504 Record.push_back(VisMD->isPublic());
2509 bool EmittedModuleMacros =
false;
2513 llvm::DenseMap<ModuleMacro*, unsigned> Visits;
2514 while (!Worklist.empty()) {
2515 auto *Macro = Worklist.pop_back_val();
2518 ModuleMacroRecord.push_back(
2519 getSubmoduleID(Macro->getOwningModule()));
2520 ModuleMacroRecord.push_back(getMacroRef(Macro->getMacroInfo(), Name));
2521 for (
auto *M : Macro->overrides())
2522 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2525 ModuleMacroRecord.clear();
2528 for (
auto *M : Macro->overrides())
2529 if (++Visits[M] == M->getNumOverridingMacros())
2530 Worklist.push_back(M);
2532 EmittedModuleMacros =
true;
2535 if (Record.empty() && !EmittedModuleMacros)
2538 IdentMacroDirectivesOffsetMap[Name] = StartOffset;
2549 std::vector<uint32_t> MacroOffsets;
2551 for (
unsigned I = 0, N = MacroInfosToEmit.size(); I != N; ++I) {
2556 if (ID < FirstMacroID) {
2557 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2562 unsigned Index = ID - FirstMacroID;
2563 if (Index == MacroOffsets.size())
2564 MacroOffsets.push_back(Stream.GetCurrentBitNo());
2566 if (Index > MacroOffsets.size())
2567 MacroOffsets.resize(Index + 1);
2569 MacroOffsets[Index] = Stream.GetCurrentBitNo();
2572 AddIdentifierRef(Name, Record);
2575 Record.push_back(MI->
isUsed());
2588 AddIdentifierRef(Param, Record);
2596 Stream.EmitRecord(Code, Record);
2600 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2605 AddToken(Tok, Record);
2606 Stream.EmitRecord(
PP_TOKEN, Record);
2615 using namespace llvm;
2617 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2619 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2620 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2621 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2623 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2625 RecordData::value_type Record[] = {
MACRO_OFFSET, MacroOffsets.size(),
2627 Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record,
bytes(MacroOffsets));
2641 unsigned NumPreprocessingRecords = 0;
2642 using namespace llvm;
2645 unsigned InclusionAbbrev = 0;
2647 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2649 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2650 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2651 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2652 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2653 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2654 InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2657 unsigned FirstPreprocessorEntityID
2658 = (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0)
2660 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2665 (void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2668 PreprocessedEntityOffsets.push_back(
2669 PPEntityOffset((*E)->getSourceRange(), Stream.GetCurrentBitNo()));
2671 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*E)) {
2673 MacroDefinitions[MD] = NextPreprocessorEntityID;
2675 AddIdentifierRef(MD->getName(), Record);
2680 if (
auto *ME = dyn_cast<MacroExpansion>(*E)) {
2681 Record.push_back(ME->isBuiltinMacro());
2682 if (ME->isBuiltinMacro())
2683 AddIdentifierRef(ME->getName(), Record);
2685 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2690 if (
auto *
ID = dyn_cast<InclusionDirective>(*E)) {
2692 Record.push_back(
ID->getFileName().size());
2693 Record.push_back(
ID->wasInQuotes());
2694 Record.push_back(static_cast<unsigned>(
ID->getKind()));
2695 Record.push_back(
ID->importedModule());
2697 Buffer +=
ID->getFileName();
2701 Buffer +=
ID->getFile()->getName();
2702 Stream.EmitRecordWithBlob(InclusionAbbrev, Record, Buffer);
2706 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2711 if (NumPreprocessingRecords > 0) {
2712 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2715 using namespace llvm;
2717 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2719 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2720 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2721 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2724 FirstPreprocessorEntityID -
2726 Stream.EmitRecordWithBlob(PPEOffsetAbbrev, Record,
2727 bytes(PreprocessedEntityOffsets));
2735 llvm::DenseMap<Module *, unsigned>::iterator Known = SubmoduleIDs.find(Mod);
2736 if (Known != SubmoduleIDs.end())
2737 return Known->second;
2740 if (Top != WritingModule &&
2741 (getLangOpts().CompilingPCH ||
2742 !Top->fullModuleNameIs(StringRef(getLangOpts().CurrentModule))))
2745 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2748 unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2752 unsigned ID = getLocalOrImportedSubmoduleID(Mod);
2753 assert((ID || !Mod) &&
2754 "asked for module ID for non-local, non-imported module");
2761 unsigned ChildModules = 0;
2763 Sub != SubEnd; ++Sub)
2766 return ChildModules + 1;
2769 void ASTWriter::WriteSubmodules(
Module *WritingModule) {
2774 using namespace llvm;
2776 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2778 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2779 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2780 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2781 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2782 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2783 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2784 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2785 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2786 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2787 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2788 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2789 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2790 unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2792 Abbrev = std::make_shared<BitCodeAbbrev>();
2794 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2795 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2797 Abbrev = std::make_shared<BitCodeAbbrev>();
2799 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2800 unsigned HeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2802 Abbrev = std::make_shared<BitCodeAbbrev>();
2804 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2805 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2807 Abbrev = std::make_shared<BitCodeAbbrev>();
2809 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2810 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2812 Abbrev = std::make_shared<BitCodeAbbrev>();
2814 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2815 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2816 unsigned RequiresAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2818 Abbrev = std::make_shared<BitCodeAbbrev>();
2820 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2821 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2823 Abbrev = std::make_shared<BitCodeAbbrev>();
2825 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2826 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2828 Abbrev = std::make_shared<BitCodeAbbrev>();
2830 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2831 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2833 Abbrev = std::make_shared<BitCodeAbbrev>();
2835 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2836 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2838 Abbrev = std::make_shared<BitCodeAbbrev>();
2840 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2841 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2842 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2844 Abbrev = std::make_shared<BitCodeAbbrev>();
2846 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2847 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2849 Abbrev = std::make_shared<BitCodeAbbrev>();
2851 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2852 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2853 unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2855 Abbrev = std::make_shared<BitCodeAbbrev>();
2857 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2858 unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2861 RecordData::value_type Record[] = {
2867 std::queue<Module *> Q;
2868 Q.push(WritingModule);
2869 while (!Q.empty()) {
2872 unsigned ID = getSubmoduleID(Mod);
2874 uint64_t ParentID = 0;
2876 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
2877 ParentID = SubmoduleIDs[Mod->
Parent];
2885 (RecordData::value_type)Mod->
Kind,
2894 Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->
Name);
2900 Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
2906 Stream.EmitRecordWithBlob(UmbrellaAbbrev, Record,
2907 UmbrellaHeader.NameAsWritten);
2910 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev, Record,
2911 UmbrellaDir.NameAsWritten);
2916 unsigned RecordKind;
2927 for (
auto &HL : HeaderLists) {
2928 RecordData::value_type Record[] = {HL.RecordKind};
2929 for (
auto &H : Mod->
Headers[HL.HeaderKind])
2930 Stream.EmitRecordWithBlob(HL.Abbrev, Record, H.NameAsWritten);
2937 for (
auto *H : TopHeaders)
2938 Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, H->getName());
2945 Record.push_back(getSubmoduleID(I));
2952 for (
const auto &E : Mod->
Exports) {
2955 Record.push_back(getSubmoduleID(E.getPointer()));
2956 Record.push_back(E.getInt());
2969 Stream.EmitRecordWithBlob(LinkLibraryAbbrev, Record, LL.Library);
2977 getSubmoduleID(C.Other)};
2978 Stream.EmitRecordWithBlob(ConflictAbbrev, Record, C.Message);
2984 Stream.EmitRecordWithBlob(ConfigMacroAbbrev, Record, CM);
2990 Inits.push_back(GetDeclRef(D));
2997 Stream.EmitRecordWithBlob(ExportAsAbbrev, Record, Mod->
ExportAsModule);
3007 assert((NextSubmoduleID - FirstSubmoduleID ==
3009 "Wrong # of submodules; found a reference to a non-local, " 3010 "non-imported submodule?");
3015 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
3017 unsigned CurrID = 0;
3020 auto EncodeDiagStateFlags =
3021 [](
const DiagnosticsEngine::DiagState *DS) ->
unsigned {
3022 unsigned Result = (unsigned)DS->ExtBehavior;
3024 {(unsigned)DS->IgnoreAllWarnings, (
unsigned)DS->EnableAllWarnings,
3025 (unsigned)DS->WarningsAsErrors, (
unsigned)DS->ErrorsAsFatal,
3026 (unsigned)DS->SuppressSystemWarnings})
3027 Result = (Result << 1) | Val;
3031 unsigned Flags = EncodeDiagStateFlags(Diag.DiagStatesByLoc.FirstDiagState);
3032 Record.push_back(Flags);
3034 auto AddDiagState = [&](
const DiagnosticsEngine::DiagState *
State,
3035 bool IncludeNonPragmaStates) {
3038 assert(Flags == EncodeDiagStateFlags(State) &&
3039 "diag state flags vary in single AST file");
3041 unsigned &DiagStateID = DiagStateIDMap[
State];
3042 Record.push_back(DiagStateID);
3044 if (DiagStateID == 0) {
3045 DiagStateID = ++CurrID;
3048 auto SizeIdx = Record.size();
3049 Record.emplace_back();
3050 for (
const auto &I : *State) {
3051 if (I.second.isPragma() || IncludeNonPragmaStates) {
3052 Record.push_back(I.first);
3053 Record.push_back(I.second.serialize());
3057 Record[SizeIdx] = (Record.size() - SizeIdx) / 2;
3061 AddDiagState(Diag.DiagStatesByLoc.FirstDiagState, isModule);
3064 auto NumLocationsIdx = Record.size();
3065 Record.emplace_back();
3068 unsigned NumLocations = 0;
3069 for (
auto &FileIDAndFile : Diag.DiagStatesByLoc.Files) {
3070 if (!FileIDAndFile.first.isValid() ||
3071 !FileIDAndFile.second.HasLocalTransitions)
3076 Record.push_back(FileIDAndFile.second.StateTransitions.size());
3077 for (
auto &StatePoint : FileIDAndFile.second.StateTransitions) {
3078 Record.push_back(StatePoint.Offset);
3079 AddDiagState(StatePoint.State,
false);
3084 Record[NumLocationsIdx] = NumLocations;
3092 AddSourceLocation(Diag.DiagStatesByLoc.CurDiagStateLoc, Record);
3093 AddDiagState(Diag.DiagStatesByLoc.CurDiagState,
false);
3103 void ASTWriter::WriteType(
QualType T) {
3106 IdxRef =
TypeIdx(NextTypeID++);
3109 assert(Idx.
getIndex() >= FirstTypeID &&
"Re-writing a type from a prior AST");
3119 unsigned Index = Idx.
getIndex() - FirstTypeID;
3120 if (TypeOffsets.size() == Index)
3121 TypeOffsets.push_back(Offset);
3122 else if (TypeOffsets.size() < Index) {
3123 TypeOffsets.resize(Index + 1);
3124 TypeOffsets[Index] =
Offset;
3126 llvm_unreachable(
"Types emitted in wrong order");
3139 uint64_t ASTWriter::WriteDeclContextLexicalBlock(
ASTContext &Context,
3144 uint64_t
Offset = Stream.GetCurrentBitNo();
3146 for (
const auto *D : DC->
decls()) {
3147 KindDeclPairs.push_back(D->getKind());
3148 KindDeclPairs.push_back(GetDeclRef(D));
3151 ++NumLexicalDeclContexts;
3153 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record,
3154 bytes(KindDeclPairs));
3158 void ASTWriter::WriteTypeDeclOffsets() {
3159 using namespace llvm;
3162 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3164 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3165 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3166 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3167 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3169 RecordData::value_type Record[] = {
TYPE_OFFSET, TypeOffsets.size(),
3171 Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record,
bytes(TypeOffsets));
3175 Abbrev = std::make_shared<BitCodeAbbrev>();
3177 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3178 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3179 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3180 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3182 RecordData::value_type Record[] = {
DECL_OFFSET, DeclOffsets.size(),
3184 Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record,
bytes(DeclOffsets));
3188 void ASTWriter::WriteFileDeclIDsMap() {
3189 using namespace llvm;
3192 FileDeclIDs.begin(), FileDeclIDs.end());
3193 std::sort(SortedFileDeclIDs.begin(), SortedFileDeclIDs.end(),
3194 llvm::less_first());
3198 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
3199 DeclIDInFileInfo &Info = *FileDeclEntry.second;
3200 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
3201 for (
auto &LocDeclEntry : Info.DeclIDs)
3202 FileGroupedDeclIDs.push_back(LocDeclEntry.second);
3205 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3207 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3208 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3209 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
3211 FileGroupedDeclIDs.size()};
3212 Stream.EmitRecordWithBlob(AbbrevCode, Record,
bytes(FileGroupedDeclIDs));
3215 void ASTWriter::WriteComments() {
3219 for (
const auto *I : RawComments) {
3221 AddSourceRange(I->getSourceRange(), Record);
3222 Record.push_back(I->getKind());
3223 Record.push_back(I->isTrailingComment());
3224 Record.push_back(I->isAlmostTrailingComment());
3237 class ASTMethodPoolTrait {
3242 using key_type_ref = key_type;
3248 using data_type_ref =
const data_type &;
3250 using hash_value_type = unsigned;
3251 using offset_type = unsigned;
3253 explicit ASTMethodPoolTrait(
ASTWriter &Writer) : Writer(Writer) {}
3259 std::pair<unsigned, unsigned>
3260 EmitKeyDataLength(raw_ostream& Out,
Selector Sel,
3261 data_type_ref Methods) {
3262 using namespace llvm::support;
3264 endian::Writer<little> LE(Out);
3266 LE.write<uint16_t>(KeyLen);
3267 unsigned DataLen = 4 + 2 + 2;
3270 if (Method->getMethod())
3274 if (Method->getMethod())
3276 LE.write<uint16_t>(DataLen);
3277 return std::make_pair(KeyLen, DataLen);
3280 void EmitKey(raw_ostream& Out,
Selector Sel,
unsigned) {
3281 using namespace llvm::support;
3283 endian::Writer<little> LE(Out);
3284 uint64_t Start = Out.tell();
3285 assert((Start >> 32) == 0 &&
"Selector key offset too large");
3288 LE.write<uint16_t>(N);
3291 for (
unsigned I = 0; I != N; ++I)
3296 void EmitData(raw_ostream& Out, key_type_ref,
3297 data_type_ref Methods,
unsigned DataLen) {
3298 using namespace llvm::support;
3300 endian::Writer<little> LE(Out);
3301 uint64_t Start = Out.tell(); (void)Start;
3302 LE.write<uint32_t>(Methods.ID);
3303 unsigned NumInstanceMethods = 0;
3306 if (Method->getMethod())
3307 ++NumInstanceMethods;
3309 unsigned NumFactoryMethods = 0;
3312 if (Method->getMethod())
3313 ++NumFactoryMethods;
3315 unsigned InstanceBits = Methods.Instance.getBits();
3316 assert(InstanceBits < 4);
3317 unsigned InstanceHasMoreThanOneDeclBit =
3318 Methods.Instance.hasMoreThanOneDecl();
3319 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
3320 (InstanceHasMoreThanOneDeclBit << 2) |
3322 unsigned FactoryBits = Methods.Factory.getBits();
3323 assert(FactoryBits < 4);
3324 unsigned FactoryHasMoreThanOneDeclBit =
3325 Methods.Factory.hasMoreThanOneDecl();
3326 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
3327 (FactoryHasMoreThanOneDeclBit << 2) |
3329 LE.write<uint16_t>(FullInstanceBits);
3330 LE.write<uint16_t>(FullFactoryBits);
3333 if (Method->getMethod())
3334 LE.write<uint32_t>(Writer.
getDeclID(Method->getMethod()));
3337 if (Method->getMethod())
3338 LE.write<uint32_t>(Writer.
getDeclID(Method->getMethod()));
3340 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3351 void ASTWriter::WriteSelectors(
Sema &SemaRef) {
3352 using namespace llvm;
3355 if (SemaRef.
MethodPool.empty() && SelectorIDs.empty())
3357 unsigned NumTableEntries = 0;
3360 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait> Generator;
3361 ASTMethodPoolTrait Trait(*
this);
3365 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
3366 for (
auto &SelectorAndID : SelectorIDs) {
3369 Sema::GlobalMethodPool::iterator F = SemaRef.
MethodPool.find(S);
3370 ASTMethodPoolTrait::data_type Data = {
3376 Data.Instance = F->second.first;
3377 Data.Factory = F->second.second;
3381 if (Chain && ID < FirstSelectorID) {
3383 bool changed =
false;
3385 !changed && M && M->
getMethod(); M = M->getNext()) {
3386 if (!M->getMethod()->isFromASTFile())
3391 if (!M->getMethod()->isFromASTFile())
3396 }
else if (Data.Instance.getMethod() || Data.Factory.getMethod()) {
3400 Generator.insert(S, Data, Trait);
3405 uint32_t BucketOffset;
3407 using namespace llvm::support;
3409 ASTMethodPoolTrait Trait(*
this);
3410 llvm::raw_svector_ostream Out(MethodPool);
3412 endian::Writer<little>(Out).write<uint32_t>(0);
3413 BucketOffset = Generator.Emit(Out, Trait);
3417 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3419 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3420 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3421 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3422 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3426 RecordData::value_type Record[] = {
METHOD_POOL, BucketOffset,
3428 Stream.EmitRecordWithBlob(MethodPoolAbbrev, Record, MethodPool);
3432 Abbrev = std::make_shared<BitCodeAbbrev>();
3434 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3435 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3436 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3437 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3441 RecordData::value_type Record[] = {
3444 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev, Record,
3445 bytes(SelectorOffsets));
3451 void ASTWriter::WriteReferencedSelectorsPool(
Sema &SemaRef) {
3452 using namespace llvm;
3464 Selector Sel = SelectorAndLocation.first;
3488 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3490 if (!Redecl->isFromASTFile()) {
3494 if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
3497 return cast<NamedDecl>(Redecl);
3502 if (Redecl->getOwningModuleID() == 0)
3507 if (!First->isFromASTFile())
3508 return cast<NamedDecl>(First);
3518 class ASTIdentifierTableTrait {
3543 using key_type_ref = key_type;
3546 using data_type_ref = data_type;
3548 using hash_value_type = unsigned;
3549 using offset_type = unsigned;
3554 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3555 NeedDecls(!IsModule || !Writer.
getLangOpts().CPlusPlus),
3556 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3558 bool needDecls()
const {
return NeedDecls; }
3561 return llvm::HashString(II->
getName());
3573 std::pair<unsigned, unsigned>
3576 unsigned DataLen = 4;
3586 DEnd = IdResolver.
end();
3592 using namespace llvm::support;
3594 endian::Writer<little> LE(Out);
3596 assert((uint16_t)DataLen == DataLen && (uint16_t)KeyLen == KeyLen);
3597 LE.write<uint16_t>(DataLen);
3601 LE.write<uint16_t>(KeyLen);
3602 return std::make_pair(KeyLen, DataLen);
3614 InterestingIdentifierOffsets->push_back(Out.tell() - 4);
3621 using namespace llvm::support;
3623 endian::Writer<little> LE(Out);
3627 LE.write<uint32_t>(ID << 1);
3631 LE.write<uint32_t>((ID << 1) | 0x01);
3633 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
3634 LE.write<uint16_t>(Bits);
3636 bool HadMacroDefinition = MacroOffset != 0;
3637 Bits = (Bits << 1) |
unsigned(HadMacroDefinition);
3639 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
3643 LE.write<uint16_t>(Bits);
3645 if (HadMacroDefinition)
3646 LE.write<uint32_t>(MacroOffset);
3658 DEnd = Decls.rend();
3676 using namespace llvm;
3678 RecordData InterestingIdents;
3683 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait> Generator;
3684 ASTIdentifierTableTrait Trait(
3685 *
this, PP, IdResolver, IsModule,
3686 (getLangOpts().
CPlusPlus && IsModule) ? &InterestingIdents :
nullptr);
3695 IIs.push_back(
ID.second);
3698 std::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
3700 if (Trait.isInterestingNonMacroIdentifier(II))
3701 getIdentifierRef(II);
3705 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
3706 for (
auto IdentIDPair : IdentifierIDs) {
3709 assert(II &&
"NULL identifier in identifier table");
3712 if (ID >= FirstIdentID || !Chain || !II->isFromAST()
3713 || II->hasChangedSinceDeserialization() ||
3714 (Trait.needDecls() &&
3715 II->hasFETokenInfoChangedSinceDeserialization()))
3716 Generator.insert(II, ID, Trait);
3721 uint32_t BucketOffset;
3723 using namespace llvm::support;
3725 llvm::raw_svector_ostream Out(IdentifierTable);
3727 endian::Writer<little>(Out).write<uint32_t>(0);
3728 BucketOffset = Generator.Emit(Out, Trait);
3732 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3734 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3735 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3736 unsigned IDTableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3740 Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable);
3744 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3746 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3747 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3748 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3749 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3752 for (
unsigned I = 0, N = IdentifierOffsets.size(); I != N; ++I)
3753 assert(IdentifierOffsets[I] &&
"Missing identifier offset?");
3757 IdentifierOffsets.size(),
3759 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev, Record,
3760 bytes(IdentifierOffsets));
3764 if (!InterestingIdents.empty())
3775 class ASTDeclContextNameLookupTrait {
3781 using key_type_ref = key_type;
3784 using data_type = std::pair<unsigned, unsigned>;
3785 using data_type_ref =
const data_type &;
3787 using hash_value_type = unsigned;
3788 using offset_type = unsigned;
3790 explicit ASTDeclContextNameLookupTrait(
ASTWriter &Writer) : Writer(Writer) {}
3792 template<
typename Coll>
3793 data_type getData(
const Coll &Decls) {
3794 unsigned Start = DeclIDs.size();
3799 return std::make_pair(Start, DeclIDs.size());
3803 unsigned Start = DeclIDs.size();
3804 for (
auto ID : FromReader)
3805 DeclIDs.push_back(
ID);
3806 return std::make_pair(Start, DeclIDs.size());
3809 static bool EqualKey(key_type_ref a, key_type_ref b) {
3817 void EmitFileRef(raw_ostream &Out,
ModuleFile *F)
const {
3819 "have reference to loaded module file but no chain?");
3821 using namespace llvm::support;
3823 endian::Writer<little>(Out)
3827 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
3829 data_type_ref Lookup) {
3830 using namespace llvm::support;
3832 endian::Writer<little> LE(Out);
3833 unsigned KeyLen = 1;
3852 LE.write<uint16_t>(KeyLen);
3855 unsigned DataLen = 4 * (Lookup.second - Lookup.first);
3856 assert(uint16_t(DataLen) == DataLen &&
3857 "too many decls for serialized lookup result");
3858 LE.write<uint16_t>(DataLen);
3860 return std::make_pair(KeyLen, DataLen);
3864 using namespace llvm::support;
3866 endian::Writer<little> LE(Out);
3867 LE.write<uint8_t>(Name.
getKind());
3881 "Invalid operator?");
3891 llvm_unreachable(
"Invalid name kind?");
3894 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
3896 using namespace llvm::support;
3898 endian::Writer<little> LE(Out);
3899 uint64_t Start = Out.tell(); (void)Start;
3900 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
3901 LE.write<uint32_t>(DeclIDs[I]);
3902 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3910 return Result.
hasExternalDecls() && DC->NeedToReconcileExternalVisibleStorage;
3913 bool ASTWriter::isLookupResultEntirelyExternal(
StoredDeclsList &Result,
3923 ASTWriter::GenerateNameLookupTable(
const DeclContext *ConstDC,
3925 assert(!ConstDC->HasLazyLocalLexicalLookups &&
3926 !ConstDC->HasLazyExternalLexicalLookups &&
3927 "must call buildLookups first");
3935 ASTDeclContextNameLookupTrait> Generator;
3936 ASTDeclContextNameLookupTrait Trait(*
this);
3945 llvm::SmallSet<DeclarationName, 8> ConstructorNameSet, ConversionNameSet;
3948 auto &Name = Lookup.first;
3949 auto &Result = Lookup.second;
3955 if (isLookupResultExternal(Result, DC) &&
3956 isLookupResultEntirelyExternal(Result, DC))
3973 if (Lookup.second.getLookupResult().empty())
3976 switch (Lookup.first.getNameKind()) {
3978 Names.push_back(Lookup.first);
3982 assert(isa<CXXRecordDecl>(DC) &&
3983 "Cannot have a constructor name outside of a class!");
3984 ConstructorNameSet.insert(Name);
3988 assert(isa<CXXRecordDecl>(DC) &&
3989 "Cannot have a conversion function name outside of a class!");
3990 ConversionNameSet.insert(Name);
3996 std::sort(Names.begin(), Names.end());
3998 if (
auto *D = dyn_cast<CXXRecordDecl>(DC)) {
4012 if (ConstructorNameSet.erase(ImplicitCtorName))
4013 Names.push_back(ImplicitCtorName);
4018 if (!ConstructorNameSet.empty() || !ConversionNameSet.empty())
4019 for (
Decl *ChildD : cast<CXXRecordDecl>(DC)->decls())
4020 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
4021 auto Name = ChildND->getDeclName();
4022 switch (Name.getNameKind()) {
4027 if (ConstructorNameSet.erase(Name))
4028 Names.push_back(Name);
4032 if (ConversionNameSet.erase(Name))
4033 Names.push_back(Name);
4037 if (ConstructorNameSet.empty() && ConversionNameSet.empty())
4041 assert(ConstructorNameSet.empty() &&
"Failed to find all of the visible " 4042 "constructors by walking all the " 4043 "lexical members of the context.");
4044 assert(ConversionNameSet.empty() &&
"Failed to find all of the visible " 4045 "conversion functions by walking all " 4046 "the lexical members of the context.");
4053 for (
auto &Name : Names)
4065 for (
auto &Name : Names) {
4068 switch (Name.getNameKind()) {
4070 Generator.insert(Name, Trait.getData(Result), Trait);
4074 ConstructorDecls.append(Result.
begin(), Result.
end());
4078 ConversionDecls.append(Result.
begin(), Result.
end());
4086 if (!ConstructorDecls.empty())
4087 Generator.insert(ConstructorDecls.front()->getDeclName(),
4088 Trait.getData(ConstructorDecls), Trait);
4089 if (!ConversionDecls.empty())
4090 Generator.insert(ConversionDecls.front()->getDeclName(),
4091 Trait.getData(ConversionDecls), Trait);
4095 auto *Lookups = Chain ? Chain->getLoadedLookupTables(DC) :
nullptr;
4096 Generator.emit(LookupTable, Trait, Lookups ? &Lookups->Table :
nullptr);
4104 uint64_t ASTWriter::WriteDeclContextVisibleBlock(
ASTContext &Context,
4109 if (isa<NamespaceDecl>(DC) && Chain &&
4110 Chain->getKeyDeclaration(cast<Decl>(DC))->isFromASTFile()) {
4112 for (
auto *Prev = cast<NamespaceDecl>(DC)->getPreviousDecl(); Prev;
4113 Prev = Prev->getPreviousDecl())
4114 if (!Prev->isFromASTFile())
4127 LookupResults.reserve(Map->size());
4128 for (
auto &Entry : *Map)
4129 LookupResults.push_back(
4130 std::make_pair(Entry.first, Entry.second.getLookupResult()));
4133 std::sort(LookupResults.begin(), LookupResults.end(), llvm::less_first());
4134 for (
auto &NameAndResult : LookupResults) {
4142 assert(Result.
empty() &&
"Cannot have a constructor or conversion " 4143 "function name in a namespace!");
4148 if (!ND->isFromASTFile())
4172 uint64_t
Offset = Stream.GetCurrentBitNo();
4174 if (!Map || Map->empty())
4179 GenerateNameLookupTable(DC, LookupTable);
4183 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev, Record,
4185 ++NumVisibleDeclContexts;
4195 void ASTWriter::WriteDeclContextVisibleUpdate(
const DeclContext *DC) {
4197 if (!Map || Map->empty())
4202 GenerateNameLookupTable(DC, LookupTable);
4206 if (isa<NamespaceDecl>(DC))
4207 DC = cast<DeclContext>(Chain->getKeyDeclaration(cast<Decl>(DC)));
4210 RecordData::value_type Record[] = {
UPDATE_VISIBLE, getDeclID(cast<Decl>(DC))};
4211 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev, Record, LookupTable);
4215 void ASTWriter::WriteFPPragmaOptions(
const FPOptions &Opts) {
4216 RecordData::value_type Record[] = {Opts.
getInt()};
4221 void ASTWriter::WriteOpenCLExtensions(
Sema &SemaRef) {
4227 for (
const auto &I:Opts.OptMap) {
4228 AddString(I.getKey(), Record);
4229 auto V = I.getValue();
4230 Record.push_back(V.Supported ? 1 : 0);
4231 Record.push_back(V.Enabled ? 1 : 0);
4232 Record.push_back(V.Avail);
4233 Record.push_back(V.Core);
4238 void ASTWriter::WriteOpenCLExtensionTypes(
Sema &SemaRef) {
4243 for (
const auto &I : SemaRef.OpenCLTypeExtMap) {
4245 static_cast<unsigned>(getTypeID(I.first->getCanonicalTypeInternal())));
4246 Record.push_back(I.second.size());
4247 for (
auto Ext : I.second)
4248 AddString(Ext, Record);
4253 void ASTWriter::WriteOpenCLExtensionDecls(
Sema &SemaRef) {
4258 for (
const auto &I : SemaRef.OpenCLDeclExtMap) {
4259 Record.push_back(getDeclID(I.first));
4260 Record.push_back(static_cast<unsigned>(I.second.size()));
4261 for (
auto Ext : I.second)
4262 AddString(Ext, Record);
4267 void ASTWriter::WriteCUDAPragmas(
Sema &SemaRef) {
4268 if (SemaRef.ForceCUDAHostDeviceDepth > 0) {
4269 RecordData::value_type Record[] = {SemaRef.ForceCUDAHostDeviceDepth};
4274 void ASTWriter::WriteObjCCategories() {
4276 RecordData Categories;
4278 for (
unsigned I = 0, N = ObjCClassesWithCategories.size(); I != N; ++I) {
4280 unsigned StartIndex = Categories.size();
4285 Categories.push_back(0);
4291 Cat != CatEnd; ++Cat, ++Size) {
4292 assert(getDeclID(*Cat) != 0 &&
"Bogus category");
4293 AddDeclRef(*Cat, Categories);
4297 Categories[StartIndex] = Size;
4301 CategoriesMap.push_back(CatInfo);
4306 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
4309 using namespace llvm;
4311 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4313 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
4314 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4315 unsigned AbbrevID = Stream.EmitAbbrev(std::move(Abbrev));
4318 Stream.EmitRecordWithBlob(AbbrevID, Record,
4319 reinterpret_cast<char *>(CategoriesMap.data()),
4326 void ASTWriter::WriteLateParsedTemplates(
Sema &SemaRef) {
4333 for (
auto &LPTMapEntry : LPTMap) {
4336 AddDeclRef(FD, Record);
4337 AddDeclRef(LPT.
D, Record);
4338 Record.push_back(LPT.
Toks.size());
4340 for (
const auto &
Tok : LPT.
Toks) {
4341 AddToken(
Tok, Record);
4348 void ASTWriter::WriteOptimizePragmaOptions(
Sema &SemaRef) {
4351 AddSourceLocation(PragmaLoc, Record);
4356 void ASTWriter::WriteMSStructPragmaOptions(
Sema &SemaRef) {
4364 void ASTWriter::WriteMSPointersToMembersPragmaOptions(
Sema &SemaRef) {
4372 void ASTWriter::WritePackPragmaOptions(
Sema &SemaRef) {
4383 Record.push_back(StackEntry.Value);
4384 AddSourceLocation(StackEntry.PragmaLocation, Record);
4385 AddSourceLocation(StackEntry.PragmaPushLocation, Record);
4386 AddString(StackEntry.StackSlotLabel, Record);
4391 void ASTWriter::WriteModuleFileExtension(
Sema &SemaRef,
4397 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
4399 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4400 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4401 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4402 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4403 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4404 unsigned Abbrev = Stream.EmitAbbrev(std::move(Abv));
4410 Record.push_back(Metadata.MajorVersion);
4411 Record.push_back(Metadata.MinorVersion);
4412 Record.push_back(Metadata.BlockName.size());
4413 Record.push_back(Metadata.UserInfo.size());
4415 Buffer += Metadata.BlockName;
4416 Buffer += Metadata.UserInfo;
4417 Stream.EmitRecordWithBlob(Abbrev, Record, Buffer);
4432 auto &Record = *
this;
4433 Record.push_back(Attrs.size());
4434 for (
const auto *A : Attrs) {
4435 Record.push_back(A->getKind());
4436 Record.AddSourceRange(A->getRange());
4438 #include "clang/Serialization/AttrPCHWrite.inc" 4450 Record.push_back(Tok.
getKind());
4456 Record.push_back(Str.size());
4457 Record.insert(Record.end(), Str.begin(), Str.end());
4461 assert(Context &&
"should have context when outputting path");
4467 const char *PathBegin = Path.data();
4468 const char *PathPtr =
4470 if (PathPtr != PathBegin) {
4471 Path.erase(Path.begin(), Path.begin() + (PathPtr - PathBegin));
4480 PreparePathForOutput(FilePath);
4481 AddString(FilePath, Record);
4487 PreparePathForOutput(FilePath);
4488 Stream.EmitRecordWithBlob(Abbrev, Record, FilePath);
4493 Record.push_back(Version.
getMajor());
4495 Record.push_back(*Minor + 1);
4497 Record.push_back(0);
4499 Record.push_back(*Subminor + 1);
4501 Record.push_back(0);
4510 if (ID >= FirstIdentID)
4511 IdentifierOffsets[ID - FirstIdentID] =
Offset;
4517 unsigned ID = SelectorIDs[Sel];
4518 assert(ID &&
"Unknown selector");
4521 if (ID < FirstSelectorID)
4523 SelectorOffsets[ID - FirstSelectorID] =
Offset;
4528 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
4529 bool IncludeTimestamps)
4530 : Stream(Stream), Buffer(Buffer), PCMCache(PCMCache),
4531 IncludeTimestamps(IncludeTimestamps) {
4532 for (
const auto &Ext : Extensions) {
4533 if (
auto Writer = Ext->createExtensionWriter(*
this))
4534 ModuleFileExtensionWriters.push_back(std::move(Writer));
4539 llvm::DeleteContainerSeconds(FileDeclIDs);
4543 assert(WritingAST &&
"can't determine lang opts when not writing AST");
4552 const std::string &OutputFile,
4553 Module *WritingModule, StringRef isysroot,
4557 ASTHasCompilerErrors = hasErrors;
4560 Stream.Emit((
unsigned)
'C', 8);
4561 Stream.Emit((
unsigned)
'P', 8);
4562 Stream.Emit((
unsigned)
'C', 8);
4563 Stream.Emit((
unsigned)
'H', 8);
4565 WriteBlockInfoBlock();
4569 this->WritingModule = WritingModule;
4571 WriteASTCore(SemaRef, isysroot, OutputFile, WritingModule);
4574 this->WritingModule =
nullptr;
4575 this->BaseDirectory.clear();
4581 llvm::MemoryBuffer::getMemBufferCopy(
4582 StringRef(Buffer.begin(), Buffer.size())));
4587 template<
typename Vector>
4590 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
4597 const std::string &OutputFile,
4599 using namespace llvm;
4601 bool isModule = WritingModule !=
nullptr;
4605 Chain->finalizeForWriting();
4622 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
4626 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
4630 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
4633 RegisterPredefDecl(Context.MakeIntegerSeqDecl,
4635 RegisterPredefDecl(Context.CFConstantStringTypeDecl,
4637 RegisterPredefDecl(Context.CFConstantStringTagDecl,
4639 RegisterPredefDecl(Context.TypePackElementDecl,
4652 UnusedFileScopedDecls);
4666 WeakInfo &WI = WeakUndeclaredIdentifier.second;
4670 WeakUndeclaredIdentifiers.push_back(WI.
getUsed());
4680 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I) {
4690 AddDeclRef(TD, UnusedLocalTypedefNameCandidates);
4699 "There are local ones at end of translation unit!");
4716 for (
const auto &I : SemaRef.KnownNamespaces) {
4726 for (
const auto &I : Undefined) {
4735 for (
const auto &DeleteExprsInfo :
4737 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
4738 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
4739 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
4741 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
4746 WriteControlBlock(PP, Context, isysroot, OutputFile);
4764 NewGlobalKindDeclPairs.push_back(D->
getKind());
4765 NewGlobalKindDeclPairs.push_back(
GetDeclRef(D));
4769 auto Abv = std::make_shared<BitCodeAbbrev>();
4771 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4772 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
4775 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev, Record,
4776 bytes(NewGlobalKindDeclPairs));
4780 Abv = std::make_shared<BitCodeAbbrev>();
4782 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4783 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4784 UpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
4785 WriteDeclContextVisibleUpdate(TU);
4788 if (Context.ExternCContext)
4789 WriteDeclContextVisibleUpdate(Context.ExternCContext);
4803 for (
const auto &Number : Context.MangleNumbers)
4804 if (!Number.first->isFromASTFile())
4807 for (
const auto &Number : Context.StaticLocalNumbers)
4808 if (!Number.first->isFromASTFile())
4815 for (
const auto *I : DeclsToEmitEvenIfUnreferenced) {
4829 std::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
4847 for (
auto &SelectorAndID : SelectorIDs)
4848 AllSelectors.push_back(SelectorAndID.first);
4849 for (
auto &
Selector : AllSelectors)
4858 AddTypeRef(Context.ObjCIdRedefinitionType, SpecialTypes);
4859 AddTypeRef(Context.ObjCClassRedefinitionType, SpecialTypes);
4860 AddTypeRef(Context.ObjCSelRedefinitionType, SpecialTypes);
4883 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4885 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4886 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4889 llvm::raw_svector_ostream Out(Buffer);
4891 using namespace llvm::support;
4893 endian::Writer<little> LE(Out);
4894 LE.write<uint8_t>(
static_cast<uint8_t
>(M.
Kind));
4899 LE.write<uint16_t>(Name.size());
4900 Out.write(Name.data(), Name.size());
4906 auto writeBaseIDOrNone = [&](uint32_t BaseID,
bool ShouldWrite) {
4909 LE.write<uint32_t>(BaseID);
4911 LE.write<uint32_t>(
None);
4928 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev, Record,
4929 Buffer.data(), Buffer.size());
4940 WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord);
4941 while (!DeclTypesToEmit.empty()) {
4942 DeclOrType DOT = DeclTypesToEmit.front();
4943 DeclTypesToEmit.pop();
4945 WriteType(DOT.getType());
4947 WriteDecl(Context, DOT.getDecl());
4949 }
while (!DeclUpdates.empty());
4952 DoneWritingDeclsAndTypes =
true;
4955 WriteTypeDeclOffsets();
4956 if (!DeclUpdatesOffsetsRecord.empty())
4958 WriteFileDeclIDsMap();
4961 WritePreprocessor(PP, isModule);
4963 WriteSelectors(SemaRef);
4964 WriteReferencedSelectorsPool(SemaRef);
4965 WriteLateParsedTemplates(SemaRef);
4966 WriteIdentifierTable(PP, SemaRef.
IdResolver, isModule);
4968 WriteOpenCLExtensions(SemaRef);
4969 WriteOpenCLExtensionTypes(SemaRef);
4970 WriteOpenCLExtensionDecls(SemaRef);
4971 WriteCUDAPragmas(SemaRef);
4975 WriteSubmodules(WritingModule);
4980 if (!EagerlyDeserializedDecls.empty())
4983 if (!ModularCodegenDecls.empty())
4987 if (!TentativeDefinitions.empty())
4991 if (!UnusedFileScopedDecls.empty())
4995 if (!WeakUndeclaredIdentifiers.empty())
4997 WeakUndeclaredIdentifiers);
5000 if (!ExtVectorDecls.empty())
5004 if (!VTableUses.empty())
5008 if (!UnusedLocalTypedefNameCandidates.empty())
5010 UnusedLocalTypedefNameCandidates);
5013 if (!PendingInstantiations.empty())
5017 if (!SemaDeclRefs.empty())
5021 if (!CUDASpecialDeclRefs.empty())
5025 if (!DelegatingCtorDecls.empty())
5029 if (!KnownNamespaces.empty())
5033 if (!UndefinedButUsed.empty())
5036 if (!DeleteExprsToAnalyze.empty())
5040 for (
auto *DC : UpdatedDeclContexts)
5041 WriteDeclContextVisibleUpdate(DC);
5043 if (!WritingModule) {
5048 ModuleInfo(uint64_t ID,
Module *M) :
ID(ID), M(M) {}
5052 assert(SubmoduleIDs.find(I->getImportedModule()) != SubmoduleIDs.end());
5053 Imports.push_back(ModuleInfo(SubmoduleIDs[I->getImportedModule()],
5054 I->getImportedModule()));
5057 if (!Imports.empty()) {
5058 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
5061 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
5062 return A.ID == B.ID;
5066 std::sort(Imports.begin(), Imports.end(), Cmp);
5067 Imports.erase(std::unique(Imports.begin(), Imports.end(), Eq),
5071 for (
const auto &Import : Imports) {
5072 ImportedModules.push_back(Import.ID);
5083 WriteObjCCategories();
5084 if(!WritingModule) {
5085 WriteOptimizePragmaOptions(SemaRef);
5086 WriteMSStructPragmaOptions(SemaRef);
5087 WriteMSPointersToMembersPragmaOptions(SemaRef);
5089 WritePackPragmaOptions(SemaRef);
5092 RecordData::value_type Record[] = {
5093 NumStatements, NumMacros, NumLexicalDeclContexts, NumVisibleDeclContexts};
5098 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
5099 WriteModuleFileExtension(SemaRef, *ExtWriter);
5101 return writeUnhashedControlBlock(PP, Context);
5104 void ASTWriter::WriteDeclUpdatesBlocks(
RecordDataImpl &OffsetsRecord) {
5105 if (DeclUpdates.empty())
5108 DeclUpdateMap LocalUpdates;
5109 LocalUpdates.swap(DeclUpdates);
5111 for (
auto &DeclUpdate : LocalUpdates) {
5112 const Decl *D = DeclUpdate.first;
5114 bool HasUpdatedBody =
false;
5117 for (
auto &
Update : DeclUpdate.second) {
5123 HasUpdatedBody =
true;
5131 assert(
Update.getDecl() &&
"no decl to add?");
5144 const VarDecl *VD = cast<VarDecl>(D);
5158 Record.
AddStmt(const_cast<Expr *>(
5159 cast<ParmVarDecl>(
Update.getDecl())->getDefaultArg()));
5164 cast<FieldDecl>(
Update.getDecl())->getInClassInitializer());
5168 auto *RD = cast<CXXRecordDecl>(D);
5169 UpdatedDeclContexts.insert(RD->getPrimaryContext());
5171 Record.
AddOffset(WriteDeclContextLexicalBlock(
5172 *Context, const_cast<CXXRecordDecl *>(RD)));
5177 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
5178 Record.
push_back(MSInfo->getTemplateSpecializationKind());
5181 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
5182 Record.
push_back(Spec->getTemplateSpecializationKind());
5187 auto From = Spec->getInstantiatedFrom();
5188 if (
auto PartialSpec =
5193 &Spec->getTemplateInstantiationArgs());
5214 Record.
AddStmt(cast<CXXDestructorDecl>(D)->getOperatorDeleteThisArg());
5219 cast<FunctionDecl>(D)->getType()->castAs<FunctionProtoType>(),
5237 D->
getAttr<OMPThreadPrivateDeclAttr>()->getRange());
5242 D->
getAttr<OMPDeclareTargetDeclAttr>()->getRange());
5255 if (HasUpdatedBody) {
5256 const auto *Def = cast<FunctionDecl>(D);
5270 Record.push_back((Raw << 1) | (Raw >> 31));
5279 Record->push_back(Value.getBitWidth());
5280 const uint64_t *Words = Value.getRawData();
5281 Record->append(Words, Words + Value.getNumWords());
5285 Record->push_back(Value.isUnsigned());
5290 AddAPInt(Value.bitcastToAPInt());
5317 MacroInfoToEmitData Info = { Name, MI, ID };
5318 MacroInfosToEmit.push_back(Info);
5327 assert(MacroIDs.find(MI) != MacroIDs.end() &&
"Macro not emitted!");
5328 return MacroIDs[MI];
5332 return IdentMacroDirectivesOffsetMap.lookup(Name);
5336 Record->push_back(Writer->getSelectorRef(SelRef));
5345 if (SID == 0 && Chain) {
5348 Chain->LoadSelector(Sel);
5349 SID = SelectorIDs[Sel];
5352 SID = NextSelectorID++;
5353 SelectorIDs[Sel] = SID;
5394 bool InfoHasSameExpr
5396 Record->push_back(InfoHasSameExpr);
5397 if (InfoHasSameExpr)
5415 TypeLocWriter TLW(*
this);
5432 if (Idx.getIndex() == 0) {
5433 if (DoneWritingDeclsAndTypes) {
5434 assert(0 &&
"New type seen after serializing all the types to emit!");
5441 DeclTypesToEmit.push(T);
5454 TypeIdxMap::const_iterator I = TypeIdxs.find(T);
5455 assert(I != TypeIdxs.end() &&
"Type not emitted!");
5465 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
5476 assert(!(reinterpret_cast<uintptr_t>(D) & 0x01) &&
"Invalid decl pointer");
5479 if (DoneWritingDeclsAndTypes) {
5480 assert(0 &&
"New decl seen after serializing all the decls to emit!");
5487 DeclTypesToEmit.push(const_cast<Decl *>(D));
5502 assert(DeclIDs.find(D) != DeclIDs.end() &&
"Declaration not emitted!");
5506 void ASTWriter::associateDeclWithFile(
const Decl *D,
DeclID ID) {
5519 if (isa<ParmVarDecl>(D))
5528 if (FID.isInvalid())
5532 DeclIDInFileInfo *&Info = FileDeclIDs[FID];
5534 Info =
new DeclIDInFileInfo();
5536 std::pair<unsigned, serialization::DeclID> LocDecl(Offset, ID);
5539 if (Decls.empty() || Decls.back().first <=
Offset) {
5540 Decls.push_back(LocDecl);
5544 LocDeclIDsTy::iterator I =
5545 std::upper_bound(Decls.begin(), Decls.end(), LocDecl, llvm::less_first());
5547 Decls.insert(I, LocDecl);
5590 "expected an anonymous declaration");
5594 auto It = AnonymousDeclarationNumbers.find(D);
5595 if (It == AnonymousDeclarationNumbers.end()) {
5598 AnonymousDeclarationNumbers[ND] = Number;
5601 It = AnonymousDeclarationNumbers.find(D);
5602 assert(It != AnonymousDeclarationNumbers.end() &&
5603 "declaration not found within its lexical context");
5642 AddDeclarationName(NameInfo.
getName());
5661 NestedNames.push_back(NNS);
5665 Record->push_back(NestedNames.size());
5666 while(!NestedNames.empty()) {
5667 NNS = NestedNames.pop_back_val();
5669 Record->push_back(Kind);
5708 NestedNames.push_back(NNS);
5712 Record->push_back(NestedNames.size());
5713 while(!NestedNames.empty()) {
5714 NNS = NestedNames.pop_back_val();
5717 Record->push_back(Kind);
5755 Record->push_back(Kind);
5763 Record->push_back(OvT->
size());
5764 for (
const auto &I : *OvT)
5807 Record->push_back(Arg.
getKind());
5831 Record->push_back(*NumExpansions + 1);
5833 Record->push_back(0);
5841 AddTemplateArgument(
P);
5848 assert(TemplateParams &&
"No TemplateParams!");
5853 Record->push_back(TemplateParams->
size());
5854 for (
const auto &
P : *TemplateParams)
5861 assert(TemplateArgs &&
"No TemplateArgs!");
5862 Record->push_back(TemplateArgs->
size());
5863 for (
int i = 0, e = TemplateArgs->
size(); i != e; ++i)
5864 AddTemplateArgument(TemplateArgs->
get(i));
5869 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
5875 AddTemplateArgumentLoc(TemplArgs[i]);
5879 Record->push_back(Set.
size());
5881 I = Set.
begin(), E = Set.
end(); I != E; ++I) {
5883 Record->push_back(I.getAccess());
5905 for (
auto &
Base : Bases)
5923 for (
auto *Init : CtorInits) {
5924 if (Init->isBaseInitializer()) {
5927 Writer.
push_back(Init->isBaseVirtual());
5928 }
else if (Init->isDelegatingInitializer()) {
5931 }
else if (Init->isMemberInitializer()){
5936 Writer.
AddDeclRef(Init->getIndirectMember());
5940 Writer.
AddStmt(Init->getInit());
5944 if (Init->isWritten())
5945 Writer.
push_back(Init->getSourceOrder());
5958 auto &Data = D->data();
5959 Record->push_back(Data.IsLambda);
5960 Record->push_back(Data.UserDeclaredConstructor);
5961 Record->push_back(Data.UserDeclaredSpecialMembers);
5962 Record->push_back(Data.Aggregate);
5963 Record->push_back(Data.PlainOldData);
5964 Record->push_back(Data.Empty);
5965 Record->push_back(Data.Polymorphic);
5966 Record->push_back(Data.Abstract);
5967 Record->push_back(Data.IsStandardLayout);
5968 Record->push_back(Data.HasNoNonEmptyBases);
5969 Record->push_back(Data.HasPrivateFields);
5970 Record->push_back(Data.HasProtectedFields);
5971 Record->push_back(Data.HasPublicFields);
5972 Record->push_back(Data.HasMutableFields);
5973 Record->push_back(Data.HasVariantMembers);
5974 Record->push_back(Data.HasOnlyCMembers);
5975 Record->push_back(Data.HasInClassInitializer);
5976 Record->push_back(Data.HasUninitializedReferenceMember);
5977 Record->push_back(Data.HasUninitializedFields);
5978 Record->push_back(Data.HasInheritedConstructor);
5979 Record->push_back(Data.HasInheritedAssignment);
5980 Record->push_back(Data.NeedOverloadResolutionForCopyConstructor);
5981 Record->push_back(Data.NeedOverloadResolutionForMoveConstructor);
5982 Record->push_back(Data.NeedOverloadResolutionForMoveAssignment);
5983 Record->push_back(Data.NeedOverloadResolutionForDestructor);
5984 Record->push_back(Data.DefaultedCopyConstructorIsDeleted);
5985 Record->push_back(Data.DefaultedMoveConstructorIsDeleted);
5986 Record->push_back(Data.DefaultedMoveAssignmentIsDeleted);
5987 Record->push_back(Data.DefaultedDestructorIsDeleted);
5988 Record->push_back(Data.HasTrivialSpecialMembers);
5989 Record->push_back(Data.DeclaredNonTrivialSpecialMembers);
5990 Record->push_back(Data.HasIrrelevantDestructor);
5991 Record->push_back(Data.HasConstexprNonCopyMoveConstructor);
5992 Record->push_back(Data.HasDefaultedDefaultConstructor);
5993 Record->push_back(Data.CanPassInRegisters);
5994 Record->push_back(Data.DefaultedDefaultConstructorIsConstexpr);
5995 Record->push_back(Data.HasConstexprDefaultConstructor);
5996 Record->push_back(Data.HasNonLiteralTypeFieldsOrBases);
5997 Record->push_back(Data.ComputedVisibleConversions);
5998 Record->push_back(Data.UserProvidedDefaultConstructor);
5999 Record->push_back(Data.DeclaredSpecialMembers);
6000 Record->push_back(Data.ImplicitCopyConstructorCanHaveConstParamForVBase);
6001 Record->push_back(Data.ImplicitCopyConstructorCanHaveConstParamForNonVBase);
6002 Record->push_back(Data.ImplicitCopyAssignmentHasConstParam);
6003 Record->push_back(Data.HasDeclaredCopyConstructorWithConstParam);
6004 Record->push_back(Data.HasDeclaredCopyAssignmentWithConstParam);
6008 bool ModulesDebugInfo = Writer->Context->getLangOpts().ModulesDebugInfo &&
6010 Record->push_back(ModulesDebugInfo);
6011 if (ModulesDebugInfo)
6012 Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(D));
6016 Record->push_back(Data.NumBases);
6017 if (Data.NumBases > 0)
6018 AddCXXBaseSpecifiers(Data.bases());
6021 Record->push_back(Data.NumVBases);
6022 if (Data.NumVBases > 0)
6023 AddCXXBaseSpecifiers(Data.vbases());
6025 AddUnresolvedSet(Data.Conversions.get(*Writer->Context));
6026 AddUnresolvedSet(Data.VisibleConversions.get(*Writer->Context));
6031 if (Data.IsLambda) {
6032 auto &Lambda = D->getLambdaData();
6033 Record->push_back(Lambda.Dependent);
6034 Record->push_back(Lambda.IsGenericLambda);
6035 Record->push_back(Lambda.CaptureDefault);
6036 Record->push_back(Lambda.NumCaptures);
6037 Record->push_back(Lambda.NumExplicitCaptures);
6038 Record->push_back(Lambda.ManglingNumber);
6040 AddTypeSourceInfo(Lambda.MethodTyInfo);
6041 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
6064 void ASTWriter::ReaderInitialized(
ASTReader *Reader) {
6065 assert(Reader &&
"Cannot remove chain");
6066 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
6067 assert(FirstDeclID == NextDeclID &&
6068 FirstTypeID == NextTypeID &&
6069 FirstIdentID == NextIdentID &&
6070 FirstMacroID == NextMacroID &&
6071 FirstSubmoduleID == NextSubmoduleID &&
6072 FirstSelectorID == NextSelectorID &&
6073 "Setting chain after writing has started.");
6085 NextDeclID = FirstDeclID;
6086 NextTypeID = FirstTypeID;
6087 NextIdentID = FirstIdentID;
6088 NextMacroID = FirstMacroID;
6089 NextSelectorID = FirstSelectorID;
6090 NextSubmoduleID = FirstSubmoduleID;
6095 IdentID &StoredID = IdentifierIDs[II];
6102 MacroID &StoredID = MacroIDs[MI];
6127 assert(MacroDefinitions.find(MD) == MacroDefinitions.end());
6128 MacroDefinitions[MD] =
ID;
6132 assert(SubmoduleIDs.find(Mod) == SubmoduleIDs.end());
6133 SubmoduleIDs[Mod] =
ID;
6136 void ASTWriter::CompletedTagDefinition(
const TagDecl *D) {
6137 if (Chain && Chain->isProcessingUpdateRecords())
return;
6139 assert(!WritingAST &&
"Already writing the AST!");
6140 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
6142 if (RD->isFromASTFile()) {
6147 "completed a tag from another module but not by instantiation?");
6148 DeclUpdates[RD].push_back(
6163 void ASTWriter::AddedVisibleDecl(
const DeclContext *DC,
const Decl *D) {
6164 if (Chain && Chain->isProcessingUpdateRecords())
return;
6166 "Should not add lookup results to non-lookup contexts!");
6169 if (isa<TranslationUnitDecl>(DC))
6177 !isa<FunctionTemplateDecl>(D))
6187 assert(!WritingAST &&
"Already writing the AST!");
6188 if (UpdatedDeclContexts.insert(DC) && !cast<Decl>(DC)->isFromASTFile()) {
6192 for (
auto *Child : DC->
decls())
6193 DeclsToEmitEvenIfUnreferenced.push_back(Child);
6195 DeclsToEmitEvenIfUnreferenced.push_back(D);
6198 void ASTWriter::AddedCXXImplicitMember(
const CXXRecordDecl *RD,
const Decl *D) {
6199 if (Chain && Chain->isProcessingUpdateRecords())
return;
6207 if (!isa<CXXMethodDecl>(D))
6212 assert(!WritingAST &&
"Already writing the AST!");
6216 void ASTWriter::ResolvedExceptionSpec(
const FunctionDecl *FD) {
6217 if (Chain && Chain->isProcessingUpdateRecords())
return;
6218 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
6220 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
6225 ->castAs<FunctionProtoType>()
6226 ->getExceptionSpecType()))
6232 if (Chain && Chain->isProcessingUpdateRecords())
return;
6233 assert(!WritingAST &&
"Already writing the AST!");
6235 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
6236 DeclUpdates[D].push_back(
6244 if (Chain && Chain->isProcessingUpdateRecords())
return;
6245 assert(!WritingAST &&
"Already writing the AST!");
6246 assert(Delete &&
"Not given an operator delete");
6248 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
6253 void ASTWriter::CompletedImplicitDefinition(
const FunctionDecl *D) {
6254 if (Chain && Chain->isProcessingUpdateRecords())
return;
6255 assert(!WritingAST &&
"Already writing the AST!");
6263 void ASTWriter::VariableDefinitionInstantiated(
const VarDecl *D) {
6264 if (Chain && Chain->isProcessingUpdateRecords())
return;
6265 assert(!WritingAST &&
"Already writing the AST!");
6272 void ASTWriter::FunctionDefinitionInstantiated(
const FunctionDecl *D) {
6273 if (Chain && Chain->isProcessingUpdateRecords())
return;
6274 assert(!WritingAST &&
"Already writing the AST!");
6281 void ASTWriter::InstantiationRequested(
const ValueDecl *D) {
6282 if (Chain && Chain->isProcessingUpdateRecords())
return;
6283 assert(!WritingAST &&
"Already writing the AST!");
6290 if (
auto *VD = dyn_cast<VarDecl>(D))
6291 POI = VD->getPointOfInstantiation();
6293 POI = cast<FunctionDecl>(D)->getPointOfInstantiation();
6297 void ASTWriter::DefaultArgumentInstantiated(
const ParmVarDecl *D) {
6298 if (Chain && Chain->isProcessingUpdateRecords())
return;
6299 assert(!WritingAST &&
"Already writing the AST!");
6303 DeclUpdates[D].push_back(
6307 void ASTWriter::DefaultMemberInitializerInstantiated(
const FieldDecl *D) {
6308 assert(!WritingAST &&
"Already writing the AST!");
6312 DeclUpdates[D].push_back(
6318 if (Chain && Chain->isProcessingUpdateRecords())
return;
6319 assert(!WritingAST &&
"Already writing the AST!");
6323 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
6324 ObjCClassesWithCategories.insert(
6328 void ASTWriter::DeclarationMarkedUsed(
const Decl *D) {
6329 if (Chain && Chain->isProcessingUpdateRecords())
return;
6330 assert(!WritingAST &&
"Already writing the AST!");
6342 void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(
const Decl *D) {
6343 if (Chain && Chain->isProcessingUpdateRecords())
return;
6344 assert(!WritingAST &&
"Already writing the AST!");
6351 void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
6353 if (Chain && Chain->isProcessingUpdateRecords())
return;
6354 assert(!WritingAST &&
"Already writing the AST!");
6358 DeclUpdates[D].push_back(
6362 void ASTWriter::RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M) {
6363 if (Chain && Chain->isProcessingUpdateRecords())
return;
6364 assert(!WritingAST &&
"Already writing the AST!");
6365 assert(D->
isHidden() &&
"expected a hidden declaration");
6369 void ASTWriter::AddedAttributeToRecord(
const Attr *Attr,
6371 if (Chain && Chain->isProcessingUpdateRecords())
return;
6372 assert(!WritingAST &&
"Already writing the AST!");
6378 void ASTWriter::AddedCXXTemplateSpecialization(
6380 assert(!WritingAST &&
"Already writing the AST!");
6384 if (Chain && Chain->isProcessingUpdateRecords())
6387 DeclsToEmitEvenIfUnreferenced.push_back(D);
6390 void ASTWriter::AddedCXXTemplateSpecialization(
6392 assert(!WritingAST &&
"Already writing the AST!");
6396 if (Chain && Chain->isProcessingUpdateRecords())
6399 DeclsToEmitEvenIfUnreferenced.push_back(D);
6404 assert(!WritingAST &&
"Already writing the AST!");
6408 if (Chain && Chain->isProcessingUpdateRecords())
6411 DeclsToEmitEvenIfUnreferenced.push_back(D);
A CXXConstCastExpr record.
unsigned char getOpaqueValue() const
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
TemplateTemplateParmDecl * getParameterPack() const
Retrieve the template template parameter pack being substituted.
A FriendTemplateDecl record.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Defines the clang::ASTContext interface.
A CompoundLiteralExpr record.
A NonTypeTemplateParmDecl record.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
TargetOptions & getTargetOpts() const
Retrieve the target options.
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
const FileEntry * OrigEntry
Reference to the file entry representing this ContentCache.
UnusedFileScopedDeclsType UnusedFileScopedDecls
The set of file scoped decls seen so far that have not been used and must warn if not used...
Record code for the preprocessor options table.
VarDecl * getCapturedVar() const
Retrieve the declaration of the local variable being captured.
const CXXDestructorDecl * getDestructor() const
unsigned getAnonymousDeclarationNumber(const NamedDecl *D)
uint64_t getMacroDirectivesOffset(const IdentifierInfo *Name)
An instance of this class is created to represent a function declaration or definition.
SourceRange getExceptionSpecRange() const
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
std::string Name
The name of this module.
bool isImplicit() const
Determine whether this was an implicit capture (not written between the square brackets introducing t...
NamespaceDecl * getStdNamespace() const
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimize off". If this location is invalid...
void VisitArrayType(const ArrayType *T)
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.
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
A UserDefinedLiteral record.
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
Source range/offset of a preprocessed entity.
ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl< char > &Buffer, MemoryBufferCache &PCMCache, ArrayRef< std::shared_ptr< ModuleFileExtension >> Extensions, bool IncludeTimestamps=true)
Create a new precompiled header writer that outputs to the given bitstream.
std::vector< std::pair< std::string, bool > > Macros
no exception specification
Record code for potentially unused local typedef names.
Smart pointer class that efficiently represents Objective-C method names.
Record code for map of Objective-C class definition IDs to the ObjC categories in a module that are a...
This is a discriminated union of FileInfo and ExpansionInfo.
An IndirectGotoStmt record.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
PointerType - C99 6.7.5.1 - Pointer Declarators.
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
QualType getElementType() const
QualType getPointeeType() const
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
bool hasTemplateKeyword() const
Whether the template name was prefixed by the "template" keyword.
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system...
A (possibly-)qualified type.
static void EmitBlockID(unsigned ID, const char *Name, llvm::BitstreamWriter &Stream, ASTWriter::RecordDataImpl &Record)
void * getAsOpaquePtr() const
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
The macro directives history for a particular identifier.
Represents a version number in the form major[.minor[.subminor[.build]]].
QualType getInjectedSpecializationType() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
Implements support for file system lookup, file system caching, and directory search management...
const DeclarationNameLoc & getInfo() const
SourceLocation getSpellingLoc() const
void AddToken(const Token &Tok, RecordDataImpl &Record)
Emit a token.
unsigned getNumExceptions() const
LateParsedTemplateMapT LateParsedTemplateMap
OpenCL supported extensions and optional core features.
A CXXStaticCastExpr record.
Defines the clang::FileManager interface and associated types.
time_t getModificationTime() const
Record code for the source manager line table information, which stores information about #line direc...
An AttributedStmt record.
A CXXReinterpretCastExpr record.
An OMPThreadPrivateDecl record.
bool isLookupContext() const
Test whether the context supports looking up names.
SourceLocation getKWLoc() const
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
An ObjCBoolLiteralExpr record.
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
submodule_iterator submodule_begin()
Expr * getUnderlyingExpr() const
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
FunctionType - C99 6.7.5.3 - Function Declarators.
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "C"...
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
void AddUnresolvedSet(const ASTUnresolvedSet &Set)
Emit a UnresolvedSet structure.
void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Emit a nested name specifier with source-location information.
C Language Family Type Representation.
Defines the SourceManager interface.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
static bool isImportedDeclContext(ASTReader *Chain, const Decl *D)
Represents a qualified type name for which the type name is dependent.
An OMPDeclareReductionDecl record.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
unsigned size() const
Retrieve the number of template arguments in this template argument list.
FileManager & getFileManager() const
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
RawCommentList Comments
All comments in this translation unit.
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
void GetUniqueIDMapping(SmallVectorImpl< const FileEntry *> &UIDToFiles) const
Produce an array mapping from the unique IDs assigned to each file to the corresponding FileEntry poi...
An ImplicitValueInitExpr record.
Defines the clang::Module class, which describes a module in the source code.
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
bool isLocalSourceLocation(SourceLocation Loc) const
Returns true if Loc did not come from a PCH/Module.
Decl - This represents one declaration (or definition), e.g.
An ImplicitCastExpr record.
TagDecl * getDecl() const
A VarTemplatePartialSpecializationDecl record.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
Selector getObjCSelector() const
getObjCSelector - Get the Objective-C selector stored in this declaration name.
unsigned IsFramework
Whether this is a framework module.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
ModuleKind Kind
The type of this module.
Defines the C++ template declaration subclasses.
Describes a source location entry (SLocEntry) for a macro expansion.
Represents a C++11 auto or C++14 decltype(auto) type.
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...
std::vector< std::string > Includes
bool makeAbsolutePath(SmallVectorImpl< char > &Path) const
Makes Path absolute taking into account FileSystemOptions and the working directory option...
An LValueReferenceType record.
static unsigned getNumberOfModules(Module *Mod)
Compute the number of modules within the given tree (including the given module). ...
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
Defines the clang::MacroInfo and clang::MacroDirective classes.
A CXXOperatorCallExpr record.
Defines types useful for describing an Objective-C runtime.
Specifies the submodules that are imported by this submodule.
std::string ModuleName
The name of the module.
A record that stores the set of declarations that are lexically stored within a given DeclContext...
Specifies an umbrella directory.
A CXXTemporaryObjectExpr record.
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate > > LateParsedTemplateMapT
QualType getsigjmp_bufType() const
Retrieve the C sigjmp_buf type.
Each ExpansionInfo encodes the expansion location - where the token was ultimately expanded...
DiagnosticsEngine & getDiagnostics() const
A SubstTemplateTypeParmType record.
Class that performs name lookup into a DeclContext stored in an AST file.
Writer for the on-disk hash table.
Declaration of a variable template.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamespaceDecl - Represent a C++ namespace.
A ObjCPropertyDecl record.
Wrapper for source info for typedefs.
serialization::DeclID GetDeclRef(const Decl *D)
Force a declaration to be emitted and get its ID.
const TargetInfo & getTargetInfo() const
A container of type source information.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Record code for enabled OpenCL extensions.
Record code for the module build directory.
Floating point control options.
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
time_t getTimestampForOutput(const FileEntry *E) const
Get a timestamp for output into the AST file.
void AddTypeRef(QualType T, RecordDataImpl &Record)
Emit a reference to a type.
An ElaboratedType record.
ObjCMethodDecl * getMethod() const
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
An UnresolvedUsingType record.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
static void AddStmtsExprs(llvm::BitstreamWriter &Stream, ASTWriter::RecordDataImpl &Record)
Wrapper for source info for pointers decayed from arrays and functions.
bool isPackExpansion() const
Determine whether this capture is a pack expansion, which captures a function parameter pack...
static uint64_t EmitCXXCtorInitializers(ASTWriter &W, ArrayRef< CXXCtorInitializer *> CtorInits)
Describes the capture of a variable or of this, or of a C++1y init-capture.
TemplateTypeParmDecl * getDecl() const
This is a module that was defined by a module map and built out of header files.
An IncompleteArrayType record.
The internal '__type_pack_element' template.
A template template parameter that has been substituted for some other template name.
Specifies a header that is part of the module but must be textually included.
uint64_t Emit(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, followed by its substatements, and return its offset.
IdentifierInfo * getAlias() const
bool hasBaseTypeAsWritten() const
QualType getElementType() const
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
bool hasLocalNonFastQualifiers() const
Determine whether this particular QualType instance has any "non-fast" qualifiers, e.g., those that are stored in an ExtQualType instance.
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
A ClassTemplateDecl record.
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
unsigned NumPreprocessedEntities
A PragmaDetectMismatchDecl record.
An UnresolvedUsingTypenameDecl record.
SourceLocation getRParenLoc() const
An identifier, stored as an IdentifierInfo*.
The internal '__builtin_va_list' typedef.
The stack of open #ifs/#ifdefs recorded in a preamble.
static uint64_t EmitCXXBaseSpecifiers(ASTWriter &W, ArrayRef< CXXBaseSpecifier > Bases)
Manages the set of modules loaded by an AST reader.
serialization::MacroID getMacroRef(MacroInfo *MI, const IdentifierInfo *Name)
Get the unique number used to refer to the given macro.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Record code for #pragma pack options.
A block with unhashed content.
std::string ImplicitPTHInclude
The implicit PTH input included at the start of the translation unit, or empty.
Wrapper for source info for member pointers.
An OMPCapturedExprDecl record.
void AddFunctionDefinition(const FunctionDecl *FD)
Add a definition for the given function to the queue of statements to emit.
unsigned getNumParams() const
Options for controlling the target.
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
Manage memory buffers across multiple users.
Record code for declarations associated with OpenCL extensions.
A UsingShadowDecl record.
Represents an empty template argument, e.g., one that has not been deduced.
QualType getRawCFConstantStringType() const
Get the structure type used to representation CFStrings, or NULL if it hasn't yet been built...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
SourceLocation getStarLoc() const
Represents a C++17 deduced template specialization type.
static unsigned CreateSLocFileAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a file.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
Represents a variable template specialization, which refers to a variable template with a given set o...
The value of the next COUNTER to dispense.
unsigned getNextLocalOffset() const
SourceLocation getLAngleLoc() const
A ConditionOperator record.
const DeclContext * getDefinitiveDeclContext(const DeclContext *DC)
Retrieve the "definitive" declaration that provides all of the visible entries for the given declarat...
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack...
Specifies the umbrella header used to create this module, if any.
SourceLocation getLBracketLoc() const
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
A namespace, stored as a NamespaceDecl*.
iterator local_end()
End iterator for local, non-loaded, preprocessed entities.
Record code for header search information.
Stores a list of template parameters for a TemplateDecl and its derived classes.
unsigned getODRHash() const
Describes a source location entry (SLocEntry) for a buffer.
Used to hold and unique data used to represent #line information.
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
A CXXConstructExpr record.
Record code for the target options table.
serialization::IdentID getIdentifierRef(const IdentifierInfo *II)
Get the unique number used to refer to the given identifier.
static StringRef bytes(const std::vector< T, Allocator > &v)
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
bool hasLineDirectives() const
Return true if this FileID has #line directives in it.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
A TemplateTemplateParmDecl record.
Record code for the array of eagerly deserialized decls.
Expr * getAttrExprOperand() const
The attribute's expression operand, if it has one.
ParmVarDecl - Represents a parameter to a function.
Represents the result of substituting a type for a template type parameter.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
OpenCLOptions & getOpenCLOptions()
Defines the clang::Expr interface and subclasses for C++ expressions.
FPOptions & getFPOptions()
const llvm::MapVector< FieldDecl *, DeleteLocs > & getMismatchingDeleteExpressions() const
Retrieves list of suspicious delete-expressions that will be checked at the end of translation unit...
A ObjCInterfaceDecl record.
QualType getIntegralType() const
Retrieve the type of the integral value.
const MacroDirective * getPrevious() const
Get previous definition of the macro with the same name.
tok::TokenKind getKind() const
void AddSourceRange(SourceRange Range)
Emit a source range.
void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record)
Emit a reference to an identifier.
SourceLocation getAmpAmpLoc() const
The collection of all-type qualifiers we support.
A ShuffleVectorExpr record.
bool needsExtraLocalData() const
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
ModuleKind Kind
The kind of this module.
void AddTypeSourceInfo(TypeSourceInfo *TInfo)
Emits a reference to a declarator info.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
SourceLocation getAttributeLoc() const
Base wrapper for a particular "section" of type source info.
A CXXConstructorDecl record for an inherited constructor.
RecordDecl - Represents a struct/union/class.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
QualType getOriginalType() const
TypeSpecifierSign getWrittenSignSpec() const
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
ArrayRef< PPConditionalInfo > getPreambleConditionalStack() const
A macro directive exported by a module.
An ObjCAtThrowStmt record.
FileManager & getFileManager() const
Specifies a top-level header that falls into this (sub)module.
The block containing comments.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
void AddTypeRef(QualType T)
Emit a reference to a type.
A DesignatedInitExpr record.
The Objective-C 'SEL' type.
unsigned getRegParm() const
Represents a class type in Objective C.
T * getFETokenInfo() const
getFETokenInfo/setFETokenInfo - The language front-end is allowed to associate arbitrary metadata wit...
Iteration over the preprocessed entities.
QualType getPointeeType() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
Record the location of a macro definition.
Represents a dependent template name that cannot be resolved prior to template instantiation.
The results of name lookup within a DeclContext.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
TypeSourceInfo * getUnderlyingTInfo() const
void resolveHeaderDirectives(const FileEntry *File) const
Resolve all lazy header directives for the specified file.
An ObjCProtocolExpr record.
bool isSpelledAsLValue() const
An ObjCSelectorExpr record.
Specifies a header that has been explicitly excluded from this submodule.
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
SmallVector< Requirement, 2 > Requirements
The set of language features required to use this module.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
bool isCPlusPlusOperatorKeyword() const
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
The unsigned 128-bit integer type.
Record code for the module map file that was used to build this AST file.
One instance of this struct is kept for every file loaded or used.
SourceLocation getProtocolLAngleLoc() const
Delete expressions that will be analyzed later.
bool hasCommaPasting() const
NestedNameSpecifierLoc getQualifierLoc() const
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
Optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce...
CXXRecordDecl * getStdBadAlloc() const
The iterator over UnresolvedSets.
Represents the result of substituting a set of types for a template type parameter pack...
Token - This structure provides full information about a lexed token.
SourceLocation getProtocolRAngleLoc() const
ParmVarDecl * getParam(unsigned i) const
ASTReader * getChain() const
static unsigned CreateSLocExpansionAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a macro expansion.
Wrapper for source info for unresolved typename using decls.
SourceLocation getRParenLoc() const
An AttributedType record.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
An object-like macro definition.
unsigned IsTransient
True if this file may be transient, that is, if it might not exist at some later point in time when t...
The signature of a module, which is a hash of the AST content.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
void AddTemplateParameterList(const TemplateParameterList *TemplateParams)
Emit a template parameter list.
SourceLocation getTemplateLoc() const
const LangOptions & getLangOpts() const
TemplateName getReplacement() const
Expr * getAttrExprOperand() const
The attribute's expression operand, if it has one.
for(const auto &A :T->param_types())
QualType getParamTypeForDecl() const
Describes a module or submodule.
SourceLocation getLParenLoc() const
unsigned getTypeQuals() const
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
A IndirectFieldDecl record.
Record code for the set of ext_vector type names.
iterator end()
end - Returns an iterator that has 'finished'.
void VisitTagType(const TagType *T)
bool getProducesResult() const
serialization::MacroID getMacroID(MacroInfo *MI)
Determine the ID of an already-emitted macro.
static ModuleHeaderRole headerKindToRole(Module::HeaderKind Kind)
Convert a header kind to a role. Requires Kind to not be HK_Excluded.
SourceLocation getLAngleLoc() const
TypeSpecifierWidth getWrittenWidthSpec() const
Specifies the submodules that are re-exported from this submodule.
TemplateParameterList ** TemplParamLists
TemplParamLists - A new-allocated array of size NumTemplParamLists, containing pointers to the "outer...
serialization::MacroID BaseMacroID
Base macro ID for macros local to this module.
An rvalue reference type, per C++11 [dcl.ref].
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
UnresolvedUsingTypenameDecl * getDecl() const
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
The Objective-C 'id' type.
unsigned InferExportWildcard
Whether, when inferring submodules, the inferr submodules should export all modules they import (e...
A qualified template name, where the qualification is kept to describe the source code as written...
SourceLocation getLParenLoc() const
Wrapper for source info for injected class names of class templates.
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
< Capturing the *this object by copy
HeaderSearch & getHeaderSearchInfo() const
An AccessSpecDecl record.
unsigned getNumProtocols() const
const Token & getReplacementToken(unsigned Tok) const
SourceLocation getProtocolLoc(unsigned i) const
Describes a blob that contains the data for a buffer entry.
const FileInfo & getFile() const
Record code for the language options table.
QualType getExceptionType(unsigned i) const
bool getInheritConstructors() const
Determine whether this base class's constructors get inherited.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Wrapper for source info for functions.
Specifies a conflict with another module.
The signed 128-bit integer type.
unsigned getHash() const
Compute a fingerprint of this key for use in on-disk hash table.
StoredDeclsMap * buildLookup()
Ensure the lookup structure is fully-built and return it.
A UnaryTransformType record.
A reference to a previously [de]serialized Stmt record.
SourceRange getLocalSourceRange() const
Retrieve the source range covering just the last part of this nested-name-specifier, not including the prefix.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
A UsingDirecitveDecl record.
SourceLocation getElaboratedKeywordLoc() const
An ObjCObjectType record.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
A ConstantArrayType record.
Wrapper for substituted template type parameters.
Concrete class used by the front-end to report problems and issues.
Represents a typeof (or typeof) expression (a GCC extension).
Record code for #pragma optimize options.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
void AddSourceRange(SourceRange Range, RecordDataImpl &Record)
Emit a source range.
Specifies a header that is private to this submodule but must be textually included.
Optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
Record code for pending implicit instantiations.
Wrapper for substituted template type parameters.
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
The internal '__make_integer_seq' template.
ASTTypeWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
SourceLocation getLParenLoc() const
Module * Parent
The parent of this module.
const Type * getClass() const
Record code for floating point #pragma options.
CXXRecordDecl * getDecl() const
void AddTypeLoc(TypeLoc TL)
Emits a type with source-location information.
Defines the Diagnostic-related interfaces.
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
SourceLocation getTemplateKeywordLoc() const
Expr * getSizeExpr() const
Wrapper for source info for ObjC interfaces.
Record code for the set of known namespaces, which are used for typo correction.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
TypeID MakeTypeID(ASTContext &Context, QualType T, IdxForTypeTy IdxForType)
bool hasRevertedBuiltin() const
True if setNotBuiltin() was called.
Record code for an array of all of the (sub)modules that were imported by the AST file...
submodule_iterator submodule_end()
serialization::DeclID BaseDeclID
Base declaration ID for declarations local to this module.
unsigned getInt() const
Used to serialize this.
import_range local_imports() const
std::vector< std::string > Warnings
The list of -W...
A marker record that indicates that we are at the end of an expression.
A ClassTemplateSpecializationDecl record.
bool isUsed() const
Return false if this macro is defined in the main file and has not yet been used. ...
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
SourceLocation getNameLoc() const
TemplateTemplateParmDecl * getParameter() const
A BlockPointerType record.
uint32_t getIndex() const
SmallVector< uint64_t, 64 > RecordData
A MemberPointerType record.
TemplateArgumentLoc getArgLoc(unsigned i) const
Represents an ObjC class declaration.
SourceLocation getIncludeLoc() const
unsigned getNumArgs() const
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
SourceLocation getProtocolRAngleLoc() const
A DependentSizedExtVectorType record.
SmallVectorImpl< uint64_t > RecordDataImpl
SourceLocation getElaboratedKeywordLoc() const
unsigned getLength() const
Efficiently return the length of this identifier info.
Expr * getSizeExpr() const
Record code for the table of offsets into the block of source-location information.
bool isMacroArgExpansion() const
bool getNoCallerSavedRegs() const
QualType getPointeeTypeAsWritten() const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
unsigned getNumProtocols() const
Return the number of qualifying protocols in this type, or 0 if there are none.
QualType getElementType() const
Represents an extended vector type where either the type or size is dependent.
A SubstTemplateTypeParmPackType record.
TypeCode
Record codes for each kind of type.
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
Iterator that walks over the list of categories, filtering out those that do not meet specific criter...
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
SourceLocation getTemplateEllipsisLoc() const
SourceLocation getTemplateKeywordLoc() const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
unsigned IsSystem
Whether this is a "system" module (which assumes that all headers in it are system headers)...
The block containing information about the source manager.
Expr * getAddrSpaceExpr() const
bool DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
A VariableArrayType record.
unsigned local_sloc_entry_size() const
Get the number of local SLocEntries we have.
QualType getBaseType() const
Gets the base type of this object type.
SourceLocation getBuiltinLoc() const
unsigned getLocalFastQualifiers() const
bool hasExternalDecls() const
Sema - This implements semantic analysis and AST building for C.
const unsigned int NUM_PREDEF_PP_ENTITY_IDS
The number of predefined preprocessed entity IDs.
bool hasChangedSinceDeserialization() const
Determine whether this identifier has changed since it was loaded from an AST file.
unsigned NumTemplParamLists
NumTemplParamLists - The number of "outer" template parameter lists.
FunctionDecl * getExceptionSpecDecl() const
If this function type has an exception specification which hasn't been determined yet (either because...
Represents a prototype with parameter type info, e.g.
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Defines the major attributes of a submodule, including its name and parent.
void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc, DeclarationName Name)
std::string CurrentModule
The name of the current module, of which the main source file is a part.
void AddCXXTemporary(const CXXTemporary *Temp)
Emit a CXXTemporary.
ModuleHeaderRole
Flags describing the role of a module header.
OverloadedOperatorKind getOperatorKind() const
SourceLocation getNameLoc() const
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
llvm::SmallSetVector< Module *, 2 > Imports
The set of modules imported by this module, and on which this module depends.
A dependent template name that has not been resolved to a template (or set of templates).
DeclarationNameTable DeclarationNames
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
unsigned LocalNumSLocEntries
The number of source location entries in this AST file.
ObjCTypeParamDecl * getDecl() const
bool isInlineSpecified() const
A StaticAssertDecl record.
Captures information about a #pragma weak directive.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
void AddPath(StringRef Path, RecordDataImpl &Record)
Add a path to the given record.
A VarTemplateSpecializationDecl record.
Record code for the table of offsets of each macro ID.
unsigned getNumParams() const
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...
llvm::MemoryBuffer & addBuffer(llvm::StringRef Filename, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Store the Buffer under the Filename.
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
An ObjCTypeParamDecl record.
Exposes information about the current target.
A record containing CXXBaseSpecifiers.
Represents an array type in C++ whose size is a value-dependent expression.
CommentOptions CommentOpts
Options for parsing comments.
SourceLocation getTemplateNameLoc() const
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Specifies some declarations with initializers that must be emitted to initialize the module...
An ObjCObjectPointerType record.
An TemplateSpecializationType record.
File is from a prebuilt module path.
QualType getElementType() const
Type source information for an attributed type.
An ObjCInterfaceType record.
unsigned getNumArgs() const
Retrieve the number of template arguments.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
llvm::MemoryBuffer * getBuffer(DiagnosticsEngine &Diag, const SourceManager &SM, SourceLocation Loc=SourceLocation(), bool *Invalid=nullptr) const
Returns the memory buffer for the associated content.
Describes a zlib-compressed blob that contains the data for a buffer entry.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
A ObjCCategoryImplDecl record.
Defines the clang::LangOptions interface.
unsigned getCounterValue() const
SourceLocation getLocalRangeEnd() const
TemplateDecl * getTemplateDecl() const
The template declaration to which this qualified name refers.
Record code for the array of VTable uses.
ObjCMethodList * getNext() const
static bool isInterestingIdentifier(ASTReader &Reader, IdentifierInfo &II, bool IsModule)
Whether the given identifier is "interesting".
QualType getucontext_tType() const
Retrieve the C ucontext_t type.
The directory that the PCH was originally created in.
unsigned getAsOpaqueValue() const
A ObjCPropertyImplDecl record.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
const FunctionProtoType * T
unsigned getIndex() const
std::string WorkingDir
If set, paths are resolved as if the working directory was set to the value of WorkingDir.
NamespaceDecl * getAnonymousNamespace() const
unsigned LocalNumIdentifiers
The number of identifiers in this AST file.
void AddCXXDefinitionData(const CXXRecordDecl *D)
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
std::string OMPHostIRFile
Name of the IR file that contains the result of the OpenMP target host code generation.
Implements an efficient mapping from strings to IdentifierInfo nodes.
Defines implementation details of the clang::SourceManager class.
bool getHasRegParm() const
StoredDeclsMap * getLookupPtr() const
Retrieve the internal representation of the lookup structure.
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
unsigned ConfigMacrosExhaustive
Whether the set of configuration macros is exhaustive.
Record code for the table of offsets to entries in the preprocessing record.
Represents a C++ destructor within a class.
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Selector getSelector() const
A CXXConstructorDecl record.
Defines version macros and version-related utility functions for Clang.
const FileEntry * ContentsEntry
References the file which the contents were actually loaded from.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Defines the clang::Preprocessor interface.
ArgKind
The kind of template argument we're storing.
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
The block containing the detailed preprocessing record.
llvm::MapVector< IdentifierInfo *, WeakInfo > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
Record code for #pragma diagnostic mappings.
bool isFileContext() const
serialization::TypeID GetOrCreateTypeID(QualType T)
Force a type to be emitted and get its ID.
DeclContext * getDeclContext()
A structure for storing the information associated with a substituted template template parameter...
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
unsigned LocalNumMacros
The number of macros in this AST file.
SourceLocation getCaretLoc() const
A CXXStdInitializerListExpr record.
SourceLocation getEllipsisLoc() const
A record containing CXXCtorInitializers.
ArrayRef< const FileEntry * > getTopHeaders(FileManager &FileMgr)
The top-level headers associated with this module.
A VarTemplateDecl record.
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Record code for the original file that was used to generate the AST file, including both its file ID ...
An ArraySubscriptExpr record.
Represents a C++ template name within the type system.
llvm::Optional< PreambleSkipInfo > getPreambleSkipInfo() const
llvm::SmallVector< LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used...
Represents the type decltype(expr) (C++11).
Information about a module that has been loaded by the ASTReader.
QualType getFILEType() const
Retrieve the C FILE type.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
A namespace alias, stored as a NamespaceAliasDecl*.
void AddString(StringRef Str, RecordDataImpl &Record)
Add a string to the given record.
Record code for the diagnostic options table.
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
A CXXDestructorDecl record.
unsigned getLocalOrImportedSubmoduleID(Module *Mod)
Retrieve or create a submodule ID for this module, or return 0 if the submodule is neither local (a s...
A FunctionProtoType record.
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack...
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Describes a source location entry (SLocEntry) for a file.
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
SourceLocation getLocalRangeBegin() const
Wrapper for source info for enum types.
A block containing a module file extension.
SourceLocation getProtocolLAngleLoc() const
clang::ObjCRuntime ObjCRuntime
std::string FileName
The file name of the module file.
A NamespaceAliasDecl record.
Record code for an update to a decl context's lookup table.
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Record code for #pragma ms_struct options.
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
QualType getRecordType(const RecordDecl *Decl) const
const unsigned VERSION_MINOR
AST file minor version number supported by this version of Clang.
void AddQualifierInfo(const QualifierInfo &Info)
A DesignatedInitUpdateExpr record.
void AddStmt(Stmt *S)
Add the given statement or expression to the queue of statements to emit.
SourceLocation getEnd() const
void AddSelectorRef(Selector S)
Emit a Selector (which is a smart pointer reference).
Represents a GCC generic vector type.
ArraySizeModifier getSizeModifier() const
struct CXXOpName CXXOperatorName
An lvalue reference type, per C++11 [dcl.ref].
bool isBaseOfClass() const
Determine whether this base class is a base of a class declared with the 'class' keyword (vs...
An ImplicitParamDecl record.
unsigned getNumArgs() const
bool isAvailable() const
Determine whether this module is available for use within the current translation unit...
bool isObjectLike() const
unsigned SLocEntryBaseOffset
The base offset in the source manager's view of this module.
An EnumConstantDecl record.
Record code for the table of offsets of each identifier ID.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
Record code for undefined but used functions and variables that need a definition in this TU...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
A DependentNameType record.
Abstract base class that writes a module file extension block into a module file. ...
SourceLocation getLocation() const
An ImportDecl recording a module import.
A ObjCCategoryDecl record.
An ObjCPropertyRefExpr record.
const ExpansionInfo & getExpansion() const
unsigned getOffset() const
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
An ObjCForCollectionStmt record.
Expr * getUnderlyingExpr() const
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Record code for the identifier table.
bool isRecordingPreamble() const
A FileScopeAsmDecl record.
A ObjCCompatibleAliasDecl record.
bool hasAttrExprOperand() const
TypeSourceInfo * getAsTypeSourceInfo() const
SmallVector< ExportDecl, 2 > Exports
The set of export declarations.
DelegatingCtorDeclsType DelegatingCtorDecls
All the delegating constructors seen so far in the file, used for cycle detection at the end of the T...
std::string CPU
If given, the name of the target CPU to generate code for.
A MS-style AsmStmt record.
SourceManager & getSourceManager() const
bool hasTrailingReturn() const
const DirectoryEntry * Directory
The build directory of this module.
void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record)
Emit a source location.
void push_back(uint64_t N)
Minimal vector-like interface.
bool capturesVariable() const
Determine whether this capture handles a variable.
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
The Objective-C 'Class' type.
SpecifierKind
The kind of specifier that completes this nested name specifier.
NestedNameSpecifierLoc getTemplateQualifierLoc() const
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
SourceLocation getExpansionLocEnd() const
Defines the clang::OpenCLOptions class.
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
A template template parameter pack that has been substituted for a template template argument pack...
Wrapper for source info for arrays.
Record code for the set of source location entries that need to be preloaded by the AST reader...
QualifierInfo - A struct with extended info about a syntactic name qualifier, to be used for the case...
Information about a FileID, basically just the logical file that it represents and include stack info...
The list of delegating constructor declarations.
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
Record code for types associated with OpenCL extensions.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
SourceLocation getTemplateNameLoc() const
DeclContext::lookup_result getLookupResult()
getLookupResult - Return an array of all the decls that this list represents.
Encapsulates changes to the "macros namespace" (the location where the macro name became active...
An UnresolvedUsingValueDecl record.
serialization::TypeID BaseTypeIndex
Base type ID for types local to this module as represented in the global type ID space.
std::string ABI
If given, the name of the target ABI to use.
ExtParameterInfo getExtParameterInfo(unsigned I) const
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
ElaboratedTypeKeyword getKeyword() const
const ContentCache * getContentCache() const
serialization::IdentID BaseIdentifierID
Base identifier ID for identifiers local to this module.
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis for a capture that is a pack expansion.
Encodes a location in the source.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
SourceLocation getStarLoc() const
Sugar for parentheses used when specifying types.
QualType getAdjustedType() const
QualType getReturnType() const
SourceLocation CurrentPragmaLocation
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, const TemplateArgumentLocInfo &Arg)
Emits a template argument location info.
StringRef getName() const
FileSystemOptions & getFileSystemOpts()
Returns the current file system options.
A record that stores the set of declarations that are visible from a given DeclContext.
Specifies a library or framework to link against.
Record code for file ID of the file or buffer that was used to generate the AST file.
Represents a C++ temporary.
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
Specifies a header that falls into this (sub)module.
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
std::string ExportAsModule
The module through which entities defined in this module will eventually be exposed, for use in "private" modules.
A structure for storing an already-substituted template template parameter pack.
Record code for special CUDA declarations.
MacroDirective * getLocalMacroDirectiveHistory(const IdentifierInfo *II) const
Given an identifier, return the latest non-imported macro directive for that identifier.
Options for controlling the compiler diagnostics engine.
A list of "interesting" identifiers.
The block of configuration options, used to check that a module is being used in a configuration comp...
void AddDeclarationName(DeclarationName Name)
Emit a declaration name.
unsigned IsSystemFile
True if this content cache was initially created for a source file considered as a system one...
DeclarationName getName() const
getName - Returns the embedded declaration name.
void AddOffset(uint64_t BitOffset)
Add a bit offset into the record.
TagDecl - Represents the declaration of a struct/union/class/enum.
TemplateArgument getArgumentPack() const
ASTContext & getASTContext() const LLVM_READONLY
CallingConv getCC() const
QualType getElementType() const
IdentifierInfo * getIdentifierInfo() const
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
virtual void writeExtensionContents(Sema &SemaRef, llvm::BitstreamWriter &Stream)=0
Write the contents of the extension block into the given bitstream.
This is so that older clang versions, before the introduction of the control block, can read and reject the newer PCH format.
IdentifierTable & getIdentifierTable()
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Cached information about one file (either on disk or in the virtual file system). ...
Metadata describing this particular extension.
const SrcMgr::SLocEntry & getLocalSLocEntry(unsigned Index, bool *Invalid=nullptr) const
Get a local SLocEntry. This is exposed for indexing.
static bool shouldIgnoreMacro(MacroDirective *MD, bool IsModule, const Preprocessor &PP)
An ObjCTypeParamType record.
SmallVector< Header, 2 > Headers[5]
The headers that are part of this module.
A CXXFunctionalCastExpr record.
std::vector< std::string > Remarks
The list of -R...
A FloatingLiteral record.
Record code for the offsets of each decl.
Metadata for submodules as a whole.
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location...
bool isModuleMap(CharacteristicKind CK)
Determine whether a file characteristic is for a module map.
void AddTemplateArgument(const TemplateArgument &Arg)
Emit a template argument.
An ObjCEncodeExpr record.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
Record code for late parsed template functions.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
SourceLocation getRParenLoc() const
bool isPackExpansion() const
Determine whether this base specifier is a pack expansion.
Defines the clang::TargetOptions class.
A TemplateTypeParmDecl record.
bool isParameterPack() const
bool isPoisoned() const
Return true if this token has been poisoned.
An ImaginaryLiteral record.
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings startin...
unsigned LocalNumDecls
The number of declarations in this AST file.
ObjCCategoryDecl - Represents a category declaration.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
bool SawDateOrTime() const
Returns true if the preprocessor has seen a use of DATE or TIME in the file so far.
QualType getEquivalentType() const
Expr * getNoexceptExpr() const
The internal 'instancetype' typedef.
SourceLocation getStarLoc() const
void AddNestedNameSpecifier(NestedNameSpecifier *NNS)
Emit a nested name specifier.
serialization::TypeID getTypeID(QualType T) const
Determine the type ID of an already-emitted type.
QualType getInnerType() const
IdentifierInfo * getIdentifier() const
Describes the categories of an Objective-C class.
The AST block, which acts as a container around the full AST block.
A DeducedTemplateSpecializationType record.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
uint32_t TypeID
An ID number that refers to a type in an AST file.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
void AddAttributes(ArrayRef< const Attr *> Attrs)
Emit a list of attributes.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line...
const unsigned int DECL_UPDATES
Record of updates for a declaration that was modified after being deserialized.
const LangOptions & getLangOpts() const
void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record)
Add a version tuple to the given record.
void updateOutOfDateSelector(Selector Sel)
void AddSourceLocation(SourceLocation Loc)
Emit a source location.
AutoTypeKeyword getKeyword() const
TypeClass getTypeClass() const
static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob, unsigned SLocBufferBlobCompressedAbbrv, unsigned SLocBufferBlobAbbrv)
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
An InjectedClassNameType record.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
Record code for the extra statistics we gather while generating an AST file.
SourceLocation getRAngleLoc() const
FunctionDecl * getcudaConfigureCallDecl()
SourceLocation getRAngleLoc() const
bool isC99Varargs() const
SourceLocation getExpansionLocStart() const
SourceRange getBracketsRange() const
An array of decls optimized for the common case of only containing one entry.
void AddAPFloat(const llvm::APFloat &Value)
Emit a floating-point value.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
bool PreparePathForOutput(SmallVectorImpl< char > &Path)
Convert a path from this build process into one that is appropriate for emission in the module file...
const VersionTuple & getVersion() const
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
unsigned LocalNumSubmodules
The number of submodules in this module.
TypeSourceInfo * getTypeSourceInfo() const
Retrieves the type and source location of the base class.
unsigned ComputeHash(Selector Sel)
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
Record code for the signature that identifiers this AST file.
Record code for referenced selector pool.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
std::vector< std::string > MacroIncludes
Represents a pointer type decayed from an array or function type.
const MacroInfo * getMacroInfo() const
void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
The injected class name of a C++ class template or class template partial specialization.
Record code for the set of non-builtin, special types.
QualType getPointeeType() const
A ObjCProtocolDecl record.
Represents a pack expansion of types.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Defines various enumerations that describe declaration and type specifiers.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
ArrayRef< Decl * > getModuleInitializers(Module *M)
Get the initializations to perform when importing a module, if any.
StringRef getName() const
Return the actual identifier string.
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
static void addExceptionSpec(const FunctionProtoType *T, ASTRecordWriter &Record)
Base class for declarations which introduce a typedef-name.
void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset)
Note that the identifier II occurs at the given offset within the identifier table.
unsigned LocalNumSelectors
The number of selectors new to this file.
unsigned getObjCOrBuiltinID() const
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
SourceLocation getTypeofLoc() const
Represents a template argument.
Record code for the list of other AST files imported by this AST file.
A CXXConversionDecl record.
Describes a macro definition within the preprocessing record.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
TypeSourceInfo * getClassTInfo() const
Represents a template name that was expressed as a qualified name.
The internal '__NSConstantString' typedef.
Record code for the module name.
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Dataflow Directional Tag Classes.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getRBracketLoc() const
An IntegerLiteral record.
Describes an inclusion directive within the preprocessing record.
Optional< unsigned > getSubminor() const
Retrieve the subminor version number, if provided.
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
The internal '__builtin_ms_va_list' typedef.
ExtInfo getExtInfo() const
const TemplateArgument & getArgument() const
unsigned getNumTokens() const
Return the number of tokens that this macro expands to.
not evaluated yet, for special member function
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
NestedNameSpecifier * getQualifier() const
Record code for a file sorted array of DeclIDs in a module.
A CXXBoolLiteralExpr record.
Record code for the array of Objective-C categories (including extensions).
SourceLocation getTemplateNameLoc() const
Specifies a configuration macro for this module.
virtual ModuleFileExtensionMetadata getExtensionMetadata() const =0
Retrieves the metadata for this module file extension.
bool isInitKnownICE() const
Determines whether it is already known whether the initializer is an integral constant expression or ...
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
QualType getType() const
Get the type for which this source info wrapper provides information.
An ExtVectorElementExpr record.
The template argument is a pack expansion of a template name that was provided for a template templat...
Record code for the array of unused file scoped decls.
void AddCXXBaseSpecifiers(ArrayRef< CXXBaseSpecifier > Bases)
Emit a set of C++ base specifiers.
PreprocessingRecord * getPreprocessingRecord() const
Retrieve the preprocessing record, or NULL if there is no preprocessing record.
llvm::iterator_range< submodule_iterator > submodules()
A FunctionNoProtoType record.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
Reads an AST files chain containing the contents of a translation unit.
File is an explicitly-loaded module.
ArrayRef< KnownHeader > findAllModulesForHeader(const FileEntry *File) const
Retrieve all the modules that contain the given header file.
A ClassTemplatePartialSpecializationDecl record.
An ObjCIvarRefExpr record.
TemplateArgumentLoc getArgLoc(unsigned i) const
ModuleFileExtension * getExtension() const
Retrieve the module file extension with which this writer is associated.
const Expr * getInit() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
FileID getMainFileID() const
Returns the FileID of the main source file.
QualType getUnderlyingType() const
LambdaCaptureKind getCaptureKind() const
Determine the kind of capture.
SourceLocation getRAngleLoc() const
void AddCXXCtorInitializers(ArrayRef< CXXCtorInitializer *> CtorInits)
Emit a CXXCtorInitializer array.
unsigned getMajor() const
Retrieve the major version number.
DeclarationName - The name of a declaration.
A ClassScopeFunctionSpecializationDecl record a class scope function specialization.
VectorKind getVectorKind() const
Record code for the Objective-C method pool,.
bool isExtensionToken() const
get/setExtension - Initialize information about whether or not this language token is an extension...
static unsigned CreateSLocBufferAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a buffer.
A CharacterLiteral record.
Specifies a header that is private to this submodule.
A LinkageSpecDecl record.
Describes a macro expansion within the preprocessing record.
An ObjCStringLiteral record.
A CXXDynamicCastExpr record.
A CXXForRangeStmt record.
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
SourceLocation getLocation() const
A pointer to member type per C++ 8.3.3 - Pointers to members.
IdentifierResolver IdResolver
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
An RValueReferenceType record.
A type that was preceded by the 'template' keyword, stored as a Type*.
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
unsigned getLength() const
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
An ObjCAtFinallyStmt record.
NestedNameSpecifierLoc getQualifierLoc() const
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...
SourceLocation getElaboratedKeywordLoc() const
QualType getModifiedType() const
unsigned getNumParams() const
SourceLocation getRBracketLoc() const
bool hasAttrEnumOperand() const
Represents a pointer to an Objective C object.
Number of unmatched #pragma clang cuda_force_host_device begin directives we've seen.
Encapsulates the data about a macro definition (e.g.
Capturing variable-length array type.
A PragmaCommentDecl record.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
struct CXXLitOpName CXXLiteralOperatorName
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
unsigned getIndexTypeCVRQualifiers() const
unsigned getNumArgs() const
Retrieve the number of template arguments.
std::vector< Conflict > Conflicts
The list of conflicts.
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
Record code for the table of offsets into the Objective-C method pool.
QualType getCanonicalTypeInternal() const
Defines the clang::FileSystemOptions interface.
A DependentSizedArrayType record.
Record code for the remapping information used to relate loaded modules to the various offsets and ID...
An ObjCAtSynchronizedStmt record.
SourceLocation getTemplateNameLoc() const
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
A key used when looking up entities by DeclarationName.
SourceLocation getKWLoc() const
SourceLocation getRParenLoc() const
An UnresolvedSet-like class which uses the ASTContext's allocator.
Record code for declarations that Sema keeps references of.
const llvm::APInt & getSize() const
A SizefAlignOfExpr record.
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
Offsets into the input-files block where input files reside.
A CXXMemberCallExpr record.
ExtVectorType - Extended vector type.
SourceLocation getProtocolLoc(unsigned i) const
Expr * getSizeExpr() const
void AddAPSInt(const llvm::APSInt &Value)
Emit a signed integral value.
unsigned getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
The block containing the submodule structure.
Wrapper for source info for record types.
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
SourceLocation getLBracketLoc() const
The template argument is a type.
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
Wraps an ObjCPointerType with source location information.
QualType getUnderlyingType() const
unsigned getNumArgs() const
SourceLocation getDefinitionLoc() const
Return the location that the macro was defined at.
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
serialization::SelectorID getSelectorRef(Selector Sel)
Get the unique number used to refer to the given selector.
The template argument is actually a parameter pack.
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
Capturing the *this object by reference.
void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record, StringRef Path)
Emit the current record with the given path as a blob.
Represents a base class of a C++ class.
PreprocessorOptions & getPreprocessorOpts() const
Retrieve the preprocessor options used to initialize this preprocessor.
SourceLocation getLParenLoc() const
unsigned BufferOverridden
Indicates whether the buffer itself was provided to override the actual file contents.
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
SourceManager & getSourceManager()
Keeps track of options that affect how file operations are performed.
SourceLocation getDefinitionEndLoc() const
Return the location of the last token in the macro.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
EnumDecl * getStdAlignValT() const
A template argument list.
SourceLocation getModuleImportLoc(Module *M) const
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
TypedefNameDecl * getDecl() const
SourceLocation getLAngleLoc() const
SourceLocation getTypeArgsLAngleLoc() const
NestedNameSpecifierLoc QualifierLoc
known_categories_iterator known_categories_end() const
Retrieve an iterator to the end of the known-categories list.
ArgKind getKind() const
Return the kind of stored template argument.
unsigned getDepth() const
An attributed type is a type to which a type attribute has been applied.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
Represents a type parameter type in Objective C.
TranslationUnitDecl * getTranslationUnitDecl() const
Defines the clang::SourceLocation class and associated facilities.
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
A GCC-style AsmStmt record.
void SetSelectorOffset(Selector Sel, uint32_t Offset)
Note that the selector Sel occurs at the given offset within the method pool/selector table...
unsigned InferSubmodules
Whether we should infer submodules for this module based on the headers.
Represents a C++ struct/union/class.
Represents a template specialization type whose template cannot be resolved, e.g. ...
FileID getPredefinesFileID() const
Returns the FileID for the preprocessor predefines.
DiagnosticsEngine & getDiagnostics() const
An TemplateTypeParmType record.
Decl * D
The template function declaration to be late parsed.
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
TemplateArgumentLocInfo getLocInfo() const
SourceLocation getEllipsisLoc() const
For a pack expansion, determine the location of the ellipsis.
Record code for the filesystem options table.
An object for streaming information to a record.
static void AddLazyVectorDecls(ASTWriter &Writer, Vector &Vec, ASTWriter::RecordData &Record)
An ObjCAtCatchStmt record.
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...
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
A ObjCImplementationDecl record.
QualType getNamedType() const
Retrieve the type named by the qualified-id.
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
A structure for storing the information associated with an overloaded template name.
ASTFileSignature WriteAST(Sema &SemaRef, const std::string &OutputFile, Module *WritingModule, StringRef isysroot, bool hasErrors=false)
Write a precompiled header for the given semantic analysis.
unsigned getNumProtocols() const
bool isBuiltinMacro() const
Return true if this macro requires processing before expansion.
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Location information for a TemplateArgument.
A ObjCAtDefsFieldDecl record.
Declaration of a class template.
Record code for the offsets of each type.
A DependentAddressSpaceType record.
The block containing the definitions of all of the types and decls used within the AST file...
The internal '__va_list_tag' struct, if any.
This class is used for builtin types like 'int'.
Writes an AST file containing the contents of a translation unit.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
bool hasAttrOperand() const
bool hasRecordedPreamble() const
serialization::DeclID getDeclID(const Decl *D)
Determine the declaration ID of an already-emitted declaration.
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Emit a C++ base specifier.
void AddASTTemplateArgumentListInfo(const ASTTemplateArgumentListInfo *ASTTemplArgList)
Emits an AST template argument list info.
SourceLocation getLocation() const
Retrieve the source location of the capture.
void AddAPInt(const llvm::APInt &Value)
Emit an integral value.
LineTableInfo & getLineTable()
Retrieve the stored line table.
Specifies the name of the module that will eventually re-export the entities in this module...
Defines the clang::TargetInfo interface.
MacroDefinitionRecord * findMacroDefinition(const MacroInfo *MI)
Retrieve the macro definition that corresponds to the given MacroInfo.
SourceLocation getNameLoc() const
Defines the clang::VersionTuple class, which represents a version in the form major[.minor[.subminor]].
ArrayRef< ModuleMacro * > getLeafModuleMacros(const IdentifierInfo *II) const
Get the list of leaf (non-overridden) module macros for a name.
a linked list of methods with the same selector name but different signatures.
Specifies a required feature.
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
std::vector< std::string > ConfigMacros
The set of "configuration macros", which are macros that (intentionally) change how this module is bu...
An ObjCMessageExpr record.
bool isGNUVarargs() const
QualType getjmp_bufType() const
Retrieve the C jmp_buf type.
unsigned getNumTypeArgs() const
unsigned getNumElements() const
Record for offsets of DECL_UPDATES records for declarations that were modified after being deserializ...
SourceLocation getAmpLoc() const
TranslationUnitDecl - The top declaration context.
A CompoundAssignOperator record.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getAsType() const
Retrieve the type for a type template argument.
void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs)
Emit a template argument list.
Represents an extended address space qualifier where the input address space value is dependent...
Represents a type template specialization; the template must be a class template, a type alias templa...
static unsigned CreateSLocBufferBlobAbbrev(llvm::BitstreamWriter &Stream, bool Compressed)
Create an abbreviation for the SLocEntry that refers to a buffer's blob.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
A FunctionTemplateDecl record.
llvm::DenseMap< CXXRecordDecl *, bool > VTablesUsed
The set of classes whose vtables have been used within this translation unit, and a bit that will be ...
A TypeAliasTemplateDecl record.
Contains a late templated function.
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Record code for weak undeclared identifiers.
The block containing information about the preprocessor.
void AddTemplateName(TemplateName Name)
Emit a template name.
PragmaStack< unsigned > PackStack
TypeSpecifierType getWrittenTypeSpec() const
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg)
Emits a template argument location.
AccessSpecifier getAccessSpecifierAsWritten() const
Retrieves the access specifier as written in the source code (which may mean that no access specifier...
Wrapper for source info for builtin types.
TemplateArgument getArgumentPack() const
Retrieve the template template argument pack with which this parameter was substituted.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
void VisitFunctionType(const FunctionType *T)
A set of overloaded template declarations.
Wrapper for template type parameters.
Record code for the headers search options table.
A trivial tuple used to represent a source range.
unsigned getFlags() const
Return the internal represtation of the flags.
known_categories_iterator known_categories_begin() const
Retrieve an iterator to the beginning of the known-categories list.
NamedDecl - This represents a decl with a name.
bool isTranslationUnit() const
AST file metadata, including the AST file version number and information about the compiler used to b...
static void EmitRecordID(unsigned ID, const char *Name, llvm::BitstreamWriter &Stream, ASTWriter::RecordDataImpl &Record)
The block of input files, which were used as inputs to create this AST file.
FunctionDecl * getExceptionSpecTemplate() const
If this function type has an uninstantiated exception specification, this is the function whose excep...
unsigned IsExplicit
Whether this is an explicit submodule.
Represents a C array with a specified size that is not an integer-constant-expression.
void numberAnonymousDeclsWithin(const DeclContext *DC, Fn Visit)
Visit each declaration within DC that needs an anonymous declaration number and call Visit with the d...
unsigned LocalNumTypes
The number of types in this AST file.
NestedNameSpecifierLoc getQualifierLoc() const
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
The internal '__NSConstantString' tag type.
SourceLocation getAttributeLoc() const
bool isInline() const
Whether this variable is (C++1z) inline.
A function-like macro definition.
The Objective-C 'Protocol' type.
SourceLocation getAttrEnumOperandLoc() const
The location of the attribute's enumerated operand, if it has one.
The global specifier '::'. There is no stored value.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
The control block, which contains all of the information that needs to be validated prior to committi...
Wrapper for source info for pointers.
SourceLocation getBegin() const
SmallVector< Slot, 2 > Stack
std::string Triple
The name of the target triple to compile for.
const LangOptions & getLangOpts() const
Wrapper for source info for block pointers.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
This class handles loading and caching of source files into memory.
Represents the canonical version of C arrays with a specified constant size.
PredefinedDeclIDs
Predefined declaration IDs.
Declaration of a template function.
iterator - Iterate over the decls of a specified declaration name.
Record code for an update to the TU's lexically contained declarations.
bool isUsedForHeaderGuard() const
Determine whether this macro was used for a header guard.
A class which abstracts out some details necessary for making a call.
A GenericSelectionExpr record.
A type index; the type ID with the qualifier bits removed.
Attr - This represents one attribute.
SourceLocation getLocation() const
SourceLocation getTypeArgsRAngleLoc() const
QualType getPointeeType() const
A PackExpansionType record.
A single template declaration.
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
Defines the LambdaCapture class.
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.
Record code for #pragma ms_struct options.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
const IdentifierInfo * getIdentifier() const
A DependentTemplateSpecializationType record.
Expr * getSizeExpr() const
bool hasLineTable() const
Determine if the source manager has a line table.
StringRef getName() const
ArrayRef< const IdentifierInfo * > params() const
Record code for the array of tentative definitions.
iterator local_begin()
Begin iterator for local, non-loaded, preprocessed entities.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.