Mercurial > hg > CbC > CbC_llvm
comparison clang/test/CodeGenCXX/for-range.cpp @ 150:1d019706d866
LLVM10
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 15:10:13 +0900 |
parents | |
children | 2e18cbf3894f |
comparison
equal
deleted
inserted
replaced
147:c2174574ed3a | 150:1d019706d866 |
---|---|
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - %s | opt -instnamer -S | FileCheck %s | |
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 B *begin(C&); | |
31 B *end(C&); | |
32 | |
33 extern B array[5]; | |
34 | |
35 // CHECK-LABEL: define void @_Z9for_arrayv( | |
36 void for_array() { | |
37 // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]]) | |
38 A a; | |
39 for (B b : array) { | |
40 // CHECK-NOT: 5begin | |
41 // CHECK-NOT: 3end | |
42 // CHECK: getelementptr {{.*}}, i64 0 | |
43 // CHECK: getelementptr {{.*}}, i64 5 | |
44 // CHECK: br label %[[COND:.*]] | |
45 | |
46 // CHECK: [[COND]]: | |
47 // CHECK: %[[CMP:.*]] = icmp ne | |
48 // CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[END:.*]] | |
49 | |
50 // CHECK: [[BODY]]: | |
51 // CHECK: call void @_ZN1BC1ERKS_( | |
52 // CHECK: call void @_ZN1BD1Ev( | |
53 // CHECK: br label %[[INC:.*]] | |
54 | |
55 // CHECK: [[INC]]: | |
56 // CHECK: getelementptr {{.*}} i32 1 | |
57 // CHECK: br label %[[COND]] | |
58 } | |
59 // CHECK: [[END]]: | |
60 // CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]]) | |
61 // CHECK: ret void | |
62 } | |
63 | |
64 // CHECK-LABEL: define void @_Z9for_rangev( | |
65 void for_range() { | |
66 // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]]) | |
67 A a; | |
68 for (B b : C()) { | |
69 // CHECK: call void @_ZN1CC1Ev( | |
70 // CHECK: = call %struct.B* @_Z5beginR1C( | |
71 // CHECK: = call %struct.B* @_Z3endR1C( | |
72 // CHECK: br label %[[COND:.*]] | |
73 | |
74 // CHECK: [[COND]]: | |
75 // CHECK: %[[CMP:.*]] = icmp ne | |
76 // CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[CLEANUP:.*]] | |
77 | |
78 // CHECK: [[CLEANUP]]: | |
79 // CHECK: call void @_ZN1CD1Ev( | |
80 // CHECK: br label %[[END:.*]] | |
81 | |
82 // CHECK: [[BODY]]: | |
83 // CHECK: call void @_ZN1BC1ERKS_( | |
84 // CHECK: call void @_ZN1BD1Ev( | |
85 // CHECK: br label %[[INC:.*]] | |
86 | |
87 // CHECK: [[INC]]: | |
88 // CHECK: getelementptr {{.*}} i32 1 | |
89 // CHECK: br label %[[COND]] | |
90 } | |
91 // CHECK: [[END]]: | |
92 // CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]]) | |
93 // CHECK: ret void | |
94 } | |
95 | |
96 // CHECK-LABEL: define void @_Z16for_member_rangev( | |
97 void for_member_range() { | |
98 // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]]) | |
99 A a; | |
100 for (B b : D()) { | |
101 // CHECK: call void @_ZN1DC1Ev( | |
102 // CHECK: = call %struct.B* @_ZN1D5beginEv( | |
103 // CHECK: = call %struct.B* @_ZN1D3endEv( | |
104 // CHECK: br label %[[COND:.*]] | |
105 | |
106 // CHECK: [[COND]]: | |
107 // CHECK: %[[CMP:.*]] = icmp ne | |
108 // CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[CLEANUP:.*]] | |
109 | |
110 // CHECK: [[CLEANUP]]: | |
111 // CHECK: call void @_ZN1DD1Ev( | |
112 // CHECK: br label %[[END:.*]] | |
113 | |
114 // CHECK: [[BODY]]: | |
115 // CHECK: call void @_ZN1BC1ERKS_( | |
116 // CHECK: call void @_ZN1BD1Ev( | |
117 // CHECK: br label %[[INC:.*]] | |
118 | |
119 // CHECK: [[INC]]: | |
120 // CHECK: getelementptr {{.*}} i32 1 | |
121 // CHECK: br label %[[COND]] | |
122 } | |
123 // CHECK: [[END]]: | |
124 // CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]]) | |
125 // CHECK: ret void | |
126 } |