@@ -1412,10 +1412,12 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
1412
1412
}
1413
1413
1414
1414
// / Write the control block.
1415
- void ASTWriter::WriteControlBlock (Preprocessor &PP, ASTContext &Context,
1416
- StringRef isysroot) {
1415
+ void ASTWriter::WriteControlBlock (Preprocessor &PP, StringRef isysroot) {
1417
1416
using namespace llvm ;
1418
1417
1418
+ SourceManager &SourceMgr = PP.getSourceManager ();
1419
+ FileManager &FileMgr = PP.getFileManager ();
1420
+
1419
1421
Stream.EnterSubblock (CONTROL_BLOCK_ID, 5 );
1420
1422
RecordData Record;
1421
1423
@@ -1463,14 +1465,12 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1463
1465
SmallString<128 > BaseDir;
1464
1466
if (PP.getHeaderSearchInfo ().getHeaderSearchOpts ().ModuleFileHomeIsCwd ) {
1465
1467
// Use the current working directory as the base path for all inputs.
1466
- auto CWD =
1467
- Context.getSourceManager ().getFileManager ().getOptionalDirectoryRef (
1468
- " ." );
1468
+ auto CWD = FileMgr.getOptionalDirectoryRef (" ." );
1469
1469
BaseDir.assign (CWD->getName ());
1470
1470
} else {
1471
1471
BaseDir.assign (WritingModule->Directory ->getName ());
1472
1472
}
1473
- cleanPathForOutput (Context. getSourceManager (). getFileManager () , BaseDir);
1473
+ cleanPathForOutput (FileMgr , BaseDir);
1474
1474
1475
1475
// If the home of the module is the current working directory, then we
1476
1476
// want to pick up the cwd of the build process loading the module, not
@@ -1539,7 +1539,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1539
1539
}
1540
1540
1541
1541
// CAS include-tree id, for the scanner.
1542
- if (auto ID = Context. getCASIncludeTreeID ()) {
1542
+ if (auto ID = Context-> getCASIncludeTreeID ()) {
1543
1543
auto Abbrev = std::make_shared<BitCodeAbbrev>();
1544
1544
Abbrev->Add (BitCodeAbbrevOp (CAS_INCLUDE_TREE_ID));
1545
1545
Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Blob));
@@ -1548,7 +1548,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1548
1548
Stream.EmitRecordWithBlob (AbbrevCode, Record, *ID);
1549
1549
}
1550
1550
// CAS filesystem root id, for the scanner.
1551
- if (auto ID = Context. getCASFileSystemRootID ()) {
1551
+ if (auto ID = Context-> getCASFileSystemRootID ()) {
1552
1552
auto Abbrev = std::make_shared<BitCodeAbbrev>();
1553
1553
Abbrev->Add (BitCodeAbbrevOp (CASFS_ROOT_ID));
1554
1554
Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Blob));
@@ -1598,7 +1598,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1598
1598
1599
1599
// Language options.
1600
1600
Record.clear ();
1601
- const LangOptions &LangOpts = Context .getLangOpts ();
1601
+ const LangOptions &LangOpts = PP .getLangOpts ();
1602
1602
#define LANGOPT (Name, Bits, Default, Description ) \
1603
1603
Record.push_back (LangOpts.Name );
1604
1604
#define ENUM_LANGOPT (Name, Type, Bits, Default, Description ) \
@@ -1635,7 +1635,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1635
1635
1636
1636
// Target options.
1637
1637
Record.clear ();
1638
- const TargetInfo &Target = Context .getTargetInfo ();
1638
+ const TargetInfo &Target = PP .getTargetInfo ();
1639
1639
const TargetOptions &TargetOpts = Target.getTargetOpts ();
1640
1640
AddString (TargetOpts.Triple , Record);
1641
1641
AddString (TargetOpts.CPU , Record);
@@ -1712,8 +1712,8 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1712
1712
Stream.ExitBlock ();
1713
1713
1714
1714
// Original file name and file ID
1715
- SourceManager &SM = Context. getSourceManager ();
1716
- if ( auto MainFile = SM .getFileEntryRefForID (SM .getMainFileID ())) {
1715
+ if ( auto MainFile =
1716
+ SourceMgr .getFileEntryRefForID (SourceMgr .getMainFileID ())) {
1717
1717
auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
1718
1718
FileAbbrev->Add (BitCodeAbbrevOp (ORIGINAL_FILE));
1719
1719
FileAbbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 )); // File ID
@@ -1722,16 +1722,15 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1722
1722
1723
1723
Record.clear ();
1724
1724
Record.push_back (ORIGINAL_FILE);
1725
- AddFileID (SM .getMainFileID (), Record);
1725
+ AddFileID (SourceMgr .getMainFileID (), Record);
1726
1726
EmitRecordWithPath (FileAbbrevCode, Record, MainFile->getName ());
1727
1727
}
1728
1728
1729
1729
Record.clear ();
1730
- AddFileID (SM .getMainFileID (), Record);
1730
+ AddFileID (SourceMgr .getMainFileID (), Record);
1731
1731
Stream.EmitRecord (ORIGINAL_FILE_ID, Record);
1732
1732
1733
- WriteInputFiles (Context.SourceMgr ,
1734
- PP.getHeaderSearchInfo ().getHeaderSearchOpts ());
1733
+ WriteInputFiles (SourceMgr, PP.getHeaderSearchInfo ().getHeaderSearchOpts ());
1735
1734
Stream.ExitBlock ();
1736
1735
}
1737
1736
@@ -5427,7 +5426,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
5427
5426
PrepareWritingSpecialDecls (SemaRef);
5428
5427
5429
5428
// Write the control block
5430
- WriteControlBlock (PP, Context, isysroot);
5429
+ WriteControlBlock (PP, isysroot);
5431
5430
5432
5431
// Write the remaining AST contents.
5433
5432
Stream.FlushToWord ();
0 commit comments