Author: Timm Bäder Date: 2024-07-09T11:52:41+02:00 New Revision: f6712d27874004835170e6eb8ff5f348a8866057
URL: https://github.com/llvm/llvm-project/commit/f6712d27874004835170e6eb8ff5f348a8866057 DIFF: https://github.com/llvm/llvm-project/commit/f6712d27874004835170e6eb8ff5f348a8866057.diff LOG: [clang][Interp][NFC] Get rid of AutoScope Added: Modified: clang/lib/AST/Interp/Compiler.cpp clang/lib/AST/Interp/Compiler.h Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/Compiler.cpp b/clang/lib/AST/Interp/Compiler.cpp index 5fad24a0930ac..48e7519f8f89d 100644 --- a/clang/lib/AST/Interp/Compiler.cpp +++ b/clang/lib/AST/Interp/Compiler.cpp @@ -1794,6 +1794,8 @@ bool Compiler<Emitter>::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E) { if (!this->visitArrayElemInit(I, SubExpr)) return false; + if (!BS.destroyLocals()) + return false; } return true; } @@ -3080,7 +3082,7 @@ bool Compiler<Emitter>::VisitStmtExpr(const StmtExpr *E) { return false; } - return true; + return BS.destroyLocals(); } template <class Emitter> bool Compiler<Emitter>::discard(const Expr *E) { @@ -4190,7 +4192,7 @@ template <class Emitter> bool Compiler<Emitter>::visitIfStmt(const IfStmt *IS) { this->emitLabel(LabelEnd); } - return true; + return IfScope.destroyLocals(); } template <class Emitter> @@ -4656,6 +4658,9 @@ bool Compiler<Emitter>::visitFunc(const FunctionDecl *F) { if (!this->emitPopPtr(InitExpr)) return false; } + + if (!Scope.destroyLocals()) + return false; } } diff --git a/clang/lib/AST/Interp/Compiler.h b/clang/lib/AST/Interp/Compiler.h index 246ff25347067..de873c7e6825f 100644 --- a/clang/lib/AST/Interp/Compiler.h +++ b/clang/lib/AST/Interp/Compiler.h @@ -589,20 +589,10 @@ template <class Emitter> class DestructorScope final { LocalScope<Emitter> &OtherScope; }; -/// Like a regular LocalScope, except that the destructors of all local -/// variables are automatically emitted when the AutoScope is destroyed. -template <class Emitter> class AutoScope : public LocalScope<Emitter> { -public: - AutoScope(Compiler<Emitter> *Ctx) : LocalScope<Emitter>(Ctx), DS(*this) {} - -private: - DestructorScope<Emitter> DS; -}; - /// Scope for storage declared in a compound statement. -template <class Emitter> class BlockScope final : public AutoScope<Emitter> { +template <class Emitter> class BlockScope final : public LocalScope<Emitter> { public: - BlockScope(Compiler<Emitter> *Ctx) : AutoScope<Emitter>(Ctx) {} + BlockScope(Compiler<Emitter> *Ctx) : LocalScope<Emitter>(Ctx) {} void addExtended(const Scope::Local &Local) override { // If we to this point, just add the variable as a normal local _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits