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 ![[CLEANUP:[0-9]+]] 8 // CHECK: ret i32 0, !dbg ![[RET:[0-9]+]] 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 16 class C { 17 public: 18 ~C() {} 19 int i; 20 }; 21 22 int foo() 23 { 24 C c; 25 c.i = 42; 26 // This breakpoint should be at/before the cleanup code. 27 // CHECK: ![[CLEANUP]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} 28 return 0; 29 // CHECK: ![[RET]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} 30 } 31 32 void bar() 33 { 34 if (!foo()) 35 // CHECK: {{.*}} = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} 36 return; 37 38 if (foo()) { 39 C c; 40 c.i = foo(); 41 } 42 // Clang creates only a single ret instruction. Make sure it is at a useful line. 43 // CHECK: ![[RETBAR]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} 44 } 45 46 void baz() 47 { 48 if (!foo()) 49 // CHECK: ![[SCOPE1:.*]] = metadata !{{{.*}}, i32 [[@LINE-1]], {{.*}}} ; [ DW_TAG_lexical_block ] 50 // CHECK: {{.*}} = metadata !{i32 [[@LINE+1]], i32 0, metadata ![[SCOPE1]], null} 51 return; 52 53 if (foo()) { 54 // no cleanup 55 // CHECK: {{.*}} = metadata !{i32 [[@LINE+2]], i32 0, metadata ![[SCOPE2:.*]], null} 56 // CHECK: ![[SCOPE2]] = metadata !{{{.*}}, i32 [[@LINE-3]], {{.*}}} ; [ DW_TAG_lexical_block ] 57 return; 58 } 59 // CHECK: ![[RETBAZ]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} 60 } 61