48 #include "llvm/ADT/APFloat.h"
49 #include "llvm/ADT/APInt.h"
50 #include "llvm/ADT/Hashing.h"
51 #include "llvm/ADT/StringExtras.h"
52 #include "llvm/Bitcode/BitstreamWriter.h"
53 #include "llvm/Support/Compression.h"
54 #include "llvm/Support/EndianStream.h"
55 #include "llvm/Support/FileSystem.h"
56 #include "llvm/Support/MemoryBuffer.h"
57 #include "llvm/Support/OnDiskHashTable.h"
58 #include "llvm/Support/Path.h"
59 #include "llvm/Support/Process.h"
65 using namespace clang;
66 using namespace clang::serialization;
68 template <
typename T,
typename Allocator>
69 static StringRef
bytes(
const std::vector<T, Allocator> &
v) {
70 if (v.empty())
return StringRef();
71 return StringRef(reinterpret_cast<const char*>(&v[0]),
72 sizeof(T) * v.size());
77 return StringRef(reinterpret_cast<const char*>(v.data()),
78 sizeof(T) * v.size());
97 : Writer(Writer), Record(Writer, Record), Code((
TypeCode)0), AbbrevToUse(0) { }
100 return Record.Emit(Code, AbbrevToUse);
109 AbbrevToUse = Writer.TypeExtQualAbbrev;
114 #define TYPE(Class, Base) \
115 case Type::Class: Visit##Class##Type(cast<Class##Type>(T)); break;
116 #define ABSTRACT_TYPE(Class, Base)
117 #include "clang/AST/TypeNodes.def"
124 void VisitTagType(
const TagType *T);
126 #define TYPE(Class, Base) void Visit##Class##Type(const Class##Type *T);
127 #define ABSTRACT_TYPE(Class, Base)
128 #include "clang/AST/TypeNodes.def"
132 void ASTTypeWriter::VisitBuiltinType(
const BuiltinType *T) {
133 llvm_unreachable(
"Built-in types are never serialized");
136 void ASTTypeWriter::VisitComplexType(
const ComplexType *T) {
141 void ASTTypeWriter::VisitPointerType(
const PointerType *T) {
146 void ASTTypeWriter::VisitDecayedType(
const DecayedType *T) {
151 void ASTTypeWriter::VisitAdjustedType(
const AdjustedType *T) {
204 void ASTTypeWriter::VisitVectorType(
const VectorType *T) {
211 void ASTTypeWriter::VisitExtVectorType(
const ExtVectorType *T) {
223 Record.push_back(C.
getCC());
231 VisitFunctionType(T);
253 VisitFunctionType(T);
279 Record.AddDeclRef(T->
getDecl());
283 void ASTTypeWriter::VisitTypedefType(
const TypedefType *T) {
284 Record.AddDeclRef(T->
getDecl());
290 void ASTTypeWriter::VisitTypeOfExprType(
const TypeOfExprType *T) {
295 void ASTTypeWriter::VisitTypeOfType(
const TypeOfType *T) {
300 void ASTTypeWriter::VisitDecltypeType(
const DecltypeType *T) {
313 void ASTTypeWriter::VisitAutoType(
const AutoType *T) {
325 "Cannot serialize in the middle of a type definition");
328 void ASTTypeWriter::VisitRecordType(
const RecordType *T) {
333 void ASTTypeWriter::VisitEnumType(
const EnumType *T) {
338 void ASTTypeWriter::VisitAttributedType(
const AttributedType *T) {
346 ASTTypeWriter::VisitSubstTemplateTypeParmType(
354 ASTTypeWriter::VisitSubstTemplateTypeParmPackType(
362 ASTTypeWriter::VisitTemplateSpecializationType(
364 Record.push_back(T->isDependentType());
365 Record.AddTemplateName(T->getTemplateName());
366 Record.push_back(T->getNumArgs());
367 for (
const auto &ArgI : *T)
368 Record.AddTemplateArgument(ArgI);
369 Record.AddTypeRef(T->isTypeAlias() ? T->getAliasedType()
370 : T->isCanonicalUnqualified()
372 : T->getCanonicalTypeInternal());
385 ASTTypeWriter::VisitDependentSizedExtVectorType(
388 llvm_unreachable(
"Cannot serialize dependent sized extended vector types");
396 Record.AddDeclRef(T->
getDecl());
411 ASTTypeWriter::VisitDependentTemplateSpecializationType(
413 Record.push_back(T->getKeyword());
414 Record.AddNestedNameSpecifier(T->getQualifier());
415 Record.AddIdentifierRef(T->getIdentifier());
416 Record.push_back(T->getNumArgs());
417 for (
const auto &
I : *T)
418 Record.AddTemplateArgument(
I);
425 Record.push_back(*NumExpansions + 1);
431 void ASTTypeWriter::VisitParenType(
const ParenType *T) {
436 void ASTTypeWriter::VisitElaboratedType(
const ElaboratedType *T) {
454 void ASTTypeWriter::VisitObjCObjectType(
const ObjCObjectType *T) {
458 Record.AddTypeRef(TypeArg);
460 for (
const auto *
I : T->
quals())
461 Record.AddDeclRef(
I);
473 ASTTypeWriter::VisitAtomicType(
const AtomicType *T) {
479 ASTTypeWriter::VisitPipeType(
const PipeType *T) {
493 #define ABSTRACT_TYPELOC(CLASS, PARENT)
494 #define TYPELOC(CLASS, PARENT) \
495 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
496 #include "clang/AST/TypeLocNodes.def"
532 Record.AddSourceLocation(TL.
getAmpLoc());
541 void TypeLocWriter::VisitArrayTypeLoc(
ArrayTypeLoc TL) {
549 VisitArrayTypeLoc(TL);
552 VisitArrayTypeLoc(TL);
555 VisitArrayTypeLoc(TL);
557 void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
559 VisitArrayTypeLoc(TL);
561 void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
576 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i)
580 VisitFunctionTypeLoc(TL);
583 VisitFunctionTypeLoc(TL);
606 Record.AddSourceLocation(TL.
getKWLoc());
611 void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
617 void TypeLocWriter::VisitEnumTypeLoc(
EnumTypeLoc TL) {
621 Record.AddSourceLocation(TL.getAttrNameLoc());
624 Record.AddSourceLocation(range.
getBegin());
625 Record.AddSourceLocation(range.
getEnd());
628 Expr *operand = TL.getAttrExprOperand();
629 Record.push_back(operand ? 1 : 0);
630 if (operand) Record.AddStmt(operand);
638 void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
642 void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
646 void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
652 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
656 void TypeLocWriter::VisitParenTypeLoc(
ParenTypeLoc TL) {
672 void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
705 Record.AddSourceLocation(TL.
getKWLoc());
709 void TypeLocWriter::VisitPipeTypeLoc(
PipeTypeLoc TL) {
710 Record.AddSourceLocation(TL.
getKWLoc());
713 void ASTWriter::WriteTypeAbbrevs() {
714 using namespace llvm;
719 Abv =
new BitCodeAbbrev();
721 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
722 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
723 TypeExtQualAbbrev = Stream.EmitAbbrev(Abv);
726 Abv =
new BitCodeAbbrev();
729 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
730 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
731 Abv->Add(BitCodeAbbrevOp(0));
732 Abv->Add(BitCodeAbbrevOp(0));
733 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
734 Abv->Add(BitCodeAbbrevOp(0));
736 Abv->Add(BitCodeAbbrevOp(0));
737 Abv->Add(BitCodeAbbrevOp(0));
738 Abv->Add(BitCodeAbbrevOp(0));
739 Abv->Add(BitCodeAbbrevOp(0));
740 Abv->Add(BitCodeAbbrevOp(
EST_None));
741 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
742 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
743 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
744 TypeFunctionProtoAbbrev = Stream.EmitAbbrev(Abv);
752 llvm::BitstreamWriter &Stream,
755 Record.push_back(ID);
756 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);
759 if (!Name || Name[0] == 0)
763 Record.push_back(*Name++);
764 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME, Record);
768 llvm::BitstreamWriter &Stream,
771 Record.push_back(ID);
773 Record.push_back(*Name++);
774 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, Record);
779 #define RECORD(X) EmitRecordID(X, #X, Stream, Record)
906 void ASTWriter::WriteBlockInfoBlock() {
908 Stream.EnterSubblock(llvm::bitc::BLOCKINFO_BLOCK_ID, 3);
910 #define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
911 #define RECORD(X) EmitRecordID(X, #X, Stream, Record)
914 BLOCK(CONTROL_BLOCK);
926 BLOCK(OPTIONS_BLOCK);
934 BLOCK(INPUT_FILES_BLOCK);
988 BLOCK(SOURCE_MANAGER_BLOCK);
996 BLOCK(PREPROCESSOR_BLOCK);
1004 BLOCK(SUBMODULE_BLOCK);
1023 BLOCK(COMMENTS_BLOCK);
1027 BLOCK(DECLTYPES_BLOCK);
1143 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
1149 BLOCK(EXTENSION_BLOCK);
1164 return Changed | llvm::sys::path::remove_dots(Path);
1179 assert(Filename &&
"No file name to adjust?");
1181 if (BaseDir.empty())
1186 for (; Filename[Pos] && Pos < BaseDir.size(); ++Pos)
1187 if (Filename[Pos] != BaseDir[Pos])
1196 if (!llvm::sys::path::is_separator(Filename[Pos])) {
1197 if (!llvm::sys::path::is_separator(BaseDir.back()))
1211 return Filename + Pos;
1223 uint64_t ASTWriter::WriteControlBlock(
Preprocessor &PP,
1226 const std::string &OutputFile) {
1229 using namespace llvm;
1234 auto *MetadataAbbrev =
new BitCodeAbbrev();
1235 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1236 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1237 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1238 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1239 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1240 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1241 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1242 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1243 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1244 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(MetadataAbbrev);
1245 assert((!WritingModule || isysroot.empty()) &&
1246 "writing module as a relocatable PCH?");
1249 CLANG_VERSION_MAJOR, CLANG_VERSION_MINOR,
1250 !isysroot.empty(), IncludeTimestamps,
1251 ASTHasCompilerErrors};
1252 Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
1255 if (WritingModule) {
1262 RecordData::value_type Record[] = {Signature};
1267 auto *Abbrev =
new BitCodeAbbrev();
1269 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1270 unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
1272 Stream.EmitRecordWithBlob(AbbrevCode, Record, WritingModule->Name);
1275 if (WritingModule && WritingModule->Directory) {
1285 WritingModule->Directory->getName() != StringRef(
".")) {
1287 auto *Abbrev =
new BitCodeAbbrev();
1289 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1290 unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
1293 Stream.EmitRecordWithBlob(AbbrevCode, Record, BaseDir);
1297 BaseDirectory.assign(BaseDir.begin(), BaseDir.end());
1298 }
else if (!isysroot.empty()) {
1300 BaseDirectory = isysroot;
1304 if (WritingModule) {
1310 AddPath(
Map.getModuleMapFileForUniquing(WritingModule)->getName(), Record);
1313 if (
auto *AdditionalModMaps =
1314 Map.getAdditionalModuleMapFiles(WritingModule)) {
1315 Record.push_back(AdditionalModMaps->size());
1316 for (
const FileEntry *F : *AdditionalModMaps)
1317 AddPath(F->getName(), Record);
1319 Record.push_back(0);
1330 for (
auto *M : Mgr) {
1332 if (!M->isDirectlyImported())
1335 Record.push_back((
unsigned)M->Kind);
1336 AddSourceLocation(M->ImportLoc, Record);
1337 Record.push_back(M->File->getSize());
1338 Record.push_back(getTimestampForOutput(M->File));
1339 Record.push_back(M->Signature);
1340 AddPath(M->FileName, Record);
1342 Stream.EmitRecord(
IMPORTS, Record);
1351 #define LANGOPT(Name, Bits, Default, Description) \
1352 Record.push_back(LangOpts.Name);
1353 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
1354 Record.push_back(static_cast<unsigned>(LangOpts.get##Name()));
1355 #include "clang/Basic/LangOptions.def"
1356 #define SANITIZER(NAME, ID) \
1357 Record.push_back(LangOpts.Sanitize.has(SanitizerKind::ID));
1358 #include "clang/Basic/Sanitizers.def"
1360 Record.push_back(LangOpts.ModuleFeatures.size());
1361 for (StringRef Feature : LangOpts.ModuleFeatures)
1362 AddString(Feature, Record);
1364 Record.push_back((
unsigned) LangOpts.ObjCRuntime.getKind());
1365 AddVersionTuple(LangOpts.ObjCRuntime.getVersion(), Record);
1367 AddString(LangOpts.CurrentModule, Record);
1370 Record.push_back(LangOpts.CommentOpts.BlockCommandNames.size());
1371 for (
const auto &
I : LangOpts.CommentOpts.BlockCommandNames) {
1372 AddString(
I, Record);
1374 Record.push_back(LangOpts.CommentOpts.ParseAllComments);
1377 Record.push_back(LangOpts.OMPTargetTriples.size());
1378 for (
auto &T : LangOpts.OMPTargetTriples)
1379 AddString(T.getTriple(), Record);
1381 AddString(LangOpts.OMPHostIRFile, Record);
1389 AddString(TargetOpts.Triple, Record);
1390 AddString(TargetOpts.CPU, Record);
1391 AddString(TargetOpts.ABI, Record);
1392 Record.push_back(TargetOpts.FeaturesAsWritten.size());
1393 for (
unsigned I = 0, N = TargetOpts.FeaturesAsWritten.size();
I != N; ++
I) {
1394 AddString(TargetOpts.FeaturesAsWritten[
I], Record);
1396 Record.push_back(TargetOpts.Features.size());
1397 for (
unsigned I = 0, N = TargetOpts.Features.size();
I != N; ++
I) {
1398 AddString(TargetOpts.Features[
I], Record);
1406 #define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name);
1407 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
1408 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name()));
1409 #include "clang/Basic/DiagnosticOptions.def"
1410 Record.push_back(DiagOpts.Warnings.size());
1411 for (
unsigned I = 0, N = DiagOpts.Warnings.size();
I != N; ++
I)
1412 AddString(DiagOpts.Warnings[
I], Record);
1413 Record.push_back(DiagOpts.Remarks.size());
1414 for (
unsigned I = 0, N = DiagOpts.Remarks.size();
I != N; ++
I)
1415 AddString(DiagOpts.Remarks[
I], Record);
1424 AddString(FSOpts.WorkingDir, Record);
1431 AddString(HSOpts.Sysroot, Record);
1434 Record.push_back(HSOpts.UserEntries.size());
1435 for (
unsigned I = 0, N = HSOpts.UserEntries.size();
I != N; ++
I) {
1437 AddString(Entry.
Path, Record);
1438 Record.push_back(static_cast<unsigned>(Entry.
Group));
1444 Record.push_back(HSOpts.SystemHeaderPrefixes.size());
1445 for (
unsigned I = 0, N = HSOpts.SystemHeaderPrefixes.size();
I != N; ++
I) {
1446 AddString(HSOpts.SystemHeaderPrefixes[
I].Prefix, Record);
1447 Record.push_back(HSOpts.SystemHeaderPrefixes[
I].IsSystemHeader);
1450 AddString(HSOpts.ResourceDir, Record);
1451 AddString(HSOpts.ModuleCachePath, Record);
1452 AddString(HSOpts.ModuleUserBuildPath, Record);
1453 Record.push_back(HSOpts.DisableModuleHash);
1454 Record.push_back(HSOpts.UseBuiltinIncludes);
1455 Record.push_back(HSOpts.UseStandardSystemIncludes);
1456 Record.push_back(HSOpts.UseStandardCXXIncludes);
1457 Record.push_back(HSOpts.UseLibcxx);
1467 Record.push_back(PPOpts.Macros.size());
1468 for (
unsigned I = 0, N = PPOpts.Macros.size();
I != N; ++
I) {
1469 AddString(PPOpts.Macros[
I].first, Record);
1470 Record.push_back(PPOpts.Macros[
I].second);
1474 Record.push_back(PPOpts.Includes.size());
1475 for (
unsigned I = 0, N = PPOpts.Includes.size();
I != N; ++
I)
1476 AddString(PPOpts.Includes[
I], Record);
1479 Record.push_back(PPOpts.MacroIncludes.size());
1480 for (
unsigned I = 0, N = PPOpts.MacroIncludes.size();
I != N; ++
I)
1481 AddString(PPOpts.MacroIncludes[
I], Record);
1483 Record.push_back(PPOpts.UsePredefines);
1485 Record.push_back(PPOpts.DetailedRecord);
1486 AddString(PPOpts.ImplicitPCHInclude, Record);
1487 AddString(PPOpts.ImplicitPTHInclude, Record);
1488 Record.push_back(static_cast<unsigned>(PPOpts.ObjCXXARCStandardLibrary));
1497 auto *FileAbbrev =
new BitCodeAbbrev();
1499 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1500 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1501 unsigned FileAbbrevCode = Stream.EmitAbbrev(FileAbbrev);
1506 EmitRecordWithPath(FileAbbrevCode, Record, MainFile->getName());
1514 if (!OutputFile.empty() && OutputFile !=
"-") {
1515 auto *Abbrev =
new BitCodeAbbrev();
1517 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1518 unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
1523 StringRef origDir = llvm::sys::path::parent_path(OutputPath);
1526 Stream.EmitRecordWithBlob(AbbrevCode, Record, origDir);
1529 WriteInputFiles(Context.SourceMgr,
1538 struct InputFileEntry {
1542 bool BufferOverridden;
1549 using namespace llvm;
1553 auto *IFAbbrev =
new BitCodeAbbrev();
1555 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1556 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1557 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1558 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1559 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1560 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1561 unsigned IFAbbrevCode = Stream.EmitAbbrev(IFAbbrev);
1565 std::deque<InputFileEntry> SortedFiles;
1575 if (!Cache->OrigEntry)
1578 InputFileEntry Entry;
1579 Entry.File = Cache->OrigEntry;
1580 Entry.IsSystemFile = Cache->IsSystemFile;
1581 Entry.IsTransient = Cache->IsTransient;
1582 Entry.BufferOverridden = Cache->BufferOverridden;
1583 if (Cache->IsSystemFile)
1584 SortedFiles.push_back(Entry);
1586 SortedFiles.push_front(Entry);
1589 unsigned UserFilesNum = 0;
1591 std::vector<uint64_t> InputFileOffsets;
1592 for (
const auto &Entry : SortedFiles) {
1593 uint32_t &InputFileID = InputFileIDs[Entry.File];
1594 if (InputFileID != 0)
1598 InputFileOffsets.push_back(Stream.GetCurrentBitNo());
1600 InputFileID = InputFileOffsets.size();
1602 if (!Entry.IsSystemFile)
1607 RecordData::value_type Record[] = {
1609 InputFileOffsets.size(),
1610 (uint64_t)Entry.File->getSize(),
1611 (uint64_t)getTimestampForOutput(Entry.File),
1612 Entry.BufferOverridden,
1615 EmitRecordWithPath(IFAbbrevCode, Record, Entry.File->getName());
1621 auto *OffsetsAbbrev =
new BitCodeAbbrev();
1623 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1624 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1626 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1627 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(OffsetsAbbrev);
1631 InputFileOffsets.size(), UserFilesNum};
1632 Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record,
bytes(InputFileOffsets));
1642 using namespace llvm;
1644 auto *Abbrev =
new BitCodeAbbrev();
1646 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1647 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1648 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
1649 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1651 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1652 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1653 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
1654 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1655 return Stream.EmitAbbrev(Abbrev);
1661 using namespace llvm;
1663 auto *Abbrev =
new BitCodeAbbrev();
1665 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1666 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1667 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
1668 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1669 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1670 return Stream.EmitAbbrev(Abbrev);
1677 using namespace llvm;
1679 auto *Abbrev =
new BitCodeAbbrev();
1683 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1684 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1685 return Stream.EmitAbbrev(Abbrev);
1691 using namespace llvm;
1693 auto *Abbrev =
new BitCodeAbbrev();
1695 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1696 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1697 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1698 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1699 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1700 return Stream.EmitAbbrev(Abbrev);
1705 class HeaderFileInfoTrait {
1711 llvm::StringMap<unsigned> FrameworkNameOffset;
1715 : Writer(Writer), HS(HS) { }
1721 typedef const key_type &key_type_ref;
1724 typedef const data_type &data_type_ref;
1725 typedef unsigned hash_value_type;
1726 typedef unsigned offset_type;
1732 return llvm::hash_combine(key.FE->getSize(),
1733 Writer.getTimestampForOutput(key.FE));
1736 std::pair<unsigned,unsigned>
1737 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) {
1738 using namespace llvm::support;
1739 endian::Writer<little> LE(Out);
1740 unsigned KeyLen = strlen(key.Filename) + 1 + 8 + 8;
1741 LE.write<uint16_t>(KeyLen);
1742 unsigned DataLen = 1 + 2 + 4 + 4;
1743 for (
auto ModInfo : HS.getModuleMap().findAllModulesForHeader(key.FE))
1744 if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
1746 LE.write<uint8_t>(DataLen);
1747 return std::make_pair(KeyLen, DataLen);
1750 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
1751 using namespace llvm::support;
1752 endian::Writer<little> LE(Out);
1753 LE.write<uint64_t>(key.FE->getSize());
1755 LE.write<uint64_t>(Writer.getTimestampForOutput(key.FE));
1757 Out.write(key.Filename, KeyLen);
1760 void EmitData(raw_ostream &Out, key_type_ref key,
1761 data_type_ref Data,
unsigned DataLen) {
1762 using namespace llvm::support;
1763 endian::Writer<little> LE(Out);
1764 uint64_t Start = Out.tell(); (void)Start;
1766 unsigned char Flags = (Data.isImport << 4)
1767 | (Data.isPragmaOnce << 3)
1768 | (Data.DirInfo << 1)
1769 | Data.IndexHeaderMapHeader;
1770 LE.write<uint8_t>(Flags);
1771 LE.write<uint16_t>(Data.NumIncludes);
1773 if (!Data.ControllingMacro)
1774 LE.write<uint32_t>(Data.ControllingMacroID);
1776 LE.write<uint32_t>(Writer.getIdentifierRef(Data.ControllingMacro));
1779 if (!Data.Framework.empty()) {
1782 = FrameworkNameOffset.find(Data.Framework);
1783 if (Pos == FrameworkNameOffset.end()) {
1784 Offset = FrameworkStringData.size() + 1;
1785 FrameworkStringData.append(Data.Framework.begin(),
1786 Data.Framework.end());
1787 FrameworkStringData.push_back(0);
1789 FrameworkNameOffset[Data.Framework] =
Offset;
1793 LE.write<uint32_t>(
Offset);
1797 for (
auto ModInfo : HS.getModuleMap().findAllModulesForHeader(key.FE)) {
1798 if (uint32_t ModID =
1799 Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule())) {
1800 uint32_t
Value = (ModID << 2) | (
unsigned)ModInfo.getRole();
1801 assert((Value >> 2) == ModID &&
"overflow in header module info");
1802 LE.write<uint32_t>(
Value);
1806 assert(Out.tell() - Start == DataLen &&
"Wrong data length");
1809 const char *strings_begin()
const {
return FrameworkStringData.begin(); }
1810 const char *strings_end()
const {
return FrameworkStringData.end(); }
1817 void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
1824 HeaderFileInfoTrait GeneratorTrait(*
this, HS);
1825 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait> Generator;
1827 unsigned NumHeaderSearchEntries = 0;
1828 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
1829 const FileEntry *File = FilesByUID[UID];
1847 if (PreparePathForOutput(FilenameTmp)) {
1850 Filename = strdup(FilenameTmp.c_str());
1851 SavedStrings.push_back(Filename);
1854 HeaderFileInfoTrait::key_type key = { File, Filename };
1855 Generator.insert(key, *HFI, GeneratorTrait);
1856 ++NumHeaderSearchEntries;
1861 uint32_t BucketOffset;
1863 using namespace llvm::support;
1864 llvm::raw_svector_ostream Out(TableData);
1866 endian::Writer<little>(Out).write<uint32_t>(0);
1867 BucketOffset = Generator.Emit(Out, GeneratorTrait);
1871 using namespace llvm;
1873 auto *Abbrev =
new BitCodeAbbrev();
1875 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1876 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1877 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1878 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1879 unsigned TableAbbrev = Stream.EmitAbbrev(Abbrev);
1883 NumHeaderSearchEntries, TableData.size()};
1884 TableData.append(GeneratorTrait.strings_begin(),GeneratorTrait.strings_end());
1885 Stream.EmitRecordWithBlob(TableAbbrev, Record, TableData);
1888 for (
unsigned I = 0, N = SavedStrings.size();
I != N; ++
I)
1889 free(const_cast<char *>(SavedStrings[
I]));
1900 void ASTWriter::WriteSourceManagerBlock(
SourceManager &SourceMgr,
1911 unsigned SLocBufferBlobCompressedAbbrv =
1917 std::vector<uint32_t> SLocEntryOffsets;
1918 RecordData PreloadSLocs;
1928 SLocEntryOffsets.push_back(Stream.GetCurrentBitNo());
1934 if (Cache->OrigEntry) {
1941 Record.push_back(Code);
1944 Record.push_back(SLoc->
getOffset() - 2);
1952 bool EmitBlob =
false;
1953 if (Content->OrigEntry) {
1954 assert(Content->OrigEntry == Content->ContentsEntry &&
1955 "Writing to AST an overridden file is not supported");
1958 assert(InputFileIDs[Content->OrigEntry] != 0 &&
"Missed file entry");
1959 Record.push_back(InputFileIDs[Content->OrigEntry]);
1961 Record.push_back(File.NumCreatedFIDs);
1964 if (FDI != FileDeclIDs.end()) {
1965 Record.push_back(FDI->second->FirstDeclIndex);
1966 Record.push_back(FDI->second->DeclIDs.size());
1968 Record.push_back(0);
1969 Record.push_back(0);
1972 Stream.EmitRecordWithAbbrev(SLocFileAbbrv, Record);
1974 if (Content->BufferOverridden || Content->IsTransient)
1983 const llvm::MemoryBuffer *
Buffer
1985 const char *
Name = Buffer->getBufferIdentifier();
1986 Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
1987 StringRef(Name, strlen(Name) + 1));
1990 if (strcmp(Name,
"<built-in>") == 0) {
1991 PreloadSLocs.push_back(SLocEntryOffsets.size());
1998 const llvm::MemoryBuffer *Buffer =
2000 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
2005 if (llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer) ==
2006 llvm::zlib::StatusOK) {
2009 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record,
2013 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob);
2023 : Expansion.getExpansionLocEnd(),
2030 Record.push_back(NextOffset - SLoc->
getOffset() - 1);
2031 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv, Record);
2037 if (SLocEntryOffsets.empty())
2042 using namespace llvm;
2044 auto *Abbrev =
new BitCodeAbbrev();
2046 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2047 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2048 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2049 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(Abbrev);
2051 RecordData::value_type Record[] = {
2054 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
2055 bytes(SLocEntryOffsets));
2069 llvm::DenseMap<int, int> FilenameMap;
2070 for (
const auto &L : LineTable) {
2073 for (
auto &LE : L.second) {
2074 if (FilenameMap.insert(std::make_pair(LE.FilenameID,
2075 FilenameMap.size())).second)
2076 AddPath(LineTable.getFilename(LE.FilenameID), Record);
2079 Record.push_back(0);
2082 for (
const auto &L : LineTable) {
2088 Record.push_back(L.first.ID);
2091 Record.push_back(L.second.size());
2092 for (
const auto &LE : L.second) {
2093 Record.push_back(LE.FileOffset);
2094 Record.push_back(LE.LineNo);
2095 Record.push_back(FilenameMap[LE.FilenameID]);
2096 Record.push_back((
unsigned)LE.FileKind);
2097 Record.push_back(LE.IncludeOffset);
2112 if (MI->isBuiltinMacro())
2129 void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2132 WritePreprocessorDetail(*PPRec);
2135 RecordData ModuleMacroRecord;
2158 if (Id.second->hadMacroDefinition() &&
2159 (!Id.second->isFromAST() ||
2160 Id.second->hasChangedSinceDeserialization()))
2161 MacroIdentifiers.push_back(Id.second);
2164 std::sort(MacroIdentifiers.begin(), MacroIdentifiers.end(),
2165 llvm::less_ptr<IdentifierInfo>());
2171 auto StartOffset = Stream.GetCurrentBitNo();
2181 Record.push_back(MD->
getKind());
2182 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2183 Record.push_back(getMacroRef(DefMD->getInfo(),
Name));
2184 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2185 Record.push_back(VisMD->isPublic());
2190 bool EmittedModuleMacros =
false;
2194 llvm::DenseMap<ModuleMacro*, unsigned> Visits;
2195 while (!Worklist.empty()) {
2196 auto *
Macro = Worklist.pop_back_val();
2199 ModuleMacroRecord.push_back(
2200 getSubmoduleID(
Macro->getOwningModule()));
2201 ModuleMacroRecord.push_back(getMacroRef(
Macro->getMacroInfo(),
Name));
2202 for (
auto *M :
Macro->overrides())
2203 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2206 ModuleMacroRecord.clear();
2209 for (
auto *M :
Macro->overrides())
2210 if (++Visits[M] == M->getNumOverridingMacros())
2211 Worklist.push_back(M);
2213 EmittedModuleMacros =
true;
2216 if (Record.empty() && !EmittedModuleMacros)
2219 IdentMacroDirectivesOffsetMap[
Name] = StartOffset;
2230 std::vector<uint32_t> MacroOffsets;
2232 for (
unsigned I = 0, N = MacroInfosToEmit.size();
I != N; ++
I) {
2237 if (ID < FirstMacroID) {
2238 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2243 unsigned Index = ID - FirstMacroID;
2244 if (Index == MacroOffsets.size())
2245 MacroOffsets.push_back(Stream.GetCurrentBitNo());
2247 if (Index > MacroOffsets.size())
2248 MacroOffsets.resize(Index + 1);
2250 MacroOffsets[Index] = Stream.GetCurrentBitNo();
2253 AddIdentifierRef(Name, Record);
2257 Record.push_back(MI->
isUsed());
2270 AddIdentifierRef(Arg, Record);
2278 Stream.EmitRecord(Code, Record);
2282 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2287 AddToken(Tok, Record);
2288 Stream.EmitRecord(
PP_TOKEN, Record);
2297 using namespace llvm;
2299 auto *Abbrev =
new BitCodeAbbrev();
2301 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2302 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2303 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2305 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
2307 RecordData::value_type Record[] = {
MACRO_OFFSET, MacroOffsets.size(),
2309 Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record,
bytes(MacroOffsets));
2323 unsigned NumPreprocessingRecords = 0;
2324 using namespace llvm;
2327 unsigned InclusionAbbrev = 0;
2329 auto *Abbrev =
new BitCodeAbbrev();
2331 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2332 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2333 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2334 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2335 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2336 InclusionAbbrev = Stream.EmitAbbrev(Abbrev);
2339 unsigned FirstPreprocessorEntityID
2340 = (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0)
2342 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2347 (void)++
E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2350 PreprocessedEntityOffsets.push_back(
2351 PPEntityOffset((*E)->getSourceRange(), Stream.GetCurrentBitNo()));
2353 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*
E)) {
2355 MacroDefinitions[MD] = NextPreprocessorEntityID;
2357 AddIdentifierRef(MD->getName(), Record);
2362 if (
auto *ME = dyn_cast<MacroExpansion>(*
E)) {
2363 Record.push_back(ME->isBuiltinMacro());
2364 if (ME->isBuiltinMacro())
2365 AddIdentifierRef(ME->getName(), Record);
2367 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2372 if (
auto *ID = dyn_cast<InclusionDirective>(*
E)) {
2374 Record.push_back(ID->getFileName().size());
2375 Record.push_back(ID->wasInQuotes());
2376 Record.push_back(static_cast<unsigned>(ID->getKind()));
2377 Record.push_back(ID->importedModule());
2379 Buffer += ID->getFileName();
2383 Buffer += ID->getFile()->getName();
2384 Stream.EmitRecordWithBlob(InclusionAbbrev, Record, Buffer);
2388 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2393 if (NumPreprocessingRecords > 0) {
2394 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2397 using namespace llvm;
2399 auto *Abbrev =
new BitCodeAbbrev();
2401 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2402 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2403 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
2406 FirstPreprocessorEntityID -
2408 Stream.EmitRecordWithBlob(PPEOffsetAbbrev, Record,
2409 bytes(PreprocessedEntityOffsets));
2418 if (Known != SubmoduleIDs.end())
2419 return Known->second;
2424 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2427 unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2431 unsigned ID = getLocalOrImportedSubmoduleID(Mod);
2432 assert((ID || !Mod) &&
2433 "asked for module ID for non-local, non-imported module");
2440 unsigned ChildModules = 0;
2442 Sub != SubEnd; ++Sub)
2445 return ChildModules + 1;
2448 void ASTWriter::WriteSubmodules(
Module *WritingModule) {
2453 using namespace llvm;
2455 auto *Abbrev =
new BitCodeAbbrev();
2457 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2458 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2459 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2460 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2461 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2462 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2463 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2464 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2465 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2466 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2467 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2468 unsigned DefinitionAbbrev = Stream.EmitAbbrev(Abbrev);
2470 Abbrev =
new BitCodeAbbrev();
2472 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2473 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(Abbrev);
2475 Abbrev =
new BitCodeAbbrev();
2477 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2478 unsigned HeaderAbbrev = Stream.EmitAbbrev(Abbrev);
2480 Abbrev =
new BitCodeAbbrev();
2482 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2483 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(Abbrev);
2485 Abbrev =
new BitCodeAbbrev();
2487 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2488 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(Abbrev);
2490 Abbrev =
new BitCodeAbbrev();
2492 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2493 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2494 unsigned RequiresAbbrev = Stream.EmitAbbrev(Abbrev);
2496 Abbrev =
new BitCodeAbbrev();
2498 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2499 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(Abbrev);
2501 Abbrev =
new BitCodeAbbrev();
2503 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2504 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(Abbrev);
2506 Abbrev =
new BitCodeAbbrev();
2508 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2509 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(Abbrev);
2511 Abbrev =
new BitCodeAbbrev();
2513 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2514 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(Abbrev);
2516 Abbrev =
new BitCodeAbbrev();
2518 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2519 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2520 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(Abbrev);
2522 Abbrev =
new BitCodeAbbrev();
2524 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2525 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(Abbrev);
2527 Abbrev =
new BitCodeAbbrev();
2529 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2530 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2531 unsigned ConflictAbbrev = Stream.EmitAbbrev(Abbrev);
2540 std::queue<Module *> Q;
2541 Q.push(WritingModule);
2542 while (!Q.empty()) {
2545 unsigned ID = getSubmoduleID(Mod);
2547 uint64_t ParentID = 0;
2549 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
2550 ParentID = SubmoduleIDs[Mod->
Parent];
2555 RecordData::value_type Record[] = {
2560 Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->
Name);
2566 Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
2572 Stream.EmitRecordWithBlob(UmbrellaAbbrev, Record,
2573 UmbrellaHeader.NameAsWritten);
2576 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev, Record,
2577 UmbrellaDir.NameAsWritten);
2582 unsigned RecordKind;
2593 for (
auto &HL : HeaderLists) {
2594 RecordData::value_type Record[] = {HL.RecordKind};
2595 for (
auto &H : Mod->
Headers[HL.HeaderKind])
2596 Stream.EmitRecordWithBlob(HL.Abbrev, Record, H.NameAsWritten);
2603 for (
auto *H : TopHeaders)
2604 Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, H->getName());
2611 Record.push_back(getSubmoduleID(
I));
2618 for (
const auto &
E : Mod->
Exports) {
2621 Record.push_back(getSubmoduleID(
E.getPointer()));
2622 Record.push_back(
E.getInt());
2635 Stream.EmitRecordWithBlob(LinkLibraryAbbrev, Record, LL.Library);
2643 getSubmoduleID(
C.Other)};
2644 Stream.EmitRecordWithBlob(ConflictAbbrev, Record,
C.Message);
2650 Stream.EmitRecordWithBlob(ConfigMacroAbbrev, Record, CM);
2660 assert((NextSubmoduleID - FirstSubmoduleID ==
2662 "Wrong # of submodules; found a reference to a non-local, "
2663 "non-imported submodule?");
2679 if (WritingModule != OwningMod && !OwningMod->
isSubModuleOf(WritingModule))
2682 return getSubmoduleID(OwningMod);
2693 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
2695 unsigned CurrID = 0;
2696 DiagStateIDMap[&Diag.DiagStates.front()] = ++CurrID;
2698 for (DiagnosticsEngine::DiagStatePointsTy::const_iterator
2699 I = Diag.DiagStatePoints.begin(),
E = Diag.DiagStatePoints.end();
2701 const DiagnosticsEngine::DiagStatePoint &point = *
I;
2702 if (point.Loc.isInvalid())
2705 AddSourceLocation(point.Loc, Record);
2706 unsigned &DiagStateID = DiagStateIDMap[point.State];
2707 Record.push_back(DiagStateID);
2709 if (DiagStateID == 0) {
2710 DiagStateID = ++CurrID;
2711 for (
const auto &
I : *(point.State)) {
2712 if (
I.second.isPragma()) {
2713 Record.push_back(
I.first);
2714 Record.push_back((
unsigned)
I.second.getSeverity());
2717 Record.push_back(-1);
2722 if (!Record.empty())
2731 void ASTWriter::WriteType(
QualType T) {
2732 TypeIdx &IdxRef = TypeIdxs[T];
2734 IdxRef =
TypeIdx(NextTypeID++);
2737 assert(Idx.
getIndex() >= FirstTypeID &&
"Re-writing a type from a prior AST");
2744 uint64_t
Offset = W.Emit();
2747 unsigned Index = Idx.
getIndex() - FirstTypeID;
2748 if (TypeOffsets.size() == Index)
2749 TypeOffsets.push_back(Offset);
2750 else if (TypeOffsets.size() < Index) {
2751 TypeOffsets.resize(Index + 1);
2752 TypeOffsets[Index] =
Offset;
2754 llvm_unreachable(
"Types emitted in wrong order");
2767 uint64_t ASTWriter::WriteDeclContextLexicalBlock(
ASTContext &Context,
2772 uint64_t Offset = Stream.GetCurrentBitNo();
2774 for (
const auto *D : DC->
decls()) {
2775 KindDeclPairs.push_back(D->getKind());
2776 KindDeclPairs.push_back(GetDeclRef(D));
2779 ++NumLexicalDeclContexts;
2781 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record,
2782 bytes(KindDeclPairs));
2786 void ASTWriter::WriteTypeDeclOffsets() {
2787 using namespace llvm;
2790 auto *Abbrev =
new BitCodeAbbrev();
2792 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2793 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2794 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2795 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
2797 RecordData::value_type Record[] = {
TYPE_OFFSET, TypeOffsets.size(),
2799 Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record,
bytes(TypeOffsets));
2803 Abbrev =
new BitCodeAbbrev();
2805 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2806 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2807 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2808 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
2810 RecordData::value_type Record[] = {
DECL_OFFSET, DeclOffsets.size(),
2812 Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record,
bytes(DeclOffsets));
2816 void ASTWriter::WriteFileDeclIDsMap() {
2817 using namespace llvm;
2820 FileDeclIDs.begin(), FileDeclIDs.end());
2821 std::sort(SortedFileDeclIDs.begin(), SortedFileDeclIDs.end(),
2822 llvm::less_first());
2826 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
2827 DeclIDInFileInfo &Info = *FileDeclEntry.second;
2828 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
2829 for (
auto &LocDeclEntry : Info.DeclIDs)
2830 FileGroupedDeclIDs.push_back(LocDeclEntry.second);
2833 auto *Abbrev =
new BitCodeAbbrev();
2835 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2836 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2837 unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
2839 FileGroupedDeclIDs.size()};
2840 Stream.EmitRecordWithBlob(AbbrevCode, Record,
bytes(FileGroupedDeclIDs));
2843 void ASTWriter::WriteComments() {
2847 for (
const auto *
I : RawComments) {
2849 AddSourceRange(
I->getSourceRange(), Record);
2850 Record.push_back(
I->getKind());
2851 Record.push_back(
I->isTrailingComment());
2852 Record.push_back(
I->isAlmostTrailingComment());
2864 class ASTMethodPoolTrait {
2869 typedef key_type key_type_ref;
2875 typedef const data_type& data_type_ref;
2877 typedef unsigned hash_value_type;
2878 typedef unsigned offset_type;
2880 explicit ASTMethodPoolTrait(
ASTWriter &Writer) : Writer(Writer) { }
2886 std::pair<unsigned,unsigned>
2887 EmitKeyDataLength(raw_ostream& Out,
Selector Sel,
2888 data_type_ref Methods) {
2889 using namespace llvm::support;
2890 endian::Writer<little> LE(Out);
2892 LE.write<uint16_t>(KeyLen);
2893 unsigned DataLen = 4 + 2 + 2;
2896 if (Method->getMethod())
2900 if (Method->getMethod())
2902 LE.write<uint16_t>(DataLen);
2903 return std::make_pair(KeyLen, DataLen);
2906 void EmitKey(raw_ostream& Out,
Selector Sel,
unsigned) {
2907 using namespace llvm::support;
2908 endian::Writer<little> LE(Out);
2909 uint64_t Start = Out.tell();
2910 assert((Start >> 32) == 0 &&
"Selector key offset too large");
2911 Writer.SetSelectorOffset(Sel, Start);
2913 LE.write<uint16_t>(N);
2916 for (
unsigned I = 0;
I != N; ++
I)
2921 void EmitData(raw_ostream& Out, key_type_ref,
2922 data_type_ref Methods,
unsigned DataLen) {
2923 using namespace llvm::support;
2924 endian::Writer<little> LE(Out);
2925 uint64_t Start = Out.tell(); (void)Start;
2926 LE.write<uint32_t>(Methods.ID);
2927 unsigned NumInstanceMethods = 0;
2930 if (Method->getMethod())
2931 ++NumInstanceMethods;
2933 unsigned NumFactoryMethods = 0;
2936 if (Method->getMethod())
2937 ++NumFactoryMethods;
2939 unsigned InstanceBits = Methods.Instance.getBits();
2940 assert(InstanceBits < 4);
2941 unsigned InstanceHasMoreThanOneDeclBit =
2942 Methods.Instance.hasMoreThanOneDecl();
2943 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
2944 (InstanceHasMoreThanOneDeclBit << 2) |
2946 unsigned FactoryBits = Methods.Factory.getBits();
2947 assert(FactoryBits < 4);
2948 unsigned FactoryHasMoreThanOneDeclBit =
2949 Methods.Factory.hasMoreThanOneDecl();
2950 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
2951 (FactoryHasMoreThanOneDeclBit << 2) |
2953 LE.write<uint16_t>(FullInstanceBits);
2954 LE.write<uint16_t>(FullFactoryBits);
2957 if (Method->getMethod())
2958 LE.write<uint32_t>(Writer.getDeclID(Method->getMethod()));
2961 if (Method->getMethod())
2962 LE.write<uint32_t>(Writer.getDeclID(Method->getMethod()));
2964 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
2974 void ASTWriter::WriteSelectors(
Sema &SemaRef) {
2975 using namespace llvm;
2978 if (SemaRef.
MethodPool.empty() && SelectorIDs.empty())
2980 unsigned NumTableEntries = 0;
2983 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait> Generator;
2984 ASTMethodPoolTrait Trait(*
this);
2988 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
2989 for (
auto &SelectorAndID : SelectorIDs) {
2993 ASTMethodPoolTrait::data_type Data = {
2999 Data.Instance = F->second.first;
3000 Data.Factory = F->second.second;
3004 if (Chain && ID < FirstSelectorID) {
3006 bool changed =
false;
3008 !changed && M && M->
getMethod(); M = M->getNext()) {
3009 if (!M->getMethod()->isFromASTFile())
3014 if (!M->getMethod()->isFromASTFile())
3019 }
else if (Data.Instance.getMethod() || Data.Factory.getMethod()) {
3023 Generator.insert(S, Data, Trait);
3028 uint32_t BucketOffset;
3030 using namespace llvm::support;
3031 ASTMethodPoolTrait Trait(*
this);
3032 llvm::raw_svector_ostream Out(MethodPool);
3034 endian::Writer<little>(Out).write<uint32_t>(0);
3035 BucketOffset = Generator.Emit(Out, Trait);
3039 auto *Abbrev =
new BitCodeAbbrev();
3041 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3042 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3043 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3044 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(Abbrev);
3048 RecordData::value_type Record[] = {
METHOD_POOL, BucketOffset,
3050 Stream.EmitRecordWithBlob(MethodPoolAbbrev, Record, MethodPool);
3054 Abbrev =
new BitCodeAbbrev();
3056 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3057 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3058 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3059 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
3063 RecordData::value_type Record[] = {
3066 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev, Record,
3067 bytes(SelectorOffsets));
3073 void ASTWriter::WriteReferencedSelectorsPool(
Sema &SemaRef) {
3074 using namespace llvm;
3085 Selector Sel = SelectorAndLocation.first;
3087 Writer.AddSelectorRef(Sel);
3088 Writer.AddSourceLocation(Loc);
3104 if (!LangOpts.Modules || !D->isFromASTFile())
3107 if (
Decl *Redecl = D->getPreviousDecl()) {
3109 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3111 if (!Redecl->isFromASTFile()) {
3115 if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
3116 D->getDeclContext()->getRedeclContext()))
3118 return cast<NamedDecl>(Redecl);
3123 if (Redecl->getOwningModuleID() == 0)
3126 }
else if (
Decl *First = D->getCanonicalDecl()) {
3128 if (!First->isFromASTFile())
3129 return cast<NamedDecl>(First);
3138 class ASTIdentifierTableTrait {
3163 typedef key_type key_type_ref;
3166 typedef data_type data_type_ref;
3168 typedef unsigned hash_value_type;
3169 typedef unsigned offset_type;
3174 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3175 NeedDecls(!IsModule || !Writer.getLangOpts().
CPlusPlus),
3176 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3178 bool needDecls()
const {
return NeedDecls; }
3181 return llvm::HashString(II->
getName());
3185 auto MacroOffset = Writer.getMacroDirectivesOffset(II);
3192 std::pair<unsigned,unsigned>
3195 unsigned DataLen = 4;
3196 auto MacroOffset = Writer.getMacroDirectivesOffset(II);
3205 DEnd = IdResolver.end();
3210 using namespace llvm::support;
3211 endian::Writer<little> LE(Out);
3213 assert((uint16_t)DataLen == DataLen && (uint16_t)KeyLen == KeyLen);
3214 LE.write<uint16_t>(DataLen);
3218 LE.write<uint16_t>(KeyLen);
3219 return std::make_pair(KeyLen, DataLen);
3226 Writer.SetIdentifierOffset(II, Out.tell());
3231 InterestingIdentifierOffsets->push_back(Out.tell() - 4);
3238 using namespace llvm::support;
3239 endian::Writer<little> LE(Out);
3241 auto MacroOffset = Writer.getMacroDirectivesOffset(II);
3243 LE.write<uint32_t>(ID << 1);
3247 LE.write<uint32_t>((ID << 1) | 0x01);
3249 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
3250 LE.write<uint16_t>(Bits);
3252 bool HadMacroDefinition = MacroOffset != 0;
3253 Bits = (Bits << 1) |
unsigned(HadMacroDefinition);
3255 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
3259 LE.write<uint16_t>(Bits);
3261 if (HadMacroDefinition)
3262 LE.write<uint32_t>(MacroOffset);
3274 DEnd = Decls.rend();
3291 using namespace llvm;
3293 RecordData InterestingIdents;
3298 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait> Generator;
3299 ASTIdentifierTableTrait Trait(
3300 *
this, PP, IdResolver, IsModule,
3301 (getLangOpts().
CPlusPlus && IsModule) ? &InterestingIdents :
nullptr);
3310 IIs.push_back(ID.second);
3313 std::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
3315 if (Trait.isInterestingNonMacroIdentifier(II))
3316 getIdentifierRef(II);
3320 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
3321 for (
auto IdentIDPair : IdentifierIDs) {
3323 IdentID ID = IdentIDPair.second;
3324 assert(II &&
"NULL identifier in identifier table");
3327 if (ID >= FirstIdentID || !Chain || !II->
isFromAST()
3329 (Trait.needDecls() &&
3331 Generator.insert(II, ID, Trait);
3336 uint32_t BucketOffset;
3338 using namespace llvm::support;
3339 llvm::raw_svector_ostream Out(IdentifierTable);
3341 endian::Writer<little>(Out).write<uint32_t>(0);
3342 BucketOffset = Generator.Emit(Out, Trait);
3346 auto *Abbrev =
new BitCodeAbbrev();
3348 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3349 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3350 unsigned IDTableAbbrev = Stream.EmitAbbrev(Abbrev);
3354 Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable);
3358 auto *Abbrev =
new BitCodeAbbrev();
3360 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3361 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3362 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3363 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
3366 for (
unsigned I = 0, N = IdentifierOffsets.size();
I != N; ++
I)
3367 assert(IdentifierOffsets[
I] &&
"Missing identifier offset?");
3371 IdentifierOffsets.size(),
3373 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev, Record,
3374 bytes(IdentifierOffsets));
3378 if (!InterestingIdents.empty())
3388 class ASTDeclContextNameLookupTrait {
3394 typedef key_type key_type_ref;
3397 typedef std::pair<unsigned, unsigned> data_type;
3398 typedef const data_type& data_type_ref;
3400 typedef unsigned hash_value_type;
3401 typedef unsigned offset_type;
3403 explicit ASTDeclContextNameLookupTrait(
ASTWriter &Writer) : Writer(Writer) { }
3405 template<
typename Coll>
3406 data_type getData(
const Coll &Decls) {
3407 unsigned Start = DeclIDs.size();
3412 return std::make_pair(Start, DeclIDs.size());
3416 unsigned Start = DeclIDs.size();
3417 for (
auto ID : FromReader)
3418 DeclIDs.push_back(ID);
3419 return std::make_pair(Start, DeclIDs.size());
3422 static bool EqualKey(key_type_ref a, key_type_ref b) {
3430 void EmitFileRef(raw_ostream &Out,
ModuleFile *F)
const {
3431 assert(Writer.hasChain() &&
3432 "have reference to loaded module file but no chain?");
3434 using namespace llvm::support;
3435 endian::Writer<little>(Out)
3436 .write<uint32_t>(Writer.getChain()->getModuleFileID(F));
3439 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
3441 data_type_ref Lookup) {
3442 using namespace llvm::support;
3443 endian::Writer<little> LE(Out);
3444 unsigned KeyLen = 1;
3462 LE.write<uint16_t>(KeyLen);
3465 unsigned DataLen = 4 * (Lookup.second - Lookup.first);
3466 assert(uint16_t(DataLen) == DataLen &&
3467 "too many decls for serialized lookup result");
3468 LE.write<uint16_t>(DataLen);
3470 return std::make_pair(KeyLen, DataLen);
3474 using namespace llvm::support;
3475 endian::Writer<little> LE(Out);
3476 LE.write<uint8_t>(Name.
getKind());
3480 LE.write<uint32_t>(Writer.getIdentifierRef(Name.
getIdentifier()));
3485 LE.write<uint32_t>(Writer.getSelectorRef(Name.
getSelector()));
3489 "Invalid operator?");
3499 llvm_unreachable(
"Invalid name kind?");
3502 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
3504 using namespace llvm::support;
3505 endian::Writer<little> LE(Out);
3506 uint64_t Start = Out.tell(); (void)Start;
3507 for (
unsigned I = Lookup.first, N = Lookup.second;
I != N; ++
I)
3508 LE.write<uint32_t>(DeclIDs[
I]);
3509 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3516 return Result.
hasExternalDecls() && DC->NeedToReconcileExternalVisibleStorage;
3519 bool ASTWriter::isLookupResultEntirelyExternal(
StoredDeclsList &Result,
3529 ASTWriter::GenerateNameLookupTable(
const DeclContext *ConstDC,
3531 assert(!ConstDC->HasLazyLocalLexicalLookups &&
3532 !ConstDC->HasLazyExternalLexicalLookups &&
3533 "must call buildLookups first");
3541 ASTDeclContextNameLookupTrait> Generator;
3542 ASTDeclContextNameLookupTrait Trait(*
this);
3551 llvm::SmallSet<DeclarationName, 8> ConstructorNameSet, ConversionNameSet;
3554 auto &Name = Lookup.first;
3555 auto &Result = Lookup.second;
3561 if (isLookupResultExternal(Result, DC) &&
3562 isLookupResultEntirelyExternal(Result, DC))
3579 if (Lookup.second.getLookupResult().empty())
3582 switch (Lookup.first.getNameKind()) {
3584 Names.push_back(Lookup.first);
3588 assert(isa<CXXRecordDecl>(DC) &&
3589 "Cannot have a constructor name outside of a class!");
3590 ConstructorNameSet.insert(Name);
3594 assert(isa<CXXRecordDecl>(DC) &&
3595 "Cannot have a conversion function name outside of a class!");
3596 ConversionNameSet.insert(Name);
3602 std::sort(Names.begin(), Names.end());
3604 if (
auto *D = dyn_cast<CXXRecordDecl>(DC)) {
3618 if (ConstructorNameSet.erase(ImplicitCtorName))
3619 Names.push_back(ImplicitCtorName);
3624 if (!ConstructorNameSet.empty() || !ConversionNameSet.empty())
3625 for (
Decl *ChildD : cast<CXXRecordDecl>(DC)->decls())
3626 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
3627 auto Name = ChildND->getDeclName();
3628 switch (Name.getNameKind()) {
3633 if (ConstructorNameSet.erase(Name))
3634 Names.push_back(Name);
3638 if (ConversionNameSet.erase(Name))
3639 Names.push_back(Name);
3643 if (ConstructorNameSet.empty() && ConversionNameSet.empty())
3647 assert(ConstructorNameSet.empty() &&
"Failed to find all of the visible "
3648 "constructors by walking all the "
3649 "lexical members of the context.");
3650 assert(ConversionNameSet.empty() &&
"Failed to find all of the visible "
3651 "conversion functions by walking all "
3652 "the lexical members of the context.");
3659 for (
auto &Name : Names)
3671 for (
auto &Name : Names) {
3674 switch (Name.getNameKind()) {
3676 Generator.insert(Name, Trait.getData(Result), Trait);
3680 ConstructorDecls.append(Result.
begin(), Result.
end());
3684 ConversionDecls.append(Result.
begin(), Result.
end());
3692 if (!ConstructorDecls.empty())
3693 Generator.insert(ConstructorDecls.front()->getDeclName(),
3694 Trait.getData(ConstructorDecls), Trait);
3695 if (!ConversionDecls.empty())
3696 Generator.insert(ConversionDecls.front()->getDeclName(),
3697 Trait.getData(ConversionDecls), Trait);
3701 auto *Lookups = Chain ? Chain->getLoadedLookupTables(DC) :
nullptr;
3702 Generator.emit(LookupTable, Trait, Lookups ? &Lookups->Table :
nullptr);
3710 uint64_t ASTWriter::WriteDeclContextVisibleBlock(
ASTContext &Context,
3715 if (isa<NamespaceDecl>(DC) && Chain &&
3716 Chain->getKeyDeclaration(cast<Decl>(DC))->isFromASTFile()) {
3718 for (
auto *Prev = cast<NamespaceDecl>(DC)->getPreviousDecl(); Prev;
3719 Prev = Prev->getPreviousDecl())
3720 if (!Prev->isFromASTFile())
3733 LookupResults.reserve(Map->size());
3734 for (
auto &Entry : *Map)
3735 LookupResults.push_back(
3736 std::make_pair(Entry.first, Entry.second.getLookupResult()));
3739 std::sort(LookupResults.begin(), LookupResults.end(), llvm::less_first());
3740 for (
auto &NameAndResult : LookupResults) {
3748 assert(Result.
empty() &&
"Cannot have a constructor or conversion "
3749 "function name in a namespace!");
3754 if (!ND->isFromASTFile())
3778 uint64_t Offset = Stream.GetCurrentBitNo();
3780 if (!Map || Map->empty())
3785 GenerateNameLookupTable(DC, LookupTable);
3789 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev, Record,
3791 ++NumVisibleDeclContexts;
3801 void ASTWriter::WriteDeclContextVisibleUpdate(
const DeclContext *DC) {
3803 if (!Map || Map->empty())
3808 GenerateNameLookupTable(DC, LookupTable);
3812 if (isa<NamespaceDecl>(DC))
3813 DC = cast<DeclContext>(Chain->getKeyDeclaration(cast<Decl>(DC)));
3816 RecordData::value_type Record[] = {
UPDATE_VISIBLE, getDeclID(cast<Decl>(DC))};
3817 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev, Record, LookupTable);
3821 void ASTWriter::WriteFPPragmaOptions(
const FPOptions &Opts) {
3822 RecordData::value_type Record[] = {Opts.
fp_contract};
3827 void ASTWriter::WriteOpenCLExtensions(
Sema &SemaRef) {
3833 #define OPENCLEXT(nm) Record.push_back(Opts.nm);
3834 #include "clang/Basic/OpenCLExtensions.def"
3838 void ASTWriter::WriteObjCCategories() {
3840 RecordData Categories;
3842 for (
unsigned I = 0, N = ObjCClassesWithCategories.size();
I != N; ++
I) {
3844 unsigned StartIndex = Categories.size();
3849 Categories.push_back(0);
3855 Cat != CatEnd; ++Cat, ++Size) {
3856 assert(getDeclID(*Cat) != 0 &&
"Bogus category");
3857 AddDeclRef(*Cat, Categories);
3861 Categories[StartIndex] = Size;
3865 CategoriesMap.push_back(CatInfo);
3870 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
3873 using namespace llvm;
3875 auto *Abbrev =
new BitCodeAbbrev();
3877 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3878 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3879 unsigned AbbrevID = Stream.EmitAbbrev(Abbrev);
3882 Stream.EmitRecordWithBlob(AbbrevID, Record,
3883 reinterpret_cast<char *>(CategoriesMap.data()),
3890 void ASTWriter::WriteLateParsedTemplates(
Sema &SemaRef) {
3897 for (
auto LPTMapEntry : LPTMap) {
3900 AddDeclRef(FD, Record);
3901 AddDeclRef(LPT->
D, Record);
3902 Record.push_back(LPT->
Toks.size());
3904 for (
const auto &Tok : LPT->
Toks) {
3905 AddToken(Tok, Record);
3912 void ASTWriter::WriteOptimizePragmaOptions(
Sema &SemaRef) {
3915 AddSourceLocation(PragmaLoc, Record);
3920 void ASTWriter::WriteMSStructPragmaOptions(
Sema &SemaRef) {
3928 void ASTWriter::WriteMSPointersToMembersPragmaOptions(
Sema &SemaRef) {
3935 void ASTWriter::WriteModuleFileExtension(
Sema &SemaRef,
3941 auto *Abv =
new llvm::BitCodeAbbrev();
3943 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
3944 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
3945 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
3946 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
3947 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
3948 unsigned Abbrev = Stream.EmitAbbrev(Abv);
3954 Record.push_back(Metadata.MajorVersion);
3955 Record.push_back(Metadata.MinorVersion);
3956 Record.push_back(Metadata.BlockName.size());
3957 Record.push_back(Metadata.UserInfo.size());
3959 Buffer += Metadata.BlockName;
3960 Buffer += Metadata.UserInfo;
3961 Stream.EmitRecordWithBlob(Abbrev, Record, Buffer);
3976 auto &Record = *
this;
3977 Record.push_back(Attrs.size());
3978 for (
const auto *A : Attrs) {
3979 Record.push_back(A->getKind());
3980 Record.AddSourceRange(A->getRange());
3982 #include "clang/Serialization/AttrPCHWrite.inc"
3995 Record.push_back(Tok.
getKind());
4001 Record.push_back(Str.size());
4002 Record.insert(Record.end(), Str.begin(), Str.end());
4006 assert(Context &&
"should have context when outputting path");
4012 const char *PathBegin = Path.data();
4013 const char *PathPtr =
4015 if (PathPtr != PathBegin) {
4016 Path.erase(Path.begin(), Path.begin() + (PathPtr - PathBegin));
4025 PreparePathForOutput(FilePath);
4026 AddString(FilePath, Record);
4032 PreparePathForOutput(FilePath);
4033 Stream.EmitRecordWithBlob(Abbrev, Record, FilePath);
4038 Record.push_back(Version.
getMajor());
4040 Record.push_back(*Minor + 1);
4042 Record.push_back(0);
4044 Record.push_back(*Subminor + 1);
4046 Record.push_back(0);
4052 IdentID ID = IdentifierIDs[II];
4055 if (ID >= FirstIdentID)
4056 IdentifierOffsets[ID - FirstIdentID] =
Offset;
4062 unsigned ID = SelectorIDs[Sel];
4063 assert(ID &&
"Unknown selector");
4066 if (ID < FirstSelectorID)
4068 SelectorOffsets[ID - FirstSelectorID] =
Offset;
4072 llvm::BitstreamWriter &Stream,
4074 bool IncludeTimestamps)
4075 : Stream(Stream), Context(nullptr), PP(nullptr), Chain(nullptr),
4076 WritingModule(nullptr), IncludeTimestamps(IncludeTimestamps),
4077 WritingAST(
false), DoneWritingDeclsAndTypes(
false),
4083 NextSubmoduleID(FirstSubmoduleID),
4085 NumStatements(0), NumMacros(0),
4086 NumLexicalDeclContexts(0), NumVisibleDeclContexts(0),
4087 TypeExtQualAbbrev(0), TypeFunctionProtoAbbrev(0), DeclParmVarAbbrev(0),
4088 DeclContextLexicalAbbrev(0), DeclContextVisibleLookupAbbrev(0),
4089 UpdateVisibleAbbrev(0), DeclRecordAbbrev(0), DeclTypedefAbbrev(0),
4090 DeclVarAbbrev(0), DeclFieldAbbrev(0), DeclEnumAbbrev(0),
4091 DeclObjCIvarAbbrev(0), DeclCXXMethodAbbrev(0), DeclRefExprAbbrev(0),
4092 CharacterLiteralAbbrev(0), IntegerLiteralAbbrev(0),
4093 ExprImplicitCastAbbrev(0) {
4094 for (
const auto &Ext : Extensions) {
4095 if (
auto Writer = Ext->createExtensionWriter(*
this))
4096 ModuleFileExtensionWriters.push_back(std::move(Writer));
4101 llvm::DeleteContainerSeconds(FileDeclIDs);
4105 assert(WritingAST &&
"can't determine lang opts when not writing AST");
4114 Module *WritingModule, StringRef isysroot,
4118 ASTHasCompilerErrors = hasErrors;
4121 Stream.Emit((
unsigned)
'C', 8);
4122 Stream.Emit((
unsigned)
'P', 8);
4123 Stream.Emit((
unsigned)
'C', 8);
4124 Stream.Emit((
unsigned)
'H', 8);
4126 WriteBlockInfoBlock();
4130 this->WritingModule = WritingModule;
4132 WriteASTCore(SemaRef, isysroot, OutputFile, WritingModule);
4135 this->WritingModule =
nullptr;
4136 this->BaseDirectory.clear();
4142 template<
typename Vector>
4151 uint64_t ASTWriter::WriteASTCore(
Sema &SemaRef, StringRef isysroot,
4152 const std::string &OutputFile,
4154 using namespace llvm;
4156 bool isModule = WritingModule !=
nullptr;
4160 Chain->finalizeForWriting();
4168 assert(D->isCanonicalDecl() &&
"predefined decl is not canonical");
4177 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
4181 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
4185 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
4188 RegisterPredefDecl(Context.MakeIntegerSeqDecl,
4190 RegisterPredefDecl(Context.CFConstantStringTypeDecl,
4192 RegisterPredefDecl(Context.CFConstantStringTagDecl,
4194 RegisterPredefDecl(Context.TypePackElementDecl,
4207 UnusedFileScopedDecls);
4221 WeakInfo &WI = WeakUndeclaredIdentifier.second;
4225 WeakUndeclaredIdentifiers.push_back(WI.
getUsed());
4235 for (
unsigned I = 0, N = SemaRef.
VTableUses.size();
I != N; ++
I) {
4245 AddDeclRef(TD, UnusedLocalTypedefNameCandidates);
4254 "There are local ones at end of translation unit!");
4270 for (
const auto &
I : SemaRef.KnownNamespaces) {
4280 for (
const auto &
I : Undefined) {
4289 for (
const auto &DeleteExprsInfo :
4291 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
4292 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
4293 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
4295 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
4300 uint64_t Signature = WriteControlBlock(PP, Context, isysroot, OutputFile);
4316 for (
const auto *D : TU->noload_decls()) {
4317 if (!D->isFromASTFile()) {
4318 NewGlobalKindDeclPairs.push_back(D->getKind());
4319 NewGlobalKindDeclPairs.push_back(
GetDeclRef(D));
4323 auto *Abv =
new llvm::BitCodeAbbrev();
4325 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4326 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(Abv);
4329 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev, Record,
4330 bytes(NewGlobalKindDeclPairs));
4334 Abv =
new llvm::BitCodeAbbrev();
4336 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4337 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4338 UpdateVisibleAbbrev = Stream.EmitAbbrev(Abv);
4339 WriteDeclContextVisibleUpdate(TU);
4342 if (Context.ExternCContext)
4343 WriteDeclContextVisibleUpdate(Context.ExternCContext);
4357 for (
const auto &Number : Context.MangleNumbers)
4358 if (!Number.first->isFromASTFile())
4361 for (
const auto &Number : Context.StaticLocalNumbers)
4362 if (!Number.first->isFromASTFile())
4368 for (
const auto *
I : UpdatingVisibleDecls) {
4382 std::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
4400 for (
auto &SelectorAndID : SelectorIDs)
4401 AllSelectors.push_back(SelectorAndID.first);
4402 for (
auto &
Selector : AllSelectors)
4411 AddTypeRef(Context.ObjCIdRedefinitionType, SpecialTypes);
4412 AddTypeRef(Context.ObjCClassRedefinitionType, SpecialTypes);
4413 AddTypeRef(Context.ObjCSelRedefinitionType, SpecialTypes);
4432 auto *Abbrev =
new BitCodeAbbrev();
4434 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4435 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(Abbrev);
4438 llvm::raw_svector_ostream Out(Buffer);
4440 using namespace llvm::support;
4441 endian::Writer<little> LE(Out);
4443 LE.write<uint16_t>(
FileName.size());
4450 auto writeBaseIDOrNone = [&](uint32_t BaseID,
bool ShouldWrite) {
4453 LE.write<uint32_t>(BaseID);
4455 LE.write<uint32_t>(
None);
4472 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev, Record,
4473 Buffer.data(), Buffer.size());
4484 WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord);
4485 while (!DeclTypesToEmit.empty()) {
4486 DeclOrType DOT = DeclTypesToEmit.front();
4487 DeclTypesToEmit.pop();
4489 WriteType(DOT.getType());
4491 WriteDecl(Context, DOT.getDecl());
4493 }
while (!DeclUpdates.empty());
4496 DoneWritingDeclsAndTypes =
true;
4499 WriteTypeDeclOffsets();
4500 if (!DeclUpdatesOffsetsRecord.empty())
4502 WriteFileDeclIDsMap();
4505 WritePreprocessor(PP, isModule);
4507 WriteSelectors(SemaRef);
4508 WriteReferencedSelectorsPool(SemaRef);
4509 WriteLateParsedTemplates(SemaRef);
4510 WriteIdentifierTable(PP, SemaRef.
IdResolver, isModule);
4512 WriteOpenCLExtensions(SemaRef);
4513 WritePragmaDiagnosticMappings(Context.
getDiagnostics(), isModule);
4517 WriteSubmodules(WritingModule);
4522 if (!EagerlyDeserializedDecls.empty())
4526 if (!TentativeDefinitions.empty())
4530 if (!UnusedFileScopedDecls.empty())
4534 if (!WeakUndeclaredIdentifiers.empty())
4536 WeakUndeclaredIdentifiers);
4539 if (!ExtVectorDecls.empty())
4543 if (!VTableUses.empty())
4547 if (!UnusedLocalTypedefNameCandidates.empty())
4549 UnusedLocalTypedefNameCandidates);
4552 if (!PendingInstantiations.empty())
4556 if (!SemaDeclRefs.empty())
4560 if (!CUDASpecialDeclRefs.empty())
4564 if (!DelegatingCtorDecls.empty())
4568 if (!KnownNamespaces.empty())
4572 if (!UndefinedButUsed.empty())
4575 if (!DeleteExprsToAnalyze.empty())
4579 for (
auto *DC : UpdatedDeclContexts)
4580 WriteDeclContextVisibleUpdate(DC);
4582 if (!WritingModule) {
4587 ModuleInfo(uint64_t ID,
Module *M) : ID(ID), M(M) {}
4591 assert(SubmoduleIDs.find(
I->getImportedModule()) != SubmoduleIDs.end());
4592 Imports.push_back(ModuleInfo(SubmoduleIDs[
I->getImportedModule()],
4593 I->getImportedModule()));
4596 if (!Imports.empty()) {
4597 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
4600 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
4601 return A.ID == B.ID;
4605 std::sort(Imports.begin(), Imports.end(), Cmp);
4606 Imports.erase(std::unique(Imports.begin(), Imports.end(), Eq),
4610 for (
const auto &Import : Imports) {
4611 ImportedModules.push_back(Import.ID);
4622 WriteObjCCategories();
4623 if(!WritingModule) {
4624 WriteOptimizePragmaOptions(SemaRef);
4625 WriteMSStructPragmaOptions(SemaRef);
4626 WriteMSPointersToMembersPragmaOptions(SemaRef);
4630 RecordData::value_type Record[] = {
4631 NumStatements, NumMacros, NumLexicalDeclContexts, NumVisibleDeclContexts};
4636 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
4637 WriteModuleFileExtension(SemaRef, *ExtWriter);
4642 void ASTWriter::WriteDeclUpdatesBlocks(
RecordDataImpl &OffsetsRecord) {
4643 if (DeclUpdates.empty())
4646 DeclUpdateMap LocalUpdates;
4647 LocalUpdates.swap(DeclUpdates);
4649 for (
auto &DeclUpdate : LocalUpdates) {
4650 const Decl *D = DeclUpdate.first;
4652 bool HasUpdatedBody =
false;
4655 for (
auto &Update : DeclUpdate.second) {
4661 HasUpdatedBody =
true;
4663 Record.push_back(Kind);
4669 assert(Update.getDecl() &&
"no decl to add?");
4670 Record.push_back(
GetDeclRef(Update.getDecl()));
4677 Record.AddSourceLocation(Update.getLoc());
4681 Record.AddStmt(const_cast<Expr *>(
4682 cast<ParmVarDecl>(Update.getDecl())->getDefaultArg()));
4686 auto *RD = cast<CXXRecordDecl>(D);
4687 UpdatedDeclContexts.insert(RD->getPrimaryContext());
4688 Record.AddCXXDefinitionData(RD);
4689 Record.AddOffset(WriteDeclContextLexicalBlock(
4690 *Context, const_cast<CXXRecordDecl *>(RD)));
4695 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
4696 Record.push_back(MSInfo->getTemplateSpecializationKind());
4697 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
4699 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
4700 Record.push_back(Spec->getTemplateSpecializationKind());
4701 Record.AddSourceLocation(Spec->getPointOfInstantiation());
4705 auto From = Spec->getInstantiatedFrom();
4706 if (
auto PartialSpec =
4708 Record.push_back(
true);
4709 Record.AddDeclRef(PartialSpec);
4710 Record.AddTemplateArgumentList(
4711 &Spec->getTemplateInstantiationArgs());
4713 Record.push_back(
false);
4716 Record.push_back(RD->getTagKind());
4717 Record.AddSourceLocation(RD->getLocation());
4718 Record.AddSourceLocation(RD->getLocStart());
4719 Record.AddSourceRange(RD->getBraceRange());
4722 Record.push_back(D->hasAttrs());
4724 Record.AddAttributes(D->getAttrs());
4731 Record.AddDeclRef(Update.getDecl());
4736 cast<FunctionDecl>(D)->getType()->castAs<FunctionProtoType>(),
4749 Record.push_back(Update.getNumber());
4753 Record.AddSourceRange(
4754 D->getAttr<OMPThreadPrivateDeclAttr>()->getRange());
4758 Record.AddSourceRange(
4759 D->getAttr<OMPDeclareTargetDeclAttr>()->getRange());
4763 Record.push_back(getSubmoduleID(Update.getModule()));
4767 Record.AddAttributes(llvm::makeArrayRef(Update.getAttr()));
4772 if (HasUpdatedBody) {
4773 const auto *Def = cast<FunctionDecl>(D);
4775 Record.push_back(Def->isInlined());
4776 Record.AddSourceLocation(Def->getInnerLocStart());
4777 Record.AddFunctionDefinition(Def);
4787 Record.push_back((Raw << 1) | (Raw >> 31));
4796 Record->push_back(Value.getBitWidth());
4797 const uint64_t *Words = Value.getRawData();
4798 Record->append(Words, Words + Value.getNumWords());
4802 Record->push_back(Value.isUnsigned());
4807 AddAPInt(Value.bitcastToAPInt());
4818 IdentID &ID = IdentifierIDs[II];
4834 MacroInfoToEmitData Info = {
Name, MI, ID };
4835 MacroInfosToEmit.push_back(Info);
4844 assert(MacroIDs.find(MI) != MacroIDs.end() &&
"Macro not emitted!");
4845 return MacroIDs[MI];
4849 return IdentMacroDirectivesOffsetMap.lookup(Name);
4853 Record->push_back(Writer->getSelectorRef(SelRef));
4862 if (SID == 0 && Chain) {
4865 Chain->LoadSelector(Sel);
4866 SID = SelectorIDs[Sel];
4869 SID = NextSelectorID++;
4870 SelectorIDs[Sel] = SID;
4911 bool InfoHasSameExpr
4913 Record->push_back(InfoHasSameExpr);
4914 if (InfoHasSameExpr)
4932 TypeLocWriter TLW(*
this);
4949 if (Idx.getIndex() == 0) {
4950 if (DoneWritingDeclsAndTypes) {
4951 assert(0 &&
"New type seen after serializing all the types to emit!");
4958 DeclTypesToEmit.push(T);
4971 TypeIdxMap::const_iterator
I = TypeIdxs.find(T);
4972 assert(I != TypeIdxs.end() &&
"Type not emitted!");
4982 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
4990 if (D->isFromASTFile())
4991 return D->getGlobalID();
4993 assert(!(reinterpret_cast<uintptr_t>(D) & 0x01) &&
"Invalid decl pointer");
4996 if (DoneWritingDeclsAndTypes) {
4997 assert(0 &&
"New decl seen after serializing all the decls to emit!");
5004 DeclTypesToEmit.push(const_cast<Decl *>(D));
5016 if (D->isFromASTFile())
5017 return D->getGlobalID();
5019 assert(DeclIDs.find(D) != DeclIDs.end() &&
"Declaration not emitted!");
5023 void ASTWriter::associateDeclWithFile(
const Decl *D,
DeclID ID) {
5032 if (!D->getLexicalDeclContext()->isFileContext())
5036 if (isa<ParmVarDecl>(D))
5045 if (FID.isInvalid())
5049 DeclIDInFileInfo *&Info = FileDeclIDs[FID];
5051 Info =
new DeclIDInFileInfo();
5053 std::pair<unsigned, serialization::DeclID> LocDecl(Offset, ID);
5054 LocDeclIDsTy &Decls = Info->DeclIDs;
5056 if (Decls.empty() || Decls.back().first <=
Offset) {
5057 Decls.push_back(LocDecl);
5062 std::upper_bound(Decls.begin(), Decls.end(), LocDecl, llvm::less_first());
5064 Decls.insert(I, LocDecl);
5103 "expected an anonymous declaration");
5107 auto It = AnonymousDeclarationNumbers.find(D);
5108 if (It == AnonymousDeclarationNumbers.end()) {
5109 auto *DC = D->getLexicalDeclContext();
5111 AnonymousDeclarationNumbers[ND] = Number;
5114 It = AnonymousDeclarationNumbers.find(D);
5115 assert(It != AnonymousDeclarationNumbers.end() &&
5116 "declaration not found within its lexical context");
5154 AddDeclarationName(NameInfo.
getName());
5173 NestedNames.push_back(NNS);
5177 Record->push_back(NestedNames.size());
5178 while(!NestedNames.empty()) {
5179 NNS = NestedNames.pop_back_val();
5181 Record->push_back(Kind);
5220 NestedNames.push_back(NNS);
5224 Record->push_back(NestedNames.size());
5225 while(!NestedNames.empty()) {
5226 NNS = NestedNames.pop_back_val();
5229 Record->push_back(Kind);
5267 Record->push_back(Kind);
5275 Record->push_back(OvT->
size());
5276 for (
const auto &I : *OvT)
5319 Record->push_back(Arg.
getKind());
5343 Record->push_back(*NumExpansions + 1);
5345 Record->push_back(0);
5353 AddTemplateArgument(
P);
5360 assert(TemplateParams &&
"No TemplateParams!");
5364 Record->push_back(TemplateParams->
size());
5365 for (
const auto &
P : *TemplateParams)
5372 assert(TemplateArgs &&
"No TemplateArgs!");
5373 Record->push_back(TemplateArgs->
size());
5374 for (
int i=0, e = TemplateArgs->
size(); i != e; ++i)
5375 AddTemplateArgument(TemplateArgs->
get(i));
5380 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
5386 AddTemplateArgumentLoc(TemplArgs[i]);
5390 Record->push_back(Set.
size());
5394 Record->push_back(I.getAccess());
5416 for (
auto &
Base : Bases)
5434 for (
auto *Init : CtorInits) {
5435 if (Init->isBaseInitializer()) {
5438 Writer.
push_back(Init->isBaseVirtual());
5439 }
else if (Init->isDelegatingInitializer()) {
5442 }
else if (Init->isMemberInitializer()){
5447 Writer.
AddDeclRef(Init->getIndirectMember());
5451 Writer.
AddStmt(Init->getInit());
5455 if (Init->isWritten()) {
5456 Writer.
push_back(Init->getSourceOrder());
5458 Writer.
push_back(Init->getNumArrayIndices());
5459 for (
auto *VD : Init->getArrayIndices())
5474 auto &Data = D->data();
5475 Record->push_back(Data.IsLambda);
5476 Record->push_back(Data.UserDeclaredConstructor);
5477 Record->push_back(Data.UserDeclaredSpecialMembers);
5478 Record->push_back(Data.Aggregate);
5479 Record->push_back(Data.PlainOldData);
5480 Record->push_back(Data.Empty);
5481 Record->push_back(Data.Polymorphic);
5482 Record->push_back(Data.Abstract);
5483 Record->push_back(Data.IsStandardLayout);
5484 Record->push_back(Data.HasNoNonEmptyBases);
5485 Record->push_back(Data.HasPrivateFields);
5486 Record->push_back(Data.HasProtectedFields);
5487 Record->push_back(Data.HasPublicFields);
5488 Record->push_back(Data.HasMutableFields);
5489 Record->push_back(Data.HasVariantMembers);
5490 Record->push_back(Data.HasOnlyCMembers);
5491 Record->push_back(Data.HasInClassInitializer);
5492 Record->push_back(Data.HasUninitializedReferenceMember);
5493 Record->push_back(Data.HasUninitializedFields);
5494 Record->push_back(Data.HasInheritedConstructor);
5495 Record->push_back(Data.HasInheritedAssignment);
5496 Record->push_back(Data.NeedOverloadResolutionForMoveConstructor);
5497 Record->push_back(Data.NeedOverloadResolutionForMoveAssignment);
5498 Record->push_back(Data.NeedOverloadResolutionForDestructor);
5499 Record->push_back(Data.DefaultedMoveConstructorIsDeleted);
5500 Record->push_back(Data.DefaultedMoveAssignmentIsDeleted);
5501 Record->push_back(Data.DefaultedDestructorIsDeleted);
5502 Record->push_back(Data.HasTrivialSpecialMembers);
5503 Record->push_back(Data.DeclaredNonTrivialSpecialMembers);
5504 Record->push_back(Data.HasIrrelevantDestructor);
5505 Record->push_back(Data.HasConstexprNonCopyMoveConstructor);
5506 Record->push_back(Data.HasDefaultedDefaultConstructor);
5507 Record->push_back(Data.DefaultedDefaultConstructorIsConstexpr);
5508 Record->push_back(Data.HasConstexprDefaultConstructor);
5509 Record->push_back(Data.HasNonLiteralTypeFieldsOrBases);
5510 Record->push_back(Data.ComputedVisibleConversions);
5511 Record->push_back(Data.UserProvidedDefaultConstructor);
5512 Record->push_back(Data.DeclaredSpecialMembers);
5513 Record->push_back(Data.ImplicitCopyConstructorHasConstParam);
5514 Record->push_back(Data.ImplicitCopyAssignmentHasConstParam);
5515 Record->push_back(Data.HasDeclaredCopyConstructorWithConstParam);
5516 Record->push_back(Data.HasDeclaredCopyAssignmentWithConstParam);
5519 Record->push_back(Data.NumBases);
5520 if (Data.NumBases > 0)
5521 AddCXXBaseSpecifiers(Data.bases());
5524 Record->push_back(Data.NumVBases);
5525 if (Data.NumVBases > 0)
5526 AddCXXBaseSpecifiers(Data.vbases());
5528 AddUnresolvedSet(Data.Conversions.get(*Writer->Context));
5529 AddUnresolvedSet(Data.VisibleConversions.get(*Writer->Context));
5534 if (Data.IsLambda) {
5535 auto &Lambda = D->getLambdaData();
5536 Record->push_back(Lambda.Dependent);
5537 Record->push_back(Lambda.IsGenericLambda);
5538 Record->push_back(Lambda.CaptureDefault);
5539 Record->push_back(Lambda.NumCaptures);
5540 Record->push_back(Lambda.NumExplicitCaptures);
5541 Record->push_back(Lambda.ManglingNumber);
5543 AddTypeSourceInfo(Lambda.MethodTyInfo);
5544 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
5567 void ASTWriter::ReaderInitialized(
ASTReader *Reader) {
5568 assert(Reader &&
"Cannot remove chain");
5569 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
5570 assert(FirstDeclID == NextDeclID &&
5571 FirstTypeID == NextTypeID &&
5572 FirstIdentID == NextIdentID &&
5573 FirstMacroID == NextMacroID &&
5574 FirstSubmoduleID == NextSubmoduleID &&
5575 FirstSelectorID == NextSelectorID &&
5576 "Setting chain after writing has started.");
5588 NextDeclID = FirstDeclID;
5589 NextTypeID = FirstTypeID;
5590 NextIdentID = FirstIdentID;
5591 NextMacroID = FirstMacroID;
5592 NextSelectorID = FirstSelectorID;
5593 NextSubmoduleID = FirstSubmoduleID;
5598 IdentID &StoredID = IdentifierIDs[II];
5605 MacroID &StoredID = MacroIDs[MI];
5616 TypeIdx &StoredIdx = TypeIdxs[T];
5630 assert(MacroDefinitions.find(MD) == MacroDefinitions.end());
5631 MacroDefinitions[MD] =
ID;
5635 assert(SubmoduleIDs.find(Mod) == SubmoduleIDs.end());
5636 SubmoduleIDs[Mod] =
ID;
5639 void ASTWriter::CompletedTagDefinition(
const TagDecl *D) {
5640 if (Chain && Chain->isProcessingUpdateRecords())
return;
5642 assert(!WritingAST &&
"Already writing the AST!");
5643 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
5645 if (RD->isFromASTFile()) {
5650 "completed a tag from another module but not by instantiation?");
5651 DeclUpdates[RD].push_back(
5658 if (D->isFromASTFile())
5663 return D == D->getASTContext().getVaListTagDecl();
5666 void ASTWriter::AddedVisibleDecl(
const DeclContext *DC,
const Decl *D) {
5667 if (Chain && Chain->isProcessingUpdateRecords())
return;
5669 "Should not add lookup results to non-lookup contexts!");
5672 if (isa<TranslationUnitDecl>(DC))
5679 if (isa<NamespaceDecl>(DC) && D->getFriendObjectKind() == Decl::FOK_None &&
5680 !isa<FunctionTemplateDecl>(D))
5690 assert(!WritingAST &&
"Already writing the AST!");
5691 if (UpdatedDeclContexts.insert(DC) && !cast<Decl>(DC)->isFromASTFile()) {
5695 for (
auto *Child : DC->
decls())
5696 UpdatingVisibleDecls.push_back(Child);
5698 UpdatingVisibleDecls.push_back(D);
5701 void ASTWriter::AddedCXXImplicitMember(
const CXXRecordDecl *RD,
const Decl *D) {
5702 if (Chain && Chain->isProcessingUpdateRecords())
return;
5703 assert(D->isImplicit());
5710 if (!isa<CXXMethodDecl>(D))
5715 assert(!WritingAST &&
"Already writing the AST!");
5719 void ASTWriter::ResolvedExceptionSpec(
const FunctionDecl *FD) {
5720 if (Chain && Chain->isProcessingUpdateRecords())
return;
5721 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
5723 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
5728 ->castAs<FunctionProtoType>()
5729 ->getExceptionSpecType()))
5735 if (Chain && Chain->isProcessingUpdateRecords())
return;
5736 assert(!WritingAST &&
"Already writing the AST!");
5738 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
5739 DeclUpdates[D].push_back(
5746 if (Chain && Chain->isProcessingUpdateRecords())
return;
5747 assert(!WritingAST &&
"Already writing the AST!");
5748 assert(Delete &&
"Not given an operator delete");
5750 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
5755 void ASTWriter::CompletedImplicitDefinition(
const FunctionDecl *D) {
5756 if (Chain && Chain->isProcessingUpdateRecords())
return;
5757 assert(!WritingAST &&
"Already writing the AST!");
5758 if (!D->isFromASTFile())
5765 void ASTWriter::FunctionDefinitionInstantiated(
const FunctionDecl *D) {
5766 if (Chain && Chain->isProcessingUpdateRecords())
return;
5767 assert(!WritingAST &&
"Already writing the AST!");
5768 if (!D->isFromASTFile())
5774 void ASTWriter::StaticDataMemberInstantiated(
const VarDecl *D) {
5775 if (Chain && Chain->isProcessingUpdateRecords())
return;
5776 assert(!WritingAST &&
"Already writing the AST!");
5777 if (!D->isFromASTFile())
5782 DeclUpdates[D].push_back(
5787 void ASTWriter::DefaultArgumentInstantiated(
const ParmVarDecl *D) {
5788 if (Chain && Chain->isProcessingUpdateRecords())
return;
5789 assert(!WritingAST &&
"Already writing the AST!");
5790 if (!D->isFromASTFile())
5793 DeclUpdates[D].push_back(
5799 if (Chain && Chain->isProcessingUpdateRecords())
return;
5800 assert(!WritingAST &&
"Already writing the AST!");
5801 if (!IFD->isFromASTFile())
5804 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
5805 ObjCClassesWithCategories.insert(
5809 void ASTWriter::DeclarationMarkedUsed(
const Decl *D) {
5810 if (Chain && Chain->isProcessingUpdateRecords())
return;
5811 assert(!WritingAST &&
"Already writing the AST!");
5816 for (
auto Prev = D->getMostRecentDecl(); Prev; Prev = Prev->getPreviousDecl())
5823 void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(
const Decl *D) {
5824 if (Chain && Chain->isProcessingUpdateRecords())
return;
5825 assert(!WritingAST &&
"Already writing the AST!");
5826 if (!D->isFromASTFile())
5832 void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
5834 if (Chain && Chain->isProcessingUpdateRecords())
return;
5835 assert(!WritingAST &&
"Already writing the AST!");
5836 if (!D->isFromASTFile())
5839 DeclUpdates[D].push_back(
5843 void ASTWriter::RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M) {
5844 if (Chain && Chain->isProcessingUpdateRecords())
return;
5845 assert(!WritingAST &&
"Already writing the AST!");
5846 assert(D->
isHidden() &&
"expected a hidden declaration");
5850 void ASTWriter::AddedAttributeToRecord(
const Attr *Attr,
5852 if (Chain && Chain->isProcessingUpdateRecords())
return;
5853 assert(!WritingAST &&
"Already writing the AST!");
5854 if (!Record->isFromASTFile())
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
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.
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
Record code for the signature that identifiers this AST file.
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.
llvm::iterator_range< pack_iterator > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
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.
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
ArrayRef< const IdentifierInfo * > args() const
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.
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 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...
CXXRecordDecl * getDecl() const
RawCommentList Comments
All comments in this translation unit.
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
An ImplicitValueInitExpr record.
unsigned getNextLocalOffset() const
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
An ImplicitCastExpr record.
Defines the FileSystemStatCache interface.
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...
An LValueReferenceType record.
static unsigned getNumberOfModules(Module *Mod)
Compute the number of modules within the given tree (including the given module). ...
Defines the clang::MacroInfo and clang::MacroDirective classes.
A CXXOperatorCallExpr record.
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.
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.
DependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, ArrayRef< TemplateArgument > Args, QualType Canon)
Represents an array type, per C99 6.7.5.2 - Array Declarators.
TemplateTemplateParmDecl * getParameterPack() const
Retrieve the template template parameter pack being substituted.
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
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.
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.
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...
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. ...
bool hasAttrExprOperand() const
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.
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.
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.
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.
Record code for the diagnostic options table.
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.
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.
DeclarationName getName() const
getName - Returns the embedded declaration name.
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.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
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.
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.
Delete expressions that will be analyzed later.
unsigned ASTFileSignature
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
llvm::MapVector< const FunctionDecl *, LateParsedTemplate * > LateParsedTemplateMapT
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.
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.
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.
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.
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
Wrapper for source info for injected class names of class templates.
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
< Capturing the *this object by copy
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.
QualType getReturnType() const
Wrapper for source info for functions.
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
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
Record code for #pragma diagnostic mappings.
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.
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
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.
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.
tok::TokenKind getKind() const
A BlockPointerType record.
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
A MemberPointerType record.
Represents an ObjC class declaration.
ObjCMethodDecl * getMethod() const
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.
QualType getCanonicalTypeInternal() const
Record code for the table of offsets into the block of source-location information.
serialization::SubmoduleID inferSubmoduleIDFromLocation(SourceLocation Loc)
Infer the submodule ID that contains an entity at the given source location.
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.
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.
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.
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...
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...
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.
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.
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 getNumArgs() 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.
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.
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.
serialization::TypeID GetOrCreateTypeID(QualType T)
Force a type to be emitted and get its ID.
SourceLocation getLParenLoc() const
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*.
void AddString(StringRef Str, RecordDataImpl &Record)
Add a string to the given record.
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...
bool isSubModuleOf(const Module *Other) const
Determine whether this module is a submodule of the given other module.
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.
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.
Record code for an update to a decl context's lookup table.
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)
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.
Record code for the identifier table.
A FileScopeAsmDecl record.
A ObjCCompatibleAliasDecl record.
SourceLocation getProtocolRAngleLoc() const
SmallVector< ExportDecl, 2 > Exports
The set of export declarations.
SourceLocation getTemplateNameLoc() const
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.
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.
NestedNameSpecifierLoc getTemplateQualifierLoc() 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.
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.
const char * getName() const
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.
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.
const TemplateArgument * iterator
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...
void AddDeclarationName(DeclarationName Name)
Emit a declaration name.
TagDecl - Represents the declaration of a struct/union/class/enum.
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
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)
SmallVector< Header, 2 > Headers[5]
The headers that are part of this module.
A CXXFunctionalCastExpr record.
A FloatingLiteral record.
Record code for the offsets of each decl.
SourceLocation getTemplateEllipsisLoc() const
SourceLocation getNameLoc() const
Metadata for submodules as a whole.
SourceLocation getDefinitionEndLoc() const
Return the location of the last token in the macro.
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.
static ASTFileSignature getSignature()
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.
TypedefNameDecl * getDecl() const
DiagnosticOptions & getDiagnosticOptions() const
Retrieve the diagnostic options.
TypeSpecifierType getWrittenTypeSpec() const
unsigned getNumProtocols() const
Return the number of qualifying protocols in this interface type, or 0 if there are none...
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
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.
Record code for the extra statistics we gather while generating an AST file.
FunctionDecl * getcudaConfigureCallDecl()
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...
unsigned LocalNumSubmodules
The number of submodules in this module.
unsigned ComputeHash(Selector Sel)
DiagnosticsEngine & getDiagnostics() 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. ...
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...
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
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.
Module * inferModuleFromLocation(FullSourceLoc Loc)
Infers the (sub)module based on the given source location and source manager.
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.
SourceLocation getTemplateKeywordLoc() const
bool isGNUVarargs() const
bool isParameterPack() 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.
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...
unsigned Map[Count]
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
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.
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
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.
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.
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.
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.
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.
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.
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.
SourceLocation getRParenLoc() const
Location information for a TemplateArgument.
A ObjCAtDefsFieldDecl record.
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.
uint64_t WriteAST(Sema &SemaRef, const std::string &OutputFile, Module *WritingModule, StringRef isysroot, bool hasErrors=false)
Write a precompiled header for the given semantic analysis.
Defines the clang::TargetInfo interface.
MacroDefinitionRecord * findMacroDefinition(const MacroInfo *MI)
Retrieve the macro definition that corresponds to the given MacroInfo.
A SourceLocation and its associated SourceManager.
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 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
TypeSourceInfo * getAsTypeSourceInfo() 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.
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.
llvm::DenseMap< CXXRecordDecl *, bool > VTablesUsed
The set of classes whose vtables have been used within this translation unit, and a bit that will be ...
A TypeAliasTemplateDecl record.
Contains a late templated function.
OverloadedOperatorKind getOperatorKind() const
Record code for weak undeclared identifiers.
The block containing information about the preprocessor.
void AddTemplateName(TemplateName Name)
Emit a template name.
SourceLocation getAmpLoc() const
SourceLocation getLAngleLoc() const
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg)
Emits a template argument location.
uint32_t TypeID
An ID number that refers to a type in an AST file.
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.
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.
Wrapper for source info for block pointers.
TemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon, QualType Aliased)
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.
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.
ASTWriter(llvm::BitstreamWriter &Stream, ArrayRef< llvm::IntrusiveRefCntPtr< ModuleFileExtension >> Extensions, bool IncludeTimestamps=true)
Create a new precompiled header writer that outputs to the given bitstream.
A single template declaration.
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
SourceLocation getLocation() const
SourceLocation getStarLoc() const
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.
bool isHidden() const
Determine whether this declaration is hidden from name lookup.
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
QualType getDeducedType() const
Get the type deduced for this auto type, or null if it's either not been deduced or was deduced to a ...