https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/202277

This is not necessary since `Frame` already has a `getCaller()` function, which 
can be used to identify the bottom frame.
And the current code never needs the bottom frame for anything other than 
checking if another frame is the bottom frame.

>From 559ad3f4f7ed5776c45a7ac886c183f59d410b78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Mon, 8 Jun 2026 09:34:25 +0200
Subject: [PATCH] [clang][ExprConst] Remove State::getBottomFrame()

---
 clang/lib/AST/ByteCode/InterpState.h | 2 --
 clang/lib/AST/ByteCode/State.cpp     | 4 ++--
 clang/lib/AST/ByteCode/State.h       | 1 -
 clang/lib/AST/ExprConstant.cpp       | 3 +--
 4 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/clang/lib/AST/ByteCode/InterpState.h 
b/clang/lib/AST/ByteCode/InterpState.h
index 499a21a094e2c..b6ef985095907 100644
--- a/clang/lib/AST/ByteCode/InterpState.h
+++ b/clang/lib/AST/ByteCode/InterpState.h
@@ -54,8 +54,6 @@ class InterpState final : public State, public SourceMapper {
   unsigned getCallStackDepth() override {
     return Current ? (Current->getDepth() + 1) : 1;
   }
-  const Frame *getBottomFrame() const override { return &BottomFrame; }
-
   bool stepsLeft() const override { return true; }
   bool inConstantContext() const;
 
diff --git a/clang/lib/AST/ByteCode/State.cpp b/clang/lib/AST/ByteCode/State.cpp
index 00e3b1a331172..e612c6863e60f 100644
--- a/clang/lib/AST/ByteCode/State.cpp
+++ b/clang/lib/AST/ByteCode/State.cpp
@@ -122,8 +122,8 @@ void State::addCallStack(unsigned Limit) {
   // Walk the call stack and add the diagnostics.
   unsigned CallIdx = 0;
   const Frame *Top = getCurrentFrame();
-  const Frame *Bottom = getBottomFrame();
-  for (const Frame *F = Top; F != Bottom; F = F->getCaller(), ++CallIdx) {
+  for (const Frame *F = Top; F->getCaller() != nullptr;
+       F = F->getCaller(), ++CallIdx) {
     SourceRange CallRange = F->getCallRange();
     assert(CallRange.isValid());
 
diff --git a/clang/lib/AST/ByteCode/State.h b/clang/lib/AST/ByteCode/State.h
index a720033c7914b..df3afdf8cbc24 100644
--- a/clang/lib/AST/ByteCode/State.h
+++ b/clang/lib/AST/ByteCode/State.h
@@ -85,7 +85,6 @@ class State {
   virtual ~State();
 
   virtual const Frame *getCurrentFrame() = 0;
-  virtual const Frame *getBottomFrame() const = 0;
   virtual unsigned getCallStackDepth() = 0;
   virtual bool stepsLeft() const = 0;
 
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 33df4cab06e7c..ab30a0874d95f 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -1032,7 +1032,7 @@ namespace {
     };
 
     StdAllocatorCaller getStdAllocatorCaller(StringRef FnName) const {
-      for (const CallStackFrame *Call = CurrentCall; Call != &BottomFrame;
+      for (const CallStackFrame *Call = CurrentCall; Call->Caller != nullptr;
            Call = Call->Caller) {
         const auto *MD = dyn_cast_or_null<CXXMethodDecl>(Call->Callee);
         if (!MD)
@@ -1080,7 +1080,6 @@ namespace {
 
   private:
     const interp::Frame *getCurrentFrame() override { return CurrentCall; }
-    const interp::Frame *getBottomFrame() const override { return 
&BottomFrame; }
 
     unsigned getCallStackDepth() override { return CallStackDepth; }
     bool stepsLeft() const override { return StepsLeft > 0; }

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to