xref: /llvm-project/clang/test/AST/ast-dump-decl.mm (revision 29444f0444c6d3586969fd6fbe49c8188c02c244)
1// Test without serialization:
2// RUN: %clang_cc1 -Wno-unused -fblocks -ast-dump -ast-dump-filter Test %s \
3// RUN: | FileCheck --strict-whitespace %s
4// RUN: %clang_cc1 -Wno-unused -fblocks -ast-dump -triple i386-windows-pc -ast-dump-filter Test %s \
5// RUN: | FileCheck --strict-whitespace %s
6//
7// Test with serialization:
8// RUN: %clang_cc1 -Wno-unused -fblocks -emit-pch -o %t %s
9// RUN: %clang_cc1 -x objective-c++ -Wno-unused -fblocks -include-pch %t \
10// RUN: -ast-dump-all -ast-dump-filter Test /dev/null \
11// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
12// RUN: | FileCheck --strict-whitespace %s
13
14@interface A
15@end
16
17@interface TestObjCImplementation : A
18@end
19
20@implementation TestObjCImplementation : A {
21  struct X {
22    int i;
23  } X;
24}
25- (void) foo {
26}
27@end
28// CHECK:      ObjCImplementationDecl{{.*}} TestObjCImplementation
29// CHECK-NEXT:   super ObjCInterface{{.*}} 'A'
30// CHECK-NEXT:   ObjCInterface{{.*}} 'TestObjCImplementation'
31// CHECK-NEXT:   CXXCtorInitializer{{.*}} 'X'
32// CHECK-NEXT:     CXXConstructExpr
33// CHECK-NEXT:   CXXRecordDecl{{.*}} struct X definition
34// CHECK-NEXT:     DefinitionData
35// CHECK-NEXT:       DefaultConstructor
36// CHECK-NEXT:       CopyConstructor
37// CHECK-NEXT:       MoveConstructor
38// CHECK-NEXT:       CopyAssignment
39// CHECK-NEXT:       MoveAssignment
40// CHECK-NEXT:       Destructor
41// CHECK-NEXT:     CXXRecordDecl{{.*}} struct X
42// CHECK-NEXT:     FieldDecl{{.*}} i 'int'
43// CHECK-NEXT:     CXXConstructorDecl{{.*}} 'void ()
44// CHECK-NEXT:       CompoundStmt
45// CHECK-NEXT:     CXXConstructorDecl{{.*}} 'void (const X &)
46// CHECK-NEXT:       ParmVarDecl{{.*}} 'const X &'
47// CHECK-NEXT:     CXXConstructorDecl{{.*}} 'void (X &&)
48// CHECK-NEXT:       ParmVarDecl{{.*}} 'X &&'
49// CHECK-NEXT:     CXXDestructorDecl
50// CHECK-NEXT:   ObjCIvarDecl{{.*}} X
51// CHECK-NEXT:   ObjCMethodDecl{{.*}} foo
52
53// @() boxing expressions.
54template <typename T>
55struct BoxingTest {
56  static id box(T value) {
57    return @(value);
58  }
59};
60
61// CHECK: ObjCBoxedExpr{{.*}} '<dependent type>'{{$}}
62
63struct Test {
64  void f() {
65    ^{ this->yada(); }();
66    // CHECK:      ExprWithCleanups {{.*}} <line:[[@LINE-1]]:5, col:24> 'void'
67    // CHECK-NEXT:   cleanup Block
68    // CHECK-NEXT:   CallExpr {{.*}} <col:5, col:24> 'void'
69    // CHECK-NEXT:     BlockExpr {{.*}} <col:5, col:22> 'void (^)()'
70    // CHECK-NEXT:       BlockDecl {{.*}} <col:5, col:22> col:5 captures_this
71    // CHECK-NEXT:         CompoundStmt {{.*}} <col:6, col:22>
72    // CHECK-NEXT:           CXXMemberCallExpr {{.*}} <col:8, col:19> 'void'
73    // CHECK-NEXT:             MemberExpr {{.*}} <col:8, col:14> '<bound member function type>' ->yada
74    // CHECK-NEXT:               CXXThisExpr {{.*}} <col:8> 'Test *' this
75  }
76  void yada();
77  // CHECK:      CXXMethodDecl {{.*}} <line:[[@LINE-1]]:3, col:13> col:8 used yada 'void (){{.*}}'
78};
79
80@protocol P
81@end;
82
83using TestObjCPointerWithoutStar = id<P>;
84// CHECK:      TypeAliasDecl {{.+}} <{{.+}}:[[@LINE-1]]:1, col:40> col:7 TestObjCPointerWithoutStar 'id<P>'
85
86using TestObjCPointerWithStar = A *;
87// CHECK:      TypeAliasDecl {{.+}} <{{.+}}:[[@LINE-1]]:1, col:35> col:7 TestObjCPointerWithStar 'A *'
88