Fix debug info for cleanup block.

llvm-svn: 101100
This commit is contained in:
Devang Patel 2010-04-13 00:08:43 +00:00
parent 9d94f04f27
commit 74c10507a6
3 changed files with 27 additions and 1 deletions

View 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);
}

View 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) {

View File

@ -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);
}
}