72 #include "llvm/ADT/APFloat.h" 73 #include "llvm/ADT/APInt.h" 74 #include "llvm/ADT/APSInt.h" 75 #include "llvm/ADT/ArrayRef.h" 76 #include "llvm/ADT/DenseMap.h" 77 #include "llvm/ADT/Hashing.h" 78 #include "llvm/ADT/Optional.h" 79 #include "llvm/ADT/PointerIntPair.h" 80 #include "llvm/ADT/STLExtras.h" 81 #include "llvm/ADT/ScopeExit.h" 82 #include "llvm/ADT/SmallSet.h" 83 #include "llvm/ADT/SmallString.h" 84 #include "llvm/ADT/SmallVector.h" 85 #include "llvm/ADT/StringMap.h" 86 #include "llvm/ADT/StringRef.h" 87 #include "llvm/Bitcode/BitCodes.h" 88 #include "llvm/Bitcode/BitstreamWriter.h" 89 #include "llvm/Support/Casting.h" 90 #include "llvm/Support/Compression.h" 91 #include "llvm/Support/DJB.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/VersionTuple.h" 101 #include "llvm/Support/raw_ostream.h" 116 using namespace clang;
119 template <
typename T,
typename Allocator>
120 static StringRef
bytes(
const std::vector<T, Allocator> &
v) {
121 if (v.empty())
return StringRef();
122 return StringRef(reinterpret_cast<const char*>(&v[0]),
123 sizeof(T) * v.size());
126 template <
typename T>
128 return StringRef(reinterpret_cast<const char*>(v.data()),
129 sizeof(T) * v.size());
146 unsigned AbbrevToUse = 0;
150 : Writer(Writer), Record(Writer, Record) {}
153 return Record.
Emit(Code, AbbrevToUse);
162 AbbrevToUse = Writer.TypeExtQualAbbrev;
167 #define TYPE(Class, Base) \ 168 case Type::Class: Visit##Class##Type(cast<Class##Type>(T)); break; 169 #define ABSTRACT_TYPE(Class, Base) 170 #include "clang/AST/TypeNodes.def" 177 void VisitTagType(
const TagType *T);
179 #define TYPE(Class, Base) void Visit##Class##Type(const Class##Type *T); 180 #define ABSTRACT_TYPE(Class, Base) 181 #include "clang/AST/TypeNodes.def" 186 void ASTTypeWriter::VisitBuiltinType(
const BuiltinType *T) {
187 llvm_unreachable(
"Built-in types are never serialized");
190 void ASTTypeWriter::VisitComplexType(
const ComplexType *T) {
195 void ASTTypeWriter::VisitPointerType(
const PointerType *T) {
200 void ASTTypeWriter::VisitDecayedType(
const DecayedType *T) {
205 void ASTTypeWriter::VisitAdjustedType(
const AdjustedType *T) {
258 void ASTTypeWriter::VisitVectorType(
const VectorType *T) {
265 void ASTTypeWriter::VisitExtVectorType(
const ExtVectorType *T) {
277 Record.push_back(C.
getCC());
287 VisitFunctionType(T);
309 VisitFunctionType(T);
318 for (
unsigned I = 0, N = T->
getNumParams(); I != N; ++I)
322 for (
unsigned I = 0, N = T->
getNumParams(); I != N; ++I)
335 Record.AddDeclRef(T->
getDecl());
339 void ASTTypeWriter::VisitTypedefType(
const TypedefType *T) {
340 Record.AddDeclRef(T->
getDecl());
346 void ASTTypeWriter::VisitTypeOfExprType(
const TypeOfExprType *T) {
351 void ASTTypeWriter::VisitTypeOfType(
const TypeOfType *T) {
356 void ASTTypeWriter::VisitDecltypeType(
const DecltypeType *T) {
369 void ASTTypeWriter::VisitAutoType(
const AutoType *T) {
377 void ASTTypeWriter::VisitDeducedTemplateSpecializationType(
390 "Cannot serialize in the middle of a type definition");
393 void ASTTypeWriter::VisitRecordType(
const RecordType *T) {
398 void ASTTypeWriter::VisitEnumType(
const EnumType *T) {
403 void ASTTypeWriter::VisitAttributedType(
const AttributedType *T) {
411 ASTTypeWriter::VisitSubstTemplateTypeParmType(
419 ASTTypeWriter::VisitSubstTemplateTypeParmPackType(
427 ASTTypeWriter::VisitTemplateSpecializationType(
432 for (
const auto &ArgI : *T)
433 Record.AddTemplateArgument(ArgI);
434 Record.AddTypeRef(T->isTypeAlias() ? T->getAliasedType()
435 : T->isCanonicalUnqualified()
437 : T->getCanonicalTypeInternal());
450 ASTTypeWriter::VisitDependentSizedExtVectorType(
460 Record.AddStmt(const_cast<Expr*>(T->
getSizeExpr()));
467 ASTTypeWriter::VisitDependentAddressSpaceType(
480 Record.AddDeclRef(T->
getDecl());
495 ASTTypeWriter::VisitDependentTemplateSpecializationType(
501 for (
const auto &I : *T)
502 Record.AddTemplateArgument(I);
509 Record.push_back(*NumExpansions + 1);
515 void ASTTypeWriter::VisitParenType(
const ParenType *T) {
520 void ASTTypeWriter::VisitElaboratedType(
const ElaboratedType *T) {
540 Record.AddDeclRef(T->
getDecl());
542 for (
const auto *I : T->
quals())
543 Record.AddDeclRef(I);
547 void ASTTypeWriter::VisitObjCObjectType(
const ObjCObjectType *T) {
551 Record.AddTypeRef(TypeArg);
553 for (
const auto *I : T->
quals())
554 Record.AddDeclRef(I);
566 ASTTypeWriter::VisitAtomicType(
const AtomicType *T) {
572 ASTTypeWriter::VisitPipeType(
const PipeType *T) {
586 #define ABSTRACT_TYPELOC(CLASS, PARENT) 587 #define TYPELOC(CLASS, PARENT) \ 588 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc); 589 #include "clang/AST/TypeLocNodes.def" 632 Record.AddSourceLocation(TL.
getAmpLoc());
644 void TypeLocWriter::VisitArrayTypeLoc(
ArrayTypeLoc TL) {
653 VisitArrayTypeLoc(TL);
657 VisitArrayTypeLoc(TL);
661 VisitArrayTypeLoc(TL);
664 void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
666 VisitArrayTypeLoc(TL);
669 void TypeLocWriter::VisitDependentAddressSpaceTypeLoc(
673 Record.AddSourceLocation(range.
getBegin());
674 Record.AddSourceLocation(range.
getEnd());
678 void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
687 void TypeLocWriter::VisitDependentVectorTypeLoc(
702 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i)
707 VisitFunctionTypeLoc(TL);
711 VisitFunctionTypeLoc(TL);
749 Record.AddSourceLocation(TL.
getKWLoc());
755 void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
759 void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
768 void TypeLocWriter::VisitEnumTypeLoc(
EnumTypeLoc TL) {
776 Record.AddSourceLocation(range.
getBegin());
777 Record.AddSourceLocation(range.
getEnd());
781 Record.push_back(operand ? 1 : 0);
782 if (operand) Record.AddStmt(operand);
792 void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
797 void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
802 void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
808 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
813 void TypeLocWriter::VisitParenTypeLoc(
ParenTypeLoc TL) {
833 void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
841 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I)
871 Record.AddSourceLocation(TL.
getKWLoc());
876 void TypeLocWriter::VisitPipeTypeLoc(
PipeTypeLoc TL) {
877 Record.AddSourceLocation(TL.
getKWLoc());
880 void ASTWriter::WriteTypeAbbrevs() {
881 using namespace llvm;
883 std::shared_ptr<BitCodeAbbrev> Abv;
886 Abv = std::make_shared<BitCodeAbbrev>();
888 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
889 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
890 TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
893 Abv = std::make_shared<BitCodeAbbrev>();
896 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
897 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
898 Abv->Add(BitCodeAbbrevOp(0));
899 Abv->Add(BitCodeAbbrevOp(0));
900 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
901 Abv->Add(BitCodeAbbrevOp(0));
902 Abv->Add(BitCodeAbbrevOp(0));
903 Abv->Add(BitCodeAbbrevOp(0));
905 Abv->Add(BitCodeAbbrevOp(0));
906 Abv->Add(BitCodeAbbrevOp(0));
907 Abv->Add(BitCodeAbbrevOp(0));
908 Abv->Add(BitCodeAbbrevOp(0));
909 Abv->Add(BitCodeAbbrevOp(
EST_None));
910 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
911 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
912 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
913 TypeFunctionProtoAbbrev = Stream.EmitAbbrev(std::move(Abv));
921 llvm::BitstreamWriter &Stream,
924 Record.push_back(ID);
925 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);
928 if (!Name || Name[0] == 0)
932 Record.push_back(*Name++);
933 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME, Record);
937 llvm::BitstreamWriter &Stream,
940 Record.push_back(ID);
942 Record.push_back(*Name++);
943 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, Record);
948 #define RECORD(X) EmitRecordID(X, #X, Stream, Record) 1075 void ASTWriter::WriteBlockInfoBlock() {
1077 Stream.EnterBlockInfoBlock();
1079 #define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record) 1080 #define RECORD(X) EmitRecordID(X, #X, Stream, Record) 1083 BLOCK(CONTROL_BLOCK);
1094 BLOCK(OPTIONS_BLOCK);
1101 BLOCK(INPUT_FILES_BLOCK);
1160 BLOCK(SOURCE_MANAGER_BLOCK);
1168 BLOCK(PREPROCESSOR_BLOCK);
1176 BLOCK(SUBMODULE_BLOCK);
1197 BLOCK(COMMENTS_BLOCK);
1201 BLOCK(DECLTYPES_BLOCK);
1318 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
1324 BLOCK(EXTENSION_BLOCK);
1327 BLOCK(UNHASHED_CONTROL_BLOCK);
1344 return Changed | llvm::sys::path::remove_dots(Path);
1359 assert(Filename &&
"No file name to adjust?");
1361 if (BaseDir.empty())
1366 for (; Filename[Pos] && Pos < BaseDir.size(); ++Pos)
1367 if (Filename[Pos] != BaseDir[Pos])
1376 if (!llvm::sys::path::is_separator(Filename[Pos])) {
1377 if (!llvm::sys::path::is_separator(BaseDir.back()))
1391 return Filename + Pos;
1398 auto Hash = Hasher.result();
1402 auto LShift = [&](
unsigned char Val,
unsigned Shift) {
1403 return (uint32_t)Val <<
Shift;
1405 for (
int I = 0; I != 5; ++I)
1406 Signature[I] = LShift(Hash[I * 4 + 0], 24) | LShift(Hash[I * 4 + 1], 16) |
1407 LShift(Hash[I * 4 + 2], 8) | LShift(Hash[I * 4 + 3], 0);
1415 Stream.FlushToWord();
1416 auto StartOfUnhashedControl = Stream.GetCurrentBitNo() >> 3;
1424 if (WritingModule &&
1426 Signature = createSignature(StringRef(Buffer.begin(), StartOfUnhashedControl));
1427 Record.append(Signature.begin(), Signature.end());
1435 #define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name); 1436 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ 1437 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name())); 1438 #include "clang/Basic/DiagnosticOptions.def" 1439 Record.push_back(DiagOpts.
Warnings.size());
1440 for (
unsigned I = 0, N = DiagOpts.
Warnings.size(); I != N; ++I)
1441 AddString(DiagOpts.
Warnings[I], Record);
1442 Record.push_back(DiagOpts.
Remarks.size());
1443 for (
unsigned I = 0, N = DiagOpts.
Remarks.size(); I != N; ++I)
1444 AddString(DiagOpts.
Remarks[I], Record);
1450 WritePragmaDiagnosticMappings(Diags, WritingModule);
1460 const std::string &OutputFile) {
1461 using namespace llvm;
1467 auto MetadataAbbrev = std::make_shared<BitCodeAbbrev>();
1468 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1469 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1470 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1471 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1472 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1473 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1474 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1475 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1476 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1477 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1478 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev));
1479 assert((!WritingModule || isysroot.empty()) &&
1480 "writing module as a relocatable PCH?");
1482 RecordData::value_type Record[] = {
1486 CLANG_VERSION_MAJOR,
1487 CLANG_VERSION_MINOR,
1491 ASTHasCompilerErrors};
1492 Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
1496 if (WritingModule) {
1498 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1500 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1501 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1503 Stream.EmitRecordWithBlob(AbbrevCode, Record, WritingModule->Name);
1506 if (WritingModule && WritingModule->Directory) {
1516 WritingModule->Directory->getName() != StringRef(
".")) {
1518 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1520 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1521 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1524 Stream.EmitRecordWithBlob(AbbrevCode, Record, BaseDir);
1528 BaseDirectory.assign(BaseDir.begin(), BaseDir.end());
1529 }
else if (!isysroot.empty()) {
1531 BaseDirectory = isysroot;
1539 AddPath(WritingModule->PresumedModuleMapFile.empty()
1540 ? Map.getModuleMapFileForUniquing(WritingModule)->getName()
1541 : StringRef(WritingModule->PresumedModuleMapFile),
1545 if (
auto *AdditionalModMaps =
1546 Map.getAdditionalModuleMapFiles(WritingModule)) {
1547 Record.push_back(AdditionalModMaps->size());
1548 for (
const FileEntry *F : *AdditionalModMaps)
1549 AddPath(F->getName(), Record);
1551 Record.push_back(0);
1564 if (!M.isDirectlyImported())
1567 Record.push_back((
unsigned)M.Kind);
1568 AddSourceLocation(M.ImportLoc, Record);
1572 Record.push_back(M.Signature ? 0 : M.File->getSize());
1573 Record.push_back(M.Signature ? 0 : getTimestampForOutput(M.File));
1575 for (
auto I : M.Signature)
1576 Record.push_back(I);
1578 AddString(M.ModuleName, Record);
1579 AddPath(M.FileName, Record);
1581 Stream.EmitRecord(
IMPORTS, Record);
1590 #define LANGOPT(Name, Bits, Default, Description) \ 1591 Record.push_back(LangOpts.Name); 1592 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 1593 Record.push_back(static_cast<unsigned>(LangOpts.get##Name())); 1594 #include "clang/Basic/LangOptions.def" 1595 #define SANITIZER(NAME, ID) \ 1596 Record.push_back(LangOpts.Sanitize.has(SanitizerKind::ID)); 1597 #include "clang/Basic/Sanitizers.def" 1601 AddString(Feature, Record);
1611 AddString(I, Record);
1618 AddString(T.getTriple(), Record);
1628 AddString(TargetOpts.
Triple, Record);
1629 AddString(TargetOpts.
CPU, Record);
1630 AddString(TargetOpts.
ABI, Record);
1635 Record.push_back(TargetOpts.
Features.size());
1636 for (
unsigned I = 0, N = TargetOpts.
Features.size(); I != N; ++I) {
1637 AddString(TargetOpts.
Features[I], Record);
1652 AddString(HSOpts.
Sysroot, Record);
1656 for (
unsigned I = 0, N = HSOpts.
UserEntries.size(); I != N; ++I) {
1658 AddString(Entry.
Path, Record);
1659 Record.push_back(static_cast<unsigned>(Entry.
Group));
1690 Record.push_back(PPOpts.
Macros.size());
1691 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
1692 AddString(PPOpts.
Macros[I].first, Record);
1693 Record.push_back(PPOpts.
Macros[I].second);
1697 Record.push_back(PPOpts.
Includes.size());
1698 for (
unsigned I = 0, N = PPOpts.
Includes.size(); I != N; ++I)
1699 AddString(PPOpts.
Includes[I], Record);
1703 for (
unsigned I = 0, N = PPOpts.
MacroIncludes.size(); I != N; ++I)
1720 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1722 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1723 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1724 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
1729 EmitRecordWithPath(FileAbbrevCode, Record, MainFile->getName());
1737 if (!OutputFile.empty() && OutputFile !=
"-") {
1738 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1740 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1741 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1746 StringRef origDir = llvm::sys::path::parent_path(OutputPath);
1749 Stream.EmitRecordWithBlob(AbbrevCode, Record, origDir);
1752 WriteInputFiles(Context.SourceMgr,
1761 struct InputFileEntry {
1765 bool BufferOverridden;
1766 bool IsTopLevelModuleMap;
1774 using namespace llvm;
1779 auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
1781 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1782 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1783 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1784 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1785 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1786 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1787 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1788 unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
1792 std::deque<InputFileEntry> SortedFiles;
1796 assert(&SourceMgr.
getSLocEntry(FileID::get(I)) == SLoc);
1806 InputFileEntry Entry;
1814 SortedFiles.push_back(Entry);
1816 SortedFiles.push_front(Entry);
1819 unsigned UserFilesNum = 0;
1821 std::vector<uint64_t> InputFileOffsets;
1822 for (
const auto &Entry : SortedFiles) {
1823 uint32_t &InputFileID = InputFileIDs[Entry.File];
1824 if (InputFileID != 0)
1828 InputFileOffsets.push_back(Stream.GetCurrentBitNo());
1830 InputFileID = InputFileOffsets.size();
1832 if (!Entry.IsSystemFile)
1837 RecordData::value_type Record[] = {
1839 InputFileOffsets.size(),
1840 (uint64_t)Entry.File->getSize(),
1841 (uint64_t)getTimestampForOutput(Entry.File),
1842 Entry.BufferOverridden,
1844 Entry.IsTopLevelModuleMap};
1846 EmitRecordWithPath(IFAbbrevCode, Record, Entry.File->getName());
1852 auto OffsetsAbbrev = std::make_shared<BitCodeAbbrev>();
1854 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1855 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1857 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1858 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(std::move(OffsetsAbbrev));
1862 InputFileOffsets.size(), UserFilesNum};
1863 Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record,
bytes(InputFileOffsets));
1873 using namespace llvm;
1875 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1877 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1878 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1879 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1880 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1882 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1883 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1884 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
1885 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1886 return Stream.EmitAbbrev(std::move(Abbrev));
1892 using namespace llvm;
1894 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1896 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1897 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1898 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1899 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1900 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1901 return Stream.EmitAbbrev(std::move(Abbrev));
1908 using namespace llvm;
1910 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1914 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1915 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1916 return Stream.EmitAbbrev(std::move(Abbrev));
1922 using namespace llvm;
1924 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1926 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1927 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1928 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1929 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1930 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1931 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1932 return Stream.EmitAbbrev(std::move(Abbrev));
1938 class HeaderFileInfoTrait {
1943 llvm::StringMap<unsigned> FrameworkNameOffset;
1946 HeaderFileInfoTrait(
ASTWriter &Writer) : Writer(Writer) {}
1953 using key_type_ref =
const key_type &;
1955 using UnresolvedModule =
1956 llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
1961 UnresolvedModule Unresolved;
1963 using data_type_ref =
const data_type &;
1965 using hash_value_type = unsigned;
1966 using offset_type = unsigned;
1975 std::pair<unsigned, unsigned>
1976 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) {
1977 using namespace llvm::support;
1979 endian::Writer LE(Out, little);
1980 unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
1981 LE.write<uint16_t>(KeyLen);
1982 unsigned DataLen = 1 + 2 + 4 + 4;
1983 for (
auto ModInfo : Data.KnownHeaders)
1986 if (Data.Unresolved.getPointer())
1988 LE.write<uint8_t>(DataLen);
1989 return std::make_pair(KeyLen, DataLen);
1992 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
1993 using namespace llvm::support;
1995 endian::Writer LE(Out, little);
1996 LE.write<uint64_t>(key.Size);
1998 LE.write<uint64_t>(key.ModTime);
2000 Out.write(key.Filename.data(), KeyLen);
2003 void EmitData(raw_ostream &Out, key_type_ref key,
2004 data_type_ref Data,
unsigned DataLen) {
2005 using namespace llvm::support;
2007 endian::Writer LE(Out, little);
2008 uint64_t Start = Out.tell(); (void)Start;
2010 unsigned char Flags = (Data.HFI.isImport << 5)
2011 | (Data.HFI.isPragmaOnce << 4)
2012 | (Data.HFI.DirInfo << 1)
2013 | Data.HFI.IndexHeaderMapHeader;
2014 LE.write<uint8_t>(Flags);
2015 LE.write<uint16_t>(Data.HFI.NumIncludes);
2017 if (!Data.HFI.ControllingMacro)
2018 LE.write<uint32_t>(Data.HFI.ControllingMacroID);
2023 if (!Data.HFI.Framework.empty()) {
2025 llvm::StringMap<unsigned>::iterator Pos
2026 = FrameworkNameOffset.find(Data.HFI.Framework);
2027 if (Pos == FrameworkNameOffset.end()) {
2028 Offset = FrameworkStringData.size() + 1;
2029 FrameworkStringData.append(Data.HFI.Framework.begin(),
2030 Data.HFI.Framework.end());
2031 FrameworkStringData.push_back(0);
2033 FrameworkNameOffset[Data.HFI.Framework] =
Offset;
2035 Offset = Pos->second;
2037 LE.write<uint32_t>(
Offset);
2041 uint32_t
Value = (ModID << 2) | (
unsigned)Role;
2042 assert((Value >> 2) == ModID &&
"overflow in header module info");
2043 LE.write<uint32_t>(
Value);
2049 for (
auto ModInfo : Data.KnownHeaders)
2050 EmitModule(ModInfo.getModule(), ModInfo.getRole());
2051 if (Data.Unresolved.getPointer())
2052 EmitModule(Data.Unresolved.getPointer(), Data.Unresolved.getInt());
2054 assert(Out.tell() - Start == DataLen &&
"Wrong data length");
2057 const char *strings_begin()
const {
return FrameworkStringData.begin(); }
2058 const char *strings_end()
const {
return FrameworkStringData.end(); }
2066 void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
2067 HeaderFileInfoTrait GeneratorTrait(*
this);
2068 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait> Generator;
2070 unsigned NumHeaderSearchEntries = 0;
2077 if (WritingModule) {
2079 while (!Worklist.empty()) {
2080 Module *M = Worklist.pop_back_val();
2096 if (!U.Size || (!U.ModTime && IncludeTimestamps)) {
2097 PP->
Diag(U.FileNameLoc, diag::err_module_no_size_mtime_for_header)
2098 << WritingModule->getFullModuleName() << U.Size.hasValue()
2105 llvm::sys::path::append(
Filename, U.FileName);
2108 StringRef FilenameDup = strdup(
Filename.c_str());
2109 SavedStrings.push_back(FilenameDup.data());
2111 HeaderFileInfoTrait::key_type Key = {
2112 FilenameDup, *U.Size, IncludeTimestamps ? *U.ModTime : 0
2114 HeaderFileInfoTrait::data_type Data = {
2119 Generator.insert(Key, Data, GeneratorTrait);
2120 ++NumHeaderSearchEntries;
2133 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
2134 const FileEntry *File = FilesByUID[UID];
2152 if (PreparePathForOutput(FilenameTmp)) {
2155 Filename = StringRef(strdup(FilenameTmp.c_str()));
2156 SavedStrings.push_back(Filename.data());
2159 HeaderFileInfoTrait::key_type Key = {
2162 HeaderFileInfoTrait::data_type Data = {
2165 Generator.insert(Key, Data, GeneratorTrait);
2166 ++NumHeaderSearchEntries;
2171 uint32_t BucketOffset;
2173 using namespace llvm::support;
2175 llvm::raw_svector_ostream Out(TableData);
2177 endian::write<uint32_t>(Out, 0, little);
2178 BucketOffset = Generator.Emit(Out, GeneratorTrait);
2182 using namespace llvm;
2184 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2186 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2187 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2188 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2189 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2190 unsigned TableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2194 NumHeaderSearchEntries, TableData.size()};
2195 TableData.append(GeneratorTrait.strings_begin(),GeneratorTrait.strings_end());
2196 Stream.EmitRecordWithBlob(TableAbbrev, Record, TableData);
2199 for (
unsigned I = 0, N = SavedStrings.size(); I != N; ++I)
2200 free(const_cast<char *>(SavedStrings[I]));
2203 static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
2204 unsigned SLocBufferBlobCompressedAbbrv,
2205 unsigned SLocBufferBlobAbbrv) {
2206 using RecordDataType = ASTWriter::RecordData::value_type;
2211 if (llvm::zlib::isAvailable()) {
2212 llvm::Error E = llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer);
2216 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record,
2220 llvm::consumeError(std::move(E));
2224 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob);
2235 void ASTWriter::WriteSourceManagerBlock(
SourceManager &SourceMgr,
2246 unsigned SLocBufferBlobCompressedAbbrv =
2252 std::vector<uint32_t> SLocEntryOffsets;
2253 RecordData PreloadSLocs;
2259 FileID FID = FileID::get(I);
2263 SLocEntryOffsets.push_back(Stream.GetCurrentBitNo());
2276 Record.push_back(Code);
2279 Record.push_back(SLoc->
getOffset() - 2);
2287 bool EmitBlob =
false;
2290 "Writing to AST an overridden file is not supported");
2293 assert(InputFileIDs[Content->
OrigEntry] != 0 &&
"Missed file entry");
2294 Record.push_back(InputFileIDs[Content->
OrigEntry]);
2296 Record.push_back(File.NumCreatedFIDs);
2298 FileDeclIDsTy::iterator FDI = FileDeclIDs.find(FID);
2299 if (FDI != FileDeclIDs.end()) {
2300 Record.push_back(FDI->second->FirstDeclIndex);
2301 Record.push_back(FDI->second->DeclIDs.size());
2303 Record.push_back(0);
2304 Record.push_back(0);
2307 Stream.EmitRecordWithAbbrev(SLocFileAbbrv, Record);
2318 const llvm::MemoryBuffer *Buffer
2320 StringRef Name = Buffer->getBufferIdentifier();
2321 Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
2322 StringRef(Name.data(), Name.size() + 1));
2325 if (Name ==
"<built-in>")
2326 PreloadSLocs.push_back(SLocEntryOffsets.size());
2332 const llvm::MemoryBuffer *Buffer =
2334 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
2335 emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv,
2336 SLocBufferBlobAbbrv);
2353 Record.push_back(NextOffset - SLoc->
getOffset() - 1);
2354 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv, Record);
2360 if (SLocEntryOffsets.empty())
2365 using namespace llvm;
2367 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2369 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2370 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2371 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2372 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2374 RecordData::value_type Record[] = {
2377 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
2378 bytes(SLocEntryOffsets));
2392 llvm::DenseMap<int, int> FilenameMap;
2393 FilenameMap[-1] = -1;
2394 for (
const auto &L : LineTable) {
2397 for (
auto &LE : L.second) {
2398 if (FilenameMap.insert(std::make_pair(LE.FilenameID,
2399 FilenameMap.size() - 1)).second)
2400 AddPath(LineTable.getFilename(LE.FilenameID), Record);
2403 Record.push_back(0);
2406 for (
const auto &L : LineTable) {
2412 Record.push_back(L.first.ID);
2415 Record.push_back(L.second.size());
2416 for (
const auto &LE : L.second) {
2417 Record.push_back(LE.FileOffset);
2418 Record.push_back(LE.LineNo);
2419 Record.push_back(FilenameMap[LE.FilenameID]);
2420 Record.push_back((
unsigned)LE.FileKind);
2421 Record.push_back(LE.IncludeOffset);
2436 if (MI->isBuiltinMacro())
2452 void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2455 WritePreprocessorDetail(*PPRec);
2458 RecordData ModuleMacroRecord;
2469 if (SkipInfo.hasValue()) {
2470 Record.push_back(
true);
2471 AddSourceLocation(SkipInfo->HashTokenLoc, Record);
2472 AddSourceLocation(SkipInfo->IfTokenLoc, Record);
2473 Record.push_back(SkipInfo->FoundNonSkipPortion);
2474 Record.push_back(SkipInfo->FoundElse);
2475 AddSourceLocation(SkipInfo->ElseLoc, Record);
2477 Record.push_back(
false);
2480 AddSourceLocation(Cond.IfLoc, Record);
2481 Record.push_back(Cond.WasSkipping);
2482 Record.push_back(Cond.FoundNonSkip);
2483 Record.push_back(Cond.FoundElse);
2504 if (
Id.second->hadMacroDefinition() &&
2505 (!
Id.second->isFromAST() ||
2506 Id.second->hasChangedSinceDeserialization()))
2507 MacroIdentifiers.push_back(
Id.second);
2510 llvm::sort(MacroIdentifiers.begin(), MacroIdentifiers.end(),
2511 llvm::less_ptr<IdentifierInfo>());
2517 auto StartOffset = Stream.GetCurrentBitNo();
2527 Record.push_back(MD->
getKind());
2528 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2529 Record.push_back(getMacroRef(DefMD->getInfo(), Name));
2530 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2531 Record.push_back(VisMD->isPublic());
2536 bool EmittedModuleMacros =
false;
2540 llvm::DenseMap<ModuleMacro*, unsigned> Visits;
2541 while (!Worklist.empty()) {
2542 auto *Macro = Worklist.pop_back_val();
2545 ModuleMacroRecord.push_back(
2546 getSubmoduleID(Macro->getOwningModule()));
2547 ModuleMacroRecord.push_back(getMacroRef(Macro->getMacroInfo(), Name));
2548 for (
auto *M : Macro->overrides())
2549 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2552 ModuleMacroRecord.clear();
2555 for (
auto *M : Macro->overrides())
2556 if (++Visits[M] == M->getNumOverridingMacros())
2557 Worklist.push_back(M);
2559 EmittedModuleMacros =
true;
2562 if (Record.empty() && !EmittedModuleMacros)
2565 IdentMacroDirectivesOffsetMap[Name] = StartOffset;
2576 std::vector<uint32_t> MacroOffsets;
2578 for (
unsigned I = 0, N = MacroInfosToEmit.size(); I != N; ++I) {
2583 if (ID < FirstMacroID) {
2584 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2589 unsigned Index = ID - FirstMacroID;
2590 if (Index == MacroOffsets.size())
2591 MacroOffsets.push_back(Stream.GetCurrentBitNo());
2593 if (Index > MacroOffsets.size())
2594 MacroOffsets.resize(Index + 1);
2596 MacroOffsets[Index] = Stream.GetCurrentBitNo();
2599 AddIdentifierRef(Name, Record);
2602 Record.push_back(MI->
isUsed());
2615 AddIdentifierRef(Param, Record);
2623 Stream.EmitRecord(Code, Record);
2627 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2632 AddToken(Tok, Record);
2633 Stream.EmitRecord(
PP_TOKEN, Record);
2642 using namespace llvm;
2644 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2646 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2647 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2648 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2650 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2652 RecordData::value_type Record[] = {
MACRO_OFFSET, MacroOffsets.size(),
2654 Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record,
bytes(MacroOffsets));
2668 unsigned NumPreprocessingRecords = 0;
2669 using namespace llvm;
2672 unsigned InclusionAbbrev = 0;
2674 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2676 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2677 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2678 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2679 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2680 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2681 InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2684 unsigned FirstPreprocessorEntityID
2685 = (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0)
2687 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2692 (void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2695 PreprocessedEntityOffsets.push_back(
2696 PPEntityOffset((*E)->getSourceRange(), Stream.GetCurrentBitNo()));
2698 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*E)) {
2700 MacroDefinitions[MD] = NextPreprocessorEntityID;
2702 AddIdentifierRef(MD->getName(), Record);
2707 if (
auto *ME = dyn_cast<MacroExpansion>(*E)) {
2708 Record.push_back(ME->isBuiltinMacro());
2709 if (ME->isBuiltinMacro())
2710 AddIdentifierRef(ME->getName(), Record);
2712 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2717 if (
auto *
ID = dyn_cast<InclusionDirective>(*E)) {
2719 Record.push_back(
ID->getFileName().size());
2720 Record.push_back(
ID->wasInQuotes());
2721 Record.push_back(static_cast<unsigned>(
ID->getKind()));
2722 Record.push_back(
ID->importedModule());
2724 Buffer +=
ID->getFileName();
2728 Buffer +=
ID->getFile()->getName();
2729 Stream.EmitRecordWithBlob(InclusionAbbrev, Record, Buffer);
2733 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2738 if (NumPreprocessingRecords > 0) {
2739 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2742 using namespace llvm;
2744 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2746 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2747 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2748 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2751 FirstPreprocessorEntityID -
2753 Stream.EmitRecordWithBlob(PPEOffsetAbbrev, Record,
2754 bytes(PreprocessedEntityOffsets));
2759 if (SkippedRanges.size() > 0) {
2760 std::vector<PPSkippedRange> SerializedSkippedRanges;
2761 SerializedSkippedRanges.reserve(SkippedRanges.size());
2762 for (
auto const& Range : SkippedRanges)
2763 SerializedSkippedRanges.emplace_back(Range);
2765 using namespace llvm;
2766 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2768 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2769 unsigned PPESkippedRangeAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2773 Stream.EmitRecordWithBlob(PPESkippedRangeAbbrev, Record,
2774 bytes(SerializedSkippedRanges));
2782 llvm::DenseMap<Module *, unsigned>::iterator Known = SubmoduleIDs.find(Mod);
2783 if (Known != SubmoduleIDs.end())
2784 return Known->second;
2787 if (Top != WritingModule &&
2788 (getLangOpts().CompilingPCH ||
2789 !Top->fullModuleNameIs(StringRef(getLangOpts().CurrentModule))))
2792 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2795 unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2799 unsigned ID = getLocalOrImportedSubmoduleID(Mod);
2800 assert((ID || !Mod) &&
2801 "asked for module ID for non-local, non-imported module");
2808 unsigned ChildModules = 0;
2810 Sub != SubEnd; ++Sub)
2813 return ChildModules + 1;
2816 void ASTWriter::WriteSubmodules(
Module *WritingModule) {
2821 using namespace llvm;
2823 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2825 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2826 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2827 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2828 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2829 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2830 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2831 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2832 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2833 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2834 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2835 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2836 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2837 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2838 unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2840 Abbrev = std::make_shared<BitCodeAbbrev>();
2842 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2843 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2845 Abbrev = std::make_shared<BitCodeAbbrev>();
2847 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2848 unsigned HeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2850 Abbrev = std::make_shared<BitCodeAbbrev>();
2852 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2853 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2855 Abbrev = std::make_shared<BitCodeAbbrev>();
2857 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2858 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2860 Abbrev = std::make_shared<BitCodeAbbrev>();
2862 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2863 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2864 unsigned RequiresAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2866 Abbrev = std::make_shared<BitCodeAbbrev>();
2868 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2869 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2871 Abbrev = std::make_shared<BitCodeAbbrev>();
2873 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2874 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2876 Abbrev = std::make_shared<BitCodeAbbrev>();
2878 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2879 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2881 Abbrev = std::make_shared<BitCodeAbbrev>();
2883 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2884 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2886 Abbrev = std::make_shared<BitCodeAbbrev>();
2888 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2889 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2890 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2892 Abbrev = std::make_shared<BitCodeAbbrev>();
2894 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2895 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2897 Abbrev = std::make_shared<BitCodeAbbrev>();
2899 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2900 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2901 unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2903 Abbrev = std::make_shared<BitCodeAbbrev>();
2905 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2906 unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2909 RecordData::value_type Record[] = {
2915 std::queue<Module *> Q;
2916 Q.push(WritingModule);
2917 while (!Q.empty()) {
2920 unsigned ID = getSubmoduleID(Mod);
2922 uint64_t ParentID = 0;
2924 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
2925 ParentID = SubmoduleIDs[Mod->
Parent];
2933 (RecordData::value_type)Mod->
Kind,
2943 Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->
Name);
2949 Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
2955 Stream.EmitRecordWithBlob(UmbrellaAbbrev, Record,
2956 UmbrellaHeader.NameAsWritten);
2959 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev, Record,
2960 UmbrellaDir.NameAsWritten);
2965 unsigned RecordKind;
2976 for (
auto &HL : HeaderLists) {
2977 RecordData::value_type Record[] = {HL.RecordKind};
2978 for (
auto &H : Mod->
Headers[HL.HeaderKind])
2979 Stream.EmitRecordWithBlob(HL.Abbrev, Record, H.NameAsWritten);
2986 for (
auto *H : TopHeaders)
2987 Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, H->getName());
2994 Record.push_back(getSubmoduleID(I));
3001 for (
const auto &E : Mod->
Exports) {
3004 Record.push_back(getSubmoduleID(E.getPointer()));
3005 Record.push_back(E.getInt());
3018 Stream.EmitRecordWithBlob(LinkLibraryAbbrev, Record, LL.Library);
3026 getSubmoduleID(C.Other)};
3027 Stream.EmitRecordWithBlob(ConflictAbbrev, Record, C.Message);
3033 Stream.EmitRecordWithBlob(ConfigMacroAbbrev, Record, CM);
3039 Inits.push_back(GetDeclRef(D));
3046 Stream.EmitRecordWithBlob(ExportAsAbbrev, Record, Mod->
ExportAsModule);
3056 assert((NextSubmoduleID - FirstSubmoduleID ==
3058 "Wrong # of submodules; found a reference to a non-local, " 3059 "non-imported submodule?");
3064 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
3066 unsigned CurrID = 0;
3069 auto EncodeDiagStateFlags =
3070 [](
const DiagnosticsEngine::DiagState *DS) ->
unsigned {
3071 unsigned Result = (unsigned)DS->ExtBehavior;
3073 {(unsigned)DS->IgnoreAllWarnings, (
unsigned)DS->EnableAllWarnings,
3074 (unsigned)DS->WarningsAsErrors, (
unsigned)DS->ErrorsAsFatal,
3075 (unsigned)DS->SuppressSystemWarnings})
3076 Result = (Result << 1) | Val;
3080 unsigned Flags = EncodeDiagStateFlags(Diag.DiagStatesByLoc.FirstDiagState);
3081 Record.push_back(Flags);
3083 auto AddDiagState = [&](
const DiagnosticsEngine::DiagState *
State,
3084 bool IncludeNonPragmaStates) {
3087 assert(Flags == EncodeDiagStateFlags(State) &&
3088 "diag state flags vary in single AST file");
3090 unsigned &DiagStateID = DiagStateIDMap[
State];
3091 Record.push_back(DiagStateID);
3093 if (DiagStateID == 0) {
3094 DiagStateID = ++CurrID;
3097 auto SizeIdx = Record.size();
3098 Record.emplace_back();
3099 for (
const auto &I : *State) {
3100 if (I.second.isPragma() || IncludeNonPragmaStates) {
3101 Record.push_back(I.first);
3102 Record.push_back(I.second.serialize());
3106 Record[SizeIdx] = (Record.size() - SizeIdx) / 2;
3110 AddDiagState(Diag.DiagStatesByLoc.FirstDiagState, isModule);
3113 auto NumLocationsIdx = Record.size();
3114 Record.emplace_back();
3117 unsigned NumLocations = 0;
3118 for (
auto &FileIDAndFile : Diag.DiagStatesByLoc.Files) {
3119 if (!FileIDAndFile.first.isValid() ||
3120 !FileIDAndFile.second.HasLocalTransitions)
3125 assert(!Loc.
isInvalid() &&
"start loc for valid FileID is invalid");
3126 AddSourceLocation(Loc, Record);
3128 Record.push_back(FileIDAndFile.second.StateTransitions.size());
3129 for (
auto &StatePoint : FileIDAndFile.second.StateTransitions) {
3130 Record.push_back(StatePoint.Offset);
3131 AddDiagState(StatePoint.State,
false);
3136 Record[NumLocationsIdx] = NumLocations;
3144 AddSourceLocation(Diag.DiagStatesByLoc.CurDiagStateLoc, Record);
3145 AddDiagState(Diag.DiagStatesByLoc.CurDiagState,
false);
3155 void ASTWriter::WriteType(
QualType T) {
3156 TypeIdx &IdxRef = TypeIdxs[T];
3158 IdxRef =
TypeIdx(NextTypeID++);
3161 assert(Idx.
getIndex() >= FirstTypeID &&
"Re-writing a type from a prior AST");
3171 unsigned Index = Idx.
getIndex() - FirstTypeID;
3172 if (TypeOffsets.size() == Index)
3173 TypeOffsets.push_back(Offset);
3174 else if (TypeOffsets.size() < Index) {
3175 TypeOffsets.resize(Index + 1);
3176 TypeOffsets[Index] =
Offset;
3178 llvm_unreachable(
"Types emitted in wrong order");
3191 uint64_t ASTWriter::WriteDeclContextLexicalBlock(
ASTContext &Context,
3196 uint64_t
Offset = Stream.GetCurrentBitNo();
3198 for (
const auto *D : DC->
decls()) {
3199 KindDeclPairs.push_back(D->getKind());
3200 KindDeclPairs.push_back(GetDeclRef(D));
3203 ++NumLexicalDeclContexts;
3205 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record,
3206 bytes(KindDeclPairs));
3210 void ASTWriter::WriteTypeDeclOffsets() {
3211 using namespace llvm;
3214 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3216 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3217 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3218 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3219 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3221 RecordData::value_type Record[] = {
TYPE_OFFSET, TypeOffsets.size(),
3223 Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record,
bytes(TypeOffsets));
3227 Abbrev = std::make_shared<BitCodeAbbrev>();
3229 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3230 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3231 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3232 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3234 RecordData::value_type Record[] = {
DECL_OFFSET, DeclOffsets.size(),
3236 Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record,
bytes(DeclOffsets));
3240 void ASTWriter::WriteFileDeclIDsMap() {
3241 using namespace llvm;
3244 FileDeclIDs.begin(), FileDeclIDs.end());
3245 llvm::sort(SortedFileDeclIDs.begin(), SortedFileDeclIDs.end(),
3246 llvm::less_first());
3250 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
3251 DeclIDInFileInfo &Info = *FileDeclEntry.second;
3252 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
3253 for (
auto &LocDeclEntry : Info.DeclIDs)
3254 FileGroupedDeclIDs.push_back(LocDeclEntry.second);
3257 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3259 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3260 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3261 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
3263 FileGroupedDeclIDs.size()};
3264 Stream.EmitRecordWithBlob(AbbrevCode, Record,
bytes(FileGroupedDeclIDs));
3267 void ASTWriter::WriteComments() {
3269 auto _ = llvm::make_scope_exit([
this] { Stream.ExitBlock(); });
3274 for (
const auto *I : RawComments) {
3276 AddSourceRange(I->getSourceRange(), Record);
3277 Record.push_back(I->getKind());
3278 Record.push_back(I->isTrailingComment());
3279 Record.push_back(I->isAlmostTrailingComment());
3291 class ASTMethodPoolTrait {
3296 using key_type_ref = key_type;
3302 using data_type_ref =
const data_type &;
3304 using hash_value_type = unsigned;
3305 using offset_type = unsigned;
3307 explicit ASTMethodPoolTrait(
ASTWriter &Writer) : Writer(Writer) {}
3313 std::pair<unsigned, unsigned>
3314 EmitKeyDataLength(raw_ostream& Out,
Selector Sel,
3315 data_type_ref Methods) {
3316 using namespace llvm::support;
3318 endian::Writer LE(Out, little);
3320 LE.write<uint16_t>(KeyLen);
3321 unsigned DataLen = 4 + 2 + 2;
3324 if (Method->getMethod())
3328 if (Method->getMethod())
3330 LE.write<uint16_t>(DataLen);
3331 return std::make_pair(KeyLen, DataLen);
3334 void EmitKey(raw_ostream& Out,
Selector Sel,
unsigned) {
3335 using namespace llvm::support;
3337 endian::Writer LE(Out, little);
3338 uint64_t Start = Out.tell();
3339 assert((Start >> 32) == 0 &&
"Selector key offset too large");
3342 LE.write<uint16_t>(N);
3345 for (
unsigned I = 0; I != N; ++I)
3350 void EmitData(raw_ostream& Out, key_type_ref,
3351 data_type_ref Methods,
unsigned DataLen) {
3352 using namespace llvm::support;
3354 endian::Writer LE(Out, little);
3355 uint64_t Start = Out.tell(); (void)Start;
3356 LE.write<uint32_t>(Methods.ID);
3357 unsigned NumInstanceMethods = 0;
3360 if (Method->getMethod())
3361 ++NumInstanceMethods;
3363 unsigned NumFactoryMethods = 0;
3366 if (Method->getMethod())
3367 ++NumFactoryMethods;
3369 unsigned InstanceBits = Methods.Instance.getBits();
3370 assert(InstanceBits < 4);
3371 unsigned InstanceHasMoreThanOneDeclBit =
3372 Methods.Instance.hasMoreThanOneDecl();
3373 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
3374 (InstanceHasMoreThanOneDeclBit << 2) |
3376 unsigned FactoryBits = Methods.Factory.getBits();
3377 assert(FactoryBits < 4);
3378 unsigned FactoryHasMoreThanOneDeclBit =
3379 Methods.Factory.hasMoreThanOneDecl();
3380 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
3381 (FactoryHasMoreThanOneDeclBit << 2) |
3383 LE.write<uint16_t>(FullInstanceBits);
3384 LE.write<uint16_t>(FullFactoryBits);
3387 if (Method->getMethod())
3388 LE.write<uint32_t>(Writer.
getDeclID(Method->getMethod()));
3391 if (Method->getMethod())
3392 LE.write<uint32_t>(Writer.
getDeclID(Method->getMethod()));
3394 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3405 void ASTWriter::WriteSelectors(
Sema &SemaRef) {
3406 using namespace llvm;
3409 if (SemaRef.
MethodPool.empty() && SelectorIDs.empty())
3411 unsigned NumTableEntries = 0;
3414 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait> Generator;
3415 ASTMethodPoolTrait Trait(*
this);
3419 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
3420 for (
auto &SelectorAndID : SelectorIDs) {
3423 Sema::GlobalMethodPool::iterator F = SemaRef.
MethodPool.find(S);
3424 ASTMethodPoolTrait::data_type Data = {
3430 Data.Instance = F->second.first;
3431 Data.Factory = F->second.second;
3435 if (Chain && ID < FirstSelectorID) {
3437 bool changed =
false;
3439 !changed && M && M->
getMethod(); M = M->getNext()) {
3440 if (!M->getMethod()->isFromASTFile())
3445 if (!M->getMethod()->isFromASTFile())
3450 }
else if (Data.Instance.getMethod() || Data.Factory.getMethod()) {
3454 Generator.insert(S, Data, Trait);
3459 uint32_t BucketOffset;
3461 using namespace llvm::support;
3463 ASTMethodPoolTrait Trait(*
this);
3464 llvm::raw_svector_ostream Out(MethodPool);
3466 endian::write<uint32_t>(Out, 0, little);
3467 BucketOffset = Generator.Emit(Out, Trait);
3471 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3473 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3474 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3475 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3476 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3480 RecordData::value_type Record[] = {
METHOD_POOL, BucketOffset,
3482 Stream.EmitRecordWithBlob(MethodPoolAbbrev, Record, MethodPool);
3486 Abbrev = std::make_shared<BitCodeAbbrev>();
3488 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3489 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3490 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3491 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3495 RecordData::value_type Record[] = {
3498 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev, Record,
3499 bytes(SelectorOffsets));
3505 void ASTWriter::WriteReferencedSelectorsPool(
Sema &SemaRef) {
3506 using namespace llvm;
3518 Selector Sel = SelectorAndLocation.first;
3542 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3544 if (!Redecl->isFromASTFile()) {
3548 if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
3551 return cast<NamedDecl>(Redecl);
3556 if (Redecl->getOwningModuleID() == 0)
3561 if (!
First->isFromASTFile())
3562 return cast<NamedDecl>(
First);
3572 class ASTIdentifierTableTrait {
3597 using key_type_ref = key_type;
3600 using data_type_ref = data_type;
3602 using hash_value_type = unsigned;
3603 using offset_type = unsigned;
3608 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3609 NeedDecls(!IsModule || !Writer.
getLangOpts().CPlusPlus),
3610 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3612 bool needDecls()
const {
return NeedDecls; }
3615 return llvm::djbHash(II->
getName());
3627 std::pair<unsigned, unsigned>
3630 unsigned DataLen = 4;
3640 DEnd = IdResolver.
end();
3646 using namespace llvm::support;
3648 endian::Writer LE(Out, little);
3650 assert((uint16_t)DataLen == DataLen && (uint16_t)KeyLen == KeyLen);
3651 LE.write<uint16_t>(DataLen);
3655 LE.write<uint16_t>(KeyLen);
3656 return std::make_pair(KeyLen, DataLen);
3668 InterestingIdentifierOffsets->push_back(Out.tell() - 4);
3675 using namespace llvm::support;
3677 endian::Writer LE(Out, little);
3681 LE.write<uint32_t>(ID << 1);
3685 LE.write<uint32_t>((ID << 1) | 0x01);
3687 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
3688 LE.write<uint16_t>(Bits);
3690 bool HadMacroDefinition = MacroOffset != 0;
3691 Bits = (Bits << 1) |
unsigned(HadMacroDefinition);
3693 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
3697 LE.write<uint16_t>(Bits);
3699 if (HadMacroDefinition)
3700 LE.write<uint32_t>(MacroOffset);
3712 DEnd = Decls.rend();
3730 using namespace llvm;
3732 RecordData InterestingIdents;
3737 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait> Generator;
3738 ASTIdentifierTableTrait Trait(
3739 *
this, PP, IdResolver, IsModule,
3740 (getLangOpts().
CPlusPlus && IsModule) ? &InterestingIdents :
nullptr);
3749 IIs.push_back(
ID.second);
3752 llvm::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
3754 if (Trait.isInterestingNonMacroIdentifier(II))
3755 getIdentifierRef(II);
3759 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
3760 for (
auto IdentIDPair : IdentifierIDs) {
3763 assert(II &&
"NULL identifier in identifier table");
3766 if (ID >= FirstIdentID || !Chain || !II->isFromAST()
3767 || II->hasChangedSinceDeserialization() ||
3768 (Trait.needDecls() &&
3769 II->hasFETokenInfoChangedSinceDeserialization()))
3770 Generator.insert(II, ID, Trait);
3775 uint32_t BucketOffset;
3777 using namespace llvm::support;
3779 llvm::raw_svector_ostream Out(IdentifierTable);
3781 endian::write<uint32_t>(Out, 0, little);
3782 BucketOffset = Generator.Emit(Out, Trait);
3786 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3788 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3789 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3790 unsigned IDTableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3794 Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable);
3798 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3800 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3801 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3802 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3803 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3806 for (
unsigned I = 0, N = IdentifierOffsets.size(); I != N; ++I)
3807 assert(IdentifierOffsets[I] &&
"Missing identifier offset?");
3811 IdentifierOffsets.size(),
3813 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev, Record,
3814 bytes(IdentifierOffsets));
3818 if (!InterestingIdents.empty())
3829 class ASTDeclContextNameLookupTrait {
3835 using key_type_ref = key_type;
3838 using data_type = std::pair<unsigned, unsigned>;
3839 using data_type_ref =
const data_type &;
3841 using hash_value_type = unsigned;
3842 using offset_type = unsigned;
3844 explicit ASTDeclContextNameLookupTrait(
ASTWriter &Writer) : Writer(Writer) {}
3846 template<
typename Coll>
3847 data_type getData(
const Coll &Decls) {
3848 unsigned Start = DeclIDs.size();
3853 return std::make_pair(Start, DeclIDs.size());
3857 unsigned Start = DeclIDs.size();
3858 for (
auto ID : FromReader)
3859 DeclIDs.push_back(
ID);
3860 return std::make_pair(Start, DeclIDs.size());
3863 static bool EqualKey(key_type_ref a, key_type_ref b) {
3871 void EmitFileRef(raw_ostream &Out,
ModuleFile *F)
const {
3873 "have reference to loaded module file but no chain?");
3875 using namespace llvm::support;
3880 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
3882 data_type_ref Lookup) {
3883 using namespace llvm::support;
3885 endian::Writer LE(Out, little);
3886 unsigned KeyLen = 1;
3905 LE.write<uint16_t>(KeyLen);
3908 unsigned DataLen = 4 * (Lookup.second - Lookup.first);
3909 assert(uint16_t(DataLen) == DataLen &&
3910 "too many decls for serialized lookup result");
3911 LE.write<uint16_t>(DataLen);
3913 return std::make_pair(KeyLen, DataLen);
3917 using namespace llvm::support;
3919 endian::Writer LE(Out, little);
3920 LE.write<uint8_t>(Name.
getKind());
3934 "Invalid operator?");
3944 llvm_unreachable(
"Invalid name kind?");
3947 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
3949 using namespace llvm::support;
3951 endian::Writer LE(Out, little);
3952 uint64_t Start = Out.tell(); (void)Start;
3953 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
3954 LE.write<uint32_t>(DeclIDs[I]);
3955 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3963 return Result.
hasExternalDecls() && DC->NeedToReconcileExternalVisibleStorage;
3966 bool ASTWriter::isLookupResultEntirelyExternal(
StoredDeclsList &Result,
3976 ASTWriter::GenerateNameLookupTable(
const DeclContext *ConstDC,
3978 assert(!ConstDC->HasLazyLocalLexicalLookups &&
3979 !ConstDC->HasLazyExternalLexicalLookups &&
3980 "must call buildLookups first");
3988 ASTDeclContextNameLookupTrait> Generator;
3989 ASTDeclContextNameLookupTrait Trait(*
this);
3998 llvm::SmallSet<DeclarationName, 8> ConstructorNameSet, ConversionNameSet;
4001 auto &Name = Lookup.first;
4002 auto &Result = Lookup.second;
4008 if (isLookupResultExternal(Result, DC) &&
4009 isLookupResultEntirelyExternal(Result, DC))
4026 if (Lookup.second.getLookupResult().empty())
4029 switch (Lookup.first.getNameKind()) {
4031 Names.push_back(Lookup.first);
4035 assert(isa<CXXRecordDecl>(DC) &&
4036 "Cannot have a constructor name outside of a class!");
4037 ConstructorNameSet.insert(Name);
4041 assert(isa<CXXRecordDecl>(DC) &&
4042 "Cannot have a conversion function name outside of a class!");
4043 ConversionNameSet.insert(Name);
4049 llvm::sort(Names.begin(), Names.end());
4051 if (
auto *D = dyn_cast<CXXRecordDecl>(DC)) {
4065 if (ConstructorNameSet.erase(ImplicitCtorName))
4066 Names.push_back(ImplicitCtorName);
4071 if (!ConstructorNameSet.empty() || !ConversionNameSet.empty())
4072 for (
Decl *ChildD : cast<CXXRecordDecl>(DC)->decls())
4073 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
4074 auto Name = ChildND->getDeclName();
4075 switch (Name.getNameKind()) {
4080 if (ConstructorNameSet.erase(Name))
4081 Names.push_back(Name);
4085 if (ConversionNameSet.erase(Name))
4086 Names.push_back(Name);
4090 if (ConstructorNameSet.empty() && ConversionNameSet.empty())
4094 assert(ConstructorNameSet.empty() &&
"Failed to find all of the visible " 4095 "constructors by walking all the " 4096 "lexical members of the context.");
4097 assert(ConversionNameSet.empty() &&
"Failed to find all of the visible " 4098 "conversion functions by walking all " 4099 "the lexical members of the context.");
4106 for (
auto &Name : Names)
4118 for (
auto &Name : Names) {
4121 switch (Name.getNameKind()) {
4123 Generator.insert(Name, Trait.getData(Result), Trait);
4127 ConstructorDecls.append(Result.
begin(), Result.
end());
4131 ConversionDecls.append(Result.
begin(), Result.
end());
4139 if (!ConstructorDecls.empty())
4140 Generator.insert(ConstructorDecls.front()->getDeclName(),
4141 Trait.getData(ConstructorDecls), Trait);
4142 if (!ConversionDecls.empty())
4143 Generator.insert(ConversionDecls.front()->getDeclName(),
4144 Trait.getData(ConversionDecls), Trait);
4148 auto *Lookups = Chain ? Chain->getLoadedLookupTables(DC) :
nullptr;
4149 Generator.emit(LookupTable, Trait, Lookups ? &Lookups->Table :
nullptr);
4157 uint64_t ASTWriter::WriteDeclContextVisibleBlock(
ASTContext &Context,
4162 if (isa<NamespaceDecl>(DC) && Chain &&
4163 Chain->getKeyDeclaration(cast<Decl>(DC))->isFromASTFile()) {
4165 for (
auto *Prev = cast<NamespaceDecl>(DC)->getPreviousDecl(); Prev;
4166 Prev = Prev->getPreviousDecl())
4167 if (!Prev->isFromASTFile())
4180 LookupResults.reserve(Map->size());
4181 for (
auto &Entry : *Map)
4182 LookupResults.push_back(
4183 std::make_pair(Entry.first, Entry.second.getLookupResult()));
4186 llvm::sort(LookupResults.begin(), LookupResults.end(), llvm::less_first());
4187 for (
auto &NameAndResult : LookupResults) {
4195 assert(Result.
empty() &&
"Cannot have a constructor or conversion " 4196 "function name in a namespace!");
4201 if (!ND->isFromASTFile())
4225 uint64_t
Offset = Stream.GetCurrentBitNo();
4227 if (!Map || Map->empty())
4232 GenerateNameLookupTable(DC, LookupTable);
4236 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev, Record,
4238 ++NumVisibleDeclContexts;
4248 void ASTWriter::WriteDeclContextVisibleUpdate(
const DeclContext *DC) {
4250 if (!Map || Map->empty())
4255 GenerateNameLookupTable(DC, LookupTable);
4259 if (isa<NamespaceDecl>(DC))
4260 DC = cast<DeclContext>(Chain->getKeyDeclaration(cast<Decl>(DC)));
4263 RecordData::value_type Record[] = {
UPDATE_VISIBLE, getDeclID(cast<Decl>(DC))};
4264 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev, Record, LookupTable);
4268 void ASTWriter::WriteFPPragmaOptions(
const FPOptions &Opts) {
4269 RecordData::value_type Record[] = {Opts.
getInt()};
4274 void ASTWriter::WriteOpenCLExtensions(
Sema &SemaRef) {
4280 for (
const auto &I:Opts.OptMap) {
4281 AddString(I.getKey(), Record);
4282 auto V = I.getValue();
4283 Record.push_back(V.Supported ? 1 : 0);
4284 Record.push_back(V.Enabled ? 1 : 0);
4285 Record.push_back(V.Avail);
4286 Record.push_back(V.Core);
4291 void ASTWriter::WriteOpenCLExtensionTypes(
Sema &SemaRef) {
4296 for (
const auto &I : SemaRef.OpenCLTypeExtMap) {
4298 static_cast<unsigned>(getTypeID(I.first->getCanonicalTypeInternal())));
4299 Record.push_back(I.second.size());
4300 for (
auto Ext : I.second)
4301 AddString(Ext, Record);
4306 void ASTWriter::WriteOpenCLExtensionDecls(
Sema &SemaRef) {
4311 for (
const auto &I : SemaRef.OpenCLDeclExtMap) {
4312 Record.push_back(getDeclID(I.first));
4313 Record.push_back(static_cast<unsigned>(I.second.size()));
4314 for (
auto Ext : I.second)
4315 AddString(Ext, Record);
4320 void ASTWriter::WriteCUDAPragmas(
Sema &SemaRef) {
4321 if (SemaRef.ForceCUDAHostDeviceDepth > 0) {
4322 RecordData::value_type Record[] = {SemaRef.ForceCUDAHostDeviceDepth};
4327 void ASTWriter::WriteObjCCategories() {
4329 RecordData Categories;
4331 for (
unsigned I = 0, N = ObjCClassesWithCategories.size(); I != N; ++I) {
4333 unsigned StartIndex = Categories.size();
4338 Categories.push_back(0);
4344 Cat != CatEnd; ++Cat, ++Size) {
4345 assert(getDeclID(*Cat) != 0 &&
"Bogus category");
4346 AddDeclRef(*Cat, Categories);
4350 Categories[StartIndex] = Size;
4354 CategoriesMap.push_back(CatInfo);
4359 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
4362 using namespace llvm;
4364 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4366 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
4367 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4368 unsigned AbbrevID = Stream.EmitAbbrev(std::move(Abbrev));
4371 Stream.EmitRecordWithBlob(AbbrevID, Record,
4372 reinterpret_cast<char *>(CategoriesMap.data()),
4379 void ASTWriter::WriteLateParsedTemplates(
Sema &SemaRef) {
4386 for (
auto &LPTMapEntry : LPTMap) {
4389 AddDeclRef(FD, Record);
4390 AddDeclRef(LPT.
D, Record);
4391 Record.push_back(LPT.
Toks.size());
4393 for (
const auto &
Tok : LPT.
Toks) {
4394 AddToken(
Tok, Record);
4401 void ASTWriter::WriteOptimizePragmaOptions(
Sema &SemaRef) {
4404 AddSourceLocation(PragmaLoc, Record);
4409 void ASTWriter::WriteMSStructPragmaOptions(
Sema &SemaRef) {
4417 void ASTWriter::WriteMSPointersToMembersPragmaOptions(
Sema &SemaRef) {
4425 void ASTWriter::WritePackPragmaOptions(
Sema &SemaRef) {
4436 Record.push_back(StackEntry.Value);
4437 AddSourceLocation(StackEntry.PragmaLocation, Record);
4438 AddSourceLocation(StackEntry.PragmaPushLocation, Record);
4439 AddString(StackEntry.StackSlotLabel, Record);
4444 void ASTWriter::WriteModuleFileExtension(
Sema &SemaRef,
4450 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
4452 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4453 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4454 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4455 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4456 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4457 unsigned Abbrev = Stream.EmitAbbrev(std::move(Abv));
4463 Record.push_back(Metadata.MajorVersion);
4464 Record.push_back(Metadata.MinorVersion);
4465 Record.push_back(Metadata.BlockName.size());
4466 Record.push_back(Metadata.UserInfo.size());
4468 Buffer += Metadata.BlockName;
4469 Buffer += Metadata.UserInfo;
4470 Stream.EmitRecordWithBlob(Abbrev, Record, Buffer);
4485 auto &Record = *
this;
4486 Record.push_back(Attrs.size());
4487 for (
const auto *A : Attrs) {
4488 Record.push_back(A->getKind());
4489 Record.AddSourceRange(A->getRange());
4491 #include "clang/Serialization/AttrPCHWrite.inc" 4503 Record.push_back(Tok.
getKind());
4509 Record.push_back(Str.size());
4510 Record.insert(Record.end(), Str.begin(), Str.end());
4514 assert(Context &&
"should have context when outputting path");
4520 const char *PathBegin = Path.data();
4521 const char *PathPtr =
4523 if (PathPtr != PathBegin) {
4524 Path.erase(Path.begin(), Path.begin() + (PathPtr - PathBegin));
4533 PreparePathForOutput(FilePath);
4534 AddString(FilePath, Record);
4540 PreparePathForOutput(FilePath);
4541 Stream.EmitRecordWithBlob(Abbrev, Record, FilePath);
4546 Record.push_back(Version.getMajor());
4548 Record.push_back(*Minor + 1);
4550 Record.push_back(0);
4552 Record.push_back(*Subminor + 1);
4554 Record.push_back(0);
4563 if (ID >= FirstIdentID)
4564 IdentifierOffsets[ID - FirstIdentID] =
Offset;
4570 unsigned ID = SelectorIDs[Sel];
4571 assert(ID &&
"Unknown selector");
4574 if (ID < FirstSelectorID)
4576 SelectorOffsets[ID - FirstSelectorID] =
Offset;
4581 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
4582 bool IncludeTimestamps)
4583 : Stream(Stream), Buffer(Buffer), PCMCache(PCMCache),
4584 IncludeTimestamps(IncludeTimestamps) {
4585 for (
const auto &Ext : Extensions) {
4586 if (
auto Writer = Ext->createExtensionWriter(*
this))
4587 ModuleFileExtensionWriters.push_back(std::move(Writer));
4592 llvm::DeleteContainerSeconds(FileDeclIDs);
4596 assert(WritingAST &&
"can't determine lang opts when not writing AST");
4605 const std::string &OutputFile,
4606 Module *WritingModule, StringRef isysroot,
4610 ASTHasCompilerErrors = hasErrors;
4613 Stream.Emit((
unsigned)
'C', 8);
4614 Stream.Emit((
unsigned)
'P', 8);
4615 Stream.Emit((
unsigned)
'C', 8);
4616 Stream.Emit((
unsigned)
'H', 8);
4618 WriteBlockInfoBlock();
4622 this->WritingModule = WritingModule;
4624 WriteASTCore(SemaRef, isysroot, OutputFile, WritingModule);
4627 this->WritingModule =
nullptr;
4628 this->BaseDirectory.clear();
4634 llvm::MemoryBuffer::getMemBufferCopy(
4635 StringRef(Buffer.begin(), Buffer.size())));
4640 template<
typename Vector>
4643 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
4650 const std::string &OutputFile,
4652 using namespace llvm;
4654 bool isModule = WritingModule !=
nullptr;
4658 Chain->finalizeForWriting();
4675 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
4679 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
4683 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
4686 RegisterPredefDecl(Context.MakeIntegerSeqDecl,
4688 RegisterPredefDecl(Context.CFConstantStringTypeDecl,
4690 RegisterPredefDecl(Context.CFConstantStringTagDecl,
4692 RegisterPredefDecl(Context.TypePackElementDecl,
4705 UnusedFileScopedDecls);
4719 WeakInfo &WI = WeakUndeclaredIdentifier.second;
4723 WeakUndeclaredIdentifiers.push_back(WI.
getUsed());
4733 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I) {
4743 AddDeclRef(TD, UnusedLocalTypedefNameCandidates);
4752 "There are local ones at end of translation unit!");
4769 for (
const auto &I : SemaRef.KnownNamespaces) {
4779 for (
const auto &I : Undefined) {
4789 for (
const auto &DeleteExprsInfo :
4791 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
4792 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
4793 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
4795 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
4801 WriteControlBlock(PP, Context, isysroot, OutputFile);
4819 NewGlobalKindDeclPairs.push_back(D->
getKind());
4820 NewGlobalKindDeclPairs.push_back(
GetDeclRef(D));
4824 auto Abv = std::make_shared<BitCodeAbbrev>();
4826 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4827 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
4830 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev, Record,
4831 bytes(NewGlobalKindDeclPairs));
4835 Abv = std::make_shared<BitCodeAbbrev>();
4837 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4838 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4839 UpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
4840 WriteDeclContextVisibleUpdate(TU);
4843 if (Context.ExternCContext)
4844 WriteDeclContextVisibleUpdate(Context.ExternCContext);
4858 for (
const auto &Number : Context.MangleNumbers)
4859 if (!Number.first->isFromASTFile())
4862 for (
const auto &Number : Context.StaticLocalNumbers)
4863 if (!Number.first->isFromASTFile())
4870 for (
const auto *I : DeclsToEmitEvenIfUnreferenced) {
4884 llvm::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
4902 for (
auto &SelectorAndID : SelectorIDs)
4903 AllSelectors.push_back(SelectorAndID.first);
4904 for (
auto &
Selector : AllSelectors)
4913 AddTypeRef(Context.ObjCIdRedefinitionType, SpecialTypes);
4914 AddTypeRef(Context.ObjCClassRedefinitionType, SpecialTypes);
4915 AddTypeRef(Context.ObjCSelRedefinitionType, SpecialTypes);
4938 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4940 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4941 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4944 llvm::raw_svector_ostream Out(Buffer);
4946 using namespace llvm::support;
4948 endian::Writer LE(Out, little);
4949 LE.write<uint8_t>(
static_cast<uint8_t
>(M.
Kind));
4954 LE.write<uint16_t>(Name.size());
4955 Out.write(Name.data(), Name.size());
4961 auto writeBaseIDOrNone = [&](uint32_t BaseID,
bool ShouldWrite) {
4964 LE.write<uint32_t>(BaseID);
4966 LE.write<uint32_t>(
None);
4983 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev, Record,
4984 Buffer.data(), Buffer.size());
4995 WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord);
4996 while (!DeclTypesToEmit.empty()) {
4997 DeclOrType DOT = DeclTypesToEmit.front();
4998 DeclTypesToEmit.pop();
5000 WriteType(DOT.getType());
5002 WriteDecl(Context, DOT.getDecl());
5004 }
while (!DeclUpdates.empty());
5007 DoneWritingDeclsAndTypes =
true;
5010 WriteTypeDeclOffsets();
5011 if (!DeclUpdatesOffsetsRecord.empty())
5013 WriteFileDeclIDsMap();
5016 WritePreprocessor(PP, isModule);
5018 WriteSelectors(SemaRef);
5019 WriteReferencedSelectorsPool(SemaRef);
5020 WriteLateParsedTemplates(SemaRef);
5021 WriteIdentifierTable(PP, SemaRef.
IdResolver, isModule);
5023 WriteOpenCLExtensions(SemaRef);
5024 WriteOpenCLExtensionTypes(SemaRef);
5025 WriteOpenCLExtensionDecls(SemaRef);
5026 WriteCUDAPragmas(SemaRef);
5030 WriteSubmodules(WritingModule);
5035 if (!EagerlyDeserializedDecls.empty())
5038 if (!ModularCodegenDecls.empty())
5042 if (!TentativeDefinitions.empty())
5046 if (!UnusedFileScopedDecls.empty())
5050 if (!WeakUndeclaredIdentifiers.empty())
5052 WeakUndeclaredIdentifiers);
5055 if (!ExtVectorDecls.empty())
5059 if (!VTableUses.empty())
5063 if (!UnusedLocalTypedefNameCandidates.empty())
5065 UnusedLocalTypedefNameCandidates);
5068 if (!PendingInstantiations.empty())
5072 if (!SemaDeclRefs.empty())
5076 if (!CUDASpecialDeclRefs.empty())
5080 if (!DelegatingCtorDecls.empty())
5084 if (!KnownNamespaces.empty())
5088 if (!UndefinedButUsed.empty())
5091 if (!DeleteExprsToAnalyze.empty())
5095 for (
auto *DC : UpdatedDeclContexts)
5096 WriteDeclContextVisibleUpdate(DC);
5098 if (!WritingModule) {
5103 ModuleInfo(uint64_t ID,
Module *M) :
ID(ID), M(M) {}
5107 assert(SubmoduleIDs.find(I->getImportedModule()) != SubmoduleIDs.end());
5108 Imports.push_back(ModuleInfo(SubmoduleIDs[I->getImportedModule()],
5109 I->getImportedModule()));
5112 if (!Imports.empty()) {
5113 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
5116 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
5117 return A.ID == B.ID;
5121 llvm::sort(Imports.begin(), Imports.end(), Cmp);
5122 Imports.erase(std::unique(Imports.begin(), Imports.end(), Eq),
5126 for (
const auto &Import : Imports) {
5127 ImportedModules.push_back(Import.ID);
5138 WriteObjCCategories();
5139 if(!WritingModule) {
5140 WriteOptimizePragmaOptions(SemaRef);
5141 WriteMSStructPragmaOptions(SemaRef);
5142 WriteMSPointersToMembersPragmaOptions(SemaRef);
5144 WritePackPragmaOptions(SemaRef);
5147 RecordData::value_type Record[] = {
5148 NumStatements, NumMacros, NumLexicalDeclContexts, NumVisibleDeclContexts};
5153 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
5154 WriteModuleFileExtension(SemaRef, *ExtWriter);
5156 return writeUnhashedControlBlock(PP, Context);
5159 void ASTWriter::WriteDeclUpdatesBlocks(
RecordDataImpl &OffsetsRecord) {
5160 if (DeclUpdates.empty())
5163 DeclUpdateMap LocalUpdates;
5164 LocalUpdates.swap(DeclUpdates);
5166 for (
auto &DeclUpdate : LocalUpdates) {
5167 const Decl *D = DeclUpdate.first;
5169 bool HasUpdatedBody =
false;
5172 for (
auto &
Update : DeclUpdate.second) {
5178 HasUpdatedBody =
true;
5186 assert(
Update.getDecl() &&
"no decl to add?");
5199 const VarDecl *VD = cast<VarDecl>(D);
5213 Record.
AddStmt(const_cast<Expr *>(
5214 cast<ParmVarDecl>(
Update.getDecl())->getDefaultArg()));
5219 cast<FieldDecl>(
Update.getDecl())->getInClassInitializer());
5223 auto *RD = cast<CXXRecordDecl>(D);
5224 UpdatedDeclContexts.insert(RD->getPrimaryContext());
5225 Record.
push_back(RD->isParamDestroyedInCallee());
5226 Record.
push_back(RD->getArgPassingRestrictions());
5228 Record.
AddOffset(WriteDeclContextLexicalBlock(
5229 *Context, const_cast<CXXRecordDecl *>(RD)));
5234 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
5235 Record.
push_back(MSInfo->getTemplateSpecializationKind());
5238 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
5239 Record.
push_back(Spec->getTemplateSpecializationKind());
5244 auto From = Spec->getInstantiatedFrom();
5245 if (
auto PartialSpec =
5250 &Spec->getTemplateInstantiationArgs());
5271 Record.
AddStmt(cast<CXXDestructorDecl>(D)->getOperatorDeleteThisArg());
5276 cast<FunctionDecl>(D)->getType()->castAs<FunctionProtoType>(),
5294 D->
getAttr<OMPThreadPrivateDeclAttr>()->getRange());
5299 D->
getAttr<OMPDeclareTargetDeclAttr>()->getRange());
5312 if (HasUpdatedBody) {
5313 const auto *Def = cast<FunctionDecl>(D);
5327 Record.push_back((Raw << 1) | (Raw >> 31));
5336 Record->push_back(Value.getBitWidth());
5337 const uint64_t *Words = Value.getRawData();
5338 Record->append(Words, Words + Value.getNumWords());
5342 Record->push_back(Value.isUnsigned());
5347 AddAPInt(Value.bitcastToAPInt());
5374 MacroInfoToEmitData Info = { Name, MI, ID };
5375 MacroInfosToEmit.push_back(Info);
5384 assert(MacroIDs.find(MI) != MacroIDs.end() &&
"Macro not emitted!");
5385 return MacroIDs[MI];
5389 return IdentMacroDirectivesOffsetMap.lookup(Name);
5393 Record->push_back(Writer->getSelectorRef(SelRef));
5402 if (SID == 0 && Chain) {
5405 Chain->LoadSelector(Sel);
5406 SID = SelectorIDs[Sel];
5409 SID = NextSelectorID++;
5410 SelectorIDs[Sel] = SID;
5451 bool InfoHasSameExpr
5453 Record->push_back(InfoHasSameExpr);
5454 if (InfoHasSameExpr)
5471 TypeLocWriter TLW(*
this);
5488 if (Idx.getIndex() == 0) {
5489 if (DoneWritingDeclsAndTypes) {
5490 assert(0 &&
"New type seen after serializing all the types to emit!");
5497 DeclTypesToEmit.push(T);
5510 TypeIdxMap::const_iterator I = TypeIdxs.find(T);
5511 assert(I != TypeIdxs.end() &&
"Type not emitted!");
5521 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
5532 assert(!(reinterpret_cast<uintptr_t>(D) & 0x01) &&
"Invalid decl pointer");
5535 if (DoneWritingDeclsAndTypes) {
5536 assert(0 &&
"New decl seen after serializing all the decls to emit!");
5543 DeclTypesToEmit.push(const_cast<Decl *>(D));
5558 assert(DeclIDs.find(D) != DeclIDs.end() &&
"Declaration not emitted!");
5562 void ASTWriter::associateDeclWithFile(
const Decl *D,
DeclID ID) {
5577 if (isa<ParmVarDecl>(D) || isa<TemplateTemplateParmDecl>(D))
5586 if (FID.isInvalid())
5590 DeclIDInFileInfo *&Info = FileDeclIDs[FID];
5592 Info =
new DeclIDInFileInfo();
5594 std::pair<unsigned, serialization::DeclID> LocDecl(Offset, ID);
5597 if (Decls.empty() || Decls.back().first <=
Offset) {
5598 Decls.push_back(LocDecl);
5602 LocDeclIDsTy::iterator I =
5603 std::upper_bound(Decls.begin(), Decls.end(), LocDecl, llvm::less_first());
5605 Decls.insert(I, LocDecl);
5648 "expected an anonymous declaration");
5652 auto It = AnonymousDeclarationNumbers.find(D);
5653 if (It == AnonymousDeclarationNumbers.end()) {
5656 AnonymousDeclarationNumbers[ND] = Number;
5659 It = AnonymousDeclarationNumbers.find(D);
5660 assert(It != AnonymousDeclarationNumbers.end() &&
5661 "declaration not found within its lexical context");
5700 AddDeclarationName(NameInfo.
getName());
5719 NestedNames.push_back(NNS);
5723 Record->push_back(NestedNames.size());
5724 while(!NestedNames.empty()) {
5725 NNS = NestedNames.pop_back_val();
5727 Record->push_back(Kind);
5766 NestedNames.push_back(NNS);
5770 Record->push_back(NestedNames.size());
5771 while(!NestedNames.empty()) {
5772 NNS = NestedNames.pop_back_val();
5775 Record->push_back(Kind);
5814 Record->push_back(Kind);
5822 Record->push_back(OvT->
size());
5823 for (
const auto &I : *OvT)
5866 Record->push_back(Arg.
getKind());
5890 Record->push_back(*NumExpansions + 1);
5892 Record->push_back(0);
5900 AddTemplateArgument(
P);
5907 assert(TemplateParams &&
"No TemplateParams!");
5912 Record->push_back(TemplateParams->
size());
5913 for (
const auto &
P : *TemplateParams)
5920 assert(TemplateArgs &&
"No TemplateArgs!");
5921 Record->push_back(TemplateArgs->
size());
5922 for (
int i = 0, e = TemplateArgs->
size(); i != e; ++i)
5923 AddTemplateArgument(TemplateArgs->
get(i));
5928 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
5934 AddTemplateArgumentLoc(TemplArgs[i]);
5938 Record->push_back(Set.
size());
5940 I = Set.
begin(), E = Set.
end(); I != E; ++I) {
5942 Record->push_back(I.getAccess());
5964 for (
auto &
Base : Bases)
5982 for (
auto *Init : CtorInits) {
5983 if (Init->isBaseInitializer()) {
5986 Writer.
push_back(Init->isBaseVirtual());
5987 }
else if (Init->isDelegatingInitializer()) {
5990 }
else if (Init->isMemberInitializer()){
5995 Writer.
AddDeclRef(Init->getIndirectMember());
5999 Writer.
AddStmt(Init->getInit());
6003 if (Init->isWritten())
6004 Writer.
push_back(Init->getSourceOrder());
6017 auto &Data = D->data();
6018 Record->push_back(Data.IsLambda);
6019 Record->push_back(Data.UserDeclaredConstructor);
6020 Record->push_back(Data.UserDeclaredSpecialMembers);
6021 Record->push_back(Data.Aggregate);
6022 Record->push_back(Data.PlainOldData);
6023 Record->push_back(Data.Empty);
6024 Record->push_back(Data.Polymorphic);
6025 Record->push_back(Data.Abstract);
6026 Record->push_back(Data.IsStandardLayout);
6027 Record->push_back(Data.IsCXX11StandardLayout);
6028 Record->push_back(Data.HasBasesWithFields);
6029 Record->push_back(Data.HasBasesWithNonStaticDataMembers);
6030 Record->push_back(Data.HasPrivateFields);
6031 Record->push_back(Data.HasProtectedFields);
6032 Record->push_back(Data.HasPublicFields);
6033 Record->push_back(Data.HasMutableFields);
6034 Record->push_back(Data.HasVariantMembers);
6035 Record->push_back(Data.HasOnlyCMembers);
6036 Record->push_back(Data.HasInClassInitializer);
6037 Record->push_back(Data.HasUninitializedReferenceMember);
6038 Record->push_back(Data.HasUninitializedFields);
6039 Record->push_back(Data.HasInheritedConstructor);
6040 Record->push_back(Data.HasInheritedAssignment);
6041 Record->push_back(Data.NeedOverloadResolutionForCopyConstructor);
6042 Record->push_back(Data.NeedOverloadResolutionForMoveConstructor);
6043 Record->push_back(Data.NeedOverloadResolutionForMoveAssignment);
6044 Record->push_back(Data.NeedOverloadResolutionForDestructor);
6045 Record->push_back(Data.DefaultedCopyConstructorIsDeleted);
6046 Record->push_back(Data.DefaultedMoveConstructorIsDeleted);
6047 Record->push_back(Data.DefaultedMoveAssignmentIsDeleted);
6048 Record->push_back(Data.DefaultedDestructorIsDeleted);
6049 Record->push_back(Data.HasTrivialSpecialMembers);
6050 Record->push_back(Data.HasTrivialSpecialMembersForCall);
6051 Record->push_back(Data.DeclaredNonTrivialSpecialMembers);
6052 Record->push_back(Data.DeclaredNonTrivialSpecialMembersForCall);
6053 Record->push_back(Data.HasIrrelevantDestructor);
6054 Record->push_back(Data.HasConstexprNonCopyMoveConstructor);
6055 Record->push_back(Data.HasDefaultedDefaultConstructor);
6056 Record->push_back(Data.DefaultedDefaultConstructorIsConstexpr);
6057 Record->push_back(Data.HasConstexprDefaultConstructor);
6058 Record->push_back(Data.HasNonLiteralTypeFieldsOrBases);
6059 Record->push_back(Data.ComputedVisibleConversions);
6060 Record->push_back(Data.UserProvidedDefaultConstructor);
6061 Record->push_back(Data.DeclaredSpecialMembers);
6062 Record->push_back(Data.ImplicitCopyConstructorCanHaveConstParamForVBase);
6063 Record->push_back(Data.ImplicitCopyConstructorCanHaveConstParamForNonVBase);
6064 Record->push_back(Data.ImplicitCopyAssignmentHasConstParam);
6065 Record->push_back(Data.HasDeclaredCopyConstructorWithConstParam);
6066 Record->push_back(Data.HasDeclaredCopyAssignmentWithConstParam);
6070 bool ModulesDebugInfo = Writer->Context->getLangOpts().ModulesDebugInfo &&
6072 Record->push_back(ModulesDebugInfo);
6073 if (ModulesDebugInfo)
6074 Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(D));
6078 Record->push_back(Data.NumBases);
6079 if (Data.NumBases > 0)
6080 AddCXXBaseSpecifiers(Data.bases());
6083 Record->push_back(Data.NumVBases);
6084 if (Data.NumVBases > 0)
6085 AddCXXBaseSpecifiers(Data.vbases());
6087 AddUnresolvedSet(Data.Conversions.get(*Writer->Context));
6088 AddUnresolvedSet(Data.VisibleConversions.get(*Writer->Context));
6093 if (Data.IsLambda) {
6094 auto &Lambda = D->getLambdaData();
6095 Record->push_back(Lambda.Dependent);
6096 Record->push_back(Lambda.IsGenericLambda);
6097 Record->push_back(Lambda.CaptureDefault);
6098 Record->push_back(Lambda.NumCaptures);
6099 Record->push_back(Lambda.NumExplicitCaptures);
6100 Record->push_back(Lambda.ManglingNumber);
6102 AddTypeSourceInfo(Lambda.MethodTyInfo);
6103 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
6126 void ASTWriter::ReaderInitialized(
ASTReader *Reader) {
6127 assert(Reader &&
"Cannot remove chain");
6128 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
6129 assert(FirstDeclID == NextDeclID &&
6130 FirstTypeID == NextTypeID &&
6131 FirstIdentID == NextIdentID &&
6132 FirstMacroID == NextMacroID &&
6133 FirstSubmoduleID == NextSubmoduleID &&
6134 FirstSelectorID == NextSelectorID &&
6135 "Setting chain after writing has started.");
6147 NextDeclID = FirstDeclID;
6148 NextTypeID = FirstTypeID;
6149 NextIdentID = FirstIdentID;
6150 NextMacroID = FirstMacroID;
6151 NextSelectorID = FirstSelectorID;
6152 NextSubmoduleID = FirstSubmoduleID;
6157 IdentID &StoredID = IdentifierIDs[II];
6164 MacroID &StoredID = MacroIDs[MI];
6175 TypeIdx &StoredIdx = TypeIdxs[T];
6189 assert(MacroDefinitions.find(MD) == MacroDefinitions.end());
6190 MacroDefinitions[MD] =
ID;
6194 assert(SubmoduleIDs.find(Mod) == SubmoduleIDs.end());
6195 SubmoduleIDs[Mod] =
ID;
6198 void ASTWriter::CompletedTagDefinition(
const TagDecl *D) {
6199 if (Chain && Chain->isProcessingUpdateRecords())
return;
6201 assert(!WritingAST &&
"Already writing the AST!");
6202 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
6204 if (RD->isFromASTFile()) {
6209 "completed a tag from another module but not by instantiation?");
6210 DeclUpdates[RD].push_back(
6225 void ASTWriter::AddedVisibleDecl(
const DeclContext *DC,
const Decl *D) {
6226 if (Chain && Chain->isProcessingUpdateRecords())
return;
6228 "Should not add lookup results to non-lookup contexts!");
6231 if (isa<TranslationUnitDecl>(DC))
6239 !isa<FunctionTemplateDecl>(D))
6249 assert(!WritingAST &&
"Already writing the AST!");
6250 if (UpdatedDeclContexts.insert(DC) && !cast<Decl>(DC)->isFromASTFile()) {
6254 for (
auto *Child : DC->
decls())
6255 DeclsToEmitEvenIfUnreferenced.push_back(Child);
6257 DeclsToEmitEvenIfUnreferenced.push_back(D);
6260 void ASTWriter::AddedCXXImplicitMember(
const CXXRecordDecl *RD,
const Decl *D) {
6261 if (Chain && Chain->isProcessingUpdateRecords())
return;
6269 if (!isa<CXXMethodDecl>(D))
6274 assert(!WritingAST &&
"Already writing the AST!");
6278 void ASTWriter::ResolvedExceptionSpec(
const FunctionDecl *FD) {
6279 if (Chain && Chain->isProcessingUpdateRecords())
return;
6280 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
6282 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
6287 ->castAs<FunctionProtoType>()
6288 ->getExceptionSpecType()))
6294 if (Chain && Chain->isProcessingUpdateRecords())
return;
6295 assert(!WritingAST &&
"Already writing the AST!");
6297 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
6298 DeclUpdates[D].push_back(
6306 if (Chain && Chain->isProcessingUpdateRecords())
return;
6307 assert(!WritingAST &&
"Already writing the AST!");
6308 assert(Delete &&
"Not given an operator delete");
6310 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
6315 void ASTWriter::CompletedImplicitDefinition(
const FunctionDecl *D) {
6316 if (Chain && Chain->isProcessingUpdateRecords())
return;
6317 assert(!WritingAST &&
"Already writing the AST!");
6325 void ASTWriter::VariableDefinitionInstantiated(
const VarDecl *D) {
6326 if (Chain && Chain->isProcessingUpdateRecords())
return;
6327 assert(!WritingAST &&
"Already writing the AST!");
6334 void ASTWriter::FunctionDefinitionInstantiated(
const FunctionDecl *D) {
6335 if (Chain && Chain->isProcessingUpdateRecords())
return;
6336 assert(!WritingAST &&
"Already writing the AST!");
6343 void ASTWriter::InstantiationRequested(
const ValueDecl *D) {
6344 if (Chain && Chain->isProcessingUpdateRecords())
return;
6345 assert(!WritingAST &&
"Already writing the AST!");
6352 if (
auto *VD = dyn_cast<VarDecl>(D))
6353 POI = VD->getPointOfInstantiation();
6355 POI = cast<FunctionDecl>(D)->getPointOfInstantiation();
6359 void ASTWriter::DefaultArgumentInstantiated(
const ParmVarDecl *D) {
6360 if (Chain && Chain->isProcessingUpdateRecords())
return;
6361 assert(!WritingAST &&
"Already writing the AST!");
6365 DeclUpdates[D].push_back(
6369 void ASTWriter::DefaultMemberInitializerInstantiated(
const FieldDecl *D) {
6370 assert(!WritingAST &&
"Already writing the AST!");
6374 DeclUpdates[D].push_back(
6380 if (Chain && Chain->isProcessingUpdateRecords())
return;
6381 assert(!WritingAST &&
"Already writing the AST!");
6385 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
6386 ObjCClassesWithCategories.insert(
6390 void ASTWriter::DeclarationMarkedUsed(
const Decl *D) {
6391 if (Chain && Chain->isProcessingUpdateRecords())
return;
6392 assert(!WritingAST &&
"Already writing the AST!");
6404 void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(
const Decl *D) {
6405 if (Chain && Chain->isProcessingUpdateRecords())
return;
6406 assert(!WritingAST &&
"Already writing the AST!");
6413 void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
6415 if (Chain && Chain->isProcessingUpdateRecords())
return;
6416 assert(!WritingAST &&
"Already writing the AST!");
6420 DeclUpdates[D].push_back(
6424 void ASTWriter::RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M) {
6425 if (Chain && Chain->isProcessingUpdateRecords())
return;
6426 assert(!WritingAST &&
"Already writing the AST!");
6427 assert(D->
isHidden() &&
"expected a hidden declaration");
6431 void ASTWriter::AddedAttributeToRecord(
const Attr *Attr,
6433 if (Chain && Chain->isProcessingUpdateRecords())
return;
6434 assert(!WritingAST &&
"Already writing the AST!");
6440 void ASTWriter::AddedCXXTemplateSpecialization(
6442 assert(!WritingAST &&
"Already writing the AST!");
6446 if (Chain && Chain->isProcessingUpdateRecords())
6449 DeclsToEmitEvenIfUnreferenced.push_back(D);
6452 void ASTWriter::AddedCXXTemplateSpecialization(
6454 assert(!WritingAST &&
"Already writing the AST!");
6458 if (Chain && Chain->isProcessingUpdateRecords())
6461 DeclsToEmitEvenIfUnreferenced.push_back(D);
6466 assert(!WritingAST &&
"Already writing the AST!");
6470 if (Chain && Chain->isProcessingUpdateRecords())
6473 DeclsToEmitEvenIfUnreferenced.push_back(D);
A CXXConstCastExpr record.
unsigned char getOpaqueValue() const
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)
Represents 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.
bool getNoCfCheck() const
The macro directives history for a particular identifier.
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
const std::vector< SourceRange > & getSkippedRanges()
Retrieve all ranges that got skipped while preprocessing.
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)
bool isExpansionTokenRange() const
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.
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.
SourceLocation getAttributeLoc() const
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
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.
Represents 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.
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.
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.
Represents a member of a struct/union/class.
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.
TagDecl * getOwnedTagDecl() const
Return the (re)declaration of this type owned by this occurrence of this type, or nullptr if none...
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.
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)
SourceLocation getComposedLoc(FileID FID, unsigned Offset) const
Form a SourceLocation from a FileID and Offset pair.
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
A new-allocated array of size NumTemplParamLists, containing pointers to the "outer" template paramet...
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.
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 source location information for a type. Does not emit the type.
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.
Expr * getSizeExpr() const
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
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 table of skipped ranges within the preprocessing record.
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.
for(unsigned I=0, E=TL.getNumArgs();I !=E;++I)
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.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
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.
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.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
Record code for the set of source location entries that need to be preloaded by the AST reader...
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
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.
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()
Represents a vector type where either the type or size is dependent.
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.
A dependentSizedVectorType record.
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.
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.
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.
unsigned ModuleMapIsPrivate
Whether this module came from a "private" module map, found next to a regular (public) module map...
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.
bool WriteCommentListToPCH
Whether to write comment locations into the PCH when building it.
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.
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
VectorType::VectorKind getVectorKind() 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
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.
__DEVICE__ int max(int __a, int __b)
unsigned getNumTypeArgs() const
unsigned getNumElements() const
Record for offsets of DECL_UPDATES records for declarations that were modified after being deserializ...
SourceLocation getAmpLoc() const
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 ...
static llvm::ImmutableListFactory< const FieldRegion * > Factory
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.
This represents a decl that may have 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.
QualType getElementType() const
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.
QualType getType() const
Return the type wrapped by this type source info.
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.