r215766 - DebugInfo: Fix PR19864 better - attribute the jump at the end of a range-for loop, to the start of the loop.

David Blaikie dblaikie at gmail.com
Fri Aug 15 13:50:45 PDT 2014


Author: dblaikie
Date: Fri Aug 15 15:50:45 2014
New Revision: 215766

URL: http://llvm.org/viewvc/llvm-project?rev=215766&view=rev
Log:
DebugInfo: Fix PR19864 better - attribute the jump at the end of a range-for loop, to the start of the loop.

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).

Modified:
    cfe/trunk/lib/CodeGen/CGStmt.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-line-if.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=215766&r1=215765&r2=215766&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Aug 15 15:50:45 2014
@@ -974,6 +974,7 @@ CodeGenFunction::EmitCXXForRangeStmt(con
     EmitStmt(S.getBody());
   }
 
+  EmitStopPoint(&S);
   // If there is an increment, emit it next.
   EmitBlock(Continue.getBlock());
   EmitStmt(S.getInc());

Modified: cfe/trunk/test/CodeGenCXX/debug-info-line-if.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-line-if.cpp?rev=215766&r1=215765&r2=215766&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-line-if.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-line-if.cpp Fri Aug 15 15:50:45 2014
@@ -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}
 
 }





More information about the cfe-commits mailing list