ast-dump-expr.cpp 27.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584
// Test without serialization:
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -fcxx-exceptions -std=gnu++17 -ast-dump %s \
// RUN: | FileCheck --strict-whitespace %s
//
// Test with serialization:
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -fcxx-exceptions -std=gnu++17 -emit-pch -o %t %s
// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value -fcxx-exceptions -std=gnu++17 \
// RUN: -include-pch %t -ast-dump-all /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck --strict-whitespace %s

namespace std {
using size_t = decltype(sizeof(0));

class type_info {
public:
  virtual ~type_info();
  bool operator==(const type_info& rhs) const noexcept;
  bool operator!=(const type_info& rhs) const noexcept;
  type_info(const type_info& rhs) = delete; // cannot be copied
  type_info& operator=(const type_info& rhs) = delete; // cannot be copied
};

class bad_typeid {
public:
  bad_typeid() noexcept;
  bad_typeid(const bad_typeid&) noexcept;
  virtual ~bad_typeid();
  bad_typeid& operator=(const bad_typeid&) noexcept;
  const char* what() const noexcept;
};
} // namespace std
void *operator new(std::size_t, void *ptr);

struct S {
  virtual ~S() = default;

  void func(int);
  template <typename Ty>
  Ty foo();

  int i;
};

struct T : S {};

template <typename>
struct U {};

void Throw() {
  throw 12;
  // CHECK: CXXThrowExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:9> 'void'
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:9> 'int' 12

  throw;
  // CHECK: CXXThrowExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3> 'void'
}

void PointerToMember(S obj1, S *obj2, int S::* data, void (S::*call)(int)) {
  obj1.*data;
  // CHECK: BinaryOperator 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:9> 'int' lvalue '.*'
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S' lvalue ParmVar 0x{{[^ ]*}} 'obj1' 'S'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:9> 'int S::*' lvalue ParmVar 0x{{[^ ]*}} 'data' 'int S::*'

  obj2->*data;
  // CHECK: BinaryOperator 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:10> 'int' lvalue '->*'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S *' lvalue ParmVar 0x{{[^ ]*}} 'obj2' 'S *'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> 'int S::*' lvalue ParmVar 0x{{[^ ]*}} 'data' 'int S::*'

  (obj1.*call)(12);
  // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:18> 'void'
  // CHECK-NEXT: ParenExpr 0x{{[^ ]*}} <col:3, col:14> '<bound member function type>'
  // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:4, col:10> '<bound member function type>' '.*'
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'S' lvalue ParmVar 0x{{[^ ]*}} 'obj1' 'S'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> 'void (S::*)(int)' lvalue ParmVar 0x{{[^ ]*}} 'call' 'void (S::*)(int)'
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:16> 'int' 12

  (obj2->*call)(12);
  // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:19> 'void'
  // CHECK-NEXT: ParenExpr 0x{{[^ ]*}} <col:3, col:15> '<bound member function type>'
  // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:4, col:11> '<bound member function type>' '->*'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'S *' lvalue ParmVar 0x{{[^ ]*}} 'obj2' 'S *'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> 'void (S::*)(int)' lvalue ParmVar 0x{{[^ ]*}} 'call' 'void (S::*)(int)'
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:17> 'int' 12
}

void Casting(const S *s) {
  // FIXME: The cast expressions contain "struct S" instead of "S".

  const_cast<S *>(s);
  // CHECK: CXXConstCastExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:20> 'S *' const_cast<struct S *> <NoOp>
  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} <col:19> 'const S *' <LValueToRValue> part_of_explicit_cast
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:19> 'const S *' lvalue ParmVar 0x{{[^ ]*}} 's' 'const S *'

  static_cast<const T *>(s);
  // CHECK: CXXStaticCastExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:27> 'const T *' static_cast<const struct T *> <BaseToDerived (S)>
  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} <col:26> 'const S *' <LValueToRValue> part_of_explicit_cast
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:26> 'const S *' lvalue ParmVar 0x{{[^ ]*}} 's' 'const S *'

  dynamic_cast<const T *>(s);
  // CHECK: CXXDynamicCastExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:28> 'const T *' dynamic_cast<const struct T *> <Dynamic>
  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} <col:27> 'const S *' <LValueToRValue> part_of_explicit_cast
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:27> 'const S *' lvalue ParmVar 0x{{[^ ]*}} 's' 'const S *'

  reinterpret_cast<const int *>(s);
  // CHECK: CXXReinterpretCastExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:34> 'const int *' reinterpret_cast<const int *> <BitCast>
  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} <col:33> 'const S *' <LValueToRValue> part_of_explicit_cast
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:33> 'const S *' lvalue ParmVar 0x{{[^ ]*}} 's' 'const S *'
}

