Author: Timm Baeder Date: 2026-08-30T09:12:00+02:00 New Revision: 37cc7ee1d53e5850033809ad61425053800fd370
URL: https://github.com/llvm/llvm-project/commit/37cc7ee1d53e5850033809ad61425053800fd370 DIFF: https://github.com/llvm/llvm-project/commit/37cc7ee1d53e5850033809ad61425053800fd370.diff LOG: [clang][bytecode] Clean up diagnostic location getters (#219762) Implement `getRange()` etc. in terms of `getSource()` to reduce code duplication. Added: Modified: clang/lib/AST/ByteCode/InterpFrame.cpp clang/lib/AST/ByteCode/InterpFrame.h clang/lib/AST/ByteCode/InterpState.h Removed: ################################################################################ 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
