]> granicus.if.org Git - clang/commitdiff
DebugInfo: for loop backedge should be attributed to the start of the for statement.
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 22 Aug 2014 22:25:37 +0000 (22:25 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 22 Aug 2014 22:25:37 +0000 (22:25 +0000)
Similar to r215768 (which fixed the same case for while loops). To quote
r215768's commit message:

"A little test case simplification - this could be simplified further,
though there are certainly interesting connections to the if/else
construct so I'm hesitant to remove that entirely though it does appear
somewhat unrelated.

(similar fix to r215766, related to PR19864)"

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216297 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 6912378cadfb9c5297f176064151931abfea87ba..d8681d480f410efddbd9b14317a04ae506bf0ded 100644 (file)
@@ -894,6 +894,8 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
   BreakContinueStack.pop_back();
 
   ConditionScope.ForceCleanup();
+
+  EmitStopPoint(&S);
   EmitBranch(CondBlock);
 
   ForScope.ForceCleanup();
index 1ebe51cee5e1dcdfe95839f620811d568c37d474..6319993b14b10878308eaafcc8be576dbe679f47 100644 (file)
@@ -26,6 +26,18 @@ int main() {
 
   // CHECK: br label
   // CHECK: br label {{.*}}, !dbg [[DBG2:!.*]]
+
+#line 300
+  for (; a; )
+    if (b)
+      ++b; // CHECK: add nsw{{.*}}, 1
+    else
+      ++a; // CHECK: add nsw{{.*}}, 1
+
+  // CHECK: br label
+  // CHECK: br label {{.*}}, !dbg [[DBG3:!.*]]
+
   // CHECK: [[DBG1]] = metadata !{i32 100, i32 0, metadata !{{.*}}, null}
   // CHECK: [[DBG2]] = metadata !{i32 200, i32 0, metadata !{{.*}}, null}
+  // CHECK: [[DBG3]] = metadata !{i32 300, i32 0, metadata !{{.*}}, null}
 }