template <typename... Ts>
void UnaryExpressions(int *p) {
  sizeof...(Ts);
  // CHECK: SizeOfPackExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:15> 'unsigned long' 0x{{[^ ]*}} Ts

  noexcept(p - p);
  // CHECK: CXXNoexceptExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:17> 'bool'
  // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:12, col:16> 'long' '-'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *'

  ::new int;
  // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:9> 'int *' global Function 0x{{[^ ]*}} 'operator new' 'void *(unsigned long)'

  new (int);
  // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> 'int *' Function 0x{{[^ ]*}} 'operator new' 'void *(unsigned long)'

  new int{12};
  // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:13> 'int *' Function 0x{{[^ ]*}} 'operator new' 'void *(unsigned long)'
  // CHECK-NEXT: InitListExpr 0x{{[^ ]*}} <col:10, col:13> 'int'
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:11> 'int' 12

  new int[2];
  // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:12> 'int *' array Function 0x{{[^ ]*}} 'operator new[]' 'void *(unsigned long)'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:11> 'int' 2

  new int[2]{1, 2};
  // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:18> 'int *' array Function 0x{{[^ ]*}} 'operator new[]' 'void *(unsigned long)'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:11> 'int' 2
  // CHECK-NEXT: InitListExpr 0x{{[^ ]*}} <col:13, col:18> 'int [2]'
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:14> 'int' 1
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:17> 'int' 2

  new (p) int;
  // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> 'int *' Function 0x{{[^ ]*}} 'operator new' 'void *(std::size_t, void *)'
  // CHECK-NEXT: ImplicitCastExpr {{.*}} 'void *' <BitCast>
  // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int *' <LValueToRValue>
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:8> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *'

  new (p) int{12};
  // CHECK: CXXNewExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:17> 'int *' Function 0x{{[^ ]*}} 'operator new' 'void *(std::size_t, void *)'
  // CHECK-NEXT: InitListExpr 0x{{[^ ]*}} <col:14, col:17> 'int'
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:15> 'int' 12
  // CHECK-NEXT: ImplicitCastExpr {{.*}} 'void *' <BitCast>
  // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int *' <LValueToRValue>
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:8> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *'

  ::delete p;
  // CHECK: CXXDeleteExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:12> 'void' global Function 0x{{[^ ]*}} 'operator delete' 'void (void *) noexcept'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *'

  delete [] p;
  // CHECK: CXXDeleteExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:13> 'void' array Function 0x{{[^ ]*}} 'operator delete[]' 'void (void *) noexcept'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:13> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *'
}

void PostfixExpressions(S a, S *p, U<int> *r) {
  a.func(0);
  // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> 'void'
  // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:5> '<bound member function type>' .func 0x{{[^ ]*}}
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S'
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:10> 'int' 0

  p->func(0);
  // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:12> 'void'
  // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:6> '<bound member function type>' ->func 0x{{[^ ]*}}
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'S *'
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:11> 'int' 0

  // FIXME: there is no mention that this used the template keyword.
  p->template foo<int>();
  // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:24> 'int':'int'
  // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:22> '<bound member function type>' ->foo 0x{{[^ ]*}}
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'S *'

  // FIXME: there is no mention that this used the template keyword.
  a.template foo<float>();
  // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:25> 'float':'float'
  // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:23> '<bound member function type>' .foo 0x{{[^ ]*}}
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S'

  p->~S();
  // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:9> 'void'
  // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:7> '<bound member function type>' ->~S 0x{{[^ ]*}}
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'S *'

  a.~S();
  // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:8> 'void'
  // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:6> '<bound member function type>' .~S 0x{{[^ ]*}}
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S'

  // FIXME: there seems to be no way to distinguish the construct below from
  // the construct above.
  a.~decltype(a)();
  // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:18> 'void'
  // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:5> '<bound member function type>' .~S 0x{{[^ ]*}}
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S'

  // FIXME: similarly, there is no way to distinguish the construct below from
  // the p->~S() case.
  p->::S::~S();
  // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:14> 'void'
  // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:12> '<bound member function type>' ->~S 0x{{[^ ]*}}
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'S *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'S *'

  // FIXME: there is no mention that this used the template keyword.
  r->template U<int>::~U();
  // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:26> 'void'
  // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} <col:3, col:24> '<bound member function type>' ->~U 0x{{[^ ]*}}
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:3> 'U<int> *' lvalue ParmVar 0x{{[^ ]*}} 'r' 'U<int> *'

  typeid(a);
  // CHECK: CXXTypeidExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> 'const std::type_info' lvalue
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S'

  // FIXME: no type information is printed for the argument.
  typeid(S);
  // CHECK: CXXTypeidExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> 'const std::type_info' lvalue
}

