Clang Project

clang_source_code/test/AST/ast-dump-decl.m
1// RUN: %clang_cc1 -Wno-unused -fblocks -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s
2
3@protocol P
4@end
5
6@interface A
7@end
8
9@interface TestObjCIvarDecl : A
10@end
11
12@implementation TestObjCIvarDecl {
13  int varDefault;
14  @private int varPrivate;
15  @protected int varProtected;
16  @public int varPublic;
17  @package int varPackage;
18}
19@end
20// CHECK:      ObjCImplementationDecl{{.*}} TestObjCIvarDecl
21// CHECK-NEXT:   ObjCInterface{{.*}} 'TestObjCIvarDecl'
22// CHECK-NEXT:   ObjCIvarDecl{{.*}} varDefault 'int' private
23// CHECK-NEXT:   ObjCIvarDecl{{.*}} varPrivate 'int' private
24// CHECK-NEXT:   ObjCIvarDecl{{.*}} varProtected 'int' protected
25// CHECK-NEXT:   ObjCIvarDecl{{.*}} varPublic 'int' public
26// CHECK-NEXT:   ObjCIvarDecl{{.*}} varPackage 'int' package
27
28@interface testObjCMethodDecl : A {
29}
30- (int) TestObjCMethodDecl: (int)i, ...;
31// CHECK:      ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int' variadic
32// CHECK-NEXT:   ParmVarDecl{{.*}} i 'int'
33@end
34
35@implementation testObjCMethodDecl
36- (int) TestObjCMethodDecl: (int)i, ... {
37  return 0;
38}
39// CHECK:      ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int' variadic
40// CHECK-NEXT:   ImplicitParamDecl{{.*}} self
41// CHECK-NEXT:   ImplicitParamDecl{{.*}} _cmd
42// CHECK-NEXT:   ParmVarDecl{{.*}} i 'int'
43// CHECK-NEXT:   CompoundStmt
44@end
45
46@protocol TestObjCProtocolDecl
47- (void) foo;
48@end
49// CHECK:      ObjCProtocolDecl{{.*}} TestObjCProtocolDecl
50// CHECK-NEXT:   ObjCMethodDecl{{.*}} foo
51
52@interface TestObjCClass : A <P>
53- (void) foo;
54@end
55// CHECK:      ObjCInterfaceDecl{{.*}} TestObjCClass
56// CHECK-NEXT:   super ObjCInterface{{.*}} 'A'
57// CHECK-NEXT:   ObjCImplementation{{.*}} 'TestObjCClass'
58// CHECK-NEXT:   ObjCProtocol{{.*}} 'P'
59// CHECK-NEXT:   ObjCMethodDecl{{.*}} foo
60
61@implementation TestObjCClass : A {
62  int i;
63}
64- (void) foo {
65}
66@end
67// CHECK:      ObjCImplementationDecl{{.*}} TestObjCClass
68// CHECK-NEXT:   super ObjCInterface{{.*}} 'A'
69// CHECK-NEXT:   ObjCInterface{{.*}} 'TestObjCClass'
70// CHECK-NEXT:   ObjCIvarDecl{{.*}} i
71// CHECK-NEXT:   ObjCMethodDecl{{.*}} foo
72
73@interface TestObjCClass (TestObjCCategoryDecl) <P>
74- (void) bar;
75@end
76// CHECK:      ObjCCategoryDecl{{.*}} TestObjCCategoryDecl
77// CHECK-NEXT:   ObjCInterface{{.*}} 'TestObjCClass'
78// CHECK-NEXT:   ObjCCategoryImpl{{.*}} 'TestObjCCategoryDecl'
79// CHECK-NEXT:   ObjCProtocol{{.*}} 'P'
80// CHECK-NEXT:   ObjCMethodDecl{{.*}} bar
81
82@interface TestGenericInterface<T> : A<P> {
83}
84@end
85// CHECK:      ObjCInterfaceDecl{{.*}} TestGenericInterface
86// CHECK-NEXT:   -super ObjCInterface {{.+}} 'A'
87// CHECK-NEXT:   -ObjCProtocol {{.+}} 'P'
88// CHECK-NEXT:   -ObjCTypeParamDecl {{.+}} <col:33> col:33 T 'id':'id'
89
90@implementation TestObjCClass (TestObjCCategoryDecl)
91- (void) bar {
92}
93@end
94// CHECK:      ObjCCategoryImplDecl{{.*}} TestObjCCategoryDecl
95// CHECK-NEXT:   ObjCInterface{{.*}} 'TestObjCClass'
96// CHECK-NEXT:   ObjCCategory{{.*}} 'TestObjCCategoryDecl'
97// CHECK-NEXT:   ObjCMethodDecl{{.*}} bar
98
99@compatibility_alias TestObjCCompatibleAliasDecl A;
100// CHECK:      ObjCCompatibleAliasDecl{{.*}} TestObjCCompatibleAliasDecl
101// CHECK-NEXT:   ObjCInterface{{.*}} 'A'
102
103@interface TestObjCProperty: A
104@property(getter=getterFoo, setter=setterFoo:) int foo;
105@property int bar;
106@end
107// CHECK:      ObjCInterfaceDecl{{.*}} TestObjCProperty
108// CHECK:        ObjCPropertyDecl{{.*}} foo 'int' assign readwrite atomic unsafe_unretained
109// CHECK-NEXT:     getter ObjCMethod{{.*}} 'getterFoo'
110// CHECK-NEXT:     setter ObjCMethod{{.*}} 'setterFoo:'
111// CHECK-NEXT:   ObjCPropertyDecl{{.*}} bar 'int' assign readwrite atomic unsafe_unretained
112// CHECK-NEXT:   ObjCMethodDecl{{.*}} getterFoo
113// CHECK-NEXT:   ObjCMethodDecl{{.*}} setterFoo:
114// CHECK-NEXT:     ParmVarDecl{{.*}} foo
115// CHECK-NEXT:   ObjCMethodDecl{{.*}} bar
116// CHECK-NEXT:   ObjCMethodDecl{{.*}} setBar:
117// CHECK-NEXT:     ParmVarDecl{{.*}} bar
118
119@implementation TestObjCProperty {
120  int i;
121}
122@synthesize foo=i;
123@synthesize bar;
124@end
125// CHECK:      ObjCImplementationDecl{{.*}} TestObjCProperty
126// CHECK:        ObjCPropertyImplDecl{{.*}} foo synthesize
127// CHECK-NEXT:     ObjCProperty{{.*}} 'foo'
128// CHECK-NEXT:     ObjCIvar{{.*}} 'i' 'int'
129// CHECK-NEXT:   ObjCIvarDecl{{.*}} bar 'int' synthesize private
130// CHECK-NEXT:   ObjCPropertyImplDecl{{.*}} bar synthesize
131// CHECK-NEXT:     ObjCProperty{{.*}} 'bar'
132// CHECK-NEXT:     ObjCIvar{{.*}} 'bar' 'int'
133
134void TestBlockDecl(int x) {
135  ^(int y, ...){ x; };
136}
137// CHECK:      FunctionDecl{{.*}}TestBlockDecl
138// CHECK:      BlockDecl {{.+}} <col:3, col:21> col:3 variadic
139// CHECK-NEXT:   ParmVarDecl{{.*}} y 'int'
140// CHECK-NEXT:   capture ParmVar{{.*}} 'x' 'int'
141// CHECK-NEXT:   CompoundStmt
142
143@interface B
144+ (int) foo;
145@end
146
147void f() {
148  __typeof__(B.foo) Test;
149}
150// CHECK: VarDecl{{.*}}Test 'typeof (B.foo)':'int'
151