]> granicus.if.org Git - clang/commitdiff
Do not line number entry for unconditional branches. Usually, users do not want to...
authorDevang Patel <dpatel@apple.com>
Tue, 29 Mar 2011 18:35:54 +0000 (18:35 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 29 Mar 2011 18:35:54 +0000 (18:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128471 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGStmt.cpp
test/CodeGen/debug-info-line2.c [new file with mode: 0644]
test/CodeGenObjC/debug-info-foreach.m

index 24acf65739805a2f1c29cefaa4f0bef237639dc7..add85a2a068bdc1d610501f1ab72bebdbd697c3e 100644 (file)
@@ -270,6 +270,9 @@ void CodeGenFunction::EmitBranch(llvm::BasicBlock *Target) {
     // terminated, don't touch it.
   } else {
     // Otherwise, create a fall-through branch.
+    // There is no need to emit line number for unconditional branch.
+    if (getDebugInfo())
+      Builder.SetCurrentDebugLocation(llvm::DebugLoc());
     Builder.CreateBr(Target);
   }
 
diff --git a/test/CodeGen/debug-info-line2.c b/test/CodeGen/debug-info-line2.c
new file mode 100644 (file)
index 0000000..bf3250d
--- /dev/null
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -g -emit-llvm -o - %s | FileCheck %s
+// Radar 9199234
+
+int bar();
+int foo(int i) {
+       int j = 0;
+       if (i) {
+               j = bar();
+//CHECK:  store i32 %call, i32* %j, align 4, !dbg 
+//CHECK-NOT:  br label %if.end, !dbg 
+       } 
+       else
+       {
+               j = bar() + 2;
+       }
+       return j;
+}
index c056e0e249de5cfad29bf2a26fba1c9aaba65018..89b409c7169e69ebe3c408eef8ad4175c669e6b7 100644 (file)
@@ -4,10 +4,17 @@
 
 @class NSArray;
 
+int i;
 void f(NSArray *a) {
   id keys;
   for (id thisKey in keys) {
+    int j = i;
+    ++j;
+    i = j;
   }
   for (id thisKey in keys) {
+    int k = i;
+    ++k;
+    i = k;
   }
 }