template <typename... Ts>
void PrimaryExpressions(Ts... a) {
  struct V {
    void f() {
      this;
      // CHECK: CXXThisExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:7> 'V *' this
      [this]{};
      // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:7, col:14>
      // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:7> col:7 implicit class definition
      // CHECK-NEXT: DefinitionData lambda
      // CHECK-NEXT: DefaultConstructor
      // CHECK-NEXT: CopyConstructor
      // CHECK-NEXT: MoveConstructor
      // CHECK-NEXT: CopyAssignment
      // CHECK-NEXT: MoveAssignment
      // CHECK-NEXT: Destructor
      // CHECK-NEXT: CXXMethodDecl
      // CHECK-NEXT: CompoundStmt
      // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:8> col:8 implicit 'V *'
      // CHECK-NEXT: ParenListExpr
      // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}} <col:8> 'V *' this

      [*this]{};
      // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:7, col:15>
      // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:7> col:7 implicit class definition
      // CHECK-NEXT: DefinitionData lambda
      // CHECK-NEXT: DefaultConstructor
      // CHECK-NEXT: CopyConstructor
      // CHECK-NEXT: MoveConstructor
      // CHECK-NEXT: CopyAssignment
      // CHECK-NEXT: MoveAssignment
      // CHECK-NEXT: Destructor
      // CHECK-NEXT: CXXMethodDecl
      // CHECK-NEXT: CompoundStmt
      // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:8> col:8 implicit 'V'
      // CHECK-NEXT: ParenListExpr 0x{{[^ ]*}} <col:8> 'NULL TYPE'
      // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:8> '<dependent type>' prefix '*' cannot overflow
      // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}} <col:8> 'V *' this
    }
  };

  int b, c;

  [](){};
  // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:8> '(lambda at {{.*}}:[[@LINE-1]]:3)'
  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition
  // CHECK-NEXT: DefinitionData lambda
  // CHECK-NEXT: DefaultConstructor
  // CHECK-NEXT: CopyConstructor
  // CHECK-NEXT: MoveConstructor
  // CHECK-NEXT: CopyAssignment
  // CHECK-NEXT: MoveAssignment
  // CHECK-NEXT: Destructor
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:6, col:8> col:3 operator() 'auto () const' inline
  // CHECK-NEXT: CompoundStmt
  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}} <col:3, col:8> col:3 implicit constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:3, col:8> col:3 implicit __invoke 'auto ()' static inline
  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:7, col:8>

  [](int a, ...){};
  // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:18> '(lambda at {{.*}}:[[@LINE-1]]:3)'
  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition
  // CHECK-NEXT: DefinitionData lambda
  // CHECK-NEXT: DefaultConstructor
  // CHECK-NEXT: CopyConstructor
  // CHECK-NEXT: MoveConstructor
  // CHECK-NEXT: CopyAssignment
  // CHECK-NEXT: MoveAssignment
  // CHECK-NEXT: Destructor
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:16, col:18> col:3 operator() 'auto (int, ...) const' inline
  // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:6, col:10> col:10 a 'int'
  // CHECK-NEXT: CompoundStmt
  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}} <col:3, col:18> col:3 implicit constexpr operator auto (*)(int, ...) 'auto (*() const noexcept)(int, ...)' inline
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:3, col:18> col:3 implicit __invoke 'auto (int, ...)' static inline
  // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:6, col:10> col:10 a 'int'
  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:17, col:18>

  [a...]{};
  // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:10> '(lambda at {{.*}}:[[@LINE-1]]:3)'
  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition
  // CHECK-NEXT: DefinitionData lambda
  // CHECK-NEXT: DefaultConstructor
  // CHECK-NEXT: CopyConstructor
  // CHECK-NEXT: MoveConstructor
  // CHECK-NEXT: CopyAssignment
  // CHECK-NEXT: MoveAssignment
  // CHECK-NEXT: Destructor
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:8, col:10> col:3 operator() 'auto () const -> auto' inline
  // CHECK-NEXT: CompoundStmt
  // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:4> col:4 implicit 'Ts...'
  // CHECK-NEXT: ParenListExpr 0x{{[^ ]*}} <col:4> 'NULL TYPE'
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'Ts' lvalue ParmVar 0x{{[^ ]*}} 'a' 'Ts...'
  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:9, col:10>

  [=]{};
  // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:7> '(lambda at {{.*}}:[[@LINE-1]]:3)'
  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition
  // CHECK-NEXT: DefinitionData lambda
  // CHECK-NEXT: DefaultConstructor
  // CHECK-NEXT: CopyConstructor
  // CHECK-NEXT: MoveConstructor
  // CHECK-NEXT: CopyAssignment
  // CHECK-NEXT: MoveAssignment
  // CHECK-NEXT: Destructor
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:5, col:7> col:3 operator() 'auto () const -> auto' inline
  // CHECK-NEXT: CompoundStmt
  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:6, col:7>

  [=] { return b; };
  // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:19> '(lambda at {{.*}}:[[@LINE-1]]:3)'
  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition
  // CHECK-NEXT: DefinitionData lambda
  // CHECK-NEXT: DefaultConstructor
  // CHECK-NEXT: CopyConstructor
  // CHECK-NEXT: MoveConstructor
  // CHECK-NEXT: CopyAssignment
  // CHECK-NEXT: MoveAssignment
  // CHECK-NEXT: Destructor
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:5, col:19> col:3 operator() 'auto () const -> auto' inline
  // CHECK-NEXT: CompoundStmt
  // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:9, col:16>
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> 'const int' lvalue Var 0x{{[^ ]*}} 'b' 'int'
  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:7, col:19>
  // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:9, col:16>
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> 'const int' lvalue Var 0x{{[^ ]*}} 'b' 'int'

  [&]{};
  // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:7> '(lambda at {{.*}}:[[@LINE-1]]:3)'
  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition
  // CHECK-NEXT: DefinitionData lambda
  // CHECK-NEXT: DefaultConstructor
  // CHECK-NEXT: CopyConstructor
  // CHECK-NEXT: MoveConstructor
  // CHECK-NEXT: CopyAssignment
  // CHECK-NEXT: MoveAssignment
  // CHECK-NEXT: Destructor
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:5, col:7> col:3 operator() 'auto () const -> auto' inline
  // CHECK-NEXT: CompoundStmt
  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:6, col:7>

  [&] { return c; };
  // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:19> '(lambda at {{.*}}:[[@LINE-1]]:3)'
  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition
  // CHECK-NEXT: DefinitionData lambda
  // CHECK-NEXT: DefaultConstructor
  // CHECK-NEXT: CopyConstructor
  // CHECK-NEXT: MoveConstructor
  // CHECK-NEXT: CopyAssignment
  // CHECK-NEXT: MoveAssignment
  // CHECK-NEXT: Destructor
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:5, col:19> col:3 operator() 'auto () const -> auto' inline
  // CHECK-NEXT: CompoundStmt
  // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:9, col:16>
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> 'int' lvalue Var 0x{{[^ ]*}} 'c' 'int'
  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:7, col:19>
  // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:9, col:16>
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> 'int' lvalue Var 0x{{[^ ]*}} 'c' 'int'

  [b, &c]{ return b + c; };
  // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:26> '(lambda at {{.*}}:[[@LINE-1]]:3)'
  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition
  // CHECK-NEXT: DefinitionData lambda
  // CHECK-NEXT: DefaultConstructor
  // CHECK-NEXT: CopyConstructor
  // CHECK-NEXT: MoveConstructor
  // CHECK-NEXT: CopyAssignment
  // CHECK-NEXT: MoveAssignment
  // CHECK-NEXT: Destructor
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:9, col:26> col:3 operator() 'auto () const -> auto' inline
  // CHECK-NEXT: CompoundStmt
  // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:12, col:23>
  // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:19, col:23> 'int' '+'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:19> 'const int' lvalue Var 0x{{[^ ]*}} 'b' 'int'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:23> 'int' lvalue Var 0x{{[^ ]*}} 'c' 'int'
  // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:4> col:4 implicit 'int'
  // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:8> col:8 implicit 'int &'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'int' lvalue Var 0x{{[^ ]*}} 'b' 'int'
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:8> 'int' lvalue Var 0x{{[^ ]*}} 'c' 'int'
  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:10, col:26>
  // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:12, col:23>
  // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:19, col:23> 'int' '+'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:19> 'const int' lvalue Var 0x{{[^ ]*}} 'b' 'int'
  // CHECK-NEXT: ImplicitCastExpr
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:23> 'int' lvalue Var 0x{{[^ ]*}} 'c' 'int'

  [a..., x = 12]{};
  // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:18> '(lambda at {{.*}}:[[@LINE-1]]:3)'
  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition
  // CHECK-NEXT: DefinitionData lambda
  // CHECK-NEXT: DefaultConstructor
  // CHECK-NEXT: CopyConstructor
  // CHECK-NEXT: MoveConstructor
  // CHECK-NEXT: CopyAssignment
  // CHECK-NEXT: MoveAssignment
  // CHECK-NEXT: Destructor
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:16, col:18> col:3 operator() 'auto () const -> auto' inline
  // CHECK-NEXT: CompoundStmt
  // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:4> col:4 implicit 'Ts...'
  // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <col:10> col:10 implicit 'int':'int'
  // CHECK-NEXT: ParenListExpr 0x{{[^ ]*}} <col:4> 'NULL TYPE'
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'Ts' lvalue ParmVar 0x{{[^ ]*}} 'a' 'Ts...'
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:14> 'int' 12
  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:17, col:18>

  []() constexpr {};
  // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:19> '(lambda at {{.*}}:[[@LINE-1]]:3)'
  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition
  // CHECK-NEXT: DefinitionData lambda
  // CHECK-NEXT: DefaultConstructor
  // CHECK-NEXT: CopyConstructor
  // CHECK-NEXT: MoveConstructor
  // CHECK-NEXT: CopyAssignment
  // CHECK-NEXT: MoveAssignment
  // CHECK-NEXT: Destructor
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:8, col:19> col:3 constexpr operator() 'auto () const' inline
  // CHECK-NEXT: CompoundStmt
  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}} <col:3, col:19> col:3 implicit constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:3, col:19> col:3 implicit __invoke 'auto ()' static inline
  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:18, col:19>

  []() mutable {};
  // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:17> '(lambda at {{.*}}:[[@LINE-1]]:3)'
  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition
  // CHECK-NEXT: DefinitionData lambda
  // CHECK-NEXT: DefaultConstructor
  // CHECK-NEXT: CopyConstructor
  // CHECK-NEXT: MoveConstructor
  // CHECK-NEXT: CopyAssignment
  // CHECK-NEXT: MoveAssignment
  // CHECK-NEXT: Destructor
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:8, col:17> col:3 operator() 'auto ()' inline
  // CHECK-NEXT: CompoundStmt
  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}} <col:3, col:17> col:3 implicit constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:3, col:17> col:3 implicit __invoke 'auto ()' static inline
  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:16, col:17>

  []() noexcept {};
  // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:18> '(lambda at {{.*}}:[[@LINE-1]]:3)'
  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition
  // CHECK-NEXT: DefinitionData lambda
  // CHECK-NEXT: DefaultConstructor
  // CHECK-NEXT: CopyConstructor
  // CHECK-NEXT: MoveConstructor
  // CHECK-NEXT: CopyAssignment
  // CHECK-NEXT: MoveAssignment
  // CHECK-NEXT: Destructor
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:8, col:18> col:3 operator() 'auto () const noexcept' inline
  // CHECK-NEXT: CompoundStmt
  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}} <col:3, col:18> col:3 implicit constexpr operator auto (*)() noexcept 'auto (*() const noexcept)() noexcept' inline
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:3, col:18> col:3 implicit __invoke 'auto () noexcept' static inline
  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:17, col:18>

  []() -> int { return 0; };
  // CHECK: LambdaExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:27> '(lambda at {{.*}}:[[@LINE-1]]:3)'
  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}} <col:3> col:3 implicit class definition
  // CHECK-NEXT: DefinitionData lambda
  // CHECK-NEXT: DefaultConstructor
  // CHECK-NEXT: CopyConstructor
  // CHECK-NEXT: MoveConstructor
  // CHECK-NEXT: CopyAssignment
  // CHECK-NEXT: MoveAssignment
  // CHECK-NEXT: Destructor
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:11, col:27> col:3 operator() 'auto () const -> int' inline
  // CHECK-NEXT: CompoundStmt
  // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:17, col:24>
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:24> 'int' 0
  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}} <col:3, col:27> col:3 implicit constexpr operator int (*)() 'auto (*() const noexcept)() -> int' inline
  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}} <col:3, col:27> col:3 implicit __invoke 'auto () -> int' static inline
  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:15, col:27>
  // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} <col:17, col:24>
  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:24> 'int' 0

  (a + ...);
  // CHECK: CXXFoldExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> '<dependent type>'
  // CHECK-NEXT: <<<NULL>>>
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'Ts' lvalue ParmVar 0x{{[^ ]*}} 'a' 'Ts...'
  // CHECK-NEXT: <<<NULL>>>

  (... + a);
  // CHECK: CXXFoldExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11> '<dependent type>'
  // CHECK-NEXT: <<<NULL>>>
  // CHECK-NEXT: <<<NULL>>>
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> 'Ts' lvalue ParmVar 0x{{[^ ]*}} 'a' 'Ts...'

  (a + ... + b);
  // CHECK: CXXFoldExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:15> '<dependent type>'
  // CHECK-NEXT: <<<NULL>>>
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:4> 'Ts' lvalue ParmVar 0x{{[^ ]*}} 'a' 'Ts...'
  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:14> 'int' lvalue Var 0x{{[^ ]*}} 'b' 'int'
}


