63 #include "llvm/ADT/APFloat.h"
64 #include "llvm/ADT/APInt.h"
65 #include "llvm/ADT/Hashing.h"
66 #include "llvm/ADT/IntrusiveRefCntPtr.h"
67 #include "llvm/ADT/Optional.h"
68 #include "llvm/ADT/STLExtras.h"
69 #include "llvm/ADT/SmallSet.h"
70 #include "llvm/ADT/SmallString.h"
71 #include "llvm/ADT/StringExtras.h"
72 #include "llvm/Bitcode/BitCodes.h"
73 #include "llvm/Bitcode/BitstreamWriter.h"
74 #include "llvm/Support/Casting.h"
75 #include "llvm/Support/Compression.h"
76 #include "llvm/Support/EndianStream.h"
77 #include "llvm/Support/Error.h"
78 #include "llvm/Support/ErrorHandling.h"
79 #include "llvm/Support/MemoryBuffer.h"
80 #include "llvm/Support/OnDiskHashTable.h"
81 #include "llvm/Support/Path.h"
82 #include "llvm/Support/Process.h"
83 #include "llvm/Support/SHA1.h"
84 #include "llvm/Support/raw_ostream.h"
96 using namespace clang;
97 using namespace clang::serialization;
99 template <
typename T,
typename Allocator>
100 static StringRef
bytes(
const std::vector<T, Allocator> &
v) {
101 if (v.empty())
return StringRef();
102 return StringRef(reinterpret_cast<const char*>(&v[0]),
103 sizeof(T) * v.size());
106 template <
typename T>
108 return StringRef(reinterpret_cast<const char*>(v.data()),
109 sizeof(T) * v.size());
125 unsigned AbbrevToUse;
129 : Writer(Writer), Record(Writer, Record), Code((
TypeCode)0), AbbrevToUse(0) { }
132 return Record.Emit(Code, AbbrevToUse);
141 AbbrevToUse = Writer.TypeExtQualAbbrev;
146 #define TYPE(Class, Base) \
147 case Type::Class: Visit##Class##Type(cast<Class##Type>(T)); break;
148 #define ABSTRACT_TYPE(Class, Base)
149 #include "clang/AST/TypeNodes.def"
156 void VisitTagType(
const TagType *T);
158 #define TYPE(Class, Base) void Visit##Class##Type(const Class##Type *T);
159 #define ABSTRACT_TYPE(Class, Base)
160 #include "clang/AST/TypeNodes.def"
165 void ASTTypeWriter::VisitBuiltinType(
const BuiltinType *T) {
166 llvm_unreachable(
"Built-in types are never serialized");
169 void ASTTypeWriter::VisitComplexType(
const ComplexType *T) {
174 void ASTTypeWriter::VisitPointerType(
const PointerType *T) {
179 void ASTTypeWriter::VisitDecayedType(
const DecayedType *T) {
184 void ASTTypeWriter::VisitAdjustedType(
const AdjustedType *T) {
237 void ASTTypeWriter::VisitVectorType(
const VectorType *T) {
244 void ASTTypeWriter::VisitExtVectorType(
const ExtVectorType *T) {
256 Record.push_back(C.
getCC());
265 VisitFunctionType(T);
287 VisitFunctionType(T);
313 Record.AddDeclRef(T->
getDecl());
317 void ASTTypeWriter::VisitTypedefType(
const TypedefType *T) {
318 Record.AddDeclRef(T->
getDecl());
324 void ASTTypeWriter::VisitTypeOfExprType(
const TypeOfExprType *T) {
329 void ASTTypeWriter::VisitTypeOfType(
const TypeOfType *T) {
334 void ASTTypeWriter::VisitDecltypeType(
const DecltypeType *T) {
347 void ASTTypeWriter::VisitAutoType(
const AutoType *T) {
355 void ASTTypeWriter::VisitDeducedTemplateSpecializationType(
368 "Cannot serialize in the middle of a type definition");
371 void ASTTypeWriter::VisitRecordType(
const RecordType *T) {
376 void ASTTypeWriter::VisitEnumType(
const EnumType *T) {
381 void ASTTypeWriter::VisitAttributedType(
const AttributedType *T) {
389 ASTTypeWriter::VisitSubstTemplateTypeParmType(
397 ASTTypeWriter::VisitSubstTemplateTypeParmPackType(
405 ASTTypeWriter::VisitTemplateSpecializationType(
410 for (
const auto &ArgI : *T)
411 Record.AddTemplateArgument(ArgI);
412 Record.AddTypeRef(T->isTypeAlias() ? T->getAliasedType()
413 : T->isCanonicalUnqualified()
415 : T->getCanonicalTypeInternal());
428 ASTTypeWriter::VisitDependentSizedExtVectorType(
441 Record.AddDeclRef(T->
getDecl());
456 ASTTypeWriter::VisitDependentTemplateSpecializationType(
462 for (
const auto &
I : *T)
463 Record.AddTemplateArgument(
I);
470 Record.push_back(*NumExpansions + 1);
476 void ASTTypeWriter::VisitParenType(
const ParenType *T) {
481 void ASTTypeWriter::VisitElaboratedType(
const ElaboratedType *T) {
500 Record.AddDeclRef(T->
getDecl());
502 for (
const auto *
I : T->
quals())
503 Record.AddDeclRef(
I);
507 void ASTTypeWriter::VisitObjCObjectType(
const ObjCObjectType *T) {
511 Record.AddTypeRef(TypeArg);
513 for (
const auto *
I : T->
quals())
514 Record.AddDeclRef(
I);
526 ASTTypeWriter::VisitAtomicType(
const AtomicType *T) {
532 ASTTypeWriter::VisitPipeType(
const PipeType *T) {
547 #define ABSTRACT_TYPELOC(CLASS, PARENT)
548 #define TYPELOC(CLASS, PARENT) \
549 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
550 #include "clang/AST/TypeLocNodes.def"
593 Record.AddSourceLocation(TL.
getAmpLoc());
605 void TypeLocWriter::VisitArrayTypeLoc(
ArrayTypeLoc TL) {
614 VisitArrayTypeLoc(TL);
618 VisitArrayTypeLoc(TL);
622 VisitArrayTypeLoc(TL);
625 void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
627 VisitArrayTypeLoc(TL);
630 void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
649 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i)
653 VisitFunctionTypeLoc(TL);
656 VisitFunctionTypeLoc(TL);
690 Record.AddSourceLocation(TL.
getKWLoc());
696 void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
700 void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
709 void TypeLocWriter::VisitEnumTypeLoc(
EnumTypeLoc TL) {
714 Record.AddSourceLocation(TL.getAttrNameLoc());
717 Record.AddSourceLocation(range.
getBegin());
718 Record.AddSourceLocation(range.
getEnd());
721 Expr *operand = TL.getAttrExprOperand();
722 Record.push_back(operand ? 1 : 0);
723 if (operand) Record.AddStmt(operand);
733 void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
738 void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
743 void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
749 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
754 void TypeLocWriter::VisitParenTypeLoc(
ParenTypeLoc TL) {
774 void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
812 Record.AddSourceLocation(TL.
getKWLoc());
817 void TypeLocWriter::VisitPipeTypeLoc(
PipeTypeLoc TL) {
818 Record.AddSourceLocation(TL.
getKWLoc());
821 void ASTWriter::WriteTypeAbbrevs() {
822 using namespace llvm;
824 std::shared_ptr<BitCodeAbbrev> Abv;
827 Abv = std::make_shared<BitCodeAbbrev>();
829 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
830 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
831 TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
834 Abv = std::make_shared<BitCodeAbbrev>();
837 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
838 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
839 Abv->Add(BitCodeAbbrevOp(0));
840 Abv->Add(BitCodeAbbrevOp(0));
841 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
842 Abv->Add(BitCodeAbbrevOp(0));
843 Abv->Add(BitCodeAbbrevOp(0));
845 Abv->Add(BitCodeAbbrevOp(0));
846 Abv->Add(BitCodeAbbrevOp(0));
847 Abv->Add(BitCodeAbbrevOp(0));
848 Abv->Add(BitCodeAbbrevOp(0));
849 Abv->Add(BitCodeAbbrevOp(
EST_None));
850 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
851 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
852 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
853 TypeFunctionProtoAbbrev = Stream.EmitAbbrev(std::move(Abv));
861 llvm::BitstreamWriter &Stream,
864 Record.push_back(ID);
865 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);
868 if (!Name || Name[0] == 0)
872 Record.push_back(*Name++);
873 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME, Record);
877 llvm::BitstreamWriter &Stream,
880 Record.push_back(ID);
882 Record.push_back(*Name++);
883 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, Record);
888 #define RECORD(X) EmitRecordID(X, #X, Stream, Record)
1015 void ASTWriter::WriteBlockInfoBlock() {
1017 Stream.EnterBlockInfoBlock();
1019 #define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
1020 #define RECORD(X) EmitRecordID(X, #X, Stream, Record)
1023 BLOCK(CONTROL_BLOCK);
1034 BLOCK(OPTIONS_BLOCK);
1041 BLOCK(INPUT_FILES_BLOCK);
1099 BLOCK(SOURCE_MANAGER_BLOCK);
1107 BLOCK(PREPROCESSOR_BLOCK);
1115 BLOCK(SUBMODULE_BLOCK);
1135 BLOCK(COMMENTS_BLOCK);
1139 BLOCK(DECLTYPES_BLOCK);
1256 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
1262 BLOCK(EXTENSION_BLOCK);
1265 BLOCK(UNHASHED_CONTROL_BLOCK);
1282 return Changed | llvm::sys::path::remove_dots(Path);
1297 assert(Filename &&
"No file name to adjust?");
1299 if (BaseDir.empty())
1304 for (; Filename[Pos] && Pos < BaseDir.size(); ++Pos)
1305 if (Filename[Pos] != BaseDir[Pos])
1314 if (!llvm::sys::path::is_separator(Filename[Pos])) {
1315 if (!llvm::sys::path::is_separator(BaseDir.back()))
1329 return Filename + Pos;
1336 auto Hash = Hasher.result();
1340 auto LShift = [&](
unsigned char Val,
unsigned Shift) {
1341 return (uint32_t)Val <<
Shift;
1343 for (
int I = 0;
I != 5; ++
I)
1344 Signature[
I] = LShift(Hash[
I * 4 + 0], 24) | LShift(Hash[
I * 4 + 1], 16) |
1345 LShift(Hash[
I * 4 + 2], 8) | LShift(Hash[
I * 4 + 3], 0);
1353 Stream.FlushToWord();
1354 auto StartOfUnhashedControl = Stream.GetCurrentBitNo() >> 3;
1362 if (WritingModule &&
1364 Signature = createSignature(StringRef(
Buffer.begin(), StartOfUnhashedControl));
1365 Record.append(Signature.begin(), Signature.end());
1373 #define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name);
1374 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
1375 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name()));
1376 #include "clang/Basic/DiagnosticOptions.def"
1377 Record.push_back(DiagOpts.
Warnings.size());
1378 for (
unsigned I = 0, N = DiagOpts.
Warnings.size();
I != N; ++
I)
1379 AddString(DiagOpts.
Warnings[
I], Record);
1380 Record.push_back(DiagOpts.
Remarks.size());
1381 for (
unsigned I = 0, N = DiagOpts.
Remarks.size();
I != N; ++
I)
1382 AddString(DiagOpts.
Remarks[
I], Record);
1388 WritePragmaDiagnosticMappings(Diags, WritingModule);
1398 const std::string &OutputFile) {
1399 using namespace llvm;
1404 auto MetadataAbbrev = std::make_shared<BitCodeAbbrev>();
1405 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1406 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1407 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1408 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1409 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1410 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1411 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1412 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1413 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1414 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev));
1415 assert((!WritingModule || isysroot.empty()) &&
1416 "writing module as a relocatable PCH?");
1419 CLANG_VERSION_MAJOR, CLANG_VERSION_MINOR,
1420 !isysroot.empty(), IncludeTimestamps,
1421 ASTHasCompilerErrors};
1422 Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
1426 if (WritingModule) {
1428 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1430 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1431 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1433 Stream.EmitRecordWithBlob(AbbrevCode, Record, WritingModule->Name);
1436 if (WritingModule && WritingModule->Directory) {
1446 WritingModule->Directory->getName() != StringRef(
".")) {
1448 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1450 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1451 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1454 Stream.EmitRecordWithBlob(AbbrevCode, Record, BaseDir);
1458 BaseDirectory.assign(BaseDir.begin(), BaseDir.end());
1459 }
else if (!isysroot.empty()) {
1461 BaseDirectory = isysroot;
1469 AddPath(WritingModule->PresumedModuleMapFile.empty()
1470 ?
Map.getModuleMapFileForUniquing(WritingModule)->getName()
1471 : StringRef(WritingModule->PresumedModuleMapFile),
1475 if (
auto *AdditionalModMaps =
1476 Map.getAdditionalModuleMapFiles(WritingModule)) {
1477 Record.push_back(AdditionalModMaps->size());
1478 for (
const FileEntry *F : *AdditionalModMaps)
1479 AddPath(F->getName(), Record);
1481 Record.push_back(0);
1494 if (!M.isDirectlyImported())
1497 Record.push_back((
unsigned)M.Kind);
1498 AddSourceLocation(M.ImportLoc, Record);
1502 Record.push_back(M.Signature ? 0 : M.File->getSize());
1503 Record.push_back(M.Signature ? 0 : getTimestampForOutput(M.File));
1505 for (
auto I : M.Signature)
1506 Record.push_back(
I);
1508 AddPath(M.FileName, Record);
1510 Stream.EmitRecord(
IMPORTS, Record);
1519 #define LANGOPT(Name, Bits, Default, Description) \
1520 Record.push_back(LangOpts.Name);
1521 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
1522 Record.push_back(static_cast<unsigned>(LangOpts.get##Name()));
1523 #include "clang/Basic/LangOptions.def"
1524 #define SANITIZER(NAME, ID) \
1525 Record.push_back(LangOpts.Sanitize.has(SanitizerKind::ID));
1526 #include "clang/Basic/Sanitizers.def"
1528 Record.push_back(LangOpts.ModuleFeatures.size());
1529 for (StringRef Feature : LangOpts.ModuleFeatures)
1530 AddString(Feature, Record);
1532 Record.push_back((
unsigned) LangOpts.ObjCRuntime.getKind());
1533 AddVersionTuple(LangOpts.ObjCRuntime.getVersion(), Record);
1535 AddString(LangOpts.CurrentModule, Record);
1538 Record.push_back(LangOpts.CommentOpts.BlockCommandNames.size());
1539 for (
const auto &
I : LangOpts.CommentOpts.BlockCommandNames) {
1540 AddString(
I, Record);
1542 Record.push_back(LangOpts.CommentOpts.ParseAllComments);
1545 Record.push_back(LangOpts.OMPTargetTriples.size());
1546 for (
auto &T : LangOpts.OMPTargetTriples)
1547 AddString(T.getTriple(), Record);
1549 AddString(LangOpts.OMPHostIRFile, Record);
1557 AddString(TargetOpts.Triple, Record);
1558 AddString(TargetOpts.CPU, Record);
1559 AddString(TargetOpts.ABI, Record);
1560 Record.push_back(TargetOpts.FeaturesAsWritten.size());
1561 for (
unsigned I = 0, N = TargetOpts.FeaturesAsWritten.size();
I != N; ++
I) {
1562 AddString(TargetOpts.FeaturesAsWritten[
I], Record);
1564 Record.push_back(TargetOpts.Features.size());
1565 for (
unsigned I = 0, N = TargetOpts.Features.size();
I != N; ++
I) {
1566 AddString(TargetOpts.Features[
I], Record);
1574 AddString(FSOpts.WorkingDir, Record);
1581 AddString(HSOpts.Sysroot, Record);
1584 Record.push_back(HSOpts.UserEntries.size());
1585 for (
unsigned I = 0, N = HSOpts.UserEntries.size();
I != N; ++
I) {
1587 AddString(Entry.
Path, Record);
1588 Record.push_back(static_cast<unsigned>(Entry.
Group));
1594 Record.push_back(HSOpts.SystemHeaderPrefixes.size());
1595 for (
unsigned I = 0, N = HSOpts.SystemHeaderPrefixes.size();
I != N; ++
I) {
1596 AddString(HSOpts.SystemHeaderPrefixes[
I].Prefix, Record);
1597 Record.push_back(HSOpts.SystemHeaderPrefixes[
I].IsSystemHeader);
1600 AddString(HSOpts.ResourceDir, Record);
1601 AddString(HSOpts.ModuleCachePath, Record);
1602 AddString(HSOpts.ModuleUserBuildPath, Record);
1603 Record.push_back(HSOpts.DisableModuleHash);
1604 Record.push_back(HSOpts.ImplicitModuleMaps);
1605 Record.push_back(HSOpts.ModuleMapFileHomeIsCwd);
1606 Record.push_back(HSOpts.UseBuiltinIncludes);
1607 Record.push_back(HSOpts.UseStandardSystemIncludes);
1608 Record.push_back(HSOpts.UseStandardCXXIncludes);
1609 Record.push_back(HSOpts.UseLibcxx);
1619 Record.push_back(PPOpts.Macros.size());
1620 for (
unsigned I = 0, N = PPOpts.Macros.size();
I != N; ++
I) {
1621 AddString(PPOpts.Macros[
I].first, Record);
1622 Record.push_back(PPOpts.Macros[
I].second);
1626 Record.push_back(PPOpts.Includes.size());
1627 for (
unsigned I = 0, N = PPOpts.Includes.size();
I != N; ++
I)
1628 AddString(PPOpts.Includes[
I], Record);
1631 Record.push_back(PPOpts.MacroIncludes.size());
1632 for (
unsigned I = 0, N = PPOpts.MacroIncludes.size();
I != N; ++
I)
1633 AddString(PPOpts.MacroIncludes[
I], Record);
1635 Record.push_back(PPOpts.UsePredefines);
1637 Record.push_back(PPOpts.DetailedRecord);
1638 AddString(PPOpts.ImplicitPCHInclude, Record);
1639 AddString(PPOpts.ImplicitPTHInclude, Record);
1640 Record.push_back(static_cast<unsigned>(PPOpts.ObjCXXARCStandardLibrary));
1649 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1651 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1652 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1653 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
1658 EmitRecordWithPath(FileAbbrevCode, Record, MainFile->getName());
1666 if (!OutputFile.empty() && OutputFile !=
"-") {
1667 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1669 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1670 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1675 StringRef origDir = llvm::sys::path::parent_path(OutputPath);
1678 Stream.EmitRecordWithBlob(AbbrevCode, Record, origDir);
1681 WriteInputFiles(Context.SourceMgr,
1690 struct InputFileEntry {
1694 bool BufferOverridden;
1695 bool IsTopLevelModuleMap;
1703 using namespace llvm;
1707 auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
1709 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1710 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1711 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1712 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1713 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1714 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1715 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1716 unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
1720 std::deque<InputFileEntry> SortedFiles;
1734 InputFileEntry Entry;
1742 SortedFiles.push_back(Entry);
1744 SortedFiles.push_front(Entry);
1747 unsigned UserFilesNum = 0;
1749 std::vector<uint64_t> InputFileOffsets;
1750 for (
const auto &Entry : SortedFiles) {
1751 uint32_t &InputFileID = InputFileIDs[Entry.File];
1752 if (InputFileID != 0)
1756 InputFileOffsets.push_back(Stream.GetCurrentBitNo());
1758 InputFileID = InputFileOffsets.size();
1760 if (!Entry.IsSystemFile)
1765 RecordData::value_type Record[] = {
1767 InputFileOffsets.size(),
1768 (uint64_t)Entry.File->getSize(),
1769 (uint64_t)getTimestampForOutput(Entry.File),
1770 Entry.BufferOverridden,
1772 Entry.IsTopLevelModuleMap};
1774 EmitRecordWithPath(IFAbbrevCode, Record, Entry.File->getName());
1780 auto OffsetsAbbrev = std::make_shared<BitCodeAbbrev>();
1782 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1783 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1785 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1786 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(std::move(OffsetsAbbrev));
1790 InputFileOffsets.size(), UserFilesNum};
1791 Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record,
bytes(InputFileOffsets));
1801 using namespace llvm;
1803 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1805 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1806 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1807 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1808 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1810 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1811 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1812 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
1813 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1814 return Stream.EmitAbbrev(std::move(Abbrev));
1820 using namespace llvm;
1822 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1824 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1825 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1826 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1827 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1828 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1829 return Stream.EmitAbbrev(std::move(Abbrev));
1836 using namespace llvm;
1838 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1842 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1843 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1844 return Stream.EmitAbbrev(std::move(Abbrev));
1850 using namespace llvm;
1852 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1854 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1855 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1856 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1857 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1858 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1859 return Stream.EmitAbbrev(std::move(Abbrev));
1865 class HeaderFileInfoTrait {
1870 llvm::StringMap<unsigned> FrameworkNameOffset;
1873 HeaderFileInfoTrait(
ASTWriter &Writer) : Writer(Writer) {}
1880 typedef const key_type &key_type_ref;
1882 using UnresolvedModule =
1883 llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
1888 UnresolvedModule Unresolved;
1890 typedef const data_type &data_type_ref;
1892 typedef unsigned hash_value_type;
1893 typedef unsigned offset_type;
1899 return llvm::hash_combine(key.Size, key.ModTime);
1902 std::pair<unsigned,unsigned>
1903 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) {
1904 using namespace llvm::support;
1905 endian::Writer<little> LE(Out);
1906 unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
1907 LE.write<uint16_t>(KeyLen);
1908 unsigned DataLen = 1 + 2 + 4 + 4;
1909 for (
auto ModInfo : Data.KnownHeaders)
1910 if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
1912 if (Data.Unresolved.getPointer())
1914 LE.write<uint8_t>(DataLen);
1915 return std::make_pair(KeyLen, DataLen);
1918 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
1919 using namespace llvm::support;
1920 endian::Writer<little> LE(Out);
1921 LE.write<uint64_t>(key.Size);
1923 LE.write<uint64_t>(key.ModTime);
1925 Out.write(key.Filename.data(), KeyLen);
1928 void EmitData(raw_ostream &Out, key_type_ref key,
1929 data_type_ref Data,
unsigned DataLen) {
1930 using namespace llvm::support;
1931 endian::Writer<little> LE(Out);
1932 uint64_t Start = Out.tell(); (void)Start;
1934 unsigned char Flags = (Data.HFI.isImport << 5)
1935 | (Data.HFI.isPragmaOnce << 4)
1936 | (Data.HFI.DirInfo << 1)
1937 | Data.HFI.IndexHeaderMapHeader;
1938 LE.write<uint8_t>(Flags);
1939 LE.write<uint16_t>(Data.HFI.NumIncludes);
1941 if (!Data.HFI.ControllingMacro)
1942 LE.write<uint32_t>(Data.HFI.ControllingMacroID);
1944 LE.write<uint32_t>(Writer.getIdentifierRef(Data.HFI.ControllingMacro));
1947 if (!Data.HFI.Framework.empty()) {
1949 llvm::StringMap<unsigned>::iterator Pos
1950 = FrameworkNameOffset.find(Data.HFI.Framework);
1951 if (Pos == FrameworkNameOffset.end()) {
1952 Offset = FrameworkStringData.size() + 1;
1953 FrameworkStringData.append(Data.HFI.Framework.begin(),
1954 Data.HFI.Framework.end());
1955 FrameworkStringData.push_back(0);
1957 FrameworkNameOffset[Data.HFI.Framework] =
Offset;
1961 LE.write<uint32_t>(
Offset);
1964 if (uint32_t ModID = Writer.getLocalOrImportedSubmoduleID(M)) {
1965 uint32_t
Value = (ModID << 2) | (
unsigned)Role;
1966 assert((Value >> 2) == ModID &&
"overflow in header module info");
1967 LE.write<uint32_t>(
Value);
1973 for (
auto ModInfo : Data.KnownHeaders)
1974 EmitModule(ModInfo.getModule(), ModInfo.getRole());
1975 if (Data.Unresolved.getPointer())
1976 EmitModule(Data.Unresolved.getPointer(), Data.Unresolved.getInt());
1978 assert(Out.tell() - Start == DataLen &&
"Wrong data length");
1981 const char *strings_begin()
const {
return FrameworkStringData.begin(); }
1982 const char *strings_end()
const {
return FrameworkStringData.end(); }
1990 void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
1991 HeaderFileInfoTrait GeneratorTrait(*
this);
1992 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait> Generator;
1994 unsigned NumHeaderSearchEntries = 0;
2001 if (WritingModule) {
2003 while (!Worklist.empty()) {
2004 Module *M = Worklist.pop_back_val();
2020 if (!U.Size || (!U.ModTime && IncludeTimestamps)) {
2021 PP->
Diag(U.FileNameLoc, diag::err_module_no_size_mtime_for_header)
2022 << WritingModule->getFullModuleName() << U.Size.hasValue()
2029 llvm::sys::path::append(
Filename, U.FileName);
2032 StringRef FilenameDup = strdup(
Filename.c_str());
2033 SavedStrings.push_back(FilenameDup.data());
2035 HeaderFileInfoTrait::key_type Key = {
2036 FilenameDup, *U.Size, IncludeTimestamps ? *U.ModTime : 0
2038 HeaderFileInfoTrait::data_type Data = {
2043 Generator.insert(Key, Data, GeneratorTrait);
2044 ++NumHeaderSearchEntries;
2057 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
2058 const FileEntry *File = FilesByUID[UID];
2076 if (PreparePathForOutput(FilenameTmp)) {
2079 Filename = StringRef(strdup(FilenameTmp.c_str()));
2080 SavedStrings.push_back(Filename.data());
2083 HeaderFileInfoTrait::key_type Key = {
2086 HeaderFileInfoTrait::data_type Data = {
2089 Generator.insert(Key, Data, GeneratorTrait);
2090 ++NumHeaderSearchEntries;
2095 uint32_t BucketOffset;
2097 using namespace llvm::support;
2098 llvm::raw_svector_ostream Out(TableData);
2100 endian::Writer<little>(Out).write<uint32_t>(0);
2101 BucketOffset = Generator.Emit(Out, GeneratorTrait);
2105 using namespace llvm;
2107 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2109 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2110 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2111 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2112 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2113 unsigned TableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2117 NumHeaderSearchEntries, TableData.size()};
2118 TableData.append(GeneratorTrait.strings_begin(),GeneratorTrait.strings_end());
2119 Stream.EmitRecordWithBlob(TableAbbrev, Record, TableData);
2122 for (
unsigned I = 0, N = SavedStrings.size();
I != N; ++
I)
2123 free(const_cast<char *>(SavedStrings[
I]));
2126 static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
2127 unsigned SLocBufferBlobCompressedAbbrv,
2128 unsigned SLocBufferBlobAbbrv) {
2129 typedef ASTWriter::RecordData::value_type RecordDataType;
2134 if (llvm::zlib::isAvailable()) {
2135 llvm::Error E = llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer);
2139 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record,
2143 llvm::consumeError(std::move(E));
2147 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob);
2158 void ASTWriter::WriteSourceManagerBlock(
SourceManager &SourceMgr,
2169 unsigned SLocBufferBlobCompressedAbbrv =
2175 std::vector<uint32_t> SLocEntryOffsets;
2176 RecordData PreloadSLocs;
2186 SLocEntryOffsets.push_back(Stream.GetCurrentBitNo());
2199 Record.push_back(Code);
2202 Record.push_back(SLoc->
getOffset() - 2);
2210 bool EmitBlob =
false;
2213 "Writing to AST an overridden file is not supported");
2216 assert(InputFileIDs[Content->
OrigEntry] != 0 &&
"Missed file entry");
2217 Record.push_back(InputFileIDs[Content->
OrigEntry]);
2219 Record.push_back(File.NumCreatedFIDs);
2221 FileDeclIDsTy::iterator FDI = FileDeclIDs.find(FID);
2222 if (FDI != FileDeclIDs.end()) {
2223 Record.push_back(FDI->second->FirstDeclIndex);
2224 Record.push_back(FDI->second->DeclIDs.size());
2226 Record.push_back(0);
2227 Record.push_back(0);
2230 Stream.EmitRecordWithAbbrev(SLocFileAbbrv, Record);
2241 const llvm::MemoryBuffer *
Buffer
2243 StringRef
Name = Buffer->getBufferIdentifier();
2244 Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
2245 StringRef(Name.data(), Name.size() + 1));
2248 if (Name ==
"<built-in>")
2249 PreloadSLocs.push_back(SLocEntryOffsets.size());
2255 const llvm::MemoryBuffer *Buffer =
2257 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
2258 emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv,
2259 SLocBufferBlobAbbrv);
2268 : Expansion.getExpansionLocEnd(),
2275 Record.push_back(NextOffset - SLoc->
getOffset() - 1);
2276 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv, Record);
2282 if (SLocEntryOffsets.empty())
2287 using namespace llvm;
2289 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2291 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2292 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2293 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2294 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2296 RecordData::value_type Record[] = {
2299 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
2300 bytes(SLocEntryOffsets));
2314 llvm::DenseMap<int, int> FilenameMap;
2315 for (
const auto &L : LineTable) {
2318 for (
auto &LE : L.second) {
2319 if (FilenameMap.insert(std::make_pair(LE.FilenameID,
2320 FilenameMap.size())).second)
2321 AddPath(LineTable.getFilename(LE.FilenameID), Record);
2324 Record.push_back(0);
2327 for (
const auto &L : LineTable) {
2333 Record.push_back(L.first.ID);
2336 Record.push_back(L.second.size());
2337 for (
const auto &LE : L.second) {
2338 Record.push_back(LE.FileOffset);
2339 Record.push_back(LE.LineNo);
2340 Record.push_back(FilenameMap[LE.FilenameID]);
2341 Record.push_back((
unsigned)LE.FileKind);
2342 Record.push_back(LE.IncludeOffset);
2357 if (MI->isBuiltinMacro())
2374 void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2377 WritePreprocessorDetail(*PPRec);
2380 RecordData ModuleMacroRecord;
2391 AddSourceLocation(Cond.IfLoc, Record);
2392 Record.push_back(Cond.WasSkipping);
2393 Record.push_back(Cond.FoundNonSkip);
2394 Record.push_back(Cond.FoundElse);
2415 if (Id.second->hadMacroDefinition() &&
2416 (!Id.second->isFromAST() ||
2417 Id.second->hasChangedSinceDeserialization()))
2418 MacroIdentifiers.push_back(Id.second);
2421 std::sort(MacroIdentifiers.begin(), MacroIdentifiers.end(),
2422 llvm::less_ptr<IdentifierInfo>());
2428 auto StartOffset = Stream.GetCurrentBitNo();
2438 Record.push_back(MD->
getKind());
2439 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2440 Record.push_back(getMacroRef(DefMD->getInfo(),
Name));
2441 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2442 Record.push_back(VisMD->isPublic());
2447 bool EmittedModuleMacros =
false;
2451 llvm::DenseMap<ModuleMacro*, unsigned> Visits;
2452 while (!Worklist.empty()) {
2453 auto *
Macro = Worklist.pop_back_val();
2456 ModuleMacroRecord.push_back(
2457 getSubmoduleID(
Macro->getOwningModule()));
2458 ModuleMacroRecord.push_back(getMacroRef(
Macro->getMacroInfo(),
Name));
2459 for (
auto *M :
Macro->overrides())
2460 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2463 ModuleMacroRecord.clear();
2466 for (
auto *M :
Macro->overrides())
2467 if (++Visits[M] == M->getNumOverridingMacros())
2468 Worklist.push_back(M);
2470 EmittedModuleMacros =
true;
2473 if (Record.empty() && !EmittedModuleMacros)
2476 IdentMacroDirectivesOffsetMap[
Name] = StartOffset;
2487 std::vector<uint32_t> MacroOffsets;
2489 for (
unsigned I = 0, N = MacroInfosToEmit.size();
I != N; ++
I) {
2494 if (ID < FirstMacroID) {
2495 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2500 unsigned Index = ID - FirstMacroID;
2501 if (Index == MacroOffsets.size())
2502 MacroOffsets.push_back(Stream.GetCurrentBitNo());
2504 if (Index > MacroOffsets.size())
2505 MacroOffsets.resize(Index + 1);
2507 MacroOffsets[Index] = Stream.GetCurrentBitNo();
2510 AddIdentifierRef(Name, Record);
2513 Record.push_back(MI->
isUsed());
2526 AddIdentifierRef(Param, Record);
2534 Stream.EmitRecord(Code, Record);
2538 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2543 AddToken(Tok, Record);
2544 Stream.EmitRecord(
PP_TOKEN, Record);
2553 using namespace llvm;
2555 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2557 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2558 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2559 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2561 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2563 RecordData::value_type Record[] = {
MACRO_OFFSET, MacroOffsets.size(),
2565 Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record,
bytes(MacroOffsets));
2579 unsigned NumPreprocessingRecords = 0;
2580 using namespace llvm;
2583 unsigned InclusionAbbrev = 0;
2585 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2587 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2588 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2589 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2590 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2591 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2592 InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2595 unsigned FirstPreprocessorEntityID
2596 = (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0)
2598 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2603 (void)++
E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2606 PreprocessedEntityOffsets.push_back(
2607 PPEntityOffset((*E)->getSourceRange(), Stream.GetCurrentBitNo()));
2609 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*
E)) {
2611 MacroDefinitions[MD] = NextPreprocessorEntityID;
2613 AddIdentifierRef(MD->getName(), Record);
2618 if (
auto *ME = dyn_cast<MacroExpansion>(*
E)) {
2619 Record.push_back(ME->isBuiltinMacro());
2620 if (ME->isBuiltinMacro())
2621 AddIdentifierRef(ME->getName(), Record);
2623 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2628 if (
auto *ID = dyn_cast<InclusionDirective>(*
E)) {
2630 Record.push_back(ID->getFileName().size());
2631 Record.push_back(ID->wasInQuotes());
2632 Record.push_back(static_cast<unsigned>(ID->getKind()));
2633 Record.push_back(ID->importedModule());
2635 Buffer += ID->getFileName();
2639 Buffer += ID->getFile()->getName();
2640 Stream.EmitRecordWithBlob(InclusionAbbrev, Record, Buffer);
2644 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2649 if (NumPreprocessingRecords > 0) {
2650 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2653 using namespace llvm;
2655 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2657 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2658 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2659 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2662 FirstPreprocessorEntityID -
2664 Stream.EmitRecordWithBlob(PPEOffsetAbbrev, Record,
2665 bytes(PreprocessedEntityOffsets));
2673 llvm::DenseMap<Module *, unsigned>::iterator Known = SubmoduleIDs.find(Mod);
2674 if (Known != SubmoduleIDs.end())
2675 return Known->second;
2678 if (Top != WritingModule &&
2679 (getLangOpts().CompilingPCH ||
2680 !Top->fullModuleNameIs(StringRef(getLangOpts().CurrentModule))))
2683 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2686 unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2690 unsigned ID = getLocalOrImportedSubmoduleID(Mod);
2691 assert((ID || !Mod) &&
2692 "asked for module ID for non-local, non-imported module");
2699 unsigned ChildModules = 0;
2701 Sub != SubEnd; ++Sub)
2704 return ChildModules + 1;
2707 void ASTWriter::WriteSubmodules(
Module *WritingModule) {
2712 using namespace llvm;
2714 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2716 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2717 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2718 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2719 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2720 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2721 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2722 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2723 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2724 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2725 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2726 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2727 unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2729 Abbrev = std::make_shared<BitCodeAbbrev>();
2731 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2732 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2734 Abbrev = std::make_shared<BitCodeAbbrev>();
2736 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2737 unsigned HeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2739 Abbrev = std::make_shared<BitCodeAbbrev>();
2741 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2742 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2744 Abbrev = std::make_shared<BitCodeAbbrev>();
2746 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2747 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2749 Abbrev = std::make_shared<BitCodeAbbrev>();
2751 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2752 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2753 unsigned RequiresAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2755 Abbrev = std::make_shared<BitCodeAbbrev>();
2757 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2758 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2760 Abbrev = std::make_shared<BitCodeAbbrev>();
2762 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2763 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2765 Abbrev = std::make_shared<BitCodeAbbrev>();
2767 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2768 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2770 Abbrev = std::make_shared<BitCodeAbbrev>();
2772 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2773 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2775 Abbrev = std::make_shared<BitCodeAbbrev>();
2777 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2778 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2779 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2781 Abbrev = std::make_shared<BitCodeAbbrev>();
2783 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2784 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2786 Abbrev = std::make_shared<BitCodeAbbrev>();
2788 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2789 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2790 unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2793 RecordData::value_type Record[] = {
2800 std::queue<Module *> Q;
2801 Q.push(WritingModule);
2802 while (!Q.empty()) {
2805 unsigned ID = getSubmoduleID(Mod);
2807 uint64_t ParentID = 0;
2809 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
2810 ParentID = SubmoduleIDs[Mod->
Parent];
2826 Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->
Name);
2832 Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
2838 Stream.EmitRecordWithBlob(UmbrellaAbbrev, Record,
2839 UmbrellaHeader.NameAsWritten);
2842 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev, Record,
2843 UmbrellaDir.NameAsWritten);
2848 unsigned RecordKind;
2859 for (
auto &HL : HeaderLists) {
2860 RecordData::value_type Record[] = {HL.RecordKind};
2861 for (
auto &H : Mod->
Headers[HL.HeaderKind])
2862 Stream.EmitRecordWithBlob(HL.Abbrev, Record, H.NameAsWritten);
2869 for (
auto *H : TopHeaders)
2870 Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, H->getName());
2877 Record.push_back(getSubmoduleID(
I));
2884 for (
const auto &
E : Mod->
Exports) {
2887 Record.push_back(getSubmoduleID(
E.getPointer()));
2888 Record.push_back(
E.getInt());
2901 Stream.EmitRecordWithBlob(LinkLibraryAbbrev, Record, LL.Library);
2909 getSubmoduleID(
C.Other)};
2910 Stream.EmitRecordWithBlob(ConflictAbbrev, Record,
C.Message);
2916 Stream.EmitRecordWithBlob(ConfigMacroAbbrev, Record, CM);
2922 Inits.push_back(GetDeclRef(D));
2933 assert((NextSubmoduleID - FirstSubmoduleID ==
2935 "Wrong # of submodules; found a reference to a non-local, "
2936 "non-imported submodule?");
2941 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
2943 unsigned CurrID = 0;
2946 auto EncodeDiagStateFlags =
2947 [](
const DiagnosticsEngine::DiagState *DS) ->
unsigned {
2950 {(
unsigned)DS->IgnoreAllWarnings, (
unsigned)DS->EnableAllWarnings,
2951 (
unsigned)DS->WarningsAsErrors, (
unsigned)DS->ErrorsAsFatal,
2952 (
unsigned)DS->SuppressSystemWarnings})
2953 Result = (Result << 1) | Val;
2957 unsigned Flags = EncodeDiagStateFlags(Diag.DiagStatesByLoc.FirstDiagState);
2958 Record.push_back(Flags);
2960 auto AddDiagState = [&](
const DiagnosticsEngine::DiagState *
State,
2961 bool IncludeNonPragmaStates) {
2964 assert(Flags == EncodeDiagStateFlags(State) &&
2965 "diag state flags vary in single AST file");
2967 unsigned &DiagStateID = DiagStateIDMap[
State];
2968 Record.push_back(DiagStateID);
2970 if (DiagStateID == 0) {
2971 DiagStateID = ++CurrID;
2974 auto SizeIdx = Record.size();
2975 Record.emplace_back();
2976 for (
const auto &
I : *State) {
2977 if (
I.second.isPragma() || IncludeNonPragmaStates) {
2978 Record.push_back(
I.first);
2979 Record.push_back(
I.second.serialize());
2983 Record[SizeIdx] = (Record.size() - SizeIdx) / 2;
2987 AddDiagState(Diag.DiagStatesByLoc.FirstDiagState, isModule);
2990 auto NumLocationsIdx = Record.size();
2991 Record.emplace_back();
2994 unsigned NumLocations = 0;
2995 for (
auto &FileIDAndFile : Diag.DiagStatesByLoc.Files) {
2996 if (!FileIDAndFile.first.isValid() ||
2997 !FileIDAndFile.second.HasLocalTransitions)
3002 Record.push_back(FileIDAndFile.second.StateTransitions.size());
3003 for (
auto &StatePoint : FileIDAndFile.second.StateTransitions) {
3004 Record.push_back(StatePoint.Offset);
3005 AddDiagState(StatePoint.State,
false);
3010 Record[NumLocationsIdx] = NumLocations;
3018 AddSourceLocation(Diag.DiagStatesByLoc.CurDiagStateLoc, Record);
3019 AddDiagState(Diag.DiagStatesByLoc.CurDiagState,
false);
3029 void ASTWriter::WriteType(
QualType T) {
3030 TypeIdx &IdxRef = TypeIdxs[T];
3032 IdxRef =
TypeIdx(NextTypeID++);
3035 assert(Idx.
getIndex() >= FirstTypeID &&
"Re-writing a type from a prior AST");
3042 uint64_t
Offset = W.Emit();
3045 unsigned Index = Idx.
getIndex() - FirstTypeID;
3046 if (TypeOffsets.size() == Index)
3047 TypeOffsets.push_back(Offset);
3048 else if (TypeOffsets.size() < Index) {
3049 TypeOffsets.resize(Index + 1);
3050 TypeOffsets[Index] =
Offset;
3052 llvm_unreachable(
"Types emitted in wrong order");
3065 uint64_t ASTWriter::WriteDeclContextLexicalBlock(
ASTContext &Context,
3070 uint64_t Offset = Stream.GetCurrentBitNo();
3072 for (
const auto *D : DC->
decls()) {
3073 KindDeclPairs.push_back(D->getKind());
3074 KindDeclPairs.push_back(GetDeclRef(D));
3077 ++NumLexicalDeclContexts;
3079 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record,
3080 bytes(KindDeclPairs));
3084 void ASTWriter::WriteTypeDeclOffsets() {
3085 using namespace llvm;
3088 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3090 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3091 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3092 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3093 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3095 RecordData::value_type Record[] = {
TYPE_OFFSET, TypeOffsets.size(),
3097 Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record,
bytes(TypeOffsets));
3101 Abbrev = std::make_shared<BitCodeAbbrev>();
3103 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3104 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3105 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3106 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3108 RecordData::value_type Record[] = {
DECL_OFFSET, DeclOffsets.size(),
3110 Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record,
bytes(DeclOffsets));
3114 void ASTWriter::WriteFileDeclIDsMap() {
3115 using namespace llvm;
3118 FileDeclIDs.begin(), FileDeclIDs.end());
3119 std::sort(SortedFileDeclIDs.begin(), SortedFileDeclIDs.end(),
3120 llvm::less_first());
3124 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
3125 DeclIDInFileInfo &Info = *FileDeclEntry.second;
3126 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
3127 for (
auto &LocDeclEntry : Info.DeclIDs)
3128 FileGroupedDeclIDs.push_back(LocDeclEntry.second);
3131 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3133 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3134 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3135 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
3137 FileGroupedDeclIDs.size()};
3138 Stream.EmitRecordWithBlob(AbbrevCode, Record,
bytes(FileGroupedDeclIDs));
3141 void ASTWriter::WriteComments() {
3145 for (
const auto *
I : RawComments) {
3147 AddSourceRange(
I->getSourceRange(), Record);
3148 Record.push_back(
I->getKind());
3149 Record.push_back(
I->isTrailingComment());
3150 Record.push_back(
I->isAlmostTrailingComment());
3163 class ASTMethodPoolTrait {
3168 typedef key_type key_type_ref;
3174 typedef const data_type& data_type_ref;
3176 typedef unsigned hash_value_type;
3177 typedef unsigned offset_type;
3179 explicit ASTMethodPoolTrait(
ASTWriter &Writer) : Writer(Writer) { }
3185 std::pair<unsigned,unsigned>
3186 EmitKeyDataLength(raw_ostream& Out,
Selector Sel,
3187 data_type_ref Methods) {
3188 using namespace llvm::support;
3189 endian::Writer<little> LE(Out);
3191 LE.write<uint16_t>(KeyLen);
3192 unsigned DataLen = 4 + 2 + 2;
3195 if (Method->getMethod())
3199 if (Method->getMethod())
3201 LE.write<uint16_t>(DataLen);
3202 return std::make_pair(KeyLen, DataLen);
3205 void EmitKey(raw_ostream& Out,
Selector Sel,
unsigned) {
3206 using namespace llvm::support;
3207 endian::Writer<little> LE(Out);
3208 uint64_t Start = Out.tell();
3209 assert((Start >> 32) == 0 &&
"Selector key offset too large");
3210 Writer.SetSelectorOffset(Sel, Start);
3212 LE.write<uint16_t>(N);
3215 for (
unsigned I = 0;
I != N; ++
I)
3220 void EmitData(raw_ostream& Out, key_type_ref,
3221 data_type_ref Methods,
unsigned DataLen) {
3222 using namespace llvm::support;
3223 endian::Writer<little> LE(Out);
3224 uint64_t Start = Out.tell(); (void)Start;
3225 LE.write<uint32_t>(Methods.ID);
3226 unsigned NumInstanceMethods = 0;
3229 if (Method->getMethod())
3230 ++NumInstanceMethods;
3232 unsigned NumFactoryMethods = 0;
3235 if (Method->getMethod())
3236 ++NumFactoryMethods;
3238 unsigned InstanceBits = Methods.Instance.getBits();
3239 assert(InstanceBits < 4);
3240 unsigned InstanceHasMoreThanOneDeclBit =
3241 Methods.Instance.hasMoreThanOneDecl();
3242 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
3243 (InstanceHasMoreThanOneDeclBit << 2) |
3245 unsigned FactoryBits = Methods.Factory.getBits();
3246 assert(FactoryBits < 4);
3247 unsigned FactoryHasMoreThanOneDeclBit =
3248 Methods.Factory.hasMoreThanOneDecl();
3249 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
3250 (FactoryHasMoreThanOneDeclBit << 2) |
3252 LE.write<uint16_t>(FullInstanceBits);
3253 LE.write<uint16_t>(FullFactoryBits);
3256 if (Method->getMethod())
3257 LE.write<uint32_t>(Writer.getDeclID(Method->getMethod()));
3260 if (Method->getMethod())
3261 LE.write<uint32_t>(Writer.getDeclID(Method->getMethod()));
3263 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3274 void ASTWriter::WriteSelectors(
Sema &SemaRef) {
3275 using namespace llvm;
3278 if (SemaRef.
MethodPool.empty() && SelectorIDs.empty())
3280 unsigned NumTableEntries = 0;
3283 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait> Generator;
3284 ASTMethodPoolTrait Trait(*
this);
3288 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
3289 for (
auto &SelectorAndID : SelectorIDs) {
3292 Sema::GlobalMethodPool::iterator F = SemaRef.
MethodPool.find(S);
3293 ASTMethodPoolTrait::data_type Data = {
3299 Data.Instance = F->second.first;
3300 Data.Factory = F->second.second;
3304 if (Chain && ID < FirstSelectorID) {
3306 bool changed =
false;
3308 !changed && M && M->getMethod(); M = M->getNext()) {
3309 if (!M->getMethod()->isFromASTFile())
3312 for (
ObjCMethodList *M = &Data.Factory; !changed && M && M->getMethod();
3314 if (!M->getMethod()->isFromASTFile())
3319 }
else if (Data.Instance.getMethod() || Data.Factory.getMethod()) {
3323 Generator.insert(S, Data, Trait);
3328 uint32_t BucketOffset;
3330 using namespace llvm::support;
3331 ASTMethodPoolTrait Trait(*
this);
3332 llvm::raw_svector_ostream Out(MethodPool);
3334 endian::Writer<little>(Out).write<uint32_t>(0);
3335 BucketOffset = Generator.Emit(Out, Trait);
3339 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3341 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3342 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3343 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3344 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3348 RecordData::value_type Record[] = {
METHOD_POOL, BucketOffset,
3350 Stream.EmitRecordWithBlob(MethodPoolAbbrev, Record, MethodPool);
3354 Abbrev = std::make_shared<BitCodeAbbrev>();
3356 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3357 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3358 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3359 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3363 RecordData::value_type Record[] = {
3366 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev, Record,
3367 bytes(SelectorOffsets));
3373 void ASTWriter::WriteReferencedSelectorsPool(
Sema &SemaRef) {
3374 using namespace llvm;
3385 Selector Sel = SelectorAndLocation.first;
3387 Writer.AddSelectorRef(Sel);
3388 Writer.AddSourceLocation(Loc);
3409 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3411 if (!Redecl->isFromASTFile()) {
3415 if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
3418 return cast<NamedDecl>(Redecl);
3423 if (Redecl->getOwningModuleID() == 0)
3428 if (!First->isFromASTFile())
3429 return cast<NamedDecl>(First);
3439 class ASTIdentifierTableTrait {
3464 typedef key_type key_type_ref;
3467 typedef data_type data_type_ref;
3469 typedef unsigned hash_value_type;
3470 typedef unsigned offset_type;
3475 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3476 NeedDecls(!IsModule || !Writer.getLangOpts().
CPlusPlus),
3477 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3479 bool needDecls()
const {
return NeedDecls; }
3482 return llvm::HashString(II->
getName());
3486 auto MacroOffset = Writer.getMacroDirectivesOffset(II);
3494 std::pair<unsigned,unsigned>
3497 unsigned DataLen = 4;
3498 auto MacroOffset = Writer.getMacroDirectivesOffset(II);
3507 DEnd = IdResolver.end();
3512 using namespace llvm::support;
3513 endian::Writer<little> LE(Out);
3515 assert((uint16_t)DataLen == DataLen && (uint16_t)KeyLen == KeyLen);
3516 LE.write<uint16_t>(DataLen);
3520 LE.write<uint16_t>(KeyLen);
3521 return std::make_pair(KeyLen, DataLen);
3528 Writer.SetIdentifierOffset(II, Out.tell());
3533 InterestingIdentifierOffsets->push_back(Out.tell() - 4);
3540 using namespace llvm::support;
3541 endian::Writer<little> LE(Out);
3543 auto MacroOffset = Writer.getMacroDirectivesOffset(II);
3545 LE.write<uint32_t>(ID << 1);
3549 LE.write<uint32_t>((ID << 1) | 0x01);
3551 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
3552 LE.write<uint16_t>(Bits);
3554 bool HadMacroDefinition = MacroOffset != 0;
3555 Bits = (Bits << 1) |
unsigned(HadMacroDefinition);
3557 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
3561 LE.write<uint16_t>(Bits);
3563 if (HadMacroDefinition)
3564 LE.write<uint32_t>(MacroOffset);
3576 DEnd = Decls.rend();
3594 using namespace llvm;
3596 RecordData InterestingIdents;
3601 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait> Generator;
3602 ASTIdentifierTableTrait Trait(
3603 *
this, PP, IdResolver, IsModule,
3604 (getLangOpts().
CPlusPlus && IsModule) ? &InterestingIdents :
nullptr);
3613 IIs.push_back(ID.second);
3616 std::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
3618 if (Trait.isInterestingNonMacroIdentifier(II))
3619 getIdentifierRef(II);
3623 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
3624 for (
auto IdentIDPair : IdentifierIDs) {
3626 IdentID ID = IdentIDPair.second;
3627 assert(II &&
"NULL identifier in identifier table");
3630 if (ID >= FirstIdentID || !Chain || !II->
isFromAST()
3632 (Trait.needDecls() &&
3634 Generator.insert(II, ID, Trait);
3639 uint32_t BucketOffset;
3641 using namespace llvm::support;
3642 llvm::raw_svector_ostream Out(IdentifierTable);
3644 endian::Writer<little>(Out).write<uint32_t>(0);
3645 BucketOffset = Generator.Emit(Out, Trait);
3649 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3651 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3652 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3653 unsigned IDTableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3657 Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable);
3661 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3663 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3664 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3665 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3666 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3669 for (
unsigned I = 0, N = IdentifierOffsets.size();
I != N; ++
I)
3670 assert(IdentifierOffsets[
I] &&
"Missing identifier offset?");
3674 IdentifierOffsets.size(),
3676 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev, Record,
3677 bytes(IdentifierOffsets));
3681 if (!InterestingIdents.empty())
3692 class ASTDeclContextNameLookupTrait {
3698 typedef key_type key_type_ref;
3701 typedef std::pair<unsigned, unsigned> data_type;
3702 typedef const data_type& data_type_ref;
3704 typedef unsigned hash_value_type;
3705 typedef unsigned offset_type;
3707 explicit ASTDeclContextNameLookupTrait(
ASTWriter &Writer) : Writer(Writer) { }
3709 template<
typename Coll>
3710 data_type getData(
const Coll &Decls) {
3711 unsigned Start = DeclIDs.size();
3716 return std::make_pair(Start, DeclIDs.size());
3720 unsigned Start = DeclIDs.size();
3721 for (
auto ID : FromReader)
3722 DeclIDs.push_back(ID);
3723 return std::make_pair(Start, DeclIDs.size());
3726 static bool EqualKey(key_type_ref a, key_type_ref b) {
3734 void EmitFileRef(raw_ostream &Out,
ModuleFile *F)
const {
3735 assert(Writer.hasChain() &&
3736 "have reference to loaded module file but no chain?");
3738 using namespace llvm::support;
3739 endian::Writer<little>(Out)
3740 .write<uint32_t>(Writer.getChain()->getModuleFileID(F));
3743 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
3745 data_type_ref Lookup) {
3746 using namespace llvm::support;
3747 endian::Writer<little> LE(Out);
3748 unsigned KeyLen = 1;
3767 LE.write<uint16_t>(KeyLen);
3770 unsigned DataLen = 4 * (Lookup.second - Lookup.first);
3771 assert(uint16_t(DataLen) == DataLen &&
3772 "too many decls for serialized lookup result");
3773 LE.write<uint16_t>(DataLen);
3775 return std::make_pair(KeyLen, DataLen);
3779 using namespace llvm::support;
3780 endian::Writer<little> LE(Out);
3781 LE.write<uint8_t>(Name.
getKind());
3786 LE.write<uint32_t>(Writer.getIdentifierRef(Name.
getIdentifier()));
3791 LE.write<uint32_t>(Writer.getSelectorRef(Name.
getSelector()));
3795 "Invalid operator?");
3805 llvm_unreachable(
"Invalid name kind?");
3808 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
3810 using namespace llvm::support;
3811 endian::Writer<little> LE(Out);
3812 uint64_t Start = Out.tell(); (void)Start;
3813 for (
unsigned I = Lookup.first, N = Lookup.second;
I != N; ++
I)
3814 LE.write<uint32_t>(DeclIDs[
I]);
3815 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3823 return Result.
hasExternalDecls() && DC->NeedToReconcileExternalVisibleStorage;
3826 bool ASTWriter::isLookupResultEntirelyExternal(
StoredDeclsList &Result,
3836 ASTWriter::GenerateNameLookupTable(
const DeclContext *ConstDC,
3838 assert(!ConstDC->HasLazyLocalLexicalLookups &&
3839 !ConstDC->HasLazyExternalLexicalLookups &&
3840 "must call buildLookups first");
3848 ASTDeclContextNameLookupTrait> Generator;
3849 ASTDeclContextNameLookupTrait Trait(*
this);
3858 llvm::SmallSet<DeclarationName, 8> ConstructorNameSet, ConversionNameSet;
3861 auto &Name = Lookup.first;
3862 auto &Result = Lookup.second;
3868 if (isLookupResultExternal(Result, DC) &&
3869 isLookupResultEntirelyExternal(Result, DC))
3886 if (Lookup.second.getLookupResult().empty())
3889 switch (Lookup.first.getNameKind()) {
3891 Names.push_back(Lookup.first);
3895 assert(isa<CXXRecordDecl>(DC) &&
3896 "Cannot have a constructor name outside of a class!");
3897 ConstructorNameSet.insert(Name);
3901 assert(isa<CXXRecordDecl>(DC) &&
3902 "Cannot have a conversion function name outside of a class!");
3903 ConversionNameSet.insert(Name);
3909 std::sort(Names.begin(), Names.end());
3911 if (
auto *D = dyn_cast<CXXRecordDecl>(DC)) {
3925 if (ConstructorNameSet.erase(ImplicitCtorName))
3926 Names.push_back(ImplicitCtorName);
3931 if (!ConstructorNameSet.empty() || !ConversionNameSet.empty())
3932 for (
Decl *ChildD : cast<CXXRecordDecl>(DC)->decls())
3933 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
3934 auto Name = ChildND->getDeclName();
3935 switch (Name.getNameKind()) {
3940 if (ConstructorNameSet.erase(Name))
3941 Names.push_back(Name);
3945 if (ConversionNameSet.erase(Name))
3946 Names.push_back(Name);
3950 if (ConstructorNameSet.empty() && ConversionNameSet.empty())
3954 assert(ConstructorNameSet.empty() &&
"Failed to find all of the visible "
3955 "constructors by walking all the "
3956 "lexical members of the context.");
3957 assert(ConversionNameSet.empty() &&
"Failed to find all of the visible "
3958 "conversion functions by walking all "
3959 "the lexical members of the context.");
3966 for (
auto &Name : Names)
3978 for (
auto &Name : Names) {
3981 switch (Name.getNameKind()) {
3983 Generator.insert(Name, Trait.getData(Result), Trait);
3987 ConstructorDecls.append(Result.
begin(), Result.
end());
3991 ConversionDecls.append(Result.
begin(), Result.
end());
3999 if (!ConstructorDecls.empty())
4000 Generator.insert(ConstructorDecls.front()->getDeclName(),
4001 Trait.getData(ConstructorDecls), Trait);
4002 if (!ConversionDecls.empty())
4003 Generator.insert(ConversionDecls.front()->getDeclName(),
4004 Trait.getData(ConversionDecls), Trait);
4008 auto *Lookups = Chain ? Chain->getLoadedLookupTables(DC) :
nullptr;
4009 Generator.emit(LookupTable, Trait, Lookups ? &Lookups->Table :
nullptr);
4017 uint64_t ASTWriter::WriteDeclContextVisibleBlock(
ASTContext &Context,
4022 if (isa<NamespaceDecl>(DC) && Chain &&
4023 Chain->getKeyDeclaration(cast<Decl>(DC))->isFromASTFile()) {
4025 for (
auto *Prev = cast<NamespaceDecl>(DC)->getPreviousDecl(); Prev;
4026 Prev = Prev->getPreviousDecl())
4027 if (!Prev->isFromASTFile())
4040 LookupResults.reserve(Map->size());
4041 for (
auto &Entry : *Map)
4042 LookupResults.push_back(
4043 std::make_pair(Entry.first, Entry.second.getLookupResult()));
4046 std::sort(LookupResults.begin(), LookupResults.end(), llvm::less_first());
4047 for (
auto &NameAndResult : LookupResults) {
4055 assert(Result.
empty() &&
"Cannot have a constructor or conversion "
4056 "function name in a namespace!");
4061 if (!ND->isFromASTFile())
4085 uint64_t Offset = Stream.GetCurrentBitNo();
4087 if (!Map || Map->empty())
4092 GenerateNameLookupTable(DC, LookupTable);
4096 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev, Record,
4098 ++NumVisibleDeclContexts;
4108 void ASTWriter::WriteDeclContextVisibleUpdate(
const DeclContext *DC) {
4110 if (!Map || Map->empty())
4115 GenerateNameLookupTable(DC, LookupTable);
4119 if (isa<NamespaceDecl>(DC))
4120 DC = cast<DeclContext>(Chain->getKeyDeclaration(cast<Decl>(DC)));
4123 RecordData::value_type Record[] = {
UPDATE_VISIBLE, getDeclID(cast<Decl>(DC))};
4124 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev, Record, LookupTable);
4128 void ASTWriter::WriteFPPragmaOptions(
const FPOptions &Opts) {
4129 RecordData::value_type Record[] = {Opts.
getInt()};
4134 void ASTWriter::WriteOpenCLExtensions(
Sema &SemaRef) {
4140 for (
const auto &
I:Opts.OptMap) {
4141 AddString(
I.getKey(), Record);
4142 auto V =
I.getValue();
4143 Record.push_back(V.Supported ? 1 : 0);
4144 Record.push_back(V.Enabled ? 1 : 0);
4145 Record.push_back(V.Avail);
4146 Record.push_back(V.Core);
4151 void ASTWriter::WriteOpenCLExtensionTypes(
Sema &SemaRef) {
4156 for (
const auto &
I : SemaRef.OpenCLTypeExtMap) {
4158 static_cast<unsigned>(getTypeID(
I.first->getCanonicalTypeInternal())));
4159 Record.push_back(
I.second.size());
4160 for (
auto Ext :
I.second)
4161 AddString(Ext, Record);
4166 void ASTWriter::WriteOpenCLExtensionDecls(
Sema &SemaRef) {
4171 for (
const auto &
I : SemaRef.OpenCLDeclExtMap) {
4172 Record.push_back(getDeclID(
I.first));
4173 Record.push_back(static_cast<unsigned>(
I.second.size()));
4174 for (
auto Ext :
I.second)
4175 AddString(Ext, Record);
4180 void ASTWriter::WriteCUDAPragmas(
Sema &SemaRef) {
4181 if (SemaRef.ForceCUDAHostDeviceDepth > 0) {
4182 RecordData::value_type Record[] = {SemaRef.ForceCUDAHostDeviceDepth};
4187 void ASTWriter::WriteObjCCategories() {
4189 RecordData Categories;
4191 for (
unsigned I = 0, N = ObjCClassesWithCategories.size();
I != N; ++
I) {
4193 unsigned StartIndex = Categories.size();
4198 Categories.push_back(0);
4204 Cat != CatEnd; ++Cat, ++Size) {
4205 assert(getDeclID(*Cat) != 0 &&
"Bogus category");
4206 AddDeclRef(*Cat, Categories);
4210 Categories[StartIndex] = Size;
4214 CategoriesMap.push_back(CatInfo);
4219 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
4222 using namespace llvm;
4224 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4226 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
4227 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4228 unsigned AbbrevID = Stream.EmitAbbrev(std::move(Abbrev));
4231 Stream.EmitRecordWithBlob(AbbrevID, Record,
4232 reinterpret_cast<char *>(CategoriesMap.data()),
4239 void ASTWriter::WriteLateParsedTemplates(
Sema &SemaRef) {
4246 for (
auto &LPTMapEntry : LPTMap) {
4249 AddDeclRef(FD, Record);
4250 AddDeclRef(LPT.
D, Record);
4251 Record.push_back(LPT.
Toks.size());
4253 for (
const auto &Tok : LPT.
Toks) {
4254 AddToken(Tok, Record);
4261 void ASTWriter::WriteOptimizePragmaOptions(
Sema &SemaRef) {
4264 AddSourceLocation(PragmaLoc, Record);
4269 void ASTWriter::WriteMSStructPragmaOptions(
Sema &SemaRef) {
4277 void ASTWriter::WriteMSPointersToMembersPragmaOptions(
Sema &SemaRef) {
4285 void ASTWriter::WritePackPragmaOptions(
Sema &SemaRef) {
4296 Record.push_back(StackEntry.Value);
4297 AddSourceLocation(StackEntry.PragmaLocation, Record);
4298 AddString(StackEntry.StackSlotLabel, Record);
4303 void ASTWriter::WriteModuleFileExtension(
Sema &SemaRef,
4309 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
4311 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4312 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4313 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4314 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4315 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4316 unsigned Abbrev = Stream.EmitAbbrev(std::move(Abv));
4322 Record.push_back(Metadata.MajorVersion);
4323 Record.push_back(Metadata.MinorVersion);
4324 Record.push_back(Metadata.BlockName.size());
4325 Record.push_back(Metadata.UserInfo.size());
4327 Buffer += Metadata.BlockName;
4328 Buffer += Metadata.UserInfo;
4329 Stream.EmitRecordWithBlob(Abbrev, Record, Buffer);
4344 auto &Record = *
this;
4345 Record.push_back(Attrs.size());
4346 for (
const auto *A : Attrs) {
4347 Record.push_back(A->getKind());
4348 Record.AddSourceRange(A->getRange());
4350 #include "clang/Serialization/AttrPCHWrite.inc"
4363 Record.push_back(Tok.
getKind());
4369 Record.push_back(Str.size());
4370 Record.insert(Record.end(), Str.begin(), Str.end());
4374 assert(Context &&
"should have context when outputting path");
4380 const char *PathBegin = Path.data();
4381 const char *PathPtr =
4383 if (PathPtr != PathBegin) {
4384 Path.erase(Path.begin(), Path.begin() + (PathPtr - PathBegin));
4393 PreparePathForOutput(FilePath);
4394 AddString(FilePath, Record);
4400 PreparePathForOutput(FilePath);
4401 Stream.EmitRecordWithBlob(Abbrev, Record, FilePath);
4406 Record.push_back(Version.
getMajor());
4408 Record.push_back(*Minor + 1);
4410 Record.push_back(0);
4412 Record.push_back(*Subminor + 1);
4414 Record.push_back(0);
4420 IdentID ID = IdentifierIDs[II];
4423 if (ID >= FirstIdentID)
4424 IdentifierOffsets[ID - FirstIdentID] =
Offset;
4430 unsigned ID = SelectorIDs[Sel];
4431 assert(ID &&
"Unknown selector");
4434 if (ID < FirstSelectorID)
4436 SelectorOffsets[ID - FirstSelectorID] =
Offset;
4441 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
4442 bool IncludeTimestamps)
4443 : Stream(Stream), Buffer(Buffer), PCMCache(PCMCache),
4444 IncludeTimestamps(IncludeTimestamps) {
4445 for (
const auto &Ext : Extensions) {
4446 if (
auto Writer = Ext->createExtensionWriter(*
this))
4447 ModuleFileExtensionWriters.push_back(std::move(Writer));
4452 llvm::DeleteContainerSeconds(FileDeclIDs);
4456 assert(WritingAST &&
"can't determine lang opts when not writing AST");
4465 const std::string &OutputFile,
4466 Module *WritingModule, StringRef isysroot,
4470 ASTHasCompilerErrors = hasErrors;
4473 Stream.Emit((
unsigned)
'C', 8);
4474 Stream.Emit((
unsigned)
'P', 8);
4475 Stream.Emit((
unsigned)
'C', 8);
4476 Stream.Emit((
unsigned)
'H', 8);
4478 WriteBlockInfoBlock();
4482 this->WritingModule = WritingModule;
4484 WriteASTCore(SemaRef, isysroot, OutputFile, WritingModule);
4487 this->WritingModule =
nullptr;
4488 this->BaseDirectory.clear();
4494 llvm::MemoryBuffer::getMemBufferCopy(
4495 StringRef(Buffer.begin(), Buffer.size())));
4500 template<
typename Vector>
4503 for (
typename Vector::iterator
I = Vec.begin(
nullptr,
true),
E = Vec.end();
4510 const std::string &OutputFile,
4512 using namespace llvm;
4514 bool isModule = WritingModule !=
nullptr;
4518 Chain->finalizeForWriting();
4526 assert(D->isCanonicalDecl() &&
"predefined decl is not canonical");
4535 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
4539 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
4543 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
4546 RegisterPredefDecl(Context.MakeIntegerSeqDecl,
4548 RegisterPredefDecl(Context.CFConstantStringTypeDecl,
4550 RegisterPredefDecl(Context.CFConstantStringTagDecl,
4552 RegisterPredefDecl(Context.TypePackElementDecl,
4565 UnusedFileScopedDecls);
4579 WeakInfo &WI = WeakUndeclaredIdentifier.second;
4583 WeakUndeclaredIdentifiers.push_back(WI.
getUsed());
4593 for (
unsigned I = 0, N = SemaRef.
VTableUses.size();
I != N; ++
I) {
4603 AddDeclRef(TD, UnusedLocalTypedefNameCandidates);
4612 "There are local ones at end of translation unit!");
4629 for (
const auto &
I : SemaRef.KnownNamespaces) {
4639 for (
const auto &
I : Undefined) {
4648 for (
const auto &DeleteExprsInfo :
4650 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
4651 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
4652 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
4654 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
4659 WriteControlBlock(PP, Context, isysroot, OutputFile);
4675 for (
const auto *D : TU->noload_decls()) {
4676 if (!D->isFromASTFile()) {
4677 NewGlobalKindDeclPairs.push_back(D->getKind());
4678 NewGlobalKindDeclPairs.push_back(
GetDeclRef(D));
4682 auto Abv = std::make_shared<BitCodeAbbrev>();
4684 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4685 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
4688 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev, Record,
4689 bytes(NewGlobalKindDeclPairs));
4693 Abv = std::make_shared<BitCodeAbbrev>();
4695 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4696 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4697 UpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
4698 WriteDeclContextVisibleUpdate(TU);
4701 if (Context.ExternCContext)
4702 WriteDeclContextVisibleUpdate(Context.ExternCContext);
4716 for (
const auto &Number : Context.MangleNumbers)
4717 if (!Number.first->isFromASTFile())
4720 for (
const auto &Number : Context.StaticLocalNumbers)
4721 if (!Number.first->isFromASTFile())
4728 for (
const auto *
I : DeclsToEmitEvenIfUnreferenced) {
4742 std::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
4760 for (
auto &SelectorAndID : SelectorIDs)
4761 AllSelectors.push_back(SelectorAndID.first);
4762 for (
auto &
Selector : AllSelectors)
4771 AddTypeRef(Context.ObjCIdRedefinitionType, SpecialTypes);
4772 AddTypeRef(Context.ObjCClassRedefinitionType, SpecialTypes);
4773 AddTypeRef(Context.ObjCSelRedefinitionType, SpecialTypes);
4792 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4794 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4795 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4798 llvm::raw_svector_ostream Out(Buffer);
4800 using namespace llvm::support;
4801 endian::Writer<little> LE(Out);
4803 LE.write<uint16_t>(
FileName.size());
4810 auto writeBaseIDOrNone = [&](uint32_t BaseID,
bool ShouldWrite) {
4813 LE.write<uint32_t>(BaseID);
4815 LE.write<uint32_t>(
None);
4832 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev, Record,
4833 Buffer.data(), Buffer.size());
4844 WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord);
4845 while (!DeclTypesToEmit.empty()) {
4846 DeclOrType DOT = DeclTypesToEmit.front();
4847 DeclTypesToEmit.pop();
4849 WriteType(DOT.getType());
4851 WriteDecl(Context, DOT.getDecl());
4853 }
while (!DeclUpdates.empty());
4856 DoneWritingDeclsAndTypes =
true;
4859 WriteTypeDeclOffsets();
4860 if (!DeclUpdatesOffsetsRecord.empty())
4862 WriteFileDeclIDsMap();
4865 WritePreprocessor(PP, isModule);
4867 WriteSelectors(SemaRef);
4868 WriteReferencedSelectorsPool(SemaRef);
4869 WriteLateParsedTemplates(SemaRef);
4870 WriteIdentifierTable(PP, SemaRef.
IdResolver, isModule);
4872 WriteOpenCLExtensions(SemaRef);
4873 WriteOpenCLExtensionTypes(SemaRef);
4874 WriteOpenCLExtensionDecls(SemaRef);
4875 WriteCUDAPragmas(SemaRef);
4879 WriteSubmodules(WritingModule);
4884 if (!EagerlyDeserializedDecls.empty())
4887 if (!ModularCodegenDecls.empty())
4891 if (!TentativeDefinitions.empty())
4895 if (!UnusedFileScopedDecls.empty())
4899 if (!WeakUndeclaredIdentifiers.empty())
4901 WeakUndeclaredIdentifiers);
4904 if (!ExtVectorDecls.empty())
4908 if (!VTableUses.empty())
4912 if (!UnusedLocalTypedefNameCandidates.empty())
4914 UnusedLocalTypedefNameCandidates);
4917 if (!PendingInstantiations.empty())
4921 if (!SemaDeclRefs.empty())
4925 if (!CUDASpecialDeclRefs.empty())
4929 if (!DelegatingCtorDecls.empty())
4933 if (!KnownNamespaces.empty())
4937 if (!UndefinedButUsed.empty())
4940 if (!DeleteExprsToAnalyze.empty())
4944 for (
auto *DC : UpdatedDeclContexts)
4945 WriteDeclContextVisibleUpdate(DC);
4947 if (!WritingModule) {
4952 ModuleInfo(uint64_t ID,
Module *M) : ID(ID), M(M) {}
4956 assert(SubmoduleIDs.find(
I->getImportedModule()) != SubmoduleIDs.end());
4957 Imports.push_back(ModuleInfo(SubmoduleIDs[
I->getImportedModule()],
4958 I->getImportedModule()));
4961 if (!Imports.empty()) {
4962 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
4965 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
4966 return A.ID == B.ID;
4970 std::sort(Imports.begin(), Imports.end(), Cmp);
4971 Imports.erase(std::unique(Imports.begin(), Imports.end(), Eq),
4975 for (
const auto &Import : Imports) {
4976 ImportedModules.push_back(Import.ID);
4987 WriteObjCCategories();
4988 if(!WritingModule) {
4989 WriteOptimizePragmaOptions(SemaRef);
4990 WriteMSStructPragmaOptions(SemaRef);
4991 WriteMSPointersToMembersPragmaOptions(SemaRef);
4993 WritePackPragmaOptions(SemaRef);
4996 RecordData::value_type Record[] = {
4997 NumStatements, NumMacros, NumLexicalDeclContexts, NumVisibleDeclContexts};
5002 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
5003 WriteModuleFileExtension(SemaRef, *ExtWriter);
5005 return writeUnhashedControlBlock(PP, Context);
5008 void ASTWriter::WriteDeclUpdatesBlocks(
RecordDataImpl &OffsetsRecord) {
5009 if (DeclUpdates.empty())
5012 DeclUpdateMap LocalUpdates;
5013 LocalUpdates.swap(DeclUpdates);
5015 for (
auto &DeclUpdate : LocalUpdates) {
5016 const Decl *D = DeclUpdate.first;
5018 bool HasUpdatedBody =
false;
5021 for (
auto &Update : DeclUpdate.second) {
5027 HasUpdatedBody =
true;
5029 Record.push_back(Kind);
5035 assert(Update.getDecl() &&
"no decl to add?");
5036 Record.push_back(
GetDeclRef(Update.getDecl()));
5043 const VarDecl *VD = cast<VarDecl>(D);
5044 Record.AddSourceLocation(Update.getLoc());
5048 Record.AddStmt(const_cast<Expr*>(VD->
getInit()));
5050 Record.push_back(0);
5056 Record.AddStmt(const_cast<Expr *>(
5057 cast<ParmVarDecl>(Update.getDecl())->getDefaultArg()));
5062 cast<FieldDecl>(Update.getDecl())->getInClassInitializer());
5066 auto *RD = cast<CXXRecordDecl>(D);
5067 UpdatedDeclContexts.insert(RD->getPrimaryContext());
5068 Record.AddCXXDefinitionData(RD);
5069 Record.AddOffset(WriteDeclContextLexicalBlock(
5070 *Context, const_cast<CXXRecordDecl *>(RD)));
5075 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
5076 Record.push_back(MSInfo->getTemplateSpecializationKind());
5077 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
5079 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
5080 Record.push_back(Spec->getTemplateSpecializationKind());
5081 Record.AddSourceLocation(Spec->getPointOfInstantiation());
5085 auto From = Spec->getInstantiatedFrom();
5086 if (
auto PartialSpec =
5088 Record.push_back(
true);
5089 Record.AddDeclRef(PartialSpec);
5090 Record.AddTemplateArgumentList(
5091 &Spec->getTemplateInstantiationArgs());
5093 Record.push_back(
false);
5096 Record.push_back(RD->getTagKind());
5097 Record.AddSourceLocation(RD->getLocation());
5098 Record.AddSourceLocation(RD->getLocStart());
5099 Record.AddSourceRange(RD->getBraceRange());
5104 Record.AddAttributes(D->
getAttrs());
5111 Record.AddDeclRef(Update.getDecl());
5116 cast<FunctionDecl>(D)->getType()->castAs<FunctionProtoType>(),
5129 Record.push_back(Update.getNumber());
5133 Record.AddSourceRange(
5134 D->
getAttr<OMPThreadPrivateDeclAttr>()->getRange());
5138 Record.AddSourceRange(
5139 D->
getAttr<OMPDeclareTargetDeclAttr>()->getRange());
5143 Record.push_back(getSubmoduleID(Update.getModule()));
5147 Record.AddAttributes(llvm::makeArrayRef(Update.getAttr()));
5152 if (HasUpdatedBody) {
5153 const auto *Def = cast<FunctionDecl>(D);
5155 Record.push_back(Def->isInlined());
5156 Record.AddSourceLocation(Def->getInnerLocStart());
5157 Record.AddFunctionDefinition(Def);
5167 Record.push_back((Raw << 1) | (Raw >> 31));
5176 Record->push_back(Value.getBitWidth());
5177 const uint64_t *Words = Value.getRawData();
5178 Record->append(Words, Words + Value.getNumWords());
5182 Record->push_back(Value.isUnsigned());
5187 AddAPInt(Value.bitcastToAPInt());
5198 IdentID &ID = IdentifierIDs[II];
5214 MacroInfoToEmitData Info = {
Name, MI, ID };
5215 MacroInfosToEmit.push_back(Info);
5224 assert(MacroIDs.find(MI) != MacroIDs.end() &&
"Macro not emitted!");
5225 return MacroIDs[MI];
5229 return IdentMacroDirectivesOffsetMap.lookup(Name);
5233 Record->push_back(Writer->getSelectorRef(SelRef));
5242 if (SID == 0 && Chain) {
5245 Chain->LoadSelector(Sel);
5246 SID = SelectorIDs[Sel];
5249 SID = NextSelectorID++;
5250 SelectorIDs[Sel] = SID;
5263 AddStmt(Arg.getAsExpr());
5266 AddTypeSourceInfo(Arg.getAsTypeSourceInfo());
5269 AddNestedNameSpecifierLoc(Arg.getTemplateQualifierLoc());
5273 AddNestedNameSpecifierLoc(Arg.getTemplateQualifierLoc());
5291 bool InfoHasSameExpr
5293 Record->push_back(InfoHasSameExpr);
5294 if (InfoHasSameExpr)
5312 TypeLocWriter TLW(*
this);
5329 if (Idx.getIndex() == 0) {
5330 if (DoneWritingDeclsAndTypes) {
5331 assert(0 &&
"New type seen after serializing all the types to emit!");
5338 DeclTypesToEmit.push(T);
5351 TypeIdxMap::const_iterator
I = TypeIdxs.find(T);
5352 assert(I != TypeIdxs.end() &&
"Type not emitted!");
5362 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
5373 assert(!(reinterpret_cast<uintptr_t>(D) & 0x01) &&
"Invalid decl pointer");
5376 if (DoneWritingDeclsAndTypes) {
5377 assert(0 &&
"New decl seen after serializing all the decls to emit!");
5384 DeclTypesToEmit.push(const_cast<Decl *>(D));
5399 assert(DeclIDs.find(D) != DeclIDs.end() &&
"Declaration not emitted!");
5403 void ASTWriter::associateDeclWithFile(
const Decl *D,
DeclID ID) {
5416 if (isa<ParmVarDecl>(D))
5425 if (FID.isInvalid())
5429 DeclIDInFileInfo *&Info = FileDeclIDs[FID];
5431 Info =
new DeclIDInFileInfo();
5433 std::pair<unsigned, serialization::DeclID> LocDecl(Offset, ID);
5434 LocDeclIDsTy &Decls = Info->DeclIDs;
5436 if (Decls.empty() || Decls.back().first <=
Offset) {
5437 Decls.push_back(LocDecl);
5441 LocDeclIDsTy::iterator
I =
5442 std::upper_bound(Decls.begin(), Decls.end(), LocDecl, llvm::less_first());
5444 Decls.insert(I, LocDecl);
5487 "expected an anonymous declaration");
5491 auto It = AnonymousDeclarationNumbers.find(D);
5492 if (It == AnonymousDeclarationNumbers.end()) {
5495 AnonymousDeclarationNumbers[ND] = Number;
5498 It = AnonymousDeclarationNumbers.find(D);
5499 assert(It != AnonymousDeclarationNumbers.end() &&
5500 "declaration not found within its lexical context");
5539 AddDeclarationName(NameInfo.
getName());
5558 NestedNames.push_back(NNS);
5562 Record->push_back(NestedNames.size());
5563 while(!NestedNames.empty()) {
5564 NNS = NestedNames.pop_back_val();
5566 Record->push_back(Kind);
5605 NestedNames.push_back(NNS);
5609 Record->push_back(NestedNames.size());
5610 while(!NestedNames.empty()) {
5611 NNS = NestedNames.pop_back_val();
5614 Record->push_back(Kind);
5652 Record->push_back(Kind);
5660 Record->push_back(OvT->
size());
5661 for (
const auto &I : *OvT)
5704 Record->push_back(Arg.
getKind());
5728 Record->push_back(*NumExpansions + 1);
5730 Record->push_back(0);
5738 AddTemplateArgument(
P);
5745 assert(TemplateParams &&
"No TemplateParams!");
5750 Record->push_back(TemplateParams->
size());
5751 for (
const auto &
P : *TemplateParams)
5758 assert(TemplateArgs &&
"No TemplateArgs!");
5759 Record->push_back(TemplateArgs->
size());
5760 for (
int i = 0, e = TemplateArgs->
size(); i != e; ++i)
5761 AddTemplateArgument(TemplateArgs->
get(i));
5766 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
5772 AddTemplateArgumentLoc(TemplArgs[i]);
5776 Record->push_back(Set.
size());
5780 Record->push_back(I.getAccess());
5802 for (
auto &
Base : Bases)
5820 for (
auto *Init : CtorInits) {
5821 if (Init->isBaseInitializer()) {
5824 Writer.
push_back(Init->isBaseVirtual());
5825 }
else if (Init->isDelegatingInitializer()) {
5828 }
else if (Init->isMemberInitializer()){
5833 Writer.
AddDeclRef(Init->getIndirectMember());
5837 Writer.
AddStmt(Init->getInit());
5841 if (Init->isWritten())
5842 Writer.
push_back(Init->getSourceOrder());
5855 auto &Data = D->data();
5856 Record->push_back(Data.IsLambda);
5857 Record->push_back(Data.UserDeclaredConstructor);
5858 Record->push_back(Data.UserDeclaredSpecialMembers);
5859 Record->push_back(Data.Aggregate);
5860 Record->push_back(Data.PlainOldData);
5861 Record->push_back(Data.Empty);
5862 Record->push_back(Data.Polymorphic);
5863 Record->push_back(Data.Abstract);
5864 Record->push_back(Data.IsStandardLayout);
5865 Record->push_back(Data.HasNoNonEmptyBases);
5866 Record->push_back(Data.HasPrivateFields);
5867 Record->push_back(Data.HasProtectedFields);
5868 Record->push_back(Data.HasPublicFields);
5869 Record->push_back(Data.HasMutableFields);
5870 Record->push_back(Data.HasVariantMembers);
5871 Record->push_back(Data.HasOnlyCMembers);
5872 Record->push_back(Data.HasInClassInitializer);
5873 Record->push_back(Data.HasUninitializedReferenceMember);
5874 Record->push_back(Data.HasUninitializedFields);
5875 Record->push_back(Data.HasInheritedConstructor);
5876 Record->push_back(Data.HasInheritedAssignment);
5877 Record->push_back(Data.NeedOverloadResolutionForCopyConstructor);
5878 Record->push_back(Data.NeedOverloadResolutionForMoveConstructor);
5879 Record->push_back(Data.NeedOverloadResolutionForMoveAssignment);
5880 Record->push_back(Data.NeedOverloadResolutionForDestructor);
5881 Record->push_back(Data.DefaultedCopyConstructorIsDeleted);
5882 Record->push_back(Data.DefaultedMoveConstructorIsDeleted);
5883 Record->push_back(Data.DefaultedMoveAssignmentIsDeleted);
5884 Record->push_back(Data.DefaultedDestructorIsDeleted);
5885 Record->push_back(Data.HasTrivialSpecialMembers);
5886 Record->push_back(Data.DeclaredNonTrivialSpecialMembers);
5887 Record->push_back(Data.HasIrrelevantDestructor);
5888 Record->push_back(Data.HasConstexprNonCopyMoveConstructor);
5889 Record->push_back(Data.HasDefaultedDefaultConstructor);
5890 Record->push_back(Data.CanPassInRegisters);
5891 Record->push_back(Data.DefaultedDefaultConstructorIsConstexpr);
5892 Record->push_back(Data.HasConstexprDefaultConstructor);
5893 Record->push_back(Data.HasNonLiteralTypeFieldsOrBases);
5894 Record->push_back(Data.ComputedVisibleConversions);
5895 Record->push_back(Data.UserProvidedDefaultConstructor);
5896 Record->push_back(Data.DeclaredSpecialMembers);
5897 Record->push_back(Data.ImplicitCopyConstructorCanHaveConstParamForVBase);
5898 Record->push_back(Data.ImplicitCopyConstructorCanHaveConstParamForNonVBase);
5899 Record->push_back(Data.ImplicitCopyAssignmentHasConstParam);
5900 Record->push_back(Data.HasDeclaredCopyConstructorWithConstParam);
5901 Record->push_back(Data.HasDeclaredCopyAssignmentWithConstParam);
5905 bool ModulesDebugInfo = Writer->Context->getLangOpts().ModulesDebugInfo &&
5907 Record->push_back(ModulesDebugInfo);
5908 if (ModulesDebugInfo)
5909 Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(D));
5913 Record->push_back(Data.NumBases);
5914 if (Data.NumBases > 0)
5915 AddCXXBaseSpecifiers(Data.bases());
5918 Record->push_back(Data.NumVBases);
5919 if (Data.NumVBases > 0)
5920 AddCXXBaseSpecifiers(Data.vbases());
5922 AddUnresolvedSet(Data.Conversions.get(*Writer->Context));
5923 AddUnresolvedSet(Data.VisibleConversions.get(*Writer->Context));
5928 if (Data.IsLambda) {
5929 auto &Lambda = D->getLambdaData();
5930 Record->push_back(Lambda.Dependent);
5931 Record->push_back(Lambda.IsGenericLambda);
5932 Record->push_back(Lambda.CaptureDefault);
5933 Record->push_back(Lambda.NumCaptures);
5934 Record->push_back(Lambda.NumExplicitCaptures);
5935 Record->push_back(Lambda.ManglingNumber);
5937 AddTypeSourceInfo(Lambda.MethodTyInfo);
5938 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
5961 void ASTWriter::ReaderInitialized(
ASTReader *Reader) {
5962 assert(Reader &&
"Cannot remove chain");
5963 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
5964 assert(FirstDeclID == NextDeclID &&
5965 FirstTypeID == NextTypeID &&
5966 FirstIdentID == NextIdentID &&
5967 FirstMacroID == NextMacroID &&
5968 FirstSubmoduleID == NextSubmoduleID &&
5969 FirstSelectorID == NextSelectorID &&
5970 "Setting chain after writing has started.");
5982 NextDeclID = FirstDeclID;
5983 NextTypeID = FirstTypeID;
5984 NextIdentID = FirstIdentID;
5985 NextMacroID = FirstMacroID;
5986 NextSelectorID = FirstSelectorID;
5987 NextSubmoduleID = FirstSubmoduleID;
5992 IdentID &StoredID = IdentifierIDs[II];
5999 MacroID &StoredID = MacroIDs[MI];
6010 TypeIdx &StoredIdx = TypeIdxs[T];
6024 assert(MacroDefinitions.find(MD) == MacroDefinitions.end());
6025 MacroDefinitions[MD] =
ID;
6029 assert(SubmoduleIDs.find(Mod) == SubmoduleIDs.end());
6030 SubmoduleIDs[Mod] =
ID;
6033 void ASTWriter::CompletedTagDefinition(
const TagDecl *D) {
6034 if (Chain && Chain->isProcessingUpdateRecords())
return;
6036 assert(!WritingAST &&
"Already writing the AST!");
6037 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
6039 if (RD->isFromASTFile()) {
6044 "completed a tag from another module but not by instantiation?");
6045 DeclUpdates[RD].push_back(
6060 void ASTWriter::AddedVisibleDecl(
const DeclContext *DC,
const Decl *D) {
6061 if (Chain && Chain->isProcessingUpdateRecords())
return;
6063 "Should not add lookup results to non-lookup contexts!");
6066 if (isa<TranslationUnitDecl>(DC))
6074 !isa<FunctionTemplateDecl>(D))
6084 assert(!WritingAST &&
"Already writing the AST!");
6085 if (UpdatedDeclContexts.insert(DC) && !cast<Decl>(DC)->isFromASTFile()) {
6089 for (
auto *Child : DC->
decls())
6090 DeclsToEmitEvenIfUnreferenced.push_back(Child);
6092 DeclsToEmitEvenIfUnreferenced.push_back(D);
6095 void ASTWriter::AddedCXXImplicitMember(
const CXXRecordDecl *RD,
const Decl *D) {
6096 if (Chain && Chain->isProcessingUpdateRecords())
return;
6104 if (!isa<CXXMethodDecl>(D))
6109 assert(!WritingAST &&
"Already writing the AST!");
6113 void ASTWriter::ResolvedExceptionSpec(
const FunctionDecl *FD) {
6114 if (Chain && Chain->isProcessingUpdateRecords())
return;
6115 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
6117 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
6122 ->castAs<FunctionProtoType>()
6123 ->getExceptionSpecType()))
6129 if (Chain && Chain->isProcessingUpdateRecords())
return;
6130 assert(!WritingAST &&
"Already writing the AST!");
6132 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
6133 DeclUpdates[D].push_back(
6140 if (Chain && Chain->isProcessingUpdateRecords())
return;
6141 assert(!WritingAST &&
"Already writing the AST!");
6142 assert(Delete &&
"Not given an operator delete");
6144 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
6149 void ASTWriter::CompletedImplicitDefinition(
const FunctionDecl *D) {
6150 if (Chain && Chain->isProcessingUpdateRecords())
return;
6151 assert(!WritingAST &&
"Already writing the AST!");
6159 void ASTWriter::FunctionDefinitionInstantiated(
const FunctionDecl *D) {
6160 if (Chain && Chain->isProcessingUpdateRecords())
return;
6161 assert(!WritingAST &&
"Already writing the AST!");
6168 void ASTWriter::StaticDataMemberInstantiated(
const VarDecl *D) {
6169 if (Chain && Chain->isProcessingUpdateRecords())
return;
6170 assert(!WritingAST &&
"Already writing the AST!");
6176 DeclUpdates[D].push_back(
6181 void ASTWriter::DefaultArgumentInstantiated(
const ParmVarDecl *D) {
6182 if (Chain && Chain->isProcessingUpdateRecords())
return;
6183 assert(!WritingAST &&
"Already writing the AST!");
6187 DeclUpdates[D].push_back(
6191 void ASTWriter::DefaultMemberInitializerInstantiated(
const FieldDecl *D) {
6192 assert(!WritingAST &&
"Already writing the AST!");
6196 DeclUpdates[D].push_back(
6202 if (Chain && Chain->isProcessingUpdateRecords())
return;
6203 assert(!WritingAST &&
"Already writing the AST!");
6207 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
6208 ObjCClassesWithCategories.insert(
6212 void ASTWriter::DeclarationMarkedUsed(
const Decl *D) {
6213 if (Chain && Chain->isProcessingUpdateRecords())
return;
6214 assert(!WritingAST &&
"Already writing the AST!");
6226 void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(
const Decl *D) {
6227 if (Chain && Chain->isProcessingUpdateRecords())
return;
6228 assert(!WritingAST &&
"Already writing the AST!");
6235 void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
6237 if (Chain && Chain->isProcessingUpdateRecords())
return;
6238 assert(!WritingAST &&
"Already writing the AST!");
6242 DeclUpdates[D].push_back(
6246 void ASTWriter::RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M) {
6247 if (Chain && Chain->isProcessingUpdateRecords())
return;
6248 assert(!WritingAST &&
"Already writing the AST!");
6249 assert(D->
isHidden() &&
"expected a hidden declaration");
6253 void ASTWriter::AddedAttributeToRecord(
const Attr *Attr,
6255 if (Chain && Chain->isProcessingUpdateRecords())
return;
6256 assert(!WritingAST &&
"Already writing the AST!");
6262 void ASTWriter::AddedCXXTemplateSpecialization(
6264 assert(!WritingAST &&
"Already writing the AST!");
6268 if (Chain && Chain->isProcessingUpdateRecords())
6271 DeclsToEmitEvenIfUnreferenced.push_back(D);
6274 void ASTWriter::AddedCXXTemplateSpecialization(
6276 assert(!WritingAST &&
"Already writing the AST!");
6280 if (Chain && Chain->isProcessingUpdateRecords())
6283 DeclsToEmitEvenIfUnreferenced.push_back(D);
6288 assert(!WritingAST &&
"Already writing the AST!");
6292 if (Chain && Chain->isProcessingUpdateRecords())
6295 DeclsToEmitEvenIfUnreferenced.push_back(D);
A CXXConstCastExpr record.
bool hasLineDirectives() const
Return true if this FileID has #line directives in it.
unsigned getNumElements() const
TypeSourceInfo * getUnderlyingTInfo() const
SourceManager & getSourceManager() const
bool isPoisoned() const
Return true if this token has been poisoned.
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimize off". If this location is invalid...
A FriendTemplateDecl record.
Defines the clang::ASTContext interface.
A CompoundLiteralExpr record.
A NonTypeTemplateParmDecl record.
QualType getExceptionType(unsigned i) const
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
SourceLocation getEnd() const
const FileEntry * OrigEntry
Reference to the file entry representing this ContentCache.
Expr * getSizeExpr() const
QualType getUnderlyingType() const
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.
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
unsigned getAnonymousDeclarationNumber(const NamedDecl *D)
uint64_t getMacroDirectivesOffset(const IdentifierInfo *Name)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
std::string Name
The name of this module.
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.
IdentifierInfo * getIdentifier() const
A UserDefinedLiteral record.
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.
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
SourceLocation getElaboratedKeywordLoc() const
ExtParameterInfo getExtParameterInfo(unsigned I) const
unsigned getDepth() const
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.
PointerType - C99 6.7.5.1 - Pointer Declarators.
bool hasFETokenInfoChangedSinceDeserialization() const
Determine whether the frontend token information for this identifier has changed since it was loaded ...
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
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)
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
TemplateName getReplacement() const
bool isBaseOfClass() const
Determine whether this base class is a base of a class declared with the 'class' keyword (vs...
The macro directives history for a particular identifier.
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
Represents a version number in the form major[.minor[.subminor[.build]]].
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
Implements support for file system lookup, file system caching, and directory search management...
SourceLocation getNameLoc() const
void AddToken(const Token &Tok, RecordDataImpl &Record)
Emit a token.
unsigned local_sloc_entry_size() const
Get the number of local SLocEntries we have.
LateParsedTemplateMapT LateParsedTemplateMap
FunctionDecl * getExceptionSpecDecl() const
If this function type has an exception specification which hasn't been determined yet (either because...
OpenCL supported extensions and optional core features.
A CXXStaticCastExpr record.
Defines the clang::FileManager interface and associated types.
Record code for the source manager line table information, which stores information about #line direc...
An AttributedStmt record.
A CXXReinterpretCastExpr record.
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
An OMPThreadPrivateDecl record.
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()
unsigned getHash() const
Compute a fingerprint of this key for use in on-disk hash table.
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
SourceLocation getLAngleLoc() const
unsigned getNumArgs() const
Retrieve the number of template arguments.
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "...
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
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.
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
static bool isImportedDeclContext(ASTReader *Chain, const Decl *D)
const LangOptions & getLangOpts() 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...
for(unsigned I=0, E=TL.getNumArgs();I!=E;++I)
CXXRecordDecl * getDecl() const
RawCommentList Comments
All comments in this translation unit.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
An ImplicitValueInitExpr record.
unsigned getNextLocalOffset() const
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.
Decl - This represents one declaration (or definition), e.g.
An ImplicitCastExpr record.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
A VarTemplatePartialSpecializationDecl record.
bool isObjectLike() const
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
unsigned IsFramework
Whether this is a framework module.
bool hasCommaPasting() const
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...
unsigned getODRHash() const
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.
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
Optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
Specifies the submodules that are imported by this submodule.
A record that stores the set of declarations that are lexically stored within a given DeclContext...
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
QualType getPointeeType() const
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
Specifies an umbrella directory.
A CXXTemporaryObjectExpr record.
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate > > LateParsedTemplateMapT
SourceLocation getLocalRangeBegin() const
Each ExpansionInfo encodes the expansion location - where the token was ultimately expanded...
const ExpansionInfo & getExpansion() const
unsigned getLength() const
Efficiently return the length of this identifier info.
A SubstTemplateTypeParmType record.
QualType getRecordType(const RecordDecl *Decl) const
std::unique_ptr< llvm::MemoryBuffer > Buffer
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.
TemplateTemplateParmDecl * getParameterPack() const
Retrieve the template template parameter pack being substituted.
const Expr * getInit() const
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamespaceDecl - Represent a C++ namespace.
A ObjCPropertyDecl record.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
StoredDeclsMap * getLookupPtr() const
Retrieve the internal representation of the lookup structure.
Wrapper for source info for typedefs.
bool hasBaseTypeAsWritten() const
serialization::DeclID GetDeclRef(const Decl *D)
Force a declaration to be emitted and get its ID.
A container of type source information.
unsigned getIndex() const
Record code for enabled OpenCL extensions.
Record code for the module build directory.
Floating point control options.
void * getAsOpaquePtr() const
void AddTypeRef(QualType T, RecordDataImpl &Record)
Emit a reference to a type.
An ElaboratedType record.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
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)
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
Wrapper for source info for pointers decayed from arrays and functions.
bool hasAttrEnumOperand() const
Describes the capture of a variable or of this, or of a C++1y init-capture.
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
bool isSpelledAsLValue() 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.
unsigned getInt() const
Used to serialize this.
const llvm::APInt & getSize() const
A ClassTemplateDecl record.
SourceLocation getIncludeLoc() const
unsigned NumPreprocessedEntities
A PragmaDetectMismatchDecl record.
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
An UnresolvedUsingTypenameDecl record.
unsigned getCounterValue() const
An identifier, stored as an IdentifierInfo*.
The internal '__builtin_va_list' typedef.
The stack of open #ifs/#ifdefs recorded in a preamble.
static uint64_t EmitCXXBaseSpecifiers(ASTWriter &W, ArrayRef< CXXBaseSpecifier > Bases)
Manages the set of modules loaded by an AST reader.
serialization::MacroID getMacroRef(MacroInfo *MI, const IdentifierInfo *Name)
Get the unique number used to refer to the given macro.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Record code for #pragma pack options.
A block with unhashed content.
Wrapper for source info for member pointers.
An OMPCapturedExprDecl record.
Options for controlling the target.
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
Manage memory buffers across multiple users.
bool hasAttrExprOperand() const
Record code for declarations associated with OpenCL extensions.
A UsingShadowDecl record.
SourceLocation getDefinitionLoc() const
Return the location that the macro was defined at.
Represents an empty template argument, e.g., one that has not been deduced.
AutoTypeKeyword getKeyword() const
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.
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.
QualType getucontext_tType() const
Retrieve the C ucontext_t type.
Represents a variable template specialization, which refers to a variable template with a given set o...
The value of the next COUNTER to dispense.
A ConditionOperator record.
const DeclContext * getDefinitiveDeclContext(const DeclContext *DC)
Retrieve the "definitive" declaration that provides all of the visible entries for the given declarat...
TemplateTypeParmDecl * getDecl() const
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack...
Specifies the umbrella header used to create this module, if any.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
A namespace, stored as a NamespaceDecl*.
QualType getOriginalType() const
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.
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)
bool hasAttrOperand() const
A TemplateTemplateParmDecl record.
Record code for the array of eagerly deserialized decls.
TemplateTemplateParmDecl * getParameter() const
ParmVarDecl - Represents a parameter to a function.
Represents the result of substituting a type for a template type parameter.
OpenCLOptions & getOpenCLOptions()
Defines the clang::Expr interface and subclasses for C++ expressions.
unsigned getNumArgs() const
Retrieve the number of template arguments.
FPOptions & getFPOptions()
A ObjCInterfaceDecl record.
QualType getRawCFConstantStringType() const
Get the structure type used to representation CFStrings, or NULL if it hasn't yet been built...
SourceLocation getAmpAmpLoc() const
void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record)
Emit a reference to an identifier.
The collection of all-type qualifiers we support.
A ShuffleVectorExpr record.
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
ModuleKind Kind
The kind of this module.
void AddTypeSourceInfo(TypeSourceInfo *TInfo)
Emits a reference to a declarator info.
known_categories_iterator known_categories_begin() const
Retrieve an iterator to the beginning of the known-categories list.
Base wrapper for a particular "section" of type source info.
A CXXConstructorDecl record for an inherited constructor.
unsigned getNumParams() const
RecordDecl - Represents a struct/union/class.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
SourceRange getLocalSourceRange() const
Retrieve the source range covering just the last part of this nested-name-specifier, not including the prefix.
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
QualType getElementType() const
DeclarationName getName() const
getName - Returns the embedded declaration name.
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.
unsigned getIndexTypeCVRQualifiers() const
A macro directive exported by a module.
An ObjCAtThrowStmt record.
time_t getTimestampForOutput(const FileEntry *E) const
Get a timestamp for output into the AST file.
Specifies a top-level header that falls into this (sub)module.
The block containing comments.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
void AddTypeRef(QualType T)
Emit a reference to a type.
A DesignatedInitExpr record.
The Objective-C 'SEL' type.
Represents a class type in Objective C.
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
Iteration over the preprocessed entities.
Expr * getSizeExpr() const
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
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.
unsigned getNumArgs() const
bool isIdentifier() const
Determine whether this template name refers to an identifier.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
An ObjCProtocolExpr record.
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.
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
SourceLocation getLocalRangeEnd() const
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis for a capture that is a pack expansion.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
SourceLocation getTypeArgsRAngleLoc() const
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.
Delete expressions that will be analyzed later.
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
ParmVarDecl * getParam(unsigned i) const
bool isTranslationUnit() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
unsigned getNumProtocols() const
The iterator over UnresolvedSets.
const LangOptions & getLangOpts() const
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.
static unsigned CreateSLocExpansionAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a macro expansion.
unsigned getNumProtocols() const
Wrapper for source info for unresolved typename using decls.
bool makeAbsolutePath(SmallVectorImpl< char > &Path) const
Makes Path absolute taking into account FileSystemOptions and the working directory option...
SourceLocation getBuiltinLoc() const
An AttributedType record.
unsigned getAsOpaqueValue() const
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...
unsigned getRegParm() const
void AddTemplateParameterList(const TemplateParameterList *TemplateParams)
Emit a template parameter list.
Describes a module or submodule.
QualType getUnderlyingType() const
Expr * getUnderlyingExpr() const
A IndirectFieldDecl record.
EnumDecl * getStdAlignValT() const
FileManager & getFileManager() const
Record code for the set of ext_vector type names.
iterator end()
end - Returns an iterator that has 'finished'.
void VisitTagType(const TagType *T)
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.
Specifies the submodules that are re-exported from this submodule.
TemplateParameterList ** TemplParamLists
TemplParamLists - A new-allocated array of size NumTemplParamLists, containing pointers to the "outer...
serialization::MacroID BaseMacroID
Base macro ID for macros local to this module.
TemplateArgument getArgumentPack() const
An rvalue reference type, per C++11 [dcl.ref].
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
SourceLocation getLAngleLoc() const
SmallVector< uint64_t, 64 > RecordData
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...
const TargetInfo & getTargetInfo() const
const LangOptions & getLangOpts() const
bool isAvailable() const
Determine whether this module is available for use within the current translation unit...
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...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
< Capturing the *this object by copy
An AccessSpecDecl record.
SourceLocation getRAngleLoc() const
Describes a blob that contains the data for a buffer entry.
QualType getBaseType() const
Gets the base type of this object type.
Record code for the language options table.
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
QualType getReturnType() const
Wrapper for source info for functions.
ArrayRef< KnownHeader > findAllModulesForHeader(const FileEntry *File) const
Retrieve all the modules that contain the given header file.
Specifies a conflict with another module.
The signed 128-bit integer type.
StoredDeclsMap * buildLookup()
Ensure the lookup structure is fully-built and return it.
bool isUsedForHeaderGuard() const
Determine whether this macro was used for a header guard.
SourceLocation getEllipsisLoc() const
For a pack expansion, determine the location of the ellipsis.
A UnaryTransformType record.
UnresolvedUsingTypenameDecl * getDecl() const
A reference to a previously [de]serialized Stmt record.
NestedNameSpecifierLoc getQualifierLoc() const
A UsingDirecitveDecl record.
An ObjCObjectType record.
A ConstantArrayType record.
TemplateArgument getArgumentPack() const
Retrieve the template template argument pack with which this parameter was substituted.
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".
HeaderSearch & getHeaderSearchInfo() const
void AddSourceRange(SourceRange Range, RecordDataImpl &Record)
Emit a source range.
Specifies a header that is private to this submodule but must be textually included.
Expr * getNoexceptExpr() const
TypeSourceInfo * getClassTInfo() const
bool isInitKnownICE() const
Determines whether it is already known whether the initializer is an integral constant expression or ...
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)
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
void AddCXXCtorInitializers(ArrayRef< CXXCtorInitializer * > CtorInits)
Emit a CXXCtorInitializer array.
bool needsExtraLocalData() const
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
Module * Parent
The parent of this module.
Record code for floating point #pragma options.
void AddTypeLoc(TypeLoc TL)
Emits a type with source-location information.
SourceLocation getProtocolRAngleLoc() const
StringRef getName() const
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
TemplateDecl * getTemplateDecl() const
The template declaration to which this qualified name refers.
SourceLocation getRParenLoc() const
Wrapper for source info for ObjC interfaces.
Record code for the set of known namespaces, which are used for typo correction.
void AddAttributes(ArrayRef< const Attr * > Attrs)
Emit a list of attributes.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location...
TypeID MakeTypeID(ASTContext &Context, QualType T, IdxForTypeTy IdxForType)
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.
QualType getsigjmp_bufType() const
Retrieve the C sigjmp_buf type.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
std::vector< std::string > Warnings
The list of -W...
TypeClass getTypeClass() const
VarDecl * getCapturedVar() const
Retrieve the declaration of the local variable being captured.
A marker record that indicates that we are at the end of an expression.
A ClassTemplateSpecializationDecl record.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
tok::TokenKind getKind() const
A BlockPointerType record.
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
unsigned getNumParams() const
A MemberPointerType record.
Represents an ObjC class declaration.
SourceLocation getTypeofLoc() const
detail::InMemoryDirectory::const_iterator I
SourceLocation getTypeArgsLAngleLoc() const
unsigned getNumParams() const
serialization::TypeID getTypeID(QualType T) const
Determine the type ID of an already-emitted type.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
A DependentSizedExtVectorType record.
QualType getCanonicalTypeInternal() const
Record code for the table of offsets into the block of source-location information.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Represents an extended vector type where either the type or size is dependent.
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
A SubstTemplateTypeParmPackType record.
TypeCode
Record codes for each kind of type.
DiagnosticsEngine & getDiagnostics() const
Iterator that walks over the list of categories, filtering out those that do not meet specific criter...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
unsigned getObjCOrBuiltinID() const
IdentifierInfo * getAlias() const
SourceLocation getKWLoc() 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.
bool isCPlusPlusOperatorKeyword() const
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
A VariableArrayType record.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce...
QualType getInjectedSpecializationType() const
ExtInfo getExtInfo() 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.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
unsigned NumTemplParamLists
NumTemplParamLists - The number of "outer" template parameter lists.
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
void resolveHeaderDirectives(const FileEntry *File) const
Resolve all lazy header directives for the specified file.
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Defines the major attributes of a submodule, including its name and parent.
const llvm::MapVector< FieldDecl *, DeleteLocs > & getMismatchingDeleteExpressions() const
Retrieves list of suspicious delete-expressions that will be checked at the end of translation unit...
void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc, DeclarationName Name)
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
void AddCXXTemporary(const CXXTemporary *Temp)
Emit a CXXTemporary.
ModuleHeaderRole
Flags describing the role of a module header.
SourceLocation getAttrEnumOperandLoc() const
The modified type, which is generally canonically different from the attribute type.
llvm::SmallSetVector< Module *, 2 > Imports
The set of modules imported by this module, and on which this module depends.
A dependent template name that has not been resolved to a template (or set of templates).
DeclarationNameTable DeclarationNames
SourceLocation getLBracketLoc() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
unsigned LocalNumSLocEntries
The number of source location entries in this AST file.
A StaticAssertDecl record.
Captures information about a #pragma weak directive.
void AddPath(StringRef Path, RecordDataImpl &Record)
Add a path to the given record.
bool getNoCallerSavedRegs() const
A VarTemplateSpecializationDecl record.
Record code for the table of offsets of each macro ID.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
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.
bool isRecordingPreamble() const
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.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
SourceLocation getElaboratedKeywordLoc() const
bool isImplicit() const
Determine whether this was an implicit capture (not written between the square brackets introducing t...
Specifies some declarations with initializers that must be emitted to initialize the module...
An ObjCObjectPointerType record.
An TemplateSpecializationType record.
Type source information for an attributed type.
An ObjCInterfaceType record.
SourceLocation getRBracketLoc() const
QualType getPointeeType() const
Describes a zlib-compressed blob that contains the data for a buffer entry.
Expr - This represents one expression.
A ObjCCategoryImplDecl record.
Defines the clang::LangOptions interface.
StringRef getName() const
Return the actual identifier string.
Record code for the array of VTable uses.
static bool isInterestingIdentifier(ASTReader &Reader, IdentifierInfo &II, bool IsModule)
Whether the given identifier is "interesting".
bool isLookupContext() const
Test whether the context supports looking up names.
The directory that the PCH was originally created in.
unsigned getNumArgs() const
A ObjCPropertyImplDecl record.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
TypeSpecifierWidth getWrittenWidthSpec() 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.
Implements an efficient mapping from strings to IdentifierInfo nodes.
bool hasLineTable() const
Determine if the source manager has a line table.
Defines implementation details of the clang::SourceManager class.
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
FileManager & getFileManager() const
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.
TranslationUnitDecl * getTranslationUnitDecl() 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.
Expr * getUnderlyingExpr() const
Defines the clang::Preprocessor interface.
ArgKind
The kind of template argument we're storing.
const SrcMgr::SLocEntry & getLocalSLocEntry(unsigned Index, bool *Invalid=nullptr) const
Get a local SLocEntry. This is exposed for indexing.
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.
AccessSpecifier getAccessSpecifierAsWritten() const
Retrieves the access specifier as written in the source code (which may mean that no access specifier...
QualType getNamedType() const
Retrieve the type named by the qualified-id.
ArgKind getKind() const
Return the kind of stored template argument.
llvm::MapVector< IdentifierInfo *, WeakInfo > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
Record code for #pragma diagnostic mappings.
serialization::TypeID GetOrCreateTypeID(QualType T)
Force a type to be emitted and get its ID.
SourceLocation getLParenLoc() const
DeclContext * getDeclContext()
SourceLocation getLocation() const
Retrieve the source location of the capture.
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...
unsigned LocalNumMacros
The number of macros in this AST file.
A CXXStdInitializerListExpr record.
A record containing CXXCtorInitializers.
ArrayRef< const FileEntry * > getTopHeaders(FileManager &FileMgr)
The top-level headers associated with this module.
A VarTemplateDecl record.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
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::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.
A namespace alias, stored as a NamespaceAliasDecl*.
SourceRange getExceptionSpecRange() const
void AddString(StringRef Str, RecordDataImpl &Record)
Add a string to the given record.
Record code for the diagnostic options table.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
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...
SourceLocation getTemplateNameLoc() const
QualType getType() const
Get the type for which this source info wrapper provides information.
QualType getFILEType() const
Retrieve the C FILE type.
SourceLocation getAttributeLoc() const
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.
Wrapper for source info for enum types.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
A block containing a module file extension.
unsigned getNumTokens() const
Return the number of tokens that this macro expands to.
bool hasTrailingReturn() const
std::string FileName
The file name of the module file.
A NamespaceAliasDecl record.
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.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Record code for an update to a decl context's lookup table.
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
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.
Record code for #pragma ms_struct options.
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
const unsigned VERSION_MINOR
AST file minor version number supported by this version of Clang.
SourceLocation getModuleImportLoc(Module *M) const
void AddQualifierInfo(const QualifierInfo &Info)
unsigned Map[FirstTargetAddressSpace]
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
A DesignatedInitUpdateExpr record.
void AddStmt(Stmt *S)
Add the given statement or expression to the queue of statements to emit.
void AddSelectorRef(Selector S)
Emit a Selector (which is a smart pointer reference).
Represents a GCC generic vector type.
struct CXXOpName CXXOperatorName
An lvalue reference type, per C++11 [dcl.ref].
CXXRecordDecl * getStdBadAlloc() const
An ImplicitParamDecl record.
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
QualType getElementType() 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.
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. ...
An ImportDecl recording a module import.
A ObjCCategoryDecl record.
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
An ObjCPropertyRefExpr record.
SourceLocation getRAngleLoc() const
bool isC99Varargs() const
LambdaCaptureKind getCaptureKind() const
Determine the kind of capture.
An ObjCForCollectionStmt record.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Record code for the identifier table.
A FileScopeAsmDecl record.
A ObjCCompatibleAliasDecl record.
SourceLocation getProtocolRAngleLoc() const
SmallVector< ExportDecl, 2 > Exports
The set of export declarations.
SourceRange getBracketsRange() const
DelegatingCtorDeclsType DelegatingCtorDecls
All the delegating constructors seen so far in the file, used for cycle detection at the end of the T...
A MS-style AsmStmt record.
ArrayRef< const IdentifierInfo * > params() const
const DirectoryEntry * Directory
The build directory of this module.
void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record)
Emit a source location.
unsigned getLocalFastQualifiers() const
void push_back(uint64_t N)
Minimal vector-like interface.
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
The Objective-C 'Class' type.
SpecifierKind
The kind of specifier that completes this nested name specifier.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const IdentifierInfo * getIdentifier() const
TemplateArgumentLoc getArgLoc(unsigned i) const
A template template parameter pack that has been substituted for a template template argument pack...
Wrapper for source info for arrays.
Record code for the set of source location entries that need to be preloaded by the AST reader...
QualifierInfo - A struct with extended info about a syntactic name qualifier, to be used for the case...
TemplateArgumentLoc getArgLoc(unsigned i) const
Information about a FileID, basically just the logical file that it represents and include stack info...
The list of delegating constructor declarations.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Record code for types associated with OpenCL extensions.
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...
SourceLocation getTemplateKeywordLoc() const
SourceLocation getRParenLoc() const
An UnresolvedUsingValueDecl record.
serialization::TypeID BaseTypeIndex
Base type ID for types local to this module as represented in the global type ID space.
bool hasRevertedBuiltin() const
True if setNotBuiltin() was called.
bool hasChangedSinceDeserialization() const
Determine whether this identifier has changed since it was loaded from an AST file.
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.
static uint64_t EmitCXXCtorInitializers(ASTWriter &W, ArrayRef< CXXCtorInitializer * > CtorInits)
Encodes a location in the source.
Sugar for parentheses used when specifying types.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
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.
QualType getElementType() 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.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
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.
A structure for storing an already-substituted template template parameter pack.
Record code for special CUDA declarations.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
Options for controlling the compiler diagnostics engine.
A list of "interesting" identifiers.
SourceLocation getLParenLoc() const
The block of configuration options, used to check that a module is being used in a configuration comp...
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
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...
TagDecl - Represents the declaration of a struct/union/class/enum.
ASTContext & getASTContext() const LLVM_READONLY
unsigned getOffset() const
bool isPackExpansion() const
Determine whether this base specifier is a pack expansion.
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()
VectorKind getVectorKind() const
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.
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.
SourceLocation getNameLoc() const
Metadata for submodules as a whole.
SourceLocation getDefinitionEndLoc() const
Return the location of the last token in the macro.
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.
Defines the clang::TargetOptions class.
A TemplateTypeParmDecl record.
An ImaginaryLiteral record.
unsigned LocalNumDecls
The number of declarations in this AST file.
ObjCCategoryDecl - Represents a category declaration.
unsigned getMajor() const
Retrieve the major version number.
The internal 'instancetype' typedef.
unsigned getNumTypeArgs() const
FunctionDecl * getExceptionSpecTemplate() const
If this function type has an uninstantiated exception specification, this is the function whose excep...
SourceLocation getRParenLoc() const
void AddNestedNameSpecifier(NestedNameSpecifier *NNS)
Emit a nested name specifier.
Describes the categories of an Objective-C class.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
uint32_t MacroID
An ID number that refers to a macro in an AST file.
const FileInfo & getFile() const
The AST block, which acts as a container around the full AST block.
A DeducedTemplateSpecializationType record.
TypedefNameDecl * getDecl() const
TypeSpecifierType getWrittenTypeSpec() const
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
const unsigned int DECL_UPDATES
Record of updates for a declaration that was modified after being deserialized.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
SourceLocation getBegin() const
void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record)
Add a version tuple to the given record.
void updateOutOfDateSelector(Selector Sel)
ModuleFileExtension * getExtension() const
Retrieve the module file extension with which this writer is associated.
void AddSourceLocation(SourceLocation Loc)
Emit a source location.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
const Token & getReplacementToken(unsigned Tok) 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.
FileID getMainFileID() const
Returns the FileID of the main source file.
bool getInheritConstructors() const
Determine whether this base class's constructors get inherited.
bool isFileContext() const
Record code for the extra statistics we gather while generating an AST file.
FunctionDecl * getcudaConfigureCallDecl()
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
SourceLocation getKWLoc() 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.
bool PreparePathForOutput(SmallVectorImpl< char > &Path)
Convert a path from this build process into one that is appropriate for emission in the module file...
SourceLocation getTemplateNameLoc() const
unsigned LocalNumSubmodules
The number of submodules in this module.
unsigned ComputeHash(Selector Sel)
DiagnosticsEngine & getDiagnostics() const
SourceLocation getProtocolLAngleLoc() const
Record code for the signature that identifiers this AST file.
ObjCTypeParamDecl * getDecl() const
Record code for referenced selector pool.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
bool isLocalSourceLocation(SourceLocation Loc) const
Returns true if Loc did not come from a PCH/Module.
SourceLocation getNameLoc() const
Represents a pointer type decayed from an array or function type.
FileID getPredefinesFileID() const
Returns the FileID for the preprocessor predefines.
void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
The injected class name of a C++ class template or class template partial specialization.
QualType getPointeeType() const
Record code for the set of non-builtin, special types.
A ObjCProtocolDecl record.
Represents a pack expansion of types.
SmallVectorImpl< uint64_t > RecordDataImpl
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
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.
static void addExceptionSpec(const FunctionProtoType *T, ASTRecordWriter &Record)
Expr * getSizeExpr() const
unsigned getFlags() const
Return the internal represtation of the flags.
SourceLocation getLocation() const
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.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
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...
QualType getAsType() const
Retrieve the type for a type template argument.
Represents a template name that was expressed as a qualified name.
The internal '__NSConstantString' typedef.
Record code for the module name.
Selector getObjCSelector() const
getObjCSelector - Get the Objective-C selector stored in this declaration name.
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.
bool hasTemplateKeyword() const
Whether the template name was prefixed by the "template" keyword.
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...
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).
Specifies a configuration macro for this module.
virtual ModuleFileExtensionMetadata getExtensionMetadata() const =0
Retrieves the metadata for this module file extension.
SourceLocation getEllipsisLoc() const
bool hasLocalNonFastQualifiers() const
Determine whether this particular QualType instance has any "non-fast" qualifiers, e.g., those that are stored in an ExtQualType instance.
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.
llvm::iterator_range< submodule_iterator > submodules()
A FunctionNoProtoType record.
Reads an AST files chain containing the contents of a translation unit.
bool getProducesResult() const
QualType getEquivalentType() const
A ClassTemplatePartialSpecializationDecl record.
An ObjCIvarRefExpr record.
SourceLocation getStarLoc() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
bool hasRecordedPreamble() const
SourceLocation getTemplateKeywordLoc() const
bool isGNUVarargs() const
bool isParameterPack() const
StringRef getName() const
const ContentCache * getContentCache() const
DeclarationName - The name of a declaration.
A ClassScopeFunctionSpecializationDecl record a class scope function specialization.
Record code for the Objective-C method pool,.
const MacroInfo * getMacroInfo() const
static unsigned CreateSLocBufferAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a buffer.
A CharacterLiteral record.
CallingConv getCC() const
SourceLocation getCaretLoc() const
Specifies a header that is private to this submodule.
Expr * getSizeExpr() const
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 ('<').
detail::InMemoryDirectory::const_iterator E
SourceLocation getElaboratedKeywordLoc() const
A pointer to member type per C++ 8.3.3 - Pointers to members.
unsigned getNumProtocols() const
Return the number of qualifying protocols in this type, or 0 if there are none.
QualType getModifiedType() const
PreprocessingRecord * getPreprocessingRecord() const
Retrieve the preprocessing record, or NULL if there is no preprocessing record.
IdentifierResolver IdResolver
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
SourceLocation getExpansionLocStart() const
An RValueReferenceType record.
A type that was preceded by the 'template' keyword, stored as a Type*.
unsigned char getOpaqueValue() const
bool isExtensionToken() const
get/setExtension - Initialize information about whether or not this language token is an extension...
An ObjCAtFinallyStmt record.
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...
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Represents a pointer to an Objective C object.
Number of unmatched #pragma clang cuda_force_host_device begin directives we've seen.
Encapsulates the data about a macro definition (e.g.
Capturing variable-length array type.
bool isMacroArgExpansion() const
A PragmaCommentDecl record.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
time_t getModificationTime() const
struct CXXLitOpName CXXLiteralOperatorName
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
TypeSpecifierSign getWrittenSignSpec() const
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
std::vector< Conflict > Conflicts
The list of conflicts.
Record code for the table of offsets into the Objective-C method pool.
unsigned getTypeQuals() const
Selector getSelector() const
Defines the clang::FileSystemOptions interface.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
A DependentSizedArrayType record.
Record code for the remapping information used to relate loaded modules to the various offsets and ID...
An ObjCAtSynchronizedStmt record.
A key used when looking up entities by DeclarationName.
MacroDirective * getLocalMacroDirectiveHistory(const IdentifierInfo *II) const
Given an identifier, return the latest non-imported macro directive for that identifier.
An UnresolvedSet-like class which uses the ASTContext's allocator.
unsigned getNumArgs() const
Record code for declarations that Sema keeps references of.
QualType getIntegralType() const
Retrieve the type of the integral value.
A SizefAlignOfExpr record.
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
Offsets into the input-files block where input files reside.
A CXXMemberCallExpr record.
ExtVectorType - Extended vector type.
QualType getInnerType() const
void AddAPSInt(const llvm::APSInt &Value)
Emit a signed integral value.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
const DeclarationNameLoc & getInfo() const
bool isBuiltinMacro() const
Return true if this macro requires processing before expansion.
The block containing the submodule structure.
Wrapper for source info for record types.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
TypeSourceInfo * getTypeSourceInfo() const
Retrieves the type and source location of the base class.
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
The template argument is a type.
Wraps an ObjCPointerType with source location information.
import_range local_imports() const
Optional< unsigned > getSubminor() const
Retrieve the subminor version number, if provided.
NestedNameSpecifier * getQualifier() const
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.
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.
unsigned BufferOverridden
Indicates whether the buffer itself was provided to override the actual file contents.
SourceLocation getProtocolLAngleLoc() const
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
SourceManager & getSourceManager()
Keeps track of options that affect how file operations are performed.
NestedNameSpecifierLoc getQualifierLoc() const
A template argument list.
TemplateArgumentLocInfo getLocInfo() const
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
const Type * getClass() const
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
NestedNameSpecifierLoc QualifierLoc
PreprocessorOptions & getPreprocessorOpts() const
Retrieve the preprocessor options used to initialize this preprocessor.
An attributed type is a type to which a type attribute has been applied.
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Represents a type parameter type in Objective C.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
SourceLocation getProtocolLoc(unsigned i) const
unsigned pack_size() const
The number of template arguments in the given template argument pack.
known_categories_iterator known_categories_end() const
Retrieve an iterator to the end of the known-categories list.
bool isPackExpansion() const
Determine whether this capture is a pack expansion, which captures a function parameter pack...
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. ...
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
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.
Record code for the filesystem options table.
SourceLocation getTemplateNameLoc() const
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.
A ObjCImplementationDecl record.
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
ArraySizeModifier getSizeModifier() const
ElaboratedTypeKeyword getKeyword() const
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.
SourceLocation getRParenLoc() const
Location information for a TemplateArgument.
A ObjCAtDefsFieldDecl record.
Declaration of a class template.
Record code for the offsets of each type.
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.
SourceLocation getLBracketLoc() const
serialization::DeclID getDeclID(const Decl *D)
Determine the declaration ID of an already-emitted declaration.
QualType getAdjustedType() const
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.
void AddAPInt(const llvm::APInt &Value)
Emit an integral value.
LineTableInfo & getLineTable()
Retrieve the stored line table.
QualType getParamTypeForDecl() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
Defines the clang::TargetInfo interface.
MacroDefinitionRecord * findMacroDefinition(const MacroInfo *MI)
Retrieve the macro definition that corresponds to the given MacroInfo.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Defines the clang::VersionTuple class, which represents a version in the form major[.minor[.subminor]].
ArrayRef< ModuleMacro * > getLeafModuleMacros(const IdentifierInfo *II) const
Get the list of leaf (non-overridden) module macros for a name.
a linked list of methods with the same selector name but different signatures.
Specifies a required feature.
bool hasExternalDecls() const
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
SourceLocation getProtocolLoc(unsigned i) const
QualType getPointeeTypeAsWritten() const
std::vector< std::string > ConfigMacros
The set of "configuration macros", which are macros that (intentionally) change how this module is bu...
bool getHasRegParm() const
uint32_t getIndex() const
An ObjCMessageExpr record.
TagDecl * getDecl() const
SourceLocation getRBracketLoc() const
Record for offsets of DECL_UPDATES records for declarations that were modified after being deserializ...
TranslationUnitDecl - The top declaration context.
A CompoundAssignOperator record.
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs)
Emit a template argument list.
Represents a type template specialization; the template must be a class template, a type alias templa...
QualType getjmp_bufType() const
Retrieve the C jmp_buf type.
SourceLocation getRAngleLoc() const
static unsigned CreateSLocBufferBlobAbbrev(llvm::BitstreamWriter &Stream, bool Compressed)
Create an abbreviation for the SLocEntry that refers to a buffer's blob.
unsigned getLength() const
QualType getElementType() const
QualType getElementType() const
SourceLocation getStarLoc() const
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
A FunctionTemplateDecl record.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
llvm::DenseMap< CXXRecordDecl *, bool > VTablesUsed
The set of classes whose vtables have been used within this translation unit, and a bit that will be ...
llvm::MemoryBuffer * getBuffer(DiagnosticsEngine &Diag, const SourceManager &SM, SourceLocation Loc=SourceLocation(), bool *Invalid=nullptr) const
Returns the memory buffer for the associated content.
A TypeAliasTemplateDecl record.
Contains a late templated function.
OverloadedOperatorKind getOperatorKind() const
Record code for weak undeclared identifiers.
The block containing information about the preprocessor.
void AddTemplateName(TemplateName Name)
Emit a template name.
PragmaStack< unsigned > PackStack
SourceLocation getAmpLoc() const
SourceLocation getLAngleLoc() const
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg)
Emits a template argument location.
ArrayRef< PPConditionalInfo > getPreambleConditionalStack() const
uint32_t TypeID
An ID number that refers to a type in an AST file.
unsigned getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
Wrapper for source info for builtin types.
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.
SourceLocation getLocation() const
NamedDecl - This represents a decl with a name.
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.
ObjCMethodList * getNext() const
unsigned IsExplicit
Whether this is an explicit submodule.
NestedNameSpecifierLoc getQualifierLoc() const
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.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
The internal '__NSConstantString' tag type.
A function-like macro definition.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
The Objective-C 'Protocol' type.
The global specifier '::'. There is no stored value.
T * getFETokenInfo() const
getFETokenInfo/setFETokenInfo - The language front-end is allowed to associate arbitrary metadata wit...
NamespaceDecl * getStdNamespace() const
The control block, which contains all of the information that needs to be validated prior to committi...
const TemplateArgument & getArgument() const
Wrapper for source info for pointers.
SmallVector< Slot, 2 > Stack
Wrapper for source info for block pointers.
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
This class handles loading and caching of source files into memory.
Represents the canonical version of C arrays with a specified constant size.
const CXXDestructorDecl * getDestructor() const
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.
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.
const MacroDirective * getPrevious() const
Get previous definition of the macro with the same name.
bool SawDateOrTime() const
Returns true if the preprocessor has seen a use of DATE or TIME in the file so far.
A PackExpansionType record.
A single template declaration.
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
SourceLocation getLocation() const
SourceLocation getStarLoc() const
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.
void GetUniqueIDMapping(SmallVectorImpl< const FileEntry * > &UIDToFiles) const
Produce an array mapping from the unique IDs assigned to each file to the corresponding FileEntry poi...
A DependentTemplateSpecializationType record.
bool isUsed() const
Return false if this macro is defined in the main file and has not yet been used. ...
SourceLocation getSpellingLoc() const
bool capturesVariable() const
Determine whether this capture handles a variable.
SourceLocation getLParenLoc() const
Record code for the array of tentative definitions.
unsigned getNumExceptions() const
SourceLocation getLParenLoc() const
iterator local_begin()
Begin iterator for local, non-loaded, preprocessed entities.
IdentifierInfo * getIdentifierInfo() const
SourceLocation getTemplateLoc() const