]> granicus.if.org Git - clang/commitdiff
Carry the debug information from single exit unified return block
authorEric Christopher <echristo@apple.com>
Fri, 9 Sep 2011 21:53:04 +0000 (21:53 +0000)
committerEric Christopher <echristo@apple.com>
Fri, 9 Sep 2011 21:53:04 +0000 (21:53 +0000)
along with the new insert point.

Fixes PR10829

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

lib/CodeGen/CodeGenFunction.cpp
test/CodeGen/debug-info-line3.c [new file with mode: 0644]

index 7e8415bb268f2f4f99545eea0f24dbaf5693cf3a..a16f10e6541e229defa1e6e8fd908e2830b69ea2 100644 (file)
@@ -116,7 +116,8 @@ void CodeGenFunction::EmitReturnBlock() {
       dyn_cast<llvm::BranchInst>(*ReturnBlock.getBlock()->use_begin());
     if (BI && BI->isUnconditional() &&
         BI->getSuccessor(0) == ReturnBlock.getBlock()) {
-      // Reset insertion point and delete the branch.
+      // Reset insertion point, including debug location, and delete the branch.
+      Builder.SetCurrentDebugLocation(BI->getDebugLoc());
       Builder.SetInsertPoint(BI->getParent());
       BI->eraseFromParent();
       delete ReturnBlock.getBlock();
diff --git a/test/CodeGen/debug-info-line3.c b/test/CodeGen/debug-info-line3.c
new file mode 100644 (file)
index 0000000..645ffb9
--- /dev/null
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -g -S -emit-llvm %s -o - | FileCheck %s
+
+void func(char c, char* d)
+{
+  *d = c + 1;
+  return;
+  
+
+  
+  
+  
+  
+}
+
+// CHECK: ret void, !dbg !19
+// CHECK: !19 = metadata !{i32 6,