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/EndianStream.h"
54 #include "llvm/Support/FileSystem.h"
55 #include "llvm/Support/MemoryBuffer.h"
56 #include "llvm/Support/OnDiskHashTable.h"
57 #include "llvm/Support/Path.h"
58 #include "llvm/Support/Process.h"
64 using namespace clang;
65 using namespace clang::serialization;
67 template <
typename T,
typename Allocator>
68 static StringRef
bytes(
const std::vector<T, Allocator> &
v) {
69 if (v.empty())
return StringRef();
70 return StringRef(reinterpret_cast<const char*>(&v[0]),
71 sizeof(T) * v.size());
76 return StringRef(reinterpret_cast<const char*>(v.data()),
77 sizeof(T) * v.size());
100 void VisitTagType(
const TagType *T);
102 #define TYPE(Class, Base) void Visit##Class##Type(const Class##Type *T);
103 #define ABSTRACT_TYPE(Class, Base)
104 #include "clang/AST/TypeNodes.def"
108 void ASTTypeWriter::VisitBuiltinType(
const BuiltinType *T) {
109 llvm_unreachable(
"Built-in types are never serialized");
112 void ASTTypeWriter::VisitComplexType(
const ComplexType *T) {
117 void ASTTypeWriter::VisitPointerType(
const PointerType *T) {
122 void ASTTypeWriter::VisitDecayedType(
const DecayedType *T) {
127 void ASTTypeWriter::VisitAdjustedType(
const AdjustedType *T) {
155 void ASTTypeWriter::VisitArrayType(
const ArrayType *T) {
163 Writer.AddAPInt(T->
getSize(), Record);
180 void ASTTypeWriter::VisitVectorType(
const VectorType *T) {
187 void ASTTypeWriter::VisitExtVectorType(
const ExtVectorType *T) {
192 void ASTTypeWriter::VisitFunctionType(
const FunctionType *T) {
199 Record.push_back(C.
getCC());
207 VisitFunctionType(T);
229 VisitFunctionType(T);
249 Writer.AddDeclRef(T->
getDecl(), Record);
253 void ASTTypeWriter::VisitTypedefType(
const TypedefType *T) {
254 Writer.AddDeclRef(T->
getDecl(), Record);
260 void ASTTypeWriter::VisitTypeOfExprType(
const TypeOfExprType *T) {
265 void ASTTypeWriter::VisitTypeOfType(
const TypeOfType *T) {
270 void ASTTypeWriter::VisitDecltypeType(
const DecltypeType *T) {
283 void ASTTypeWriter::VisitAutoType(
const AutoType *T) {
291 void ASTTypeWriter::VisitTagType(
const TagType *T) {
295 "Cannot serialize in the middle of a type definition");
298 void ASTTypeWriter::VisitRecordType(
const RecordType *T) {
303 void ASTTypeWriter::VisitEnumType(
const EnumType *T) {
308 void ASTTypeWriter::VisitAttributedType(
const AttributedType *T) {
316 ASTTypeWriter::VisitSubstTemplateTypeParmType(
324 ASTTypeWriter::VisitSubstTemplateTypeParmPackType(
332 ASTTypeWriter::VisitTemplateSpecializationType(
334 Record.push_back(T->isDependentType());
335 Writer.AddTemplateName(T->getTemplateName(), Record);
336 Record.push_back(T->getNumArgs());
337 for (
const auto &ArgI : *T)
338 Writer.AddTemplateArgument(ArgI, Record);
339 Writer.AddTypeRef(T->isTypeAlias() ? T->getAliasedType() :
340 T->isCanonicalUnqualified() ?
QualType()
341 : T->getCanonicalTypeInternal(),
355 ASTTypeWriter::VisitDependentSizedExtVectorType(
358 llvm_unreachable(
"Cannot serialize dependent sized extended vector types");
366 Writer.AddDeclRef(T->
getDecl(), Record);
373 Writer.AddNestedNameSpecifier(T->
getQualifier(), Record);
376 : T->getCanonicalTypeInternal(),
382 ASTTypeWriter::VisitDependentTemplateSpecializationType(
384 Record.push_back(T->getKeyword());
385 Writer.AddNestedNameSpecifier(T->getQualifier(), Record);
386 Writer.AddIdentifierRef(T->getIdentifier(), Record);
387 Record.push_back(T->getNumArgs());
388 for (
const auto &
I : *T)
389 Writer.AddTemplateArgument(
I, Record);
396 Record.push_back(*NumExpansions + 1);
402 void ASTTypeWriter::VisitParenType(
const ParenType *T) {
407 void ASTTypeWriter::VisitElaboratedType(
const ElaboratedType *T) {
409 Writer.AddNestedNameSpecifier(T->
getQualifier(), Record);
425 void ASTTypeWriter::VisitObjCObjectType(
const ObjCObjectType *T) {
429 Writer.AddTypeRef(TypeArg, Record);
431 for (
const auto *
I : T->
quals())
432 Writer.AddDeclRef(
I, Record);
444 ASTTypeWriter::VisitAtomicType(
const AtomicType *T) {
450 ASTTypeWriter::VisitPipeType(
const PipeType *T) {
463 : Writer(Writer), Record(Record) { }
465 #define ABSTRACT_TYPELOC(CLASS, PARENT)
466 #define TYPELOC(CLASS, PARENT) \
467 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
468 #include "clang/AST/TypeLocNodes.def"
489 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
492 Writer.AddSourceLocation(TL.
getStarLoc(), Record);
501 Writer.AddSourceLocation(TL.
getCaretLoc(), Record);
504 Writer.AddSourceLocation(TL.
getAmpLoc(), Record);
510 Writer.AddSourceLocation(TL.
getStarLoc(), Record);
513 void TypeLocWriter::VisitArrayTypeLoc(
ArrayTypeLoc TL) {
521 VisitArrayTypeLoc(TL);
524 VisitArrayTypeLoc(TL);
527 VisitArrayTypeLoc(TL);
529 void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
531 VisitArrayTypeLoc(TL);
533 void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
535 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
538 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
541 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
548 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i)
549 Writer.AddDeclRef(TL.
getParam(i), Record);
552 VisitFunctionTypeLoc(TL);
555 VisitFunctionTypeLoc(TL);
558 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
561 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
575 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
578 Writer.AddSourceLocation(TL.
getKWLoc(), Record);
583 void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
584 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
587 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
589 void TypeLocWriter::VisitEnumTypeLoc(
EnumTypeLoc TL) {
590 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
593 Writer.AddSourceLocation(TL.getAttrNameLoc(), Record);
596 Writer.AddSourceLocation(range.
getBegin(), Record);
597 Writer.AddSourceLocation(range.
getEnd(), Record);
600 Expr *operand = TL.getAttrExprOperand();
601 Record.push_back(operand ? 1 : 0);
602 if (operand) Writer.AddStmt(operand);
608 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
610 void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
612 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
614 void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
616 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
618 void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
624 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
628 void TypeLocWriter::VisitParenTypeLoc(
ParenTypeLoc TL) {
637 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
642 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
644 void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
660 Writer.AddSourceLocation(TL.
getNameLoc(), Record);
674 Writer.AddSourceLocation(TL.
getStarLoc(), Record);
677 Writer.AddSourceLocation(TL.
getKWLoc(), Record);
681 void TypeLocWriter::VisitPipeTypeLoc(
PipeTypeLoc TL) {
682 Writer.AddSourceLocation(TL.
getKWLoc(), Record);
685 void ASTWriter::WriteTypeAbbrevs() {
686 using namespace llvm;
691 Abv =
new BitCodeAbbrev();
693 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
694 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
695 TypeExtQualAbbrev = Stream.EmitAbbrev(Abv);
698 Abv =
new BitCodeAbbrev();
701 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
702 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
703 Abv->Add(BitCodeAbbrevOp(0));
704 Abv->Add(BitCodeAbbrevOp(0));
705 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
706 Abv->Add(BitCodeAbbrevOp(0));
708 Abv->Add(BitCodeAbbrevOp(0));
709 Abv->Add(BitCodeAbbrevOp(0));
710 Abv->Add(BitCodeAbbrevOp(0));
711 Abv->Add(BitCodeAbbrevOp(0));
712 Abv->Add(BitCodeAbbrevOp(
EST_None));
713 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
714 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
715 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
716 TypeFunctionProtoAbbrev = Stream.EmitAbbrev(Abv);
724 llvm::BitstreamWriter &Stream,
727 Record.push_back(ID);
728 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);
731 if (!Name || Name[0] == 0)
735 Record.push_back(*Name++);
736 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME, Record);
740 llvm::BitstreamWriter &Stream,
743 Record.push_back(ID);
745 Record.push_back(*Name++);
746 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, Record);
751 #define RECORD(X) EmitRecordID(X, #X, Stream, Record)
878 void ASTWriter::WriteBlockInfoBlock() {
880 Stream.EnterSubblock(llvm::bitc::BLOCKINFO_BLOCK_ID, 3);
882 #define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
883 #define RECORD(X) EmitRecordID(X, #X, Stream, Record)
886 BLOCK(CONTROL_BLOCK);
898 BLOCK(OPTIONS_BLOCK);
906 BLOCK(INPUT_FILES_BLOCK);
961 BLOCK(SOURCE_MANAGER_BLOCK);
968 BLOCK(PREPROCESSOR_BLOCK);
976 BLOCK(SUBMODULE_BLOCK);
995 BLOCK(COMMENTS_BLOCK);
999 BLOCK(DECLTYPES_BLOCK);
1102 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
1108 BLOCK(EXTENSION_BLOCK);
1123 return Changed | llvm::sys::path::remove_dots(Path);
1138 assert(Filename &&
"No file name to adjust?");
1140 if (BaseDir.empty())
1145 for (; Filename[Pos] && Pos < BaseDir.size(); ++Pos)
1146 if (Filename[Pos] != BaseDir[Pos])
1155 if (!llvm::sys::path::is_separator(Filename[Pos])) {
1156 if (!llvm::sys::path::is_separator(BaseDir.back()))
1170 return Filename + Pos;
1182 uint64_t ASTWriter::WriteControlBlock(
Preprocessor &PP,
1185 const std::string &OutputFile) {
1188 using namespace llvm;
1193 auto *MetadataAbbrev =
new BitCodeAbbrev();
1194 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1195 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1196 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1197 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1198 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1199 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1200 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1201 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1202 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1203 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(MetadataAbbrev);
1204 assert((!WritingModule || isysroot.empty()) &&
1205 "writing module as a relocatable PCH?");
1208 CLANG_VERSION_MAJOR, CLANG_VERSION_MINOR,
1209 !isysroot.empty(), IncludeTimestamps,
1210 ASTHasCompilerErrors};
1211 Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
1214 if (WritingModule) {
1221 RecordData::value_type Record[] = {Signature};
1226 auto *Abbrev =
new BitCodeAbbrev();
1228 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1229 unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
1231 Stream.EmitRecordWithBlob(AbbrevCode, Record, WritingModule->Name);
1234 if (WritingModule && WritingModule->Directory) {
1244 WritingModule->Directory->getName() != StringRef(
".")) {
1246 auto *Abbrev =
new BitCodeAbbrev();
1248 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1249 unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
1252 Stream.EmitRecordWithBlob(AbbrevCode, Record, BaseDir);
1256 BaseDirectory.assign(BaseDir.begin(), BaseDir.end());
1257 }
else if (!isysroot.empty()) {
1259 BaseDirectory = isysroot;
1263 if (WritingModule) {
1269 AddPath(
Map.getModuleMapFileForUniquing(WritingModule)->getName(), Record);
1272 if (
auto *AdditionalModMaps =
1273 Map.getAdditionalModuleMapFiles(WritingModule)) {
1274 Record.push_back(AdditionalModMaps->size());
1275 for (
const FileEntry *F : *AdditionalModMaps)
1276 AddPath(F->getName(), Record);
1278 Record.push_back(0);
1289 for (
auto *M : Mgr) {
1291 if (!M->isDirectlyImported())
1294 Record.push_back((
unsigned)M->Kind);
1295 AddSourceLocation(M->ImportLoc, Record);
1296 Record.push_back(M->File->getSize());
1297 Record.push_back(getTimestampForOutput(M->File));
1298 Record.push_back(M->Signature);
1299 AddPath(M->FileName, Record);
1301 Stream.EmitRecord(
IMPORTS, Record);
1310 #define LANGOPT(Name, Bits, Default, Description) \
1311 Record.push_back(LangOpts.Name);
1312 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
1313 Record.push_back(static_cast<unsigned>(LangOpts.get##Name()));
1314 #include "clang/Basic/LangOptions.def"
1315 #define SANITIZER(NAME, ID) \
1316 Record.push_back(LangOpts.Sanitize.has(SanitizerKind::ID));
1317 #include "clang/Basic/Sanitizers.def"
1319 Record.push_back(LangOpts.ModuleFeatures.size());
1320 for (StringRef Feature : LangOpts.ModuleFeatures)
1321 AddString(Feature, Record);
1323 Record.push_back((
unsigned) LangOpts.ObjCRuntime.getKind());
1324 AddVersionTuple(LangOpts.ObjCRuntime.getVersion(), Record);
1326 AddString(LangOpts.CurrentModule, Record);
1329 Record.push_back(LangOpts.CommentOpts.BlockCommandNames.size());
1330 for (
const auto &
I : LangOpts.CommentOpts.BlockCommandNames) {
1331 AddString(
I, Record);
1333 Record.push_back(LangOpts.CommentOpts.ParseAllComments);
1336 Record.push_back(LangOpts.OMPTargetTriples.size());
1337 for (
auto &T : LangOpts.OMPTargetTriples)
1338 AddString(T.getTriple(), Record);
1340 AddString(LangOpts.OMPHostIRFile, Record);
1348 AddString(TargetOpts.Triple, Record);
1349 AddString(TargetOpts.CPU, Record);
1350 AddString(TargetOpts.ABI, Record);
1351 Record.push_back(TargetOpts.FeaturesAsWritten.size());
1352 for (
unsigned I = 0, N = TargetOpts.FeaturesAsWritten.size();
I != N; ++
I) {
1353 AddString(TargetOpts.FeaturesAsWritten[
I], Record);
1355 Record.push_back(TargetOpts.Features.size());
1356 for (
unsigned I = 0, N = TargetOpts.Features.size();
I != N; ++
I) {
1357 AddString(TargetOpts.Features[
I], Record);
1365 #define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name);
1366 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
1367 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name()));
1368 #include "clang/Basic/DiagnosticOptions.def"
1369 Record.push_back(DiagOpts.Warnings.size());
1370 for (
unsigned I = 0, N = DiagOpts.Warnings.size();
I != N; ++
I)
1371 AddString(DiagOpts.Warnings[
I], Record);
1372 Record.push_back(DiagOpts.Remarks.size());
1373 for (
unsigned I = 0, N = DiagOpts.Remarks.size();
I != N; ++
I)
1374 AddString(DiagOpts.Remarks[
I], Record);
1383 AddString(FSOpts.WorkingDir, Record);
1390 AddString(HSOpts.Sysroot, Record);
1393 Record.push_back(HSOpts.UserEntries.size());
1394 for (
unsigned I = 0, N = HSOpts.UserEntries.size();
I != N; ++
I) {
1396 AddString(Entry.
Path, Record);
1397 Record.push_back(static_cast<unsigned>(Entry.
Group));
1403 Record.push_back(HSOpts.SystemHeaderPrefixes.size());
1404 for (
unsigned I = 0, N = HSOpts.SystemHeaderPrefixes.size();
I != N; ++
I) {
1405 AddString(HSOpts.SystemHeaderPrefixes[
I].Prefix, Record);
1406 Record.push_back(HSOpts.SystemHeaderPrefixes[
I].IsSystemHeader);
1409 AddString(HSOpts.ResourceDir, Record);
1410 AddString(HSOpts.ModuleCachePath, Record);
1411 AddString(HSOpts.ModuleUserBuildPath, Record);
1412 Record.push_back(HSOpts.DisableModuleHash);
1413 Record.push_back(HSOpts.UseBuiltinIncludes);
1414 Record.push_back(HSOpts.UseStandardSystemIncludes);
1415 Record.push_back(HSOpts.UseStandardCXXIncludes);
1416 Record.push_back(HSOpts.UseLibcxx);
1426 Record.push_back(PPOpts.Macros.size());
1427 for (
unsigned I = 0, N = PPOpts.Macros.size();
I != N; ++
I) {
1428 AddString(PPOpts.Macros[
I].first, Record);
1429 Record.push_back(PPOpts.Macros[
I].second);
1433 Record.push_back(PPOpts.Includes.size());
1434 for (
unsigned I = 0, N = PPOpts.Includes.size();
I != N; ++
I)
1435 AddString(PPOpts.Includes[
I], Record);
1438 Record.push_back(PPOpts.MacroIncludes.size());
1439 for (
unsigned I = 0, N = PPOpts.MacroIncludes.size();
I != N; ++
I)
1440 AddString(PPOpts.MacroIncludes[
I], Record);
1442 Record.push_back(PPOpts.UsePredefines);
1444 Record.push_back(PPOpts.DetailedRecord);
1445 AddString(PPOpts.ImplicitPCHInclude, Record);
1446 AddString(PPOpts.ImplicitPTHInclude, Record);
1447 Record.push_back(static_cast<unsigned>(PPOpts.ObjCXXARCStandardLibrary));
1456 auto *FileAbbrev =
new BitCodeAbbrev();
1458 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1459 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1460 unsigned FileAbbrevCode = Stream.EmitAbbrev(FileAbbrev);
1465 EmitRecordWithPath(FileAbbrevCode, Record, MainFile->getName());
1473 if (!OutputFile.empty() && OutputFile !=
"-") {
1474 auto *Abbrev =
new BitCodeAbbrev();
1476 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1477 unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
1482 StringRef origDir = llvm::sys::path::parent_path(OutputPath);
1485 Stream.EmitRecordWithBlob(AbbrevCode, Record, origDir);
1488 WriteInputFiles(Context.SourceMgr,
1497 struct InputFileEntry {
1501 bool BufferOverridden;
1508 using namespace llvm;
1512 auto *IFAbbrev =
new BitCodeAbbrev();
1514 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1515 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1516 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1517 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1518 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1519 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1520 unsigned IFAbbrevCode = Stream.EmitAbbrev(IFAbbrev);
1524 std::deque<InputFileEntry> SortedFiles;
1534 if (!Cache->OrigEntry)
1537 InputFileEntry Entry;
1538 Entry.File = Cache->OrigEntry;
1539 Entry.IsSystemFile = Cache->IsSystemFile;
1540 Entry.IsTransient = Cache->IsTransient;
1541 Entry.BufferOverridden = Cache->BufferOverridden;
1542 if (Cache->IsSystemFile)
1543 SortedFiles.push_back(Entry);
1545 SortedFiles.push_front(Entry);
1548 unsigned UserFilesNum = 0;
1550 std::vector<uint64_t> InputFileOffsets;
1551 for (
const auto &Entry : SortedFiles) {
1552 uint32_t &InputFileID = InputFileIDs[Entry.File];
1553 if (InputFileID != 0)
1557 InputFileOffsets.push_back(Stream.GetCurrentBitNo());
1559 InputFileID = InputFileOffsets.size();
1561 if (!Entry.IsSystemFile)
1566 RecordData::value_type Record[] = {
1568 InputFileOffsets.size(),
1569 (uint64_t)Entry.File->getSize(),
1570 (uint64_t)getTimestampForOutput(Entry.File),
1571 Entry.BufferOverridden,
1574 EmitRecordWithPath(IFAbbrevCode, Record, Entry.File->getName());
1580 auto *OffsetsAbbrev =
new BitCodeAbbrev();
1582 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1583 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1585 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1586 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(OffsetsAbbrev);
1590 InputFileOffsets.size(), UserFilesNum};
1591 Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record,
bytes(InputFileOffsets));
1601 using namespace llvm;
1603 auto *Abbrev =
new BitCodeAbbrev();
1605 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1606 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1607 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
1608 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1610 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1611 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1612 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
1613 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1614 return Stream.EmitAbbrev(Abbrev);
1620 using namespace llvm;
1622 auto *Abbrev =
new BitCodeAbbrev();
1624 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1625 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1626 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
1627 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1628 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1629 return Stream.EmitAbbrev(Abbrev);
1635 using namespace llvm;
1637 auto *Abbrev =
new BitCodeAbbrev();
1639 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1640 return Stream.EmitAbbrev(Abbrev);
1646 using namespace llvm;
1648 auto *Abbrev =
new BitCodeAbbrev();
1650 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1651 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1652 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1653 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1654 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1655 return Stream.EmitAbbrev(Abbrev);
1660 class HeaderFileInfoTrait {
1666 llvm::StringMap<unsigned> FrameworkNameOffset;
1670 : Writer(Writer), HS(HS) { }
1676 typedef const key_type &key_type_ref;
1679 typedef const data_type &data_type_ref;
1680 typedef unsigned hash_value_type;
1681 typedef unsigned offset_type;
1687 return llvm::hash_combine(key.FE->getSize(),
1688 Writer.getTimestampForOutput(key.FE));
1691 std::pair<unsigned,unsigned>
1692 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) {
1693 using namespace llvm::support;
1694 endian::Writer<little> LE(Out);
1695 unsigned KeyLen = strlen(key.Filename) + 1 + 8 + 8;
1696 LE.write<uint16_t>(KeyLen);
1697 unsigned DataLen = 1 + 2 + 4 + 4;
1698 for (
auto ModInfo : HS.getModuleMap().findAllModulesForHeader(key.FE))
1699 if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
1701 LE.write<uint8_t>(DataLen);
1702 return std::make_pair(KeyLen, DataLen);
1705 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
1706 using namespace llvm::support;
1707 endian::Writer<little> LE(Out);
1708 LE.write<uint64_t>(key.FE->getSize());
1710 LE.write<uint64_t>(Writer.getTimestampForOutput(key.FE));
1712 Out.write(key.Filename, KeyLen);
1715 void EmitData(raw_ostream &Out, key_type_ref key,
1716 data_type_ref Data,
unsigned DataLen) {
1717 using namespace llvm::support;
1718 endian::Writer<little> LE(Out);
1719 uint64_t Start = Out.tell(); (void)Start;
1721 unsigned char Flags = (Data.isImport << 4)
1722 | (Data.isPragmaOnce << 3)
1723 | (Data.DirInfo << 1)
1724 | Data.IndexHeaderMapHeader;
1725 LE.write<uint8_t>(Flags);
1726 LE.write<uint16_t>(Data.NumIncludes);
1728 if (!Data.ControllingMacro)
1729 LE.write<uint32_t>(Data.ControllingMacroID);
1731 LE.write<uint32_t>(Writer.getIdentifierRef(Data.ControllingMacro));
1734 if (!Data.Framework.empty()) {
1737 = FrameworkNameOffset.find(Data.Framework);
1738 if (Pos == FrameworkNameOffset.end()) {
1739 Offset = FrameworkStringData.size() + 1;
1740 FrameworkStringData.append(Data.Framework.begin(),
1741 Data.Framework.end());
1742 FrameworkStringData.push_back(0);
1744 FrameworkNameOffset[Data.Framework] =
Offset;
1748 LE.write<uint32_t>(
Offset);
1752 for (
auto ModInfo : HS.getModuleMap().findAllModulesForHeader(key.FE)) {
1753 if (uint32_t ModID =
1754 Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule())) {
1755 uint32_t
Value = (ModID << 2) | (
unsigned)ModInfo.getRole();
1756 assert((Value >> 2) == ModID &&
"overflow in header module info");
1757 LE.write<uint32_t>(
Value);
1761 assert(Out.tell() - Start == DataLen &&
"Wrong data length");
1764 const char *strings_begin()
const {
return FrameworkStringData.begin(); }
1765 const char *strings_end()
const {
return FrameworkStringData.end(); }
1772 void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
1779 HeaderFileInfoTrait GeneratorTrait(*
this, HS);
1780 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait> Generator;
1782 unsigned NumHeaderSearchEntries = 0;
1783 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
1784 const FileEntry *File = FilesByUID[UID];
1802 if (PreparePathForOutput(FilenameTmp)) {
1805 Filename = strdup(FilenameTmp.c_str());
1806 SavedStrings.push_back(Filename);
1809 HeaderFileInfoTrait::key_type key = { File, Filename };
1810 Generator.insert(key, *HFI, GeneratorTrait);
1811 ++NumHeaderSearchEntries;
1816 uint32_t BucketOffset;
1818 using namespace llvm::support;
1819 llvm::raw_svector_ostream Out(TableData);
1821 endian::Writer<little>(Out).write<uint32_t>(0);
1822 BucketOffset = Generator.Emit(Out, GeneratorTrait);
1826 using namespace llvm;
1828 auto *Abbrev =
new BitCodeAbbrev();
1830 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1831 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1832 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1833 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1834 unsigned TableAbbrev = Stream.EmitAbbrev(Abbrev);
1838 NumHeaderSearchEntries, TableData.size()};
1839 TableData.append(GeneratorTrait.strings_begin(),GeneratorTrait.strings_end());
1840 Stream.EmitRecordWithBlob(TableAbbrev, Record, TableData);
1843 for (
unsigned I = 0, N = SavedStrings.size();
I != N; ++
I)
1844 free(const_cast<char *>(SavedStrings[
I]));
1855 void ASTWriter::WriteSourceManagerBlock(
SourceManager &SourceMgr,
1870 std::vector<uint32_t> SLocEntryOffsets;
1871 RecordData PreloadSLocs;
1881 SLocEntryOffsets.push_back(Stream.GetCurrentBitNo());
1887 if (Cache->OrigEntry) {
1894 Record.push_back(Code);
1897 Record.push_back(SLoc->
getOffset() - 2);
1905 if (Content->OrigEntry) {
1906 assert(Content->OrigEntry == Content->ContentsEntry &&
1907 "Writing to AST an overridden file is not supported");
1910 assert(InputFileIDs[Content->OrigEntry] != 0 &&
"Missed file entry");
1911 Record.push_back(InputFileIDs[Content->OrigEntry]);
1913 Record.push_back(File.NumCreatedFIDs);
1916 if (FDI != FileDeclIDs.end()) {
1917 Record.push_back(FDI->second->FirstDeclIndex);
1918 Record.push_back(FDI->second->DeclIDs.size());
1920 Record.push_back(0);
1921 Record.push_back(0);
1924 Stream.EmitRecordWithAbbrev(SLocFileAbbrv, Record);
1926 if (Content->BufferOverridden || Content->IsTransient) {
1928 const llvm::MemoryBuffer *
Buffer
1930 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record,
1931 StringRef(Buffer->getBufferStart(),
1932 Buffer->getBufferSize() + 1));
1941 const llvm::MemoryBuffer *Buffer
1943 const char *
Name = Buffer->getBufferIdentifier();
1944 Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
1945 StringRef(Name, strlen(Name) + 1));
1947 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record,
1948 StringRef(Buffer->getBufferStart(),
1949 Buffer->getBufferSize() + 1));
1951 if (strcmp(Name,
"<built-in>") == 0) {
1952 PreloadSLocs.push_back(SLocEntryOffsets.size());
1967 Record.push_back(NextOffset - SLoc->
getOffset() - 1);
1968 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv, Record);
1974 if (SLocEntryOffsets.empty())
1979 using namespace llvm;
1981 auto *Abbrev =
new BitCodeAbbrev();
1983 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
1984 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
1985 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1986 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(Abbrev);
1988 RecordData::value_type Record[] = {
1991 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
1992 bytes(SLocEntryOffsets));
2006 llvm::DenseMap<int, int> FilenameMap;
2007 for (
const auto &L : LineTable) {
2010 for (
auto &LE : L.second) {
2011 if (FilenameMap.insert(std::make_pair(LE.FilenameID,
2012 FilenameMap.size())).second)
2013 AddPath(LineTable.getFilename(LE.FilenameID), Record);
2016 Record.push_back(0);
2019 for (
const auto &L : LineTable) {
2025 Record.push_back(L.first.ID);
2028 Record.push_back(L.second.size());
2029 for (
const auto &LE : L.second) {
2030 Record.push_back(LE.FileOffset);
2031 Record.push_back(LE.LineNo);
2032 Record.push_back(FilenameMap[LE.FilenameID]);
2033 Record.push_back((
unsigned)LE.FileKind);
2034 Record.push_back(LE.IncludeOffset);
2049 if (MI->isBuiltinMacro())
2066 void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2069 WritePreprocessorDetail(*PPRec);
2072 RecordData ModuleMacroRecord;
2095 if (Id.second->hadMacroDefinition() &&
2096 (!Id.second->isFromAST() ||
2097 Id.second->hasChangedSinceDeserialization()))
2098 MacroIdentifiers.push_back(Id.second);
2101 std::sort(MacroIdentifiers.begin(), MacroIdentifiers.end(),
2102 llvm::less_ptr<IdentifierInfo>());
2108 auto StartOffset = Stream.GetCurrentBitNo();
2118 Record.push_back(MD->
getKind());
2119 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2120 Record.push_back(getMacroRef(DefMD->getInfo(),
Name));
2121 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2122 Record.push_back(VisMD->isPublic());
2127 bool EmittedModuleMacros =
false;
2131 llvm::DenseMap<ModuleMacro*, unsigned> Visits;
2132 while (!Worklist.empty()) {
2133 auto *Macro = Worklist.pop_back_val();
2136 ModuleMacroRecord.push_back(
2137 getSubmoduleID(Macro->getOwningModule()));
2138 ModuleMacroRecord.push_back(getMacroRef(Macro->getMacroInfo(),
Name));
2139 for (
auto *M : Macro->overrides())
2140 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2143 ModuleMacroRecord.clear();
2146 for (
auto *M : Macro->overrides())
2147 if (++Visits[M] == M->getNumOverridingMacros())
2148 Worklist.push_back(M);
2150 EmittedModuleMacros =
true;
2154 if (Record.empty() && !EmittedModuleMacros)
2157 IdentMacroDirectivesOffsetMap[
Name] = StartOffset;
2168 std::vector<uint32_t> MacroOffsets;
2170 for (
unsigned I = 0, N = MacroInfosToEmit.size();
I != N; ++
I) {
2175 if (ID < FirstMacroID) {
2176 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2181 unsigned Index = ID - FirstMacroID;
2182 if (Index == MacroOffsets.size())
2183 MacroOffsets.push_back(Stream.GetCurrentBitNo());
2185 if (Index > MacroOffsets.size())
2186 MacroOffsets.resize(Index + 1);
2188 MacroOffsets[Index] = Stream.GetCurrentBitNo();
2191 AddIdentifierRef(Name, Record);
2195 Record.push_back(MI->
isUsed());
2208 AddIdentifierRef(Arg, Record);
2216 Stream.EmitRecord(Code, Record);
2220 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2225 AddToken(Tok, Record);
2226 Stream.EmitRecord(
PP_TOKEN, Record);
2235 using namespace llvm;
2237 auto *Abbrev =
new BitCodeAbbrev();
2239 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2240 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2241 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2243 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
2245 RecordData::value_type Record[] = {
MACRO_OFFSET, MacroOffsets.size(),
2247 Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record,
bytes(MacroOffsets));
2261 unsigned NumPreprocessingRecords = 0;
2262 using namespace llvm;
2265 unsigned InclusionAbbrev = 0;
2267 auto *Abbrev =
new BitCodeAbbrev();
2269 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2270 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2271 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2272 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2273 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2274 InclusionAbbrev = Stream.EmitAbbrev(Abbrev);
2277 unsigned FirstPreprocessorEntityID
2278 = (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0)
2280 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2285 (void)++
E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2288 PreprocessedEntityOffsets.push_back(
2289 PPEntityOffset((*E)->getSourceRange(), Stream.GetCurrentBitNo()));
2291 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*
E)) {
2293 MacroDefinitions[MD] = NextPreprocessorEntityID;
2295 AddIdentifierRef(MD->getName(), Record);
2300 if (
auto *ME = dyn_cast<MacroExpansion>(*
E)) {
2301 Record.push_back(ME->isBuiltinMacro());
2302 if (ME->isBuiltinMacro())
2303 AddIdentifierRef(ME->getName(), Record);
2305 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2310 if (
auto *ID = dyn_cast<InclusionDirective>(*
E)) {
2312 Record.push_back(ID->getFileName().size());
2313 Record.push_back(ID->wasInQuotes());
2314 Record.push_back(static_cast<unsigned>(ID->getKind()));
2315 Record.push_back(ID->importedModule());
2317 Buffer += ID->getFileName();
2321 Buffer += ID->getFile()->getName();
2322 Stream.EmitRecordWithBlob(InclusionAbbrev, Record, Buffer);
2326 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2331 if (NumPreprocessingRecords > 0) {
2332 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2335 using namespace llvm;
2337 auto *Abbrev =
new BitCodeAbbrev();
2339 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2340 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2341 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
2344 FirstPreprocessorEntityID -
2346 Stream.EmitRecordWithBlob(PPEOffsetAbbrev, Record,
2347 bytes(PreprocessedEntityOffsets));
2356 if (Known != SubmoduleIDs.end())
2357 return Known->second;
2362 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2365 unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2369 unsigned ID = getLocalOrImportedSubmoduleID(Mod);
2370 assert((ID || !Mod) &&
2371 "asked for module ID for non-local, non-imported module");
2378 unsigned ChildModules = 0;
2380 Sub != SubEnd; ++Sub)
2383 return ChildModules + 1;
2386 void ASTWriter::WriteSubmodules(
Module *WritingModule) {
2391 using namespace llvm;
2393 auto *Abbrev =
new BitCodeAbbrev();
2395 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2396 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2397 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2398 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2399 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2400 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2401 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2402 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2403 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2404 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2405 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2406 unsigned DefinitionAbbrev = Stream.EmitAbbrev(Abbrev);
2408 Abbrev =
new BitCodeAbbrev();
2410 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2411 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(Abbrev);
2413 Abbrev =
new BitCodeAbbrev();
2415 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2416 unsigned HeaderAbbrev = Stream.EmitAbbrev(Abbrev);
2418 Abbrev =
new BitCodeAbbrev();
2420 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2421 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(Abbrev);
2423 Abbrev =
new BitCodeAbbrev();
2425 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2426 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(Abbrev);
2428 Abbrev =
new BitCodeAbbrev();
2430 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2431 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2432 unsigned RequiresAbbrev = Stream.EmitAbbrev(Abbrev);
2434 Abbrev =
new BitCodeAbbrev();
2436 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2437 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(Abbrev);
2439 Abbrev =
new BitCodeAbbrev();
2441 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2442 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(Abbrev);
2444 Abbrev =
new BitCodeAbbrev();
2446 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2447 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(Abbrev);
2449 Abbrev =
new BitCodeAbbrev();
2451 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2452 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(Abbrev);
2454 Abbrev =
new BitCodeAbbrev();
2456 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2457 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2458 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(Abbrev);
2460 Abbrev =
new BitCodeAbbrev();
2462 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2463 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(Abbrev);
2465 Abbrev =
new BitCodeAbbrev();
2467 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2468 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2469 unsigned ConflictAbbrev = Stream.EmitAbbrev(Abbrev);
2478 std::queue<Module *> Q;
2479 Q.push(WritingModule);
2480 while (!Q.empty()) {
2483 unsigned ID = getSubmoduleID(Mod);
2485 uint64_t ParentID = 0;
2487 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
2488 ParentID = SubmoduleIDs[Mod->
Parent];
2493 RecordData::value_type Record[] = {
2498 Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->
Name);
2504 Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
2510 Stream.EmitRecordWithBlob(UmbrellaAbbrev, Record,
2511 UmbrellaHeader.NameAsWritten);
2514 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev, Record,
2515 UmbrellaDir.NameAsWritten);
2520 unsigned RecordKind;
2531 for (
auto &HL : HeaderLists) {
2532 RecordData::value_type Record[] = {HL.RecordKind};
2533 for (
auto &H : Mod->
Headers[HL.HeaderKind])
2534 Stream.EmitRecordWithBlob(HL.Abbrev, Record, H.NameAsWritten);
2541 for (
auto *H : TopHeaders)
2542 Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, H->getName());
2549 Record.push_back(getSubmoduleID(
I));
2556 for (
const auto &
E : Mod->
Exports) {
2559 Record.push_back(getSubmoduleID(
E.getPointer()));
2560 Record.push_back(
E.getInt());
2573 Stream.EmitRecordWithBlob(LinkLibraryAbbrev, Record, LL.Library);
2581 getSubmoduleID(C.Other)};
2582 Stream.EmitRecordWithBlob(ConflictAbbrev, Record, C.Message);
2588 Stream.EmitRecordWithBlob(ConfigMacroAbbrev, Record, CM);
2598 assert((NextSubmoduleID - FirstSubmoduleID ==
2600 "Wrong # of submodules; found a reference to a non-local, "
2601 "non-imported submodule?");
2617 if (WritingModule != OwningMod && !OwningMod->
isSubModuleOf(WritingModule))
2620 return getSubmoduleID(OwningMod);
2631 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
2633 unsigned CurrID = 0;
2634 DiagStateIDMap[&Diag.DiagStates.front()] = ++CurrID;
2636 for (DiagnosticsEngine::DiagStatePointsTy::const_iterator
2637 I = Diag.DiagStatePoints.begin(),
E = Diag.DiagStatePoints.end();
2639 const DiagnosticsEngine::DiagStatePoint &point = *
I;
2640 if (point.Loc.isInvalid())
2643 Record.push_back(point.Loc.getRawEncoding());
2644 unsigned &DiagStateID = DiagStateIDMap[point.State];
2645 Record.push_back(DiagStateID);
2647 if (DiagStateID == 0) {
2648 DiagStateID = ++CurrID;
2649 for (
const auto &
I : *(point.State)) {
2650 if (
I.second.isPragma()) {
2651 Record.push_back(
I.first);
2652 Record.push_back((
unsigned)
I.second.getSeverity());
2655 Record.push_back(-1);
2660 if (!Record.empty())
2664 void ASTWriter::WriteCXXCtorInitializersOffsets() {
2665 if (CXXCtorInitializersOffsets.empty())
2669 using namespace llvm;
2671 auto *Abbrev =
new BitCodeAbbrev();
2673 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2674 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2675 unsigned CtorInitializersOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
2679 CXXCtorInitializersOffsets.size()};
2680 Stream.EmitRecordWithBlob(CtorInitializersOffsetAbbrev, Record,
2681 bytes(CXXCtorInitializersOffsets));
2684 void ASTWriter::WriteCXXBaseSpecifiersOffsets() {
2685 if (CXXBaseSpecifiersOffsets.empty())
2689 using namespace llvm;
2691 auto *Abbrev =
new BitCodeAbbrev();
2693 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2694 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2695 unsigned BaseSpecifierOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
2699 CXXBaseSpecifiersOffsets.size()};
2700 Stream.EmitRecordWithBlob(BaseSpecifierOffsetAbbrev, Record,
2701 bytes(CXXBaseSpecifiersOffsets));
2709 void ASTWriter::WriteType(
QualType T) {
2714 assert(Idx.
getIndex() >= FirstTypeID &&
"Re-writing a type from a prior AST");
2717 unsigned Index = Idx.
getIndex() - FirstTypeID;
2718 if (TypeOffsets.size() == Index)
2719 TypeOffsets.push_back(Stream.GetCurrentBitNo());
2720 else if (TypeOffsets.size() < Index) {
2721 TypeOffsets.resize(Index + 1);
2722 TypeOffsets[Index] = Stream.GetCurrentBitNo();
2728 ASTTypeWriter W(*
this, Record);
2736 W.AbbrevToUse = TypeExtQualAbbrev;
2741 #define TYPE(Class, Base) \
2742 case Type::Class: W.Visit##Class##Type(cast<Class##Type>(T)); break;
2743 #define ABSTRACT_TYPE(Class, Base)
2744 #include "clang/AST/TypeNodes.def"
2749 Stream.EmitRecord(W.Code, Record, W.AbbrevToUse);
2764 uint64_t ASTWriter::WriteDeclContextLexicalBlock(
ASTContext &Context,
2769 uint64_t
Offset = Stream.GetCurrentBitNo();
2771 for (
const auto *D : DC->
decls()) {
2772 KindDeclPairs.push_back(D->getKind());
2773 KindDeclPairs.push_back(GetDeclRef(D));
2776 ++NumLexicalDeclContexts;
2778 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record,
2779 bytes(KindDeclPairs));
2783 void ASTWriter::WriteTypeDeclOffsets() {
2784 using namespace llvm;
2787 auto *Abbrev =
new BitCodeAbbrev();
2789 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2790 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2791 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2792 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
2794 RecordData::value_type Record[] = {
TYPE_OFFSET, TypeOffsets.size(),
2796 Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record,
bytes(TypeOffsets));
2800 Abbrev =
new BitCodeAbbrev();
2802 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2803 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2804 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2805 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
2807 RecordData::value_type Record[] = {
DECL_OFFSET, DeclOffsets.size(),
2809 Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record,
bytes(DeclOffsets));
2813 void ASTWriter::WriteFileDeclIDsMap() {
2814 using namespace llvm;
2817 FileDeclIDs.begin(), FileDeclIDs.end());
2818 std::sort(SortedFileDeclIDs.begin(), SortedFileDeclIDs.end(),
2819 llvm::less_first());
2823 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
2824 DeclIDInFileInfo &Info = *FileDeclEntry.second;
2825 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
2826 for (
auto &LocDeclEntry : Info.DeclIDs)
2827 FileGroupedDeclIDs.push_back(LocDeclEntry.second);
2830 auto *Abbrev =
new BitCodeAbbrev();
2832 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2833 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2834 unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
2836 FileGroupedDeclIDs.size()};
2837 Stream.EmitRecordWithBlob(AbbrevCode, Record,
bytes(FileGroupedDeclIDs));
2840 void ASTWriter::WriteComments() {
2844 for (
const auto *
I : RawComments) {
2846 AddSourceRange(
I->getSourceRange(), Record);
2847 Record.push_back(
I->getKind());
2848 Record.push_back(
I->isTrailingComment());
2849 Record.push_back(
I->isAlmostTrailingComment());
2861 class ASTMethodPoolTrait {
2866 typedef key_type key_type_ref;
2872 typedef const data_type& data_type_ref;
2874 typedef unsigned hash_value_type;
2875 typedef unsigned offset_type;
2877 explicit ASTMethodPoolTrait(
ASTWriter &Writer) : Writer(Writer) { }
2883 std::pair<unsigned,unsigned>
2884 EmitKeyDataLength(raw_ostream& Out,
Selector Sel,
2885 data_type_ref Methods) {
2886 using namespace llvm::support;
2887 endian::Writer<little> LE(Out);
2889 LE.write<uint16_t>(KeyLen);
2890 unsigned DataLen = 4 + 2 + 2;
2893 if (Method->getMethod())
2897 if (Method->getMethod())
2899 LE.write<uint16_t>(DataLen);
2900 return std::make_pair(KeyLen, DataLen);
2903 void EmitKey(raw_ostream& Out,
Selector Sel,
unsigned) {
2904 using namespace llvm::support;
2905 endian::Writer<little> LE(Out);
2906 uint64_t Start = Out.tell();
2907 assert((Start >> 32) == 0 &&
"Selector key offset too large");
2908 Writer.SetSelectorOffset(Sel, Start);
2910 LE.write<uint16_t>(N);
2913 for (
unsigned I = 0;
I != N; ++
I)
2918 void EmitData(raw_ostream& Out, key_type_ref,
2919 data_type_ref Methods,
unsigned DataLen) {
2920 using namespace llvm::support;
2921 endian::Writer<little> LE(Out);
2922 uint64_t Start = Out.tell(); (void)Start;
2923 LE.write<uint32_t>(Methods.ID);
2924 unsigned NumInstanceMethods = 0;
2927 if (Method->getMethod())
2928 ++NumInstanceMethods;
2930 unsigned NumFactoryMethods = 0;
2933 if (Method->getMethod())
2934 ++NumFactoryMethods;
2936 unsigned InstanceBits = Methods.Instance.getBits();
2937 assert(InstanceBits < 4);
2938 unsigned InstanceHasMoreThanOneDeclBit =
2939 Methods.Instance.hasMoreThanOneDecl();
2940 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
2941 (InstanceHasMoreThanOneDeclBit << 2) |
2943 unsigned FactoryBits = Methods.Factory.getBits();
2944 assert(FactoryBits < 4);
2945 unsigned FactoryHasMoreThanOneDeclBit =
2946 Methods.Factory.hasMoreThanOneDecl();
2947 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
2948 (FactoryHasMoreThanOneDeclBit << 2) |
2950 LE.write<uint16_t>(FullInstanceBits);
2951 LE.write<uint16_t>(FullFactoryBits);
2954 if (Method->getMethod())
2955 LE.write<uint32_t>(Writer.getDeclID(Method->getMethod()));
2958 if (Method->getMethod())
2959 LE.write<uint32_t>(Writer.getDeclID(Method->getMethod()));
2961 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
2971 void ASTWriter::WriteSelectors(
Sema &SemaRef) {
2972 using namespace llvm;
2975 if (SemaRef.
MethodPool.empty() && SelectorIDs.empty())
2977 unsigned NumTableEntries = 0;
2980 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait> Generator;
2981 ASTMethodPoolTrait Trait(*
this);
2985 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
2986 for (
auto &SelectorAndID : SelectorIDs) {
2990 ASTMethodPoolTrait::data_type Data = {
2996 Data.Instance = F->second.first;
2997 Data.Factory = F->second.second;
3001 if (Chain && ID < FirstSelectorID) {
3003 bool changed =
false;
3005 !changed && M && M->
getMethod(); M = M->getNext()) {
3006 if (!M->getMethod()->isFromASTFile())
3011 if (!M->getMethod()->isFromASTFile())
3016 }
else if (Data.Instance.getMethod() || Data.Factory.getMethod()) {
3020 Generator.insert(S, Data, Trait);
3025 uint32_t BucketOffset;
3027 using namespace llvm::support;
3028 ASTMethodPoolTrait Trait(*
this);
3029 llvm::raw_svector_ostream Out(MethodPool);
3031 endian::Writer<little>(Out).write<uint32_t>(0);
3032 BucketOffset = Generator.Emit(Out, Trait);
3036 auto *Abbrev =
new BitCodeAbbrev();
3038 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3039 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3040 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3041 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(Abbrev);
3045 RecordData::value_type Record[] = {
METHOD_POOL, BucketOffset,
3047 Stream.EmitRecordWithBlob(MethodPoolAbbrev, Record, MethodPool);
3051 Abbrev =
new BitCodeAbbrev();
3053 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3054 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3055 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3056 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
3060 RecordData::value_type Record[] = {
3063 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev, Record,
3064 bytes(SelectorOffsets));
3070 void ASTWriter::WriteReferencedSelectorsPool(
Sema &SemaRef) {
3071 using namespace llvm;
3081 Selector Sel = SelectorAndLocation.first;
3083 AddSelectorRef(Sel, Record);
3084 AddSourceLocation(Loc, Record);
3105 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3106 if (!Redecl->isFromASTFile())
3107 return cast<NamedDecl>(Redecl);
3115 if (!First->isFromASTFile())
3116 return cast<NamedDecl>(First);
3125 class ASTIdentifierTableTrait {
3150 typedef key_type key_type_ref;
3153 typedef data_type data_type_ref;
3155 typedef unsigned hash_value_type;
3156 typedef unsigned offset_type;
3161 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3162 NeedDecls(!IsModule || !Writer.getLangOpts().
CPlusPlus),
3163 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3166 return llvm::HashString(II->
getName());
3170 auto MacroOffset = Writer.getMacroDirectivesOffset(II);
3177 std::pair<unsigned,unsigned>
3180 unsigned DataLen = 4;
3181 auto MacroOffset = Writer.getMacroDirectivesOffset(II);
3190 DEnd = IdResolver.end();
3195 using namespace llvm::support;
3196 endian::Writer<little> LE(Out);
3198 assert((uint16_t)DataLen == DataLen && (uint16_t)KeyLen == KeyLen);
3199 LE.write<uint16_t>(DataLen);
3203 LE.write<uint16_t>(KeyLen);
3204 return std::make_pair(KeyLen, DataLen);
3211 Writer.SetIdentifierOffset(II, Out.tell());
3216 InterestingIdentifierOffsets->push_back(Out.tell() - 4);
3223 using namespace llvm::support;
3224 endian::Writer<little> LE(Out);
3226 auto MacroOffset = Writer.getMacroDirectivesOffset(II);
3228 LE.write<uint32_t>(ID << 1);
3232 LE.write<uint32_t>((ID << 1) | 0x01);
3234 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
3235 LE.write<uint16_t>(Bits);
3237 bool HadMacroDefinition = MacroOffset != 0;
3238 Bits = (Bits << 1) |
unsigned(HadMacroDefinition);
3240 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
3244 LE.write<uint16_t>(Bits);
3246 if (HadMacroDefinition)
3247 LE.write<uint32_t>(MacroOffset);
3259 DEnd = Decls.rend();
3276 using namespace llvm;
3278 RecordData InterestingIdents;
3283 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait> Generator;
3284 ASTIdentifierTableTrait Trait(
3285 *
this, PP, IdResolver, IsModule,
3286 (getLangOpts().
CPlusPlus && IsModule) ? &InterestingIdents :
nullptr);
3295 IIs.push_back(ID.second);
3298 std::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
3300 if (Trait.isInterestingNonMacroIdentifier(II))
3301 getIdentifierRef(II);
3305 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
3306 for (
auto IdentIDPair : IdentifierIDs) {
3308 IdentID ID = IdentIDPair.second;
3309 assert(II &&
"NULL identifier in identifier table");
3311 Generator.insert(II, ID, Trait);
3316 uint32_t BucketOffset;
3318 using namespace llvm::support;
3319 llvm::raw_svector_ostream Out(IdentifierTable);
3321 endian::Writer<little>(Out).write<uint32_t>(0);
3322 BucketOffset = Generator.Emit(Out, Trait);
3326 auto *Abbrev =
new BitCodeAbbrev();
3328 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3329 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3330 unsigned IDTableAbbrev = Stream.EmitAbbrev(Abbrev);
3334 Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable);
3338 auto *Abbrev =
new BitCodeAbbrev();
3340 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3341 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3342 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3343 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
3346 for (
unsigned I = 0, N = IdentifierOffsets.size();
I != N; ++
I)
3347 assert(IdentifierOffsets[
I] &&
"Missing identifier offset?");
3351 IdentifierOffsets.size(),
3353 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev, Record,
3354 bytes(IdentifierOffsets));
3358 if (!InterestingIdents.empty())
3368 class ASTDeclContextNameLookupTrait {
3374 typedef key_type key_type_ref;
3377 typedef std::pair<unsigned, unsigned> data_type;
3378 typedef const data_type& data_type_ref;
3380 typedef unsigned hash_value_type;
3381 typedef unsigned offset_type;
3383 explicit ASTDeclContextNameLookupTrait(
ASTWriter &Writer) : Writer(Writer) { }
3385 template<
typename Coll>
3386 data_type getData(
const Coll &Decls) {
3387 unsigned Start = DeclIDs.size();
3392 return std::make_pair(Start, DeclIDs.size());
3396 unsigned Start = DeclIDs.size();
3397 for (
auto ID : FromReader)
3398 DeclIDs.push_back(ID);
3399 return std::make_pair(Start, DeclIDs.size());
3402 static bool EqualKey(key_type_ref a, key_type_ref b) {
3410 void EmitFileRef(raw_ostream &Out,
ModuleFile *F)
const {
3411 assert(Writer.hasChain() &&
3412 "have reference to loaded module file but no chain?");
3414 using namespace llvm::support;
3415 endian::Writer<little>(Out)
3416 .write<uint32_t>(Writer.getChain()->getModuleFileID(F));
3419 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
3421 data_type_ref Lookup) {
3422 using namespace llvm::support;
3423 endian::Writer<little> LE(Out);
3424 unsigned KeyLen = 1;
3442 LE.write<uint16_t>(KeyLen);
3445 unsigned DataLen = 4 * (Lookup.second - Lookup.first);
3446 assert(uint16_t(DataLen) == DataLen &&
3447 "too many decls for serialized lookup result");
3448 LE.write<uint16_t>(DataLen);
3450 return std::make_pair(KeyLen, DataLen);
3454 using namespace llvm::support;
3455 endian::Writer<little> LE(Out);
3456 LE.write<uint8_t>(Name.
getKind());
3460 LE.write<uint32_t>(Writer.getIdentifierRef(Name.
getIdentifier()));
3465 LE.write<uint32_t>(Writer.getSelectorRef(Name.
getSelector()));
3469 "Invalid operator?");
3479 llvm_unreachable(
"Invalid name kind?");
3482 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
3484 using namespace llvm::support;
3485 endian::Writer<little> LE(Out);
3486 uint64_t Start = Out.tell(); (void)Start;
3487 for (
unsigned I = Lookup.first, N = Lookup.second;
I != N; ++
I)
3488 LE.write<uint32_t>(DeclIDs[
I]);
3489 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3496 return Result.
hasExternalDecls() && DC->NeedToReconcileExternalVisibleStorage;
3499 bool ASTWriter::isLookupResultEntirelyExternal(
StoredDeclsList &Result,
3509 ASTWriter::GenerateNameLookupTable(
const DeclContext *ConstDC,
3511 assert(!ConstDC->HasLazyLocalLexicalLookups &&
3512 !ConstDC->HasLazyExternalLexicalLookups &&
3513 "must call buildLookups first");
3521 ASTDeclContextNameLookupTrait> Generator;
3522 ASTDeclContextNameLookupTrait Trait(*
this);
3531 llvm::SmallSet<DeclarationName, 8> ConstructorNameSet, ConversionNameSet;
3534 auto &Name = Lookup.first;
3535 auto &Result = Lookup.second;
3541 if (isLookupResultExternal(Result, DC) &&
3542 isLookupResultEntirelyExternal(Result, DC))
3559 if (Lookup.second.getLookupResult().empty())
3562 switch (Lookup.first.getNameKind()) {
3564 Names.push_back(Lookup.first);
3568 assert(isa<CXXRecordDecl>(DC) &&
3569 "Cannot have a constructor name outside of a class!");
3570 ConstructorNameSet.insert(Name);
3574 assert(isa<CXXRecordDecl>(DC) &&
3575 "Cannot have a conversion function name outside of a class!");
3576 ConversionNameSet.insert(Name);
3582 std::sort(Names.begin(), Names.end());
3584 if (
auto *D = dyn_cast<CXXRecordDecl>(DC)) {
3598 if (ConstructorNameSet.erase(ImplicitCtorName))
3599 Names.push_back(ImplicitCtorName);
3604 if (!ConstructorNameSet.empty() || !ConversionNameSet.empty())
3605 for (
Decl *ChildD : cast<CXXRecordDecl>(DC)->decls())
3606 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
3607 auto Name = ChildND->getDeclName();
3608 switch (Name.getNameKind()) {
3613 if (ConstructorNameSet.erase(Name))
3614 Names.push_back(Name);
3618 if (ConversionNameSet.erase(Name))
3619 Names.push_back(Name);
3623 if (ConstructorNameSet.empty() && ConversionNameSet.empty())
3627 assert(ConstructorNameSet.empty() &&
"Failed to find all of the visible "
3628 "constructors by walking all the "
3629 "lexical members of the context.");
3630 assert(ConversionNameSet.empty() &&
"Failed to find all of the visible "
3631 "conversion functions by walking all "
3632 "the lexical members of the context.");
3639 for (
auto &Name : Names)
3651 for (
auto &Name : Names) {
3654 switch (Name.getNameKind()) {
3656 Generator.insert(Name, Trait.getData(Result), Trait);
3660 ConstructorDecls.append(Result.
begin(), Result.
end());
3664 ConversionDecls.append(Result.
begin(), Result.
end());
3672 if (!ConstructorDecls.empty())
3673 Generator.insert(ConstructorDecls.front()->getDeclName(),
3674 Trait.getData(ConstructorDecls), Trait);
3675 if (!ConversionDecls.empty())
3676 Generator.insert(ConversionDecls.front()->getDeclName(),
3677 Trait.getData(ConversionDecls), Trait);
3681 auto *Lookups = Chain ? Chain->getLoadedLookupTables(DC) :
nullptr;
3682 Generator.emit(LookupTable, Trait, Lookups ? &Lookups->Table :
nullptr);
3690 uint64_t ASTWriter::WriteDeclContextVisibleBlock(
ASTContext &Context,
3695 if (isa<NamespaceDecl>(DC) && Chain &&
3696 Chain->getKeyDeclaration(cast<Decl>(DC))->isFromASTFile()) {
3698 for (
auto *Prev = cast<NamespaceDecl>(DC)->getPreviousDecl(); Prev;
3699 Prev = Prev->getPreviousDecl())
3700 if (!Prev->isFromASTFile())
3713 LookupResults.reserve(Map->size());
3714 for (
auto &Entry : *Map)
3715 LookupResults.push_back(
3716 std::make_pair(Entry.first, Entry.second.getLookupResult()));
3719 std::sort(LookupResults.begin(), LookupResults.end(), llvm::less_first());
3720 for (
auto &NameAndResult : LookupResults) {
3728 assert(Result.
empty() &&
"Cannot have a constructor or conversion "
3729 "function name in a namespace!");
3734 if (!ND->isFromASTFile())
3758 uint64_t Offset = Stream.GetCurrentBitNo();
3760 if (!Map || Map->empty())
3765 GenerateNameLookupTable(DC, LookupTable);
3769 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev, Record,
3771 ++NumVisibleDeclContexts;
3781 void ASTWriter::WriteDeclContextVisibleUpdate(
const DeclContext *DC) {
3783 if (!Map || Map->empty())
3788 GenerateNameLookupTable(DC, LookupTable);
3792 if (isa<NamespaceDecl>(DC))
3793 DC = cast<DeclContext>(Chain->getKeyDeclaration(cast<Decl>(DC)));
3796 RecordData::value_type Record[] = {
UPDATE_VISIBLE, getDeclID(cast<Decl>(DC))};
3797 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev, Record, LookupTable);
3801 void ASTWriter::WriteFPPragmaOptions(
const FPOptions &Opts) {
3802 RecordData::value_type Record[] = {Opts.
fp_contract};
3807 void ASTWriter::WriteOpenCLExtensions(
Sema &SemaRef) {
3813 #define OPENCLEXT(nm) Record.push_back(Opts.nm);
3814 #include "clang/Basic/OpenCLExtensions.def"
3818 void ASTWriter::WriteObjCCategories() {
3820 RecordData Categories;
3822 for (
unsigned I = 0, N = ObjCClassesWithCategories.size();
I != N; ++
I) {
3824 unsigned StartIndex = Categories.size();
3829 Categories.push_back(0);
3835 Cat != CatEnd; ++Cat, ++Size) {
3836 assert(getDeclID(*Cat) != 0 &&
"Bogus category");
3837 AddDeclRef(*Cat, Categories);
3841 Categories[StartIndex] = Size;
3845 CategoriesMap.push_back(CatInfo);
3850 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
3853 using namespace llvm;
3855 auto *Abbrev =
new BitCodeAbbrev();
3857 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
3858 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3859 unsigned AbbrevID = Stream.EmitAbbrev(Abbrev);
3862 Stream.EmitRecordWithBlob(AbbrevID, Record,
3863 reinterpret_cast<char *>(CategoriesMap.data()),
3870 void ASTWriter::WriteLateParsedTemplates(
Sema &SemaRef) {
3877 for (
auto LPTMapEntry : LPTMap) {
3880 AddDeclRef(FD, Record);
3881 AddDeclRef(LPT->
D, Record);
3882 Record.push_back(LPT->
Toks.size());
3884 for (
const auto &Tok : LPT->
Toks) {
3885 AddToken(Tok, Record);
3892 void ASTWriter::WriteOptimizePragmaOptions(
Sema &SemaRef) {
3895 AddSourceLocation(PragmaLoc, Record);
3899 void ASTWriter::WriteModuleFileExtension(
Sema &SemaRef,
3905 auto *Abv =
new llvm::BitCodeAbbrev();
3907 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
3908 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
3909 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
3910 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
3911 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
3912 unsigned Abbrev = Stream.EmitAbbrev(Abv);
3918 Record.push_back(Metadata.MajorVersion);
3919 Record.push_back(Metadata.MinorVersion);
3920 Record.push_back(Metadata.BlockName.size());
3921 Record.push_back(Metadata.UserInfo.size());
3923 Buffer += Metadata.BlockName;
3924 Buffer += Metadata.UserInfo;
3925 Stream.EmitRecordWithBlob(Abbrev, Record, Buffer);
3940 RecordDataImpl &Record) {
3941 Record.push_back(Attrs.size());
3942 for (
const auto *A : Attrs) {
3943 Record.push_back(A->getKind());
3944 AddSourceRange(A->getRange(), Record);
3946 #include "clang/Serialization/AttrPCHWrite.inc"
3959 Record.push_back(Tok.
getKind());
3965 Record.push_back(Str.size());
3966 Record.insert(Record.end(), Str.begin(), Str.end());
3970 assert(Context &&
"should have context when outputting path");
3976 const char *PathBegin = Path.data();
3977 const char *PathPtr =
3979 if (PathPtr != PathBegin) {
3980 Path.erase(Path.begin(), Path.begin() + (PathPtr - PathBegin));
3989 PreparePathForOutput(FilePath);
3990 AddString(FilePath, Record);
3996 PreparePathForOutput(FilePath);
3997 Stream.EmitRecordWithBlob(Abbrev, Record, FilePath);
4002 Record.push_back(Version.
getMajor());
4004 Record.push_back(*Minor + 1);
4006 Record.push_back(0);
4008 Record.push_back(*Subminor + 1);
4010 Record.push_back(0);
4016 IdentID ID = IdentifierIDs[II];
4019 if (ID >= FirstIdentID)
4020 IdentifierOffsets[ID - FirstIdentID] =
Offset;
4026 unsigned ID = SelectorIDs[Sel];
4027 assert(ID &&
"Unknown selector");
4030 if (ID < FirstSelectorID)
4032 SelectorOffsets[ID - FirstSelectorID] =
Offset;
4036 llvm::BitstreamWriter &Stream,
4038 bool IncludeTimestamps)
4039 : Stream(Stream), Context(nullptr), PP(nullptr), Chain(nullptr),
4040 WritingModule(nullptr), IncludeTimestamps(IncludeTimestamps),
4041 WritingAST(
false), DoneWritingDeclsAndTypes(
false),
4047 NextSubmoduleID(FirstSubmoduleID),
4049 CollectedStmts(&StmtsToEmit), NumStatements(0), NumMacros(0),
4050 NumLexicalDeclContexts(0), NumVisibleDeclContexts(0),
4051 NextCXXBaseSpecifiersID(1), NextCXXCtorInitializersID(1),
4052 TypeExtQualAbbrev(0), TypeFunctionProtoAbbrev(0), DeclParmVarAbbrev(0),
4053 DeclContextLexicalAbbrev(0), DeclContextVisibleLookupAbbrev(0),
4054 UpdateVisibleAbbrev(0), DeclRecordAbbrev(0), DeclTypedefAbbrev(0),
4055 DeclVarAbbrev(0), DeclFieldAbbrev(0), DeclEnumAbbrev(0),
4056 DeclObjCIvarAbbrev(0), DeclCXXMethodAbbrev(0), DeclRefExprAbbrev(0),
4057 CharacterLiteralAbbrev(0), IntegerLiteralAbbrev(0),
4058 ExprImplicitCastAbbrev(0) {
4059 for (
const auto &Ext : Extensions) {
4060 if (
auto Writer = Ext->createExtensionWriter(*
this))
4061 ModuleFileExtensionWriters.push_back(std::move(Writer));
4066 llvm::DeleteContainerSeconds(FileDeclIDs);
4070 assert(WritingAST &&
"can't determine lang opts when not writing AST");
4079 Module *WritingModule, StringRef isysroot,
4083 ASTHasCompilerErrors = hasErrors;
4086 Stream.Emit((
unsigned)
'C', 8);
4087 Stream.Emit((
unsigned)
'P', 8);
4088 Stream.Emit((
unsigned)
'C', 8);
4089 Stream.Emit((
unsigned)
'H', 8);
4091 WriteBlockInfoBlock();
4095 this->WritingModule = WritingModule;
4097 WriteASTCore(SemaRef, isysroot, OutputFile, WritingModule);
4100 this->WritingModule =
nullptr;
4101 this->BaseDirectory.clear();
4107 template<
typename Vector>
4116 uint64_t ASTWriter::WriteASTCore(
Sema &SemaRef, StringRef isysroot,
4117 const std::string &OutputFile,
4119 using namespace llvm;
4121 bool isModule = WritingModule !=
nullptr;
4125 Chain->finalizeForWriting();
4133 assert(D->isCanonicalDecl() &&
"predefined decl is not canonical");
4142 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
4146 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
4150 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
4153 RegisterPredefDecl(Context.MakeIntegerSeqDecl,
4166 UnusedFileScopedDecls);
4180 WeakInfo &WI = WeakUndeclaredIdentifier.second;
4184 WeakUndeclaredIdentifiers.push_back(WI.
getUsed());
4194 for (
unsigned I = 0, N = SemaRef.
VTableUses.size();
I != N; ++
I) {
4204 AddDeclRef(TD, UnusedLocalTypedefNameCandidates);
4213 "There are local ones at end of translation unit!");
4229 for (
const auto &
I : SemaRef.KnownNamespaces) {
4239 for (
const auto &
I : Undefined) {
4248 for (
const auto &DeleteExprsInfo :
4250 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
4251 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
4252 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
4254 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
4259 uint64_t Signature = WriteControlBlock(PP, Context, isysroot, OutputFile);
4275 for (
const auto *D : TU->noload_decls()) {
4276 if (!D->isFromASTFile()) {
4277 NewGlobalKindDeclPairs.push_back(D->getKind());
4278 NewGlobalKindDeclPairs.push_back(
GetDeclRef(D));
4282 auto *Abv =
new llvm::BitCodeAbbrev();
4284 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4285 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(Abv);
4288 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev, Record,
4289 bytes(NewGlobalKindDeclPairs));
4293 Abv =
new llvm::BitCodeAbbrev();
4295 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4296 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4297 UpdateVisibleAbbrev = Stream.EmitAbbrev(Abv);
4298 WriteDeclContextVisibleUpdate(TU);
4301 if (Context.ExternCContext)
4302 WriteDeclContextVisibleUpdate(Context.ExternCContext);
4316 for (
const auto &Number : Context.MangleNumbers)
4317 if (!Number.first->isFromASTFile())
4320 for (
const auto &Number : Context.StaticLocalNumbers)
4321 if (!Number.first->isFromASTFile())
4327 for (
const auto *
I : UpdatingVisibleDecls) {
4341 std::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
4357 AddTypeRef(Context.ObjCIdRedefinitionType, SpecialTypes);
4358 AddTypeRef(Context.ObjCClassRedefinitionType, SpecialTypes);
4359 AddTypeRef(Context.ObjCSelRedefinitionType, SpecialTypes);
4378 auto *Abbrev =
new BitCodeAbbrev();
4380 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4381 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(Abbrev);
4384 llvm::raw_svector_ostream Out(Buffer);
4386 using namespace llvm::support;
4387 endian::Writer<little> LE(Out);
4389 LE.write<uint16_t>(FileName.size());
4390 Out.write(FileName.data(), FileName.size());
4394 uint32_t
None = std::numeric_limits<uint32_t>::max();
4396 auto writeBaseIDOrNone = [&](uint32_t BaseID,
bool ShouldWrite) {
4397 assert(BaseID < std::numeric_limits<uint32_t>::max() &&
"base id too high");
4399 LE.write<uint32_t>(BaseID);
4401 LE.write<uint32_t>(
None);
4418 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev, Record,
4419 Buffer.data(), Buffer.size());
4430 WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord);
4431 while (!DeclTypesToEmit.empty()) {
4432 DeclOrType DOT = DeclTypesToEmit.front();
4433 DeclTypesToEmit.pop();
4435 WriteType(DOT.getType());
4437 WriteDecl(Context, DOT.getDecl());
4439 }
while (!DeclUpdates.empty());
4442 DoneWritingDeclsAndTypes =
true;
4445 WriteTypeDeclOffsets();
4446 if (!DeclUpdatesOffsetsRecord.empty())
4448 WriteCXXBaseSpecifiersOffsets();
4449 WriteCXXCtorInitializersOffsets();
4450 WriteFileDeclIDsMap();
4453 WritePreprocessor(PP, isModule);
4455 WriteSelectors(SemaRef);
4456 WriteReferencedSelectorsPool(SemaRef);
4457 WriteLateParsedTemplates(SemaRef);
4458 WriteIdentifierTable(PP, SemaRef.
IdResolver, isModule);
4460 WriteOpenCLExtensions(SemaRef);
4461 WritePragmaDiagnosticMappings(Context.
getDiagnostics(), isModule);
4465 WriteSubmodules(WritingModule);
4470 if (!EagerlyDeserializedDecls.empty())
4474 if (!TentativeDefinitions.empty())
4478 if (!UnusedFileScopedDecls.empty())
4482 if (!WeakUndeclaredIdentifiers.empty())
4484 WeakUndeclaredIdentifiers);
4487 if (!ExtVectorDecls.empty())
4491 if (!VTableUses.empty())
4495 if (!UnusedLocalTypedefNameCandidates.empty())
4497 UnusedLocalTypedefNameCandidates);
4500 if (!PendingInstantiations.empty())
4504 if (!SemaDeclRefs.empty())
4508 if (!CUDASpecialDeclRefs.empty())
4512 if (!DelegatingCtorDecls.empty())
4516 if (!KnownNamespaces.empty())
4520 if (!UndefinedButUsed.empty())
4523 if (!DeleteExprsToAnalyze.empty())
4527 for (
auto *DC : UpdatedDeclContexts)
4528 WriteDeclContextVisibleUpdate(DC);
4530 if (!WritingModule) {
4535 ModuleInfo(uint64_t ID,
Module *M) : ID(ID), M(M) {}
4539 assert(SubmoduleIDs.find(
I->getImportedModule()) != SubmoduleIDs.end());
4540 Imports.push_back(ModuleInfo(SubmoduleIDs[
I->getImportedModule()],
4541 I->getImportedModule()));
4544 if (!Imports.empty()) {
4545 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
4548 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
4549 return A.ID == B.ID;
4553 std::sort(Imports.begin(), Imports.end(), Cmp);
4554 Imports.erase(std::unique(Imports.begin(), Imports.end(), Eq),
4558 for (
const auto &Import : Imports) {
4559 ImportedModules.push_back(Import.ID);
4570 WriteDeclReplacementsBlock();
4571 WriteObjCCategories();
4573 WriteOptimizePragmaOptions(SemaRef);
4576 RecordData::value_type Record[] = {
4577 NumStatements, NumMacros, NumLexicalDeclContexts, NumVisibleDeclContexts};
4582 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
4583 WriteModuleFileExtension(SemaRef, *ExtWriter);
4588 void ASTWriter::WriteDeclUpdatesBlocks(
RecordDataImpl &OffsetsRecord) {
4589 if (DeclUpdates.empty())
4592 DeclUpdateMap LocalUpdates;
4593 LocalUpdates.swap(DeclUpdates);
4595 for (
auto &DeclUpdate : LocalUpdates) {
4596 const Decl *D = DeclUpdate.first;
4598 bool HasUpdatedBody =
false;
4600 for (
auto &Update : DeclUpdate.second) {
4603 Record.push_back(Kind);
4608 assert(Update.getDecl() &&
"no decl to add?");
4609 Record.push_back(
GetDeclRef(Update.getDecl()));
4616 HasUpdatedBody =
true;
4625 cast<ParmVarDecl>(Update.getDecl())->getDefaultArg()));
4629 auto *RD = cast<CXXRecordDecl>(D);
4630 UpdatedDeclContexts.insert(RD->getPrimaryContext());
4632 Record.push_back(WriteDeclContextLexicalBlock(
4633 *Context, const_cast<CXXRecordDecl *>(RD)));
4638 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
4639 Record.push_back(MSInfo->getTemplateSpecializationKind());
4642 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
4643 Record.push_back(Spec->getTemplateSpecializationKind());
4648 auto From = Spec->getInstantiatedFrom();
4649 if (
auto PartialSpec =
4651 Record.push_back(
true);
4656 Record.push_back(
false);
4659 Record.push_back(RD->getTagKind());
4667 WriteAttributes(llvm::makeArrayRef(D->
getAttrs().begin(),
4681 cast<FunctionDecl>(D)->getType()->castAs<FunctionProtoType>(),
4694 Record.push_back(Update.getNumber());
4703 Record.push_back(getSubmoduleID(Update.getModule()));
4707 WriteAttributes(llvm::makeArrayRef(Update.getAttr()), Record);
4712 if (HasUpdatedBody) {
4713 const auto *Def = cast<FunctionDecl>(D);
4715 Record.push_back(Def->isInlined());
4717 AddFunctionDefinition(Def, Record);
4721 OffsetsRecord.push_back(Stream.GetCurrentBitNo());
4729 void ASTWriter::WriteDeclReplacementsBlock() {
4730 if (ReplacedDecls.empty())
4734 for (
const auto &
I : ReplacedDecls) {
4735 Record.push_back(
I.ID);
4736 Record.push_back(
I.Offset);
4737 Record.push_back(
I.Loc);
4752 Record.push_back(Value.getBitWidth());
4753 const uint64_t *Words = Value.getRawData();
4754 Record.append(Words, Words + Value.getNumWords());
4758 Record.push_back(Value.isUnsigned());
4763 AddAPInt(Value.bitcastToAPInt(), Record);
4774 IdentID &ID = IdentifierIDs[II];
4790 MacroInfoToEmitData Info = {
Name, MI, ID };
4791 MacroInfosToEmit.push_back(Info);
4800 assert(MacroIDs.find(MI) != MacroIDs.end() &&
"Macro not emitted!");
4801 return MacroIDs[MI];
4805 return IdentMacroDirectivesOffsetMap.lookup(Name);
4818 if (SID == 0 && Chain) {
4821 Chain->LoadSelector(Sel);
4822 SID = SelectorIDs[Sel];
4825 SID = NextSelectorID++;
4826 SelectorIDs[Sel] = SID;
4837 assert(!Inits.empty() &&
"Empty ctor initializer sets are not recorded");
4838 CXXCtorInitializersToWrite.push_back(
4839 QueuedCXXCtorInitializers(NextCXXCtorInitializersID, Inits));
4840 Record.push_back(NextCXXCtorInitializersID++);
4846 assert(Bases != BasesEnd &&
"Empty base-specifier sets are not recorded");
4847 CXXBaseSpecifiersToWrite.push_back(
4848 QueuedCXXBaseSpecifiers(NextCXXBaseSpecifiersID,
4850 Record.push_back(NextCXXBaseSpecifiersID++);
4887 bool InfoHasSameExpr
4889 Record.push_back(InfoHasSameExpr);
4890 if (InfoHasSameExpr)
4910 TypeLocWriter TLW(*
this, Record);
4927 if (Idx.getIndex() == 0) {
4928 if (DoneWritingDeclsAndTypes) {
4929 assert(0 &&
"New type seen after serializing all the types to emit!");
4936 DeclTypesToEmit.push(T);
4949 TypeIdxMap::const_iterator
I = TypeIdxs.find(T);
4950 assert(I != TypeIdxs.end() &&
"Type not emitted!");
4960 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
4971 assert(!(reinterpret_cast<uintptr_t>(D) & 0x01) &&
"Invalid decl pointer");
4974 if (DoneWritingDeclsAndTypes) {
4975 assert(0 &&
"New decl seen after serializing all the decls to emit!");
4982 DeclTypesToEmit.push(const_cast<Decl *>(D));
4997 assert(DeclIDs.find(D) != DeclIDs.end() &&
"Declaration not emitted!");
5001 void ASTWriter::associateDeclWithFile(
const Decl *D,
DeclID ID) {
5014 if (isa<ParmVarDecl>(D))
5023 if (FID.isInvalid())
5027 DeclIDInFileInfo *&Info = FileDeclIDs[FID];
5029 Info =
new DeclIDInFileInfo();
5031 std::pair<unsigned, serialization::DeclID> LocDecl(Offset, ID);
5032 LocDeclIDsTy &Decls = Info->DeclIDs;
5034 if (Decls.empty() || Decls.back().first <=
Offset) {
5035 Decls.push_back(LocDecl);
5040 std::upper_bound(Decls.begin(), Decls.end(), LocDecl, llvm::less_first());
5042 Decls.insert(I, LocDecl);
5081 "expected an anonymous declaration");
5085 auto It = AnonymousDeclarationNumbers.find(D);
5086 if (It == AnonymousDeclarationNumbers.end()) {
5089 AnonymousDeclarationNumbers[ND] = Number;
5092 It = AnonymousDeclarationNumbers.find(D);
5093 assert(It != AnonymousDeclarationNumbers.end() &&
5094 "declaration not found within its lexical context");
5156 NestedNames.push_back(NNS);
5160 Record.push_back(NestedNames.size());
5161 while(!NestedNames.empty()) {
5162 NNS = NestedNames.pop_back_val();
5164 Record.push_back(Kind);
5204 NestedNames.push_back(NNS);
5208 Record.push_back(NestedNames.size());
5209 while(!NestedNames.empty()) {
5210 NNS = NestedNames.pop_back_val();
5213 Record.push_back(Kind);
5251 Record.push_back(Kind);
5259 Record.push_back(OvT->
size());
5260 for (
const auto &I : *OvT)
5304 Record.push_back(Arg.
getKind());
5328 Record.push_back(*NumExpansions + 1);
5330 Record.push_back(0);
5346 assert(TemplateParams &&
"No TemplateParams!");
5350 Record.push_back(TemplateParams->
size());
5351 for (
const auto &
P : *TemplateParams)
5359 assert(TemplateArgs &&
"No TemplateArgs!");
5360 Record.push_back(TemplateArgs->
size());
5361 for (
int i=0, e = TemplateArgs->
size(); i != e; ++i)
5368 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
5379 Record.push_back(Set.
size());
5383 Record.push_back(I.getAccess());
5402 unsigned N = CXXBaseSpecifiersToWrite.size();
5403 for (
unsigned I = 0; I != N; ++
I) {
5407 unsigned Index = CXXBaseSpecifiersToWrite[
I].ID - 1;
5408 if (Index == CXXBaseSpecifiersOffsets.size())
5409 CXXBaseSpecifiersOffsets.push_back(Stream.GetCurrentBitNo());
5411 if (Index > CXXBaseSpecifiersOffsets.size())
5412 CXXBaseSpecifiersOffsets.resize(Index + 1);
5413 CXXBaseSpecifiersOffsets[Index] = Stream.GetCurrentBitNo();
5417 *BEnd = CXXBaseSpecifiersToWrite[
I].BasesEnd;
5418 Record.push_back(BEnd - B);
5419 for (; B != BEnd; ++B)
5427 assert(N == CXXBaseSpecifiersToWrite.size() &&
5428 "added more base specifiers while writing base specifiers");
5429 CXXBaseSpecifiersToWrite.clear();
5434 unsigned NumCtorInitializers,
5436 Record.push_back(NumCtorInitializers);
5437 for (
unsigned i=0; i != NumCtorInitializers; ++i) {
5473 unsigned N = CXXCtorInitializersToWrite.size();
5475 for (
auto &Init : CXXCtorInitializersToWrite) {
5479 unsigned Index = Init.ID - 1;
5480 if (Index == CXXCtorInitializersOffsets.size())
5481 CXXCtorInitializersOffsets.push_back(Stream.GetCurrentBitNo());
5483 if (Index > CXXCtorInitializersOffsets.size())
5484 CXXCtorInitializersOffsets.resize(Index + 1);
5485 CXXCtorInitializersOffsets[Index] = Stream.GetCurrentBitNo();
5495 assert(N == CXXCtorInitializersToWrite.size() &&
5496 "added more ctor initializers while writing ctor initializers");
5497 CXXCtorInitializersToWrite.clear();
5501 auto &Data = D->data();
5502 Record.push_back(Data.IsLambda);
5503 Record.push_back(Data.UserDeclaredConstructor);
5504 Record.push_back(Data.UserDeclaredSpecialMembers);
5505 Record.push_back(Data.Aggregate);
5506 Record.push_back(Data.PlainOldData);
5507 Record.push_back(Data.Empty);
5508 Record.push_back(Data.Polymorphic);
5509 Record.push_back(Data.Abstract);
5510 Record.push_back(Data.IsStandardLayout);
5511 Record.push_back(Data.HasNoNonEmptyBases);
5512 Record.push_back(Data.HasPrivateFields);
5513 Record.push_back(Data.HasProtectedFields);
5514 Record.push_back(Data.HasPublicFields);
5515 Record.push_back(Data.HasMutableFields);
5516 Record.push_back(Data.HasVariantMembers);
5517 Record.push_back(Data.HasOnlyCMembers);
5518 Record.push_back(Data.HasInClassInitializer);
5519 Record.push_back(Data.HasUninitializedReferenceMember);
5520 Record.push_back(Data.NeedOverloadResolutionForMoveConstructor);
5521 Record.push_back(Data.NeedOverloadResolutionForMoveAssignment);
5522 Record.push_back(Data.NeedOverloadResolutionForDestructor);
5523 Record.push_back(Data.DefaultedMoveConstructorIsDeleted);
5524 Record.push_back(Data.DefaultedMoveAssignmentIsDeleted);
5525 Record.push_back(Data.DefaultedDestructorIsDeleted);
5526 Record.push_back(Data.HasTrivialSpecialMembers);
5527 Record.push_back(Data.DeclaredNonTrivialSpecialMembers);
5528 Record.push_back(Data.HasIrrelevantDestructor);
5529 Record.push_back(Data.HasConstexprNonCopyMoveConstructor);
5530 Record.push_back(Data.DefaultedDefaultConstructorIsConstexpr);
5531 Record.push_back(Data.HasConstexprDefaultConstructor);
5532 Record.push_back(Data.HasNonLiteralTypeFieldsOrBases);
5533 Record.push_back(Data.ComputedVisibleConversions);
5534 Record.push_back(Data.UserProvidedDefaultConstructor);
5535 Record.push_back(Data.DeclaredSpecialMembers);
5536 Record.push_back(Data.ImplicitCopyConstructorHasConstParam);
5537 Record.push_back(Data.ImplicitCopyAssignmentHasConstParam);
5538 Record.push_back(Data.HasDeclaredCopyConstructorWithConstParam);
5539 Record.push_back(Data.HasDeclaredCopyAssignmentWithConstParam);
5542 Record.push_back(Data.NumBases);
5543 if (Data.NumBases > 0)
5548 Record.push_back(Data.NumVBases);
5549 if (Data.NumVBases > 0)
5559 if (Data.IsLambda) {
5560 auto &Lambda = D->getLambdaData();
5561 Record.push_back(Lambda.Dependent);
5562 Record.push_back(Lambda.IsGenericLambda);
5563 Record.push_back(Lambda.CaptureDefault);
5564 Record.push_back(Lambda.NumCaptures);
5565 Record.push_back(Lambda.NumExplicitCaptures);
5566 Record.push_back(Lambda.ManglingNumber);
5569 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
5593 assert(Reader &&
"Cannot remove chain");
5594 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
5595 assert(FirstDeclID == NextDeclID &&
5596 FirstTypeID == NextTypeID &&
5597 FirstIdentID == NextIdentID &&
5598 FirstMacroID == NextMacroID &&
5599 FirstSubmoduleID == NextSubmoduleID &&
5600 FirstSelectorID == NextSelectorID &&
5601 "Setting chain after writing has started.");
5613 NextDeclID = FirstDeclID;
5614 NextTypeID = FirstTypeID;
5615 NextIdentID = FirstIdentID;
5616 NextMacroID = FirstMacroID;
5617 NextSelectorID = FirstSelectorID;
5618 NextSubmoduleID = FirstSubmoduleID;
5623 IdentID &StoredID = IdentifierIDs[II];
5630 MacroID &StoredID = MacroIDs[MI];
5641 TypeIdx &StoredIdx = TypeIdxs[T];
5655 assert(MacroDefinitions.find(MD) == MacroDefinitions.end());
5656 MacroDefinitions[MD] =
ID;
5660 assert(SubmoduleIDs.find(Mod) == SubmoduleIDs.end());
5661 SubmoduleIDs[Mod] =
ID;
5666 assert(!WritingAST &&
"Already writing the AST!");
5667 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
5669 if (RD->isFromASTFile()) {
5674 "completed a tag from another module but not by instantiation?");
5675 DeclUpdates[RD].push_back(
5696 if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC))
5706 assert(!WritingAST &&
"Already writing the AST!");
5707 if (UpdatedDeclContexts.insert(DC) && !cast<Decl>(DC)->isFromASTFile()) {
5711 for (
auto *Child : DC->
decls())
5712 UpdatingVisibleDecls.push_back(Child);
5714 UpdatingVisibleDecls.push_back(D);
5725 if (!isa<CXXMethodDecl>(D))
5730 assert(!WritingAST &&
"Already writing the AST!");
5735 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
5737 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
5742 ->castAs<FunctionProtoType>()
5743 ->getExceptionSpecType()))
5749 assert(!WritingAST &&
"Already writing the AST!");
5751 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
5752 DeclUpdates[D].push_back(
5759 assert(!WritingAST &&
"Already writing the AST!");
5760 assert(Delete &&
"Not given an operator delete");
5762 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
5768 assert(!WritingAST &&
"Already writing the AST!");
5777 assert(!WritingAST &&
"Already writing the AST!");
5785 assert(!WritingAST &&
"Already writing the AST!");
5791 DeclUpdates[D].push_back(
5797 assert(!WritingAST &&
"Already writing the AST!");
5801 DeclUpdates[D].push_back(
5807 assert(!WritingAST &&
"Already writing the AST!");
5811 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
5812 ObjCClassesWithCategories.insert(
5817 assert(!WritingAST &&
"Already writing the AST!");
5825 assert(!WritingAST &&
"Already writing the AST!");
5833 assert(!WritingAST &&
"Already writing the AST!");
5834 assert(D->
isHidden() &&
"expected a hidden declaration");
5840 assert(!WritingAST &&
"Already writing the AST!");
void AddTemplateArgument(const TemplateArgument &Arg, RecordDataImpl &Record)
Emit a template argument.
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.
unsigned getNumArrayIndices() const
Determine the number of implicit array indices used while described an array member initialization...
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)
void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override
A new declaration with name has been added to a DeclContext.
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.
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
unsigned getDepth() const
Record code for the signature that identifiers this AST file.
no exception specification
void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo, RecordDataImpl &Record)
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.
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
void FunctionDefinitionInstantiated(const FunctionDecl *D) override
A function template's definition was instantiated.
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...
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.
void AddAPInt(const llvm::APInt &Value, RecordDataImpl &Record)
Emit an integral value.
A CXXReinterpretCastExpr record.
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
A 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...
void MacroDefinitionRead(serialization::PreprocessedEntityID ID, MacroDefinitionRecord *MD) override
A macro definition was read from the AST file.
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.
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.
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
unsigned size() const
Number of modules loaded.
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
Decl - This represents one declaration (or definition), e.g.
An ImplicitCastExpr record.
Defines the FileSystemStatCache interface.
void CompletedTagDefinition(const TagDecl *D) override
A new TagDecl definition was completed.
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). ...
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
Defines the clang::MacroInfo and clang::MacroDirective classes.
A CXXOperatorCallExpr record.
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...
TemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon, QualType Aliased)
void ReaderInitialized(ASTReader *Reader) override
The ASTReader was initialized.
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...
DependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, unsigned NumArgs, const TemplateArgument *Args, QualType Canon)
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
void AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordDataImpl &Record)
Emits a reference to a declarator info.
Class that performs name lookup into a DeclContext stored in an AST file.
Writer for the on-disk hash table.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
SourceLocation getRParenLoc() const
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.
void AddTemplateName(TemplateName Name, RecordDataImpl &Record)
Emit a template name.
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.
void AddCXXCtorInitializersRef(ArrayRef< CXXCtorInitializer * > Inits, RecordDataImpl &Record)
Emit the ID for a CXXCtorInitializer array and register the array for later serialization.
unsigned getIndex() const
Record code for enabled OpenCL extensions.
Record code for the module build directory.
Floating point control options.
void * getAsOpaquePtr() const
An ElaboratedType record.
void AddTypeRef(QualType T, RecordDataImpl &Record)
Emit a reference to a type.
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.
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.
const llvm::APInt & getSize() const
static unsigned CreateSLocBufferBlobAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a buffer's blob.
A ClassTemplateDecl record.
SourceLocation getIncludeLoc() const
unsigned NumPreprocessedEntities
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.
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...
Expr * getInit() const
Get the initializer.
Wrapper for source info for member pointers.
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
void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) override
A declaration is marked as OpenMP threadprivate which was not previously marked as threadprivate...
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
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*.
void AddCXXTemporary(const CXXTemporary *Temp, RecordDataImpl &Record)
Emit a CXXTemporary.
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.
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
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.
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.
unsigned getNumParams() const
RecordDecl - Represents a struct/union/class.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
void AddQualifierInfo(const QualifierInfo &Info, RecordDataImpl &Record)
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.
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
void AddTypeLoc(TypeLoc TL, RecordDataImpl &Record)
Emits a type with source-location information.
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...
void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) override
A definition has been made visible by being redefined locally.
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
bool isMemberInitializer() const
Determine whether this initializer is initializing a non-static data member.
The unsigned 128-bit integer type.
Record code for the module map file that was used to build this AST file.
void ResolvedOperatorDelete(const CXXDestructorDecl *DD, const FunctionDecl *Delete) override
A virtual destructor's operator delete has been resolved.
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
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'.
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...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Capturing by copy (a.k.a., by value)
IndirectFieldDecl * getIndirectMember() const
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.
ModuleManager & getModuleManager()
Retrieve the module manager.
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.
void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II) override
An identifier was deserialized from the AST file.
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.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
bool needsExtraLocalData() const
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
Record code for #pragma diagnostic mappings.
Module * Parent
The parent of this module.
void AddTemplateParameterList(const TemplateParameterList *TemplateParams, RecordDataImpl &Record)
Emit a template parameter list.
Record code for floating point #pragma options.
void AddSelectorRef(Selector, RecordDataImpl &Record)
Emit a Selector (which is a smart pointer reference).
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.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location...
TypeID MakeTypeID(ASTContext &Context, QualType T, IdxForTypeTy IdxForType)
Record code for an array of all of the (sub)modules that were imported by the AST file...
submodule_iterator submodule_end()
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
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
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg, RecordDataImpl &Record)
Emits a template argument location.
VarDecl * getCapturedVar() const
Retrieve the declaration of the local variable being captured.
A marker record that indicates that we are at the end of an expression.
A ClassTemplateSpecializationDecl record.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
tok::TokenKind getKind() const
A BlockPointerType record.
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
void StaticDataMemberInstantiated(const VarDecl *D) override
A static data member was implicitly instantiated.
A MemberPointerType record.
Represents an ObjC class declaration.
bool isWritten() const
Determine whether this initializer is explicitly written in the source code.
ObjCMethodDecl * getMethod() const
SourceLocation getTypeofLoc() const
detail::InMemoryDirectory::const_iterator I
SourceLocation getTypeArgsLAngleLoc() const
unsigned getNumParams() const
void AddDeclarationName(DeclarationName Name, RecordDataImpl &Record)
Emit a declaration name.
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.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Represents an extended vector type where either the type or size is dependent.
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
A SubstTemplateTypeParmPackType record.
TypeCode
Record codes for each kind of type.
DiagnosticsEngine & getDiagnostics() const
Iterator that walks over the list of categories, filtering out those that do not meet specific criter...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
unsigned getObjCOrBuiltinID() const
IdentifierInfo * getAlias() const
SourceLocation getKWLoc() const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
unsigned IsSystem
Whether this is a "system" module (which assumes that all headers in it are system headers)...
The block containing information about the source manager.
bool isCPlusPlusOperatorKeyword() const
void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, const ObjCInterfaceDecl *IFD) override
A new objc category class was added for an interface.
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
void AddedAttributeToRecord(const Attr *Attr, const RecordDecl *Record) override
An attribute was added to a RecordDecl.
void SelectorRead(serialization::SelectorID ID, Selector Sel) override
A selector was read from the AST file.
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.
void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, RecordDataImpl &Record)
Emit a nested name specifier with source-location information.
Optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce...
QualType getInjectedSpecializationType() const
void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override
A module definition was read from the AST file.
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...
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
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
unsigned getOwningModuleID() const
Retrieve the global ID of the module that owns this particular declaration.
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.
ID
Defines the set of possible language-specific address spaces.
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...
Exposes information about the current target.
A record containing CXXBaseSpecifiers.
Represents an array type in C++ whose size is a value-dependent expression.
void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs, RecordDataImpl &Record)
Emit a template argument list.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
SourceLocation getElaboratedKeywordLoc() const
void FlushCXXBaseSpecifiers()
Flush all of the C++ base specifier sets that have been added via AddCXXBaseSpecifiersRef().
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
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.
SourceLocation getLParenLoc() const
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.
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...
SourceLocation getMemberLocation() const
bool isSubModuleOf(const Module *Other) const
Determine whether this module is a submodule of the given other module.
void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base, RecordDataImpl &Record)
Emit a C++ base specifier.
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.
void FlushPendingAfterDecl()
Flush all pending records that are tacked onto the end of decl and decl update records.
Wrapper for source info for enum types.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
A block containing a module file extension.
unsigned getNumTokens() const
Return the number of tokens that this macro expands to.
bool hasTrailingReturn() const
std::string FileName
The file name of the module file.
A NamespaceAliasDecl record.
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Record code for an update to a decl context's lookup table.
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.
const unsigned VERSION_MINOR
AST file minor version number supported by this version of Clang.
SourceLocation getModuleImportLoc(Module *M) const
A DesignatedInitUpdateExpr record.
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.
SourceLocation getExpansionLocEnd() const
QualType getElementType() const
void MacroRead(serialization::MacroID ID, MacroInfo *MI) override
A macro was read from the AST file.
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. ...
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
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.
void AddAPSInt(const llvm::APSInt &Value, RecordDataImpl &Record)
Emit a signed integral value.
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
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, RecordDataImpl &Record)
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.
Record code for the table of offsets to CXXBaseSpecifier sets.
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...
TagDecl - Represents the declaration of a struct/union/class/enum.
void DefaultArgumentInstantiated(const ParmVarDecl *D) override
A default argument was instantiated.
ASTContext & getASTContext() const LLVM_READONLY
unsigned getOffset() const
bool isPackExpansion() const
Determine whether this base specifier is a pack expansion.
virtual void writeExtensionContents(Sema &SemaRef, llvm::BitstreamWriter &Stream)=0
Write the contents of the extension block into the given bitstream.
This is so that older clang versions, before the introduction of the control block, can read and reject the newer PCH format.
IdentifierTable & getIdentifierTable()
VectorKind getVectorKind() const
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Cached information about one file (either on disk or in the virtual file system). ...
Metadata describing this particular extension.
static bool shouldIgnoreMacro(MacroDirective *MD, bool IsModule, const Preprocessor &PP)
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.
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.
bool isBaseVirtual() const
Returns whether the base is virtual or not.
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...
void CompletedImplicitDefinition(const FunctionDecl *D) override
An implicit member got a definition.
SourceLocation getRParenLoc() const
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
void AddCXXDefinitionData(const CXXRecordDecl *D, RecordDataImpl &Record)
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.
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.
ModuleFileExtension * getExtension() const
Retrieve the module file extension with which this writer is associated.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void AddNestedNameSpecifier(NestedNameSpecifier *NNS, RecordDataImpl &Record)
Emit a nested name specifier.
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.
bool isFileContext() const
Record code for the extra statistics we gather while generating an AST file.
FunctionDecl * getcudaConfigureCallDecl()
int getSourceOrder() const
Return the source position of the initializer, counting from 0.
SourceLocation getKWLoc() const
static void addExceptionSpec(ASTWriter &Writer, const FunctionProtoType *T, ASTWriter::RecordDataImpl &Record)
An array of decls optimized for the common case of only containing one entry.
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)
void AddCXXBaseSpecifiersRef(CXXBaseSpecifier const *Bases, CXXBaseSpecifier const *BasesEnd, RecordDataImpl &Record)
Emit a set of C++ base specifiers to the record.
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.
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. ...
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.
Record code for a decl replacement block.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc, DeclarationName Name, RecordDataImpl &Record)
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.
void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) override
A function's return type has been deduced.
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.
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
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.
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.
void AddASTTemplateArgumentListInfo(const ASTTemplateArgumentListInfo *ASTTemplArgList, RecordDataImpl &Record)
Emits an AST template argument list info.
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.
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
void AddUnresolvedSet(const ASTUnresolvedSet &Set, RecordDataImpl &Record)
Emit a UnresolvedSet structure.
DeclarationName - The name of a declaration.
Record code for the Objective-C method pool,.
const MacroInfo * getMacroInfo() const
Record of updates for a declaration that was modified after being deserialized.
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 ...
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
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*.
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.
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
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
Represents a C++ base or member initializer.
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 ResolvedExceptionSpec(const FunctionDecl *FD) override
A function's exception specification has been evaluated or instantiated.
const DeclarationNameLoc & getInfo() const
void FlushCXXCtorInitializers()
Flush all of the C++ constructor initializer lists that have been added via AddCXXCtorInitializersRef...
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 pointer.
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
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.
void AddStmt(Stmt *S)
Add the given statement or expression to the queue of statements to emit.
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.
void FlushStmts()
Flush all of the statements and expressions that have been added to the queue via AddStmt()...
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
An TemplateTypeParmType record.
void DeclarationMarkedUsed(const Decl *D) override
A declaration is marked used which was not previously marked used.
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
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.
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.
Record code for the table of offsets to CXXCtorInitializers lists.
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.
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.
VarDecl * getArrayIndex(unsigned I)
Retrieve a particular array index variable used to describe an array member initialization.
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
QualType getjmp_bufType() const
Retrieve the C jmp_buf type.
SourceLocation getRAngleLoc() const
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 ...
void AddCXXCtorInitializers(const CXXCtorInitializer *const *CtorInitializers, unsigned NumCtorInitializers, RecordDataImpl &Record)
Emit a CXXCtorInitializer array.
Contains a late templated function.
OverloadedOperatorKind getOperatorKind() const
Record code for weak undeclared identifiers.
The block containing information about the preprocessor.
SourceLocation getAmpLoc() const
SourceLocation getLAngleLoc() const
uint32_t TypeID
An ID number that refers to a type in an AST file.
unsigned getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where in the...
Wrapper for source info for builtin types.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
A set of overloaded template declarations.
Wrapper for template type parameters.
Record code for the headers search options table.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
NamedDecl - This represents a decl with a name.
AST file metadata, including the AST file version number and information about the compiler used to b...
static void EmitRecordID(unsigned ID, const char *Name, llvm::BitstreamWriter &Stream, ASTWriter::RecordDataImpl &Record)
The block of input files, which were used as inputs to create this AST file.
ObjCMethodList * getNext() const
unsigned IsExplicit
Whether this is an explicit submodule.
NestedNameSpecifierLoc getQualifierLoc() const
Represents a C array with a specified size that is not an integer-constant-expression.
void numberAnonymousDeclsWithin(const DeclContext *DC, Fn Visit)
Visit each declaration within DC that needs an anonymous declaration number and call Visit with the d...
unsigned LocalNumTypes
The number of types in this AST file.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
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.
void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) override
An implicit member was added after the definition was completed.
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.
void TypeRead(serialization::TypeIdx Idx, QualType T) override
A type was deserialized from the AST file.
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.
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. ...
void AddAPFloat(const llvm::APFloat &Value, RecordDataImpl &Record)
Emit a floating-point value.
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 ...