[clang] [clang][bytcode][NFC] Remove StmtExprScope (PR #204530)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 18 02:12:01 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
We can use a simple llvm::SaveAndRestore instead.
---
Full diff: https://github.com/llvm/llvm-project/pull/204530.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+1-14)
``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 638e6ecafb295..f84702aa127cd 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -168,19 +168,6 @@ template <class Emitter> class SwitchScope final {
CaseMap OldCaseLabels;
};
-template <class Emitter> class StmtExprScope final {
-public:
- StmtExprScope(Compiler<Emitter> *Ctx) : Ctx(Ctx), OldFlag(Ctx->InStmtExpr) {
- Ctx->InStmtExpr = true;
- }
-
- ~StmtExprScope() { Ctx->InStmtExpr = OldFlag; }
-
-private:
- Compiler<Emitter> *Ctx;
- bool OldFlag;
-};
-
/// When generating code for e.g. implicit field initializers in constructors,
/// we don't have anything to point to in case the initializer causes an error.
/// In that case, we need to disable location tracking for the initializer so
@@ -4605,7 +4592,7 @@ bool Compiler<Emitter>::VisitCXXStdInitializerListExpr(
template <class Emitter>
bool Compiler<Emitter>::VisitStmtExpr(const StmtExpr *E) {
LocalScope<Emitter> BS(this);
- StmtExprScope<Emitter> SS(this);
+ llvm::SaveAndRestore StmtExprSAR(this->InStmtExpr, true);
const CompoundStmt *CS = E->getSubStmt();
const Stmt *Result = CS->body_back();
``````````
</details>
https://github.com/llvm/llvm-project/pull/204530
More information about the cfe-commits
mailing list