Skip to content

Commit bcb64e1

Browse files
committed
[clang][serialization] Reduce ASTWriter::WriteSourceManagerBlock() scope
1 parent b57cbbc commit bcb64e1

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,7 @@ class ASTWriter : public ASTDeserializationListener,
560560
ASTFileSignature createSignatureForNamedModule() const;
561561

562562
void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts);
563-
void WriteSourceManagerBlock(SourceManager &SourceMgr,
564-
const Preprocessor &PP);
563+
void WriteSourceManagerBlock(SourceManager &SourceMgr);
565564
void WritePreprocessor(const Preprocessor &PP, bool IsModule);
566565
void WriteHeaderSearch(const HeaderSearch &HS);
567566
void WritePreprocessorDetail(PreprocessingRecord &PPRec,

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,8 +2234,7 @@ static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
22342234
/// entries for files that we actually need. In the common case (no
22352235
/// errors), we probably won't have to create file entries for any of
22362236
/// the files in the AST.
2237-
void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
2238-
const Preprocessor &PP) {
2237+
void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
22392238
RecordData Record;
22402239

22412240
// Enter the source manager block.
@@ -2323,8 +2322,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
23232322
// We add one to the size so that we capture the trailing NULL
23242323
// that is required by llvm::MemoryBuffer::getMemBuffer (on
23252324
// the reader side).
2326-
std::optional<llvm::MemoryBufferRef> Buffer =
2327-
Content->getBufferOrNone(PP.getDiagnostics(), PP.getFileManager());
2325+
std::optional<llvm::MemoryBufferRef> Buffer = Content->getBufferOrNone(
2326+
SourceMgr.getDiagnostics(), SourceMgr.getFileManager());
23282327
StringRef Name = Buffer ? Buffer->getBufferIdentifier() : "";
23292328
Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
23302329
StringRef(Name.data(), Name.size() + 1));
@@ -2334,8 +2333,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
23342333
if (EmitBlob) {
23352334
// Include the implicit terminating null character in the on-disk buffer
23362335
// if we're writing it uncompressed.
2337-
std::optional<llvm::MemoryBufferRef> Buffer =
2338-
Content->getBufferOrNone(PP.getDiagnostics(), PP.getFileManager());
2336+
std::optional<llvm::MemoryBufferRef> Buffer = Content->getBufferOrNone(
2337+
SourceMgr.getDiagnostics(), SourceMgr.getFileManager());
23392338
if (!Buffer)
23402339
Buffer = llvm::MemoryBufferRef("<<<INVALID BUFFER>>>", "");
23412340
StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
@@ -5526,7 +5525,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
55265525
WriteDeclAndTypes(Context);
55275526

55285527
WriteFileDeclIDsMap();
5529-
WriteSourceManagerBlock(Context.getSourceManager(), PP);
5528+
WriteSourceManagerBlock(PP.getSourceManager());
55305529
WriteComments();
55315530
WritePreprocessor(PP, isModule);
55325531
WriteHeaderSearch(PP.getHeaderSearchInfo());

0 commit comments

Comments
 (0)