1 | // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -fcxx-exceptions -std=gnu++17 -ast-dump %s | FileCheck -strict-whitespace %s |
2 | |
3 | namespace std { |
4 | using size_t = decltype(sizeof(0)); |
5 | |
6 | class type_info { |
7 | public: |
8 | virtual ~type_info(); |
9 | bool operator==(const type_info& rhs) const noexcept; |
10 | bool operator!=(const type_info& rhs) const noexcept; |
11 | type_info(const type_info& rhs) = delete; // cannot be copied |
12 | type_info& operator=(const type_info& rhs) = delete; // cannot be copied |
13 | }; |
14 | |
15 | class bad_typeid { |
16 | public: |
17 | bad_typeid() noexcept; |
18 | bad_typeid(const bad_typeid&) noexcept; |
19 | virtual ~bad_typeid(); |
20 | bad_typeid& operator=(const bad_typeid&) noexcept; |
21 | const char* what() const noexcept; |
22 | }; |
23 | } // namespace std |
24 | void *operator new(std::size_t, void *ptr); |
25 | |
26 | struct S { |
27 | virtual ~S() = default; |
28 | |
29 | void func(int); |
30 | template <typename Ty> |
31 | Ty foo(); |
32 | |
33 | int i; |
34 | }; |
35 | |
36 | struct T : S {}; |
37 | |
38 | template <typename> |
39 | struct U {}; |
40 | |
41 | void Throw() { |
42 | throw 12; |
43 | // CHECK: CXXThrowExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:9> 'void' |
44 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:9> 'int' 12 |
45 | |
46 | throw; |
47 | // CHECK: CXXThrowExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3> 'void' |
48 | } |
49 | |
50 | void PointerToMember(S obj1, S *obj2, int S::* data, void (S::*call)(int)) { |
51 | obj1.*data; |
52 | // CHECK: BinaryOperator 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:9> 'int' lvalue '.*' |
53 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S' lvalue ParmVar 0x{{[^ ]*}} 'obj1' 'S' |
54 | // CHECK-NEXT: ImplicitCastExpr |
55 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:9> 'int S::*' lvalue ParmVar 0x{{[^ ]*}} 'data' 'int S::*' |
56 | |
57 | obj2->*data; |
58 | // CHECK: BinaryOperator 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:10> 'int' lvalue '->*' |
59 | // CHECK-NEXT: ImplicitCastExpr |
60 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S *' lvalue ParmVar 0x{{[^ ]*}} 'obj2' 'S *' |
61 | // CHECK-NEXT: ImplicitCastExpr |
62 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> 'int S::*' lvalue ParmVar 0x{{[^ ]*}} 'data' 'int S::*' |
63 | |
64 | (obj1.*call)(12); |
65 | // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:18> 'void' |
66 | // CHECK-NEXT: ParenExpr 0x{{[^ ]*}} <col:3, col:14> '<bound member function type>' |
67 | // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:4, col:10> '<bound member function type>' '.*' |
68 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'S' lvalue ParmVar 0x{{[^ ]*}} 'obj1' 'S' |
69 | // CHECK-NEXT: ImplicitCastExpr |
70 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> 'void (S::*)(int)' lvalue ParmVar 0x{{[^ ]*}} 'call' 'void (S::*)(int)' |
71 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:16> 'int' 12 |
72 | |
73 | (obj2->*call)(12); |
74 | // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:19> 'void' |
75 | // CHECK-NEXT: ParenExpr 0x{{[^ ]*}} <col:3, col:15> '<bound member function type>' |
76 | // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:4, col:11> '<bound member function type>' '->*' |
77 | // CHECK-NEXT: ImplicitCastExpr |
78 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'S *' lvalue ParmVar 0x{{[^ ]*}} 'obj2' 'S *' |
79 | // CHECK-NEXT: ImplicitCastExpr |
80 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> 'void (S::*)(int)' lvalue ParmVar 0x{{[^ ]*}} 'call' 'void (S::*)(int)' |
81 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:17> 'int' 12 |
82 | } |
83 | |
84 | void Casting(const S *s) { |
85 | // FIXME: The cast expressions contain "struct S" instead of "S". |
86 | |
87 | const_cast<S *>(s); |
88 | // CHECK: CXXConstCastExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:20> 'S *' const_cast<struct S *> <NoOp> |
89 | // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} <col:19> 'const S *' <LValueToRValue> part_of_explicit_cast |
90 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:19> 'const S *' lvalue ParmVar 0x{{[^ ]*}} 's' 'const S *' |
91 | |
92 | static_cast<const T *>(s); |
93 | // CHECK: CXXStaticCastExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:27> 'const T *' static_cast<const struct T *> <BaseToDerived (S)> |
94 | // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} <col:26> 'const S *' <LValueToRValue> part_of_explicit_cast |
95 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:26> 'const S *' lvalue ParmVar 0x{{[^ ]*}} 's' 'const S *' |
96 | |
97 | dynamic_cast<const T *>(s); |
98 | // CHECK: CXXDynamicCastExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:28> 'const T *' dynamic_cast<const struct T *> <Dynamic> |
99 | // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} <col:27> 'const S *' <LValueToRValue> part_of_explicit_cast |
100 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:27> 'const S *' lvalue ParmVar 0x{{[^ ]*}} 's' 'const S *' |
101 | |
102 | reinterpret_cast<const int *>(s); |
103 | // CHECK: CXXReinterpretCastExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:34> 'const int *' reinterpret_cast<const int *> <BitCast> |
104 | // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} <col:33> 'const S *' <LValueToRValue> part_of_explicit_cast |
105 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:33> 'const S *' lvalue ParmVar 0x{{[^ ]*}} 's' 'const S *' |
106 | } |
107 | |
108 | template <typename... Ts> |
109 | void UnaryExpressions(int *p) { |
110 | sizeof...(Ts); |
111 | // CHECK: SizeOfPackExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:15> 'unsigned long' 0x{{[^ ]*}} Ts |
112 | |
113 | noexcept(p - p); |
114 | // CHECK: CXXNoexceptExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:17> 'bool' |
115 | // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:12, col:16> 'long' '-' |
116 | // CHECK-NEXT: ImplicitCastExpr |
117 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *' |
118 | // CHECK-NEXT: ImplicitCastExpr |
119 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *' |
120 | |
121 | ::new int; |
122 | // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:9> 'int *' global Function 0x{{[^ ]*}} 'operator new' 'void *(unsigned long)' |
123 | |
124 | new (int); |
125 | // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> 'int *' Function 0x{{[^ ]*}} 'operator new' 'void *(unsigned long)' |
126 | |
127 | new int{12}; |
128 | // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:13> 'int *' Function 0x{{[^ ]*}} 'operator new' 'void *(unsigned long)' |
129 | // CHECK-NEXT: InitListExpr 0x{{[^ ]*}} <col:10, col:13> 'int' |
130 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:11> 'int' 12 |
131 | |
132 | new int[2]; |
133 | // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:12> 'int *' array Function 0x{{[^ ]*}} 'operator new[]' 'void *(unsigned long)' |
134 | // CHECK-NEXT: ImplicitCastExpr |
135 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:11> 'int' 2 |
136 | |
137 | new int[2]{1, 2}; |
138 | // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:18> 'int *' array Function 0x{{[^ ]*}} 'operator new[]' 'void *(unsigned long)' |
139 | // CHECK-NEXT: ImplicitCastExpr |
140 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:11> 'int' 2 |
141 | // CHECK-NEXT: InitListExpr 0x{{[^ ]*}} <col:13, col:18> 'int [2]' |
142 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:14> 'int' 1 |
143 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:17> 'int' 2 |
144 | |
145 | new (p) int; |
146 | // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> 'int *' Function 0x{{[^ ]*}} 'operator new' 'void *(std::size_t, void *)' |
147 | // CHECK-NEXT: ImplicitCastExpr {{.*}} 'void *' <BitCast> |
148 | // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int *' <LValueToRValue> |
149 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:8> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *' |
150 | |
151 | new (p) int{12}; |
152 | // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:17> 'int *' Function 0x{{[^ ]*}} 'operator new' 'void *(std::size_t, void *)' |
153 | // CHECK-NEXT: InitListExpr 0x{{[^ ]*}} <col:14, col:17> 'int' |
154 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:15> 'int' 12 |
155 | // CHECK-NEXT: ImplicitCastExpr {{.*}} 'void *' <BitCast> |
156 | // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int *' <LValueToRValue> |
157 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:8> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *' |
158 | |
159 | ::delete p; |
160 | // CHECK: CXXDeleteExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:12> 'void' global Function 0x{{[^ ]*}} 'operator delete' 'void (void *) noexcept' |
161 | // CHECK-NEXT: ImplicitCastExpr |
162 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *' |
163 | |
164 | delete [] p; |
165 | // CHECK: CXXDeleteExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:13> 'void' array Function 0x{{[^ ]*}} 'operator delete[]' 'void (void *) noexcept' |
166 | // CHECK-NEXT: ImplicitCastExpr |
167 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:13> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *' |
168 | } |
169 | |
170 | void PostfixExpressions(S a, S *p, U<int> *r) { |
171 | a.func(0); |
172 | // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> 'void' |
173 | // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:5> '<bound member function type>' .func 0x{{[^ ]*}} |
174 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S' |
175 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:10> 'int' 0 |
176 | |
177 | p->func(0); |
178 | // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:12> 'void' |
179 | // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:6> '<bound member function type>' ->func 0x{{[^ ]*}} |
180 | // CHECK-NEXT: ImplicitCastExpr |
181 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'S *' |
182 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:11> 'int' 0 |
183 | |
184 | // FIXME: there is no mention that this used the template keyword. |
185 | p->template foo<int>(); |
186 | // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:24> 'int':'int' |
187 | // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:22> '<bound member function type>' ->foo 0x{{[^ ]*}} |
188 | // CHECK-NEXT: ImplicitCastExpr |
189 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'S *' |
190 | |
191 | // FIXME: there is no mention that this used the template keyword. |
192 | a.template foo<float>(); |
193 | // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:25> 'float':'float' |
194 | // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:23> '<bound member function type>' .foo 0x{{[^ ]*}} |
195 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S' |
196 | |
197 | p->~S(); |
198 | // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:9> 'void' |
199 | // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:7> '<bound member function type>' ->~S 0x{{[^ ]*}} |
200 | // CHECK-NEXT: ImplicitCastExpr |
201 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'S *' |
202 | |
203 | a.~S(); |
204 | // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:8> 'void' |
205 | // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:6> '<bound member function type>' .~S 0x{{[^ ]*}} |
206 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S' |
207 | |
208 | // FIXME: there seems to be no way to distinguish the construct below from |
209 | // the construct above. |
210 | a.~decltype(a)(); |
211 | // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:18> 'void' |
212 | // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:5> '<bound member function type>' .~S 0x{{[^ ]*}} |
213 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S' |
214 | |
215 | // FIXME: similarly, there is no way to distinguish the construct below from |
216 | // the p->~S() case. |
217 | p->::S::~S(); |
218 | // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:14> 'void' |
219 | // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:12> '<bound member function type>' ->~S 0x{{[^ ]*}} |
220 | // CHECK-NEXT: ImplicitCastExpr |
221 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'S *' |
222 | |
223 | // FIXME: there is no mention that this used the template keyword. |
224 | r->template U<int>::~U(); |
225 | // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:26> 'void' |
226 | // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:24> '<bound member function type>' ->~U 0x{{[^ ]*}} |
227 | // CHECK-NEXT: ImplicitCastExpr |
228 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'U<int> *' lvalue ParmVar 0x{{[^ ]*}} 'r' 'U<int> *' |
229 | |
230 | typeid(a); |
231 | // CHECK: CXXTypeidExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> 'const std::type_info' lvalue |
232 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S' |
233 | |
234 | // FIXME: no type information is printed for the argument. |
235 | typeid(S); |
236 | // CHECK: CXXTypeidExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> 'const std::type_info' lvalue |
237 | } |
238 | |
239 | template <typename... Ts> |
240 | void PrimaryExpressions(Ts... a) { |
241 | struct V { |
242 | void f() { |
243 | this; |
244 | // CHECK: CXXThisExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:7> 'V *' this |
245 | [this]{}; |
246 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:7, col:14> |
247 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:7> col:7 implicit class definition |
248 | // CHECK-NEXT: DefinitionData lambda |
249 | // CHECK-NEXT: DefaultConstructor |
250 | // CHECK-NEXT: CopyConstructor |
251 | // CHECK-NEXT: MoveConstructor |
252 | // CHECK-NEXT: CopyAssignment |
253 | // CHECK-NEXT: MoveAssignment |
254 | // CHECK-NEXT: Destructor |
255 | // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:8> col:8 implicit 'V *' |
256 | // CHECK-NEXT: CXXMethodDecl |
257 | // CHECK-NEXT: CompoundStmt |
258 | // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}} <col:8> 'V *' implicit this |
259 | |
260 | [*this]{}; |
261 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:7, col:15> |
262 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:7> col:7 implicit class definition |
263 | // CHECK-NEXT: DefinitionData lambda |
264 | // CHECK-NEXT: DefaultConstructor |
265 | // CHECK-NEXT: CopyConstructor |
266 | // CHECK-NEXT: MoveConstructor |
267 | // CHECK-NEXT: CopyAssignment |
268 | // CHECK-NEXT: MoveAssignment |
269 | // CHECK-NEXT: Destructor |
270 | // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:8> col:8 implicit 'V' |
271 | // CHECK-NEXT: CXXMethodDecl |
272 | // CHECK-NEXT: CompoundStmt |
273 | // CHECK-NEXT: ParenListExpr 0x{{[^ ]*}} <col:8> 'NULL TYPE' |
274 | // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:8> '<dependent type>' prefix '*' cannot overflow |
275 | // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}} <col:8> 'V *' implicit this |
276 | } |
277 | }; |
278 | |
279 | int b, c; |
280 | |
281 | [](){}; |
282 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:8> '(lambda at {{.*}}:[[@LINE-1]]:3)' |
283 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition |
284 | // CHECK-NEXT: DefinitionData lambda |
285 | // CHECK-NEXT: DefaultConstructor |
286 | // CHECK-NEXT: CopyConstructor |
287 | // CHECK-NEXT: MoveConstructor |
288 | // CHECK-NEXT: CopyAssignment |
289 | // CHECK-NEXT: MoveAssignment |
290 | // CHECK-NEXT: Destructor |
291 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:6, col:8> col:3 operator() 'auto () const' inline |
292 | // CHECK-NEXT: CompoundStmt |
293 | // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}} <col:3, col:8> col:3 implicit constexpr operator auto (*)() 'auto (*() const noexcept)()' inline |
294 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:3, col:8> col:3 implicit __invoke 'auto ()' static inline |
295 | // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:7, col:8> |
296 | |
297 | [](int a, ...){}; |
298 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:18> '(lambda at {{.*}}:[[@LINE-1]]:3)' |
299 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition |
300 | // CHECK-NEXT: DefinitionData lambda |
301 | // CHECK-NEXT: DefaultConstructor |
302 | // CHECK-NEXT: CopyConstructor |
303 | // CHECK-NEXT: MoveConstructor |
304 | // CHECK-NEXT: CopyAssignment |
305 | // CHECK-NEXT: MoveAssignment |
306 | // CHECK-NEXT: Destructor |
307 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:16, col:18> col:3 operator() 'auto (int, ...) const' inline |
308 | // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:6, col:10> col:10 a 'int' |
309 | // CHECK-NEXT: CompoundStmt |
310 | // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}} <col:3, col:18> col:3 implicit constexpr operator auto (*)(int, ...) 'auto (*() const noexcept)(int, ...)' inline |
311 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:3, col:18> col:3 implicit __invoke 'auto (int, ...)' static inline |
312 | // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:6, col:10> col:10 a 'int' |
313 | // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:17, col:18> |
314 | |
315 | [a...]{}; |
316 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:10> '(lambda at {{.*}}:[[@LINE-1]]:3)' |
317 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition |
318 | // CHECK-NEXT: DefinitionData lambda |
319 | // CHECK-NEXT: DefaultConstructor |
320 | // CHECK-NEXT: CopyConstructor |
321 | // CHECK-NEXT: MoveConstructor |
322 | // CHECK-NEXT: CopyAssignment |
323 | // CHECK-NEXT: MoveAssignment |
324 | // CHECK-NEXT: Destructor |
325 | // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:4> col:4 implicit 'Ts...' |
326 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:8, col:10> col:3 operator() 'auto () const -> auto' inline |
327 | // CHECK-NEXT: CompoundStmt |
328 | // CHECK-NEXT: ParenListExpr 0x{{[^ ]*}} <col:4> 'NULL TYPE' |
329 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'Ts...' lvalue ParmVar 0x{{[^ ]*}} 'a' 'Ts...' |
330 | // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:9, col:10> |
331 | |
332 | [=]{}; |
333 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:7> '(lambda at {{.*}}:[[@LINE-1]]:3)' |
334 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition |
335 | // CHECK-NEXT: DefinitionData lambda |
336 | // CHECK-NEXT: DefaultConstructor |
337 | // CHECK-NEXT: CopyConstructor |
338 | // CHECK-NEXT: MoveConstructor |
339 | // CHECK-NEXT: CopyAssignment |
340 | // CHECK-NEXT: MoveAssignment |
341 | // CHECK-NEXT: Destructor |
342 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:5, col:7> col:3 operator() 'auto () const -> auto' inline |
343 | // CHECK-NEXT: CompoundStmt |
344 | // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:6, col:7> |
345 | |
346 | [=] { return b; }; |
347 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:19> '(lambda at {{.*}}:[[@LINE-1]]:3)' |
348 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition |
349 | // CHECK-NEXT: DefinitionData lambda |
350 | // CHECK-NEXT: DefaultConstructor |
351 | // CHECK-NEXT: CopyConstructor |
352 | // CHECK-NEXT: MoveConstructor |
353 | // CHECK-NEXT: CopyAssignment |
354 | // CHECK-NEXT: MoveAssignment |
355 | // CHECK-NEXT: Destructor |
356 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:5, col:19> col:3 operator() 'auto () const -> auto' inline |
357 | // CHECK-NEXT: CompoundStmt |
358 | // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:9, col:16> |
359 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> 'const int' lvalue Var 0x{{[^ ]*}} 'b' 'int' |
360 | // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:7, col:19> |
361 | // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:9, col:16> |
362 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> 'const int' lvalue Var 0x{{[^ ]*}} 'b' 'int' |
363 | |
364 | [&]{}; |
365 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:7> '(lambda at {{.*}}:[[@LINE-1]]:3)' |
366 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition |
367 | // CHECK-NEXT: DefinitionData lambda |
368 | // CHECK-NEXT: DefaultConstructor |
369 | // CHECK-NEXT: CopyConstructor |
370 | // CHECK-NEXT: MoveConstructor |
371 | // CHECK-NEXT: CopyAssignment |
372 | // CHECK-NEXT: MoveAssignment |
373 | // CHECK-NEXT: Destructor |
374 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:5, col:7> col:3 operator() 'auto () const -> auto' inline |
375 | // CHECK-NEXT: CompoundStmt |
376 | // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:6, col:7> |
377 | |
378 | [&] { return c; }; |
379 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:19> '(lambda at {{.*}}:[[@LINE-1]]:3)' |
380 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition |
381 | // CHECK-NEXT: DefinitionData lambda |
382 | // CHECK-NEXT: DefaultConstructor |
383 | // CHECK-NEXT: CopyConstructor |
384 | // CHECK-NEXT: MoveConstructor |
385 | // CHECK-NEXT: CopyAssignment |
386 | // CHECK-NEXT: MoveAssignment |
387 | // CHECK-NEXT: Destructor |
388 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:5, col:19> col:3 operator() 'auto () const -> auto' inline |
389 | // CHECK-NEXT: CompoundStmt |
390 | // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:9, col:16> |
391 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> 'int' lvalue Var 0x{{[^ ]*}} 'c' 'int' |
392 | // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:7, col:19> |
393 | // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:9, col:16> |
394 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> 'int' lvalue Var 0x{{[^ ]*}} 'c' 'int' |
395 | |
396 | [b, &c]{ return b + c; }; |
397 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:26> '(lambda at {{.*}}:[[@LINE-1]]:3)' |
398 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition |
399 | // CHECK-NEXT: DefinitionData lambda |
400 | // CHECK-NEXT: DefaultConstructor |
401 | // CHECK-NEXT: CopyConstructor |
402 | // CHECK-NEXT: MoveConstructor |
403 | // CHECK-NEXT: CopyAssignment |
404 | // CHECK-NEXT: MoveAssignment |
405 | // CHECK-NEXT: Destructor |
406 | // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:4> col:4 implicit 'int' |
407 | // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:8> col:8 implicit 'int &' |
408 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:9, col:26> col:3 operator() 'auto () const -> auto' inline |
409 | // CHECK-NEXT: CompoundStmt |
410 | // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:12, col:23> |
411 | // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:19, col:23> 'int' '+' |
412 | // CHECK-NEXT: ImplicitCastExpr |
413 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:19> 'const int' lvalue Var 0x{{[^ ]*}} 'b' 'int' |
414 | // CHECK-NEXT: ImplicitCastExpr |
415 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:23> 'int' lvalue Var 0x{{[^ ]*}} 'c' 'int' |
416 | // CHECK-NEXT: ImplicitCastExpr |
417 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'int' lvalue Var 0x{{[^ ]*}} 'b' 'int' |
418 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:8> 'int' lvalue Var 0x{{[^ ]*}} 'c' 'int' |
419 | // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:10, col:26> |
420 | // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:12, col:23> |
421 | // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:19, col:23> 'int' '+' |
422 | // CHECK-NEXT: ImplicitCastExpr |
423 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:19> 'const int' lvalue Var 0x{{[^ ]*}} 'b' 'int' |
424 | // CHECK-NEXT: ImplicitCastExpr |
425 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:23> 'int' lvalue Var 0x{{[^ ]*}} 'c' 'int' |
426 | |
427 | [a..., x = 12]{}; |
428 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:18> '(lambda at {{.*}}:[[@LINE-1]]:3)' |
429 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition |
430 | // CHECK-NEXT: DefinitionData lambda |
431 | // CHECK-NEXT: DefaultConstructor |
432 | // CHECK-NEXT: CopyConstructor |
433 | // CHECK-NEXT: MoveConstructor |
434 | // CHECK-NEXT: CopyAssignment |
435 | // CHECK-NEXT: MoveAssignment |
436 | // CHECK-NEXT: Destructor |
437 | // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:4> col:4 implicit 'Ts...' |
438 | // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:10> col:10 implicit 'int':'int' |
439 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:16, col:18> col:3 operator() 'auto () const -> auto' inline |
440 | // CHECK-NEXT: CompoundStmt |
441 | // CHECK-NEXT: ParenListExpr 0x{{[^ ]*}} <col:4> 'NULL TYPE' |
442 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'Ts...' lvalue ParmVar 0x{{[^ ]*}} 'a' 'Ts...' |
443 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:14> 'int' 12 |
444 | // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:17, col:18> |
445 | |
446 | []() constexpr {}; |
447 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:19> '(lambda at {{.*}}:[[@LINE-1]]:3)' |
448 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition |
449 | // CHECK-NEXT: DefinitionData lambda |
450 | // CHECK-NEXT: DefaultConstructor |
451 | // CHECK-NEXT: CopyConstructor |
452 | // CHECK-NEXT: MoveConstructor |
453 | // CHECK-NEXT: CopyAssignment |
454 | // CHECK-NEXT: MoveAssignment |
455 | // CHECK-NEXT: Destructor |
456 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:8, col:19> col:3 constexpr operator() 'auto () const' inline |
457 | // CHECK-NEXT: CompoundStmt |
458 | // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}} <col:3, col:19> col:3 implicit constexpr operator auto (*)() 'auto (*() const noexcept)()' inline |
459 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:3, col:19> col:3 implicit __invoke 'auto ()' static inline |
460 | // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:18, col:19> |
461 | |
462 | []() mutable {}; |
463 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:17> '(lambda at {{.*}}:[[@LINE-1]]:3)' |
464 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition |
465 | // CHECK-NEXT: DefinitionData lambda |
466 | // CHECK-NEXT: DefaultConstructor |
467 | // CHECK-NEXT: CopyConstructor |
468 | // CHECK-NEXT: MoveConstructor |
469 | // CHECK-NEXT: CopyAssignment |
470 | // CHECK-NEXT: MoveAssignment |
471 | // CHECK-NEXT: Destructor |
472 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:8, col:17> col:3 operator() 'auto ()' inline |
473 | // CHECK-NEXT: CompoundStmt |
474 | // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}} <col:3, col:17> col:3 implicit constexpr operator auto (*)() 'auto (*() const noexcept)()' inline |
475 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:3, col:17> col:3 implicit __invoke 'auto ()' static inline |
476 | // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:16, col:17> |
477 | |
478 | []() noexcept {}; |
479 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:18> '(lambda at {{.*}}:[[@LINE-1]]:3)' |
480 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition |
481 | // CHECK-NEXT: DefinitionData lambda |
482 | // CHECK-NEXT: DefaultConstructor |
483 | // CHECK-NEXT: CopyConstructor |
484 | // CHECK-NEXT: MoveConstructor |
485 | // CHECK-NEXT: CopyAssignment |
486 | // CHECK-NEXT: MoveAssignment |
487 | // CHECK-NEXT: Destructor |
488 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:8, col:18> col:3 operator() 'auto () const noexcept' inline |
489 | // CHECK-NEXT: CompoundStmt |
490 | // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}} <col:3, col:18> col:3 implicit constexpr operator auto (*)() noexcept 'auto (*() const noexcept)() noexcept' inline |
491 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:3, col:18> col:3 implicit __invoke 'auto () noexcept' static inline |
492 | // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:17, col:18> |
493 | |
494 | []() -> int { return 0; }; |
495 | // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:27> '(lambda at {{.*}}:[[@LINE-1]]:3)' |
496 | // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition |
497 | // CHECK-NEXT: DefinitionData lambda |
498 | // CHECK-NEXT: DefaultConstructor |
499 | // CHECK-NEXT: CopyConstructor |
500 | // CHECK-NEXT: MoveConstructor |
501 | // CHECK-NEXT: CopyAssignment |
502 | // CHECK-NEXT: MoveAssignment |
503 | // CHECK-NEXT: Destructor |
504 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:11, col:27> col:3 operator() 'auto () const -> int' inline |
505 | // CHECK-NEXT: CompoundStmt |
506 | // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:17, col:24> |
507 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:24> 'int' 0 |
508 | // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}} <col:3, col:27> col:3 implicit constexpr operator int (*)() 'auto (*() const noexcept)() -> int' inline |
509 | // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:3, col:27> col:3 implicit __invoke 'auto () -> int' static inline |
510 | // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:15, col:27> |
511 | // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:17, col:24> |
512 | // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:24> 'int' 0 |
513 | |
514 | (a + ...); |
515 | // CHECK: CXXFoldExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> '<dependent type>' |
516 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'Ts...' lvalue ParmVar 0x{{[^ ]*}} 'a' 'Ts...' |
517 | // CHECK-NEXT: <<<NULL>>> |
518 | |
519 | (... + a); |
520 | // CHECK: CXXFoldExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> '<dependent type>' |
521 | // CHECK-NEXT: <<<NULL>>> |
522 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> 'Ts...' lvalue ParmVar 0x{{[^ ]*}} 'a' 'Ts...' |
523 | |
524 | (a + ... + b); |
525 | // CHECK: CXXFoldExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:15> '<dependent type>' |
526 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'Ts...' lvalue ParmVar 0x{{[^ ]*}} 'a' 'Ts...' |
527 | // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:14> 'int' lvalue Var 0x{{[^ ]*}} 'b' 'int' |
528 | } |
529 | |
530 | |
531 | namespace NS { |
532 | struct X {}; |
533 | void f(X); |
534 | void y(...); |
535 | } // namespace NS |
536 | |
537 | // CHECK-LABEL: FunctionDecl 0x{{[^ ]*}} {{.*}}ADLCall 'void ()' |
538 | void ADLCall() { |
539 | NS::X x; |
540 | // CHECK: CallExpr 0x{{[^ ]*}} <line:[[@LINE+1]]:{{[^>]+}}> 'void' adl{{$}} |
541 | f(x); |
542 | // CHECK: CallExpr 0x{{[^ ]*}} <line:[[@LINE+1]]:{{[^>]+}}> 'void' adl{{$}} |
543 | y(x); |
544 | } |
545 | |
546 | // CHECK-LABEL: FunctionDecl 0x{{[^ ]*}} {{.*}}NonADLCall 'void ()' |
547 | void NonADLCall() { |
548 | NS::X x; |
549 | // CHECK: CallExpr 0x{{[^ ]*}} <line:[[@LINE+1]]:{{[^>]+}}> 'void'{{$}} |
550 | NS::f(x); |
551 | } |
552 | |
553 | // CHECK-LABEL: FunctionDecl 0x{{[^ ]*}} {{.*}}NonADLCall2 'void ()' |
554 | void NonADLCall2() { |
555 | NS::X x; |
556 | using NS::f; |
557 | // CHECK: CallExpr 0x{{[^ ]*}} <line:[[@LINE+1]]:{{[^>]+}}> 'void'{{$}} |
558 | f(x); |
559 | // CHECK: CallExpr 0x{{[^ ]*}} <line:[[@LINE+1]]:{{[^>]+}}> 'void' adl{{$}} |
560 | y(x); |
561 | } |
562 | |
563 | namespace test_adl_call_three { |
564 | using namespace NS; |
565 | // CHECK-LABEL: FunctionDecl 0x{{[^ ]*}} {{.*}}NonADLCall3 'void ()' |
566 | void NonADLCall3() { |
567 | X x; |
568 | // CHECK: CallExpr 0x{{[^ ]*}} <line:[[@LINE+1]]:{{[^>]+}}> 'void'{{$}} |
569 | f(x); |
570 | } |
571 | } // namespace test_adl_call_three |
572 | |