Reapply "[clang][Interp][NFC] Save source location of evaluating expression" This reverts commit ebcb04ae8825b15fd6aa249a8da0617b877b4705.
diff --git a/clang/lib/AST/Interp/EvalEmitter.cpp b/clang/lib/AST/Interp/EvalEmitter.cpp index d764b4b..388c361 100644 --- a/clang/lib/AST/Interp/EvalEmitter.cpp +++ b/clang/lib/AST/Interp/EvalEmitter.cpp
@@ -34,6 +34,7 @@ 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 515b1f5..51b0bd5 100644 --- a/clang/lib/AST/Interp/InterpFrame.cpp +++ b/clang/lib/AST/Interp/InterpFrame.cpp
@@ -191,8 +191,11 @@ } 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 c17cfad..d483c60 100644 --- a/clang/lib/AST/Interp/InterpState.h +++ b/clang/lib/AST/Interp/InterpState.h
@@ -98,6 +98,8 @@ Context &getContext() const { return Ctx; } + void setEvalLocation(SourceLocation SL) { this->EvalLocation = SL; } + private: /// AST Walker state. State &Parent; @@ -115,6 +117,8 @@ Context &Ctx; /// The current frame. InterpFrame *Current = nullptr; + /// Source location of the evaluating expression + SourceLocation EvalLocation; }; } // namespace interp