Skip to content

Commit 2a7964c

Browse files
committed
[Heavy] Propagate source locations in template expansions
1 parent 80bf5d7 commit 2a7964c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

heavy/lib/OpEval.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ class OpEvalImpl {
264264
}
265265

266266
BlockItrTy Visit(ApplyOp Op) {
267-
Context.setLoc(getSourceLocation(Op.getLoc()));
267+
heavy::SourceLocation Loc = getSourceLocation(Op.getLoc());
268+
Context.setLoc(Loc);
268269

269270
heavy::Value Callee = getValue(Op.getFn());
270271
ValueRefs Args;
@@ -296,10 +297,10 @@ class OpEvalImpl {
296297
}
297298

298299
BlockItrTy Visit(ConsOp Op) {
299-
// TODO Use PairWithSource to retain source location information.
300300
heavy::Value A = getValue(Op.getA());
301301
heavy::Value B = getValue(Op.getB());
302-
heavy::Pair* V = Context.CreatePair(A, B);
302+
heavy::SourceLocation Loc = getSourceLocation(Op.getLoc());
303+
heavy::Pair* V = Context.CreatePairWithSource(A, B, Loc);
303304
setValue(Op.getResult(), V);
304305
return next(Op);
305306
}

heavy/lib/OpGen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,7 @@ mlir::Value OpGen::createCall(heavy::SourceLocation Loc, mlir::Value Fn,
11161116
for (mlir::Value& Arg : Args)
11171117
Arg = LocalizeValue(Arg);
11181118

1119+
assert(Loc.isValid() && "expecting a valid location for call");
11191120
auto Op = create<ApplyOp>(Loc, Fn, Args);
11201121

11211122
if (IsTailPos) return mlir::Value();

0 commit comments

Comments
 (0)