73 #include "llvm/ADT/APFloat.h" 74 #include "llvm/ADT/APInt.h" 75 #include "llvm/ADT/APSInt.h" 76 #include "llvm/ADT/ArrayRef.h" 77 #include "llvm/ADT/DenseMap.h" 78 #include "llvm/ADT/Hashing.h" 79 #include "llvm/ADT/Optional.h" 80 #include "llvm/ADT/PointerIntPair.h" 81 #include "llvm/ADT/STLExtras.h" 82 #include "llvm/ADT/ScopeExit.h" 83 #include "llvm/ADT/SmallSet.h" 84 #include "llvm/ADT/SmallString.h" 85 #include "llvm/ADT/SmallVector.h" 86 #include "llvm/ADT/StringMap.h" 87 #include "llvm/ADT/StringRef.h" 88 #include "llvm/Bitstream/BitCodes.h" 89 #include "llvm/Bitstream/BitstreamWriter.h" 90 #include "llvm/Support/Casting.h" 91 #include "llvm/Support/Compression.h" 92 #include "llvm/Support/DJB.h" 93 #include "llvm/Support/Endian.h" 94 #include "llvm/Support/EndianStream.h" 95 #include "llvm/Support/Error.h" 96 #include "llvm/Support/ErrorHandling.h" 97 #include "llvm/Support/MemoryBuffer.h" 98 #include "llvm/Support/OnDiskHashTable.h" 99 #include "llvm/Support/Path.h" 100 #include "llvm/Support/SHA1.h" 101 #include "llvm/Support/VersionTuple.h" 102 #include "llvm/Support/raw_ostream.h" 117 using namespace clang;
120 template <
typename T,
typename Allocator>
121 static StringRef
bytes(
const std::vector<T, Allocator> &
v) {
122 if (v.empty())
return StringRef();
123 return StringRef(reinterpret_cast<const char*>(&v[0]),
124 sizeof(T) * v.size());
127 template <
typename T>
128 static StringRef
bytes(
const SmallVectorImpl<T> &
v) {
129 return StringRef(reinterpret_cast<const char*>(v.data()),
130 sizeof(T) * v.size());
139 #define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \ 140 case Type::CLASS_ID: return TYPE_##CODE_ID; 141 #include "clang/Serialization/TypeBitCodes.def" 143 llvm_unreachable(
"shouldn't be serializing a builtin type this way");
145 llvm_unreachable(
"bad type kind");
150 class ASTTypeWriter {
157 : Writer(Writer), BasicWriter(Writer, Record) {}
181 #define ABSTRACT_TYPELOC(CLASS, PARENT) 182 #define TYPELOC(CLASS, PARENT) \ 183 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc); 184 #include "clang/AST/TypeLocNodes.def" 227 Record.AddSourceLocation(TL.
getAmpLoc());
239 void TypeLocWriter::VisitArrayTypeLoc(
ArrayTypeLoc TL) {
248 VisitArrayTypeLoc(TL);
252 VisitArrayTypeLoc(TL);
256 VisitArrayTypeLoc(TL);
259 void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
261 VisitArrayTypeLoc(TL);
264 void TypeLocWriter::VisitDependentAddressSpaceTypeLoc(
268 Record.AddSourceLocation(range.
getBegin());
269 Record.AddSourceLocation(range.
getEnd());
273 void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
282 void TypeLocWriter::VisitDependentVectorTypeLoc(
297 for (
unsigned i = 0, e = TL.
getNumParams(); i != e; ++i)
302 VisitFunctionTypeLoc(TL);
306 VisitFunctionTypeLoc(TL);
344 Record.AddSourceLocation(TL.
getKWLoc());
350 void TypeLocWriter::VisitAutoTypeLoc(
AutoTypeLoc TL) {
360 for (
unsigned I = 0; I < TL.
getNumArgs(); ++I)
366 void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
375 void TypeLocWriter::VisitEnumTypeLoc(
EnumTypeLoc TL) {
387 void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
392 void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
397 void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
403 for (
unsigned i = 0, e = TL.
getNumArgs(); i != e; ++i)
408 void TypeLocWriter::VisitParenTypeLoc(
ParenTypeLoc TL) {
432 void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
440 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I)
470 Record.AddSourceLocation(TL.
getKWLoc());
475 void TypeLocWriter::VisitPipeTypeLoc(
PipeTypeLoc TL) {
476 Record.AddSourceLocation(TL.
getKWLoc());
479 void ASTWriter::WriteTypeAbbrevs() {
480 using namespace llvm;
482 std::shared_ptr<BitCodeAbbrev> Abv;
485 Abv = std::make_shared<BitCodeAbbrev>();
487 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
488 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3));
489 TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
492 Abv = std::make_shared<BitCodeAbbrev>();
493 Abv->Add(BitCodeAbbrevOp(serialization::TYPE_FUNCTION_PROTO));
495 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
496 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
497 Abv->Add(BitCodeAbbrevOp(0));
498 Abv->Add(BitCodeAbbrevOp(0));
499 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));
500 Abv->Add(BitCodeAbbrevOp(0));
501 Abv->Add(BitCodeAbbrevOp(0));
502 Abv->Add(BitCodeAbbrevOp(0));
504 Abv->Add(BitCodeAbbrevOp(0));
505 Abv->Add(BitCodeAbbrevOp(0));
506 Abv->Add(BitCodeAbbrevOp(0));
507 Abv->Add(BitCodeAbbrevOp(0));
508 Abv->Add(BitCodeAbbrevOp(
EST_None));
509 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
510 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
511 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
512 TypeFunctionProtoAbbrev = Stream.EmitAbbrev(std::move(Abv));
520 llvm::BitstreamWriter &Stream,
523 Record.push_back(ID);
524 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);
527 if (!Name || Name[0] == 0)
531 Record.push_back(*Name++);
532 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME, Record);
536 llvm::BitstreamWriter &Stream,
539 Record.push_back(ID);
541 Record.push_back(*Name++);
542 Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, Record);
547 #define RECORD(X) EmitRecordID(X, #X, Stream, Record) 675 void ASTWriter::WriteBlockInfoBlock() {
677 Stream.EnterBlockInfoBlock();
679 #define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record) 680 #define RECORD(X) EmitRecordID(X, #X, Stream, Record) 683 BLOCK(CONTROL_BLOCK);
694 BLOCK(OPTIONS_BLOCK);
701 BLOCK(INPUT_FILES_BLOCK);
761 BLOCK(SOURCE_MANAGER_BLOCK);
769 BLOCK(PREPROCESSOR_BLOCK);
777 BLOCK(SUBMODULE_BLOCK);
798 BLOCK(COMMENTS_BLOCK);
802 BLOCK(DECLTYPES_BLOCK);
806 RECORD(TYPE_BLOCK_POINTER);
807 RECORD(TYPE_LVALUE_REFERENCE);
808 RECORD(TYPE_RVALUE_REFERENCE);
809 RECORD(TYPE_MEMBER_POINTER);
810 RECORD(TYPE_CONSTANT_ARRAY);
811 RECORD(TYPE_INCOMPLETE_ARRAY);
812 RECORD(TYPE_VARIABLE_ARRAY);
815 RECORD(TYPE_FUNCTION_NO_PROTO);
816 RECORD(TYPE_FUNCTION_PROTO);
822 RECORD(TYPE_OBJC_INTERFACE);
823 RECORD(TYPE_OBJC_OBJECT_POINTER);
826 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM);
827 RECORD(TYPE_UNRESOLVED_USING);
828 RECORD(TYPE_INJECTED_CLASS_NAME);
830 RECORD(TYPE_TEMPLATE_TYPE_PARM);
831 RECORD(TYPE_TEMPLATE_SPECIALIZATION);
832 RECORD(TYPE_DEPENDENT_NAME);
833 RECORD(TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION);
834 RECORD(TYPE_DEPENDENT_SIZED_ARRAY);
836 RECORD(TYPE_MACRO_QUALIFIED);
837 RECORD(TYPE_PACK_EXPANSION);
839 RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK);
841 RECORD(TYPE_UNARY_TRANSFORM);
845 RECORD(TYPE_OBJC_TYPE_PARAM);
922 BLOCK(PREPROCESSOR_DETAIL_BLOCK);
928 BLOCK(EXTENSION_BLOCK);
931 BLOCK(UNHASHED_CONTROL_BLOCK);
948 return Changed | llvm::sys::path::remove_dots(Path);
963 assert(Filename &&
"No file name to adjust?");
970 for (; Filename[Pos] && Pos < BaseDir.size(); ++Pos)
971 if (Filename[Pos] != BaseDir[Pos])
980 if (!llvm::sys::path::is_separator(Filename[Pos])) {
981 if (!llvm::sys::path::is_separator(BaseDir.back()))
995 return Filename + Pos;
1002 auto Hash = Hasher.result();
1006 auto LShift = [&](
unsigned char Val,
unsigned Shift) {
1007 return (uint32_t)Val <<
Shift;
1009 for (
int I = 0; I != 5; ++I)
1010 Signature[I] = LShift(Hash[I * 4 + 0], 24) | LShift(Hash[I * 4 + 1], 16) |
1011 LShift(Hash[I * 4 + 2], 8) | LShift(Hash[I * 4 + 3], 0);
1019 Stream.FlushToWord();
1020 auto StartOfUnhashedControl = Stream.GetCurrentBitNo() >> 3;
1028 if (WritingModule &&
1030 Signature = createSignature(StringRef(Buffer.begin(), StartOfUnhashedControl));
1031 Record.append(Signature.begin(), Signature.end());
1039 #define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name); 1040 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ 1041 Record.push_back(static_cast<unsigned>(DiagOpts.get##Name())); 1042 #include "clang/Basic/DiagnosticOptions.def" 1043 Record.push_back(DiagOpts.
Warnings.size());
1044 for (
unsigned I = 0, N = DiagOpts.
Warnings.size(); I != N; ++I)
1045 AddString(DiagOpts.
Warnings[I], Record);
1046 Record.push_back(DiagOpts.
Remarks.size());
1047 for (
unsigned I = 0, N = DiagOpts.
Remarks.size(); I != N; ++I)
1048 AddString(DiagOpts.
Remarks[I], Record);
1054 WritePragmaDiagnosticMappings(Diags, WritingModule);
1064 const std::string &OutputFile) {
1065 using namespace llvm;
1071 auto MetadataAbbrev = std::make_shared<BitCodeAbbrev>();
1072 MetadataAbbrev->Add(BitCodeAbbrevOp(
METADATA));
1073 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1074 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1075 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1076 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16));
1077 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1078 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1079 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1080 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1081 MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1082 unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev));
1083 assert((!WritingModule || isysroot.empty()) &&
1084 "writing module as a relocatable PCH?");
1086 RecordData::value_type Record[] = {
1090 CLANG_VERSION_MAJOR,
1091 CLANG_VERSION_MINOR,
1095 ASTHasCompilerErrors};
1096 Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
1100 if (WritingModule) {
1102 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1104 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1105 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1107 Stream.EmitRecordWithBlob(AbbrevCode, Record, WritingModule->Name);
1110 if (WritingModule && WritingModule->Directory) {
1120 WritingModule->Directory->getName() != StringRef(
".")) {
1122 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1124 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1125 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1128 Stream.EmitRecordWithBlob(AbbrevCode, Record, BaseDir);
1132 BaseDirectory.assign(BaseDir.begin(), BaseDir.end());
1133 }
else if (!isysroot.empty()) {
1135 BaseDirectory = isysroot;
1143 AddPath(WritingModule->PresumedModuleMapFile.empty()
1144 ? Map.getModuleMapFileForUniquing(WritingModule)->getName()
1145 : StringRef(WritingModule->PresumedModuleMapFile),
1149 if (
auto *AdditionalModMaps =
1150 Map.getAdditionalModuleMapFiles(WritingModule)) {
1151 Record.push_back(AdditionalModMaps->size());
1152 for (
const FileEntry *F : *AdditionalModMaps)
1153 AddPath(F->getName(), Record);
1155 Record.push_back(0);
1168 if (!M.isDirectlyImported())
1171 Record.push_back((
unsigned)M.Kind);
1172 AddSourceLocation(M.ImportLoc, Record);
1176 Record.push_back(M.Signature ? 0 : M.File->getSize());
1177 Record.push_back(M.Signature ? 0 : getTimestampForOutput(M.File));
1179 for (
auto I : M.Signature)
1180 Record.push_back(I);
1182 AddString(M.ModuleName, Record);
1183 AddPath(M.FileName, Record);
1185 Stream.EmitRecord(
IMPORTS, Record);
1194 #define LANGOPT(Name, Bits, Default, Description) \ 1195 Record.push_back(LangOpts.Name); 1196 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 1197 Record.push_back(static_cast<unsigned>(LangOpts.get##Name())); 1198 #include "clang/Basic/LangOptions.def" 1199 #define SANITIZER(NAME, ID) \ 1200 Record.push_back(LangOpts.Sanitize.has(SanitizerKind::ID)); 1201 #include "clang/Basic/Sanitizers.def" 1205 AddString(Feature, Record);
1215 AddString(I, Record);
1222 AddString(T.getTriple(), Record);
1232 AddString(TargetOpts.
Triple, Record);
1233 AddString(TargetOpts.
CPU, Record);
1234 AddString(TargetOpts.
ABI, Record);
1239 Record.push_back(TargetOpts.
Features.size());
1240 for (
unsigned I = 0, N = TargetOpts.
Features.size(); I != N; ++I) {
1241 AddString(TargetOpts.
Features[I], Record);
1256 AddString(HSOpts.
Sysroot, Record);
1260 for (
unsigned I = 0, N = HSOpts.
UserEntries.size(); I != N; ++I) {
1262 AddString(Entry.
Path, Record);
1263 Record.push_back(static_cast<unsigned>(Entry.
Group));
1294 Record.push_back(PPOpts.
Macros.size());
1295 for (
unsigned I = 0, N = PPOpts.
Macros.size(); I != N; ++I) {
1296 AddString(PPOpts.
Macros[I].first, Record);
1297 Record.push_back(PPOpts.
Macros[I].second);
1301 Record.push_back(PPOpts.
Includes.size());
1302 for (
unsigned I = 0, N = PPOpts.
Includes.size(); I != N; ++I)
1303 AddString(PPOpts.
Includes[I], Record);
1307 for (
unsigned I = 0, N = PPOpts.
MacroIncludes.size(); I != N; ++I)
1323 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1325 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1326 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1327 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
1332 EmitRecordWithPath(FileAbbrevCode, Record, MainFile->getName());
1340 if (!OutputFile.empty() && OutputFile !=
"-") {
1341 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1343 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1344 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
1349 StringRef origDir = llvm::sys::path::parent_path(OutputPath);
1352 Stream.EmitRecordWithBlob(AbbrevCode, Record, origDir);
1355 WriteInputFiles(Context.SourceMgr,
1364 struct InputFileEntry {
1368 bool BufferOverridden;
1369 bool IsTopLevelModuleMap;
1370 uint32_t ContentHash[2];
1378 using namespace llvm;
1383 auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
1385 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1386 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12));
1387 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32));
1388 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1389 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1390 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1391 IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1392 unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
1395 auto IFHAbbrev = std::make_shared<BitCodeAbbrev>();
1397 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1398 IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1399 unsigned IFHAbbrevCode = Stream.EmitAbbrev(std::move(IFHAbbrev));
1403 std::deque<InputFileEntry> SortedFiles;
1407 assert(&SourceMgr.
getSLocEntry(FileID::get(I)) == SLoc);
1417 InputFileEntry Entry;
1425 auto ContentHash = hash_code(-1);
1431 ContentHash =
hash_value(MemBuff->getBuffer());
1435 << Entry.File->getName();
1438 Entry.ContentHash[0] =
1439 static_cast<uint32_t
>(CH.getLoBits(32).getZExtValue());
1440 Entry.ContentHash[1] =
1441 static_cast<uint32_t
>(CH.getHiBits(32).getZExtValue());
1443 if (Entry.IsSystemFile)
1444 SortedFiles.push_back(Entry);
1446 SortedFiles.push_front(Entry);
1449 unsigned UserFilesNum = 0;
1451 std::vector<uint64_t> InputFileOffsets;
1452 for (
const auto &Entry : SortedFiles) {
1453 uint32_t &InputFileID = InputFileIDs[Entry.File];
1454 if (InputFileID != 0)
1458 InputFileOffsets.push_back(Stream.GetCurrentBitNo());
1460 InputFileID = InputFileOffsets.size();
1462 if (!Entry.IsSystemFile)
1468 RecordData::value_type Record[] = {
1470 InputFileOffsets.size(),
1471 (uint64_t)Entry.File->getSize(),
1472 (uint64_t)getTimestampForOutput(Entry.File),
1473 Entry.BufferOverridden,
1475 Entry.IsTopLevelModuleMap};
1478 EmitRecordWithPath(IFAbbrevCode, Record, Entry.File->getName());
1483 RecordData::value_type Record[] = {
INPUT_FILE_HASH, Entry.ContentHash[0],
1484 Entry.ContentHash[1]};
1485 Stream.EmitRecordWithAbbrev(IFHAbbrevCode, Record);
1492 auto OffsetsAbbrev = std::make_shared<BitCodeAbbrev>();
1494 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1495 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1497 OffsetsAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1498 unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(std::move(OffsetsAbbrev));
1502 InputFileOffsets.size(), UserFilesNum};
1503 Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record,
bytes(InputFileOffsets));
1513 using namespace llvm;
1515 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1517 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1518 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1519 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1520 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1522 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1523 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1524 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24));
1525 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1526 return Stream.EmitAbbrev(std::move(Abbrev));
1532 using namespace llvm;
1534 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1536 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1537 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1538 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
1539 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1540 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1541 return Stream.EmitAbbrev(std::move(Abbrev));
1548 using namespace llvm;
1550 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1554 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1555 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1556 return Stream.EmitAbbrev(std::move(Abbrev));
1562 using namespace llvm;
1564 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1566 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1567 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1568 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1569 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1570 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1571 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1572 return Stream.EmitAbbrev(std::move(Abbrev));
1578 class HeaderFileInfoTrait {
1583 llvm::StringMap<unsigned> FrameworkNameOffset;
1586 HeaderFileInfoTrait(
ASTWriter &Writer) : Writer(Writer) {}
1593 using key_type_ref =
const key_type &;
1595 using UnresolvedModule =
1596 llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
1603 using data_type_ref =
const data_type &;
1605 using hash_value_type = unsigned;
1606 using offset_type = unsigned;
1615 std::pair<unsigned, unsigned>
1616 EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) {
1617 using namespace llvm::support;
1619 endian::Writer
LE(Out, little);
1620 unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
1621 LE.write<uint16_t>(KeyLen);
1622 unsigned DataLen = 1 + 2 + 4 + 4;
1623 for (
auto ModInfo : Data.KnownHeaders)
1626 if (Data.Unresolved.getPointer())
1628 LE.write<uint8_t>(DataLen);
1629 return std::make_pair(KeyLen, DataLen);
1632 void EmitKey(raw_ostream& Out, key_type_ref key,
unsigned KeyLen) {
1633 using namespace llvm::support;
1635 endian::Writer
LE(Out, little);
1636 LE.write<uint64_t>(key.Size);
1638 LE.write<uint64_t>(key.ModTime);
1640 Out.write(key.Filename.data(), KeyLen);
1643 void EmitData(raw_ostream &Out, key_type_ref key,
1644 data_type_ref Data,
unsigned DataLen) {
1645 using namespace llvm::support;
1647 endian::Writer
LE(Out, little);
1648 uint64_t Start = Out.tell(); (void)Start;
1650 unsigned char Flags = (Data.HFI.isImport << 5)
1651 | (Data.HFI.isPragmaOnce << 4)
1652 | (Data.HFI.DirInfo << 1)
1653 | Data.HFI.IndexHeaderMapHeader;
1654 LE.write<uint8_t>(Flags);
1655 LE.write<uint16_t>(Data.HFI.NumIncludes);
1657 if (!Data.HFI.ControllingMacro)
1658 LE.write<uint32_t>(Data.HFI.ControllingMacroID);
1663 if (!Data.HFI.Framework.empty()) {
1665 llvm::StringMap<unsigned>::iterator Pos
1666 = FrameworkNameOffset.find(Data.HFI.Framework);
1667 if (Pos == FrameworkNameOffset.end()) {
1668 Offset = FrameworkStringData.size() + 1;
1669 FrameworkStringData.append(Data.HFI.Framework.begin(),
1670 Data.HFI.Framework.end());
1671 FrameworkStringData.push_back(0);
1673 FrameworkNameOffset[Data.HFI.Framework] =
Offset;
1675 Offset = Pos->second;
1677 LE.write<uint32_t>(
Offset);
1681 uint32_t
Value = (ModID << 2) | (
unsigned)Role;
1682 assert((Value >> 2) == ModID &&
"overflow in header module info");
1683 LE.write<uint32_t>(
Value);
1689 for (
auto ModInfo : Data.KnownHeaders)
1690 EmitModule(ModInfo.getModule(), ModInfo.getRole());
1691 if (Data.Unresolved.getPointer())
1692 EmitModule(Data.Unresolved.getPointer(), Data.Unresolved.getInt());
1694 assert(Out.tell() - Start == DataLen &&
"Wrong data length");
1697 const char *strings_begin()
const {
return FrameworkStringData.begin(); }
1698 const char *strings_end()
const {
return FrameworkStringData.end(); }
1706 void ASTWriter::WriteHeaderSearch(
const HeaderSearch &HS) {
1707 HeaderFileInfoTrait GeneratorTrait(*
this);
1708 llvm::OnDiskChainedHashTableGenerator<HeaderFileInfoTrait> Generator;
1710 unsigned NumHeaderSearchEntries = 0;
1717 if (WritingModule) {
1719 while (!Worklist.empty()) {
1720 Module *M = Worklist.pop_back_val();
1736 if (!U.Size || (!U.ModTime && IncludeTimestamps)) {
1737 PP->
Diag(U.FileNameLoc, diag::err_module_no_size_mtime_for_header)
1738 << WritingModule->getFullModuleName() << U.Size.hasValue()
1745 llvm::sys::path::append(
Filename, U.FileName);
1748 StringRef FilenameDup = strdup(
Filename.c_str());
1749 SavedStrings.push_back(FilenameDup.data());
1751 HeaderFileInfoTrait::key_type Key = {
1752 FilenameDup, *U.Size, IncludeTimestamps ? *U.ModTime : 0
1754 HeaderFileInfoTrait::data_type Data = {
1759 Generator.insert(Key, Data, GeneratorTrait);
1760 ++NumHeaderSearchEntries;
1773 for (
unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
1774 const FileEntry *File = FilesByUID[UID];
1792 if (PreparePathForOutput(FilenameTmp)) {
1795 Filename = StringRef(strdup(FilenameTmp.c_str()));
1796 SavedStrings.push_back(Filename.data());
1799 HeaderFileInfoTrait::key_type Key = {
1802 HeaderFileInfoTrait::data_type Data = {
1805 Generator.insert(Key, Data, GeneratorTrait);
1806 ++NumHeaderSearchEntries;
1811 uint32_t BucketOffset;
1813 using namespace llvm::support;
1815 llvm::raw_svector_ostream Out(TableData);
1817 endian::write<uint32_t>(Out, 0, little);
1818 BucketOffset = Generator.Emit(Out, GeneratorTrait);
1822 using namespace llvm;
1824 auto Abbrev = std::make_shared<BitCodeAbbrev>();
1826 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1827 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1828 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1829 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1830 unsigned TableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
1834 NumHeaderSearchEntries, TableData.size()};
1835 TableData.append(GeneratorTrait.strings_begin(),GeneratorTrait.strings_end());
1836 Stream.EmitRecordWithBlob(TableAbbrev, Record, TableData);
1839 for (
unsigned I = 0, N = SavedStrings.size(); I != N; ++I)
1840 free(const_cast<char *>(SavedStrings[I]));
1843 static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
1844 unsigned SLocBufferBlobCompressedAbbrv,
1845 unsigned SLocBufferBlobAbbrv) {
1846 using RecordDataType = ASTWriter::RecordData::value_type;
1851 if (llvm::zlib::isAvailable()) {
1852 llvm::Error E = llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer);
1856 Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record,
1860 llvm::consumeError(std::move(E));
1864 Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob);
1875 void ASTWriter::WriteSourceManagerBlock(
SourceManager &SourceMgr,
1886 unsigned SLocBufferBlobCompressedAbbrv =
1892 std::vector<uint32_t> SLocEntryOffsets;
1893 RecordData PreloadSLocs;
1899 FileID FID = FileID::get(I);
1903 SLocEntryOffsets.push_back(Stream.GetCurrentBitNo());
1916 Record.push_back(Code);
1919 Record.push_back(SLoc->
getOffset() - 2);
1927 bool EmitBlob =
false;
1930 "Writing to AST an overridden file is not supported");
1933 assert(InputFileIDs[Content->
OrigEntry] != 0 &&
"Missed file entry");
1934 Record.push_back(InputFileIDs[Content->
OrigEntry]);
1936 Record.push_back(File.NumCreatedFIDs);
1938 FileDeclIDsTy::iterator FDI = FileDeclIDs.find(FID);
1939 if (FDI != FileDeclIDs.end()) {
1940 Record.push_back(FDI->second->FirstDeclIndex);
1941 Record.push_back(FDI->second->DeclIDs.size());
1943 Record.push_back(0);
1944 Record.push_back(0);
1947 Stream.EmitRecordWithAbbrev(SLocFileAbbrv, Record);
1958 const llvm::MemoryBuffer *Buffer =
1960 StringRef Name = Buffer->getBufferIdentifier();
1961 Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
1962 StringRef(Name.data(), Name.size() + 1));
1965 if (Name ==
"<built-in>")
1966 PreloadSLocs.push_back(SLocEntryOffsets.size());
1972 const llvm::MemoryBuffer *Buffer =
1974 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
1975 emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv,
1976 SLocBufferBlobAbbrv);
1993 Record.push_back(NextOffset - SLoc->
getOffset() - 1);
1994 Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv, Record);
2000 if (SLocEntryOffsets.empty())
2005 using namespace llvm;
2007 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2009 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2010 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16));
2011 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2012 unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2014 RecordData::value_type Record[] = {
2017 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
2018 bytes(SLocEntryOffsets));
2032 llvm::DenseMap<int, int> FilenameMap;
2033 FilenameMap[-1] = -1;
2034 for (
const auto &L : LineTable) {
2037 for (
auto &
LE : L.second) {
2038 if (FilenameMap.insert(std::make_pair(
LE.FilenameID,
2039 FilenameMap.size() - 1)).second)
2040 AddPath(LineTable.getFilename(
LE.FilenameID), Record);
2043 Record.push_back(0);
2046 for (
const auto &L : LineTable) {
2052 Record.push_back(L.first.ID);
2055 Record.push_back(L.second.size());
2056 for (
const auto &
LE : L.second) {
2057 Record.push_back(
LE.FileOffset);
2058 Record.push_back(
LE.LineNo);
2059 Record.push_back(FilenameMap[
LE.FilenameID]);
2060 Record.push_back((
unsigned)
LE.FileKind);
2061 Record.push_back(
LE.IncludeOffset);
2076 if (MI->isBuiltinMacro())
2092 void ASTWriter::WritePreprocessor(
const Preprocessor &PP,
bool IsModule) {
2095 WritePreprocessorDetail(*PPRec);
2098 RecordData ModuleMacroRecord;
2109 if (SkipInfo.hasValue()) {
2110 Record.push_back(
true);
2111 AddSourceLocation(SkipInfo->HashTokenLoc, Record);
2112 AddSourceLocation(SkipInfo->IfTokenLoc, Record);
2113 Record.push_back(SkipInfo->FoundNonSkipPortion);
2114 Record.push_back(SkipInfo->FoundElse);
2115 AddSourceLocation(SkipInfo->ElseLoc, Record);
2117 Record.push_back(
false);
2120 AddSourceLocation(Cond.IfLoc, Record);
2121 Record.push_back(Cond.WasSkipping);
2122 Record.push_back(Cond.FoundNonSkip);
2123 Record.push_back(Cond.FoundElse);
2144 if (
Id.second->hadMacroDefinition() &&
2145 (!
Id.second->isFromAST() ||
2146 Id.second->hasChangedSinceDeserialization()))
2147 MacroIdentifiers.push_back(
Id.second);
2150 llvm::sort(MacroIdentifiers,
llvm::deref<std::less<>>());
2156 auto StartOffset = Stream.GetCurrentBitNo();
2166 Record.push_back(MD->
getKind());
2167 if (
auto *DefMD = dyn_cast<DefMacroDirective>(MD)) {
2168 Record.push_back(getMacroRef(DefMD->getInfo(), Name));
2169 }
else if (
auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
2170 Record.push_back(VisMD->isPublic());
2175 bool EmittedModuleMacros =
false;
2179 llvm::DenseMap<ModuleMacro*, unsigned> Visits;
2180 while (!Worklist.empty()) {
2181 auto *Macro = Worklist.pop_back_val();
2184 ModuleMacroRecord.push_back(
2185 getSubmoduleID(Macro->getOwningModule()));
2186 ModuleMacroRecord.push_back(getMacroRef(Macro->getMacroInfo(), Name));
2187 for (
auto *M : Macro->overrides())
2188 ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
2191 ModuleMacroRecord.clear();
2194 for (
auto *M : Macro->overrides())
2195 if (++Visits[M] == M->getNumOverridingMacros())
2196 Worklist.push_back(M);
2198 EmittedModuleMacros =
true;
2201 if (Record.empty() && !EmittedModuleMacros)
2204 IdentMacroDirectivesOffsetMap[Name] = StartOffset;
2215 std::vector<uint32_t> MacroOffsets;
2217 for (
unsigned I = 0, N = MacroInfosToEmit.size(); I != N; ++I) {
2222 if (ID < FirstMacroID) {
2223 assert(0 &&
"Loaded MacroInfo entered MacroInfosToEmit ?");
2228 unsigned Index = ID - FirstMacroID;
2229 if (Index == MacroOffsets.size())
2230 MacroOffsets.push_back(Stream.GetCurrentBitNo());
2232 if (Index > MacroOffsets.size())
2233 MacroOffsets.resize(Index + 1);
2235 MacroOffsets[Index] = Stream.GetCurrentBitNo();
2238 AddIdentifierRef(Name, Record);
2241 Record.push_back(MI->
isUsed());
2254 AddIdentifierRef(Param, Record);
2262 Stream.EmitRecord(Code, Record);
2266 for (
unsigned TokNo = 0, e = MI->
getNumTokens(); TokNo != e; ++TokNo) {
2271 AddToken(Tok, Record);
2272 Stream.EmitRecord(
PP_TOKEN, Record);
2281 using namespace llvm;
2283 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2285 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2286 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2287 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2289 unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2291 RecordData::value_type Record[] = {
MACRO_OFFSET, MacroOffsets.size(),
2293 Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record,
bytes(MacroOffsets));
2307 unsigned NumPreprocessingRecords = 0;
2308 using namespace llvm;
2311 unsigned InclusionAbbrev = 0;
2313 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2315 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2316 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2317 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2318 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2319 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2320 InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2323 unsigned FirstPreprocessorEntityID
2324 = (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0)
2326 unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
2331 (void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2334 PreprocessedEntityOffsets.push_back(
2335 PPEntityOffset((*E)->getSourceRange(), Stream.GetCurrentBitNo()));
2337 if (
auto *MD = dyn_cast<MacroDefinitionRecord>(*E)) {
2339 MacroDefinitions[MD] = NextPreprocessorEntityID;
2341 AddIdentifierRef(MD->getName(), Record);
2346 if (
auto *ME = dyn_cast<MacroExpansion>(*E)) {
2347 Record.push_back(ME->isBuiltinMacro());
2348 if (ME->isBuiltinMacro())
2349 AddIdentifierRef(ME->getName(), Record);
2351 Record.push_back(MacroDefinitions[ME->getDefinition()]);
2356 if (
auto *
ID = dyn_cast<InclusionDirective>(*E)) {
2358 Record.push_back(
ID->getFileName().size());
2359 Record.push_back(
ID->wasInQuotes());
2360 Record.push_back(static_cast<unsigned>(
ID->getKind()));
2361 Record.push_back(
ID->importedModule());
2363 Buffer +=
ID->getFileName();
2367 Buffer +=
ID->getFile()->getName();
2368 Stream.EmitRecordWithBlob(InclusionAbbrev, Record, Buffer);
2372 llvm_unreachable(
"Unhandled PreprocessedEntity in ASTWriter");
2377 if (NumPreprocessingRecords > 0) {
2378 assert(PreprocessedEntityOffsets.size() == NumPreprocessingRecords);
2381 using namespace llvm;
2383 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2385 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2386 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2387 unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2390 FirstPreprocessorEntityID -
2392 Stream.EmitRecordWithBlob(PPEOffsetAbbrev, Record,
2393 bytes(PreprocessedEntityOffsets));
2398 if (SkippedRanges.size() > 0) {
2399 std::vector<PPSkippedRange> SerializedSkippedRanges;
2400 SerializedSkippedRanges.reserve(SkippedRanges.size());
2401 for (
auto const& Range : SkippedRanges)
2402 SerializedSkippedRanges.emplace_back(Range);
2404 using namespace llvm;
2405 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2407 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2408 unsigned PPESkippedRangeAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2412 Stream.EmitRecordWithBlob(PPESkippedRangeAbbrev, Record,
2413 bytes(SerializedSkippedRanges));
2421 llvm::DenseMap<Module *, unsigned>::iterator Known = SubmoduleIDs.find(Mod);
2422 if (Known != SubmoduleIDs.end())
2423 return Known->second;
2426 if (Top != WritingModule &&
2427 (getLangOpts().CompilingPCH ||
2428 !Top->fullModuleNameIs(StringRef(getLangOpts().CurrentModule))))
2431 return SubmoduleIDs[Mod] = NextSubmoduleID++;
2434 unsigned ASTWriter::getSubmoduleID(
Module *Mod) {
2438 unsigned ID = getLocalOrImportedSubmoduleID(Mod);
2439 assert((ID || !Mod) &&
2440 "asked for module ID for non-local, non-imported module");
2447 unsigned ChildModules = 0;
2452 return ChildModules + 1;
2455 void ASTWriter::WriteSubmodules(
Module *WritingModule) {
2460 using namespace llvm;
2462 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2464 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2465 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2466 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
2467 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2468 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2469 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2470 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2471 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2472 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2473 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2474 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2475 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2476 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2477 unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2479 Abbrev = std::make_shared<BitCodeAbbrev>();
2481 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2482 unsigned UmbrellaAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2484 Abbrev = std::make_shared<BitCodeAbbrev>();
2486 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2487 unsigned HeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2489 Abbrev = std::make_shared<BitCodeAbbrev>();
2491 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2492 unsigned TopHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2494 Abbrev = std::make_shared<BitCodeAbbrev>();
2496 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2497 unsigned UmbrellaDirAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2499 Abbrev = std::make_shared<BitCodeAbbrev>();
2501 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2502 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2503 unsigned RequiresAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2505 Abbrev = std::make_shared<BitCodeAbbrev>();
2507 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2508 unsigned ExcludedHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2510 Abbrev = std::make_shared<BitCodeAbbrev>();
2512 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2513 unsigned TextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2515 Abbrev = std::make_shared<BitCodeAbbrev>();
2517 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2518 unsigned PrivateHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2520 Abbrev = std::make_shared<BitCodeAbbrev>();
2522 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2523 unsigned PrivateTextualHeaderAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2525 Abbrev = std::make_shared<BitCodeAbbrev>();
2527 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2528 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2529 unsigned LinkLibraryAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2531 Abbrev = std::make_shared<BitCodeAbbrev>();
2533 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2534 unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2536 Abbrev = std::make_shared<BitCodeAbbrev>();
2538 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2539 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2540 unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2542 Abbrev = std::make_shared<BitCodeAbbrev>();
2544 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2545 unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2548 RecordData::value_type Record[] = {
2554 std::queue<Module *> Q;
2555 Q.push(WritingModule);
2556 while (!Q.empty()) {
2559 unsigned ID = getSubmoduleID(Mod);
2561 uint64_t ParentID = 0;
2563 assert(SubmoduleIDs[Mod->
Parent] &&
"Submodule parent not written?");
2564 ParentID = SubmoduleIDs[Mod->
Parent];
2572 (RecordData::value_type)Mod->
Kind,
2582 Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->
Name);
2588 Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
2594 Stream.EmitRecordWithBlob(UmbrellaAbbrev, Record,
2595 UmbrellaHeader.NameAsWritten);
2598 Stream.EmitRecordWithBlob(UmbrellaDirAbbrev, Record,
2599 UmbrellaDir.NameAsWritten);
2604 unsigned RecordKind;
2615 for (
auto &HL : HeaderLists) {
2616 RecordData::value_type Record[] = {HL.RecordKind};
2617 for (
auto &H : Mod->
Headers[HL.HeaderKind])
2618 Stream.EmitRecordWithBlob(HL.Abbrev, Record, H.NameAsWritten);
2625 for (
auto *H : TopHeaders)
2626 Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, H->getName());
2633 Record.push_back(getSubmoduleID(I));
2640 for (
const auto &E : Mod->
Exports) {
2643 Record.push_back(getSubmoduleID(E.getPointer()));
2644 Record.push_back(E.getInt());
2657 Stream.EmitRecordWithBlob(LinkLibraryAbbrev, Record, LL.Library);
2665 getSubmoduleID(C.Other)};
2666 Stream.EmitRecordWithBlob(ConflictAbbrev, Record, C.Message);
2672 Stream.EmitRecordWithBlob(ConfigMacroAbbrev, Record, CM);
2678 Inits.push_back(GetDeclRef(D));
2685 Stream.EmitRecordWithBlob(ExportAsAbbrev, Record, Mod->
ExportAsModule);
2695 assert((NextSubmoduleID - FirstSubmoduleID ==
2697 "Wrong # of submodules; found a reference to a non-local, " 2698 "non-imported submodule?");
2703 llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
2705 unsigned CurrID = 0;
2708 auto EncodeDiagStateFlags =
2709 [](
const DiagnosticsEngine::DiagState *DS) ->
unsigned {
2710 unsigned Result = (unsigned)DS->ExtBehavior;
2712 {(unsigned)DS->IgnoreAllWarnings, (
unsigned)DS->EnableAllWarnings,
2713 (unsigned)DS->WarningsAsErrors, (
unsigned)DS->ErrorsAsFatal,
2714 (unsigned)DS->SuppressSystemWarnings})
2715 Result = (Result << 1) | Val;
2719 unsigned Flags = EncodeDiagStateFlags(Diag.DiagStatesByLoc.FirstDiagState);
2720 Record.push_back(Flags);
2722 auto AddDiagState = [&](
const DiagnosticsEngine::DiagState *
State,
2723 bool IncludeNonPragmaStates) {
2726 assert(Flags == EncodeDiagStateFlags(State) &&
2727 "diag state flags vary in single AST file");
2729 unsigned &DiagStateID = DiagStateIDMap[
State];
2730 Record.push_back(DiagStateID);
2732 if (DiagStateID == 0) {
2733 DiagStateID = ++CurrID;
2736 auto SizeIdx = Record.size();
2737 Record.emplace_back();
2738 for (
const auto &I : *State) {
2739 if (I.second.isPragma() || IncludeNonPragmaStates) {
2740 Record.push_back(I.first);
2741 Record.push_back(I.second.serialize());
2745 Record[SizeIdx] = (Record.size() - SizeIdx) / 2;
2749 AddDiagState(Diag.DiagStatesByLoc.FirstDiagState, isModule);
2752 auto NumLocationsIdx = Record.size();
2753 Record.emplace_back();
2756 unsigned NumLocations = 0;
2757 for (
auto &FileIDAndFile : Diag.DiagStatesByLoc.Files) {
2758 if (!FileIDAndFile.first.isValid() ||
2759 !FileIDAndFile.second.HasLocalTransitions)
2764 assert(!Loc.
isInvalid() &&
"start loc for valid FileID is invalid");
2765 AddSourceLocation(Loc, Record);
2767 Record.push_back(FileIDAndFile.second.StateTransitions.size());
2768 for (
auto &StatePoint : FileIDAndFile.second.StateTransitions) {
2769 Record.push_back(StatePoint.Offset);
2770 AddDiagState(StatePoint.State,
false);
2775 Record[NumLocationsIdx] = NumLocations;
2783 AddSourceLocation(Diag.DiagStatesByLoc.CurDiagStateLoc, Record);
2784 AddDiagState(Diag.DiagStatesByLoc.CurDiagState,
false);
2794 void ASTWriter::WriteType(
QualType T) {
2795 TypeIdx &IdxRef = TypeIdxs[T];
2797 IdxRef =
TypeIdx(NextTypeID++);
2800 assert(Idx.
getIndex() >= FirstTypeID &&
"Re-writing a type from a prior AST");
2803 uint64_t
Offset = ASTTypeWriter(*this).write(T);
2806 unsigned Index = Idx.
getIndex() - FirstTypeID;
2807 if (TypeOffsets.size() == Index)
2808 TypeOffsets.push_back(Offset);
2809 else if (TypeOffsets.size() < Index) {
2810 TypeOffsets.resize(Index + 1);
2811 TypeOffsets[Index] =
Offset;
2813 llvm_unreachable(
"Types emitted in wrong order");
2826 uint64_t ASTWriter::WriteDeclContextLexicalBlock(
ASTContext &Context,
2831 uint64_t
Offset = Stream.GetCurrentBitNo();
2833 for (
const auto *D : DC->
decls()) {
2834 KindDeclPairs.push_back(D->getKind());
2835 KindDeclPairs.push_back(GetDeclRef(D));
2838 ++NumLexicalDeclContexts;
2840 Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record,
2841 bytes(KindDeclPairs));
2845 void ASTWriter::WriteTypeDeclOffsets() {
2846 using namespace llvm;
2849 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2851 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2852 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2853 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2854 unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2856 RecordData::value_type Record[] = {
TYPE_OFFSET, TypeOffsets.size(),
2858 Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record,
bytes(TypeOffsets));
2862 Abbrev = std::make_shared<BitCodeAbbrev>();
2864 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2865 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2866 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2867 unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
2869 RecordData::value_type Record[] = {
DECL_OFFSET, DeclOffsets.size(),
2871 Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record,
bytes(DeclOffsets));
2875 void ASTWriter::WriteFileDeclIDsMap() {
2876 using namespace llvm;
2879 FileDeclIDs.begin(), FileDeclIDs.end());
2880 llvm::sort(SortedFileDeclIDs, llvm::less_first());
2884 for (
auto &FileDeclEntry : SortedFileDeclIDs) {
2885 DeclIDInFileInfo &Info = *FileDeclEntry.second;
2886 Info.FirstDeclIndex = FileGroupedDeclIDs.size();
2887 for (
auto &LocDeclEntry : Info.DeclIDs)
2888 FileGroupedDeclIDs.push_back(LocDeclEntry.second);
2891 auto Abbrev = std::make_shared<BitCodeAbbrev>();
2893 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
2894 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2895 unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
2897 FileGroupedDeclIDs.size()};
2898 Stream.EmitRecordWithBlob(AbbrevCode, Record,
bytes(FileGroupedDeclIDs));
2901 void ASTWriter::WriteComments() {
2903 auto _ = llvm::make_scope_exit([
this] { Stream.ExitBlock(); });
2907 for (
const auto &FO : Context->
Comments.OrderedComments) {
2908 for (
const auto &OC : FO.second) {
2912 Record.push_back(I->
getKind());
2927 class ASTMethodPoolTrait {
2932 using key_type_ref = key_type;
2938 using data_type_ref =
const data_type &;
2940 using hash_value_type = unsigned;
2941 using offset_type = unsigned;
2943 explicit ASTMethodPoolTrait(
ASTWriter &Writer) : Writer(Writer) {}
2949 std::pair<unsigned, unsigned>
2950 EmitKeyDataLength(raw_ostream& Out,
Selector Sel,
2951 data_type_ref Methods) {
2952 using namespace llvm::support;
2954 endian::Writer
LE(Out, little);
2956 LE.write<uint16_t>(KeyLen);
2957 unsigned DataLen = 4 + 2 + 2;
2960 if (Method->getMethod())
2964 if (Method->getMethod())
2966 LE.write<uint16_t>(DataLen);
2967 return std::make_pair(KeyLen, DataLen);
2970 void EmitKey(raw_ostream& Out,
Selector Sel,
unsigned) {
2971 using namespace llvm::support;
2973 endian::Writer
LE(Out, little);
2974 uint64_t Start = Out.tell();
2975 assert((Start >> 32) == 0 &&
"Selector key offset too large");
2978 LE.write<uint16_t>(N);
2981 for (
unsigned I = 0; I != N; ++I)
2986 void EmitData(raw_ostream& Out, key_type_ref,
2987 data_type_ref Methods,
unsigned DataLen) {
2988 using namespace llvm::support;
2990 endian::Writer
LE(Out, little);
2991 uint64_t Start = Out.tell(); (void)Start;
2992 LE.write<uint32_t>(Methods.ID);
2993 unsigned NumInstanceMethods = 0;
2996 if (Method->getMethod())
2997 ++NumInstanceMethods;
2999 unsigned NumFactoryMethods = 0;
3002 if (Method->getMethod())
3003 ++NumFactoryMethods;
3005 unsigned InstanceBits = Methods.Instance.getBits();
3006 assert(InstanceBits < 4);
3007 unsigned InstanceHasMoreThanOneDeclBit =
3008 Methods.Instance.hasMoreThanOneDecl();
3009 unsigned FullInstanceBits = (NumInstanceMethods << 3) |
3010 (InstanceHasMoreThanOneDeclBit << 2) |
3012 unsigned FactoryBits = Methods.Factory.getBits();
3013 assert(FactoryBits < 4);
3014 unsigned FactoryHasMoreThanOneDeclBit =
3015 Methods.Factory.hasMoreThanOneDecl();
3016 unsigned FullFactoryBits = (NumFactoryMethods << 3) |
3017 (FactoryHasMoreThanOneDeclBit << 2) |
3019 LE.write<uint16_t>(FullInstanceBits);
3020 LE.write<uint16_t>(FullFactoryBits);
3023 if (Method->getMethod())
3024 LE.write<uint32_t>(Writer.
getDeclID(Method->getMethod()));
3027 if (Method->getMethod())
3028 LE.write<uint32_t>(Writer.
getDeclID(Method->getMethod()));
3030 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3041 void ASTWriter::WriteSelectors(
Sema &SemaRef) {
3042 using namespace llvm;
3045 if (SemaRef.
MethodPool.empty() && SelectorIDs.empty())
3047 unsigned NumTableEntries = 0;
3050 llvm::OnDiskChainedHashTableGenerator<ASTMethodPoolTrait> Generator;
3051 ASTMethodPoolTrait Trait(*
this);
3055 SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
3056 for (
auto &SelectorAndID : SelectorIDs) {
3059 Sema::GlobalMethodPool::iterator F = SemaRef.
MethodPool.find(S);
3060 ASTMethodPoolTrait::data_type Data = {
3066 Data.Instance = F->second.first;
3067 Data.Factory = F->second.second;
3071 if (Chain && ID < FirstSelectorID) {
3073 bool changed =
false;
3075 !changed && M && M->
getMethod(); M = M->getNext()) {
3076 if (!M->getMethod()->isFromASTFile())
3081 if (!M->getMethod()->isFromASTFile())
3086 }
else if (Data.Instance.getMethod() || Data.Factory.getMethod()) {
3090 Generator.insert(S, Data, Trait);
3095 uint32_t BucketOffset;
3097 using namespace llvm::support;
3099 ASTMethodPoolTrait Trait(*
this);
3100 llvm::raw_svector_ostream Out(MethodPool);
3102 endian::write<uint32_t>(Out, 0, little);
3103 BucketOffset = Generator.Emit(Out, Trait);
3107 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3109 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3110 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3111 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3112 unsigned MethodPoolAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3116 RecordData::value_type Record[] = {
METHOD_POOL, BucketOffset,
3118 Stream.EmitRecordWithBlob(MethodPoolAbbrev, Record, MethodPool);
3122 Abbrev = std::make_shared<BitCodeAbbrev>();
3124 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3125 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3126 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3127 unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3131 RecordData::value_type Record[] = {
3134 Stream.EmitRecordWithBlob(SelectorOffsetAbbrev, Record,
3135 bytes(SelectorOffsets));
3141 void ASTWriter::WriteReferencedSelectorsPool(
Sema &SemaRef) {
3142 using namespace llvm;
3154 Selector Sel = SelectorAndLocation.first;
3178 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
3180 if (!Redecl->isFromASTFile()) {
3184 if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
3187 return cast<NamedDecl>(Redecl);
3192 if (Redecl->getOwningModuleID() == 0)
3197 if (!
First->isFromASTFile())
3198 return cast<NamedDecl>(
First);
3208 class ASTIdentifierTableTrait {
3233 using key_type_ref = key_type;
3236 using data_type_ref = data_type;
3238 using hash_value_type = unsigned;
3239 using offset_type = unsigned;
3244 : Writer(Writer), PP(PP), IdResolver(IdResolver), IsModule(IsModule),
3245 NeedDecls(!IsModule || !Writer.
getLangOpts().CPlusPlus),
3246 InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
3248 bool needDecls()
const {
return NeedDecls; }
3251 return llvm::djbHash(II->
getName());
3263 std::pair<unsigned, unsigned>
3266 unsigned DataLen = 4;
3276 DEnd = IdResolver.
end();
3282 using namespace llvm::support;
3284 endian::Writer
LE(Out, little);
3286 assert((uint16_t)DataLen == DataLen && (uint16_t)KeyLen == KeyLen);
3287 LE.write<uint16_t>(DataLen);
3291 LE.write<uint16_t>(KeyLen);
3292 return std::make_pair(KeyLen, DataLen);
3304 InterestingIdentifierOffsets->push_back(Out.tell() - 4);
3311 using namespace llvm::support;
3313 endian::Writer
LE(Out, little);
3317 LE.write<uint32_t>(ID << 1);
3321 LE.write<uint32_t>((ID << 1) | 0x01);
3323 assert((Bits & 0xffff) == Bits &&
"ObjCOrBuiltinID too big for ASTReader.");
3324 LE.write<uint16_t>(Bits);
3326 bool HadMacroDefinition = MacroOffset != 0;
3327 Bits = (Bits << 1) |
unsigned(HadMacroDefinition);
3329 Bits = (Bits << 1) |
unsigned(II->
isPoisoned());
3333 LE.write<uint16_t>(Bits);
3335 if (HadMacroDefinition)
3336 LE.write<uint32_t>(MacroOffset);
3347 for (SmallVectorImpl<NamedDecl *>::reverse_iterator D = Decls.rbegin(),
3348 DEnd = Decls.rend();
3366 using namespace llvm;
3368 RecordData InterestingIdents;
3373 llvm::OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait> Generator;
3374 ASTIdentifierTableTrait Trait(
3375 *
this, PP, IdResolver, IsModule,
3376 (getLangOpts().
CPlusPlus && IsModule) ? &InterestingIdents :
nullptr);
3385 IIs.push_back(
ID.second);
3390 if (Trait.isInterestingNonMacroIdentifier(II))
3391 getIdentifierRef(II);
3395 IdentifierOffsets.resize(NextIdentID - FirstIdentID);
3396 for (
auto IdentIDPair : IdentifierIDs) {
3399 assert(II &&
"NULL identifier in identifier table");
3402 if (ID >= FirstIdentID || !Chain || !II->isFromAST()
3403 || II->hasChangedSinceDeserialization() ||
3404 (Trait.needDecls() &&
3405 II->hasFETokenInfoChangedSinceDeserialization()))
3406 Generator.insert(II, ID, Trait);
3411 uint32_t BucketOffset;
3413 using namespace llvm::support;
3415 llvm::raw_svector_ostream Out(IdentifierTable);
3417 endian::write<uint32_t>(Out, 0, little);
3418 BucketOffset = Generator.Emit(Out, Trait);
3422 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3424 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3425 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3426 unsigned IDTableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3430 Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable);
3434 auto Abbrev = std::make_shared<BitCodeAbbrev>();
3436 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3437 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
3438 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3439 unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
3442 for (
unsigned I = 0, N = IdentifierOffsets.size(); I != N; ++I)
3443 assert(IdentifierOffsets[I] &&
"Missing identifier offset?");
3447 IdentifierOffsets.size(),
3449 Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev, Record,
3450 bytes(IdentifierOffsets));
3454 if (!InterestingIdents.empty())
3465 class ASTDeclContextNameLookupTrait {
3471 using key_type_ref = key_type;
3474 using data_type = std::pair<unsigned, unsigned>;
3475 using data_type_ref =
const data_type &;
3477 using hash_value_type = unsigned;
3478 using offset_type = unsigned;
3480 explicit ASTDeclContextNameLookupTrait(
ASTWriter &Writer) : Writer(Writer) {}
3482 template<
typename Coll>
3483 data_type getData(
const Coll &Decls) {
3484 unsigned Start = DeclIDs.size();
3489 return std::make_pair(Start, DeclIDs.size());
3493 unsigned Start = DeclIDs.size();
3494 for (
auto ID : FromReader)
3495 DeclIDs.push_back(
ID);
3496 return std::make_pair(Start, DeclIDs.size());
3499 static bool EqualKey(key_type_ref a, key_type_ref b) {
3507 void EmitFileRef(raw_ostream &Out,
ModuleFile *F)
const {
3509 "have reference to loaded module file but no chain?");
3511 using namespace llvm::support;
3516 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
3518 data_type_ref Lookup) {
3519 using namespace llvm::support;
3521 endian::Writer
LE(Out, little);
3522 unsigned KeyLen = 1;
3541 LE.write<uint16_t>(KeyLen);
3544 unsigned DataLen = 4 * (Lookup.second - Lookup.first);
3545 assert(uint16_t(DataLen) == DataLen &&
3546 "too many decls for serialized lookup result");
3547 LE.write<uint16_t>(DataLen);
3549 return std::make_pair(KeyLen, DataLen);
3553 using namespace llvm::support;
3555 endian::Writer
LE(Out, little);
3556 LE.write<uint8_t>(Name.
getKind());
3570 "Invalid operator?");
3580 llvm_unreachable(
"Invalid name kind?");
3583 void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
3585 using namespace llvm::support;
3587 endian::Writer
LE(Out, little);
3588 uint64_t Start = Out.tell(); (void)Start;
3589 for (
unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
3590 LE.write<uint32_t>(DeclIDs[I]);
3591 assert(Out.tell() - Start == DataLen &&
"Data length is wrong");
3600 DC->hasNeedToReconcileExternalVisibleStorage();
3603 bool ASTWriter::isLookupResultEntirelyExternal(
StoredDeclsList &Result,
3613 ASTWriter::GenerateNameLookupTable(
const DeclContext *ConstDC,
3615 assert(!ConstDC->hasLazyLocalLexicalLookups() &&
3616 !ConstDC->hasLazyExternalLexicalLookups() &&
3617 "must call buildLookups first");
3621 assert(DC == DC->getPrimaryContext() &&
"only primary DC has lookup table");
3625 ASTDeclContextNameLookupTrait> Generator;
3626 ASTDeclContextNameLookupTrait Trait(*
this);
3635 llvm::SmallSet<DeclarationName, 8> ConstructorNameSet, ConversionNameSet;
3637 for (
auto &Lookup : *DC->buildLookup()) {
3638 auto &Name = Lookup.first;
3639 auto &Result = Lookup.second;
3645 if (isLookupResultExternal(Result, DC) &&
3646 isLookupResultEntirelyExternal(Result, DC))
3663 if (Lookup.second.getLookupResult().empty())
3666 switch (Lookup.first.getNameKind()) {
3668 Names.push_back(Lookup.first);
3672 assert(isa<CXXRecordDecl>(DC) &&
3673 "Cannot have a constructor name outside of a class!");
3674 ConstructorNameSet.insert(Name);
3678 assert(isa<CXXRecordDecl>(DC) &&
3679 "Cannot have a conversion function name outside of a class!");
3680 ConversionNameSet.insert(Name);
3688 if (
auto *D = dyn_cast<CXXRecordDecl>(DC)) {
3702 if (ConstructorNameSet.erase(ImplicitCtorName))
3703 Names.push_back(ImplicitCtorName);
3708 if (!ConstructorNameSet.empty() || !ConversionNameSet.empty())
3709 for (
Decl *ChildD : cast<CXXRecordDecl>(DC)->decls())
3710 if (
auto *ChildND = dyn_cast<NamedDecl>(ChildD)) {
3711 auto Name = ChildND->getDeclName();
3712 switch (Name.getNameKind()) {
3717 if (ConstructorNameSet.erase(Name))
3718 Names.push_back(Name);
3722 if (ConversionNameSet.erase(Name))
3723 Names.push_back(Name);
3727 if (ConstructorNameSet.empty() && ConversionNameSet.empty())
3731 assert(ConstructorNameSet.empty() &&
"Failed to find all of the visible " 3732 "constructors by walking all the " 3733 "lexical members of the context.");
3734 assert(ConversionNameSet.empty() &&
"Failed to find all of the visible " 3735 "conversion functions by walking all " 3736 "the lexical members of the context.");
3743 for (
auto &Name : Names)
3755 for (
auto &Name : Names) {
3758 switch (Name.getNameKind()) {
3760 Generator.insert(Name, Trait.getData(Result), Trait);
3764 ConstructorDecls.append(Result.
begin(), Result.
end());
3768 ConversionDecls.append(Result.
begin(), Result.
end());
3776 if (!ConstructorDecls.empty())
3777 Generator.insert(ConstructorDecls.front()->getDeclName(),
3778 Trait.getData(ConstructorDecls), Trait);
3779 if (!ConversionDecls.empty())
3780 Generator.insert(ConversionDecls.front()->getDeclName(),
3781 Trait.getData(ConversionDecls), Trait);
3785 auto *Lookups = Chain ? Chain->getLoadedLookupTables(DC) :
nullptr;
3786 Generator.emit(LookupTable, Trait, Lookups ? &Lookups->Table :
nullptr);
3794 uint64_t ASTWriter::WriteDeclContextVisibleBlock(
ASTContext &Context,
3799 if (isa<NamespaceDecl>(DC) && Chain &&
3800 Chain->getKeyDeclaration(cast<Decl>(DC))->isFromASTFile()) {
3802 for (
auto *Prev = cast<NamespaceDecl>(DC)->getPreviousDecl(); Prev;
3803 Prev = Prev->getPreviousDecl())
3804 if (!Prev->isFromASTFile())
3817 LookupResults.reserve(Map->size());
3818 for (
auto &Entry : *Map)
3819 LookupResults.push_back(
3820 std::make_pair(Entry.first, Entry.second.getLookupResult()));
3823 llvm::sort(LookupResults, llvm::less_first());
3824 for (
auto &NameAndResult : LookupResults) {
3832 assert(Result.
empty() &&
"Cannot have a constructor or conversion " 3833 "function name in a namespace!");
3838 if (!ND->isFromASTFile())
3862 uint64_t
Offset = Stream.GetCurrentBitNo();
3864 if (!Map || Map->empty())
3869 GenerateNameLookupTable(DC, LookupTable);
3873 Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev, Record,
3875 ++NumVisibleDeclContexts;
3885 void ASTWriter::WriteDeclContextVisibleUpdate(
const DeclContext *DC) {
3887 if (!Map || Map->empty())
3892 GenerateNameLookupTable(DC, LookupTable);
3896 if (isa<NamespaceDecl>(DC))
3897 DC = cast<DeclContext>(Chain->getKeyDeclaration(cast<Decl>(DC)));
3900 RecordData::value_type Record[] = {
UPDATE_VISIBLE, getDeclID(cast<Decl>(DC))};
3901 Stream.EmitRecordWithBlob(UpdateVisibleAbbrev, Record, LookupTable);
3905 void ASTWriter::WriteFPPragmaOptions(
const FPOptions &Opts) {
3906 RecordData::value_type Record[] = {Opts.
getInt()};
3911 void ASTWriter::WriteOpenCLExtensions(
Sema &SemaRef) {
3917 for (
const auto &I:Opts.OptMap) {
3918 AddString(I.getKey(), Record);
3919 auto V = I.getValue();
3920 Record.push_back(V.Supported ? 1 : 0);
3921 Record.push_back(V.Enabled ? 1 : 0);
3922 Record.push_back(V.Avail);
3923 Record.push_back(V.Core);
3928 void ASTWriter::WriteOpenCLExtensionTypes(
Sema &SemaRef) {
3934 const llvm::DenseMap<const Type *, std::set<std::string>> &OpenCLTypeExtMap =
3935 SemaRef.OpenCLTypeExtMap;
3936 using ElementTy = std::pair<TypeID, const std::set<std::string> *>;
3938 StableOpenCLTypeExtMap.reserve(OpenCLTypeExtMap.size());
3940 for (
const auto &I : OpenCLTypeExtMap)
3941 StableOpenCLTypeExtMap.emplace_back(
3942 getTypeID(I.first->getCanonicalTypeInternal()), &I.second);
3944 auto CompareByTypeID = [](
const ElementTy &E1,
const ElementTy &E2) ->
bool {
3945 return E1.first < E2.first;
3947 llvm::sort(StableOpenCLTypeExtMap, CompareByTypeID);
3950 for (
const ElementTy &E : StableOpenCLTypeExtMap) {
3951 Record.push_back(E.first);
3952 const std::set<std::string> *ExtSet = E.second;
3953 Record.push_back(static_cast<unsigned>(ExtSet->size()));
3954 for (
const std::string &Ext : *ExtSet)
3955 AddString(Ext, Record);
3961 void ASTWriter::WriteOpenCLExtensionDecls(
Sema &SemaRef) {
3967 const llvm::DenseMap<const Decl *, std::set<std::string>> &OpenCLDeclExtMap =
3968 SemaRef.OpenCLDeclExtMap;
3969 using ElementTy = std::pair<DeclID, const std::set<std::string> *>;
3971 StableOpenCLDeclExtMap.reserve(OpenCLDeclExtMap.size());
3973 for (
const auto &I : OpenCLDeclExtMap)
3974 StableOpenCLDeclExtMap.emplace_back(getDeclID(I.first), &I.second);
3976 auto CompareByDeclID = [](
const ElementTy &E1,
const ElementTy &E2) ->
bool {
3977 return E1.first < E2.first;
3979 llvm::sort(StableOpenCLDeclExtMap, CompareByDeclID);
3982 for (
const ElementTy &E : StableOpenCLDeclExtMap) {
3983 Record.push_back(E.first);
3984 const std::set<std::string> *ExtSet = E.second;
3985 Record.push_back(static_cast<unsigned>(ExtSet->size()));
3986 for (
const std::string &Ext : *ExtSet)
3987 AddString(Ext, Record);
3993 void ASTWriter::WriteCUDAPragmas(
Sema &SemaRef) {
3994 if (SemaRef.ForceCUDAHostDeviceDepth > 0) {
3995 RecordData::value_type Record[] = {SemaRef.ForceCUDAHostDeviceDepth};
4000 void ASTWriter::WriteObjCCategories() {
4002 RecordData Categories;
4004 for (
unsigned I = 0, N = ObjCClassesWithCategories.size(); I != N; ++I) {
4006 unsigned StartIndex = Categories.size();
4011 Categories.push_back(0);
4017 Cat != CatEnd; ++Cat, ++Size) {
4018 assert(getDeclID(*Cat) != 0 &&
"Bogus category");
4019 AddDeclRef(*Cat, Categories);
4023 Categories[StartIndex] = Size;
4027 CategoriesMap.push_back(CatInfo);
4032 llvm::array_pod_sort(CategoriesMap.begin(), CategoriesMap.end());
4035 using namespace llvm;
4037 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4039 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
4040 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4041 unsigned AbbrevID = Stream.EmitAbbrev(std::move(Abbrev));
4044 Stream.EmitRecordWithBlob(AbbrevID, Record,
4045 reinterpret_cast<char *>(CategoriesMap.data()),
4052 void ASTWriter::WriteLateParsedTemplates(
Sema &SemaRef) {
4059 for (
auto &LPTMapEntry : LPTMap) {
4062 AddDeclRef(FD, Record);
4063 AddDeclRef(LPT.
D, Record);
4064 Record.push_back(LPT.
Toks.size());
4066 for (
const auto &
Tok : LPT.
Toks) {
4067 AddToken(
Tok, Record);
4074 void ASTWriter::WriteOptimizePragmaOptions(
Sema &SemaRef) {
4077 AddSourceLocation(PragmaLoc, Record);
4082 void ASTWriter::WriteMSStructPragmaOptions(
Sema &SemaRef) {
4090 void ASTWriter::WriteMSPointersToMembersPragmaOptions(
Sema &SemaRef) {
4098 void ASTWriter::WritePackPragmaOptions(
Sema &SemaRef) {
4109 Record.push_back(StackEntry.Value);
4110 AddSourceLocation(StackEntry.PragmaLocation, Record);
4111 AddSourceLocation(StackEntry.PragmaPushLocation, Record);
4112 AddString(StackEntry.StackSlotLabel, Record);
4117 void ASTWriter::WriteModuleFileExtension(
Sema &SemaRef,
4123 auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
4125 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4126 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4127 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4128 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4129 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4130 unsigned Abbrev = Stream.EmitAbbrev(std::move(Abv));
4136 Record.push_back(Metadata.MajorVersion);
4137 Record.push_back(Metadata.MinorVersion);
4138 Record.push_back(Metadata.BlockName.size());
4139 Record.push_back(Metadata.UserInfo.size());
4141 Buffer += Metadata.BlockName;
4142 Buffer += Metadata.UserInfo;
4143 Stream.EmitRecordWithBlob(Abbrev, Record, Buffer);
4157 auto &Record = *
this;
4159 return Record.push_back(0);
4160 Record.push_back(A->
getKind() + 1);
4164 Record.AddSourceRange(A->
getRange());
4168 Record.push_back(A->getAttributeSpellingListIndexRaw());
4170 #include "clang/Serialization/AttrPCHWrite.inc" 4175 push_back(Attrs.size());
4176 for (
const auto *A : Attrs)
4188 Record.push_back(Tok.
getKind());
4194 Record.push_back(Str.size());
4195 Record.insert(Record.end(), Str.begin(), Str.end());
4199 assert(Context &&
"should have context when outputting path");
4205 const char *PathBegin = Path.data();
4206 const char *PathPtr =
4208 if (PathPtr != PathBegin) {
4209 Path.erase(Path.begin(), Path.begin() + (PathPtr - PathBegin));
4218 PreparePathForOutput(FilePath);
4219 AddString(FilePath, Record);
4225 PreparePathForOutput(FilePath);
4226 Stream.EmitRecordWithBlob(Abbrev, Record, FilePath);
4231 Record.push_back(Version.getMajor());
4233 Record.push_back(*Minor + 1);
4235 Record.push_back(0);
4237 Record.push_back(*Subminor + 1);
4239 Record.push_back(0);
4248 if (ID >= FirstIdentID)
4249 IdentifierOffsets[ID - FirstIdentID] =
Offset;
4255 unsigned ID = SelectorIDs[Sel];
4256 assert(ID &&
"Unknown selector");
4259 if (ID < FirstSelectorID)
4261 SelectorOffsets[ID - FirstSelectorID] =
Offset;
4267 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
4268 bool IncludeTimestamps)
4269 : Stream(Stream), Buffer(Buffer), ModuleCache(ModuleCache),
4270 IncludeTimestamps(IncludeTimestamps) {
4271 for (
const auto &Ext : Extensions) {
4272 if (
auto Writer = Ext->createExtensionWriter(*
this))
4273 ModuleFileExtensionWriters.push_back(std::move(Writer));
4278 llvm::DeleteContainerSeconds(FileDeclIDs);
4282 assert(WritingAST &&
"can't determine lang opts when not writing AST");
4291 const std::string &OutputFile,
4292 Module *WritingModule, StringRef isysroot,
4294 bool ShouldCacheASTInMemory) {
4297 ASTHasCompilerErrors = hasErrors;
4300 Stream.Emit((
unsigned)
'C', 8);
4301 Stream.Emit((
unsigned)
'P', 8);
4302 Stream.Emit((
unsigned)
'C', 8);
4303 Stream.Emit((
unsigned)
'H', 8);
4305 WriteBlockInfoBlock();
4309 this->WritingModule = WritingModule;
4311 WriteASTCore(SemaRef, isysroot, OutputFile, WritingModule);
4314 this->WritingModule =
nullptr;
4315 this->BaseDirectory.clear();
4318 if (ShouldCacheASTInMemory) {
4321 llvm::MemoryBuffer::getMemBufferCopy(
4322 StringRef(Buffer.begin(), Buffer.size())));
4327 template<
typename Vector>
4330 for (
typename Vector::iterator I = Vec.begin(
nullptr,
true), E = Vec.end();
4337 const std::string &OutputFile,
4339 using namespace llvm;
4341 bool isModule = WritingModule !=
nullptr;
4345 Chain->finalizeForWriting();
4362 RegisterPredefDecl(Context.ObjCProtocolClassDecl,
4366 RegisterPredefDecl(Context.ObjCInstanceTypeDecl,
4370 RegisterPredefDecl(Context.BuiltinMSVaListDecl,
4373 RegisterPredefDecl(Context.MakeIntegerSeqDecl,
4375 RegisterPredefDecl(Context.CFConstantStringTypeDecl,
4377 RegisterPredefDecl(Context.CFConstantStringTagDecl,
4379 RegisterPredefDecl(Context.TypePackElementDecl,
4392 UnusedFileScopedDecls);
4406 WeakInfo &WI = WeakUndeclaredIdentifier.second;
4410 WeakUndeclaredIdentifiers.push_back(WI.
getUsed());
4420 for (
unsigned I = 0, N = SemaRef.
VTableUses.size(); I != N; ++I) {
4430 AddDeclRef(TD, UnusedLocalTypedefNameCandidates);
4439 "There are local ones at end of translation unit!");
4456 for (
const auto &I : SemaRef.KnownNamespaces) {
4466 for (
const auto &I : Undefined) {
4476 for (
const auto &DeleteExprsInfo :
4478 AddDeclRef(DeleteExprsInfo.first, DeleteExprsToAnalyze);
4479 DeleteExprsToAnalyze.push_back(DeleteExprsInfo.second.size());
4480 for (
const auto &DeleteLoc : DeleteExprsInfo.second) {
4482 DeleteExprsToAnalyze.push_back(DeleteLoc.second);
4488 WriteControlBlock(PP, Context, isysroot, OutputFile);
4506 NewGlobalKindDeclPairs.push_back(D->
getKind());
4507 NewGlobalKindDeclPairs.push_back(
GetDeclRef(D));
4511 auto Abv = std::make_shared<BitCodeAbbrev>();
4513 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4514 unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
4517 Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev, Record,
4518 bytes(NewGlobalKindDeclPairs));
4522 Abv = std::make_shared<BitCodeAbbrev>();
4524 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, 6));
4525 Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
4526 UpdateVisibleAbbrev = Stream.EmitAbbrev(std::move(Abv));
4527 WriteDeclContextVisibleUpdate(TU);
4530 if (Context.ExternCContext)
4531 WriteDeclContextVisibleUpdate(Context.ExternCContext);
4545 for (
const auto &Number : Context.MangleNumbers)
4546 if (!Number.first->isFromASTFile())
4549 for (
const auto &Number : Context.StaticLocalNumbers)
4550 if (!Number.first->isFromASTFile())
4557 for (
const auto *I : DeclsToEmitEvenIfUnreferenced) {
4589 for (
auto &SelectorAndID : SelectorIDs)
4590 AllSelectors.push_back(SelectorAndID.first);
4591 for (
auto &
Selector : AllSelectors)
4600 AddTypeRef(Context.ObjCIdRedefinitionType, SpecialTypes);
4601 AddTypeRef(Context.ObjCClassRedefinitionType, SpecialTypes);
4602 AddTypeRef(Context.ObjCSelRedefinitionType, SpecialTypes);
4625 auto Abbrev = std::make_shared<BitCodeAbbrev>();
4627 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
4628 unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
4631 llvm::raw_svector_ostream Out(Buffer);
4633 using namespace llvm::support;
4635 endian::Writer
LE(Out, little);
4636 LE.write<uint8_t>(
static_cast<uint8_t
>(M.
Kind));
4641 LE.write<uint16_t>(Name.size());
4642 Out.write(Name.data(), Name.size());
4648 auto writeBaseIDOrNone = [&](uint32_t BaseID,
bool ShouldWrite) {
4651 LE.write<uint32_t>(BaseID);
4653 LE.write<uint32_t>(
None);
4670 Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev, Record,
4671 Buffer.data(), Buffer.size());
4682 WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord);
4683 while (!DeclTypesToEmit.empty()) {
4684 DeclOrType DOT = DeclTypesToEmit.front();
4685 DeclTypesToEmit.pop();
4687 WriteType(DOT.getType());
4689 WriteDecl(Context, DOT.getDecl());
4691 }
while (!DeclUpdates.empty());
4694 DoneWritingDeclsAndTypes =
true;
4697 WriteTypeDeclOffsets();
4698 if (!DeclUpdatesOffsetsRecord.empty())
4700 WriteFileDeclIDsMap();
4703 WritePreprocessor(PP, isModule);
4705 WriteSelectors(SemaRef);
4706 WriteReferencedSelectorsPool(SemaRef);
4707 WriteLateParsedTemplates(SemaRef);
4708 WriteIdentifierTable(PP, SemaRef.
IdResolver, isModule);
4710 WriteOpenCLExtensions(SemaRef);
4711 WriteOpenCLExtensionTypes(SemaRef);
4712 WriteCUDAPragmas(SemaRef);
4716 WriteSubmodules(WritingModule);
4720 WriteOpenCLExtensionDecls(SemaRef);
4725 if (!EagerlyDeserializedDecls.empty())
4728 if (!ModularCodegenDecls.empty())
4732 if (!TentativeDefinitions.empty())
4736 if (!UnusedFileScopedDecls.empty())
4740 if (!WeakUndeclaredIdentifiers.empty())
4742 WeakUndeclaredIdentifiers);
4745 if (!ExtVectorDecls.empty())
4749 if (!VTableUses.empty())
4753 if (!UnusedLocalTypedefNameCandidates.empty())
4755 UnusedLocalTypedefNameCandidates);
4758 if (!PendingInstantiations.empty())
4762 if (!SemaDeclRefs.empty())
4766 if (!CUDASpecialDeclRefs.empty())
4770 if (!DelegatingCtorDecls.empty())
4774 if (!KnownNamespaces.empty())
4778 if (!UndefinedButUsed.empty())
4781 if (!DeleteExprsToAnalyze.empty())
4785 for (
auto *DC : UpdatedDeclContexts)
4786 WriteDeclContextVisibleUpdate(DC);
4788 if (!WritingModule) {
4793 ModuleInfo(uint64_t ID,
Module *M) :
ID(ID), M(M) {}
4797 assert(SubmoduleIDs.find(I->getImportedModule()) != SubmoduleIDs.end());
4798 Imports.push_back(ModuleInfo(SubmoduleIDs[I->getImportedModule()],
4799 I->getImportedModule()));
4802 if (!Imports.empty()) {
4803 auto Cmp = [](
const ModuleInfo &A,
const ModuleInfo &B) {
4806 auto Eq = [](
const ModuleInfo &A,
const ModuleInfo &B) {
4807 return A.ID == B.ID;
4811 llvm::sort(Imports, Cmp);
4812 Imports.erase(std::unique(Imports.begin(), Imports.end(), Eq),
4816 for (
const auto &Import : Imports) {
4817 ImportedModules.push_back(Import.ID);
4828 WriteObjCCategories();
4829 if(!WritingModule) {
4830 WriteOptimizePragmaOptions(SemaRef);
4831 WriteMSStructPragmaOptions(SemaRef);
4832 WriteMSPointersToMembersPragmaOptions(SemaRef);
4834 WritePackPragmaOptions(SemaRef);
4837 RecordData::value_type Record[] = {
4838 NumStatements, NumMacros, NumLexicalDeclContexts, NumVisibleDeclContexts};
4843 for (
const auto &ExtWriter : ModuleFileExtensionWriters)
4844 WriteModuleFileExtension(SemaRef, *ExtWriter);
4846 return writeUnhashedControlBlock(PP, Context);
4849 void ASTWriter::WriteDeclUpdatesBlocks(
RecordDataImpl &OffsetsRecord) {
4850 if (DeclUpdates.empty())
4853 DeclUpdateMap LocalUpdates;
4854 LocalUpdates.swap(DeclUpdates);
4856 for (
auto &DeclUpdate : LocalUpdates) {
4857 const Decl *D = DeclUpdate.first;
4859 bool HasUpdatedBody =
false;
4862 for (
auto &
Update : DeclUpdate.second) {
4868 HasUpdatedBody =
true;
4876 assert(
Update.getDecl() &&
"no decl to add?");
4889 const VarDecl *VD = cast<VarDecl>(D);
4903 Record.
AddStmt(const_cast<Expr *>(
4904 cast<ParmVarDecl>(
Update.getDecl())->getDefaultArg()));
4909 cast<FieldDecl>(
Update.getDecl())->getInClassInitializer());
4913 auto *RD = cast<CXXRecordDecl>(D);
4914 UpdatedDeclContexts.insert(RD->getPrimaryContext());
4915 Record.
push_back(RD->isParamDestroyedInCallee());
4916 Record.
push_back(RD->getArgPassingRestrictions());
4918 Record.
AddOffset(WriteDeclContextLexicalBlock(
4919 *Context, const_cast<CXXRecordDecl *>(RD)));
4924 if (
auto *MSInfo = RD->getMemberSpecializationInfo()) {
4925 Record.
push_back(MSInfo->getTemplateSpecializationKind());
4928 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
4929 Record.
push_back(Spec->getTemplateSpecializationKind());
4934 auto From = Spec->getInstantiatedFrom();
4935 if (
auto PartialSpec =
4940 &Spec->getTemplateInstantiationArgs());
4961 Record.
AddStmt(cast<CXXDestructorDecl>(D)->getOperatorDeleteThisArg());
4985 D->
getAttr<OMPThreadPrivateDeclAttr>()->getRange());
4989 auto *A = D->
getAttr<OMPAllocateDeclAttr>();
4990 Record.
push_back(A->getAllocatorType());
4991 Record.
AddStmt(A->getAllocator());
4999 D->
getAttr<OMPDeclareTargetDeclAttr>()->getRange());
5012 if (HasUpdatedBody) {
5013 const auto *Def = cast<FunctionDecl>(D);
5027 Record.push_back((Raw << 1) | (Raw >> 31));
5036 AddAPInt(Value.bitcastToAPInt());
5049 push_back(static_cast<uint64_t>(Kind));
5055 AddAPSInt(Value.
getInt());
5058 push_back(static_cast<uint64_t>(
5059 llvm::APFloatBase::SemanticsToEnum(Value.
getFloat().getSemantics())));
5073 push_back(static_cast<uint64_t>(llvm::APFloatBase::SemanticsToEnum(
5076 push_back(static_cast<uint64_t>(llvm::APFloatBase::SemanticsToEnum(
5091 llvm_unreachable(
"Invalid APValue::ValueKind");
5118 MacroInfoToEmitData Info = { Name, MI, ID };
5119 MacroInfosToEmit.push_back(Info);
5128 assert(MacroIDs.find(MI) != MacroIDs.end() &&
"Macro not emitted!");
5129 return MacroIDs[MI];
5133 return IdentMacroDirectivesOffsetMap.lookup(Name);
5137 Record->push_back(Writer->getSelectorRef(SelRef));
5146 if (SID == 0 && Chain) {
5149 Chain->LoadSelector(Sel);
5150 SID = SelectorIDs[Sel];
5153 SID = NextSelectorID++;
5154 SelectorIDs[Sel] = SID;
5195 bool InfoHasSameExpr
5197 Record->push_back(InfoHasSameExpr);
5198 if (InfoHasSameExpr)
5215 TypeLocWriter TLW(*
this);
5232 if (Idx.getIndex() == 0) {
5233 if (DoneWritingDeclsAndTypes) {
5234 assert(0 &&
"New type seen after serializing all the types to emit!");
5241 DeclTypesToEmit.push(T);
5254 TypeIdxMap::const_iterator I = TypeIdxs.find(T);
5255 assert(I != TypeIdxs.end() &&
"Type not emitted!");
5265 assert(WritingAST &&
"Cannot request a declaration ID before AST writing");
5276 assert(!(reinterpret_cast<uintptr_t>(D) & 0x01) &&
"Invalid decl pointer");
5279 if (DoneWritingDeclsAndTypes) {
5280 assert(0 &&
"New decl seen after serializing all the decls to emit!");
5287 DeclTypesToEmit.push(const_cast<Decl *>(D));
5302 assert(DeclIDs.find(D) != DeclIDs.end() &&
"Declaration not emitted!");
5306 void ASTWriter::associateDeclWithFile(
const Decl *D,
DeclID ID) {
5321 if (isa<ParmVarDecl>(D) || isa<TemplateTemplateParmDecl>(D))
5330 if (FID.isInvalid())
5334 DeclIDInFileInfo *&Info = FileDeclIDs[FID];
5336 Info =
new DeclIDInFileInfo();
5338 std::pair<unsigned, serialization::DeclID> LocDecl(Offset, ID);
5341 if (Decls.empty() || Decls.back().first <=
Offset) {
5342 Decls.push_back(LocDecl);
5346 LocDeclIDsTy::iterator I =
5347 llvm::upper_bound(Decls, LocDecl, llvm::less_first());
5349 Decls.insert(I, LocDecl);
5354 "expected an anonymous declaration");
5358 auto It = AnonymousDeclarationNumbers.find(D);
5359 if (It == AnonymousDeclarationNumbers.end()) {
5362 AnonymousDeclarationNumbers[ND] = Number;
5365 It = AnonymousDeclarationNumbers.find(D);
5366 assert(It != AnonymousDeclarationNumbers.end() &&
5367 "declaration not found within its lexical context");
5406 AddDeclarationName(NameInfo.
getName());
5426 NestedNames.push_back(NNS);
5430 Record->push_back(NestedNames.size());
5431 while(!NestedNames.empty()) {
5432 NNS = NestedNames.pop_back_val();
5435 Record->push_back(Kind);
5474 assert(TemplateParams &&
"No TemplateParams!");
5479 Record->push_back(TemplateParams->
size());
5480 for (
const auto &
P : *TemplateParams)
5482 if (
const Expr *RequiresClause = TemplateParams->getRequiresClause()) {
5483 Record->push_back(
true);
5484 AddStmt(const_cast<Expr*>(RequiresClause));
5486 Record->push_back(
false);
5493 assert(TemplateArgs &&
"No TemplateArgs!");
5494 Record->push_back(TemplateArgs->
size());
5495 for (
int i = 0, e = TemplateArgs->
size(); i != e; ++i)
5496 AddTemplateArgument(TemplateArgs->
get(i));
5501 assert(ASTTemplArgList &&
"No ASTTemplArgList!");
5507 AddTemplateArgumentLoc(TemplArgs[i]);
5511 Record->push_back(Set.
size());
5513 I = Set.
begin(), E = Set.
end(); I != E; ++I) {
5515 Record->push_back(I.getAccess());
5537 for (
auto &
Base : Bases)
5555 for (
auto *Init : CtorInits) {
5556 if (Init->isBaseInitializer()) {
5559 Writer.
push_back(Init->isBaseVirtual());
5560 }
else if (Init->isDelegatingInitializer()) {
5563 }
else if (Init->isMemberInitializer()){
5568 Writer.
AddDeclRef(Init->getIndirectMember());
5572 Writer.
AddStmt(Init->getInit());
5576 if (Init->isWritten())
5577 Writer.
push_back(Init->getSourceOrder());
5590 auto &Data = D->data();
5591 Record->push_back(Data.IsLambda);
5593 #define FIELD(Name, Width, Merge) \ 5594 Record->push_back(Data.Name); 5595 #include "clang/AST/CXXRecordDeclDefinitionBits.def" 5599 bool ModulesDebugInfo =
5600 Writer->Context->getLangOpts().ModulesDebugInfo && !D->
isDependentType();
5601 Record->push_back(ModulesDebugInfo);
5602 if (ModulesDebugInfo)
5603 Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(D));
5607 Record->push_back(Data.NumBases);
5608 if (Data.NumBases > 0)
5609 AddCXXBaseSpecifiers(Data.bases());
5612 Record->push_back(Data.NumVBases);
5613 if (Data.NumVBases > 0)
5614 AddCXXBaseSpecifiers(Data.vbases());
5616 AddUnresolvedSet(Data.Conversions.get(*Writer->Context));
5617 Record->push_back(Data.ComputedVisibleConversions);
5618 if (Data.ComputedVisibleConversions)
5619 AddUnresolvedSet(Data.VisibleConversions.get(*Writer->Context));
5624 if (Data.IsLambda) {
5625 auto &Lambda = D->getLambdaData();
5626 Record->push_back(Lambda.Dependent);
5627 Record->push_back(Lambda.IsGenericLambda);
5628 Record->push_back(Lambda.CaptureDefault);
5629 Record->push_back(Lambda.NumCaptures);
5630 Record->push_back(Lambda.NumExplicitCaptures);
5631 Record->push_back(Lambda.HasKnownInternalLinkage);
5632 Record->push_back(Lambda.ManglingNumber);
5634 AddTypeSourceInfo(Lambda.MethodTyInfo);
5635 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
5658 void ASTWriter::ReaderInitialized(
ASTReader *Reader) {
5659 assert(Reader &&
"Cannot remove chain");
5660 assert((!Chain || Chain == Reader) &&
"Cannot replace chain");
5661 assert(FirstDeclID == NextDeclID &&
5662 FirstTypeID == NextTypeID &&
5663 FirstIdentID == NextIdentID &&
5664 FirstMacroID == NextMacroID &&
5665 FirstSubmoduleID == NextSubmoduleID &&
5666 FirstSelectorID == NextSelectorID &&
5667 "Setting chain after writing has started.");
5679 NextDeclID = FirstDeclID;
5680 NextTypeID = FirstTypeID;
5681 NextIdentID = FirstIdentID;
5682 NextMacroID = FirstMacroID;
5683 NextSelectorID = FirstSelectorID;
5684 NextSubmoduleID = FirstSubmoduleID;
5689 IdentID &StoredID = IdentifierIDs[II];
5696 MacroID &StoredID = MacroIDs[MI];
5707 TypeIdx &StoredIdx = TypeIdxs[T];
5721 assert(MacroDefinitions.find(MD) == MacroDefinitions.end());
5722 MacroDefinitions[MD] =
ID;
5726 assert(SubmoduleIDs.find(Mod) == SubmoduleIDs.end());
5727 SubmoduleIDs[Mod] =
ID;
5730 void ASTWriter::CompletedTagDefinition(
const TagDecl *D) {
5731 if (Chain && Chain->isProcessingUpdateRecords())
return;
5733 assert(!WritingAST &&
"Already writing the AST!");
5734 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
5736 if (RD->isFromASTFile()) {
5741 "completed a tag from another module but not by instantiation?");
5742 DeclUpdates[RD].push_back(
5757 void ASTWriter::AddedVisibleDecl(
const DeclContext *DC,
const Decl *D) {
5758 if (Chain && Chain->isProcessingUpdateRecords())
return;
5760 "Should not add lookup results to non-lookup contexts!");
5763 if (isa<TranslationUnitDecl>(DC))
5771 !isa<FunctionTemplateDecl>(D))
5781 assert(!WritingAST &&
"Already writing the AST!");
5782 if (UpdatedDeclContexts.insert(DC) && !cast<Decl>(DC)->isFromASTFile()) {
5786 for (
auto *Child : DC->
decls())
5787 DeclsToEmitEvenIfUnreferenced.push_back(Child);
5789 DeclsToEmitEvenIfUnreferenced.push_back(D);
5792 void ASTWriter::AddedCXXImplicitMember(
const CXXRecordDecl *RD,
const Decl *D) {
5793 if (Chain && Chain->isProcessingUpdateRecords())
return;
5801 if (!isa<CXXMethodDecl>(D))
5806 assert(!WritingAST &&
"Already writing the AST!");
5810 void ASTWriter::ResolvedExceptionSpec(
const FunctionDecl *FD) {
5811 if (Chain && Chain->isProcessingUpdateRecords())
return;
5812 assert(!DoneWritingDeclsAndTypes &&
"Already done writing updates!");
5814 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
5819 ->castAs<FunctionProtoType>()
5820 ->getExceptionSpecType()))
5826 if (Chain && Chain->isProcessingUpdateRecords())
return;
5827 assert(!WritingAST &&
"Already writing the AST!");
5829 Chain->forEachImportedKeyDecl(FD, [&](
const Decl *D) {
5830 DeclUpdates[D].push_back(
5838 if (Chain && Chain->isProcessingUpdateRecords())
return;
5839 assert(!WritingAST &&
"Already writing the AST!");
5840 assert(Delete &&
"Not given an operator delete");
5842 Chain->forEachImportedKeyDecl(DD, [&](
const Decl *D) {
5847 void ASTWriter::CompletedImplicitDefinition(
const FunctionDecl *D) {
5848 if (Chain && Chain->isProcessingUpdateRecords())
return;
5849 assert(!WritingAST &&
"Already writing the AST!");
5857 void ASTWriter::VariableDefinitionInstantiated(
const VarDecl *D) {
5858 if (Chain && Chain->isProcessingUpdateRecords())
return;
5859 assert(!WritingAST &&
"Already writing the AST!");
5866 void ASTWriter::FunctionDefinitionInstantiated(
const FunctionDecl *D) {
5867 if (Chain && Chain->isProcessingUpdateRecords())
return;
5868 assert(!WritingAST &&
"Already writing the AST!");
5875 void ASTWriter::InstantiationRequested(
const ValueDecl *D) {
5876 if (Chain && Chain->isProcessingUpdateRecords())
return;
5877 assert(!WritingAST &&
"Already writing the AST!");
5884 if (
auto *VD = dyn_cast<VarDecl>(D))
5885 POI = VD->getPointOfInstantiation();
5887 POI = cast<FunctionDecl>(D)->getPointOfInstantiation();
5891 void ASTWriter::DefaultArgumentInstantiated(
const ParmVarDecl *D) {
5892 if (Chain && Chain->isProcessingUpdateRecords())
return;
5893 assert(!WritingAST &&
"Already writing the AST!");
5897 DeclUpdates[D].push_back(
5901 void ASTWriter::DefaultMemberInitializerInstantiated(
const FieldDecl *D) {
5902 assert(!WritingAST &&
"Already writing the AST!");
5906 DeclUpdates[D].push_back(
5912 if (Chain && Chain->isProcessingUpdateRecords())
return;
5913 assert(!WritingAST &&
"Already writing the AST!");
5917 assert(IFD->
getDefinition() &&
"Category on a class without a definition?");
5918 ObjCClassesWithCategories.insert(
5922 void ASTWriter::DeclarationMarkedUsed(
const Decl *D) {
5923 if (Chain && Chain->isProcessingUpdateRecords())
return;
5924 assert(!WritingAST &&
"Already writing the AST!");
5936 void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(
const Decl *D) {
5937 if (Chain && Chain->isProcessingUpdateRecords())
return;
5938 assert(!WritingAST &&
"Already writing the AST!");
5945 void ASTWriter::DeclarationMarkedOpenMPAllocate(
const Decl *D,
const Attr *A) {
5946 if (Chain && Chain->isProcessingUpdateRecords())
return;
5947 assert(!WritingAST &&
"Already writing the AST!");
5954 void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
5956 if (Chain && Chain->isProcessingUpdateRecords())
return;
5957 assert(!WritingAST &&
"Already writing the AST!");
5961 DeclUpdates[D].push_back(
5965 void ASTWriter::RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M) {
5966 if (Chain && Chain->isProcessingUpdateRecords())
return;
5967 assert(!WritingAST &&
"Already writing the AST!");
5968 assert(D->
isHidden() &&
"expected a hidden declaration");
5972 void ASTWriter::AddedAttributeToRecord(
const Attr *Attr,
5974 if (Chain && Chain->isProcessingUpdateRecords())
return;
5975 assert(!WritingAST &&
"Already writing the AST!");
5981 void ASTWriter::AddedCXXTemplateSpecialization(
5983 assert(!WritingAST &&
"Already writing the AST!");
5987 if (Chain && Chain->isProcessingUpdateRecords())
5990 DeclsToEmitEvenIfUnreferenced.push_back(D);
5993 void ASTWriter::AddedCXXTemplateSpecialization(
5995 assert(!WritingAST &&
"Already writing the AST!");
5999 if (Chain && Chain->isProcessingUpdateRecords())
6002 DeclsToEmitEvenIfUnreferenced.push_back(D);
6007 assert(!WritingAST &&
"Already writing the AST!");
6011 if (Chain && Chain->isProcessingUpdateRecords())
6014 DeclsToEmitEvenIfUnreferenced.push_back(D);
6028 #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *S); 6029 #include "clang/Basic/OpenMPKinds.def" 6038 OMPClauseWriter(*this).writeClause(C);
6041 void OMPClauseWriter::writeClause(
OMPClause *
C) {
6045 Record.AddSourceLocation(C->
getEndLoc());
6054 VisitOMPClauseWithPreInit(C);
6058 void OMPClauseWriter::VisitOMPIfClause(
OMPIfClause *C) {
6059 VisitOMPClauseWithPreInit(C);
6068 VisitOMPClauseWithPreInit(C);
6074 VisitOMPClauseWithPreInit(C);
6112 VisitOMPClauseWithPreInit(C);
6128 Record.AddStmt(NumIter);
6140 void OMPClauseWriter::VisitOMPReadClause(
OMPReadClause *) {}
6152 void OMPClauseWriter::VisitOMPSIMDClause(
OMPSIMDClause *) {}
6169 VisitOMPClauseWithPreInit(C);
6177 for (
auto *VE : C->
inits()) {
6184 VisitOMPClauseWithPostUpdate(C);
6186 Record.writeEnum(C->
getKind());
6210 VisitOMPClauseWithPostUpdate(C);
6229 VisitOMPClauseWithPostUpdate(C);
6248 VisitOMPClauseWithPostUpdate(C);
6269 VisitOMPClauseWithPostUpdate(C);
6271 Record.AddSourceLocation(C->getColonLoc());
6272 Record.push_back(C->getModifier());
6273 Record.AddSourceLocation(C->getModifierLoc());
6277 for (
auto *VE : C->privates()) {
6280 for (
auto *VE : C->inits()) {
6283 for (
auto *VE : C->updates()) {
6286 for (
auto *VE : C->finals()) {
6289 Record.AddStmt(C->getStep());
6290 Record.AddStmt(C->getCalcStep());
6291 for (
auto *VE : C->used_expressions())
6296 Record.push_back(C->varlist_size());
6297 Record.AddSourceLocation(C->getLParenLoc());
6299 for (
auto *VE : C->varlists())
6305 Record.push_back(C->varlist_size());
6306 Record.AddSourceLocation(C->getLParenLoc());
6307 for (
auto *VE : C->varlists())
6318 Record.push_back(C->varlist_size());
6319 Record.AddSourceLocation(C->getLParenLoc());
6320 for (
auto *VE : C->varlists())
6331 Record.push_back(C->varlist_size());
6332 Record.AddSourceLocation(C->getLParenLoc());
6333 for (
auto *VE : C->varlists())
6338 Record.push_back(C->varlist_size());
6340 Record.AddSourceLocation(C->getLParenLoc());
6344 for (
auto *VE : C->varlists())
6346 for (
unsigned I = 0, E = C->
getNumLoops(); I < E; ++I)
6351 VisitOMPClauseWithPreInit(C);
6356 void OMPClauseWriter::VisitOMPMapClause(
OMPMapClause *C) {
6357 Record.push_back(C->varlist_size());
6361 Record.AddSourceLocation(C->getLParenLoc());
6369 Record.AddSourceLocation(C->
getMapLoc());
6371 for (
auto *E : C->varlists())
6376 Record.AddDeclRef(D);
6378 Record.push_back(N);
6380 Record.push_back(N);
6382 Record.AddStmt(M.getAssociatedExpression());
6383 Record.AddDeclRef(M.getAssociatedDeclaration());
6397 VisitOMPClauseWithPreInit(C);
6403 VisitOMPClauseWithPreInit(C);
6409 VisitOMPClauseWithPreInit(C);
6415 VisitOMPClauseWithPreInit(C);
6421 VisitOMPClauseWithPreInit(C);
6426 void OMPClauseWriter::VisitOMPHintClause(
OMPHintClause *C) {
6432 VisitOMPClauseWithPreInit(C);
6448 void OMPClauseWriter::VisitOMPToClause(
OMPToClause *C) {
6449 Record.push_back(C->varlist_size());
6453 Record.AddSourceLocation(C->getLParenLoc());
6456 for (
auto *E : C->varlists())
6461 Record.AddDeclRef(D);
6463 Record.push_back(N);
6465 Record.push_back(N);
6467 Record.AddStmt(M.getAssociatedExpression());
6468 Record.AddDeclRef(M.getAssociatedDeclaration());
6472 void OMPClauseWriter::VisitOMPFromClause(
OMPFromClause *C) {
6473 Record.push_back(C->varlist_size());
6477 Record.AddSourceLocation(C->getLParenLoc());
6480 for (
auto *E : C->varlists())
6485 Record.AddDeclRef(D);
6487 Record.push_back(N);
6489 Record.push_back(N);
6491 Record.AddStmt(M.getAssociatedExpression());
6492 Record.AddDeclRef(M.getAssociatedDeclaration());
6497 Record.push_back(C->varlist_size());
6501 Record.AddSourceLocation(C->getLParenLoc());
6502 for (
auto *E : C->varlists())
6506 for (
auto *VE : C->
inits())
6509 Record.AddDeclRef(D);
6511 Record.push_back(N);
6513 Record.push_back(N);
6515 Record.AddStmt(M.getAssociatedExpression());
6516 Record.AddDeclRef(M.getAssociatedDeclaration());
6521 Record.push_back(C->varlist_size());
6525 Record.AddSourceLocation(C->getLParenLoc());
6526 for (
auto *E : C->varlists())
6529 Record.AddDeclRef(D);
6531 Record.push_back(N);
6533 Record.push_back(N);
6535 Record.AddStmt(M.getAssociatedExpression());
6536 Record.AddDeclRef(M.getAssociatedDeclaration());
6542 void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
6551 void OMPClauseWriter::VisitOMPAtomicDefaultMemOrderClause(
6559 Record.push_back(C->varlist_size());
6560 Record.AddSourceLocation(C->getLParenLoc());
6561 for (
auto *VE : C->varlists())
A CXXConstCastExpr record.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
A FriendTemplateDecl record.
Defines the clang::ASTContext interface.
A CompoundLiteralExpr record.
A NonTypeTemplateParmDecl record.
TargetOptions & getTargetOpts() const
Retrieve the target options.
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...
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.
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...
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
The macro directives history for a particular identifier.
llvm::omp::ProcBindKind getProcBindKind() const
Returns kind of the clause.
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.
LateParsedTemplateMapT LateParsedTemplateMap
SourceLocation getCommaLoc()
Get location of ','.
const TypeClass * getTypePtr() const
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.
unsigned getNumArgs() const
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()
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.
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"...
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
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
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.
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.
const TemplateArgument & getArg(unsigned Idx) const
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.
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...
unsigned IsFramework
Whether this is a framework module.
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.
SourceLocation getAtomicDefaultMemOrderKindKwLoc() const
Returns location of clause kind.
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...
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.
The base class of the type hierarchy.
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
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.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Represent a C++ namespace.
A ObjCPropertyDecl record.
Wrapper for source info for typedefs.
serialization::DeclID GetDeclRef(const Decl *D)
Force a declaration to be emitted and get its ID.
Expr * getCondition() const
Returns condition.
const TargetInfo & getTargetInfo() const
A container of type source information.
This represents 'update' clause in the '#pragma omp atomic' directive.
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.
void AddTypeRef(QualType T, RecordDataImpl &Record)
Emit a reference to a type.
ObjCMethodDecl * getMethod() const
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
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.
This is a module that was defined by a module map and built out of header files.
The internal '__type_pack_element' template.
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
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.
A ClassTemplateDecl record.
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
bool isConstrained() 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.
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
static unsigned CreateSLocFileAbbrev(llvm::BitstreamWriter &Stream)
Create an abbreviation for the SLocEntry that refers to a file.
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.
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.
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.
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.
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
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.
A DesignatedInitExpr record.
The Objective-C 'SEL' type.
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
Iteration over the preprocessed entities.
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.
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...
TypeSourceInfo * getUnderlyingTInfo() const
void resolveHeaderDirectives(const FileEntry *File) const
Resolve all lazy header directives for the specified file.
An ObjCProtocolExpr record.
An ObjCSelectorExpr record.
Specifies a header that has been explicitly excluded from this submodule.
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
SmallVector< Requirement, 2 > Requirements
The set of language features required to use this module.
NameKind getNameKind() const
Determine what kind of name this is.
Represents a member of a struct/union/class.
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
bool isCPlusPlusOperatorKeyword() const
bool AddOffset(InterpState &S, CodePtr OpPC)
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.
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
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.
Token - This structure provides full information about a lexed token.
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
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...
void AddTemplateParameterList(const TemplateParameterList *TemplateParams)
Emit a template parameter list.
SourceLocation getTemplateLoc() const
const LangOptions & getLangOpts() const
Expr * getNumTeams()
Return NumTeams number.
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.
const llvm::MemoryBuffer * getRawBuffer() const
Get the underlying buffer, returning NULL if the buffer is not yet available.
Record code for the set of ext_vector type names.
iterator end()
end - Returns an iterator that has 'finished'.
SourceLocation getComposedLoc(FileID FID, unsigned Offset) const
Form a SourceLocation from a FileID and Offset pair.
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
A RequiresExprBodyDecl record.
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.
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
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...
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.
bool getInheritConstructors() const
Determine whether this base class's constructors get inherited.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Wrapper for source info for functions.
Specifies a conflict with another module.
The signed 128-bit integer type.
unsigned getHash() const
Compute a fingerprint of this key for use in on-disk hash table.
StoredDeclsMap * buildLookup()
Ensure the lookup structure is fully-built and return it.
A 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.
A UsingDirecitveDecl record.
const Stmt * getPreInitStmt() const
Get pre-initialization statement for the clause.
SourceLocation getElaboratedKeywordLoc() const
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
Wrapper for substituted template type parameters.
Concrete class used by the front-end to report problems and issues.
Record code for #pragma optimize options.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
void AddSourceRange(SourceRange Range, RecordDataImpl &Record)
Emit a source range.
Specifies a header that is private to this submodule but must be textually included.
Record code for pending implicit instantiations.
Wrapper for substituted template type parameters.
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
The internal '__make_integer_seq' template.
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.
Record code for floating point #pragma options.
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
Wrapper for source info for ObjC interfaces.
Record code for the set of known namespaces, which are used for typo correction.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
unsigned getScale() const
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
uint32_t getIndex() const
SourceLocation getDefaultmapModifierLoc() const
Get the modifier location.
SmallVector< uint64_t, 64 > RecordData
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
const IdentifierInfo * getAttrName() const
unsigned getUniqueDeclarationsNum() const
Return the number of unique base declarations in this clause.
APSInt & getComplexIntReal()
unsigned getNumArgs() const
SourceLocation getProtocolRAngleLoc() const
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.
Record code for the table of offsets into the block of source-location information.
bool isMacroArgExpansion() const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
helper_expr_const_range privates() const
private_copies_range private_copies()
This represents clause 'from' in the '#pragma omp ...' directives.
TypeCode
Record codes for each kind of type.
void writeQualifiers(Qualifiers value)
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
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.
helper_expr_const_range reduction_ops() const
bool DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
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.
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.
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.
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 '('.
bool isInlineSpecified() const
A StaticAssertDecl record.
Captures information about a #pragma weak directive.
void AddPath(StringRef Path, RecordDataImpl &Record)
Add a path to the given record.
helper_expr_const_range destination_exprs() const
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.
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...
File is from a prebuilt module path.
OpenMPLastprivateModifier getKind() const
Lastprivate kind.
Type source information for an attributed type.
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
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.
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 getScopeLoc() const
SourceLocation getScheduleKindLoc()
Get kind location.
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.
SourceLocation getLAngleLoc() const
Defines implementation details of the clang::SourceManager class.
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.
llvm::hash_code hash_value(const clang::SanitizerMask &Arg)
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()
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.
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...
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.
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.
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 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).
struct CXXOpName CXXOperatorName
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 ','.
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
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...
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
void writeOMPClause(OMPClause *C)
unsigned getOffset() const
This file defines OpenMP AST classes for clauses.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
An ObjCForCollectionStmt record.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Record code for the identifier table.
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
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 '('.
Wrapper for source info for arrays.
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 ...
static TypeCode getTypeCodeForTypeClass(Type::TypeClass id)
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.
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 '('.
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
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.
A CXXRewrittenBinaryOperator record.
Encodes a location in the source.
SourceLocation getStarLoc() const
This represents 'hint' clause in the '#pragma omp ...' directive.
SourceLocation CurrentPragmaLocation
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.
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.
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...
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.
This represents 'schedule' clause in the '#pragma omp ...' directive.
NamedDecl * getFoundDecl() const
ASTContext & getASTContext() const LLVM_READONLY
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.
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)
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.
An ObjCEncodeExpr record.
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
Record code for late parsed template functions.
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 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.
SourceLocation getKindLoc() const
Returns the location of the lastprivate kind.
This is a basic class for representing single OpenMP clause.
bool SawDateOrTime() const
Returns true if the preprocessor has seen a use of DATE or TIME in the file so far.
SourceLocation getColonLoc() const
Returns the location of the ':' delimiter.
The internal 'instancetype' typedef.
SourceLocation getRAngleLoc() const
SourceLocation getStarLoc() const
serialization::TypeID getTypeID(QualType T) const
Determine the type ID of an already-emitted type.
IdentifierInfo * getIdentifier() const
Describes the categories of an Objective-C class.
Defines the clang::Module class, which describes a module in the source code.
The AST block, which acts as a container around the full AST block.
SourceLocation getNameModifierLoc() const
Return the location of directive name modifier.
SourceRange getRange() const
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.
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.
SourceLocation getColonLoc() const
Returns the location of the ':' symbol, if any.
void updateOutOfDateSelector(Selector Sel)
void AddSourceLocation(SourceLocation Loc)
Emit a source location.
Expr * getNumForLoops() const
Return the number of associated for-loops.
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.
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
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
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
Record code for the signature that identifiers this AST file.
Record code for referenced selector pool.
std::vector< std::string > MacroIncludes
const MacroInfo * getMacroInfo() const
void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
Record code for the set of non-builtin, special types.
unsigned getTypeExtQualAbbrev() const
A ObjCProtocolDecl record.
OpenMPDirectiveKind getCaptureRegion() const
Get capture region for the stmt in the clause.
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.
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
Record code for the list of other AST files imported by this AST file.
A CXXConversionDecl record.
The input file content hash.
Describes a macro definition within the preprocessing record.
TypeSourceInfo * getClassTInfo() const
The internal '__NSConstantString' typedef.
Record code for the module name.
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Dataflow Directional Tag Classes.
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.
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.
OpenMPDefaultmapClauseKind getDefaultmapKind() const
Get kind of the clause.
const TemplateArgument & getArgument() const
unsigned getNumTokens() const
Return the number of tokens that this macro expands to.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Record code for a file sorted array of DeclIDs in a module.
A CXXBoolLiteralExpr record.
Record code for the array of Objective-C categories (including extensions).
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()
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.
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.
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
IdentifierResolver IdResolver
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
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*.
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
unsigned getNumParams() const
SourceLocation getRBracketLoc() const
SourceLocation getEndLoc() const
Returns the ending location of the clause.
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
Location wrapper for a TemplateArgument.
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.
Defines the clang::FileSystemOptions interface.
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.
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.
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
SourceLocation getProtocolLoc(unsigned i) const
Expr * getSizeExpr() const
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.
SourceLocation getLBracketLoc() const
The template argument is a type.
child_range private_refs()
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
Wraps an ObjCPointerType with source location information.
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.
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
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
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.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
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.
FileID getPredefinesFileID() const
Returns the FileID for the preprocessor predefines.
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
DiagnosticsEngine & getDiagnostics() const
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...
TemplateArgumentLocInfo getLocInfo() const
SourceLocation getEllipsisLoc() const
For a pack expansion, determine the location of the ellipsis.
bool LE(InterpState &S, CodePtr OpPC)
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.
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
SourceLocation getFirstScheduleModifierLoc() const
Get the first modifier location.
unsigned getNumProtocols() const
helper_expr_const_range reduction_ops() const
bool isBuiltinMacro() const
Return true if this macro requires processing before expansion.
Location information for a TemplateArgument.
A ObjCAtDefsFieldDecl record.
Declaration of a class template.
Record code for the offsets of each type.
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.
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.
LineTableInfo & getLineTable()
Retrieve the stored line table.
Specifies the name of the module that will eventually re-export the entities in this module...
void writeExceptionSpecInfo(const FunctionProtoType::ExceptionSpecInfo &esi)
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.
const IdentifierInfo * getScopeName() const
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
SourceLocation getTemplateKWLoc() 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.
void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs)
Emit a template argument list.
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.
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const
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.
PragmaStack< unsigned > PackStack
TypeSpecifierType getWrittenTypeSpec() const
Kind getParsedKind() const
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg)
Emits a template argument location.
AccessSpecifier getAccessSpecifierAsWritten() const
Retrieves the access specifier as written in the source code (which may mean that no access specifier...
Wrapper for source info for builtin types.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
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.
unsigned IsExplicit
Whether this is an explicit submodule.
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.
bool isInline() const
Whether this variable is (C++1z) inline.
A function-like macro definition.
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 '('.
void writeQualType(QualType T)
The global specifier '::'. There is no stored value.
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.
This represents clause 'nontemporal' in the '#pragma omp ...' directives.
const LangOptions & getLangOpts() const
Wrapper for source info for block pointers.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
This class handles loading and caching of source files into memory.
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()
SourceLocation getConceptNameLoc() const
bool Sub(InterpState &S, CodePtr OpPC)
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 getType() const
Return the type wrapped by this type source info.
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 llvm::MemoryBuffer * getBuffer(DiagnosticsEngine &Diag, FileManager &FM, SourceLocation Loc=SourceLocation(), bool *Invalid=nullptr) const
Returns the memory buffer for the associated content.
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.