Skip to content

Commit 548b7fc

Browse files
committed
Merge commit '0276621f8f5a' from llvm.org/main into next
2 parents 9a60156 + 0276621 commit 548b7fc

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,7 @@ class ASTWriter : public ASTDeserializationListener,
548548
void WriteSubStmt(Stmt *S);
549549

550550
void WriteBlockInfoBlock();
551-
void WriteControlBlock(Preprocessor &PP, ASTContext &Context,
552-
StringRef isysroot);
551+
void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
553552

554553
/// Write out the signature and diagnostic options, and return the signature.
555554
void writeUnhashedControlBlock(Preprocessor &PP, ASTContext &Context);

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,10 +1412,12 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
14121412
}
14131413

14141414
/// Write the control block.
1415-
void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1416-
StringRef isysroot) {
1415+
void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
14171416
using namespace llvm;
14181417

1418+
SourceManager &SourceMgr = PP.getSourceManager();
1419+
FileManager &FileMgr = PP.getFileManager();
1420+
14191421
Stream.EnterSubblock(CONTROL_BLOCK_ID, 5);
14201422
RecordData Record;
14211423

@@ -1463,14 +1465,12 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
14631465
SmallString<128> BaseDir;
14641466
if (PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd) {
14651467
// 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(".");
14691469
BaseDir.assign(CWD->getName());
14701470
} else {
14711471
BaseDir.assign(WritingModule->Directory->getName());
14721472
}
1473-
cleanPathForOutput(Context.getSourceManager().getFileManager(), BaseDir);
1473+
cleanPathForOutput(FileMgr, BaseDir);
14741474

14751475
// If the home of the module is the current working directory, then we
14761476
// 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,
15391539
}
15401540

15411541
// CAS include-tree id, for the scanner.
1542-
if (auto ID = Context.getCASIncludeTreeID()) {
1542+
if (auto ID = Context->getCASIncludeTreeID()) {
15431543
auto Abbrev = std::make_shared<BitCodeAbbrev>();
15441544
Abbrev->Add(BitCodeAbbrevOp(CAS_INCLUDE_TREE_ID));
15451545
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
@@ -1548,7 +1548,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
15481548
Stream.EmitRecordWithBlob(AbbrevCode, Record, *ID);
15491549
}
15501550
// CAS filesystem root id, for the scanner.
1551-
if (auto ID = Context.getCASFileSystemRootID()) {
1551+
if (auto ID = Context->getCASFileSystemRootID()) {
15521552
auto Abbrev = std::make_shared<BitCodeAbbrev>();
15531553
Abbrev->Add(BitCodeAbbrevOp(CASFS_ROOT_ID));
15541554
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
@@ -1598,7 +1598,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
15981598

15991599
// Language options.
16001600
Record.clear();
1601-
const LangOptions &LangOpts = Context.getLangOpts();
1601+
const LangOptions &LangOpts = PP.getLangOpts();
16021602
#define LANGOPT(Name, Bits, Default, Description) \
16031603
Record.push_back(LangOpts.Name);
16041604
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
@@ -1635,7 +1635,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
16351635

16361636
// Target options.
16371637
Record.clear();
1638-
const TargetInfo &Target = Context.getTargetInfo();
1638+
const TargetInfo &Target = PP.getTargetInfo();
16391639
const TargetOptions &TargetOpts = Target.getTargetOpts();
16401640
AddString(TargetOpts.Triple, Record);
16411641
AddString(TargetOpts.CPU, Record);
@@ -1712,8 +1712,8 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
17121712
Stream.ExitBlock();
17131713

17141714
// 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())) {
17171717
auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
17181718
FileAbbrev->Add(BitCodeAbbrevOp(ORIGINAL_FILE));
17191719
FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File ID
@@ -1722,16 +1722,15 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
17221722

17231723
Record.clear();
17241724
Record.push_back(ORIGINAL_FILE);
1725-
AddFileID(SM.getMainFileID(), Record);
1725+
AddFileID(SourceMgr.getMainFileID(), Record);
17261726
EmitRecordWithPath(FileAbbrevCode, Record, MainFile->getName());
17271727
}
17281728

17291729
Record.clear();
1730-
AddFileID(SM.getMainFileID(), Record);
1730+
AddFileID(SourceMgr.getMainFileID(), Record);
17311731
Stream.EmitRecord(ORIGINAL_FILE_ID, Record);
17321732

1733-
WriteInputFiles(Context.SourceMgr,
1734-
PP.getHeaderSearchInfo().getHeaderSearchOpts());
1733+
WriteInputFiles(SourceMgr, PP.getHeaderSearchInfo().getHeaderSearchOpts());
17351734
Stream.ExitBlock();
17361735
}
17371736

@@ -5427,7 +5426,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
54275426
PrepareWritingSpecialDecls(SemaRef);
54285427

54295428
// Write the control block
5430-
WriteControlBlock(PP, Context, isysroot);
5429+
WriteControlBlock(PP, isysroot);
54315430

54325431
// Write the remaining AST contents.
54335432
Stream.FlushToWord();

0 commit comments

Comments
 (0)