Richard Smith | 762bb9d | 2011-10-13 22:29:44 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - %s | opt -instnamer -S | FileCheck %s |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 2 | |
| 3 | struct A { |
| 4 | A(); |
| 5 | A(const A&); |
| 6 | ~A(); |
| 7 | }; |
| 8 | |
| 9 | struct B { |
| 10 | B(); |
| 11 | B(const B&); |
| 12 | ~B(); |
| 13 | }; |
| 14 | |
| 15 | struct C { |
| 16 | C(); |
| 17 | C(const C&); |
| 18 | ~C(); |
| 19 | }; |
| 20 | |
| 21 | struct D { |
| 22 | D(); |
| 23 | D(const D&); |
| 24 | ~D(); |
| 25 | |
| 26 | B *begin(); |
| 27 | B *end(); |
| 28 | }; |
| 29 | |
| 30 | namespace std { |
| 31 | B *begin(C&); |
| 32 | B *end(C&); |
| 33 | } |
| 34 | |
| 35 | extern B array[5]; |
| 36 | |
| 37 | // CHECK: define void @_Z9for_arrayv( |
| 38 | void for_array() { |
| 39 | // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]]) |
| 40 | A a; |
| 41 | for (B b : array) { |
| 42 | // CHECK-NOT: 5begin |
| 43 | // CHECK-NOT: 3end |
| 44 | // CHECK: getelementptr {{.*}}, i32 0 |
| 45 | // CHECK: getelementptr {{.*}}, i64 5 |
| 46 | // CHECK: br label %[[COND:.*]] |
| 47 | |
| 48 | // CHECK: [[COND]]: |
| 49 | // CHECK: %[[CMP:.*]] = icmp ne |
| 50 | // CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[END:.*]] |
| 51 | |
| 52 | // CHECK: [[BODY]]: |
| 53 | // CHECK: call void @_ZN1BC1ERKS_( |
| 54 | // CHECK: call void @_ZN1BD1Ev( |
| 55 | // CHECK: br label %[[INC:.*]] |
| 56 | |
| 57 | // CHECK: [[INC]]: |
| 58 | // CHECK: getelementptr {{.*}} i32 1 |
| 59 | // CHECK: br label %[[COND]] |
| 60 | } |
| 61 | // CHECK: [[END]]: |
| 62 | // CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]]) |
| 63 | // CHECK: ret void |
| 64 | } |
| 65 | |
| 66 | // CHECK: define void @_Z9for_rangev( |
| 67 | void for_range() { |
| 68 | // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]]) |
| 69 | A a; |
| 70 | for (B b : C()) { |
| 71 | // CHECK: call void @_ZN1CC1Ev( |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 72 | // CHECK: = call %struct.B* @_ZSt5beginR1C( |
| 73 | // CHECK: = call %struct.B* @_ZSt3endR1C( |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 74 | // CHECK: br label %[[COND:.*]] |
| 75 | |
| 76 | // CHECK: [[COND]]: |
| 77 | // CHECK: %[[CMP:.*]] = icmp ne |
| 78 | // CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[CLEANUP:.*]] |
| 79 | |
| 80 | // CHECK: [[CLEANUP]]: |
| 81 | // CHECK: call void @_ZN1CD1Ev( |
| 82 | // CHECK: br label %[[END:.*]] |
| 83 | |
| 84 | // CHECK: [[BODY]]: |
| 85 | // CHECK: call void @_ZN1BC1ERKS_( |
| 86 | // CHECK: call void @_ZN1BD1Ev( |
| 87 | // CHECK: br label %[[INC:.*]] |
| 88 | |
| 89 | // CHECK: [[INC]]: |
| 90 | // CHECK: getelementptr {{.*}} i32 1 |
| 91 | // CHECK: br label %[[COND]] |
| 92 | } |
| 93 | // CHECK: [[END]]: |
| 94 | // CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]]) |
| 95 | // CHECK: ret void |
| 96 | } |
| 97 | |
| 98 | // CHECK: define void @_Z16for_member_rangev( |
| 99 | void for_member_range() { |
| 100 | // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]]) |
| 101 | A a; |
| 102 | for (B b : D()) { |
| 103 | // CHECK: call void @_ZN1DC1Ev( |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 104 | // CHECK: = call %struct.B* @_ZN1D5beginEv( |
| 105 | // CHECK: = call %struct.B* @_ZN1D3endEv( |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 106 | // CHECK: br label %[[COND:.*]] |
| 107 | |
| 108 | // CHECK: [[COND]]: |
| 109 | // CHECK: %[[CMP:.*]] = icmp ne |
| 110 | // CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[CLEANUP:.*]] |
| 111 | |
| 112 | // CHECK: [[CLEANUP]]: |
| 113 | // CHECK: call void @_ZN1DD1Ev( |
| 114 | // CHECK: br label %[[END:.*]] |
| 115 | |
| 116 | // CHECK: [[BODY]]: |
| 117 | // CHECK: call void @_ZN1BC1ERKS_( |
| 118 | // CHECK: call void @_ZN1BD1Ev( |
| 119 | // CHECK: br label %[[INC:.*]] |
| 120 | |
| 121 | // CHECK: [[INC]]: |
| 122 | // CHECK: getelementptr {{.*}} i32 1 |
| 123 | // CHECK: br label %[[COND]] |
| 124 | } |
| 125 | // CHECK: [[END]]: |
| 126 | // CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]]) |
| 127 | // CHECK: ret void |
| 128 | } |