@@ -1405,10 +1405,12 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
14051405}
14061406
14071407// / Write the control block.
1408- void ASTWriter::WriteControlBlock (Preprocessor &PP, ASTContext &Context,
1409- StringRef isysroot) {
1408+ void ASTWriter::WriteControlBlock (Preprocessor &PP, StringRef isysroot) {
14101409 using namespace llvm ;
14111410
1411+ SourceManager &SourceMgr = PP.getSourceManager ();
1412+ FileManager &FileMgr = PP.getFileManager ();
1413+
14121414 Stream.EnterSubblock (CONTROL_BLOCK_ID, 5 );
14131415 RecordData Record;
14141416
@@ -1456,14 +1458,12 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
14561458 SmallString<128 > BaseDir;
14571459 if (PP.getHeaderSearchInfo ().getHeaderSearchOpts ().ModuleFileHomeIsCwd ) {
14581460 // Use the current working directory as the base path for all inputs.
1459- auto CWD =
1460- Context.getSourceManager ().getFileManager ().getOptionalDirectoryRef (
1461- " ." );
1461+ auto CWD = FileMgr.getOptionalDirectoryRef (" ." );
14621462 BaseDir.assign (CWD->getName ());
14631463 } else {
14641464 BaseDir.assign (WritingModule->Directory ->getName ());
14651465 }
1466- cleanPathForOutput (Context. getSourceManager (). getFileManager () , BaseDir);
1466+ cleanPathForOutput (FileMgr , BaseDir);
14671467
14681468 // If the home of the module is the current working directory, then we
14691469 // want to pick up the cwd of the build process loading the module, not
@@ -1532,7 +1532,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
15321532 }
15331533
15341534 // CAS include-tree id, for the scanner.
1535- if (auto ID = Context. getCASIncludeTreeID ()) {
1535+ if (auto ID = Context-> getCASIncludeTreeID ()) {
15361536 auto Abbrev = std::make_shared<BitCodeAbbrev>();
15371537 Abbrev->Add (BitCodeAbbrevOp (CAS_INCLUDE_TREE_ID));
15381538 Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Blob));
@@ -1541,7 +1541,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
15411541 Stream.EmitRecordWithBlob (AbbrevCode, Record, *ID);
15421542 }
15431543 // CAS filesystem root id, for the scanner.
1544- if (auto ID = Context. getCASFileSystemRootID ()) {
1544+ if (auto ID = Context-> getCASFileSystemRootID ()) {
15451545 auto Abbrev = std::make_shared<BitCodeAbbrev>();
15461546 Abbrev->Add (BitCodeAbbrevOp (CASFS_ROOT_ID));
15471547 Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Blob));
@@ -1591,7 +1591,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
15911591
15921592 // Language options.
15931593 Record.clear ();
1594- const LangOptions &LangOpts = Context .getLangOpts ();
1594+ const LangOptions &LangOpts = PP .getLangOpts ();
15951595#define LANGOPT (Name, Bits, Default, Description ) \
15961596 Record.push_back (LangOpts.Name );
15971597#define ENUM_LANGOPT (Name, Type, Bits, Default, Description ) \
@@ -1628,7 +1628,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
16281628
16291629 // Target options.
16301630 Record.clear ();
1631- const TargetInfo &Target = Context .getTargetInfo ();
1631+ const TargetInfo &Target = PP .getTargetInfo ();
16321632 const TargetOptions &TargetOpts = Target.getTargetOpts ();
16331633 AddString (TargetOpts.Triple , Record);
16341634 AddString (TargetOpts.CPU , Record);
@@ -1705,8 +1705,8 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
17051705 Stream.ExitBlock ();
17061706
17071707 // Original file name and file ID
1708- SourceManager &SM = Context. getSourceManager ();
1709- if ( auto MainFile = SM .getFileEntryRefForID (SM .getMainFileID ())) {
1708+ if ( auto MainFile =
1709+ SourceMgr .getFileEntryRefForID (SourceMgr .getMainFileID ())) {
17101710 auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
17111711 FileAbbrev->Add (BitCodeAbbrevOp (ORIGINAL_FILE));
17121712 FileAbbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 )); // File ID
@@ -1715,16 +1715,15 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
17151715
17161716 Record.clear ();
17171717 Record.push_back (ORIGINAL_FILE);
1718- AddFileID (SM .getMainFileID (), Record);
1718+ AddFileID (SourceMgr .getMainFileID (), Record);
17191719 EmitRecordWithPath (FileAbbrevCode, Record, MainFile->getName ());
17201720 }
17211721
17221722 Record.clear ();
1723- AddFileID (SM .getMainFileID (), Record);
1723+ AddFileID (SourceMgr .getMainFileID (), Record);
17241724 Stream.EmitRecord (ORIGINAL_FILE_ID, Record);
17251725
1726- WriteInputFiles (Context.SourceMgr ,
1727- PP.getHeaderSearchInfo ().getHeaderSearchOpts ());
1726+ WriteInputFiles (SourceMgr, PP.getHeaderSearchInfo ().getHeaderSearchOpts ());
17281727 Stream.ExitBlock ();
17291728}
17301729
@@ -5418,7 +5417,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
54185417 PrepareWritingSpecialDecls (SemaRef);
54195418
54205419 // Write the control block
5421- WriteControlBlock (PP, Context, isysroot);
5420+ WriteControlBlock (PP, isysroot);
54225421
54235422 // Write the remaining AST contents.
54245423 Stream.FlushToWord ();
0 commit comments