namespace NS {
struct X {};
void f(X);
void y(...);
} // namespace NS

// CHECK-LABEL: FunctionDecl 0x{{[^ ]*}} {{.*}}ADLCall 'void ()'
void ADLCall() {
  NS::X x;
  // CHECK: CallExpr 0x{{[^ ]*}} <line:[[@LINE+1]]:{{[^>]+}}> 'void' adl{{$}}
  f(x);
  // CHECK: CallExpr 0x{{[^ ]*}} <line:[[@LINE+1]]:{{[^>]+}}> 'void' adl{{$}}
  y(x);
}

// CHECK-LABEL: FunctionDecl 0x{{[^ ]*}} {{.*}}NonADLCall 'void ()'
void NonADLCall() {
  NS::X x;
  // CHECK: CallExpr 0x{{[^ ]*}} <line:[[@LINE+1]]:{{[^>]+}}> 'void'{{$}}
  NS::f(x);
}

// CHECK-LABEL: FunctionDecl 0x{{[^ ]*}} {{.*}}NonADLCall2 'void ()'
void NonADLCall2() {
  NS::X x;
  using NS::f;
  // CHECK: CallExpr 0x{{[^ ]*}} <line:[[@LINE+1]]:{{[^>]+}}> 'void'{{$}}
  f(x);
  // CHECK: CallExpr 0x{{[^ ]*}} <line:[[@LINE+1]]:{{[^>]+}}> 'void' adl{{$}}
  y(x);
}

namespace test_adl_call_three {
using namespace NS;
// CHECK-LABEL: FunctionDecl 0x{{[^ ]*}} {{.*}}NonADLCall3 'void ()'
void NonADLCall3() {
  X x;
  // CHECK: CallExpr 0x{{[^ ]*}} <line:[[@LINE+1]]:{{[^>]+}}> 'void'{{$}}
  f(x);
}
} // namespace test_adl_call_three