@@ -1269,8 +1269,7 @@ ASTFileSignature ASTWriter::backpatchSignature() {
12691269 return Signature;
12701270}
12711271
1272- void ASTWriter::writeUnhashedControlBlock (Preprocessor &PP,
1273- ASTContext &Context) {
1272+ void ASTWriter::writeUnhashedControlBlock (Preprocessor &PP) {
12741273 using namespace llvm ;
12751274
12761275 // Flush first to prepare the PCM hash (signature).
@@ -1323,7 +1322,7 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
13231322 const auto &HSOpts = PP.getHeaderSearchInfo ().getHeaderSearchOpts ();
13241323
13251324 // Diagnostic options.
1326- const auto &Diags = Context .getDiagnostics ();
1325+ const auto &Diags = PP .getDiagnostics ();
13271326 const DiagnosticOptions &DiagOpts = Diags.getDiagnosticOptions ();
13281327 if (!HSOpts.ModulesSkipDiagnosticOptions ) {
13291328#define DIAGOPT (Name, Bits, Default ) Record.push_back(DiagOpts.Name);
@@ -1403,10 +1402,12 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
14031402}
14041403
14051404// / Write the control block.
1406- void ASTWriter::WriteControlBlock (Preprocessor &PP, ASTContext &Context,
1407- StringRef isysroot) {
1405+ void ASTWriter::WriteControlBlock (Preprocessor &PP, StringRef isysroot) {
14081406 using namespace llvm ;
14091407
1408+ SourceManager &SourceMgr = PP.getSourceManager ();
1409+ FileManager &FileMgr = PP.getFileManager ();
1410+
14101411 Stream.EnterSubblock (CONTROL_BLOCK_ID, 5 );
14111412 RecordData Record;
14121413
@@ -1454,14 +1455,12 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
14541455 SmallString<128 > BaseDir;
14551456 if (PP.getHeaderSearchInfo ().getHeaderSearchOpts ().ModuleFileHomeIsCwd ) {
14561457 // Use the current working directory as the base path for all inputs.
1457- auto CWD =
1458- Context.getSourceManager ().getFileManager ().getOptionalDirectoryRef (
1459- " ." );
1458+ auto CWD = FileMgr.getOptionalDirectoryRef (" ." );
14601459 BaseDir.assign (CWD->getName ());
14611460 } else {
14621461 BaseDir.assign (WritingModule->Directory ->getName ());
14631462 }
1464- cleanPathForOutput (Context. getSourceManager (). getFileManager () , BaseDir);
1463+ cleanPathForOutput (FileMgr , BaseDir);
14651464
14661465 // If the home of the module is the current working directory, then we
14671466 // want to pick up the cwd of the build process loading the module, not
@@ -1554,7 +1553,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
15541553
15551554 // Language options.
15561555 Record.clear ();
1557- const LangOptions &LangOpts = Context .getLangOpts ();
1556+ const LangOptions &LangOpts = PP .getLangOpts ();
15581557#define LANGOPT (Name, Bits, Default, Description ) \
15591558 Record.push_back (LangOpts.Name );
15601559#define ENUM_LANGOPT (Name, Type, Bits, Default, Description ) \
@@ -1591,7 +1590,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
15911590
15921591 // Target options.
15931592 Record.clear ();
1594- const TargetInfo &Target = Context .getTargetInfo ();
1593+ const TargetInfo &Target = PP .getTargetInfo ();
15951594 const TargetOptions &TargetOpts = Target.getTargetOpts ();
15961595 AddString (TargetOpts.Triple , Record);
15971596 AddString (TargetOpts.CPU , Record);
@@ -1609,8 +1608,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
16091608
16101609 // File system options.
16111610 Record.clear ();
1612- const FileSystemOptions &FSOpts =
1613- Context.getSourceManager ().getFileManager ().getFileSystemOpts ();
1611+ const FileSystemOptions &FSOpts = FileMgr.getFileSystemOpts ();
16141612 AddString (FSOpts.WorkingDir , Record);
16151613 Stream.EmitRecord (FILE_SYSTEM_OPTIONS, Record);
16161614
@@ -1675,8 +1673,8 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
16751673 Stream.ExitBlock ();
16761674
16771675 // Original file name and file ID
1678- SourceManager &SM = Context. getSourceManager ();
1679- if ( auto MainFile = SM .getFileEntryRefForID (SM .getMainFileID ())) {
1676+ if ( auto MainFile =
1677+ SourceMgr .getFileEntryRefForID (SourceMgr .getMainFileID ())) {
16801678 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
16811679 FileAbbrev->Add (BitCodeAbbrevOp (ORIGINAL_FILE));
16821680 FileAbbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 )); // File ID
@@ -1685,16 +1683,15 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
16851683
16861684 Record.clear ();
16871685 Record.push_back (ORIGINAL_FILE);
1688- AddFileID (SM .getMainFileID (), Record);
1686+ AddFileID (SourceMgr .getMainFileID (), Record);
16891687 EmitRecordWithPath (FileAbbrevCode, Record, MainFile->getName ());
16901688 }
16911689
16921690 Record.clear ();
1693- AddFileID (SM .getMainFileID (), Record);
1691+ AddFileID (SourceMgr .getMainFileID (), Record);
16941692 Stream.EmitRecord (ORIGINAL_FILE_ID, Record);
16951693
1696- WriteInputFiles (Context.SourceMgr ,
1697- PP.getHeaderSearchInfo ().getHeaderSearchOpts ());
1694+ WriteInputFiles (SourceMgr, PP.getHeaderSearchInfo ().getHeaderSearchOpts ());
16981695 Stream.ExitBlock ();
16991696}
17001697
@@ -2234,8 +2231,7 @@ static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
22342231// / entries for files that we actually need. In the common case (no
22352232// / errors), we probably won't have to create file entries for any of
22362233// / the files in the AST.
2237- void ASTWriter::WriteSourceManagerBlock (SourceManager &SourceMgr,
2238- const Preprocessor &PP) {
2234+ void ASTWriter::WriteSourceManagerBlock (SourceManager &SourceMgr) {
22392235 RecordData Record;
22402236
22412237 // Enter the source manager block.
@@ -2323,8 +2319,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
23232319 // We add one to the size so that we capture the trailing NULL
23242320 // that is required by llvm::MemoryBuffer::getMemBuffer (on
23252321 // the reader side).
2326- std::optional<llvm::MemoryBufferRef> Buffer =
2327- Content-> getBufferOrNone (PP .getDiagnostics (), PP .getFileManager ());
2322+ std::optional<llvm::MemoryBufferRef> Buffer = Content-> getBufferOrNone (
2323+ SourceMgr .getDiagnostics (), SourceMgr .getFileManager ());
23282324 StringRef Name = Buffer ? Buffer->getBufferIdentifier () : " " ;
23292325 Stream.EmitRecordWithBlob (SLocBufferAbbrv, Record,
23302326 StringRef (Name.data (), Name.size () + 1 ));
@@ -2334,8 +2330,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
23342330 if (EmitBlob) {
23352331 // Include the implicit terminating null character in the on-disk buffer
23362332 // if we're writing it uncompressed.
2337- std::optional<llvm::MemoryBufferRef> Buffer =
2338- Content-> getBufferOrNone (PP .getDiagnostics (), PP .getFileManager ());
2333+ std::optional<llvm::MemoryBufferRef> Buffer = Content-> getBufferOrNone (
2334+ SourceMgr .getDiagnostics (), SourceMgr .getFileManager ());
23392335 if (!Buffer)
23402336 Buffer = llvm::MemoryBufferRef (" <<<INVALID BUFFER>>>" , " " );
23412337 StringRef Blob (Buffer->getBufferStart (), Buffer->getBufferSize () + 1 );
@@ -5371,7 +5367,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
53715367 // SourceLocations or FileIDs depends on it.
53725368 computeNonAffectingInputFiles ();
53735369
5374- writeUnhashedControlBlock (PP, Context );
5370+ writeUnhashedControlBlock (PP);
53755371
53765372 // Don't reuse type ID and Identifier ID from readers for C++ standard named
53775373 // modules since we want to support no-transitive-change model for named
@@ -5433,7 +5429,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
54335429 PrepareWritingSpecialDecls (SemaRef);
54345430
54355431 // Write the control block
5436- WriteControlBlock (PP, Context, isysroot);
5432+ WriteControlBlock (PP, isysroot);
54375433
54385434 // Write the remaining AST contents.
54395435 Stream.FlushToWord ();
@@ -5526,7 +5522,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
55265522 WriteDeclAndTypes (Context);
55275523
55285524 WriteFileDeclIDsMap ();
5529- WriteSourceManagerBlock (Context .getSourceManager (), PP );
5525+ WriteSourceManagerBlock (PP .getSourceManager ());
55305526 WriteComments ();
55315527 WritePreprocessor (PP, isModule);
55325528 WriteHeaderSearch (PP.getHeaderSearchInfo ());
0 commit comments