Skip to content

Commit 155dcce

Browse files
committed
Reapply "[clang][Interp][NFC] Save source location of evaluating expression"
This reverts commit ebcb04a.
1 parent ce7700e commit 155dcce

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

clang/lib/AST/Interp/EvalEmitter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ EvalEmitter::~EvalEmitter() {
3434

3535
EvaluationResult EvalEmitter::interpretExpr(const Expr *E,
3636
bool ConvertResultToRValue) {
37+
S.setEvalLocation(E->getExprLoc());
3738
this->ConvertResultToRValue = ConvertResultToRValue;
3839
EvalResult.setSource(E);
3940

clang/lib/AST/Interp/InterpFrame.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,11 @@ Frame *InterpFrame::getCaller() const {
191191
}
192192

193193
SourceRange InterpFrame::getCallRange() const {
194-
if (!Caller->Func)
195-
return S.getRange(nullptr, {});
194+
if (!Caller->Func) {
195+
if (SourceRange NullRange = S.getRange(nullptr, {}); NullRange.isValid())
196+
return NullRange;
197+
return S.EvalLocation;
198+
}
196199
return S.getRange(Caller->Func, RetPC - sizeof(uintptr_t));
197200
}
198201

clang/lib/AST/Interp/InterpState.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class InterpState final : public State, public SourceMapper {
9898

9999
Context &getContext() const { return Ctx; }
100100

101+
void setEvalLocation(SourceLocation SL) { this->EvalLocation = SL; }
102+
101103
private:
102104
/// AST Walker state.
103105
State &Parent;
@@ -115,6 +117,8 @@ class InterpState final : public State, public SourceMapper {
115117
Context &Ctx;
116118
/// The current frame.
117119
InterpFrame *Current = nullptr;
120+
/// Source location of the evaluating expression
121+
SourceLocation EvalLocation;
118122
};
119123

120124
} // namespace interp

0 commit comments

Comments
 (0)