This avoids debuggers stepping to strange places (like the last
statement in the loop body, or the first statement in the if).
This is not the whole answer, though - similar bugs no doubt exist in
other loops (patches to follow) and attributing exception handling code
to the correct line is also tricky (based on the previous fix to
PR19864, exception handling is still erroneously attributed to the 'if'
line).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215766
91177308-0d34-0410-b5e6-
96231b3b80d8
EmitStmt(S.getBody());
}
+ EmitStopPoint(&S);
// If there is an increment, emit it next.
EmitBlock(Continue.getBlock());
EmitStmt(S.getInc());
else if (x >= 0)
++a; // CHECK: add nsw{{.*}}, 1
// The continuation block if the if statement should not share the
- // location of the ++a statement. Having it point to the end of
- // the condition is not ideal either, but it's less missleading.
+ // location of the ++a statement. The branch back to the start of the loop
+ // should be attributed to the loop header line.
// CHECK: br label
// CHECK: br label
// CHECK: br label {{.*}}, !dbg ![[DBG:.*]]
- // CHECK: ![[DBG]] = metadata !{i32 [[@LINE-11]], i32 0, metadata !{{.*}}, null}
+ // CHECK: ![[DBG]] = metadata !{i32 [[@LINE-12]], i32 0, metadata !{{.*}}, null}
}