]> granicus.if.org Git - clang/commitdiff
DebugInfo: Fix PR19864 better - attribute the jump at the end of a range-for loop...
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 15 Aug 2014 20:50:45 +0000 (20:50 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 15 Aug 2014 20:50:45 +0000 (20:50 +0000)
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

lib/CodeGen/CGStmt.cpp
test/CodeGenCXX/debug-info-line-if.cpp

index df30892e8690129a1c8fc0dc5308f07d6039695e..970fdef17aa9fb6a075bcb5cbafb4641bba3655e 100644 (file)
@@ -974,6 +974,7 @@ CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S,
     EmitStmt(S.getBody());
   }
 
+  EmitStopPoint(&S);
   // If there is an increment, emit it next.
   EmitBlock(Continue.getBlock());
   EmitStmt(S.getInc());
index e14090f03f984714df729a711eda89a3209a240d..068e2a4a8c500803bb1a80ba1f254c433279e8fa 100644 (file)
@@ -9,12 +9,12 @@ int main() {
       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}
 
 }