[clang] 9d88990 - [clang][Interp][NFC] Remove visit{Global,Local,This}Initializer

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 14 01:48:17 PDT 2024


Author: Timm Bäder
Date: 2024-07-14T10:47:50+02:00
New Revision: 9d889906720c1a4fbdb3b8aaacfeebd62f235b87

URL: https://github.com/llvm/llvm-project/commit/9d889906720c1a4fbdb3b8aaacfeebd62f235b87
DIFF: https://github.com/llvm/llvm-project/commit/9d889906720c1a4fbdb3b8aaacfeebd62f235b87.diff

LOG: [clang][Interp][NFC] Remove visit{Global,Local,This}Initializer

They were only called once, or not at all.

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 0b2a38d02b4a..c58eb2eaa477 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -3583,7 +3583,19 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD, bool Topleve
         return checkDecl() && this->emitInitGlobal(*VarT, GlobalIndex, VD);
       }
 
-      return checkDecl() && this->visitGlobalInitializer(Init, GlobalIndex);
+      if (!checkDecl())
+        return false;
+
+      if (!this->emitGetPtrGlobal(GlobalIndex, Init))
+        return false;
+
+      if (!visitInitializer(Init))
+        return false;
+
+      if (!this->emitFinishInit(Init))
+        return false;
+
+      return this->emitPopPtr(Init);
     };
 
     // We've already seen and initialized this global.
@@ -3627,7 +3639,16 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD, bool Topleve
         if (!Init)
           return true;
 
-        return this->visitLocalInitializer(Init, *Offset);
+        if (!this->emitGetPtrLocal(*Offset, Init))
+          return false;
+
+        if (!visitInitializer(Init))
+          return false;
+
+        if (!this->emitFinishInit(Init))
+          return false;
+
+        return this->emitPopPtr(Init);
       }
       return false;
     }

diff  --git a/clang/lib/AST/Interp/Compiler.h b/clang/lib/AST/Interp/Compiler.h
index de873c7e6825..23e7afd767e8 100644
--- a/clang/lib/AST/Interp/Compiler.h
+++ b/clang/lib/AST/Interp/Compiler.h
@@ -278,45 +278,6 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
   /// Visits an expression and converts it to a boolean.
   bool visitBool(const Expr *E);
 
-  /// Visits an initializer for a local.
-  bool visitLocalInitializer(const Expr *Init, unsigned I) {
-    if (!this->emitGetPtrLocal(I, Init))
-      return false;
-
-    if (!visitInitializer(Init))
-      return false;
-
-    if (!this->emitFinishInit(Init))
-      return false;
-
-    return this->emitPopPtr(Init);
-  }
-
-  /// Visits an initializer for a global.
-  bool visitGlobalInitializer(const Expr *Init, unsigned I) {
-    if (!this->emitGetPtrGlobal(I, Init))
-      return false;
-
-    if (!visitInitializer(Init))
-      return false;
-
-    if (!this->emitFinishInit(Init))
-      return false;
-
-    return this->emitPopPtr(Init);
-  }
-
-  /// Visits a delegated initializer.
-  bool visitThisInitializer(const Expr *I) {
-    if (!this->emitThis(I))
-      return false;
-
-    if (!visitInitializer(I))
-      return false;
-
-    return this->emitFinishInitPop(I);
-  }
-
   bool visitInitList(ArrayRef<const Expr *> Inits, const Expr *ArrayFiller,
                      const Expr *E);
   bool visitArrayElemInit(unsigned ElemIndex, const Expr *Init);


        


More information about the cfe-commits mailing list