diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2024-11-07 14:40:21 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-07 14:40:21 -0800 |
commit | 53e49f15ab0b9b03e5671faea6f7870914b8f0ea (patch) | |
tree | bdca35cb89283752bb7b34c11659b28495827999 /clang/lib/Serialization/ASTWriterStmt.cpp | |
parent | e189d61924ba0165b3a344c3d945b3e2aa373485 (diff) | |
download | llvm-53e49f15ab0b9b03e5671faea6f7870914b8f0ea.zip llvm-53e49f15ab0b9b03e5671faea6f7870914b8f0ea.tar.gz llvm-53e49f15ab0b9b03e5671faea6f7870914b8f0ea.tar.bz2 |
[clang][serialization] Pass `ASTContext` explicitly (#115235)
This patch removes `ASTWriter::Context` and starts passing `ASTContext
&` explicitly to functions that actually need it. This is a
non-functional change with the end-goal of being able to write
lightweight PCM files with no `ASTContext` at all.
Diffstat (limited to 'clang/lib/Serialization/ASTWriterStmt.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriterStmt.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp index 321e003..7f700c2 100644 --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -91,8 +91,9 @@ namespace clang { PakedBitsWriter CurrentPackingBits; public: - ASTStmtWriter(ASTWriter &Writer, ASTWriter::RecordData &Record) - : Writer(Writer), Record(Writer, Record), + ASTStmtWriter(ASTContext &Context, ASTWriter &Writer, + ASTWriter::RecordData &Record) + : Writer(Writer), Record(Context, Writer, Record), Code(serialization::STMT_NULL_PTR), AbbrevToUse(0), CurrentPackingBits(this->Record) {} @@ -2112,7 +2113,7 @@ void ASTStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) { // propagted. DeclarationName Name = E->getName(); for (auto *Found : - Writer.getASTContext().getTranslationUnitDecl()->lookup(Name)) + Record.getASTContext().getTranslationUnitDecl()->lookup(Name)) if (Found->isFromASTFile()) Writer.GetDeclRef(Found); @@ -2952,9 +2953,9 @@ void ASTWriter::ClearSwitchCaseIDs() { /// Write the given substatement or subexpression to the /// bitstream. -void ASTWriter::WriteSubStmt(Stmt *S) { +void ASTWriter::WriteSubStmt(ASTContext &Context, Stmt *S) { RecordData Record; - ASTStmtWriter Writer(*this, Record); + ASTStmtWriter Writer(Context, *this, Record); ++NumStatements; if (!S) { @@ -3003,7 +3004,7 @@ void ASTRecordWriter::FlushStmts() { assert(Writer->ParentStmts.empty() && "unexpected entries in parent stmt map"); for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) { - Writer->WriteSubStmt(StmtsToEmit[I]); + Writer->WriteSubStmt(getASTContext(), StmtsToEmit[I]); assert(N == StmtsToEmit.size() && "record modified while being written!"); @@ -3024,7 +3025,7 @@ void ASTRecordWriter::FlushSubStmts() { // that a simple stack machine can be used when loading), and don't emit a // STMT_STOP after each one. for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) { - Writer->WriteSubStmt(StmtsToEmit[N - I - 1]); + Writer->WriteSubStmt(getASTContext(), StmtsToEmit[N - I - 1]); assert(N == StmtsToEmit.size() && "record modified while being written!"); } |