Author: Timm Baeder Date: 2026-06-09T07:15:08+02:00 New Revision: 5ec4461fee4c0e82451b000f06b6ab916449de9f
URL: https://github.com/llvm/llvm-project/commit/5ec4461fee4c0e82451b000f06b6ab916449de9f DIFF: https://github.com/llvm/llvm-project/commit/5ec4461fee4c0e82451b000f06b6ab916449de9f.diff LOG: [clang][ExprConst] Remove `State::getBottomFrame()` (#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. Added: Modified: clang/lib/AST/ByteCode/InterpState.h clang/lib/AST/ByteCode/State.cpp clang/lib/AST/ByteCode/State.h clang/lib/AST/ExprConstant.cpp Removed: ################################################################################ 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 f88a751a18563..1642c41a99a2f 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
