[clang] 155dcce - Reapply "[clang][Interp][NFC] Save source location of evaluating expression"
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Thu May 2 05:50:20 PDT 2024
Author: Timm Bäder
Date: 2024-05-02T14:49:57+02:00
New Revision: 155dcce40110fbe8a29a5b00a3078e3333d10f4a
URL: https://github.com/llvm/llvm-project/commit/155dcce40110fbe8a29a5b00a3078e3333d10f4a
DIFF: https://github.com/llvm/llvm-project/commit/155dcce40110fbe8a29a5b00a3078e3333d10f4a.diff
LOG: Reapply "[clang][Interp][NFC] Save source location of evaluating expression"
This reverts commit ebcb04ae8825b15fd6aa249a8da0617b877b4705.
Added:
Modified:
clang/lib/AST/Interp/EvalEmitter.cpp
clang/lib/AST/Interp/InterpFrame.cpp
clang/lib/AST/Interp/InterpState.h
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/EvalEmitter.cpp b/clang/lib/AST/Interp/EvalEmitter.cpp
index d764b4b6f6d17b..388c3612f292b0 100644
--- a/clang/lib/AST/Interp/EvalEmitter.cpp
+++ b/clang/lib/AST/Interp/EvalEmitter.cpp
@@ -34,6 +34,7 @@ EvalEmitter::~EvalEmitter() {
EvaluationResult EvalEmitter::interpretExpr(const Expr *E,
bool ConvertResultToRValue) {
+ S.setEvalLocation(E->getExprLoc());
this->ConvertResultToRValue = ConvertResultToRValue;
EvalResult.setSource(E);
diff --git a/clang/lib/AST/Interp/InterpFrame.cpp b/clang/lib/AST/Interp/InterpFrame.cpp
index 515b1f5fde1aa7..51b0bd5c155159 100644
--- a/clang/lib/AST/Interp/InterpFrame.cpp
+++ b/clang/lib/AST/Interp/InterpFrame.cpp
@@ -191,8 +191,11 @@ Frame *InterpFrame::getCaller() const {
}
SourceRange InterpFrame::getCallRange() const {
- if (!Caller->Func)
- return S.getRange(nullptr, {});
+ if (!Caller->Func) {
+ if (SourceRange NullRange = S.getRange(nullptr, {}); NullRange.isValid())
+ return NullRange;
+ return S.EvalLocation;
+ }
return S.getRange(Caller->Func, RetPC - sizeof(uintptr_t));
}
diff --git a/clang/lib/AST/Interp/InterpState.h b/clang/lib/AST/Interp/InterpState.h
index c17cfad11b1e2b..d483c60c58e248 100644
--- a/clang/lib/AST/Interp/InterpState.h
+++ b/clang/lib/AST/Interp/InterpState.h
@@ -98,6 +98,8 @@ class InterpState final : public State, public SourceMapper {
Context &getContext() const { return Ctx; }
+ void setEvalLocation(SourceLocation SL) { this->EvalLocation = SL; }
+
private:
/// AST Walker state.
State &Parent;
@@ -115,6 +117,8 @@ class InterpState final : public State, public SourceMapper {
Context &Ctx;
/// The current frame.
InterpFrame *Current = nullptr;
+ /// Source location of the evaluating expression
+ SourceLocation EvalLocation;
};
} // namespace interp
More information about the cfe-commits
mailing list