summaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-01-27 22:06:42 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-01-27 22:06:42 +0000
commit6f8fc217eaa12bf657be1c6468ed9938d10168b3 (patch)
treea1fd89b864d9b93e2ad68fe1dcf7afee2e3c8d76 /clang/lib/Serialization/ASTWriter.cpp
parent77fc4c146f0870ffb09c1afb823ccbe742c5e6ff (diff)
Vendor import of llvm-project main llvmorg-14-init-17616-g024a1fab5c35.vendor/llvm-project/llvmorg-14-init-17616-g024a1fab5c35
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp47
1 files changed, 44 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 65a780e67510..763fc9537c04 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -427,7 +427,8 @@ void TypeLocWriter::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
}
void TypeLocWriter::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
- Record.AddSourceLocation(TL.getNameLoc());
+ Record.AddSourceLocation(TL.getDecltypeLoc());
+ Record.AddSourceLocation(TL.getRParenLoc());
}
void TypeLocWriter::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
@@ -451,6 +452,9 @@ void TypeLocWriter::VisitAutoTypeLoc(AutoTypeLoc TL) {
Record.AddTemplateArgumentLocInfo(TL.getTypePtr()->getArg(I).getKind(),
TL.getArgLocInfo(I));
}
+ Record.push_back(TL.isDecltypeAuto());
+ if (TL.isDecltypeAuto())
+ Record.AddSourceLocation(TL.getRParenLoc());
}
void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
@@ -858,6 +862,7 @@ void ASTWriter::WriteBlockInfoBlock() {
RECORD(CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH);
RECORD(PP_CONDITIONAL_STACK);
RECORD(DECLS_TO_CHECK_FOR_DEFERRED_DIAGS);
+ RECORD(PP_INCLUDED_FILES);
// SourceManager Block.
BLOCK(SOURCE_MANAGER_BLOCK);
@@ -1769,7 +1774,7 @@ namespace {
std::pair<unsigned, unsigned>
EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) {
unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
- unsigned DataLen = 1 + 2 + 4 + 4;
+ unsigned DataLen = 1 + 4 + 4;
for (auto ModInfo : Data.KnownHeaders)
if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
DataLen += 4;
@@ -1801,7 +1806,6 @@ namespace {
| (Data.HFI.DirInfo << 1)
| Data.HFI.IndexHeaderMapHeader;
LE.write<uint8_t>(Flags);
- LE.write<uint16_t>(Data.HFI.NumIncludes);
if (!Data.HFI.ControllingMacro)
LE.write<uint32_t>(Data.HFI.ControllingMacroID);
@@ -2250,6 +2254,29 @@ static bool shouldIgnoreMacro(MacroDirective *MD, bool IsModule,
return false;
}
+void ASTWriter::writeIncludedFiles(raw_ostream &Out, const Preprocessor &PP) {
+ using namespace llvm::support;
+
+ const Preprocessor::IncludedFilesSet &IncludedFiles = PP.getIncludedFiles();
+
+ std::vector<uint32_t> IncludedInputFileIDs;
+ IncludedInputFileIDs.reserve(IncludedFiles.size());
+
+ for (const FileEntry *File : IncludedFiles) {
+ auto InputFileIt = InputFileIDs.find(File);
+ if (InputFileIt == InputFileIDs.end())
+ continue;
+ IncludedInputFileIDs.push_back(InputFileIt->second);
+ }
+
+ llvm::sort(IncludedInputFileIDs);
+
+ endian::Writer LE(Out, little);
+ LE.write<uint32_t>(IncludedInputFileIDs.size());
+ for (uint32_t ID : IncludedInputFileIDs)
+ LE.write<uint32_t>(ID);
+}
+
/// Writes the block containing the serialized form of the
/// preprocessor.
void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
@@ -2458,6 +2485,20 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
MacroOffsetsBase - ASTBlockStartOffset};
Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record, bytes(MacroOffsets));
}
+
+ {
+ auto Abbrev = std::make_shared<BitCodeAbbrev>();
+ Abbrev->Add(BitCodeAbbrevOp(PP_INCLUDED_FILES));
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
+ unsigned IncludedFilesAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
+
+ SmallString<2048> Buffer;
+ raw_svector_ostream Out(Buffer);
+ writeIncludedFiles(Out, PP);
+ RecordData::value_type Record[] = {PP_INCLUDED_FILES};
+ Stream.EmitRecordWithBlob(IncludedFilesAbbrev, Record, Buffer.data(),
+ Buffer.size());
+ }
}
void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec,