71 #include "llvm/ADT/APFloat.h" 72 #include "llvm/ADT/APInt.h" 73 #include "llvm/ADT/APSInt.h" 74 #include "llvm/ADT/ArrayRef.h" 75 #include "llvm/ADT/DenseMap.h" 76 #include "llvm/ADT/Hashing.h" 77 #include "llvm/ADT/Optional.h" 78 #include "llvm/ADT/PointerIntPair.h" 79 #include "llvm/ADT/STLExtras.h" 80 #include "llvm/ADT/ScopeExit.h" 81 #include "llvm/ADT/SmallSet.h" 82 #include "llvm/ADT/SmallString.h" 83 #include "llvm/ADT/SmallVector.h" 84 #include "llvm/ADT/StringMap.h" 85 #include "llvm/ADT/StringRef.h" 86 #include "llvm/Bitstream/BitCodes.h" 87 #include "llvm/Bitstream/BitstreamWriter.h" 88 #include "llvm/Support/Casting.h" 89 #include "llvm/Support/Compression.h" 90 #include "llvm/Support/DJB.h" 91 #include "llvm/Support/Endian.h" 92 #include "llvm/Support/EndianStream.h" 93 #include "llvm/Support/Error.h" 94 #include "llvm/Support/ErrorHandling.h" 95 #include "llvm/Support/MemoryBuffer.h" 96 #include "llvm/Support/OnDiskHashTable.h" 97 #include "llvm/Support/Path.h" 98 #include "llvm/Support/SHA1.h" 99 #include "llvm/Support/VersionTuple.h" 100 #include "llvm/Support/raw_ostream.h" 115 using namespace clang;
118 template <
typename T,
typename Allocator>
119 static StringRef
bytes(
const std::vector<T, Allocator> &
v) {
120 if (v.empty())
return StringRef();
121 return StringRef(reinterpret_cast<const char*>(&v[0]),
122 sizeof(T) * v.size());
125 template <
typename T>
126 static StringRef
bytes(
const SmallVectorImpl<T> &
v) {
127 return StringRef(reinterpret_cast<const char*>(v.data()),
128 sizeof(T) * v.size());
145 unsigned AbbrevToUse = 0;
149 : Writer(Writer), Record(Writer, Record) {}
152 return Record.
Emit(Code, AbbrevToUse);
161 AbbrevToUse = Writer.TypeExtQualAbbrev;
166 #define TYPE(Class, Base) \ 167 case Type::Class: Visit##Class##Type(cast<Class##Type>(T)); break; 168 #define ABSTRACT_TYPE(Class, Base) 169 #include "clang/AST/TypeNodes.def" 176 void VisitTagType(
const TagType *T);
178 #define TYPE(Class, Base) void Visit##Class##Type(const Class##Type *T); 179 #define ABSTRACT_TYPE(Class, Base) 180 #include "clang/AST/TypeNodes.def" 185 void ASTTypeWriter::VisitBuiltinType(
const BuiltinType *T) {
186 llvm_unreachable(
"Built-in types are never serialized");
189 void ASTTypeWriter::VisitComplexType(
const ComplexType *T) {
194 void ASTTypeWriter::VisitPointerType(
const PointerType *T) {
199 void ASTTypeWriter::VisitDecayedType(
const DecayedType *T) {
204 void ASTTypeWriter::VisitAdjustedType(
const AdjustedType *T) {
257 void ASTTypeWriter::VisitVectorType(
const VectorType *T) {
264 void ASTTypeWriter::VisitExtVectorType(
const ExtVectorType *T) {
276 Record.push_back(C.
getCC());
286 VisitFunctionType(T);
308 VisitFunctionType(T);
317 for (
unsigned I = 0, N = T->
getNumParams(); I != N; ++I)
321 for (
unsigned I = 0, N = T->
getNumParams(); I != N; ++I)
334 Record.AddDeclRef(T->
getDecl());
338 void ASTTypeWriter::VisitTypedefType(
const TypedefType *T) {
339 Record.AddDeclRef(T->
getDecl());
345 void ASTTypeWriter::VisitTypeOfExprType(
const TypeOfExprType *T) {
350 void ASTTypeWriter::VisitTypeOfType(
const TypeOfType *T) {
355 void ASTTypeWriter::VisitDecltypeType(
const DecltypeType *T) {
368 void ASTTypeWriter::VisitAutoType(
const AutoType *T) {
377 void ASTTypeWriter::VisitDeducedTemplateSpecializationType(
390 "Cannot serialize in the middle of a type definition");
393 void ASTTypeWriter::VisitRecordType(
const RecordType *T) {
398 void ASTTypeWriter::VisitEnumType(
const EnumType *T) {
403 void ASTTypeWriter::VisitAttributedType(
const AttributedType *T) {
411 ASTTypeWriter::VisitSubstTemplateTypeParmType(
419 ASTTypeWriter::VisitSubstTemplateTypeParmPackType(
427 ASTTypeWriter::VisitTemplateSpecializationType(
432 for (
const auto &ArgI : *T)
433 Record.AddTemplateArgument(ArgI);
434 Record.AddTypeRef(T->isTypeAlias() ? T->getAliasedType()
435 : T->isCanonicalUnqualified()
437 : T->getCanonicalTypeInternal());
450 ASTTypeWriter::VisitDependentSizedExtVectorType(
460 Record.AddStmt(const_cast<Expr*>(T->
getSizeExpr()));
467 ASTTypeWriter::VisitDependentAddressSpaceType(
480 Record.AddDeclRef(T->
getDecl());
495 ASTTypeWriter::VisitDependentTemplateSpecializationType(
501 for (
const auto &I : *T)
502 Record.AddTemplateArgument(I);
509 Record.push_back(*NumExpansions + 1);
515 void ASTTypeWriter::VisitParenType(
const ParenType *T) {
526 void ASTTypeWriter::VisitElaboratedType(
const ElaboratedType *T) {
546 Record.AddDeclRef(T->
getDecl());
548 for (
const auto *I : T->
quals())
549 Record.AddDeclRef(I);
553 void ASTTypeWriter::VisitObjCObjectType(
const ObjCObjectType *T) {
557 Record.AddTypeRef(TypeArg);
559 for (
const auto *I : T->
quals())
560 Record.AddDeclRef(I);
572 ASTTypeWriter::VisitAtomicType(
const AtomicType *T) {
578 ASTTypeWriter::VisitPipeType(
const PipeType *T) {
592 #define ABSTRACT_TYPELOC(CLASS, PARENT) 593 #define TYPELOC(CLASS, PARENT) \ 594 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc); 595 #include "clang/AST/TypeLocNodes.def" 638 Record.AddSourceLocation(TL.
getAmpLoc());
650 void TypeLocWriter::VisitArrayTypeLoc(
ArrayTypeLoc TL) {
659 VisitArrayTypeLoc(TL);
663 VisitArrayTypeLoc(TL);
667 VisitArrayTypeLoc(TL);
670 void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
672 VisitArrayTypeLoc(TL);
675 void TypeLocWriter::VisitDependentAddressSpaceTypeLoc(
679 Record.AddSourceLocation(range.
getBegin());
680 Record.AddSourceLocation(range.
getEnd());
684 void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
693 void TypeLocWriter::VisitDependentVectorTypeLoc(
713 VisitFunctionTypeLoc(TL);
717 VisitFunctionTypeLoc(TL);
755 Record.AddSourceLocation(TL.
getKWLoc());
761 void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
765 void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
774 void TypeLocWriter::VisitEnumTypeLoc(
EnumTypeLoc TL) {
786 void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
791 void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
796 void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
807 void TypeLocWriter::VisitParenTypeLoc(
ParenTypeLoc TL) {
831 void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
839 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I)
869 Record.AddSourceLocation(TL.
getKWLoc());
874 void TypeLocWriter::VisitPipeTypeLoc(
PipeTypeLoc TL) {
875 Record.AddSourceLocation(TL.
getKWLoc());
878 void ASTWriter::WriteTypeAbbrevs() {
879 using namespace llvm;
881 std::shared_ptr<BitCodeAbbrev> Abv;
884 Abv = std::make_shared<BitCodeAbbrev>();
886 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
887 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
888 TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
891 Abv = std::make_shared<BitCodeAbbrev>();
894 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
895 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
896 Abv->Add(BitCodeAbbrevOp(0));
897 Abv->Add(BitCodeAbbrevOp(0));
898 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
899 Abv->Add(BitCodeAbbrevOp(0));
900 Abv->Add(BitCodeAbbrevOp(0));
901 Abv->Add(BitCodeAbbrevOp(0));
903 Abv->Add(BitCodeAbbrevOp(0));
904 Abv->Add(BitCodeAbbrevOp(0));
905 Abv->Add(BitCodeAbbrevOp(0));
906 Abv->Add(BitCodeAbbrevOp(0));
907 Abv->Add(BitCodeAbbrevOp(
EST_None));
908 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
909 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
910 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
911 TypeFunctionProtoAbbrev = Stream.EmitAbbrev(std::move(Abv));
919 llvm::BitstreamWriter &Stream,
922 Record.push_back(ID);
923 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);
926 if (!Name || Name[0] == 0)
930 Record.push_back(*Name++);
931 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME, Record);
935 llvm::BitstreamWriter &Stream,
938 Record.push_back(ID);
940 Record.push_back(*Name++);
941 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, Record);
946 #define RECORD(X) EmitRecordID(X, #X, Stream, Record) 1073 void ASTWriter::WriteBlockInfoBlock() {
1075 Stream.EnterBlockInfoBlock();
1077 #define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record) 1078 #define RECORD(X) EmitRecordID(X, #X, Stream, Record) 1081 BLOCK(CONTROL_BLOCK);
1092 BLOCK(OPTIONS_BLOCK);
1099 BLOCK(INPUT_FILES_BLOCK);
1158 BLOCK(SOURCE_MANAGER_BLOCK);
1166 BLOCK(PREPROCESSOR_BLOCK);
1174 BLOCK(SUBMODULE_BLOCK);
1195 BLOCK(COMMENTS_BLOCK);
1199 BLOCK(DECLTYPES_BLOCK);
1318 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
1324 BLOCK(EXTENSION_BLOCK);
1327 BLOCK(UNHASHED_CONTROL_BLOCK);
1344 return Changed | llvm::sys::path::remove_dots(Path);
1359 assert(Filename &&
"No file name to adjust?");
1361 if (BaseDir.empty())
1366 for (; Filename[Pos] && Pos < BaseDir.size(); ++Pos)
1367 if (Filename[Pos] != BaseDir[Pos])
1376 if (!llvm::sys::path::is_separator(Filename[Pos])) {
1377 if (!llvm::sys::path::is_separator(BaseDir.back()))
1391 return Filename + Pos;
1398 auto Hash = Hasher.result();
1402 auto LShift = [&](
unsigned char Val,
unsigned Shift) {
1403 return (uint32_t)Val <<
Shift;
1405 for (
int I = 0; I != 5; ++I)
1406 Signature[I] = LShift(Hash[I * 4 + 0], 24) | LShift(Hash[I * 4 + 1], 16) |
1407 LShift(Hash[I * 4 + 2], 8) | LShift(Hash[I * 4 + 3], 0);
1415 Stream.FlushToWord();
1416 auto StartOfUnhashedControl = Stream.GetCurrentBitNo() >> 3;
1424 if (WritingModule &&
1426 Signature = createSignature(StringRef(Buffer.begin(), StartOfUnhashedControl));
1427 Record.append(Signature.begin(), Signature.end());
1435 #define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name); 1436 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ 1437 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name())); 1438 #include "clang/Basic/DiagnosticOptions.def" 1439 Record.push_back(DiagOpts.
Warnings.size());
1440 for (
unsigned I = 0, N = DiagOpts.
Warnings.size(); I != N; ++I)
1441 AddString(DiagOpts.
Warnings[I], Record);
1442 Record.push_back(DiagOpts.
Remarks.size());
1443 for (
unsigned I = 0, N = DiagOpts.
Remarks.size(); I != N; ++I)
1444 AddString(DiagOpts.
Remarks[I], Record);
1450 WritePragmaDiagnosticMappings(Diags, WritingModule);
1460 const std::string &OutputFile) {
1461 using namespace llvm;
1467 auto MetadataAbbrev = std::make_shared<BitCodeAbbrev>();
1468 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1469 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1470 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1471 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1472 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1473 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1474 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1475 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1476 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1477 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1478 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev));
1479 assert((!WritingModule || isysroot.empty()) &&
1480 "writing module as a relocatable PCH?");
1482 RecordData::value_type Record[] = {
1486 CLANG_VERSION_MAJOR,
1487 CLANG_VERSION_MINOR,
1491 ASTHasCompilerErrors};
1492 Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
1496 if (WritingModule) {
1498 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1500 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1501 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1503 Stream.EmitRecordWithBlob(AbbrevCode, Record, WritingModule->Name);
1506 if (WritingModule && WritingModule->Directory) {
1516 WritingModule->Directory->getName() != StringRef(
".")) {
1518 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1520 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1521 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1524 Stream.EmitRecordWithBlob(AbbrevCode, Record, BaseDir);
1528 BaseDirectory.assign(BaseDir.begin(), BaseDir.end());
1529 }
else if (!isysroot.empty()) {
1531 BaseDirectory = isysroot;
1539 AddPath(WritingModule->PresumedModuleMapFile.empty()
1540 ? Map.getModuleMapFileForUniquing(WritingModule)->getName()
1541 : StringRef(WritingModule->PresumedModuleMapFile),
1545 if (
auto *AdditionalModMaps =
1546 Map.getAdditionalModuleMapFiles(WritingModule)) {
1547 Record.push_back(AdditionalModMaps->size());
1548 for (
const FileEntry *F : *AdditionalModMaps)
1549 AddPath(F->getName(), Record);
1551 Record.push_back(0);
1564 if (!M.isDirectlyImported())
1567 Record.push_back((
unsigned)M.Kind);
1568 AddSourceLocation(M.ImportLoc, Record);
1572 Record.push_back(M.Signature ? 0 : M.File->getSize());
1573 Record.push_back(M.Signature ? 0 : getTimestampForOutput(M.File));
1575 for (
auto I : M.Signature)
1576 Record.push_back(I);
1578 AddString(M.ModuleName, Record);
1579 AddPath(M.FileName, Record);
1581 Stream.EmitRecord(
IMPORTS, Record);
1590 #define LANGOPT(Name, Bits, Default, Description) \ 1591 Record.push_back(LangOpts.Name); 1592 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 1593 Record.push_back(static_cast<unsigned>(LangOpts.get##Name())); 1594 #include "clang/Basic/LangOptions.def" 1595 #define SANITIZER(NAME, ID) \ 1596 Record.push_back(LangOpts.Sanitize.has(SanitizerKind::ID)); 1597 #include "clang/Basic/Sanitizers.def" 1601 AddString(Feature, Record);
1611 AddString(I, Record);
1618 AddString(T.getTriple(), Record);
1628 AddString(TargetOpts.
Triple, Record);
1629 AddString(TargetOpts.
CPU, Record);
1630 AddString(TargetOpts.
ABI, Record);
1635 Record.push_back(TargetOpts.
Features.size());
1636 for (
unsigned I = 0, N = TargetOpts.
Features.size(); I != N; ++I) {
1637 AddString(TargetOpts.
Features[I], Record);
1652 AddString(HSOpts.
Sysroot, Record);
1656 for (
unsigned I = 0, N = HSOpts.
UserEntries.size(); I != N; ++I) {
1658 AddString(Entry.
Path, Record);
1659 Record.push_back(static_cast<unsigned>(Entry.
Group));
1690 Record.push_back(PPOpts.
Macros.size());
1691 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
1692 AddString(PPOpts.
Macros[I].first, Record);
1693 Record.push_back(PPOpts.
Macros[I].second);
1697 Record.push_back(PPOpts.
Includes.size());
1698 for (
unsigned I = 0, N = PPOpts.
Includes.size(); I != N; ++I)
1699 AddString(PPOpts.
Includes[I], Record);
1703 for (
unsigned I = 0, N = PPOpts.
MacroIncludes.size(); I != N; ++I)
1719 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1721 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1722 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1723 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
1728 EmitRecordWithPath(FileAbbrevCode, Record, MainFile->getName());
1736 if (!OutputFile.empty() && OutputFile !=
"-") {
1737 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1739 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1740 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1745 StringRef origDir = llvm::sys::path::parent_path(OutputPath);
1748 Stream.EmitRecordWithBlob(AbbrevCode, Record, origDir);
1751 WriteInputFiles(Context.SourceMgr,
1760 struct InputFileEntry {
1764 bool BufferOverridden;
1765 bool IsTopLevelModuleMap;
1773 using namespace llvm;
1778 auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
1780 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1781 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1782 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1783 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1784 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1785 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1786 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1787 unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
1791 std::deque<InputFileEntry> SortedFiles;
1795 assert(&SourceMgr.
getSLocEntry(FileID::get(I)) == SLoc);
1805 InputFileEntry Entry;
1813 SortedFiles.push_back(Entry);
1815 SortedFiles.push_front(Entry);
1818 unsigned UserFilesNum = 0;
1820 std::vector<uint64_t> InputFileOffsets;
1821 for (
const auto &Entry : SortedFiles) {
1822 uint32_t &InputFileID = InputFileIDs[Entry.File];
1823 if (InputFileID != 0)
1827 InputFileOffsets.push_back(Stream.GetCurrentBitNo());
1829 InputFileID = InputFileOffsets.size();
1831 if (!Entry.IsSystemFile)
1836 RecordData::value_type Record[] = {
1838 InputFileOffsets.size(),
1839 (uint64_t)Entry.File->getSize(),
1840 (uint64_t)getTimestampForOutput(Entry.File),
1841 Entry.BufferOverridden,
1843 Entry.IsTopLevelModuleMap};
1845 EmitRecordWithPath(IFAbbrevCode, Record, Entry.File->getName());
1851 auto OffsetsAbbrev = std::make_shared<BitCodeAbbrev>();
1853 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1854 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1856 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1857 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(std::move(OffsetsAbbrev));
1861 InputFileOffsets.size(), UserFilesNum};
1862 Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record,
bytes(InputFileOffsets));
1872 using namespace llvm;
1874 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1876 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1877 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1878 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1879 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1881 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1882 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1883 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
1884 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1885 return Stream.EmitAbbrev(std::move(Abbrev));
1891 using namespace llvm;
1893 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1895 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1896 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1897 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1898 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1899 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1900 return Stream.EmitAbbrev(std::move(Abbrev));
1907 using namespace llvm;
1909 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1913 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1914 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1915 return Stream.EmitAbbrev(std::move(Abbrev));
1921 using namespace llvm;
1923 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1925 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1926 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1927 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1928 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1929 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1930 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1931 return Stream.EmitAbbrev(std::move(Abbrev));
1937 class HeaderFileInfoTrait {
1942 llvm::StringMap<unsigned> FrameworkNameOffset;
1945 HeaderFileInfoTrait(
ASTWriter &Writer) : Writer(Writer) {}
1952 using key_type_ref =
const key_type &;
1954 using UnresolvedModule =
1955 llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
1962 using data_type_ref =
const data_type &;
1964 using hash_value_type = unsigned;
1965 using offset_type = unsigned;
1974 std::pair<unsigned, unsigned>
1975 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) {
1976 using namespace llvm::support;
1978 endian::Writer LE(Out, little);
1979 unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
1980 LE.write<uint16_t>(KeyLen);
1981 unsigned DataLen = 1 + 2 + 4 + 4;
1982 for (
auto ModInfo : Data.KnownHeaders)
1985 if (Data.Unresolved.getPointer())
1987 LE.write<uint8_t>(DataLen);
1988 return std::make_pair(KeyLen, DataLen);
1991 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
1992 using namespace llvm::support;
1994 endian::Writer LE(Out, little);
1995 LE.write<uint64_t>(key.Size);
1997 LE.write<uint64_t>(key.ModTime);
1999 Out.write(key.Filename.data(), KeyLen);
2002 void EmitData(raw_ostream &Out, key_type_ref key,
2003 data_type_ref Data,
unsigned DataLen) {
2004 using namespace llvm::support;
2006 endian::Writer LE(Out, little);
2007 uint64_t Start = Out.tell(); (void)Start;
2009 unsigned char Flags = (Data.HFI.isImport << 5)
2010 | (Data.HFI.isPragmaOnce << 4)
2011 | (Data.HFI.DirInfo << 1)
2012 | Data.HFI.IndexHeaderMapHeader;
2013 LE.write<uint8_t>(Flags);
2014 LE.write<uint16_t>(Data.HFI.NumIncludes);
2016 if (!Data.HFI.ControllingMacro)
2017 LE.write<uint32_t>(Data.HFI.ControllingMacroID);
2022 if (!Data.HFI.Framework.empty()) {
2024 llvm::StringMap<unsigned>::iterator Pos
2025 = FrameworkNameOffset.find(Data.HFI.Framework);
2026 if (Pos == FrameworkNameOffset.end()) {
2027 Offset = FrameworkStringData.size() + 1;
2028 FrameworkStringData.append(Data.HFI.Framework.begin(),
2029 Data.HFI.Framework.end());
2030 FrameworkStringData.push_back(0);
2032 FrameworkNameOffset[Data.HFI.Framework] =
Offset;
2034 Offset = Pos->second;
2036 LE.write<uint32_t>(
Offset);
2040 uint32_t
Value = (ModID << 2) | (
unsigned)Role;
2041 assert((Value >> 2) == ModID &&
"overflow in header module info");
2042 LE.write<uint32_t>(
Value);
2048 for (
auto ModInfo : Data.KnownHeaders)
2049 EmitModule(ModInfo.getModule(), ModInfo.getRole());
2050 if (Data.Unresolved.getPointer())
2051 EmitModule(Data.Unresolved.getPointer(), Data.Unresolved.getInt());
2053 assert(Out.tell() - Start == DataLen &&
"Wrong data length");
2056 const char *strings_begin()
const {
return FrameworkStringData.begin(); }
2057 const char *strings_end()
const {
return FrameworkStringData.end(); }
2065 void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
2066 HeaderFileInfoTrait GeneratorTrait(*
this);
2067 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait> Generator;
2069 unsigned NumHeaderSearchEntries = 0;
2076 if (WritingModule) {
2078 while (!Worklist.empty()) {
2079 Module *M = Worklist.pop_back_val();
2095 if (!U.Size || (!U.ModTime && IncludeTimestamps)) {
2096 PP->
Diag(U.FileNameLoc, diag::err_module_no_size_mtime_for_header)
2097 << WritingModule->getFullModuleName() << U.Size.hasValue()
2104 llvm::sys::path::append(
Filename, U.FileName);
2107 StringRef FilenameDup = strdup(
Filename.c_str());
2108 SavedStrings.push_back(FilenameDup.data());
2110 HeaderFileInfoTrait::key_type Key = {
2111 FilenameDup, *U.Size, IncludeTimestamps ? *U.ModTime : 0
2113 HeaderFileInfoTrait::data_type Data = {
2118 Generator.insert(Key, Data, GeneratorTrait);
2119 ++NumHeaderSearchEntries;
2132 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
2133 const FileEntry *File = FilesByUID[UID];
2151 if (PreparePathForOutput(FilenameTmp)) {
2154 Filename = StringRef(strdup(FilenameTmp.c_str()));
2155 SavedStrings.push_back(Filename.data());
2158 HeaderFileInfoTrait::key_type Key = {
2161 HeaderFileInfoTrait::data_type Data = {
2164 Generator.insert(Key, Data, GeneratorTrait);
2165 ++NumHeaderSearchEntries;
2170 uint32_t BucketOffset;
2172 using namespace llvm::support;
2174 llvm::raw_svector_ostream Out(TableData);
2176 endian::write<uint32_t>(Out, 0, little);
2177 BucketOffset = Generator.Emit(Out, GeneratorTrait);
2181 using namespace llvm;
2183 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2185 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2186 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2187 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2188 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2189 unsigned TableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2193 NumHeaderSearchEntries, TableData.size()};
2194 TableData.append(GeneratorTrait.strings_begin(),GeneratorTrait.strings_end());
2195 Stream.EmitRecordWithBlob(TableAbbrev, Record, TableData);
2198 for (
unsigned I = 0, N = SavedStrings.size(); I != N; ++I)
2199 free(const_cast<char *>(SavedStrings[I]));
2202 static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
2203 unsigned SLocBufferBlobCompressedAbbrv,
2204 unsigned SLocBufferBlobAbbrv) {
2205 using RecordDataType = ASTWriter::RecordData::value_type;
2210 if (llvm::zlib::isAvailable()) {
2211 llvm::Error E = llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer);
2215 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record,
2219 llvm::consumeError(std::move(E));
2223 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob);
2234 void ASTWriter::WriteSourceManagerBlock(
SourceManager &SourceMgr,
2245 unsigned SLocBufferBlobCompressedAbbrv =
2251 std::vector<uint32_t> SLocEntryOffsets;
2252 RecordData PreloadSLocs;
2258 FileID FID = FileID::get(I);
2262 SLocEntryOffsets.push_back(Stream.GetCurrentBitNo());
2275 Record.push_back(Code);
2278 Record.push_back(SLoc->
getOffset() - 2);
2286 bool EmitBlob =
false;
2289 "Writing to AST an overridden file is not supported");
2292 assert(InputFileIDs[Content->
OrigEntry] != 0 &&
"Missed file entry");
2293 Record.push_back(InputFileIDs[Content->
OrigEntry]);
2295 Record.push_back(File.NumCreatedFIDs);
2297 FileDeclIDsTy::iterator FDI = FileDeclIDs.find(FID);
2298 if (FDI != FileDeclIDs.end()) {
2299 Record.push_back(FDI->second->FirstDeclIndex);
2300 Record.push_back(FDI->second->DeclIDs.size());
2302 Record.push_back(0);
2303 Record.push_back(0);
2306 Stream.EmitRecordWithAbbrev(SLocFileAbbrv, Record);
2317 const llvm::MemoryBuffer *Buffer
2319 StringRef Name = Buffer->getBufferIdentifier();
2320 Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
2321 StringRef(Name.data(), Name.size() + 1));
2324 if (Name ==
"<built-in>")
2325 PreloadSLocs.push_back(SLocEntryOffsets.size());
2331 const llvm::MemoryBuffer *Buffer =
2333 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
2334 emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv,
2335 SLocBufferBlobAbbrv);
2352 Record.push_back(NextOffset - SLoc->
getOffset() - 1);
2353 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv, Record);
2359 if (SLocEntryOffsets.empty())
2364 using namespace llvm;
2366 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2368 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2369 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2370 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2371 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2373 RecordData::value_type Record[] = {
2376 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
2377 bytes(SLocEntryOffsets));
2391 llvm::DenseMap<int, int> FilenameMap;
2392 FilenameMap[-1] = -1;
2393 for (
const auto &L : LineTable) {
2396 for (
auto &LE : L.second) {
2397 if (FilenameMap.insert(std::make_pair(LE.FilenameID,
2398 FilenameMap.size() - 1)).second)
2399 AddPath(LineTable.getFilename(LE.FilenameID), Record);
2402 Record.push_back(0);
2405 for (
const auto &L : LineTable) {
2411 Record.push_back(L.first.ID);
2414 Record.push_back(L.second.size());
2415 for (
const auto &LE : L.second) {
2416 Record.push_back(LE.FileOffset);
2417 Record.push_back(LE.LineNo);
2418 Record.push_back(FilenameMap[LE.FilenameID]);
2419 Record.push_back((
unsigned)LE.FileKind);
2420 Record.push_back(LE.IncludeOffset);
2435 if (MI->isBuiltinMacro())
2451 void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2454 WritePreprocessorDetail(*PPRec);
2457 RecordData ModuleMacroRecord;
2468 if (SkipInfo.hasValue()) {
2469 Record.push_back(
true);
2470 AddSourceLocation(SkipInfo->HashTokenLoc, Record);
2471 AddSourceLocation(SkipInfo->IfTokenLoc, Record);
2472 Record.push_back(SkipInfo->FoundNonSkipPortion);
2473 Record.push_back(SkipInfo->FoundElse);
2474 AddSourceLocation(SkipInfo->ElseLoc, Record);
2476 Record.push_back(
false);
2479 AddSourceLocation(Cond.IfLoc, Record);
2480 Record.push_back(Cond.WasSkipping);
2481 Record.push_back(Cond.FoundNonSkip);
2482 Record.push_back(Cond.FoundElse);
2503 if (
Id.second->hadMacroDefinition() &&
2504 (!
Id.second->isFromAST() ||
2505 Id.second->hasChangedSinceDeserialization()))
2506 MacroIdentifiers.push_back(
Id.second);
2509 llvm::sort(MacroIdentifiers, llvm::less_ptr<IdentifierInfo>());
2515 auto StartOffset = Stream.GetCurrentBitNo();
2525 Record.push_back(MD->
getKind());
2526 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2527 Record.push_back(getMacroRef(DefMD->getInfo(), Name));
2528 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2529 Record.push_back(VisMD->isPublic());
2534 bool EmittedModuleMacros =
false;
2538 llvm::DenseMap<ModuleMacro*, unsigned> Visits;
2539 while (!Worklist.empty()) {
2540 auto *Macro = Worklist.pop_back_val();
2543 ModuleMacroRecord.push_back(
2544 getSubmoduleID(Macro->getOwningModule()));
2545 ModuleMacroRecord.push_back(getMacroRef(Macro->getMacroInfo(), Name));
2546 for (
auto *M : Macro->overrides())
2547 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2550 ModuleMacroRecord.clear();
2553 for (
auto *M : Macro->overrides())
2554 if (++Visits[M] == M->getNumOverridingMacros())
2555 Worklist.push_back(M);
2557 EmittedModuleMacros =
true;
2560 if (Record.empty() && !EmittedModuleMacros)
2563 IdentMacroDirectivesOffsetMap[Name] = StartOffset;
2574 std::vector<uint32_t> MacroOffsets;
2576 for (
unsigned I = 0, N = MacroInfosToEmit.size(); I != N; ++I) {
2581 if (ID < FirstMacroID) {
2582 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2587 unsigned Index = ID - FirstMacroID;
2588 if (Index == MacroOffsets.size())
2589 MacroOffsets.push_back(Stream.GetCurrentBitNo());
2591 if (Index > MacroOffsets.size())
2592 MacroOffsets.resize(Index + 1);
2594 MacroOffsets[Index] = Stream.GetCurrentBitNo();
2597 AddIdentifierRef(Name, Record);
2600 Record.push_back(MI->
isUsed());
2613 AddIdentifierRef(Param, Record);
2621 Stream.EmitRecord(Code, Record);
2625 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2630 AddToken(Tok, Record);
2631 Stream.EmitRecord(
PP_TOKEN, Record);
2640 using namespace llvm;
2642 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2644 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2645 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2646 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2648 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2650 RecordData::value_type Record[] = {
MACRO_OFFSET, MacroOffsets.size(),
2652 Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record,
bytes(MacroOffsets));
2666 unsigned NumPreprocessingRecords = 0;
2667 using namespace llvm;
2670 unsigned InclusionAbbrev = 0;
2672 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2674 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2675 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2676 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2677 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2678 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2679 InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2682 unsigned FirstPreprocessorEntityID
2683 = (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0)
2685 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2690 (void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2693 PreprocessedEntityOffsets.push_back(
2694 PPEntityOffset((*E)->getSourceRange(), Stream.GetCurrentBitNo()));
2696 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*E)) {
2698 MacroDefinitions[MD] = NextPreprocessorEntityID;
2700 AddIdentifierRef(MD->getName(), Record);
2705 if (
auto *ME = dyn_cast<MacroExpansion>(*E)) {
2706 Record.push_back(ME->isBuiltinMacro());
2707 if (ME->isBuiltinMacro())
2708 AddIdentifierRef(ME->getName(), Record);
2710 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2715 if (
auto *
ID = dyn_cast<InclusionDirective>(*E)) {
2717 Record.push_back(
ID->getFileName().size());
2718 Record.push_back(
ID->wasInQuotes());
2719 Record.push_back(static_cast<unsigned>(
ID->getKind()));
2720 Record.push_back(
ID->importedModule());
2722 Buffer +=
ID->getFileName();
2726 Buffer +=
ID->getFile()->getName();
2727 Stream.EmitRecordWithBlob(InclusionAbbrev, Record, Buffer);
2731 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2736 if (NumPreprocessingRecords > 0) {
2737 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2740 using namespace llvm;
2742 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2744 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2745 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2746 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2749 FirstPreprocessorEntityID -
2751 Stream.EmitRecordWithBlob(PPEOffsetAbbrev, Record,
2752 bytes(PreprocessedEntityOffsets));
2757 if (SkippedRanges.size() > 0) {
2758 std::vector<PPSkippedRange> SerializedSkippedRanges;
2759 SerializedSkippedRanges.reserve(SkippedRanges.size());
2760 for (
auto const& Range : SkippedRanges)
2761 SerializedSkippedRanges.emplace_back(Range);
2763 using namespace llvm;
2764 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2766 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2767 unsigned PPESkippedRangeAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2771 Stream.EmitRecordWithBlob(PPESkippedRangeAbbrev, Record,
2772 bytes(SerializedSkippedRanges));
2780 llvm::DenseMap<Module *, unsigned>::iterator Known = SubmoduleIDs.find(Mod);
2781 if (Known != SubmoduleIDs.end())
2782 return Known->second;
2785 if (Top != WritingModule &&
2786 (getLangOpts().CompilingPCH ||
2787 !Top->fullModuleNameIs(StringRef(getLangOpts().CurrentModule))))
2790 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2793 unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2797 unsigned ID = getLocalOrImportedSubmoduleID(Mod);
2798 assert((ID || !Mod) &&
2799 "asked for module ID for non-local, non-imported module");
2806 unsigned ChildModules = 0;
2808 Sub != SubEnd; ++Sub)
2811 return ChildModules + 1;
2814 void ASTWriter::WriteSubmodules(
Module *WritingModule) {
2819 using namespace llvm;
2821 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2823 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2824 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2825 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2826 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2827 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2828 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2829 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2830 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2831 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2832 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2833 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2834 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2835 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2836 unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2838 Abbrev = std::make_shared<BitCodeAbbrev>();
2840 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2841 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2843 Abbrev = std::make_shared<BitCodeAbbrev>();
2845 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2846 unsigned HeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2848 Abbrev = std::make_shared<BitCodeAbbrev>();
2850 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2851 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2853 Abbrev = std::make_shared<BitCodeAbbrev>();
2855 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2856 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2858 Abbrev = std::make_shared<BitCodeAbbrev>();
2860 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2861 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2862 unsigned RequiresAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2864 Abbrev = std::make_shared<BitCodeAbbrev>();
2866 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2867 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2869 Abbrev = std::make_shared<BitCodeAbbrev>();
2871 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2872 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2874 Abbrev = std::make_shared<BitCodeAbbrev>();
2876 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2877 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2879 Abbrev = std::make_shared<BitCodeAbbrev>();
2881 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2882 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2884 Abbrev = std::make_shared<BitCodeAbbrev>();
2886 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2887 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2888 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2890 Abbrev = std::make_shared<BitCodeAbbrev>();
2892 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2893 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2895 Abbrev = std::make_shared<BitCodeAbbrev>();
2897 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2898 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2899 unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2901 Abbrev = std::make_shared<BitCodeAbbrev>();
2903 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2904 unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2907 RecordData::value_type Record[] = {
2913 std::queue<Module *> Q;
2914 Q.push(WritingModule);
2915 while (!Q.empty()) {
2918 unsigned ID = getSubmoduleID(Mod);
2920 uint64_t ParentID = 0;
2922 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
2923 ParentID = SubmoduleIDs[Mod->
Parent];
2931 (RecordData::value_type)Mod->
Kind,
2941 Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->
Name);
2947 Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
2953 Stream.EmitRecordWithBlob(UmbrellaAbbrev, Record,
2954 UmbrellaHeader.NameAsWritten);
2957 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev, Record,
2958 UmbrellaDir.NameAsWritten);
2963 unsigned RecordKind;
2974 for (
auto &HL : HeaderLists) {
2975 RecordData::value_type Record[] = {HL.RecordKind};
2976 for (
auto &H : Mod->
Headers[HL.HeaderKind])
2977 Stream.EmitRecordWithBlob(HL.Abbrev, Record, H.NameAsWritten);
2984 for (
auto *H : TopHeaders)
2985 Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, H->getName());
2992 Record.push_back(getSubmoduleID(I));
2999 for (
const auto &E : Mod->
Exports) {
3002 Record.push_back(getSubmoduleID(E.getPointer()));
3003 Record.push_back(E.getInt());
3016 Stream.EmitRecordWithBlob(LinkLibraryAbbrev, Record, LL.Library);
3024 getSubmoduleID(C.Other)};
3025 Stream.EmitRecordWithBlob(ConflictAbbrev, Record, C.Message);
3031 Stream.EmitRecordWithBlob(ConfigMacroAbbrev, Record, CM);
3037 Inits.push_back(GetDeclRef(D));
3044 Stream.EmitRecordWithBlob(ExportAsAbbrev, Record, Mod->
ExportAsModule);
3054 assert((NextSubmoduleID - FirstSubmoduleID ==
3056 "Wrong # of submodules; found a reference to a non-local, " 3057 "non-imported submodule?");
3062 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
3064 unsigned CurrID = 0;
3067 auto EncodeDiagStateFlags =
3068 [](
const DiagnosticsEngine::DiagState *DS) ->
unsigned {
3069 unsigned Result = (unsigned)DS->ExtBehavior;
3071 {(unsigned)DS->IgnoreAllWarnings, (
unsigned)DS->EnableAllWarnings,
3072 (unsigned)DS->WarningsAsErrors, (
unsigned)DS->ErrorsAsFatal,
3073 (unsigned)DS->SuppressSystemWarnings})
3074 Result = (Result << 1) | Val;
3078 unsigned Flags = EncodeDiagStateFlags(Diag.DiagStatesByLoc.FirstDiagState);
3079 Record.push_back(Flags);
3081 auto AddDiagState = [&](
const DiagnosticsEngine::DiagState *
State,
3082 bool IncludeNonPragmaStates) {
3085 assert(Flags == EncodeDiagStateFlags(State) &&
3086 "diag state flags vary in single AST file");
3088 unsigned &DiagStateID = DiagStateIDMap[
State];
3089 Record.push_back(DiagStateID);
3091 if (DiagStateID == 0) {
3092 DiagStateID = ++CurrID;
3095 auto SizeIdx = Record.size();
3096 Record.emplace_back();
3097 for (
const auto &I : *State) {
3098 if (I.second.isPragma() || IncludeNonPragmaStates) {
3099 Record.push_back(I.first);
3100 Record.push_back(I.second.serialize());
3104 Record[SizeIdx] = (Record.size() - SizeIdx) / 2;
3108 AddDiagState(Diag.DiagStatesByLoc.FirstDiagState, isModule);
3111 auto NumLocationsIdx = Record.size();
3112 Record.emplace_back();
3115 unsigned NumLocations = 0;
3116 for (
auto &FileIDAndFile : Diag.DiagStatesByLoc.Files) {
3117 if (!FileIDAndFile.first.isValid() ||
3118 !FileIDAndFile.second.HasLocalTransitions)
3123 assert(!Loc.
isInvalid() &&
"start loc for valid FileID is invalid");
3124 AddSourceLocation(Loc, Record);
3126 Record.push_back(FileIDAndFile.second.StateTransitions.size());
3127 for (
auto &StatePoint : FileIDAndFile.second.StateTransitions) {
3128 Record.push_back(StatePoint.Offset);
3129 AddDiagState(StatePoint.State,
false);
3134 Record[NumLocationsIdx] = NumLocations;
3142 AddSourceLocation(Diag.DiagStatesByLoc.CurDiagStateLoc, Record);
3143 AddDiagState(Diag.DiagStatesByLoc.CurDiagState,
false);
3153 void ASTWriter::WriteType(
QualType T) {
3154 TypeIdx &IdxRef = TypeIdxs[T];
3156 IdxRef =
TypeIdx(NextTypeID++);
3159 assert(Idx.
getIndex() >= FirstTypeID &&
"Re-writing a type from a prior AST");
3169 unsigned Index = Idx.
getIndex() - FirstTypeID;
3170 if (TypeOffsets.size() == Index)
3171 TypeOffsets.push_back(Offset);
3172 else if (TypeOffsets.size() < Index) {
3173 TypeOffsets.resize(Index + 1);
3174 TypeOffsets[Index] =
Offset;
3176 llvm_unreachable(
"Types emitted in wrong order");
3189 uint64_t ASTWriter::WriteDeclContextLexicalBlock(
ASTContext &Context,
3194 uint64_t
Offset = Stream.GetCurrentBitNo();
3196 for (
const auto *D : DC->
decls()) {
3197 KindDeclPairs.push_back(D->getKind());
3198 KindDeclPairs.push_back(GetDeclRef(D));
3201 ++NumLexicalDeclContexts;
3203 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record,
3204 bytes(KindDeclPairs));
3208 void ASTWriter::WriteTypeDeclOffsets() {
3209 using namespace llvm;
3212 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3214 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3215 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3216 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3217 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3219 RecordData::value_type Record[] = {
TYPE_OFFSET, TypeOffsets.size(),
3221 Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record,
bytes(TypeOffsets));
3225 Abbrev = std::make_shared<BitCodeAbbrev>();
3227 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3228 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3229 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3230 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3232 RecordData::value_type Record[] = {
DECL_OFFSET, DeclOffsets.size(),
3234 Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record,
bytes(DeclOffsets));
3238 void ASTWriter::WriteFileDeclIDsMap() {
3239 using namespace llvm;
3242 FileDeclIDs.begin(), FileDeclIDs.end());
3243 llvm::sort(SortedFileDeclIDs, llvm::less_first());
3247 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
3248 DeclIDInFileInfo &Info = *FileDeclEntry.second;
3249 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
3250 for (
auto &LocDeclEntry : Info.DeclIDs)
3251 FileGroupedDeclIDs.push_back(LocDeclEntry.second);
3254 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3256 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3257 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3258 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
3260 FileGroupedDeclIDs.size()};
3261 Stream.EmitRecordWithBlob(AbbrevCode, Record,
bytes(FileGroupedDeclIDs));
3264 void ASTWriter::WriteComments() {
3266 auto _ = llvm::make_scope_exit([
this] { Stream.ExitBlock(); });
3271 for (
const auto *I : RawComments) {
3273 AddSourceRange(I->getSourceRange(), Record);
3274 Record.push_back(I->getKind());
3275 Record.push_back(I->isTrailingComment());
3276 Record.push_back(I->isAlmostTrailingComment());
3288 class ASTMethodPoolTrait {
3293 using key_type_ref = key_type;
3299 using data_type_ref =
const data_type &;
3301 using hash_value_type = unsigned;
3302 using offset_type = unsigned;
3304 explicit ASTMethodPoolTrait(
ASTWriter &Writer) : Writer(Writer) {}
3310 std::pair<unsigned, unsigned>
3311 EmitKeyDataLength(raw_ostream& Out,
Selector Sel,
3312 data_type_ref Methods) {
3313 using namespace llvm::support;
3315 endian::Writer LE(Out, little);
3317 LE.write<uint16_t>(KeyLen);
3318 unsigned DataLen = 4 + 2 + 2;
3321 if (Method->getMethod())
3325 if (Method->getMethod())
3327 LE.write<uint16_t>(DataLen);
3328 return std::make_pair(KeyLen, DataLen);
3331 void EmitKey(raw_ostream& Out,
Selector Sel,
unsigned) {
3332 using namespace llvm::support;
3334 endian::Writer LE(Out, little);
3335 uint64_t Start = Out.tell();
3336 assert((Start >> 32) == 0 &&
"Selector key offset too large");
3339 LE.write<uint16_t>(N);
3342 for (
unsigned I = 0; I != N; ++I)
3347 void EmitData(raw_ostream& Out, key_type_ref,
3348 data_type_ref Methods,
unsigned DataLen) {
3349 using namespace llvm::support;
3351 endian::Writer LE(Out, little);
3352 uint64_t Start = Out.tell(); (void)Start;
3353 LE.write<uint32_t>(Methods.ID);
3354 unsigned NumInstanceMethods = 0;
3357 if (Method->getMethod())
3358 ++NumInstanceMethods;
3360 unsigned NumFactoryMethods = 0;
3363 if (Method->getMethod())
3364 ++NumFactoryMethods;
3366 unsigned InstanceBits = Methods.Instance.getBits();
3367 assert(InstanceBits < 4);
3368 unsigned InstanceHasMoreThanOneDeclBit =
3369 Methods.Instance.hasMoreThanOneDecl();
3370 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
3371 (InstanceHasMoreThanOneDeclBit << 2) |
3373 unsigned FactoryBits = Methods.Factory.getBits();
3374 assert(FactoryBits < 4);
3375 unsigned FactoryHasMoreThanOneDeclBit =
3376 Methods.Factory.hasMoreThanOneDecl();
3377 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
3378 (FactoryHasMoreThanOneDeclBit << 2) |
3380 LE.write<uint16_t>(FullInstanceBits);
3381 LE.write<uint16_t>(FullFactoryBits);
3384 if (Method->getMethod())
3385 LE.write<uint32_t>(Writer.
getDeclID(Method->getMethod()));
3388 if (Method->getMethod())
3389 LE.write<uint32_t>(Writer.
getDeclID(Method->getMethod()));
3391 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3402 void ASTWriter::WriteSelectors(
Sema &SemaRef) {
3403 using namespace llvm;
3406 if (SemaRef.
MethodPool.empty() && SelectorIDs.empty())
3408 unsigned NumTableEntries = 0;
3411 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait> Generator;
3412 ASTMethodPoolTrait Trait(*
this);
3416 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
3417 for (
auto &SelectorAndID : SelectorIDs) {
3420 Sema::GlobalMethodPool::iterator F = SemaRef.
MethodPool.find(S);
3421 ASTMethodPoolTrait::data_type Data = {
3427 Data.Instance = F->second.first;
3428 Data.Factory = F->second.second;
3432 if (Chain && ID < FirstSelectorID) {
3434 bool changed =
false;
3436 !changed && M && M->
getMethod(); M = M->getNext()) {
3437 if (!M->getMethod()->isFromASTFile())
3442 if (!M->getMethod()->isFromASTFile())
3447 }
else if (Data.Instance.getMethod() || Data.Factory.getMethod()) {
3451 Generator.insert(S, Data, Trait);
3456 uint32_t BucketOffset;
3458 using namespace llvm::support;
3460 ASTMethodPoolTrait Trait(*
this);
3461 llvm::raw_svector_ostream Out(MethodPool);
3463 endian::write<uint32_t>(Out, 0, little);
3464 BucketOffset = Generator.Emit(Out, Trait);
3468 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3470 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3471 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3472 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3473 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3477 RecordData::value_type Record[] = {
METHOD_POOL, BucketOffset,
3479 Stream.EmitRecordWithBlob(MethodPoolAbbrev, Record, MethodPool);
3483 Abbrev = std::make_shared<BitCodeAbbrev>();
3485 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3486 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3487 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3488 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3492 RecordData::value_type Record[] = {
3495 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev, Record,
3496 bytes(SelectorOffsets));
3502 void ASTWriter::WriteReferencedSelectorsPool(
Sema &SemaRef) {
3503 using namespace llvm;
3515 Selector Sel = SelectorAndLocation.first;
3539 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3541 if (!Redecl->isFromASTFile()) {
3545 if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
3548 return cast<NamedDecl>(Redecl);
3553 if (Redecl->getOwningModuleID() == 0)
3558 if (!
First->isFromASTFile())
3559 return cast<NamedDecl>(
First);
3569 class ASTIdentifierTableTrait {
3594 using key_type_ref = key_type;
3597 using data_type_ref = data_type;
3599 using hash_value_type = unsigned;
3600 using offset_type = unsigned;
3605 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3606 NeedDecls(!IsModule || !Writer.
getLangOpts().CPlusPlus),
3607 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3609 bool needDecls()
const {
return NeedDecls; }
3612 return llvm::djbHash(II->
getName());
3624 std::pair<unsigned, unsigned>
3627 unsigned DataLen = 4;
3637 DEnd = IdResolver.
end();
3643 using namespace llvm::support;
3645 endian::Writer LE(Out, little);
3647 assert((uint16_t)DataLen == DataLen && (uint16_t)KeyLen == KeyLen);
3648 LE.write<uint16_t>(DataLen);
3652 LE.write<uint16_t>(KeyLen);
3653 return std::make_pair(KeyLen, DataLen);
3665 InterestingIdentifierOffsets->push_back(Out.tell() - 4);
3672 using namespace llvm::support;
3674 endian::Writer LE(Out, little);
3678 LE.write<uint32_t>(ID << 1);
3682 LE.write<uint32_t>((ID << 1) | 0x01);
3684 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
3685 LE.write<uint16_t>(Bits);
3687 bool HadMacroDefinition = MacroOffset != 0;
3688 Bits = (Bits << 1) |
unsigned(HadMacroDefinition);
3690 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
3694 LE.write<uint16_t>(Bits);
3696 if (HadMacroDefinition)
3697 LE.write<uint32_t>(MacroOffset);
3708 for (SmallVectorImpl<NamedDecl *>::reverse_iterator D = Decls.rbegin(),
3709 DEnd = Decls.rend();
3727 using namespace llvm;
3729 RecordData InterestingIdents;
3734 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait> Generator;
3735 ASTIdentifierTableTrait Trait(
3736 *
this, PP, IdResolver, IsModule,
3737 (getLangOpts().
CPlusPlus && IsModule) ? &InterestingIdents :
nullptr);
3746 IIs.push_back(
ID.second);
3749 llvm::sort(IIs, llvm::less_ptr<IdentifierInfo>());
3751 if (Trait.isInterestingNonMacroIdentifier(II))
3752 getIdentifierRef(II);
3756 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
3757 for (
auto IdentIDPair : IdentifierIDs) {
3760 assert(II &&
"NULL identifier in identifier table");
3763 if (ID >= FirstIdentID || !Chain || !II->isFromAST()
3764 || II->hasChangedSinceDeserialization() ||
3765 (Trait.needDecls() &&
3766 II->hasFETokenInfoChangedSinceDeserialization()))
3767 Generator.insert(II, ID, Trait);
3772 uint32_t BucketOffset;
3774 using namespace llvm::support;
3776 llvm::raw_svector_ostream Out(IdentifierTable);
3778 endian::write<uint32_t>(Out, 0, little);
3779 BucketOffset = Generator.Emit(Out, Trait);
3783 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3785 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3786 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3787 unsigned IDTableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3791 Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable);
3795 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3797 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3798 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3799 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3800 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3803 for (
unsigned I = 0, N = IdentifierOffsets.size(); I != N; ++I)
3804 assert(IdentifierOffsets[I] &&
"Missing identifier offset?");
3808 IdentifierOffsets.size(),
3810 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev, Record,
3811 bytes(IdentifierOffsets));
3815 if (!InterestingIdents.empty())
3826 class ASTDeclContextNameLookupTrait {
3832 using key_type_ref = key_type;
3835 using data_type = std::pair<unsigned, unsigned>;
3836 using data_type_ref =
const data_type &;
3838 using hash_value_type = unsigned;
3839 using offset_type = unsigned;
3841 explicit ASTDeclContextNameLookupTrait(
ASTWriter &Writer) : Writer(Writer) {}
3843 template<
typename Coll>
3844 data_type getData(
const Coll &Decls) {
3845 unsigned Start = DeclIDs.size();
3850 return std::make_pair(Start, DeclIDs.size());
3854 unsigned Start = DeclIDs.size();
3855 for (
auto ID : FromReader)
3856 DeclIDs.push_back(
ID);
3857 return std::make_pair(Start, DeclIDs.size());
3860 static bool EqualKey(key_type_ref
a, key_type_ref
b) {
3868 void EmitFileRef(raw_ostream &Out,
ModuleFile *F)
const {
3870 "have reference to loaded module file but no chain?");
3872 using namespace llvm::support;
3877 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
3879 data_type_ref Lookup) {
3880 using namespace llvm::support;
3882 endian::Writer LE(Out, little);
3883 unsigned KeyLen = 1;
3902 LE.write<uint16_t>(KeyLen);
3905 unsigned DataLen = 4 * (Lookup.second - Lookup.first);
3906 assert(uint16_t(DataLen) == DataLen &&
3907 "too many decls for serialized lookup result");
3908 LE.write<uint16_t>(DataLen);
3910 return std::make_pair(KeyLen, DataLen);
3914 using namespace llvm::support;
3916 endian::Writer LE(Out, little);
3917 LE.write<uint8_t>(Name.
getKind());
3931 "Invalid operator?");
3941 llvm_unreachable(
"Invalid name kind?");
3944 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
3946 using namespace llvm::support;
3948 endian::Writer LE(Out, little);
3949 uint64_t Start = Out.tell(); (void)Start;
3950 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
3951 LE.write<uint32_t>(DeclIDs[I]);
3952 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3961 DC->hasNeedToReconcileExternalVisibleStorage();
3964 bool ASTWriter::isLookupResultEntirelyExternal(
StoredDeclsList &Result,
3974 ASTWriter::GenerateNameLookupTable(
const DeclContext *ConstDC,
3976 assert(!ConstDC->hasLazyLocalLexicalLookups() &&
3977 !ConstDC->hasLazyExternalLexicalLookups() &&
3978 "must call buildLookups first");
3982 assert(DC == DC->getPrimaryContext() &&
"only primary DC has lookup table");
3986 ASTDeclContextNameLookupTrait> Generator;
3987 ASTDeclContextNameLookupTrait Trait(*
this);
3996 llvm::SmallSet<DeclarationName, 8> ConstructorNameSet, ConversionNameSet;
3998 for (
auto &Lookup : *DC->buildLookup()) {
3999 auto &Name = Lookup.first;
4000 auto &Result = Lookup.second;
4006 if (isLookupResultExternal(Result, DC) &&
4007 isLookupResultEntirelyExternal(Result, DC))
4024 if (Lookup.second.getLookupResult().empty())
4027 switch (Lookup.first.getNameKind()) {
4029 Names.push_back(Lookup.first);
4033 assert(isa<CXXRecordDecl>(DC) &&
4034 "Cannot have a constructor name outside of a class!");
4035 ConstructorNameSet.insert(Name);
4039 assert(isa<CXXRecordDecl>(DC) &&
4040 "Cannot have a conversion function name outside of a class!");
4041 ConversionNameSet.insert(Name);
4049 if (
auto *D = dyn_cast<CXXRecordDecl>(DC)) {
4063 if (ConstructorNameSet.erase(ImplicitCtorName))
4064 Names.push_back(ImplicitCtorName);
4069 if (!ConstructorNameSet.empty() || !ConversionNameSet.empty())
4070 for (
Decl *ChildD : cast<CXXRecordDecl>(DC)->decls())
4071 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
4072 auto Name = ChildND->getDeclName();
4073 switch (Name.getNameKind()) {
4078 if (ConstructorNameSet.erase(Name))
4079 Names.push_back(Name);
4083 if (ConversionNameSet.erase(Name))
4084 Names.push_back(Name);
4088 if (ConstructorNameSet.empty() && ConversionNameSet.empty())
4092 assert(ConstructorNameSet.empty() &&
"Failed to find all of the visible " 4093 "constructors by walking all the " 4094 "lexical members of the context.");
4095 assert(ConversionNameSet.empty() &&
"Failed to find all of the visible " 4096 "conversion functions by walking all " 4097 "the lexical members of the context.");
4104 for (
auto &Name : Names)
4116 for (
auto &Name : Names) {
4119 switch (Name.getNameKind()) {
4121 Generator.insert(Name, Trait.getData(Result), Trait);
4125 ConstructorDecls.append(Result.
begin(), Result.
end());
4129 ConversionDecls.append(Result.
begin(), Result.
end());
4137 if (!ConstructorDecls.empty())
4138 Generator.insert(ConstructorDecls.front()->getDeclName(),
4139 Trait.getData(ConstructorDecls), Trait);
4140 if (!ConversionDecls.empty())
4141 Generator.insert(ConversionDecls.front()->getDeclName(),
4142 Trait.getData(ConversionDecls), Trait);
4146 auto *Lookups = Chain ? Chain->getLoadedLookupTables(DC) :
nullptr;
4147 Generator.emit(LookupTable, Trait, Lookups ? &Lookups->Table :
nullptr);
4155 uint64_t ASTWriter::WriteDeclContextVisibleBlock(
ASTContext &Context,
4160 if (isa<NamespaceDecl>(DC) && Chain &&
4161 Chain->getKeyDeclaration(cast<Decl>(DC))->isFromASTFile()) {
4163 for (
auto *Prev = cast<NamespaceDecl>(DC)->getPreviousDecl(); Prev;
4164 Prev = Prev->getPreviousDecl())
4165 if (!Prev->isFromASTFile())
4178 LookupResults.reserve(Map->size());
4179 for (
auto &Entry : *Map)
4180 LookupResults.push_back(
4181 std::make_pair(Entry.first, Entry.second.getLookupResult()));
4184 llvm::sort(LookupResults, llvm::less_first());
4185 for (
auto &NameAndResult : LookupResults) {
4193 assert(Result.
empty() &&
"Cannot have a constructor or conversion " 4194 "function name in a namespace!");
4199 if (!ND->isFromASTFile())
4223 uint64_t
Offset = Stream.GetCurrentBitNo();
4225 if (!Map || Map->empty())
4230 GenerateNameLookupTable(DC, LookupTable);
4234 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev, Record,
4236 ++NumVisibleDeclContexts;
4246 void ASTWriter::WriteDeclContextVisibleUpdate(
const DeclContext *DC) {
4248 if (!Map || Map->empty())
4253 GenerateNameLookupTable(DC, LookupTable);
4257 if (isa<NamespaceDecl>(DC))
4258 DC = cast<DeclContext>(Chain->getKeyDeclaration(cast<Decl>(DC)));
4261 RecordData::value_type Record[] = {
UPDATE_VISIBLE, getDeclID(cast<Decl>(DC))};
4262 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev, Record, LookupTable);
4266 void ASTWriter::WriteFPPragmaOptions(
const FPOptions &Opts) {
4267 RecordData::value_type Record[] = {Opts.
getInt()};
4272 void ASTWriter::WriteOpenCLExtensions(
Sema &SemaRef) {
4278 for (
const auto &I:Opts.OptMap) {
4279 AddString(I.getKey(), Record);
4280 auto V = I.getValue();
4281 Record.push_back(V.Supported ? 1 : 0);
4282 Record.push_back(V.Enabled ? 1 : 0);
4283 Record.push_back(V.Avail);
4284 Record.push_back(V.Core);
4289 void ASTWriter::WriteOpenCLExtensionTypes(
Sema &SemaRef) {
4295 const llvm::DenseMap<const Type *, std::set<std::string>> &OpenCLTypeExtMap =
4296 SemaRef.OpenCLTypeExtMap;
4297 using ElementTy = std::pair<TypeID, const std::set<std::string> *>;
4299 StableOpenCLTypeExtMap.reserve(OpenCLTypeExtMap.size());
4301 for (
const auto &I : OpenCLTypeExtMap)
4302 StableOpenCLTypeExtMap.emplace_back(
4303 getTypeID(I.first->getCanonicalTypeInternal()), &I.second);
4305 auto CompareByTypeID = [](
const ElementTy &E1,
const ElementTy &E2) ->
bool {
4306 return E1.first < E2.first;
4308 llvm::sort(StableOpenCLTypeExtMap, CompareByTypeID);
4311 for (
const ElementTy &E : StableOpenCLTypeExtMap) {
4312 Record.push_back(E.first);
4313 const std::set<std::string> *ExtSet = E.second;
4314 Record.push_back(static_cast<unsigned>(ExtSet->size()));
4315 for (
const std::string &Ext : *ExtSet)
4316 AddString(Ext, Record);
4322 void ASTWriter::WriteOpenCLExtensionDecls(
Sema &SemaRef) {
4328 const llvm::DenseMap<const Decl *, std::set<std::string>> &OpenCLDeclExtMap =
4329 SemaRef.OpenCLDeclExtMap;
4330 using ElementTy = std::pair<DeclID, const std::set<std::string> *>;
4332 StableOpenCLDeclExtMap.reserve(OpenCLDeclExtMap.size());
4334 for (
const auto &I : OpenCLDeclExtMap)
4335 StableOpenCLDeclExtMap.emplace_back(getDeclID(I.first), &I.second);
4337 auto CompareByDeclID = [](
const ElementTy &E1,
const ElementTy &E2) ->
bool {
4338 return E1.first < E2.first;
4340 llvm::sort(StableOpenCLDeclExtMap, CompareByDeclID);
4343 for (
const ElementTy &E : StableOpenCLDeclExtMap) {
4344 Record.push_back(E.first);
4345 const std::set<std::string> *ExtSet = E.second;
4346 Record.push_back(static_cast<unsigned>(ExtSet->size()));
4347 for (
const std::string &Ext : *ExtSet)
4348 AddString(Ext, Record);
4354 void ASTWriter::WriteCUDAPragmas(
Sema &SemaRef) {
4355 if (SemaRef.ForceCUDAHostDeviceDepth > 0) {
4356 RecordData::value_type Record[] = {SemaRef.ForceCUDAHostDeviceDepth};
4361 void ASTWriter::WriteObjCCategories() {
4363 RecordData Categories;
4365 for (
unsigned I = 0, N = ObjCClassesWithCategories.size(); I != N; ++I) {
4367 unsigned StartIndex = Categories.size();
4372 Categories.push_back(0);
4378 Cat != CatEnd; ++Cat, ++Size) {
4379 assert(getDeclID(*Cat) != 0 &&
"Bogus category");
4380 AddDeclRef(*Cat, Categories);
4384 Categories[StartIndex] = Size;
4388 CategoriesMap.push_back(CatInfo);
4393 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
4396 using namespace llvm;
4398 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4400 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
4401 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4402 unsigned AbbrevID = Stream.EmitAbbrev(std::move(Abbrev));
4405 Stream.EmitRecordWithBlob(AbbrevID, Record,
4406 reinterpret_cast<char *>(CategoriesMap.data()),
4413 void ASTWriter::WriteLateParsedTemplates(
Sema &SemaRef) {
4420 for (
auto &LPTMapEntry : LPTMap) {
4423 AddDeclRef(FD, Record);
4424 AddDeclRef(LPT.
D, Record);
4425 Record.push_back(LPT.
Toks.size());
4427 for (
const auto &
Tok : LPT.
Toks) {
4428 AddToken(
Tok, Record);
4435 void ASTWriter::WriteOptimizePragmaOptions(
Sema &SemaRef) {
4438 AddSourceLocation(PragmaLoc, Record);
4443 void ASTWriter::WriteMSStructPragmaOptions(
Sema &SemaRef) {
4451 void ASTWriter::WriteMSPointersToMembersPragmaOptions(
Sema &SemaRef) {
4459 void ASTWriter::WritePackPragmaOptions(
Sema &SemaRef) {
4470 Record.push_back(StackEntry.Value);
4471 AddSourceLocation(StackEntry.PragmaLocation, Record);
4472 AddSourceLocation(StackEntry.PragmaPushLocation, Record);
4473 AddString(StackEntry.StackSlotLabel, Record);
4478 void ASTWriter::WriteModuleFileExtension(
Sema &SemaRef,
4484 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
4486 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4487 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4488 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4489 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4490 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4491 unsigned Abbrev = Stream.EmitAbbrev(std::move(Abv));
4497 Record.push_back(Metadata.MajorVersion);
4498 Record.push_back(Metadata.MinorVersion);
4499 Record.push_back(Metadata.BlockName.size());
4500 Record.push_back(Metadata.UserInfo.size());
4502 Buffer += Metadata.BlockName;
4503 Buffer += Metadata.UserInfo;
4504 Stream.EmitRecordWithBlob(Abbrev, Record, Buffer);
4518 auto &Record = *
this;
4520 return Record.push_back(0);
4521 Record.push_back(A->
getKind() + 1);
4522 Record.AddSourceRange(A->
getRange());
4524 #include "clang/Serialization/AttrPCHWrite.inc" 4529 push_back(Attrs.size());
4530 for (
const auto *A : Attrs)
4542 Record.push_back(Tok.
getKind());
4548 Record.push_back(Str.size());
4549 Record.insert(Record.end(), Str.begin(), Str.end());
4553 assert(Context &&
"should have context when outputting path");
4559 const char *PathBegin = Path.data();
4560 const char *PathPtr =
4562 if (PathPtr != PathBegin) {
4563 Path.erase(Path.begin(), Path.begin() + (PathPtr - PathBegin));
4572 PreparePathForOutput(FilePath);
4573 AddString(FilePath, Record);
4579 PreparePathForOutput(FilePath);
4580 Stream.EmitRecordWithBlob(Abbrev, Record, FilePath);
4585 Record.push_back(Version.getMajor());
4587 Record.push_back(*Minor + 1);
4589 Record.push_back(0);
4591 Record.push_back(*Subminor + 1);
4593 Record.push_back(0);
4602 if (ID >= FirstIdentID)
4603 IdentifierOffsets[ID - FirstIdentID] =
Offset;
4609 unsigned ID = SelectorIDs[Sel];
4610 assert(ID &&
"Unknown selector");
4613 if (ID < FirstSelectorID)
4615 SelectorOffsets[ID - FirstSelectorID] =
Offset;
4621 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
4622 bool IncludeTimestamps)
4623 : Stream(Stream), Buffer(Buffer), ModuleCache(ModuleCache),
4624 IncludeTimestamps(IncludeTimestamps) {
4625 for (
const auto &Ext : Extensions) {
4626 if (
auto Writer = Ext->createExtensionWriter(*
this))
4627 ModuleFileExtensionWriters.push_back(std::move(Writer));
4632 llvm::DeleteContainerSeconds(FileDeclIDs);
4636 assert(WritingAST &&
"can't determine lang opts when not writing AST");
4645 const std::string &OutputFile,
4646 Module *WritingModule, StringRef isysroot,
4648 bool ShouldCacheASTInMemory) {
4651 ASTHasCompilerErrors = hasErrors;
4654 Stream.Emit((
unsigned)
'C', 8);
4655 Stream.Emit((
unsigned)
'P', 8);
4656 Stream.Emit((
unsigned)
'C', 8);
4657 Stream.Emit((
unsigned)
'H', 8);
4659 WriteBlockInfoBlock();
4663 this->WritingModule = WritingModule;
4665 WriteASTCore(SemaRef, isysroot, OutputFile, WritingModule);
4668 this->WritingModule =
nullptr;
4669 this->BaseDirectory.clear();
4672 if (ShouldCacheASTInMemory) {
4675 llvm::MemoryBuffer::getMemBufferCopy(
4676 StringRef(Buffer.begin(), Buffer.size())));
4681 template<
typename Vector>
4684 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
4691 const std::string &OutputFile,
4693 using namespace llvm;
4695 bool isModule = WritingModule !=
nullptr;
4699 Chain->finalizeForWriting();
4716 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
4720 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
4724 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
4727 RegisterPredefDecl(Context.MakeIntegerSeqDecl,
4729 RegisterPredefDecl(Context.CFConstantStringTypeDecl,
4731 RegisterPredefDecl(Context.CFConstantStringTagDecl,
4733 RegisterPredefDecl(Context.TypePackElementDecl,
4746 UnusedFileScopedDecls);
4760 WeakInfo &WI = WeakUndeclaredIdentifier.second;
4764 WeakUndeclaredIdentifiers.push_back(WI.
getUsed());
4774 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I) {
4784 AddDeclRef(TD, UnusedLocalTypedefNameCandidates);
4793 "There are local ones at end of translation unit!");
4810 for (
const auto &I : SemaRef.KnownNamespaces) {
4820 for (
const auto &I : Undefined) {
4830 for (
const auto &DeleteExprsInfo :
4832 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
4833 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
4834 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
4836 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
4842 WriteControlBlock(PP, Context, isysroot, OutputFile);
4860 NewGlobalKindDeclPairs.push_back(D->
getKind());
4861 NewGlobalKindDeclPairs.push_back(
GetDeclRef(D));
4865 auto Abv = std::make_shared<BitCodeAbbrev>();
4867 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4868 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
4871 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev, Record,
4872 bytes(NewGlobalKindDeclPairs));
4876 Abv = std::make_shared<BitCodeAbbrev>();
4878 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4879 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4880 UpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
4881 WriteDeclContextVisibleUpdate(TU);
4884 if (Context.ExternCContext)
4885 WriteDeclContextVisibleUpdate(Context.ExternCContext);
4899 for (
const auto &Number : Context.MangleNumbers)
4900 if (!Number.first->isFromASTFile())
4903 for (
const auto &Number : Context.StaticLocalNumbers)
4904 if (!Number.first->isFromASTFile())
4911 for (
const auto *I : DeclsToEmitEvenIfUnreferenced) {
4925 llvm::sort(IIs, llvm::less_ptr<IdentifierInfo>());
4943 for (
auto &SelectorAndID : SelectorIDs)
4944 AllSelectors.push_back(SelectorAndID.first);
4945 for (
auto &
Selector : AllSelectors)
4954 AddTypeRef(Context.ObjCIdRedefinitionType, SpecialTypes);
4955 AddTypeRef(Context.ObjCClassRedefinitionType, SpecialTypes);
4956 AddTypeRef(Context.ObjCSelRedefinitionType, SpecialTypes);
4979 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4981 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4982 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4985 llvm::raw_svector_ostream Out(Buffer);
4987 using namespace llvm::support;
4989 endian::Writer LE(Out, little);
4990 LE.write<uint8_t>(
static_cast<uint8_t
>(M.
Kind));
4995 LE.write<uint16_t>(Name.size());
4996 Out.write(Name.data(), Name.size());
5002 auto writeBaseIDOrNone = [&](uint32_t BaseID,
bool ShouldWrite) {
5005 LE.write<uint32_t>(BaseID);
5007 LE.write<uint32_t>(
None);
5024 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev, Record,
5025 Buffer.data(), Buffer.size());
5036 WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord);
5037 while (!DeclTypesToEmit.empty()) {
5038 DeclOrType DOT = DeclTypesToEmit.front();
5039 DeclTypesToEmit.pop();
5041 WriteType(DOT.getType());
5043 WriteDecl(Context, DOT.getDecl());
5045 }
while (!DeclUpdates.empty());
5048 DoneWritingDeclsAndTypes =
true;
5051 WriteTypeDeclOffsets();
5052 if (!DeclUpdatesOffsetsRecord.empty())
5054 WriteFileDeclIDsMap();
5057 WritePreprocessor(PP, isModule);
5059 WriteSelectors(SemaRef);
5060 WriteReferencedSelectorsPool(SemaRef);
5061 WriteLateParsedTemplates(SemaRef);
5062 WriteIdentifierTable(PP, SemaRef.
IdResolver, isModule);
5064 WriteOpenCLExtensions(SemaRef);
5065 WriteOpenCLExtensionTypes(SemaRef);
5066 WriteCUDAPragmas(SemaRef);
5070 WriteSubmodules(WritingModule);
5074 WriteOpenCLExtensionDecls(SemaRef);
5079 if (!EagerlyDeserializedDecls.empty())
5082 if (!ModularCodegenDecls.empty())
5086 if (!TentativeDefinitions.empty())
5090 if (!UnusedFileScopedDecls.empty())
5094 if (!WeakUndeclaredIdentifiers.empty())
5096 WeakUndeclaredIdentifiers);
5099 if (!ExtVectorDecls.empty())
5103 if (!VTableUses.empty())
5107 if (!UnusedLocalTypedefNameCandidates.empty())
5109 UnusedLocalTypedefNameCandidates);
5112 if (!PendingInstantiations.empty())
5116 if (!SemaDeclRefs.empty())
5120 if (!CUDASpecialDeclRefs.empty())
5124 if (!DelegatingCtorDecls.empty())
5128 if (!KnownNamespaces.empty())
5132 if (!UndefinedButUsed.empty())
5135 if (!DeleteExprsToAnalyze.empty())
5139 for (
auto *DC : UpdatedDeclContexts)
5140 WriteDeclContextVisibleUpdate(DC);
5142 if (!WritingModule) {
5147 ModuleInfo(uint64_t ID,
Module *M) :
ID(ID), M(M) {}
5151 assert(SubmoduleIDs.find(I->getImportedModule()) != SubmoduleIDs.end());
5152 Imports.push_back(ModuleInfo(SubmoduleIDs[I->getImportedModule()],
5153 I->getImportedModule()));
5156 if (!Imports.empty()) {
5157 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
5160 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
5161 return A.ID == B.ID;
5165 llvm::sort(Imports, Cmp);
5166 Imports.erase(std::unique(Imports.begin(), Imports.end(), Eq),
5170 for (
const auto &Import : Imports) {
5171 ImportedModules.push_back(Import.ID);
5182 WriteObjCCategories();
5183 if(!WritingModule) {
5184 WriteOptimizePragmaOptions(SemaRef);
5185 WriteMSStructPragmaOptions(SemaRef);
5186 WriteMSPointersToMembersPragmaOptions(SemaRef);
5188 WritePackPragmaOptions(SemaRef);
5191 RecordData::value_type Record[] = {
5192 NumStatements, NumMacros, NumLexicalDeclContexts, NumVisibleDeclContexts};
5197 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
5198 WriteModuleFileExtension(SemaRef, *ExtWriter);
5200 return writeUnhashedControlBlock(PP, Context);
5203 void ASTWriter::WriteDeclUpdatesBlocks(
RecordDataImpl &OffsetsRecord) {
5204 if (DeclUpdates.empty())
5207 DeclUpdateMap LocalUpdates;
5208 LocalUpdates.swap(DeclUpdates);
5210 for (
auto &DeclUpdate : LocalUpdates) {
5211 const Decl *D = DeclUpdate.first;
5213 bool HasUpdatedBody =
false;
5216 for (
auto &
Update : DeclUpdate.second) {
5222 HasUpdatedBody =
true;
5230 assert(
Update.getDecl() &&
"no decl to add?");
5243 const VarDecl *VD = cast<VarDecl>(D);
5257 Record.
AddStmt(const_cast<Expr *>(
5258 cast<ParmVarDecl>(
Update.getDecl())->getDefaultArg()));
5263 cast<FieldDecl>(
Update.getDecl())->getInClassInitializer());
5267 auto *RD = cast<CXXRecordDecl>(D);
5268 UpdatedDeclContexts.insert(RD->getPrimaryContext());
5269 Record.
push_back(RD->isParamDestroyedInCallee());
5270 Record.
push_back(RD->getArgPassingRestrictions());
5272 Record.
AddOffset(WriteDeclContextLexicalBlock(
5273 *Context, const_cast<CXXRecordDecl *>(RD)));
5278 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
5279 Record.
push_back(MSInfo->getTemplateSpecializationKind());
5282 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
5283 Record.
push_back(Spec->getTemplateSpecializationKind());
5288 auto From = Spec->getInstantiatedFrom();
5289 if (
auto PartialSpec =
5294 &Spec->getTemplateInstantiationArgs());
5315 Record.
AddStmt(cast<CXXDestructorDecl>(D)->getOperatorDeleteThisArg());
5320 cast<FunctionDecl>(D)->getType()->castAs<FunctionProtoType>(),
5338 D->
getAttr<OMPThreadPrivateDeclAttr>()->getRange());
5342 auto *A = D->
getAttr<OMPAllocateDeclAttr>();
5343 Record.
push_back(A->getAllocatorType());
5344 Record.
AddStmt(A->getAllocator());
5352 D->
getAttr<OMPDeclareTargetDeclAttr>()->getRange());
5365 if (HasUpdatedBody) {
5366 const auto *Def = cast<FunctionDecl>(D);
5380 Record.push_back((Raw << 1) | (Raw >> 31));
5389 Record->push_back(Value.getBitWidth());
5390 const uint64_t *Words = Value.getRawData();
5391 Record->append(Words, Words + Value.getNumWords());
5395 Record->push_back(Value.isUnsigned());
5400 AddAPInt(Value.bitcastToAPInt());
5413 push_back(static_cast<uint64_t>(Kind));
5419 AddAPSInt(Value.
getInt());
5422 push_back(static_cast<uint64_t>(
5423 llvm::APFloatBase::SemanticsToEnum(Value.
getFloat().getSemantics())));
5437 push_back(static_cast<uint64_t>(llvm::APFloatBase::SemanticsToEnum(
5440 push_back(static_cast<uint64_t>(llvm::APFloatBase::SemanticsToEnum(
5455 llvm_unreachable(
"Invalid APValue::ValueKind");
5482 MacroInfoToEmitData Info = { Name, MI, ID };
5483 MacroInfosToEmit.push_back(Info);
5492 assert(MacroIDs.find(MI) != MacroIDs.end() &&
"Macro not emitted!");
5493 return MacroIDs[MI];
5497 return IdentMacroDirectivesOffsetMap.lookup(Name);
5501 Record->push_back(Writer->getSelectorRef(SelRef));
5510 if (SID == 0 && Chain) {
5513 Chain->LoadSelector(Sel);
5514 SID = SelectorIDs[Sel];
5517 SID = NextSelectorID++;
5518 SelectorIDs[Sel] = SID;
5559 bool InfoHasSameExpr
5561 Record->push_back(InfoHasSameExpr);
5562 if (InfoHasSameExpr)
5579 TypeLocWriter TLW(*
this);
5596 if (Idx.getIndex() == 0) {
5597 if (DoneWritingDeclsAndTypes) {
5598 assert(0 &&
"New type seen after serializing all the types to emit!");
5605 DeclTypesToEmit.push(T);
5618 TypeIdxMap::const_iterator I = TypeIdxs.find(T);
5619 assert(I != TypeIdxs.end() &&
"Type not emitted!");
5629 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
5640 assert(!(reinterpret_cast<uintptr_t>(D) & 0x01) &&
"Invalid decl pointer");
5643 if (DoneWritingDeclsAndTypes) {
5644 assert(0 &&
"New decl seen after serializing all the decls to emit!");
5651 DeclTypesToEmit.push(const_cast<Decl *>(D));
5666 assert(DeclIDs.find(D) != DeclIDs.end() &&
"Declaration not emitted!");
5670 void ASTWriter::associateDeclWithFile(
const Decl *D,
DeclID ID) {
5685 if (isa<ParmVarDecl>(D) || isa<TemplateTemplateParmDecl>(D))
5694 if (FID.isInvalid())
5698 DeclIDInFileInfo *&Info = FileDeclIDs[FID];
5700 Info =
new DeclIDInFileInfo();
5702 std::pair<unsigned, serialization::DeclID> LocDecl(Offset, ID);
5705 if (Decls.empty() || Decls.back().first <=
Offset) {
5706 Decls.push_back(LocDecl);
5710 LocDeclIDsTy::iterator I =
5711 llvm::upper_bound(Decls, LocDecl, llvm::less_first());
5713 Decls.insert(I, LocDecl);
5756 "expected an anonymous declaration");
5760 auto It = AnonymousDeclarationNumbers.find(D);
5761 if (It == AnonymousDeclarationNumbers.end()) {
5764 AnonymousDeclarationNumbers[ND] = Number;
5767 It = AnonymousDeclarationNumbers.find(D);
5768 assert(It != AnonymousDeclarationNumbers.end() &&
5769 "declaration not found within its lexical context");
5808 AddDeclarationName(NameInfo.
getName());
5827 NestedNames.push_back(NNS);
5831 Record->push_back(NestedNames.size());
5832 while(!NestedNames.empty()) {
5833 NNS = NestedNames.pop_back_val();
5835 Record->push_back(Kind);
5874 NestedNames.push_back(NNS);
5878 Record->push_back(NestedNames.size());
5879 while(!NestedNames.empty()) {
5880 NNS = NestedNames.pop_back_val();
5883 Record->push_back(Kind);
5922 Record->push_back(Kind);
5930 Record->push_back(OvT->
size());
5931 for (
const auto &I : *OvT)
5980 Record->push_back(Arg.
getKind());
6004 Record->push_back(*NumExpansions + 1);
6006 Record->push_back(0);
6014 AddTemplateArgument(
P);
6021 assert(TemplateParams &&
"No TemplateParams!");
6026 Record->push_back(TemplateParams->
size());
6027 for (
const auto &
P : *TemplateParams)
6034 assert(TemplateArgs &&
"No TemplateArgs!");
6035 Record->push_back(TemplateArgs->
size());
6036 for (
int i = 0, e = TemplateArgs->
size();
i != e; ++
i)
6037 AddTemplateArgument(TemplateArgs->
get(
i));
6042 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
6048 AddTemplateArgumentLoc(TemplArgs[
i]);
6052 Record->push_back(Set.
size());
6054 I = Set.
begin(), E = Set.
end(); I != E; ++I) {
6056 Record->push_back(I.getAccess());
6078 for (
auto &
Base : Bases)
6096 for (
auto *Init : CtorInits) {
6097 if (Init->isBaseInitializer()) {
6100 Writer.
push_back(Init->isBaseVirtual());
6101 }
else if (Init->isDelegatingInitializer()) {
6104 }
else if (Init->isMemberInitializer()){
6109 Writer.
AddDeclRef(Init->getIndirectMember());
6113 Writer.
AddStmt(Init->getInit());
6117 if (Init->isWritten())
6118 Writer.
push_back(Init->getSourceOrder());
6131 auto &Data = D->data();
6132 Record->push_back(Data.IsLambda);
6133 Record->push_back(Data.UserDeclaredConstructor);
6134 Record->push_back(Data.UserDeclaredSpecialMembers);
6135 Record->push_back(Data.Aggregate);
6136 Record->push_back(Data.PlainOldData);
6137 Record->push_back(Data.Empty);
6138 Record->push_back(Data.Polymorphic);
6139 Record->push_back(Data.Abstract);
6140 Record->push_back(Data.IsStandardLayout);
6141 Record->push_back(Data.IsCXX11StandardLayout);
6142 Record->push_back(Data.HasBasesWithFields);
6143 Record->push_back(Data.HasBasesWithNonStaticDataMembers);
6144 Record->push_back(Data.HasPrivateFields);
6145 Record->push_back(Data.HasProtectedFields);
6146 Record->push_back(Data.HasPublicFields);
6147 Record->push_back(Data.HasMutableFields);
6148 Record->push_back(Data.HasVariantMembers);
6149 Record->push_back(Data.HasOnlyCMembers);
6150 Record->push_back(Data.HasInClassInitializer);
6151 Record->push_back(Data.HasUninitializedReferenceMember);
6152 Record->push_back(Data.HasUninitializedFields);
6153 Record->push_back(Data.HasInheritedConstructor);
6154 Record->push_back(Data.HasInheritedAssignment);
6155 Record->push_back(Data.NeedOverloadResolutionForCopyConstructor);
6156 Record->push_back(Data.NeedOverloadResolutionForMoveConstructor);
6157 Record->push_back(Data.NeedOverloadResolutionForMoveAssignment);
6158 Record->push_back(Data.NeedOverloadResolutionForDestructor);
6159 Record->push_back(Data.DefaultedCopyConstructorIsDeleted);
6160 Record->push_back(Data.DefaultedMoveConstructorIsDeleted);
6161 Record->push_back(Data.DefaultedMoveAssignmentIsDeleted);
6162 Record->push_back(Data.DefaultedDestructorIsDeleted);
6163 Record->push_back(Data.HasTrivialSpecialMembers);
6164 Record->push_back(Data.HasTrivialSpecialMembersForCall);
6165 Record->push_back(Data.DeclaredNonTrivialSpecialMembers);
6166 Record->push_back(Data.DeclaredNonTrivialSpecialMembersForCall);
6167 Record->push_back(Data.HasIrrelevantDestructor);
6168 Record->push_back(Data.HasConstexprNonCopyMoveConstructor);
6169 Record->push_back(Data.HasDefaultedDefaultConstructor);
6170 Record->push_back(Data.DefaultedDefaultConstructorIsConstexpr);
6171 Record->push_back(Data.HasConstexprDefaultConstructor);
6172 Record->push_back(Data.HasNonLiteralTypeFieldsOrBases);
6173 Record->push_back(Data.ComputedVisibleConversions);
6174 Record->push_back(Data.UserProvidedDefaultConstructor);
6175 Record->push_back(Data.DeclaredSpecialMembers);
6176 Record->push_back(Data.ImplicitCopyConstructorCanHaveConstParamForVBase);
6177 Record->push_back(Data.ImplicitCopyConstructorCanHaveConstParamForNonVBase);
6178 Record->push_back(Data.ImplicitCopyAssignmentHasConstParam);
6179 Record->push_back(Data.HasDeclaredCopyConstructorWithConstParam);
6180 Record->push_back(Data.HasDeclaredCopyAssignmentWithConstParam);
6184 bool ModulesDebugInfo = Writer->Context->getLangOpts().ModulesDebugInfo &&
6186 Record->push_back(ModulesDebugInfo);
6187 if (ModulesDebugInfo)
6188 Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(D));
6192 Record->push_back(Data.NumBases);
6193 if (Data.NumBases > 0)
6194 AddCXXBaseSpecifiers(Data.bases());
6197 Record->push_back(Data.NumVBases);
6198 if (Data.NumVBases > 0)
6199 AddCXXBaseSpecifiers(Data.vbases());
6201 AddUnresolvedSet(Data.Conversions.get(*Writer->Context));
6202 AddUnresolvedSet(Data.VisibleConversions.get(*Writer->Context));
6207 if (Data.IsLambda) {
6208 auto &Lambda = D->getLambdaData();
6209 Record->push_back(Lambda.Dependent);
6210 Record->push_back(Lambda.IsGenericLambda);
6211 Record->push_back(Lambda.CaptureDefault);
6212 Record->push_back(Lambda.NumCaptures);
6213 Record->push_back(Lambda.NumExplicitCaptures);
6214 Record->push_back(Lambda.ManglingNumber);
6216 AddTypeSourceInfo(Lambda.MethodTyInfo);
6217 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
6240 void ASTWriter::ReaderInitialized(
ASTReader *Reader) {
6241 assert(Reader &&
"Cannot remove chain");
6242 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
6243 assert(FirstDeclID == NextDeclID &&
6244 FirstTypeID == NextTypeID &&
6245 FirstIdentID == NextIdentID &&
6246 FirstMacroID == NextMacroID &&
6247 FirstSubmoduleID == NextSubmoduleID &&
6248 FirstSelectorID == NextSelectorID &&
6249 "Setting chain after writing has started.");
6261 NextDeclID = FirstDeclID;
6262 NextTypeID = FirstTypeID;
6263 NextIdentID = FirstIdentID;
6264 NextMacroID = FirstMacroID;
6265 NextSelectorID = FirstSelectorID;
6266 NextSubmoduleID = FirstSubmoduleID;
6271 IdentID &StoredID = IdentifierIDs[II];
6278 MacroID &StoredID = MacroIDs[MI];
6289 TypeIdx &StoredIdx = TypeIdxs[T];
6303 assert(MacroDefinitions.find(MD) == MacroDefinitions.end());
6304 MacroDefinitions[MD] =
ID;
6308 assert(SubmoduleIDs.find(Mod) == SubmoduleIDs.end());
6309 SubmoduleIDs[Mod] =
ID;
6312 void ASTWriter::CompletedTagDefinition(
const TagDecl *D) {
6313 if (Chain && Chain->isProcessingUpdateRecords())
return;
6315 assert(!WritingAST &&
"Already writing the AST!");
6316 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
6318 if (RD->isFromASTFile()) {
6323 "completed a tag from another module but not by instantiation?");
6324 DeclUpdates[RD].push_back(
6339 void ASTWriter::AddedVisibleDecl(
const DeclContext *DC,
const Decl *D) {
6340 if (Chain && Chain->isProcessingUpdateRecords())
return;
6342 "Should not add lookup results to non-lookup contexts!");
6345 if (isa<TranslationUnitDecl>(DC))
6353 !isa<FunctionTemplateDecl>(D))
6363 assert(!WritingAST &&
"Already writing the AST!");
6364 if (UpdatedDeclContexts.insert(DC) && !cast<Decl>(DC)->isFromASTFile()) {
6368 for (
auto *Child : DC->
decls())
6369 DeclsToEmitEvenIfUnreferenced.push_back(Child);
6371 DeclsToEmitEvenIfUnreferenced.push_back(D);
6374 void ASTWriter::AddedCXXImplicitMember(
const CXXRecordDecl *RD,
const Decl *D) {
6375 if (Chain && Chain->isProcessingUpdateRecords())
return;
6383 if (!isa<CXXMethodDecl>(D))
6388 assert(!WritingAST &&
"Already writing the AST!");
6392 void ASTWriter::ResolvedExceptionSpec(
const FunctionDecl *FD) {
6393 if (Chain && Chain->isProcessingUpdateRecords())
return;
6394 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
6396 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
6401 ->castAs<FunctionProtoType>()
6402 ->getExceptionSpecType()))
6408 if (Chain && Chain->isProcessingUpdateRecords())
return;
6409 assert(!WritingAST &&
"Already writing the AST!");
6411 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
6412 DeclUpdates[D].push_back(
6420 if (Chain && Chain->isProcessingUpdateRecords())
return;
6421 assert(!WritingAST &&
"Already writing the AST!");
6422 assert(Delete &&
"Not given an operator delete");
6424 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
6429 void ASTWriter::CompletedImplicitDefinition(
const FunctionDecl *D) {
6430 if (Chain && Chain->isProcessingUpdateRecords())
return;
6431 assert(!WritingAST &&
"Already writing the AST!");
6439 void ASTWriter::VariableDefinitionInstantiated(
const VarDecl *D) {
6440 if (Chain && Chain->isProcessingUpdateRecords())
return;
6441 assert(!WritingAST &&
"Already writing the AST!");
6448 void ASTWriter::FunctionDefinitionInstantiated(
const FunctionDecl *D) {
6449 if (Chain && Chain->isProcessingUpdateRecords())
return;
6450 assert(!WritingAST &&
"Already writing the AST!");
6457 void ASTWriter::InstantiationRequested(
const ValueDecl *D) {
6458 if (Chain && Chain->isProcessingUpdateRecords())
return;
6459 assert(!WritingAST &&
"Already writing the AST!");
6466 if (
auto *VD = dyn_cast<VarDecl>(D))
6467 POI = VD->getPointOfInstantiation();
6469 POI = cast<FunctionDecl>(D)->getPointOfInstantiation();
6473 void ASTWriter::DefaultArgumentInstantiated(
const ParmVarDecl *D) {
6474 if (Chain && Chain->isProcessingUpdateRecords())
return;
6475 assert(!WritingAST &&
"Already writing the AST!");
6479 DeclUpdates[D].push_back(
6483 void ASTWriter::DefaultMemberInitializerInstantiated(
const FieldDecl *D) {
6484 assert(!WritingAST &&
"Already writing the AST!");
6488 DeclUpdates[D].push_back(
6494 if (Chain && Chain->isProcessingUpdateRecords())
return;
6495 assert(!WritingAST &&
"Already writing the AST!");
6499 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
6500 ObjCClassesWithCategories.insert(
6504 void ASTWriter::DeclarationMarkedUsed(
const Decl *D) {
6505 if (Chain && Chain->isProcessingUpdateRecords())
return;
6506 assert(!WritingAST &&
"Already writing the AST!");
6518 void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(
const Decl *D) {
6519 if (Chain && Chain->isProcessingUpdateRecords())
return;
6520 assert(!WritingAST &&
"Already writing the AST!");
6527 void ASTWriter::DeclarationMarkedOpenMPAllocate(
const Decl *D,
const Attr *A) {
6528 if (Chain && Chain->isProcessingUpdateRecords())
return;
6529 assert(!WritingAST &&
"Already writing the AST!");
6536 void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
6538 if (Chain && Chain->isProcessingUpdateRecords())
return;
6539 assert(!WritingAST &&
"Already writing the AST!");
6543 DeclUpdates[D].push_back(
6547 void ASTWriter::RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M) {
6548 if (Chain && Chain->isProcessingUpdateRecords())
return;
6549 assert(!WritingAST &&
"Already writing the AST!");
6550 assert(D->
isHidden() &&
"expected a hidden declaration");
6554 void ASTWriter::AddedAttributeToRecord(
const Attr *Attr,
6556 if (Chain && Chain->isProcessingUpdateRecords())
return;
6557 assert(!WritingAST &&
"Already writing the AST!");
6563 void ASTWriter::AddedCXXTemplateSpecialization(
6565 assert(!WritingAST &&
"Already writing the AST!");
6569 if (Chain && Chain->isProcessingUpdateRecords())
6572 DeclsToEmitEvenIfUnreferenced.push_back(D);
6575 void ASTWriter::AddedCXXTemplateSpecialization(
6577 assert(!WritingAST &&
"Already writing the AST!");
6581 if (Chain && Chain->isProcessingUpdateRecords())
6584 DeclsToEmitEvenIfUnreferenced.push_back(D);
6589 assert(!WritingAST &&
"Already writing the AST!");
6593 if (Chain && Chain->isProcessingUpdateRecords())
6596 DeclsToEmitEvenIfUnreferenced.push_back(D);
6607 Record.AddSourceLocation(C->
getEndLoc());
6616 VisitOMPClauseWithPreInit(C);
6620 void OMPClauseWriter::VisitOMPIfClause(
OMPIfClause *
C) {
6621 VisitOMPClauseWithPreInit(C);
6635 VisitOMPClauseWithPreInit(C);
6673 VisitOMPClauseWithPreInit(C);
6689 Record.AddStmt(NumIter);
6701 void OMPClauseWriter::VisitOMPReadClause(
OMPReadClause *) {}
6713 void OMPClauseWriter::VisitOMPSIMDClause(
OMPSIMDClause *) {}
6730 VisitOMPClauseWithPreInit(C);
6738 for (
auto *VE : C->
inits()) {
6745 VisitOMPClauseWithPostUpdate(C);
6768 VisitOMPClauseWithPostUpdate(C);
6787 VisitOMPClauseWithPostUpdate(C);
6806 VisitOMPClauseWithPostUpdate(C);
6827 VisitOMPClauseWithPostUpdate(C);
6829 Record.AddSourceLocation(C->getColonLoc());
6830 Record.push_back(C->getModifier());
6831 Record.AddSourceLocation(C->getModifierLoc());
6835 for (
auto *VE : C->privates()) {
6838 for (
auto *VE : C->inits()) {
6841 for (
auto *VE : C->updates()) {
6844 for (
auto *VE : C->finals()) {
6847 Record.AddStmt(C->getStep());
6848 Record.AddStmt(C->getCalcStep());
6852 Record.push_back(C->varlist_size());
6853 Record.AddSourceLocation(C->getLParenLoc());
6855 for (
auto *VE : C->varlists())
6861 Record.push_back(C->varlist_size());
6862 Record.AddSourceLocation(C->getLParenLoc());
6863 for (
auto *VE : C->varlists())
6874 Record.push_back(C->varlist_size());
6875 Record.AddSourceLocation(C->getLParenLoc());
6876 for (
auto *VE : C->varlists())
6887 Record.push_back(C->varlist_size());
6888 Record.AddSourceLocation(C->getLParenLoc());
6889 for (
auto *VE : C->varlists())
6894 Record.push_back(C->varlist_size());
6896 Record.AddSourceLocation(C->getLParenLoc());
6900 for (
auto *VE : C->varlists())
6902 for (
unsigned I = 0, E = C->
getNumLoops(); I < E; ++I)
6907 VisitOMPClauseWithPreInit(C);
6912 void OMPClauseWriter::VisitOMPMapClause(
OMPMapClause *C) {
6913 Record.push_back(C->varlist_size());
6917 Record.AddSourceLocation(C->getLParenLoc());
6925 Record.AddSourceLocation(C->
getMapLoc());
6927 for (
auto *E : C->varlists())
6932 Record.AddDeclRef(D);
6934 Record.push_back(N);
6936 Record.push_back(N);
6938 Record.AddStmt(M.getAssociatedExpression());
6939 Record.AddDeclRef(M.getAssociatedDeclaration());
6953 VisitOMPClauseWithPreInit(C);
6959 VisitOMPClauseWithPreInit(C);
6979 void OMPClauseWriter::VisitOMPHintClause(
OMPHintClause *C) {
6985 VisitOMPClauseWithPreInit(C);
7001 void OMPClauseWriter::VisitOMPToClause(
OMPToClause *C) {
7002 Record.push_back(C->varlist_size());
7006 Record.AddSourceLocation(C->getLParenLoc());
7009 for (
auto *E : C->varlists())
7014 Record.AddDeclRef(D);
7016 Record.push_back(N);
7018 Record.push_back(N);
7020 Record.AddStmt(M.getAssociatedExpression());
7021 Record.AddDeclRef(M.getAssociatedDeclaration());
7025 void OMPClauseWriter::VisitOMPFromClause(
OMPFromClause *C) {
7026 Record.push_back(C->varlist_size());
7030 Record.AddSourceLocation(C->getLParenLoc());
7033 for (
auto *E : C->varlists())
7038 Record.AddDeclRef(D);
7040 Record.push_back(N);
7042 Record.push_back(N);
7044 Record.AddStmt(M.getAssociatedExpression());
7045 Record.AddDeclRef(M.getAssociatedDeclaration());
7050 Record.push_back(C->varlist_size());
7054 Record.AddSourceLocation(C->getLParenLoc());
7055 for (
auto *E : C->varlists())
7059 for (
auto *VE : C->
inits())
7062 Record.AddDeclRef(D);
7064 Record.push_back(N);
7066 Record.push_back(N);
7068 Record.AddStmt(M.getAssociatedExpression());
7069 Record.AddDeclRef(M.getAssociatedDeclaration());
7074 Record.push_back(C->varlist_size());
7078 Record.AddSourceLocation(C->getLParenLoc());
7079 for (
auto *E : C->varlists())
7082 Record.AddDeclRef(D);
7084 Record.push_back(N);
7086 Record.push_back(N);
7088 Record.AddStmt(M.getAssociatedExpression());
7089 Record.AddDeclRef(M.getAssociatedDeclaration());
7095 void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
7104 void OMPClauseWriter::VisitOMPAtomicDefaultMemOrderClause(
A CXXConstCastExpr record.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
TemplateTemplateParmDecl * getParameterPack() const
Retrieve the template template parameter pack being substituted.
A FriendTemplateDecl record.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Defines the clang::ASTContext interface.
A CompoundLiteralExpr record.
A NonTypeTemplateParmDecl record.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
TargetOptions & getTargetOpts() const
Retrieve the target options.
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
const FileEntry * OrigEntry
Reference to the file entry representing this ContentCache.
UnusedFileScopedDeclsType UnusedFileScopedDecls
The set of file scoped decls seen so far that have not been used and must warn if not used...
Record code for the preprocessor options table.
VarDecl * getCapturedVar() const
Retrieve the declaration of the local variable being captured.
const CXXDestructorDecl * getDestructor() const
unsigned getAnonymousDeclarationNumber(const NamedDecl *D)
uint64_t getMacroDirectivesOffset(const IdentifierInfo *Name)
Represents a function declaration or definition.
SourceRange getExceptionSpecRange() const
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
std::string Name
The name of this module.
helper_expr_const_range reduction_ops() const
bool isImplicit() const
Determine whether this was an implicit capture (not written between the square brackets introducing t...
NamespaceDecl * getStdNamespace() const
This represents 'thread_limit' clause in the '#pragma omp ...' directive.
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimize off". If this location is invalid...
void VisitArrayType(const ArrayType *T)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
A UserDefinedLiteral record.
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
Source range/offset of a preprocessed entity.
std::vector< std::pair< std::string, bool > > Macros
no exception specification
Record code for potentially unused local typedef names.
Smart pointer class that efficiently represents Objective-C method names.
Record code for map of Objective-C class definition IDs to the ObjC categories in a module that are a...
This is a discriminated union of FileInfo and ExpansionInfo.
An IndirectGotoStmt record.
helper_expr_const_range lhs_exprs() const
const_all_decls_range all_decls() const
This represents clause 'copyin' in the '#pragma omp ...' directives.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
PointerType - C99 6.7.5.1 - Pointer Declarators.
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
QualType getElementType() const
QualType getPointeeType() const
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
bool hasTemplateKeyword() const
Whether the template name was prefixed by the "template" keyword.
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system...
A (possibly-)qualified type.
static void EmitBlockID(unsigned ID, const char *Name, llvm::BitstreamWriter &Stream, ASTWriter::RecordDataImpl &Record)
void * getAsOpaquePtr() const
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
bool getNoCfCheck() const
The macro directives history for a particular identifier.
QualType getInjectedSpecializationType() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
Implements support for file system lookup, file system caching, and directory search management...
const DeclarationNameLoc & getInfo() const
const std::vector< SourceRange > & getSkippedRanges()
Retrieve all ranges that got skipped while preprocessing.
SourceLocation getSpellingLoc() const
void AddToken(const Token &Tok, RecordDataImpl &Record)
Emit a token.
unsigned getNumExceptions() const
Return the number of types in the exception specification.
LateParsedTemplateMapT LateParsedTemplateMap
SourceLocation getCommaLoc()
Get location of ','.
OpenCL supported extensions and optional core features.
A CXXStaticCastExpr record.
Defines the clang::FileManager interface and associated types.
time_t getModificationTime() const
llvm::APSInt getValue() const
Record code for the source manager line table information, which stores information about #line direc...
An AttributedStmt record.
A CXXReinterpretCastExpr record.
This represents 'atomic_default_mem_order' clause in the '#pragma omp requires' directive.
An OMPThreadPrivateDecl record.
bool isLookupContext() const
Test whether the context supports looking up names.
SourceLocation getKWLoc() const
helper_expr_const_range rhs_exprs() const
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
An ObjCBoolLiteralExpr record.
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
submodule_iterator submodule_begin()
Expr * getUnderlyingExpr() const
private_copies_range private_copies()
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
This represents clause 'in_reduction' in the '#pragma omp task' directives.
FunctionType - C99 6.7.5.3 - Function Declarators.
Expr * getLoopData(unsigned NumLoop)
Get the loop data.
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "C"...
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
Class that handles pre-initialization statement for some clauses, like 'shedule', 'firstprivate' etc...
The fixed point semantics work similarly to llvm::fltSemantics.
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
void AddUnresolvedSet(const ASTUnresolvedSet &Set)
Emit a UnresolvedSet structure.
void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Emit a nested name specifier with source-location information.
C Language Family Type Representation.
Defines the SourceManager interface.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
static bool isImportedDeclContext(ASTReader *Chain, const Decl *D)
bool isExpansionTokenRange() const
Represents a qualified type name for which the type name is dependent.
An OMPDeclareReductionDecl record.
SourceLocation getLParenLoc() const
Returns the location of '('.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
Expr * getAllocator() const
Returns allocator.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
FileManager & getFileManager() const
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
RawCommentList Comments
All comments in this translation unit.
helper_expr_const_range rhs_exprs() const
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
QualType getUnderlyingType() const
void GetUniqueIDMapping(SmallVectorImpl< const FileEntry *> &UIDToFiles) const
Produce an array mapping from the unique IDs assigned to each file to the corresponding FileEntry poi...
An ImplicitValueInitExpr record.
Defines the clang::Module class, which describes a module in the source code.
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
bool isLocalSourceLocation(SourceLocation Loc) const
Returns true if Loc did not come from a PCH/Module.
Decl - This represents one declaration (or definition), e.g.
This represents 'grainsize' clause in the '#pragma omp ...' directive.
An ImplicitCastExpr record.
bool isVariadic() const
Whether this function prototype is variadic.
TagDecl * getDecl() const
static constexpr unsigned NumberOfModifiers
Number of allowed map-type-modifiers.
A VarTemplatePartialSpecializationDecl record.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
unsigned IsFramework
Whether this is a framework module.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
ModuleKind Kind
The type of this module.
This represents 'if' clause in the '#pragma omp ...' directive.
Defines the C++ template declaration subclasses.
Describes a source location entry (SLocEntry) for a macro expansion.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
SourceLocation getAtomicDefaultMemOrderKindKwLoc() const
Returns location of clause kind.
Represents a C++11 auto or C++14 decltype(auto) type.
static NamedDecl * getDeclForLocalLookup(const LangOptions &LangOpts, NamedDecl *D)
Determine the declaration that should be put into the name lookup table to represent the given declar...
std::vector< std::string > Includes
bool makeAbsolutePath(SmallVectorImpl< char > &Path) const
Makes Path absolute taking into account FileSystemOptions and the working directory option...
An LValueReferenceType record.
static unsigned getNumberOfModules(Module *Mod)
Compute the number of modules within the given tree (including the given module). ...
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
Defines the clang::MacroInfo and clang::MacroDirective classes.
A CXXOperatorCallExpr record.
helper_expr_const_range assignment_ops() const
Defines types useful for describing an Objective-C runtime.
Specifies the submodules that are imported by this submodule.
std::string ModuleName
The name of the module.
A record that stores the set of declarations that are lexically stored within a given DeclContext...
This represents 'priority' clause in the '#pragma omp ...' directive.
Specifies an umbrella directory.
helper_expr_const_range lhs_exprs() const
A CXXTemporaryObjectExpr record.
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate > > LateParsedTemplateMapT
QualType getsigjmp_bufType() const
Retrieve the C sigjmp_buf type.
Each ExpansionInfo encodes the expansion location - where the token was ultimately expanded...
DiagnosticsEngine & getDiagnostics() const
A SubstTemplateTypeParmType record.
Class that performs name lookup into a DeclContext stored in an AST file.
Writer for the on-disk hash table.
Declaration of a variable template.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Represent a C++ namespace.
A ObjCPropertyDecl record.
Wrapper for source info for typedefs.
DeclarationName getDeclName() const
Get the name of the template.
serialization::DeclID GetDeclRef(const Decl *D)
Force a declaration to be emitted and get its ID.
Expr * getCondition() const
Returns condition.
const TargetInfo & getTargetInfo() const
const llvm::MemoryBuffer * getBuffer(DiagnosticsEngine &Diag, const SourceManager &SM, SourceLocation Loc=SourceLocation(), bool *Invalid=nullptr) const
Returns the memory buffer for the associated content.
A container of type source information.
This represents 'update' clause in the '#pragma omp atomic' directive.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Record code for enabled OpenCL extensions.
Record code for the module build directory.
Floating point control options.
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
time_t getTimestampForOutput(const FileEntry *E) const
Get a timestamp for output into the AST file.
Expr * getCondition() const
Returns condition.
SourceLocation getAttributeLoc() const
void AddTypeRef(QualType T, RecordDataImpl &Record)
Emit a reference to a type.
An ElaboratedType record.
ObjCMethodDecl * getMethod() const
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
An UnresolvedUsingType record.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
static void AddStmtsExprs(llvm::BitstreamWriter &Stream, ASTWriter::RecordDataImpl &Record)
Wrapper for source info for pointers decayed from arrays and functions.
bool isPackExpansion() const
Determine whether this capture is a pack expansion, which captures a function parameter pack...
static uint64_t EmitCXXCtorInitializers(ASTWriter &W, ArrayRef< CXXCtorInitializer *> CtorInits)
Describes the capture of a variable or of this, or of a C++1y init-capture.
TemplateTypeParmDecl * getDecl() const
This is a module that was defined by a module map and built out of header files.
An IncompleteArrayType record.
The internal '__type_pack_element' template.
A template template parameter that has been substituted for some other template name.
Specifies a header that is part of the module but must be textually included.
Expr * getAlignment()
Returns alignment.
Expr * getNumForLoops() const
Return the number of associated for-loops.
SourceLocation getSecondScheduleModifierLoc() const
Get the second modifier location.
OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY
Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
uint64_t Emit(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, followed by its substatements, and return its offset.
IdentifierInfo * getAlias() const
bool hasBaseTypeAsWritten() const
QualType getElementType() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
bool hasLocalNonFastQualifiers() const
Determine whether this particular QualType instance has any "non-fast" qualifiers, e.g., those that are stored in an ExtQualType instance.
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
A ClassTemplateDecl record.
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
unsigned NumPreprocessedEntities
A PragmaDetectMismatchDecl record.
An UnresolvedUsingTypenameDecl record.
SourceLocation getRParenLoc() const
An identifier, stored as an IdentifierInfo*.
The internal '__builtin_va_list' typedef.
The stack of open #ifs/#ifdefs recorded in a preamble.
static uint64_t EmitCXXBaseSpecifiers(ASTWriter &W, ArrayRef< CXXBaseSpecifier > Bases)
SourceLocation getDependencyLoc() const
Get dependency type location.
Manages the set of modules loaded by an AST reader.
This represents 'read' clause in the '#pragma omp atomic' directive.
serialization::MacroID getMacroRef(MacroInfo *MI, const IdentifierInfo *Name)
Get the unique number used to refer to the given macro.
helper_expr_const_range assignment_ops() const
SourceLocation getExpansionLoc() const
Represents a variable declaration or definition.
This represents clause 'private' in the '#pragma omp ...' directives.
Record code for #pragma pack options.
A block with unhashed content.
for(auto typeArg :T->getTypeArgsAsWritten())
This represents 'num_threads' clause in the '#pragma omp ...' directive.
Wrapper for source info for member pointers.
An OMPCapturedExprDecl record.
void AddFunctionDefinition(const FunctionDecl *FD)
Add a definition for the given function to the queue of statements to emit.
unsigned getNumParams() const
Options for controlling the target.
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
APFloat & getComplexFloatReal()
Record code for declarations associated with OpenCL extensions.
A UsingShadowDecl record.
Represents an empty template argument, e.g., one that has not been deduced.
QualType getRawCFConstantStringType() const
Get the structure type used to representation CFStrings, or NULL if it hasn't yet been built...
This represents 'defaultmap' clause in the '#pragma omp ...' directive.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
SourceLocation getStarLoc() const
Represents a C++17 deduced template specialization type.
static unsigned CreateSLocFileAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a file.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
Represents a variable template specialization, which refers to a variable template with a given set o...
The value of the next COUNTER to dispense.
unsigned getNextLocalOffset() const
SourceLocation getLAngleLoc() const
A ConditionOperator record.
const DeclContext * getDefinitiveDeclContext(const DeclContext *DC)
Retrieve the "definitive" declaration that provides all of the visible entries for the given declarat...
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack...
Specifies the umbrella header used to create this module, if any.
SourceLocation getLBracketLoc() const
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
A namespace, stored as a NamespaceDecl*.
SourceLocation getColonLoc() const
Return the location of ':'.
iterator local_end()
End iterator for local, non-loaded, preprocessed entities.
Record code for header search information.
Stores a list of template parameters for a TemplateDecl and its derived classes.
unsigned getODRHash() const
This represents implicit clause 'flush' for the '#pragma omp flush' directive.
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.
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
static StringRef bytes(const std::vector< T, Allocator > &v)
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
bool hasLineDirectives() const
Return true if this FileID has #line directives in it.
unsigned getTotalComponentsNum() const
Return the total number of components in all lists derived from the clause.
This represents 'reverse_offload' clause in the '#pragma omp requires' directive. ...
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
A TemplateTemplateParmDecl record.
Record code for the array of eagerly deserialized decls.
Expr * getAttrExprOperand() const
The attribute's expression operand, if it has one.
Represents a parameter to a function.
Represents the result of substituting a type for a template type parameter.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
OpenCLOptions & getOpenCLOptions()
Defines the clang::Expr interface and subclasses for C++ expressions.
FPOptions & getFPOptions()
const llvm::MapVector< FieldDecl *, DeleteLocs > & getMismatchingDeleteExpressions() const
Retrieves list of suspicious delete-expressions that will be checked at the end of translation unit...
A ObjCInterfaceDecl record.
QualType getIntegralType() const
Retrieve the type of the integral value.
const MacroDirective * getPrevious() const
Get previous definition of the macro with the same name.
tok::TokenKind getKind() const
SourceLocation getLParenLoc() const
Returns the location of '('.
void AddSourceRange(SourceRange Range)
Emit a source range.
void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record)
Emit a reference to an identifier.
Expr * getGrainsize() const
Return safe iteration space distance.
This represents 'nogroup' clause in the '#pragma omp ...' directive.
SourceLocation getAmpAmpLoc() const
The collection of all-type qualifiers we support.
This represents 'allocator' clause in the '#pragma omp ...' directive.
A ShuffleVectorExpr record.
This represents 'safelen' clause in the '#pragma omp ...' directive.
bool needsExtraLocalData() const
SourceLocation getLParenLoc() const
Returns the location of '('.
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
ModuleKind Kind
The kind of this module.
void AddTypeSourceInfo(TypeSourceInfo *TInfo)
Emits a reference to a declarator info.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
SourceLocation getAttributeLoc() const
Base wrapper for a particular "section" of type source info.
Represents a struct/union/class.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
unsigned varlist_size() const
QualType getOriginalType() const
TypeSpecifierSign getWrittenSignSpec() const
SourceLocation getLParenLoc() const
Returns the location of '('.
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
ArrayRef< PPConditionalInfo > getPreambleConditionalStack() const
A macro directive exported by a module.
An ObjCAtThrowStmt record.
FileManager & getFileManager() const
Specifies a top-level header that falls into this (sub)module.
The block containing comments.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
void AddTypeRef(QualType T)
Emit a reference to a type.
A DesignatedInitExpr record.
The Objective-C 'SEL' type.
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
unsigned getRegParm() const
Represents a class type in Objective C.
Iteration over the preprocessed entities.
QualType getPointeeType() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
Record the location of a macro definition.
Represents a dependent template name that cannot be resolved prior to template instantiation.
The results of name lookup within a DeclContext.
This represents 'simd' clause in the '#pragma omp ...' directive.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
TypeSourceInfo * getUnderlyingTInfo() const
void resolveHeaderDirectives(const FileEntry *File) const
Resolve all lazy header directives for the specified file.
An ObjCProtocolExpr record.
bool isSpelledAsLValue() const
An ObjCSelectorExpr record.
Specifies a header that has been explicitly excluded from this submodule.
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
SmallVector< Requirement, 2 > Requirements
The set of language features required to use this module.
NameKind getNameKind() const
Determine what kind of name this is.
Represents a member of a struct/union/class.
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
bool isCPlusPlusOperatorKeyword() const
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
This represents clause 'allocate' in the '#pragma omp ...' directives.
The unsigned 128-bit integer type.
SourceLocation getLParenLoc() const
Returns the location of '('.
Record code for the module map file that was used to build this AST file.
One instance of this struct is kept for every file loaded or used.
SourceLocation getProtocolLAngleLoc() const
Delete expressions that will be analyzed later.
bool hasCommaPasting() const
NestedNameSpecifierLoc getQualifierLoc() const
Expr * getChunkSize()
Get chunk size.
const IdentifierInfo * getMacroIdentifier() const
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
Optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce...
This represents clause 'map' in the '#pragma omp ...' directives.
SourceLocation getDefaultKindKwLoc() const
Returns location of clause kind.
CXXRecordDecl * getStdBadAlloc() const
The iterator over UnresolvedSets.
This represents clause 'to' in the '#pragma omp ...' directives.
Represents the result of substituting a set of types for a template type parameter pack...
Token - This structure provides full information about a lexed token.
TagDecl * getOwnedTagDecl() const
Return the (re)declaration of this type owned by this occurrence of this type, or nullptr if there is...
SourceLocation getProtocolRAngleLoc() const
ParmVarDecl * getParam(unsigned i) const
ASTReader * getChain() const
static unsigned CreateSLocExpansionAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a macro expansion.
Wrapper for source info for unresolved typename using decls.
SourceLocation getRParenLoc() const
An AttributedType record.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Expr * getSafelen() const
Return safe iteration space distance.
An object-like macro definition.
__DEVICE__ int max(int __a, int __b)
unsigned IsTransient
True if this file may be transient, that is, if it might not exist at some later point in time when t...
The signature of a module, which is a hash of the AST content.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
unsigned char getOpaqueValue() const
void AddTemplateParameterList(const TemplateParameterList *TemplateParams)
Emit a template parameter list.
SourceLocation getTemplateLoc() const
const LangOptions & getLangOpts() const
TemplateName getReplacement() const
Expr * getNumTeams()
Return NumTeams number.
QualType getParamTypeForDecl() const
Describes a module or submodule.
SourceLocation getLParenLoc() const
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
A IndirectFieldDecl record.
Record code for the set of ext_vector type names.
iterator end()
end - Returns an iterator that has 'finished'.
void VisitTagType(const TagType *T)
SourceLocation getComposedLoc(FileID FID, unsigned Offset) const
Form a SourceLocation from a FileID and Offset pair.
bool getProducesResult() const
serialization::MacroID getMacroID(MacroInfo *MI)
Determine the ID of an already-emitted macro.
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
static ModuleHeaderRole headerKindToRole(Module::HeaderKind Kind)
Convert a header kind to a role. Requires Kind to not be HK_Excluded.
SourceLocation getLAngleLoc() const
TypeSpecifierWidth getWrittenWidthSpec() const
Specifies the submodules that are re-exported from this submodule.
TemplateParameterList ** TemplParamLists
A new-allocated array of size NumTemplParamLists, containing pointers to the "outer" template paramet...
serialization::MacroID BaseMacroID
Base macro ID for macros local to this module.
An rvalue reference type, per C++11 [dcl.ref].
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
UnresolvedUsingTypenameDecl * getDecl() const
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
The Objective-C 'id' type.
unsigned InferExportWildcard
Whether, when inferring submodules, the inferr submodules should export all modules they import (e...
A qualified template name, where the qualification is kept to describe the source code as written...
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
SourceLocation getLParenLoc() const
Wrapper for source info for injected class names of class templates.
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
< Capturing the *this object by copy
HeaderSearch & getHeaderSearchInfo() const
SourceLocation getDefaultmapKindLoc()
Get kind location.
An AccessSpecDecl record.
unsigned getNumProtocols() const
const Token & getReplacementToken(unsigned Tok) const
SourceLocation getProtocolLoc(unsigned i) const
Describes a blob that contains the data for a buffer entry.
const FileInfo & getFile() const
Record code for the language options table.
QualType getExceptionType(unsigned i) const
Return the ith exception type, where 0 <= i < getNumExceptions().
bool getInheritConstructors() const
Determine whether this base class's constructors get inherited.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
An unqualified-id that has been assumed to name a function template that will be found by ADL...
Wrapper for source info for functions.
Specifies a conflict with another module.
The signed 128-bit integer type.
unsigned getHash() const
Compute a fingerprint of this key for use in on-disk hash table.
StoredDeclsMap * buildLookup()
Ensure the lookup structure is fully-built and return it.
A UnaryTransformType record.
A reference to a previously [de]serialized Stmt record.
SourceRange getLocalSourceRange() const
Retrieve the source range covering just the last part of this nested-name-specifier, not including the prefix.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
A UsingDirecitveDecl record.
const Stmt * getPreInitStmt() const
Get pre-initialization statement for the clause.
SourceLocation getElaboratedKeywordLoc() const
An ObjCObjectType record.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
A ConstantArrayType record.
Wrapper for substituted template type parameters.
Concrete class used by the front-end to report problems and issues.
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation...
Represents a typeof (or typeof) expression (a GCC extension).
Record code for #pragma optimize options.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
void AddSourceRange(SourceRange Range, RecordDataImpl &Record)
Emit a source range.
Specifies a header that is private to this submodule but must be textually included.
Record code for pending implicit instantiations.
Wrapper for substituted template type parameters.
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
The internal '__make_integer_seq' template.
ASTTypeWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
SourceLocation getLParenLoc() const
SourceLocation getMapTypeModifierLoc(unsigned Cnt) const LLVM_READONLY
Fetches the map-type-modifier location at 'Cnt' index of array of modifiers' locations.
Module * Parent
The parent of this module.
const Type * getClass() const
Record code for floating point #pragma options.
CXXRecordDecl * getDecl() const
void AddTypeLoc(TypeLoc TL)
Emits source location information for a type. Does not emit the type.
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc...
Defines the Diagnostic-related interfaces.
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
This represents 'default' clause in the '#pragma omp ...' directive.
SourceLocation getTemplateKeywordLoc() const
Expr * getSizeExpr() const
Wrapper for source info for ObjC interfaces.
Record code for the set of known namespaces, which are used for typo correction.
unsigned getScale() const
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
TypeID MakeTypeID(ASTContext &Context, QualType T, IdxForTypeTy IdxForType)
bool hasRevertedBuiltin() const
True if setNotBuiltin() was called.
Record code for an array of all of the (sub)modules that were imported by the AST file...
This represents 'final' clause in the '#pragma omp ...' directive.
This represents 'mergeable' clause in the '#pragma omp ...' directive.
submodule_iterator submodule_end()
serialization::DeclID BaseDeclID
Base declaration ID for declarations local to this module.
unsigned getInt() const
Used to serialize this.
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
import_range local_imports() const
std::vector< std::string > Warnings
The list of -W...
This represents clause 'reduction' in the '#pragma omp ...' directives.
A marker record that indicates that we are at the end of an expression.
A ClassTemplateSpecializationDecl record.
bool isUsed() const
Return false if this macro is defined in the main file and has not yet been used. ...
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
SourceLocation getNameLoc() const
TemplateTemplateParmDecl * getParameter() const
A BlockPointerType record.
uint32_t getIndex() const
SourceLocation getDefaultmapModifierLoc() const
Get the modifier location.
SmallVector< uint64_t, 64 > RecordData
A MemberPointerType record.
TemplateArgumentLoc getArgLoc(unsigned i) const
helper_expr_const_range source_exprs() const
This represents clause 'is_device_ptr' in the '#pragma omp ...' directives.
Represents an ObjC class declaration.
SourceLocation getIncludeLoc() const
unsigned getUniqueDeclarationsNum() const
Return the number of unique base declarations in this clause.
APSInt & getComplexIntReal()
unsigned getNumArgs() const
SourceLocation getProtocolRAngleLoc() const
A DependentSizedExtVectorType record.
SmallVectorImpl< uint64_t > RecordDataImpl
SourceLocation getElaboratedKeywordLoc() const
helper_expr_const_range source_exprs() const
unsigned getLength() const
Efficiently return the length of this identifier info.
Expr * getSizeExpr() const
Record code for the table of offsets into the block of source-location information.
bool isMacroArgExpansion() const
bool getNoCallerSavedRegs() const
QualType getPointeeTypeAsWritten() const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Expr * getSizeExpr() const
unsigned getNumProtocols() const
Return the number of qualifying protocols in this type, or 0 if there are none.
QualType getElementType() const
Represents an extended vector type where either the type or size is dependent.
helper_expr_const_range privates() const
private_copies_range private_copies()
A SubstTemplateTypeParmPackType record.
This represents clause 'from' in the '#pragma omp ...' directives.
TypeCode
Record codes for each kind of type.
SourceLocation getLParenLoc() const
Returns the location of '('.
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
Iterator that walks over the list of categories, filtering out those that do not meet specific criter...
void AddAPValue(const APValue &Value)
Emit an APvalue.
SourceLocation getTemplateEllipsisLoc() const
SourceLocation getTemplateKeywordLoc() const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
unsigned IsSystem
Whether this is a "system" module (which assumes that all headers in it are system headers)...
The block containing information about the source manager.
Expr * getAddrSpaceExpr() const
helper_expr_const_range reduction_ops() const
bool DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
A VariableArrayType record.
This represents 'dynamic_allocators' clause in the '#pragma omp requires' directive.
unsigned local_sloc_entry_size() const
Get the number of local SLocEntries we have.
QualType getBaseType() const
Gets the base type of this object type.
SourceLocation getBuiltinLoc() const
unsigned getLocalFastQualifiers() const
bool hasExternalDecls() const
Sema - This implements semantic analysis and AST building for C.
const unsigned int NUM_PREDEF_PP_ENTITY_IDS
The number of predefined preprocessed entity IDs.
bool hasChangedSinceDeserialization() const
Determine whether this identifier has changed since it was loaded from an AST file.
OpenMPDefaultClauseKind getDefaultKind() const
Returns kind of the clause.
unsigned NumTemplParamLists
The number of "outer" template parameter lists.
FunctionDecl * getExceptionSpecDecl() const
If this function type has an exception specification which hasn't been determined yet (either because...
Represents a prototype with parameter type info, e.g.
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Defines the major attributes of a submodule, including its name and parent.
This represents 'threads' clause in the '#pragma omp ...' directive.
void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc, DeclarationName Name)
std::string CurrentModule
The name of the current module, of which the main source file is a part.
NestedNameSpecifierLoc getMapperQualifierLoc() const
Gets the nested name specifier for associated user-defined mapper.
helper_expr_const_range destination_exprs() const
Expr * getSimdlen() const
Return safe iteration space distance.
void AddCXXTemporary(const CXXTemporary *Temp)
Emit a CXXTemporary.
helper_expr_const_range source_exprs() const
ModuleHeaderRole
Flags describing the role of a module header.
This represents clause 'aligned' in the '#pragma omp ...' directives.
OverloadedOperatorKind getOperatorKind() const
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
SourceLocation getNameLoc() const
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
llvm::SmallSetVector< Module *, 2 > Imports
The set of modules imported by this module, and on which this module depends.
A table of skipped ranges within the preprocessing record.
A dependent template name that has not been resolved to a template (or set of templates).
DeclarationNameTable DeclarationNames
ASTFileSignature WriteAST(Sema &SemaRef, const std::string &OutputFile, Module *WritingModule, StringRef isysroot, bool hasErrors=false, bool ShouldCacheASTInMemory=false)
Write a precompiled header for the given semantic analysis.
helper_expr_const_range private_copies() const
This represents clause 'task_reduction' in the '#pragma omp taskgroup' directives.
unsigned LocalNumSLocEntries
The number of source location entries in this AST file.
SourceLocation getLParenLoc() const
Returns the location of '('.
ObjCTypeParamDecl * getDecl() const
bool isInlineSpecified() const
A StaticAssertDecl record.
Captures information about a #pragma weak directive.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
void AddPath(StringRef Path, RecordDataImpl &Record)
Add a path to the given record.
helper_expr_const_range destination_exprs() const
OpenMPProcBindClauseKind getProcBindKind() const
Returns kind of the clause.
A VarTemplateSpecializationDecl record.
Record code for the table of offsets of each macro ID.
SourceLocation getLParenLoc() const
Returns the locaiton of '('.
unsigned getNumParams() const
unsigned getNumLoops() const
Get number of loops associated with the clause.
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...
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
An ObjCTypeParamDecl record.
Exposes information about the current target.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
A record containing CXXBaseSpecifiers.
Represents an array type in C++ whose size is a value-dependent expression.
void AddAttr(const Attr *A)
const_all_num_lists_range all_num_lists() const
CommentOptions CommentOpts
Options for parsing comments.
SourceLocation getTemplateNameLoc() const
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Specifies some declarations with initializers that must be emitted to initialize the module...
An ObjCObjectPointerType record.
An TemplateSpecializationType record.
File is from a prebuilt module path.
QualType getElementType() const
Type source information for an attributed type.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
An ObjCInterfaceType record.
unsigned getNumArgs() const
Retrieve the number of template arguments.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
This represents 'proc_bind' clause in the '#pragma omp ...' directive.
This represents 'capture' clause in the '#pragma omp atomic' directive.
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
Describes a zlib-compressed blob that contains the data for a buffer entry.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
A ObjCCategoryImplDecl record.
Defines the clang::LangOptions interface.
unsigned getCounterValue() const
SourceLocation getLocalRangeEnd() const
TemplateDecl * getTemplateDecl() const
The template declaration to which this qualified name refers.
Record code for the array of VTable uses.
ObjCMethodList * getNext() const
static bool isInterestingIdentifier(ASTReader &Reader, IdentifierInfo &II, bool IsModule)
Whether the given identifier is "interesting".
QualType getucontext_tType() const
Retrieve the C ucontext_t type.
The directory that the PCH was originally created in.
SourceLocation getMapLoc() const LLVM_READONLY
Fetches location of clause mapping kind.
unsigned getAsOpaqueValue() const
A ObjCPropertyImplDecl record.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
This represents 'simdlen' clause in the '#pragma omp ...' directive.
Expr * getNumTasks() const
Return safe iteration space distance.
SourceLocation getScheduleKindLoc()
Get kind location.
unsigned getIndex() const
std::string WorkingDir
If set, paths are resolved as if the working directory was set to the value of WorkingDir.
NamespaceDecl * getAnonymousNamespace() const
unsigned LocalNumIdentifiers
The number of identifiers in this AST file.
void AddCXXDefinitionData(const CXXRecordDecl *D)
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
std::string OMPHostIRFile
Name of the IR file that contains the result of the OpenMP target host code generation.
Implements an efficient mapping from strings to IdentifierInfo nodes.
Defines implementation details of the clang::SourceManager class.
bool getHasRegParm() const
StoredDeclsMap * getLookupPtr() const
Retrieve the internal representation of the lookup structure.
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
SourceLocation getLParenLoc() const
Returns the location of '('.
unsigned ConfigMacrosExhaustive
Whether the set of configuration macros is exhaustive.
Record code for the table of offsets to entries in the preprocessing record.
Represents a C++ destructor within a class.
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Selector getSelector() const
A CXXConstructorDecl record.
Defines version macros and version-related utility functions for Clang.
const FileEntry * ContentsEntry
References the file which the contents were actually loaded from.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Defines the clang::Preprocessor interface.
ArgKind
The kind of template argument we're storing.
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
The block containing the detailed preprocessing record.
SourceLocation getLParenLoc() const
Returns the location of '('.
llvm::MapVector< IdentifierInfo *, WeakInfo > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
Record code for #pragma diagnostic mappings.
Expr * getAllocator() const
Returns the allocator expression or nullptr, if no allocator is specified.
bool isFileContext() const
serialization::TypeID GetOrCreateTypeID(QualType T)
Force a type to be emitted and get its ID.
DeclContext * getDeclContext()
A structure for storing the information associated with a substituted template template parameter...
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
unsigned LocalNumMacros
The number of macros in this AST file.
SourceLocation getCaretLoc() const
A CXXStdInitializerListExpr record.
SourceLocation getEllipsisLoc() const
A record containing CXXCtorInitializers.
ArrayRef< const FileEntry * > getTopHeaders(FileManager &FileMgr)
The top-level headers associated with this module.
A VarTemplateDecl record.
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Record code for the original file that was used to generate the AST file, including both its file ID ...
OpenMPDistScheduleClauseKind getDistScheduleKind() const
Get kind of the clause.
An ArraySubscriptExpr record.
Represents a C++ template name within the type system.
llvm::Optional< PreambleSkipInfo > getPreambleSkipInfo() const
llvm::SmallVector< LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used...
Represents the type decltype(expr) (C++11).
helper_expr_const_range rhs_exprs() const
Information about a module that has been loaded by the ASTReader.
QualType getFILEType() const
Retrieve the C FILE type.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
A namespace alias, stored as a NamespaceAliasDecl*.
void AddString(StringRef Str, RecordDataImpl &Record)
Add a string to the given record.
This represents 'ordered' clause in the '#pragma omp ...' directive.
Record code for the diagnostic options table.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
A CXXDestructorDecl record.
unsigned getLocalOrImportedSubmoduleID(Module *Mod)
Retrieve or create a submodule ID for this module, or return 0 if the submodule is neither local (a s...
A FunctionProtoType record.
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack...
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
SourceLocation getColonLoc() const
Get colon location.
Describes a source location entry (SLocEntry) for a file.
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
SourceLocation getLocalRangeBegin() const
Wrapper for source info for enum types.
A block containing a module file extension.
SourceLocation getProtocolLAngleLoc() const
clang::ObjCRuntime ObjCRuntime
std::string FileName
The file name of the module file.
A NamespaceAliasDecl record.
Record code for an update to a decl context's lookup table.
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Record code for #pragma ms_struct options.
bool hasUnsignedPadding() const
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
QualType getRecordType(const RecordDecl *Decl) const
const unsigned VERSION_MINOR
AST file minor version number supported by this version of Clang.
void AddQualifierInfo(const QualifierInfo &Info)
A DesignatedInitUpdateExpr record.
void AddStmt(Stmt *S)
Add the given statement or expression to the queue of statements to emit.
SourceLocation getEnd() const
void AddSelectorRef(Selector S)
Emit a Selector (which is a smart pointer reference).
Represents a GCC generic vector type.
ArraySizeModifier getSizeModifier() const
struct CXXOpName CXXOperatorName
An lvalue reference type, per C++11 [dcl.ref].
bool isBaseOfClass() const
Determine whether this base class is a base of a class declared with the 'class' keyword (vs...
An ImplicitParamDecl record.
unsigned getNumArgs() const
Expr * getDevice()
Return device number.
bool isAvailable() const
Determine whether this module is available for use within the current translation unit...
This represents 'collapse' clause in the '#pragma omp ...' directive.
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
bool isObjectLike() const
SourceLocation getCommaLoc()
Get location of ','.
APSInt & getComplexIntImag()
unsigned SLocEntryBaseOffset
The base offset in the source manager's view of this module.
An EnumConstantDecl record.
Record code for the table of offsets of each identifier ID.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
Record code for undefined but used functions and variables that need a definition in this TU...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
A DependentNameType record.
Abstract base class that writes a module file extension block into a module file. ...
SourceLocation getLocation() const
An ImportDecl recording a module import.
A ObjCCategoryDecl record.
An ObjCPropertyRefExpr record.
const ExpansionInfo & getExpansion() const
unsigned getOffset() const
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
An ObjCForCollectionStmt record.
Expr * getUnderlyingExpr() const
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Record code for the identifier table.
bool isRecordingPreamble() const
A FileScopeAsmDecl record.
ArrayRef< Expr * > getLoopNumIterations() const
Get number of iterations for all the loops.
A ObjCCompatibleAliasDecl record.
This represents 'seq_cst' clause in the '#pragma omp atomic' directive.
helper_expr_const_range assignment_ops() const
This represents 'untied' clause in the '#pragma omp ...' directive.
TypeSourceInfo * getAsTypeSourceInfo() const
SmallVector< ExportDecl, 2 > Exports
The set of export declarations.
mapperlist_range mapperlists()
DelegatingCtorDeclsType DelegatingCtorDecls
All the delegating constructors seen so far in the file, used for cycle detection at the end of the T...
In-memory cache for modules.
std::string CPU
If given, the name of the target CPU to generate code for.
A MS-style AsmStmt record.
SourceManager & getSourceManager() const
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
const DirectoryEntry * Directory
The build directory of this module.
void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record)
Emit a source location.
void push_back(uint64_t N)
Minimal vector-like interface.
bool capturesVariable() const
Determine whether this capture handles a variable.
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
The Objective-C 'Class' type.
This represents 'unified_address' clause in the '#pragma omp requires' directive. ...
SpecifierKind
The kind of specifier that completes this nested name specifier.
NestedNameSpecifierLoc getTemplateQualifierLoc() const
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
SourceLocation getExpansionLocEnd() const
Defines the clang::OpenCLOptions class.
SourceLocation getLParenLoc()
Get location of '('.
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
A template template parameter pack that has been substituted for a template template argument pack...
Wrapper for source info for arrays.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
SourceLocation getColonLoc() const
Returns the location of ':'.
Record code for the set of source location entries that need to be preloaded by the AST reader...
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
This represents 'num_teams' clause in the '#pragma omp ...' directive.
Information about a FileID, basically just the logical file that it represents and include stack info...
The list of delegating constructor declarations.
Record code for types associated with OpenCL extensions.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to...
SourceLocation getTemplateNameLoc() const
DeclContext::lookup_result getLookupResult()
getLookupResult - Return an array of all the decls that this list represents.
Encapsulates changes to the "macros namespace" (the location where the macro name became active...
An UnresolvedUsingValueDecl record.
This object has an indeterminate value (C++ [basic.indet]).
serialization::TypeID BaseTypeIndex
Base type ID for types local to this module as represented in the global type ID space.
std::string ABI
If given, the name of the target ABI to use.
SourceLocation getLParenLoc()
Get location of '('.
ExtParameterInfo getExtParameterInfo(unsigned I) const
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
ElaboratedTypeKeyword getKeyword() const
const ContentCache * getContentCache() const
helper_expr_const_range taskgroup_descriptors() const
serialization::IdentID BaseIdentifierID
Base identifier ID for identifiers local to this module.
const Attr * getAttr() const
The type attribute.
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
unsigned getTotalComponentListNum() const
Return the number of lists derived from the clause expressions.
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis for a capture that is a pack expansion.
Encodes a location in the source.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
SourceLocation getStarLoc() const
Sugar for parentheses used when specifying types.
QualType getAdjustedType() const
QualType getReturnType() const
This represents 'hint' clause in the '#pragma omp ...' directive.
SourceLocation CurrentPragmaLocation
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, const TemplateArgumentLocInfo &Arg)
Emits a template argument location info.
StringRef getName() const
FileSystemOptions & getFileSystemOpts()
Returns the current file system options.
A record that stores the set of declarations that are visible from a given DeclContext.
Specifies a library or framework to link against.
Record code for file ID of the file or buffer that was used to generate the AST file.
Represents a C++ temporary.
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
Specifies a header that falls into this (sub)module.
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
std::string ExportAsModule
The module through which entities defined in this module will eventually be exposed, for use in "private" modules.
A structure for storing an already-substituted template template parameter pack.
private_copies_range private_copies()
Record code for special CUDA declarations.
MacroDirective * getLocalMacroDirectiveHistory(const IdentifierInfo *II) const
Given an identifier, return the latest non-imported macro directive for that identifier.
Options for controlling the compiler diagnostics engine.
A list of "interesting" identifiers.
The block of configuration options, used to check that a module is being used in a configuration comp...
void AddDeclarationName(DeclarationName Name)
Emit a declaration name.
unsigned IsSystemFile
True if this content cache was initially created for a source file considered as a system one...
DeclarationName getName() const
getName - Returns the embedded declaration name.
void AddOffset(uint64_t BitOffset)
Add a bit offset into the record.
Represents the declaration of a struct/union/class/enum.
TemplateArgument getArgumentPack() const
This represents 'schedule' clause in the '#pragma omp ...' directive.
ASTContext & getASTContext() const LLVM_READONLY
CallingConv getCC() const
QualType getElementType() const
IdentifierInfo * getIdentifierInfo() const
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
virtual void writeExtensionContents(Sema &SemaRef, llvm::BitstreamWriter &Stream)=0
Write the contents of the extension block into the given bitstream.
This is so that older clang versions, before the introduction of the control block, can read and reject the newer PCH format.
IdentifierTable & getIdentifierTable()
SourceLocation getLParenLoc() const
Returns the location of '('.
This represents clause 'shared' in the '#pragma omp ...' directives.
Represents a vector type where either the type or size is dependent.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getProcBindKindKwLoc() const
Returns location of clause kind.
Cached information about one file (either on disk or in the virtual file system). ...
Metadata describing this particular extension.
const SrcMgr::SLocEntry & getLocalSLocEntry(unsigned Index, bool *Invalid=nullptr) const
Get a local SLocEntry. This is exposed for indexing.
static bool shouldIgnoreMacro(MacroDirective *MD, bool IsModule, const Preprocessor &PP)
An ObjCTypeParamType record.
SmallVector< Header, 2 > Headers[5]
The headers that are part of this module.
A CXXFunctionalCastExpr record.
std::vector< std::string > Remarks
The list of -R...
A FloatingLiteral record.
Record code for the offsets of each decl.
Metadata for submodules as a whole.
Expr * getPriority()
Return Priority number.
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location...
bool isModuleMap(CharacteristicKind CK)
Determine whether a file characteristic is for a module map.
void AddTemplateArgument(const TemplateArgument &Arg)
Emit a template argument.
An ObjCEncodeExpr record.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
Record code for late parsed template functions.
A dependentSizedVectorType record.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
OpenMPMapClauseKind getMapType() const LLVM_READONLY
Fetches mapping kind for the clause.
SourceLocation getRParenLoc() const
bool isPackExpansion() const
Determine whether this base specifier is a pack expansion.
Defines the clang::TargetOptions class.
A TemplateTypeParmDecl record.
bool isParameterPack() const
bool isPoisoned() const
Return true if this token has been poisoned.
An ImaginaryLiteral record.
Expr * getLoopCounter(unsigned NumLoop)
Get loops counter for the specified loop.
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings startin...
FixedPointSemantics getSemantics() const
unsigned LocalNumDecls
The number of declarations in this AST file.
ObjCCategoryDecl - Represents a category declaration.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
This is a basic class for representing single OpenMP clause.
Qualifiers getMethodQuals() const
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
bool SawDateOrTime() const
Returns true if the preprocessor has seen a use of DATE or TIME in the file so far.
QualType getEquivalentType() const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
SourceLocation getColonLoc() const
Returns the location of the ':' delimiter.
The internal 'instancetype' typedef.
SourceLocation getStarLoc() const
void AddNestedNameSpecifier(NestedNameSpecifier *NNS)
Emit a nested name specifier.
serialization::TypeID getTypeID(QualType T) const
Determine the type ID of an already-emitted type.
QualType getInnerType() const
IdentifierInfo * getIdentifier() const
Describes the categories of an Objective-C class.
The AST block, which acts as a container around the full AST block.
SourceLocation getNameModifierLoc() const
Return the location of directive name modifier.
A DeducedTemplateSpecializationType record.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
uint32_t TypeID
An ID number that refers to a type in an AST file.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
void AddAttributes(ArrayRef< const Attr *> Attrs)
Emit a list of attributes.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line...
const unsigned int DECL_UPDATES
Record of updates for a declaration that was modified after being deserialized.
const LangOptions & getLangOpts() const
void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record)
Add a version tuple to the given record.
llvm::MemoryBuffer & addBuiltPCM(llvm::StringRef Filename, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Store a just-built PCM under the Filename.
void updateOutOfDateSelector(Selector Sel)
void AddSourceLocation(SourceLocation Loc)
Emit a source location.
Expr * getNumForLoops() const
Return the number of associated for-loops.
AutoTypeKeyword getKeyword() const
TypeClass getTypeClass() const
static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob, unsigned SLocBufferBlobCompressedAbbrv, unsigned SLocBufferBlobAbbrv)
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
An InjectedClassNameType record.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
Record code for the extra statistics we gather while generating an AST file.
SourceLocation getRAngleLoc() const
FunctionDecl * getcudaConfigureCallDecl()
SourceLocation getRAngleLoc() const
bool isC99Varargs() const
SourceLocation getExpansionLocStart() const
const_all_lists_sizes_range all_lists_sizes() const
SourceRange getBracketsRange() const
An array of decls optimized for the common case of only containing one entry.
void AddAPFloat(const llvm::APFloat &Value)
Emit a floating-point value.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
bool PreparePathForOutput(SmallVectorImpl< char > &Path)
Convert a path from this build process into one that is appropriate for emission in the module file...
const VersionTuple & getVersion() const
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
An OMPAllocateDcl record.
unsigned LocalNumSubmodules
The number of submodules in this module.
TypeSourceInfo * getTypeSourceInfo() const
Retrieves the type and source location of the base class.
unsigned ComputeHash(Selector Sel)
SourceLocation getLParenLoc() const
Returns the location of '('.
helper_expr_const_range lhs_exprs() const
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
Record code for the signature that identifiers this AST file.
Record code for referenced selector pool.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
std::vector< std::string > MacroIncludes
Represents a pointer type decayed from an array or function type.
const MacroInfo * getMacroInfo() const
void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
The injected class name of a C++ class template or class template partial specialization.
Record code for the set of non-builtin, special types.
QualType getPointeeType() const
A ObjCProtocolDecl record.
Represents a pack expansion of types.
OpenMPDirectiveKind getCaptureRegion() const
Get capture region for the stmt in the clause.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Defines various enumerations that describe declaration and type specifiers.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
ArrayRef< Decl * > getModuleInitializers(Module *M)
Get the initializations to perform when importing a module, if any.
StringRef getName() const
Return the actual identifier string.
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
static void addExceptionSpec(const FunctionProtoType *T, ASTRecordWriter &Record)
void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C)
SourceRange getRange() 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.
unsigned getObjCOrBuiltinID() const
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
SourceLocation getTypeofLoc() const
Represents a template argument.
Record code for the list of other AST files imported by this AST file.
A CXXConversionDecl record.
Describes a macro definition within the preprocessing record.
void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C)
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
TypeSourceInfo * getClassTInfo() const
Represents a template name that was expressed as a qualified name.
The internal '__NSConstantString' typedef.
Record code for the module name.
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
void writeClause(OMPClause *C)
Dataflow Directional Tag Classes.
SourceLocation getColonLoc() const
Get colon location.
This represents 'device' clause in the '#pragma omp ...' directive.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getRBracketLoc() const
An IntegerLiteral record.
Describes an inclusion directive within the preprocessing record.
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
The internal '__builtin_ms_va_list' typedef.
A type defined in a macro.
OpenMPDefaultmapClauseKind getDefaultmapKind() const
Get kind of the clause.
ExtInfo getExtInfo() const
const TemplateArgument & getArgument() const
unsigned getNumTokens() const
Return the number of tokens that this macro expands to.
not evaluated yet, for special member function
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
NestedNameSpecifier * getQualifier() const
Record code for a file sorted array of DeclIDs in a module.
A CXXBoolLiteralExpr record.
Record code for the array of Objective-C categories (including extensions).
SourceLocation getTemplateNameLoc() const
Specifies a configuration macro for this module.
virtual ModuleFileExtensionMetadata getExtensionMetadata() const =0
Retrieves the metadata for this module file extension.
helper_expr_const_range privates() const
bool isInitKnownICE() const
Determines whether it is already known whether the initializer is an integral constant expression or ...
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
QualType getType() const
Get the type for which this source info wrapper provides information.
An ExtVectorElementExpr record.
The template argument is a pack expansion of a template name that was provided for a template templat...
Record code for the array of unused file scoped decls.
void AddCXXBaseSpecifiers(ArrayRef< CXXBaseSpecifier > Bases)
Emit a set of C++ base specifiers.
PreprocessingRecord * getPreprocessingRecord() const
Retrieve the preprocessing record, or NULL if there is no preprocessing record.
llvm::iterator_range< submodule_iterator > submodules()
A FunctionNoProtoType record.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
Reads an AST files chain containing the contents of a translation unit.
File is an explicitly-loaded module.
ArrayRef< KnownHeader > findAllModulesForHeader(const FileEntry *File) const
Retrieve all the modules that contain the given header file.
A ClassTemplatePartialSpecializationDecl record.
const_all_components_range all_components() const
An ObjCIvarRefExpr record.
TemplateArgumentLoc getArgLoc(unsigned i) const
ModuleFileExtension * getExtension() const
Retrieve the module file extension with which this writer is associated.
const Expr * getInit() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
FileID getMainFileID() const
Returns the FileID of the main source file.
QualType getUnderlyingType() const
LambdaCaptureKind getCaptureKind() const
Determine the kind of capture.
SourceLocation getRAngleLoc() const
void AddCXXCtorInitializers(ArrayRef< CXXCtorInitializer *> CtorInits)
Emit a CXXCtorInitializer array.
The name of a declaration.
A ClassScopeFunctionSpecializationDecl record a class scope function specialization.
VectorKind getVectorKind() const
Record code for the Objective-C method pool,.
bool isExtensionToken() const
get/setExtension - Initialize information about whether or not this language token is an extension...
static unsigned CreateSLocBufferAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a buffer.
A CharacterLiteral record.
Specifies a header that is private to this submodule.
SourceLocation getLParenLoc()
Get location of '('.
A LinkageSpecDecl record.
Describes a macro expansion within the preprocessing record.
An ObjCStringLiteral record.
A CXXDynamicCastExpr record.
This represents 'unified_shared_memory' clause in the '#pragma omp requires' directive.
This represents clause 'linear' in the '#pragma omp ...' directives.
A CXXForRangeStmt record.
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
void * getFETokenInfo() const
Get and set FETokenInfo.
SourceLocation getLocation() const
A pointer to member type per C++ 8.3.3 - Pointers to members.
IdentifierResolver IdResolver
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
An RValueReferenceType record.
OpenMPDefaultmapClauseModifier getDefaultmapModifier() const
Get the modifier of the clause.
SourceLocation getBeginLoc() const
Returns the starting location of the clause.
A type that was preceded by the 'template' keyword, stored as a Type*.
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
SourceLocation getLParenLoc() const
Returns the location of '('.
unsigned getLength() const
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
An ObjCAtFinallyStmt record.
NestedNameSpecifierLoc getQualifierLoc() const
bool IsLocalDecl(const Decl *D)
Is this a local declaration (that is, one that will be written to our AST file)? This is the case for...
SourceLocation getElaboratedKeywordLoc() const
QualType getModifiedType() const
unsigned getNumParams() const
SourceLocation getRBracketLoc() const
SourceLocation getEndLoc() const
Returns the ending location of the clause.
Represents a pointer to an Objective C object.
helper_expr_const_range privates() const
Number of unmatched #pragma clang cuda_force_host_device begin directives we've seen.
unsigned ModuleMapIsPrivate
Whether this module came from a "private" module map, found next to a regular (public) module map...
Encapsulates the data about a macro definition (e.g.
Capturing variable-length array type.
A PragmaCommentDecl record.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
struct CXXLitOpName CXXLiteralOperatorName
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
unsigned getIndexTypeCVRQualifiers() const
unsigned getNumArgs() const
Retrieve the number of template arguments.
std::vector< Conflict > Conflicts
The list of conflicts.
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
SourceLocation getLParenLoc() const
Returns the location of '('.
Record code for the table of offsets into the Objective-C method pool.
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
QualType getCanonicalTypeInternal() const
Defines the clang::FileSystemOptions interface.
A DependentSizedArrayType record.
Record code for the remapping information used to relate loaded modules to the various offsets and ID...
An ObjCAtSynchronizedStmt record.
SourceLocation getTemplateNameLoc() const
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
A key used when looking up entities by DeclarationName.
helper_expr_const_range destination_exprs() const
SourceLocation getKWLoc() const
SourceLocation getRParenLoc() const
An UnresolvedSet-like class which uses the ASTContext's allocator.
Record code for declarations that Sema keeps references of.
const llvm::APInt & getSize() const
A SizefAlignOfExpr record.
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
SourceLocation getLParenLoc() const
Returns the location of '('.
bool WriteCommentListToPCH
Whether to write comment locations into the PCH when building it.
Offsets into the input-files block where input files reside.
A CXXMemberCallExpr record.
ExtVectorType - Extended vector type.
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
SourceLocation getProtocolLoc(unsigned i) const
Expr * getSizeExpr() const
void AddAPSInt(const llvm::APSInt &Value)
Emit a signed integral value.
unsigned getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
The block containing the submodule structure.
Wrapper for source info for record types.
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
SourceLocation getLBracketLoc() const
The template argument is a type.
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
Wraps an ObjCPointerType with source location information.
QualType getUnderlyingType() const
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
unsigned getNumArgs() const
SourceLocation getDefinitionLoc() const
Return the location that the macro was defined at.
SourceLocation getDistScheduleKindLoc()
Get kind location.
unsigned getWidth() const
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
serialization::SelectorID getSelectorRef(Selector Sel)
Get the unique number used to refer to the given selector.
The template argument is actually a parameter pack.
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
Capturing the *this object by reference.
void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record, StringRef Path)
Emit the current record with the given path as a blob.
Represents a base class of a C++ class.
PreprocessorOptions & getPreprocessorOpts() const
Retrieve the preprocessor options used to initialize this preprocessor.
This represents 'write' clause in the '#pragma omp atomic' directive.
SourceLocation getLParenLoc() const
unsigned BufferOverridden
Indicates whether the buffer itself was provided to override the actual file contents.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
SourceManager & getSourceManager()
Keeps track of options that affect how file operations are performed.
SourceLocation getLParenLoc() const
Returns the location of '('.
SourceLocation getDefinitionEndLoc() const
Return the location of the last token in the macro.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
EnumDecl * getStdAlignValT() const
A template argument list.
SourceLocation getModuleImportLoc(Module *M) const
VectorType::VectorKind getVectorKind() const
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
TypedefNameDecl * getDecl() const
SourceLocation getLAngleLoc() const
SourceLocation getTypeArgsLAngleLoc() const
SourceLocation getLParenLoc() const
Returns the location of '('.
NestedNameSpecifierLoc QualifierLoc
known_categories_iterator known_categories_end() const
Retrieve an iterator to the end of the known-categories list.
ArgKind getKind() const
Return the kind of stored template argument.
unsigned getDepth() const
An attributed type is a type to which a type attribute has been applied.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
Represents a type parameter type in Objective C.
OpenMPScheduleClauseModifier getSecondScheduleModifier() const
Get the second modifier of the clause.
ValueKind getKind() const
TranslationUnitDecl * getTranslationUnitDecl() const
Defines the clang::SourceLocation class and associated facilities.
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
A GCC-style AsmStmt record.
void SetSelectorOffset(Selector Sel, uint32_t Offset)
Note that the selector Sel occurs at the given offset within the method pool/selector table...
This represents 'nowait' clause in the '#pragma omp ...' directive.
APFloat & getComplexFloatImag()
unsigned InferSubmodules
Whether we should infer submodules for this module based on the headers.
Represents a C++ struct/union/class.
Represents a template specialization type whose template cannot be resolved, e.g. ...
FileID getPredefinesFileID() const
Returns the FileID for the preprocessor predefines.
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
DiagnosticsEngine & getDiagnostics() const
An TemplateTypeParmType record.
This represents 'num_tasks' clause in the '#pragma omp ...' directive.
Decl * D
The template function declaration to be late parsed.
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
TemplateArgumentLocInfo getLocInfo() const
SourceLocation getEllipsisLoc() const
For a pack expansion, determine the location of the ellipsis.
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
Record code for the filesystem options table.
An object for streaming information to a record.
static void AddLazyVectorDecls(ASTWriter &Writer, Vector &Vec, ASTWriter::RecordData &Record)
An ObjCAtCatchStmt record.
static bool cleanPathForOutput(FileManager &FileMgr, SmallVectorImpl< char > &Path)
Prepares a path for being written to an AST file by converting it to an absolute path and removing ne...
There is no such object (it's outside its lifetime).
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
A ObjCImplementationDecl record.
QualType getNamedType() const
Retrieve the type named by the qualified-id.
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
SourceLocation getFirstScheduleModifierLoc() const
Get the first modifier location.
A structure for storing the information associated with an overloaded template name.
A structure for storing the information associated with a name that has been assumed to be a template...
unsigned getNumProtocols() const
helper_expr_const_range reduction_ops() const
bool isBuiltinMacro() const
Return true if this macro requires processing before expansion.
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Location information for a TemplateArgument.
A ObjCAtDefsFieldDecl record.
Declaration of a class template.
Record code for the offsets of each type.
A DependentAddressSpaceType record.
Expr * getThreadLimit()
Return ThreadLimit number.
The block containing the definitions of all of the types and decls used within the AST file...
The internal '__va_list_tag' struct, if any.
This class is used for builtin types like 'int'.
Writes an AST file containing the contents of a translation unit.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl< char > &Buffer, InMemoryModuleCache &ModuleCache, ArrayRef< std::shared_ptr< ModuleFileExtension >> Extensions, bool IncludeTimestamps=true)
Create a new precompiled header writer that outputs to the given bitstream.
bool hasRecordedPreamble() const
serialization::DeclID getDeclID(const Decl *D)
Determine the declaration ID of an already-emitted declaration.
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Emit a C++ base specifier.
void AddASTTemplateArgumentListInfo(const ASTTemplateArgumentListInfo *ASTTemplArgList)
Emits an AST template argument list info.
SourceLocation getLocation() const
Retrieve the source location of the capture.
void AddAPInt(const llvm::APInt &Value)
Emit an integral value.
LineTableInfo & getLineTable()
Retrieve the stored line table.
Specifies the name of the module that will eventually re-export the entities in this module...
Defines the clang::TargetInfo interface.
MacroDefinitionRecord * findMacroDefinition(const MacroInfo *MI)
Retrieve the macro definition that corresponds to the given MacroInfo.
SourceLocation getNameLoc() const
ArrayRef< ModuleMacro * > getLeafModuleMacros(const IdentifierInfo *II) const
Get the list of leaf (non-overridden) module macros for a name.
a linked list of methods with the same selector name but different signatures.
Specifies a required feature.
This represents 'dist_schedule' clause in the '#pragma omp ...' directive.
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
std::vector< std::string > ConfigMacros
The set of "configuration macros", which are macros that (intentionally) change how this module is bu...
An ObjCMessageExpr record.
bool isGNUVarargs() const
QualType getjmp_bufType() const
Retrieve the C jmp_buf type.
unsigned getNumTypeArgs() const
unsigned getNumElements() const
Expr * getHint() const
Returns number of threads.
static void WriteFixedPointSemantics(ASTRecordWriter &Record, FixedPointSemantics FPSema)
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
Record for offsets of DECL_UPDATES records for declarations that were modified after being deserializ...
SourceLocation getAmpLoc() const
The top declaration context.
A CompoundAssignOperator record.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getAsType() const
Retrieve the type for a type template argument.
void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs)
Emit a template argument list.
Represents an extended address space qualifier where the input address space value is dependent...
Represents a type template specialization; the template must be a class template, a type alias templa...
static unsigned CreateSLocBufferBlobAbbrev(llvm::BitstreamWriter &Stream, bool Compressed)
Create an abbreviation for the SLocEntry that refers to a buffer's blob.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
A FunctionTemplateDecl record.
Expr * getChunkSize()
Get chunk size.
llvm::DenseMap< CXXRecordDecl *, bool > VTablesUsed
The set of classes whose vtables have been used within this translation unit, and a bit that will be ...
A TypeAliasTemplateDecl record.
Contains a late templated function.
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Record code for weak undeclared identifiers.
The block containing information about the preprocessor.
Expr * getNumThreads() const
Returns number of threads.
void AddTemplateName(TemplateName Name)
Emit a template name.
PragmaStack< unsigned > PackStack
TypeSpecifierType getWrittenTypeSpec() const
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg)
Emits a template argument location.
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
AccessSpecifier getAccessSpecifierAsWritten() const
Retrieves the access specifier as written in the source code (which may mean that no access specifier...
Wrapper for source info for builtin types.
TemplateArgument getArgumentPack() const
Retrieve the template template argument pack with which this parameter was substituted.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
void VisitFunctionType(const FunctionType *T)
A set of overloaded template declarations.
Wrapper for template type parameters.
Record code for the headers search options table.
A trivial tuple used to represent a source range.
unsigned getFlags() const
Return the internal represtation of the flags.
known_categories_iterator known_categories_begin() const
Retrieve an iterator to the beginning of the known-categories list.
This represents a decl that may have a name.
bool isTranslationUnit() const
SourceLocation getLParenLoc() const
Returns the location of '('.
AST file metadata, including the AST file version number and information about the compiler used to b...
static void EmitRecordID(unsigned ID, const char *Name, llvm::BitstreamWriter &Stream, ASTWriter::RecordDataImpl &Record)
The block of input files, which were used as inputs to create this AST file.
FunctionDecl * getExceptionSpecTemplate() const
If this function type has an uninstantiated exception specification, this is the function whose excep...
unsigned IsExplicit
Whether this is an explicit submodule.
Represents a C array with a specified size that is not an integer-constant-expression.
void numberAnonymousDeclsWithin(const DeclContext *DC, Fn Visit)
Visit each declaration within DC that needs an anonymous declaration number and call Visit with the d...
unsigned LocalNumTypes
The number of types in this AST file.
NestedNameSpecifierLoc getQualifierLoc() const
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
The internal '__NSConstantString' tag type.
SourceLocation getAttributeLoc() const
bool isInline() const
Whether this variable is (C++1z) inline.
A function-like macro definition.
QualType getElementType() const
attr::Kind getKind() const
The Objective-C 'Protocol' type.
const Expr * getPostUpdateExpr() const
Get post-update expression for the clause.
SourceLocation getLParenLoc() const
Returns the location of '('.
The global specifier '::'. There is no stored value.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
The control block, which contains all of the information that needs to be validated prior to committi...
OpenMPAtomicDefaultMemOrderClauseKind getAtomicDefaultMemOrderKind() const
Returns kind of the clause.
Wrapper for source info for pointers.
const DeclarationNameInfo & getMapperIdInfo() const
Gets the name info for associated user-defined mapper.
SourceLocation getBegin() const
SmallVector< Slot, 2 > Stack
std::string Triple
The name of the target triple to compile for.
const LangOptions & getLangOpts() const
Wrapper for source info for block pointers.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
This class handles loading and caching of source files into memory.
Represents the canonical version of C arrays with a specified constant size.
PredefinedDeclIDs
Predefined declaration IDs.
Declaration of a template function.
iterator - Iterate over the decls of a specified declaration name.
Record code for an update to the TU's lexically contained declarations.
bool isUsedForHeaderGuard() const
Determine whether this macro was used for a header guard.
APFixedPoint & getFixedPoint()
A class which abstracts out some details necessary for making a call.
A GenericSelectionExpr record.
A type index; the type ID with the qualifier bits removed.
Attr - This represents one attribute.
SourceLocation getLocation() const
This represents clause 'use_device_ptr' in the '#pragma omp ...' directives.
SourceLocation getTypeArgsRAngleLoc() const
QualType getPointeeType() const
A PackExpansionType record.
QualType getType() const
Return the type wrapped by this type source info.
A single template declaration.
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
Defines the LambdaCapture class.
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.
Record code for #pragma ms_struct options.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
const IdentifierInfo * getIdentifier() const
A DependentTemplateSpecializationType record.
Expr * getSizeExpr() const
bool hasLineTable() const
Determine if the source manager has a line table.
StringRef getName() const
ArrayRef< const IdentifierInfo * > params() const
Record code for the array of tentative definitions.
iterator local_begin()
Begin iterator for local, non-loaded, preprocessed entities.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.