[clang] 369d3a7 - [clang][Interp][NFC] Remove ExprScope

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 9 02:52:54 PDT 2024


Author: Timm Bäder
Date: 2024-07-09T11:52:40+02:00
New Revision: 369d3a738082a2fac1a98aae8a8cfded9a010e10

URL: https://github.com/llvm/llvm-project/commit/369d3a738082a2fac1a98aae8a8cfded9a010e10
DIFF: https://github.com/llvm/llvm-project/commit/369d3a738082a2fac1a98aae8a8cfded9a010e10.diff

LOG: [clang][Interp][NFC] Remove ExprScope

It's been nothing but a LocalScope for a while.

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 1d39d7bb9e15f..5fad24a0930ac 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -2204,7 +2204,7 @@ bool Compiler<Emitter>::VisitCompoundAssignOperator(
 
 template <class Emitter>
 bool Compiler<Emitter>::VisitExprWithCleanups(const ExprWithCleanups *E) {
-  ExprScope<Emitter> ES(this);
+  LocalScope<Emitter> ES(this);
   const Expr *SubExpr = E->getSubExpr();
 
   assert(E->getNumObjects() == 0 && "TODO: Implement cleanups");
@@ -3425,7 +3425,7 @@ const Function *Compiler<Emitter>::getFunction(const FunctionDecl *FD) {
 }
 
 template <class Emitter> bool Compiler<Emitter>::visitExpr(const Expr *E) {
-  ExprScope<Emitter> RootScope(this);
+  LocalScope<Emitter> RootScope(this);
   // Void expressions.
   if (E->getType()->isVoidType()) {
     if (!visit(E))
@@ -3610,10 +3610,10 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD, bool Topleve
         // If this is a toplevel declaration, create a scope for the
         // initializer.
         if (Toplevel) {
-          ExprScope<Emitter> Scope(this);
+          LocalScope<Emitter> Scope(this);
           if (!this->visit(Init))
             return false;
-          return this->emitSetLocal(*VarT, Offset, VD);
+          return this->emitSetLocal(*VarT, Offset, VD) && Scope.destroyLocals();
         } else {
           if (!this->visit(Init))
             return false;
@@ -4120,7 +4120,7 @@ bool Compiler<Emitter>::visitReturnStmt(const ReturnStmt *RS) {
     return this->emitUnsupported(RS);
 
   if (const Expr *RE = RS->getRetValue()) {
-    ExprScope<Emitter> RetScope(this);
+    LocalScope<Emitter> RetScope(this);
     if (ReturnType) {
       // Primitive types are simply returned.
       if (!this->visit(RE))

diff  --git a/clang/lib/AST/Interp/Compiler.h b/clang/lib/AST/Interp/Compiler.h
index fbeda8a0b7a4f..246ff25347067 100644
--- a/clang/lib/AST/Interp/Compiler.h
+++ b/clang/lib/AST/Interp/Compiler.h
@@ -612,11 +612,6 @@ template <class Emitter> class BlockScope final : public AutoScope<Emitter> {
   }
 };
 
-template <class Emitter> class ExprScope final : public AutoScope<Emitter> {
-public:
-  ExprScope(Compiler<Emitter> *Ctx) : AutoScope<Emitter>(Ctx) {}
-};
-
 template <class Emitter> class ArrayIndexScope final {
 public:
   ArrayIndexScope(Compiler<Emitter> *Ctx, uint64_t Index) : Ctx(Ctx) {


        


More information about the cfe-commits mailing list