Anders Carlsson | fa4f550 | 2009-10-18 21:11:11 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s |
Anders Carlsson | 7a039eb | 2009-08-15 22:30:50 +0000 | [diff] [blame] | 2 | struct A { |
3 | A(); | ||||
4 | ~A(); | ||||
5 | void f(); | ||||
6 | }; | ||||
7 | |||||
Anders Carlsson | ec74c59 | 2009-08-16 03:06:32 +0000 | [diff] [blame] | 8 | void f1() { |
Anders Carlsson | fa4f550 | 2009-10-18 21:11:11 +0000 | [diff] [blame] | 9 | // CHECK: call void @_ZN1AC1Ev |
10 | // CHECK: call void @_ZN1AD1Ev | ||||
Anders Carlsson | ec74c59 | 2009-08-16 03:06:32 +0000 | [diff] [blame] | 11 | (void)A(); |
Anders Carlsson | fa4f550 | 2009-10-18 21:11:11 +0000 | [diff] [blame] | 12 | |
13 | // CHECK: call void @_ZN1AC1Ev | ||||
14 | // CHECK: call void @_ZN1AD1Ev | ||||
Anders Carlsson | 7a039eb | 2009-08-15 22:30:50 +0000 | [diff] [blame] | 15 | A().f(); |
16 | } | ||||
Anders Carlsson | ec74c59 | 2009-08-16 03:06:32 +0000 | [diff] [blame] | 17 | |
Anders Carlsson | 6f68027 | 2009-08-16 03:42:12 +0000 | [diff] [blame] | 18 | // Function calls |
Anders Carlsson | ec74c59 | 2009-08-16 03:06:32 +0000 | [diff] [blame] | 19 | struct B { |
20 | B(); | ||||
21 | ~B(); | ||||
22 | }; | ||||
23 | |||||
24 | B g(); | ||||
25 | |||||
Anders Carlsson | ec74c59 | 2009-08-16 03:06:32 +0000 | [diff] [blame] | 26 | void f2() { |
Anders Carlsson | fa4f550 | 2009-10-18 21:11:11 +0000 | [diff] [blame] | 27 | // CHECK-NOT: call void @_ZN1BC1Ev |
28 | // CHECK: call void @_ZN1BD1Ev | ||||
Anders Carlsson | ec74c59 | 2009-08-16 03:06:32 +0000 | [diff] [blame] | 29 | (void)g(); |
30 | } | ||||
31 | |||||
Anders Carlsson | 6f68027 | 2009-08-16 03:42:12 +0000 | [diff] [blame] | 32 | // Member function calls |
33 | struct C { | ||||
34 | C(); | ||||
35 | ~C(); | ||||
36 | |||||
37 | C f(); | ||||
38 | }; | ||||
39 | |||||
Anders Carlsson | 6f68027 | 2009-08-16 03:42:12 +0000 | [diff] [blame] | 40 | void f3() { |
Anders Carlsson | fa4f550 | 2009-10-18 21:11:11 +0000 | [diff] [blame] | 41 | // CHECK: call void @_ZN1CC1Ev |
42 | // CHECK: call void @_ZN1CD1Ev | ||||
43 | // CHECK: call void @_ZN1CD1Ev | ||||
Anders Carlsson | 6f68027 | 2009-08-16 03:42:12 +0000 | [diff] [blame] | 44 | C().f(); |
45 | } | ||||
46 | |||||
Anders Carlsson | a303f9e | 2009-08-16 03:53:54 +0000 | [diff] [blame] | 47 | // Function call operator |
48 | struct D { | ||||
49 | D(); | ||||
50 | ~D(); | ||||
51 | |||||
52 | D operator()(); | ||||
53 | }; | ||||
54 | |||||
Anders Carlsson | a303f9e | 2009-08-16 03:53:54 +0000 | [diff] [blame] | 55 | void f4() { |
Benjamin Kramer | 3114af3 | 2009-10-31 20:42:26 +0000 | [diff] [blame] | 56 | // CHECK: call void @_ZN1DC1Ev |
57 | // CHECK: call void @_ZN1DD1Ev | ||||
58 | // CHECK: call void @_ZN1DD1Ev | ||||
Anders Carlsson | a303f9e | 2009-08-16 03:53:54 +0000 | [diff] [blame] | 59 | D()(); |
60 | } | ||||
Anders Carlsson | 6f68027 | 2009-08-16 03:42:12 +0000 | [diff] [blame] | 61 | |
Anders Carlsson | 2d46eb2 | 2009-08-16 04:11:06 +0000 | [diff] [blame] | 62 | // Overloaded operators |
63 | struct E { | ||||
64 | E(); | ||||
65 | ~E(); | ||||
66 | E operator+(const E&); | ||||
67 | E operator!(); | ||||
68 | }; | ||||
69 | |||||
Anders Carlsson | 2d46eb2 | 2009-08-16 04:11:06 +0000 | [diff] [blame] | 70 | void f5() { |
Anders Carlsson | fa4f550 | 2009-10-18 21:11:11 +0000 | [diff] [blame] | 71 | // CHECK: call void @_ZN1EC1Ev |
72 | // CHECK: call void @_ZN1EC1Ev | ||||
73 | // CHECK: call void @_ZN1ED1Ev | ||||
74 | // CHECK: call void @_ZN1ED1Ev | ||||
75 | // CHECK: call void @_ZN1ED1Ev | ||||
Anders Carlsson | 2d46eb2 | 2009-08-16 04:11:06 +0000 | [diff] [blame] | 76 | E() + E(); |
Anders Carlsson | fa4f550 | 2009-10-18 21:11:11 +0000 | [diff] [blame] | 77 | |
78 | // CHECK: call void @_ZN1EC1Ev | ||||
79 | // CHECK: call void @_ZN1ED1Ev | ||||
80 | // CHECK: call void @_ZN1ED1Ev | ||||
Anders Carlsson | 2d46eb2 | 2009-08-16 04:11:06 +0000 | [diff] [blame] | 81 | !E(); |
82 | } | ||||
Anders Carlsson | 6f68027 | 2009-08-16 03:42:12 +0000 | [diff] [blame] | 83 | |
Anders Carlsson | 283e4d5 | 2009-09-14 01:30:44 +0000 | [diff] [blame] | 84 | struct F { |
85 | F(); | ||||
86 | ~F(); | ||||
87 | F& f(); | ||||
88 | }; | ||||
89 | |||||
Anders Carlsson | 283e4d5 | 2009-09-14 01:30:44 +0000 | [diff] [blame] | 90 | void f6() { |
Anders Carlsson | fa4f550 | 2009-10-18 21:11:11 +0000 | [diff] [blame] | 91 | // CHECK: call void @_ZN1FC1Ev |
92 | // CHECK: call void @_ZN1FD1Ev | ||||
Anders Carlsson | 283e4d5 | 2009-09-14 01:30:44 +0000 | [diff] [blame] | 93 | F().f(); |
94 | } | ||||
95 | |||||
Anders Carlsson | 4fa2684 | 2009-10-18 21:20:14 +0000 | [diff] [blame] | 96 | struct G { |
97 | G(); | ||||
98 | G(A); | ||||
99 | ~G(); | ||||
100 | operator A(); | ||||
101 | }; | ||||
102 | |||||
103 | void a(const A&); | ||||
104 | |||||
105 | void f7() { | ||||
106 | // CHECK: call void @_ZN1AC1Ev | ||||
107 | // CHECK: call void @_Z1aRK1A | ||||
108 | // CHECK: call void @_ZN1AD1Ev | ||||
109 | a(A()); | ||||
110 | |||||
111 | // CHECK: call void @_ZN1GC1Ev | ||||
112 | // CHECK: call void @_ZN1Gcv1AEv | ||||
113 | // CHECK: call void @_Z1aRK1A | ||||
114 | // CHECK: call void @_ZN1AD1Ev | ||||
115 | // CHECK: call void @_ZN1GD1Ev | ||||
116 | a(G()); | ||||
117 | } | ||||
Anders Carlsson | 1faf674 | 2009-11-06 04:11:09 +0000 | [diff] [blame] | 118 | |
119 | namespace PR5077 { | ||||
120 | |||||
121 | struct A { | ||||
122 | A(); | ||||
123 | ~A(); | ||||
124 | int f(); | ||||
125 | }; | ||||
126 | |||||
127 | void f(); | ||||
128 | int g(const A&); | ||||
129 | |||||
130 | struct B { | ||||
131 | int a1; | ||||
132 | int a2; | ||||
133 | B(); | ||||
Anders Carlsson | 5e1b918 | 2009-11-06 04:19:02 +0000 | [diff] [blame] | 134 | ~B(); |
Anders Carlsson | 1faf674 | 2009-11-06 04:11:09 +0000 | [diff] [blame] | 135 | }; |
136 | |||||
137 | B::B() | ||||
138 | // CHECK: call void @_ZN6PR50771AC1Ev | ||||
139 | // CHECK: call i32 @_ZN6PR50771A1fEv | ||||
140 | // CHECK: call void @_ZN6PR50771AD1Ev | ||||
141 | : a1(A().f()) | ||||
142 | // CHECK: call void @_ZN6PR50771AC1Ev | ||||
143 | // CHECK: call i32 @_ZN6PR50771gERKNS_1AE | ||||
144 | // CHECK: call void @_ZN6PR50771AD1Ev | ||||
145 | , a2(g(A())) | ||||
146 | { | ||||
147 | // CHECK: call void @_ZN6PR50771fEv | ||||
148 | f(); | ||||
149 | } | ||||
150 | |||||
Anders Carlsson | 5e1b918 | 2009-11-06 04:19:02 +0000 | [diff] [blame] | 151 | struct C { |
152 | C(); | ||||
153 | |||||
154 | const B& b; | ||||
155 | }; | ||||
156 | |||||
157 | C::C() | ||||
158 | // CHECK: call void @_ZN6PR50771BC1Ev | ||||
159 | : b(B()) { | ||||
160 | // CHECK: call void @_ZN6PR50771fEv | ||||
161 | f(); | ||||
162 | |||||
163 | // CHECK: call void @_ZN6PR50771BD1Ev | ||||
164 | } | ||||
Anders Carlsson | 03d8ed4 | 2009-11-13 04:34:45 +0000 | [diff] [blame] | 165 | } |
Anders Carlsson | 5e1b918 | 2009-11-06 04:19:02 +0000 | [diff] [blame] | 166 | |
Anders Carlsson | 03d8ed4 | 2009-11-13 04:34:45 +0000 | [diff] [blame] | 167 | A f8() { |
168 | // CHECK: call void @_ZN1AC1Ev | ||||
169 | // CHECK-NOT: call void @_ZN1AD1Ev | ||||
170 | return A(); | ||||
171 | // CHECK: ret void | ||||
172 | } | ||||
Anders Carlsson | 5e1b918 | 2009-11-06 04:19:02 +0000 | [diff] [blame] | 173 | |
Anders Carlsson | 03d8ed4 | 2009-11-13 04:34:45 +0000 | [diff] [blame] | 174 | struct H { |
175 | H(); | ||||
176 | ~H(); | ||||
177 | H(const H&); | ||||
178 | }; | ||||
179 | |||||
180 | void f9(H h) { | ||||
181 | // CHECK: call void @_ZN1HC1Ev | ||||
182 | // CHECK: call void @_Z2f91H | ||||
183 | // CHECK: call void @_ZN1HD1Ev | ||||
184 | f9(H()); | ||||
185 | |||||
186 | // CHECK: call void @_ZN1HC1ERKS_ | ||||
187 | // CHECK: call void @_Z2f91H | ||||
188 | // CHECK: call void @_ZN1HD1Ev | ||||
189 | f9(h); | ||||
Anders Carlsson | 1faf674 | 2009-11-06 04:11:09 +0000 | [diff] [blame] | 190 | } |
Anders Carlsson | 4b3cbea | 2009-11-13 17:04:35 +0000 | [diff] [blame^] | 191 | |
192 | void f10(const H&); | ||||
193 | |||||
194 | void f11(H h) { | ||||
195 | // CHECK: call void @_ZN1HC1Ev | ||||
196 | // CHECK: call void @_Z3f10RK1H | ||||
197 | // CHECK: call void @_ZN1HD1Ev | ||||
198 | f10(H()); | ||||
199 | |||||
200 | // CHECK: call void @_Z3f10RK1H | ||||
201 | // CHECK-NOT: call void @_ZN1HD1Ev | ||||
202 | // CHECK: ret void | ||||
203 | f10(h); | ||||
204 | } |