From: David Blaikie Date: Fri, 22 Aug 2014 22:25:37 +0000 (+0000) Subject: DebugInfo: for loop backedge should be attributed to the start of the for statement. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ed816192a37eefceb0bd501bc935501f4b8e745;p=clang DebugInfo: for loop backedge should be attributed to the start of the for statement. 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 --- diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 6912378cad..d8681d480f 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -894,6 +894,8 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S, BreakContinueStack.pop_back(); ConditionScope.ForceCleanup(); + + EmitStopPoint(&S); EmitBranch(CondBlock); ForScope.ForceCleanup(); diff --git a/test/CodeGenCXX/debug-info-line-if.cpp b/test/CodeGenCXX/debug-info-line-if.cpp index 1ebe51cee5..6319993b14 100644 --- a/test/CodeGenCXX/debug-info-line-if.cpp +++ b/test/CodeGenCXX/debug-info-line-if.cpp @@ -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} }