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