blob: c705702f4f51e2da5f45d1cf56fa4a4b59bc5ab5 [file] [log] [blame]
Richard Smith762bb9d2011-10-13 22:29:44 +00001// 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 Smithad762fc2011-04-14 22:09:26 +00004
5struct A {
6 A();
7 A(const A &);
8 ~A();
9};
10
11struct B {
12 B();
13 B(const B &);
14 ~B();
15};
16
17struct C {
18 C(const B &);
19 C(const C &);
20 ~C();
21};
22
23struct E;
24struct D {
25 D(const C &);
26 D(const D &);
27 ~D();
28};
29E begin(D);
30E end(D);
31
32struct F;
33struct G;
34struct H;
35struct E {
36 E(const E &);
37 ~E();
38 F operator*();
39 G operator++();
40 H operator!=(const E &o);
41};
42
43struct I;
44struct F {
45 F(const F &);
46 ~F();
47 operator I();
48};
49
50struct G {
51 G(const G &);
52 ~G();
53 operator bool();
54};
55
56struct H {
57 H(const H &);
58 ~H();
59 operator bool();
60};
61
62struct I {
63 I(const I &);
64 ~I();
65};
66
67void body(const I &);
68
Richard Smithf747ce62011-09-04 23:52:03 +000069#ifdef TEMPLATE
70template<typename D>
71#endif
Richard Smithad762fc2011-04-14 22:09:26 +000072void 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 Smithf747ce62011-09-04 23:52:03 +000090#ifdef TEMPLATE
91template void for_temps<D>();
92#endif
93
94// CHECK: define {{.*}}for_temps
Richard Smithad762fc2011-04-14 22:09:26 +000095// 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