Skip to content

Commit 0ccc84c

Browse files
committed
[clang][serialization] Reduce ASTWriter::WriteSourceManagerBlock() scope
(cherry picked from commit bcb64e1)
1 parent 5755612 commit 0ccc84c

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
@@ -552,8 +552,7 @@ class ASTWriter : public ASTDeserializationListener,
552552
ASTFileSignature createSignatureForNamedModule() const;
553553

554554
void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts);
555-
void WriteSourceManagerBlock(SourceManager &SourceMgr,
556-
const Preprocessor &PP);
555+
void WriteSourceManagerBlock(SourceManager &SourceMgr);
557556
void WritePreprocessor(const Preprocessor &PP, bool IsModule);
558557
void WriteHeaderSearch(const HeaderSearch &HS);
559558
void WritePreprocessorDetail(PreprocessingRecord &PPRec,

clang/lib/Serialization/ASTWriter.cpp

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

22712270
// Enter the source manager block.
@@ -2353,8 +2352,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
23532352
// We add one to the size so that we capture the trailing NULL
23542353
// that is required by llvm::MemoryBuffer::getMemBuffer (on
23552354
// the reader side).
2356-
std::optional<llvm::MemoryBufferRef> Buffer =
2357-
Content->getBufferOrNone(PP.getDiagnostics(), PP.getFileManager());
2355+
std::optional<llvm::MemoryBufferRef> Buffer = Content->getBufferOrNone(
2356+
SourceMgr.getDiagnostics(), SourceMgr.getFileManager());
23582357
StringRef Name = Buffer ? Buffer->getBufferIdentifier() : "";
23592358
Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
23602359
StringRef(Name.data(), Name.size() + 1));
@@ -2364,8 +2363,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
23642363
if (EmitBlob) {
23652364
// Include the implicit terminating null character in the on-disk buffer
23662365
// if we're writing it uncompressed.
2367-
std::optional<llvm::MemoryBufferRef> Buffer =
2368-
Content->getBufferOrNone(PP.getDiagnostics(), PP.getFileManager());
2366+
std::optional<llvm::MemoryBufferRef> Buffer = Content->getBufferOrNone(
2367+
SourceMgr.getDiagnostics(), SourceMgr.getFileManager());
23692368
if (!Buffer)
23702369
Buffer = llvm::MemoryBufferRef("<<<INVALID BUFFER>>>", "");
23712370
StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
@@ -5512,7 +5511,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
55125511
WriteDeclAndTypes(Context);
55135512

55145513
WriteFileDeclIDsMap();
5515-
WriteSourceManagerBlock(Context.getSourceManager(), PP);
5514+
WriteSourceManagerBlock(PP.getSourceManager());
55165515
WriteComments();
55175516
WritePreprocessor(PP, isModule);
55185517
WriteHeaderSearch(PP.getHeaderSearchInfo());

0 commit comments

Comments
 (0)