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