]> granicus.if.org Git - clang/commitdiff
Fix debug info for cleanup block.
authorDevang Patel <dpatel@apple.com>
Tue, 13 Apr 2010 00:08:43 +0000 (00:08 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 13 Apr 2010 00:08:43 +0000 (00:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101100 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGStmt.cpp
lib/CodeGen/CodeGenFunction.cpp
test/CodeGenCXX/destructor-debug-info.cpp [new file with mode: 0644]

index 6604b91db9ff25c87668bc2ca0f3d863a70901de..07c96d82ca7da477b97c4580a41d2dd89b2d02b2 100644 (file)
@@ -160,7 +160,7 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
     EmitStmt(*I);
 
   if (DI) {
-    DI->setLocation(S.getLBracLoc());
+    DI->setLocation(S.getRBracLoc());
     DI->EmitRegionEnd(CurFn, Builder);
   }
 
index f38d8a132f02880d9cf00145638033bfb8f48d70..110a8dc812d4034304ae31ee123ac1cc2cf0b7f4 100644 (file)
@@ -749,6 +749,11 @@ void CodeGenFunction::EmitCleanupBlock() {
     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 (file)
index 0000000..9e32275
--- /dev/null
@@ -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);
+  }
+}