[clang] [clang][ExprConst] Remove `State::getBottomFrame()` (PR #202277)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 8 00:37:56 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/202277.diff
4 Files Affected:
- (modified) clang/lib/AST/ByteCode/InterpState.h (-2)
- (modified) clang/lib/AST/ByteCode/State.cpp (+2-2)
- (modified) clang/lib/AST/ByteCode/State.h (-1)
- (modified) clang/lib/AST/ExprConstant.cpp (+1-2)
``````````diff
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; }
``````````
</details>
https://github.com/llvm/llvm-project/pull/202277
More information about the cfe-commits
mailing list