Skip to content

Commit 5e66ce9

Browse files
committed
[clang][serialization] Make ASTWriter accept Preprocessor only
1 parent 27985cf commit 5e66ce9

File tree

4 files changed

+114
-87
lines changed

4 files changed

+114
-87
lines changed

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ class ASTWriter : public ASTDeserializationListener,
561561
void WriteHeaderSearch(const HeaderSearch &HS);
562562
void WritePreprocessorDetail(PreprocessingRecord &PPRec,
563563
uint64_t MacroOffsetsBase);
564-
void WriteSubmodules(Module *WritingModule, ASTContext &Context);
564+
void WriteSubmodules(Module *WritingModule, ASTContext *Context);
565565

566566
void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
567567
bool isModule);
@@ -582,7 +582,7 @@ class ASTWriter : public ASTDeserializationListener,
582582
void WriteComments(ASTContext &Context);
583583
void WriteSelectors(Sema &SemaRef);
584584
void WriteReferencedSelectorsPool(Sema &SemaRef);
585-
void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver,
585+
void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver *IdResolver,
586586
bool IsModule);
587587
void WriteDeclAndTypes(ASTContext &Context);
588588
void PrepareWritingSpecialDecls(Sema &SemaRef);
@@ -639,7 +639,7 @@ class ASTWriter : public ASTDeserializationListener,
639639
void WriteDeclAbbrevs();
640640
void WriteDecl(ASTContext &Context, Decl *D);
641641

642-
ASTFileSignature WriteASTCore(Sema &SemaRef, StringRef isysroot,
642+
ASTFileSignature WriteASTCore(Sema *SemaPtr, StringRef isysroot,
643643
Module *WritingModule);
644644

645645
public:
@@ -661,8 +661,8 @@ class ASTWriter : public ASTDeserializationListener,
661661

662662
/// Write a precompiled header for the given semantic analysis.
663663
///
664-
/// \param SemaRef a reference to the semantic analysis object that processed
665-
/// the AST to be written into the precompiled header.
664+
/// \param Subject The object that processed the input to be written into the
665+
/// AST file.
666666
///
667667
/// \param WritingModule The module that we are writing. If null, we are
668668
/// writing a precompiled header.
@@ -673,8 +673,9 @@ class ASTWriter : public ASTDeserializationListener,
673673
///
674674
/// \return the module signature, which eventually will be a hash of
675675
/// the module but currently is merely a random 32-bit number.
676-
ASTFileSignature WriteAST(Sema &SemaRef, StringRef OutputFile,
677-
Module *WritingModule, StringRef isysroot,
676+
ASTFileSignature WriteAST(llvm::PointerUnion<Sema *, Preprocessor*> Subject,
677+
StringRef OutputFile, Module *WritingModule,
678+
StringRef isysroot,
678679
bool ShouldCacheASTInMemory = false);
679680

680681
/// Emit a token.

clang/lib/Frontend/ASTUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2359,7 +2359,7 @@ bool ASTUnit::Save(StringRef File) {
23592359

23602360
static bool serializeUnit(ASTWriter &Writer, SmallVectorImpl<char> &Buffer,
23612361
Sema &S, raw_ostream &OS) {
2362-
Writer.WriteAST(S, std::string(), nullptr, "");
2362+
Writer.WriteAST(&S, std::string(), nullptr, "");
23632363

23642364
// Write the generated bitstream to "Out".
23652365
if (!Buffer.empty())

0 commit comments

Comments
 (0)