@@ -1403,10 +1403,12 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
1403
1403
}
1404
1404
1405
1405
// / Write the control block.
1406
- void ASTWriter::WriteControlBlock (Preprocessor &PP, ASTContext &Context,
1407
- StringRef isysroot) {
1406
+ void ASTWriter::WriteControlBlock (Preprocessor &PP, StringRef isysroot) {
1408
1407
using namespace llvm ;
1409
1408
1409
+ SourceManager &SourceMgr = PP.getSourceManager ();
1410
+ FileManager &FileMgr = PP.getFileManager ();
1411
+
1410
1412
Stream.EnterSubblock (CONTROL_BLOCK_ID, 5 );
1411
1413
RecordData Record;
1412
1414
@@ -1454,14 +1456,12 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1454
1456
SmallString<128 > BaseDir;
1455
1457
if (PP.getHeaderSearchInfo ().getHeaderSearchOpts ().ModuleFileHomeIsCwd ) {
1456
1458
// Use the current working directory as the base path for all inputs.
1457
- auto CWD =
1458
- Context.getSourceManager ().getFileManager ().getOptionalDirectoryRef (
1459
- " ." );
1459
+ auto CWD = FileMgr.getOptionalDirectoryRef (" ." );
1460
1460
BaseDir.assign (CWD->getName ());
1461
1461
} else {
1462
1462
BaseDir.assign (WritingModule->Directory ->getName ());
1463
1463
}
1464
- cleanPathForOutput (Context. getSourceManager (). getFileManager () , BaseDir);
1464
+ cleanPathForOutput (FileMgr , BaseDir);
1465
1465
1466
1466
// If the home of the module is the current working directory, then we
1467
1467
// want to pick up the cwd of the build process loading the module, not
@@ -1554,7 +1554,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1554
1554
1555
1555
// Language options.
1556
1556
Record.clear ();
1557
- const LangOptions &LangOpts = Context .getLangOpts ();
1557
+ const LangOptions &LangOpts = PP .getLangOpts ();
1558
1558
#define LANGOPT (Name, Bits, Default, Description ) \
1559
1559
Record.push_back (LangOpts.Name );
1560
1560
#define ENUM_LANGOPT (Name, Type, Bits, Default, Description ) \
@@ -1591,7 +1591,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1591
1591
1592
1592
// Target options.
1593
1593
Record.clear ();
1594
- const TargetInfo &Target = Context .getTargetInfo ();
1594
+ const TargetInfo &Target = PP .getTargetInfo ();
1595
1595
const TargetOptions &TargetOpts = Target.getTargetOpts ();
1596
1596
AddString (TargetOpts.Triple , Record);
1597
1597
AddString (TargetOpts.CPU , Record);
@@ -1609,8 +1609,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1609
1609
1610
1610
// File system options.
1611
1611
Record.clear ();
1612
- const FileSystemOptions &FSOpts =
1613
- Context.getSourceManager ().getFileManager ().getFileSystemOpts ();
1612
+ const FileSystemOptions &FSOpts = FileMgr.getFileSystemOpts ();
1614
1613
AddString (FSOpts.WorkingDir , Record);
1615
1614
Stream.EmitRecord (FILE_SYSTEM_OPTIONS, Record);
1616
1615
@@ -1675,8 +1674,8 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1675
1674
Stream.ExitBlock ();
1676
1675
1677
1676
// Original file name and file ID
1678
- SourceManager &SM = Context. getSourceManager ();
1679
- if ( auto MainFile = SM .getFileEntryRefForID (SM .getMainFileID ())) {
1677
+ if ( auto MainFile =
1678
+ SourceMgr .getFileEntryRefForID (SourceMgr .getMainFileID ())) {
1680
1679
auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1681
1680
FileAbbrev->Add (BitCodeAbbrevOp (ORIGINAL_FILE));
1682
1681
FileAbbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 )); // File ID
@@ -1685,16 +1684,15 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1685
1684
1686
1685
Record.clear ();
1687
1686
Record.push_back (ORIGINAL_FILE);
1688
- AddFileID (SM .getMainFileID (), Record);
1687
+ AddFileID (SourceMgr .getMainFileID (), Record);
1689
1688
EmitRecordWithPath (FileAbbrevCode, Record, MainFile->getName ());
1690
1689
}
1691
1690
1692
1691
Record.clear ();
1693
- AddFileID (SM .getMainFileID (), Record);
1692
+ AddFileID (SourceMgr .getMainFileID (), Record);
1694
1693
Stream.EmitRecord (ORIGINAL_FILE_ID, Record);
1695
1694
1696
- WriteInputFiles (Context.SourceMgr ,
1697
- PP.getHeaderSearchInfo ().getHeaderSearchOpts ());
1695
+ WriteInputFiles (SourceMgr, PP.getHeaderSearchInfo ().getHeaderSearchOpts ());
1698
1696
Stream.ExitBlock ();
1699
1697
}
1700
1698
@@ -5432,7 +5430,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
5432
5430
PrepareWritingSpecialDecls (SemaRef);
5433
5431
5434
5432
// Write the control block
5435
- WriteControlBlock (PP, Context, isysroot);
5433
+ WriteControlBlock (PP, isysroot);
5436
5434
5437
5435
// Write the remaining AST contents.
5438
5436
Stream.FlushToWord ();
0 commit comments