Author: Timm Bäder
Date: 2023-01-23T12:19:36+01:00
New Revision: 6469281100e654f690af8d5bcf0123e4105cafbe

URL: 
https://github.com/llvm/llvm-project/commit/6469281100e654f690af8d5bcf0123e4105cafbe
DIFF: 
https://github.com/llvm/llvm-project/commit/6469281100e654f690af8d5bcf0123e4105cafbe.diff

LOG: [clang][Interp][NFC] Remove InitFn code

This is unused.

Added: 
    

Modified: 
    clang/lib/AST/Interp/ByteCodeExprGen.cpp
    clang/lib/AST/Interp/ByteCodeExprGen.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 8bedf6898bb5..615dbdefefbe 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -41,45 +41,19 @@ template <class Emitter> class DeclScope final : public 
LocalScope<Emitter> {
 /// Scope used to handle initialization methods.
 template <class Emitter> class OptionScope {
 public:
-  using InitFnRef = typename ByteCodeExprGen<Emitter>::InitFnRef;
-  using ChainedInitFnRef = std::function<bool(InitFnRef)>;
-
   /// Root constructor, compiling or discarding primitives.
   OptionScope(ByteCodeExprGen<Emitter> *Ctx, bool NewDiscardResult)
-      : Ctx(Ctx), OldDiscardResult(Ctx->DiscardResult),
-        OldInitFn(std::move(Ctx->InitFn)) {
+      : Ctx(Ctx), OldDiscardResult(Ctx->DiscardResult) {
     Ctx->DiscardResult = NewDiscardResult;
-    Ctx->InitFn = std::optional<InitFnRef>{};
-  }
-
-  /// Root constructor, setting up compilation state.
-  OptionScope(ByteCodeExprGen<Emitter> *Ctx, InitFnRef NewInitFn)
-      : Ctx(Ctx), OldDiscardResult(Ctx->DiscardResult),
-        OldInitFn(std::move(Ctx->InitFn)) {
-    Ctx->DiscardResult = true;
-    Ctx->InitFn = NewInitFn;
   }
 
-  /// Extends the chain of initialisation pointers.
-  OptionScope(ByteCodeExprGen<Emitter> *Ctx, ChainedInitFnRef NewInitFn)
-      : Ctx(Ctx), OldDiscardResult(Ctx->DiscardResult),
-        OldInitFn(std::move(Ctx->InitFn)) {
-    assert(OldInitFn && "missing initializer");
-    Ctx->InitFn = [this, NewInitFn] { return NewInitFn(*OldInitFn); };
-  }
-
-  ~OptionScope() {
-    Ctx->DiscardResult = OldDiscardResult;
-    Ctx->InitFn = std::move(OldInitFn);
-  }
+  ~OptionScope() { Ctx->DiscardResult = OldDiscardResult; }
 
 private:
   /// Parent context.
   ByteCodeExprGen<Emitter> *Ctx;
   /// Old discard flag to restore.
   bool OldDiscardResult;
-  /// Old pointer emitter to restore.
-  std::optional<InitFnRef> OldInitFn;
 };
 
 } // namespace interp

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index 89782bd87c32..c7fcc59e5a60 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -44,9 +44,6 @@ class ByteCodeExprGen : public 
ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
   using LabelTy = typename Emitter::LabelTy;
   using AddrTy = typename Emitter::AddrTy;
 
-  // Reference to a function generating the pointer of an initialized object.s
-  using InitFnRef = std::function<bool()>;
-
   /// Current compilation context.
   Context &Ctx;
   /// Program to link to.
@@ -221,12 +218,6 @@ class ByteCodeExprGen : public 
ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
   /// Emits an integer constant.
   template <typename T> bool emitConst(T Value, const Expr *E);
 
-  /// Emits the initialized pointer.
-  bool emitInitFn() {
-    assert(InitFn && "missing initializer");
-    return (*InitFn)();
-  }
-
   /// Returns the CXXRecordDecl for the type of the given expression,
   /// or nullptr if no such decl exists.
   const CXXRecordDecl *getRecordDecl(const Expr *E) const {
@@ -257,9 +248,6 @@ class ByteCodeExprGen : public 
ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
 
   /// Flag indicating if return value is to be discarded.
   bool DiscardResult = false;
-
-  /// Expression being initialized.
-  std::optional<InitFnRef> InitFn = {};
 };
 
 extern template class ByteCodeExprGen<ByteCodeEmitter>;


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to