Fix debug info for cleanup block.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101100 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index 6604b91..07c96d8 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -160,7 +160,7 @@
     EmitStmt(*I);
 
   if (DI) {
-    DI->setLocation(S.getLBracLoc());
+    DI->setLocation(S.getRBracLoc());
     DI->EmitRegionEnd(CurFn, Builder);
   }
 
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index f38d8a1..110a8dc 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -749,6 +749,11 @@
     return;
   }
 
+  //  Scrub debug location info.
+  for (llvm::BasicBlock::iterator LBI = Info.CleanupBlock->begin(),
+         LBE = Info.CleanupBlock->end(); LBI != LBE; ++LBI)
+    Builder.SetInstDebugLocation(LBI);
+
   llvm::BasicBlock *CurBB = Builder.GetInsertBlock();
   if (CurBB && !CurBB->getTerminator() &&
       Info.CleanupBlock->getNumUses() == 0) {
diff --git a/test/CodeGenCXX/destructor-debug-info.cpp b/test/CodeGenCXX/destructor-debug-info.cpp
new file mode 100644
index 0000000..9e32275
--- /dev/null
+++ b/test/CodeGenCXX/destructor-debug-info.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -g -S -emit-llvm -o %t %s
+// RUN: grep "i32 20, i32 3, metadata" %t | count 1
+// Check there is a line number entry for line 20 where b1 is destructed.
+class A { int a; };
+class B {
+public:
+  B() { a = new A; }
+  ~B() { delete a; }
+private:
+  A *a;
+};
+
+void fn(B b);
+
+int i;
+void foo() {
+  if (i) {
+    B b1;
+    fn (b1);
+  }
+}