Reapply "[clang][Interp][NFC] Save source location of evaluating expression"

This reverts commit ebcb04ae8825b15fd6aa249a8da0617b877b4705.
This commit is contained in:
Timm Bäder 2024-05-02 14:04:38 +02:00
parent ce7700e29d
commit 155dcce401
3 changed files with 10 additions and 2 deletions

View File

@ -34,6 +34,7 @@ EvalEmitter::~EvalEmitter() {
EvaluationResult EvalEmitter::interpretExpr(const Expr *E,
bool ConvertResultToRValue) {
S.setEvalLocation(E->getExprLoc());
this->ConvertResultToRValue = ConvertResultToRValue;
EvalResult.setSource(E);

View File

@ -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));
}

View File

@ -98,6 +98,8 @@ public:
Context &getContext() const { return Ctx; }
void setEvalLocation(SourceLocation SL) { this->EvalLocation = SL; }
private:
/// AST Walker state.
State &Parent;
@ -115,6 +117,8 @@ public:
Context &Ctx;
/// The current frame.
InterpFrame *Current = nullptr;
/// Source location of the evaluating expression
SourceLocation EvalLocation;
};
} // namespace interp