linetable-cleanup.cpp revision 0e2c34f92f00628d48968dfea096d36381f494cb
1// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s 2 3// Check the line numbers for cleanup code with EH in combination with 4// simple return expressions. 5 6// CHECK: define {{.*}}foo 7// CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}), !dbg ![[RET:[0-9]+]] 8// CHECK: ret i32 0, !dbg ![[RET]] 9 10// CHECK: define {{.*}}bar 11// CHECK: ret void, !dbg ![[RETBAR:[0-9]+]] 12 13// CHECK: define {{.*}}baz 14// CHECK: ret void, !dbg ![[RETBAZ:[0-9]+]] 15 16class C { 17public: 18 ~C() {} 19 int i; 20}; 21 22int foo() 23{ 24 C c; 25 c.i = 42; 26 return 0; 27 // This breakpoint should be at/before the cleanup code. 28 // CHECK: ![[RET]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}}) 29} 30 31void bar() 32{ 33 if (!foo()) 34 // CHECK: {{.*}} = !MDLocation(line: [[@LINE+1]], scope: !{{.*}}) 35 return; 36 37 if (foo()) { 38 C c; 39 c.i = foo(); 40 } 41 // Clang creates only a single ret instruction. Make sure it is at a useful line. 42 // CHECK: ![[RETBAR]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}}) 43} 44 45void baz() 46{ 47 if (!foo()) 48 // CHECK: ![[SCOPE1:.*]] = !{!"0xb\00[[@LINE-1]]\00{{.*}}", {{.*}} ; [ DW_TAG_lexical_block ] 49 // CHECK: {{.*}} = !MDLocation(line: [[@LINE+1]], scope: ![[SCOPE1]]) 50 return; 51 52 if (foo()) { 53 // no cleanup 54 // CHECK: {{.*}} = !MDLocation(line: [[@LINE+2]], scope: ![[SCOPE2:.*]]) 55 // CHECK: ![[SCOPE2]] = !{!"0xb\00[[@LINE-3]]\00{{.*}}", {{.*}} ; [ DW_TAG_lexical_block ] 56 return; 57 } 58 // CHECK: ![[RETBAZ]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}}) 59} 60