https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/219762
Implement `getRange()` etc. in terms of `getSource()` to reduce code duplication. >From 110d64b7b3653138304f7af038d7b0eb92d4ded5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Sat, 29 Aug 2026 19:27:06 +0200 Subject: [PATCH] getsource --- clang/lib/AST/ByteCode/InterpFrame.cpp | 32 ++------------------------ clang/lib/AST/ByteCode/InterpFrame.h | 8 ++++--- clang/lib/AST/ByteCode/InterpState.h | 5 ---- 3 files changed, 7 insertions(+), 38 deletions(-) diff --git a/clang/lib/AST/ByteCode/InterpFrame.cpp b/clang/lib/AST/ByteCode/InterpFrame.cpp index a12836403c386..8111cba9e319c 100644 --- a/clang/lib/AST/ByteCode/InterpFrame.cpp +++ b/clang/lib/AST/ByteCode/InterpFrame.cpp @@ -218,8 +218,9 @@ void InterpFrame::describe(llvm::raw_ostream &OS) const { SourceRange InterpFrame::getCallRange() const { if (!Caller->Func) { - if (SourceRange NullRange = S.getRange({}); NullRange.isValid()) + if (SourceRange NullRange = S.getSource({}).getRange(); NullRange.isValid()) return NullRange; + return S.EvalLocation; } @@ -296,35 +297,6 @@ SourceInfo InterpFrame::getSource(CodePtr PC) const { return Result; } -const Expr *InterpFrame::getExpr(CodePtr PC) const { - if (!Func) - return S.getExpr(PC); - - if (!funcHasUsableBody(Func) && Caller) - return Caller->getExpr(getRetOpPC()); - - return Func->getSource(PC).asExpr(); -} - -SourceLocation InterpFrame::getLocation(CodePtr PC) const { - if (!Func) - return S.getLocation(PC); - if (!funcHasUsableBody(Func) && Caller) - return Caller->getLocation(getRetOpPC()); - - return Func->getSource(PC).getLoc(); -} - -SourceRange InterpFrame::getRange(CodePtr PC) const { - if (!Func) - return S.getRange(PC); - - if (!funcHasUsableBody(Func) && Caller) - return Caller->getRange(getRetOpPC()); - - return Func->getSource(PC).getRange(); -} - bool InterpFrame::isStdFunction() const { if (!Func) return false; diff --git a/clang/lib/AST/ByteCode/InterpFrame.h b/clang/lib/AST/ByteCode/InterpFrame.h index 9498a911f2892..3322136372846 100644 --- a/clang/lib/AST/ByteCode/InterpFrame.h +++ b/clang/lib/AST/ByteCode/InterpFrame.h @@ -161,9 +161,11 @@ class InterpFrame final : public Frame { /// Map a location to a source. SourceInfo getSource(CodePtr PC) const; - const Expr *getExpr(CodePtr PC) const; - SourceLocation getLocation(CodePtr PC) const; - SourceRange getRange(CodePtr PC) const; + const Expr *getExpr(CodePtr PC) const { return getSource(PC).asExpr(); } + SourceLocation getLocation(CodePtr PC) const { + return getSource(PC).getLoc(); + } + SourceRange getRange(CodePtr PC) const { return getSource(PC).getRange(); } unsigned getDepth() const { return Depth; } unsigned getArgSize() const { return ArgSize; } diff --git a/clang/lib/AST/ByteCode/InterpState.h b/clang/lib/AST/ByteCode/InterpState.h index 8b3c2a0e7dd5a..9eb94faf813ef 100644 --- a/clang/lib/AST/ByteCode/InterpState.h +++ b/clang/lib/AST/ByteCode/InterpState.h @@ -69,11 +69,6 @@ class InterpState final : public State { /// Delegates source mapping to the mapper. SourceInfo getSource(CodePtr PC) const { return M->getSource(PC); } - const Expr *getExpr(CodePtr PC) const { return getSource(PC).asExpr(); } - SourceLocation getLocation(CodePtr PC) const { - return getSource(PC).getLoc(); - } - SourceRange getRange(CodePtr PC) const { return getSource(PC).getRange(); } Context &getContext() const { return Ctx; } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
