@@ -1405,10 +1405,12 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
1405
1405
}
1406
1406
1407
1407
// / Write the control block.
1408
- void ASTWriter::WriteControlBlock (Preprocessor &PP, ASTContext &Context,
1409
- StringRef isysroot) {
1408
+ void ASTWriter::WriteControlBlock (Preprocessor &PP, StringRef isysroot) {
1410
1409
using namespace llvm ;
1411
1410
1411
+ SourceManager &SourceMgr = PP.getSourceManager ();
1412
+ FileManager &FileMgr = PP.getFileManager ();
1413
+
1412
1414
Stream.EnterSubblock (CONTROL_BLOCK_ID, 5 );
1413
1415
RecordData Record;
1414
1416
@@ -1456,14 +1458,12 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1456
1458
SmallString<128 > BaseDir;
1457
1459
if (PP.getHeaderSearchInfo ().getHeaderSearchOpts ().ModuleFileHomeIsCwd ) {
1458
1460
// 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 (" ." );
1462
1462
BaseDir.assign (CWD->getName ());
1463
1463
} else {
1464
1464
BaseDir.assign (WritingModule->Directory ->getName ());
1465
1465
}
1466
- cleanPathForOutput (Context. getSourceManager (). getFileManager () , BaseDir);
1466
+ cleanPathForOutput (FileMgr , BaseDir);
1467
1467
1468
1468
// If the home of the module is the current working directory, then we
1469
1469
// 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,
1532
1532
}
1533
1533
1534
1534
// CAS include-tree id, for the scanner.
1535
- if (auto ID = Context. getCASIncludeTreeID ()) {
1535
+ if (auto ID = Context-> getCASIncludeTreeID ()) {
1536
1536
auto Abbrev = std::make_shared<BitCodeAbbrev>();
1537
1537
Abbrev->Add (BitCodeAbbrevOp (CAS_INCLUDE_TREE_ID));
1538
1538
Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Blob));
@@ -1541,7 +1541,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1541
1541
Stream.EmitRecordWithBlob (AbbrevCode, Record, *ID);
1542
1542
}
1543
1543
// CAS filesystem root id, for the scanner.
1544
- if (auto ID = Context. getCASFileSystemRootID ()) {
1544
+ if (auto ID = Context-> getCASFileSystemRootID ()) {
1545
1545
auto Abbrev = std::make_shared<BitCodeAbbrev>();
1546
1546
Abbrev->Add (BitCodeAbbrevOp (CASFS_ROOT_ID));
1547
1547
Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Blob));
@@ -1591,7 +1591,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1591
1591
1592
1592
// Language options.
1593
1593
Record.clear ();
1594
- const LangOptions &LangOpts = Context .getLangOpts ();
1594
+ const LangOptions &LangOpts = PP .getLangOpts ();
1595
1595
#define LANGOPT (Name, Bits, Default, Description ) \
1596
1596
Record.push_back (LangOpts.Name );
1597
1597
#define ENUM_LANGOPT (Name, Type, Bits, Default, Description ) \
@@ -1628,7 +1628,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1628
1628
1629
1629
// Target options.
1630
1630
Record.clear ();
1631
- const TargetInfo &Target = Context .getTargetInfo ();
1631
+ const TargetInfo &Target = PP .getTargetInfo ();
1632
1632
const TargetOptions &TargetOpts = Target.getTargetOpts ();
1633
1633
AddString (TargetOpts.Triple , Record);
1634
1634
AddString (TargetOpts.CPU , Record);
@@ -1705,8 +1705,8 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1705
1705
Stream.ExitBlock ();
1706
1706
1707
1707
// 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 ())) {
1710
1710
auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1711
1711
FileAbbrev->Add (BitCodeAbbrevOp (ORIGINAL_FILE));
1712
1712
FileAbbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 )); // File ID
@@ -1715,16 +1715,15 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1715
1715
1716
1716
Record.clear ();
1717
1717
Record.push_back (ORIGINAL_FILE);
1718
- AddFileID (SM .getMainFileID (), Record);
1718
+ AddFileID (SourceMgr .getMainFileID (), Record);
1719
1719
EmitRecordWithPath (FileAbbrevCode, Record, MainFile->getName ());
1720
1720
}
1721
1721
1722
1722
Record.clear ();
1723
- AddFileID (SM .getMainFileID (), Record);
1723
+ AddFileID (SourceMgr .getMainFileID (), Record);
1724
1724
Stream.EmitRecord (ORIGINAL_FILE_ID, Record);
1725
1725
1726
- WriteInputFiles (Context.SourceMgr ,
1727
- PP.getHeaderSearchInfo ().getHeaderSearchOpts ());
1726
+ WriteInputFiles (SourceMgr, PP.getHeaderSearchInfo ().getHeaderSearchOpts ());
1728
1727
Stream.ExitBlock ();
1729
1728
}
1730
1729
@@ -5418,7 +5417,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
5418
5417
PrepareWritingSpecialDecls (SemaRef);
5419
5418
5420
5419
// Write the control block
5421
- WriteControlBlock (PP, Context, isysroot);
5420
+ WriteControlBlock (PP, isysroot);
5422
5421
5423
5422
// Write the remaining AST contents.
5424
5423
Stream.FlushToWord ();
0 commit comments