Adrian Prantl | d072e59 | 2013-05-03 20:11:48 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s |
| 2 | |
Adrian Prantl | 6fd131c | 2013-07-24 20:44:20 +0000 | [diff] [blame] | 3 | // Check the line numbers for cleanup code with EH in combination with |
Adrian Prantl | d072e59 | 2013-05-03 20:11:48 +0000 | [diff] [blame] | 4 | // simple return expressions. |
| 5 | |
| 6 | // CHECK: define {{.*}}foo |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 7 | // CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}), !dbg ![[RET:[0-9]+]] |
| 8 | // CHECK: ret i32 0, !dbg ![[RET]] |
Adrian Prantl | d072e59 | 2013-05-03 20:11:48 +0000 | [diff] [blame] | 9 | |
Adrian Prantl | 3b47759 | 2013-07-25 00:23:42 +0000 | [diff] [blame] | 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 | |
Adrian Prantl | d072e59 | 2013-05-03 20:11:48 +0000 | [diff] [blame] | 16 | class C { |
| 17 | public: |
| 18 | ~C() {} |
| 19 | int i; |
| 20 | }; |
| 21 | |
| 22 | int foo() |
| 23 | { |
| 24 | C c; |
| 25 | c.i = 42; |
Adrian Prantl | d072e59 | 2013-05-03 20:11:48 +0000 | [diff] [blame] | 26 | return 0; |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 27 | // This breakpoint should be at/before the cleanup code. |
| 28 | // CHECK: ![[RET]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}}) |
Adrian Prantl | d072e59 | 2013-05-03 20:11:48 +0000 | [diff] [blame] | 29 | } |
Adrian Prantl | 3b47759 | 2013-07-25 00:23:42 +0000 | [diff] [blame] | 30 | |
| 31 | void bar() |
| 32 | { |
| 33 | if (!foo()) |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 34 | // CHECK: {{.*}} = !MDLocation(line: [[@LINE+1]], scope: !{{.*}}) |
Adrian Prantl | 3b47759 | 2013-07-25 00:23:42 +0000 | [diff] [blame] | 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. |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 42 | // CHECK: ![[RETBAR]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}}) |
Adrian Prantl | 3b47759 | 2013-07-25 00:23:42 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | void baz() |
| 46 | { |
| 47 | if (!foo()) |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 48 | // CHECK: ![[SCOPE1:.*]] = distinct !MDLexicalBlock({{.*}}, line: [[@LINE-1]]) |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 49 | // CHECK: {{.*}} = !MDLocation(line: [[@LINE+1]], scope: ![[SCOPE1]]) |
Adrian Prantl | 3b47759 | 2013-07-25 00:23:42 +0000 | [diff] [blame] | 50 | return; |
| 51 | |
| 52 | if (foo()) { |
| 53 | // no cleanup |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 54 | // CHECK: {{.*}} = !MDLocation(line: [[@LINE+2]], scope: ![[SCOPE2:.*]]) |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 55 | // CHECK: ![[SCOPE2]] = distinct !MDLexicalBlock({{.*}}, line: [[@LINE-3]]) |
Adrian Prantl | 3b47759 | 2013-07-25 00:23:42 +0000 | [diff] [blame] | 56 | return; |
| 57 | } |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 58 | // CHECK: ![[RETBAZ]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}}) |
Adrian Prantl | 3b47759 | 2013-07-25 00:23:42 +0000 | [diff] [blame] | 59 | } |