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 - -UDESUGAR %s | opt -instnamer -S | FileCheck %s |
| 2 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -DDESUGAR %s | opt -instnamer -S | FileCheck %s |
| 3 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -DDESUGAR -DTEMPLATE %s | opt -instnamer -S | FileCheck %s |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 4 | |
| 5 | struct A { |
| 6 | A(); |
| 7 | A(const A &); |
| 8 | ~A(); |
| 9 | }; |
| 10 | |
| 11 | struct B { |
| 12 | B(); |
| 13 | B(const B &); |
| 14 | ~B(); |
| 15 | }; |
| 16 | |
| 17 | struct C { |
| 18 | C(const B &); |
| 19 | C(const C &); |
| 20 | ~C(); |
| 21 | }; |
| 22 | |
| 23 | struct E; |
| 24 | struct D { |
| 25 | D(const C &); |
| 26 | D(const D &); |
| 27 | ~D(); |
| 28 | }; |
| 29 | E begin(D); |
| 30 | E end(D); |
| 31 | |
| 32 | struct F; |
| 33 | struct G; |
| 34 | struct H; |
| 35 | struct E { |
| 36 | E(const E &); |
| 37 | ~E(); |
| 38 | F operator*(); |
| 39 | G operator++(); |
| 40 | H operator!=(const E &o); |
| 41 | }; |
| 42 | |
| 43 | struct I; |
| 44 | struct F { |
| 45 | F(const F &); |
| 46 | ~F(); |
| 47 | operator I(); |
| 48 | }; |
| 49 | |
| 50 | struct G { |
| 51 | G(const G &); |
| 52 | ~G(); |
| 53 | operator bool(); |
| 54 | }; |
| 55 | |
| 56 | struct H { |
| 57 | H(const H &); |
| 58 | ~H(); |
| 59 | operator bool(); |
| 60 | }; |
| 61 | |
| 62 | struct I { |
| 63 | I(const I &); |
| 64 | ~I(); |
| 65 | }; |
| 66 | |
| 67 | void body(const I &); |
| 68 | |
Richard Smith | f747ce6 | 2011-09-04 23:52:03 +0000 | [diff] [blame] | 69 | #ifdef TEMPLATE |
| 70 | template<typename D> |
| 71 | #endif |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 72 | void for_temps() { |
| 73 | A a; |
| 74 | #ifdef DESUGAR |
| 75 | { |
| 76 | auto && __range = D(B()); |
| 77 | for (auto __begin = begin(__range), __end = end(__range); |
| 78 | __begin != __end; ++__begin) { |
| 79 | I i = *__begin; |
| 80 | body(i); |
| 81 | } |
| 82 | } |
| 83 | #else |
| 84 | for (I i : D(B())) { |
| 85 | body(i); |
| 86 | } |
| 87 | #endif |
| 88 | } |
| 89 | |
Richard Smith | f747ce6 | 2011-09-04 23:52:03 +0000 | [diff] [blame] | 90 | #ifdef TEMPLATE |
| 91 | template void for_temps<D>(); |
| 92 | #endif |
| 93 | |
| 94 | // CHECK: define {{.*}}for_temps |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 95 | // CHECK: call void @_ZN1AC1Ev( |
| 96 | // CHECK: call void @_ZN1BC1Ev( |
| 97 | // CHECK: call void @_ZN1CC1ERK1B( |
| 98 | // CHECK: call void @_ZN1DC1ERK1C( |
| 99 | // CHECK: call void @_ZN1CD1Ev( |
| 100 | // CHECK: call void @_ZN1BD1Ev( |
| 101 | // CHECK: call void @_ZN1DC1ERKS_( |
| 102 | // CHECK: call void @_Z5begin1D( |
| 103 | // CHECK: call void @_ZN1DD1Ev( |
| 104 | // CHECK: call void @_ZN1DC1ERKS_( |
| 105 | // CHECK: call void @_Z3end1D( |
| 106 | // CHECK: call void @_ZN1DD1Ev( |
| 107 | // CHECK: br label %[[COND:.*]] |
| 108 | |
| 109 | // CHECK: [[COND]]: |
| 110 | // CHECK: call void @_ZN1EneERKS_( |
| 111 | // CHECK: %[[CMP:.*]] = call zeroext i1 @_ZN1HcvbEv( |
| 112 | // CHECK: call void @_ZN1HD1Ev( |
| 113 | // CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[CLEANUP:.*]] |
| 114 | |
| 115 | // CHECK: [[CLEANUP]]: |
| 116 | // CHECK: call void @_ZN1ED1Ev( |
| 117 | // CHECK: call void @_ZN1ED1Ev( |
| 118 | // In for-range: |
| 119 | // call void @_ZN1DD1Ev( |
| 120 | // CHECK: br label %[[END:.*]] |
| 121 | |
| 122 | // CHECK: [[BODY]]: |
| 123 | // CHECK: call void @_ZN1EdeEv( |
| 124 | // CHECK: call void @_ZN1Fcv1IEv( |
| 125 | // CHECK: call void @_ZN1FD1Ev( |
| 126 | // CHECK: call void @_Z4bodyRK1I( |
| 127 | // CHECK: call void @_ZN1ID1Ev( |
| 128 | // CHECK: br label %[[INC:.*]] |
| 129 | |
| 130 | // CHECK: [[INC]]: |
| 131 | // CHECK: call void @_ZN1EppEv( |
| 132 | // CHECK: call void @_ZN1GD1Ev( |
| 133 | // CHECK: br label %[[COND]] |
| 134 | |
| 135 | // CHECK: [[END]]: |
| 136 | // In desugared version: |
| 137 | // call void @_ZN1DD1Ev( |
| 138 | // CHECK: call void @_ZN1AD1Ev( |
| 139 | // CHECK: ret void |