1 // Test without serialization:
2 // RUN: %clang_cc1 -Wno-unused -fblocks -ast-dump -ast-dump-filter Test %s \
3 // RUN: | FileCheck --strict-whitespace %s
5 // Test with serialization:
6 // RUN: %clang_cc1 -Wno-unused -fblocks -emit-pch -o %t %s
7 // RUN: %clang_cc1 -x objective-c -Wno-unused -fblocks -include-pch %t \
8 // RUN: -ast-dump-all -ast-dump-filter Test /dev/null \
9 // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
10 // RUN: | FileCheck --strict-whitespace %s
18 @interface TestObjCIvarDecl : A
21 @implementation TestObjCIvarDecl {
23 @private int varPrivate;
24 @protected int varProtected;
25 @public int varPublic;
26 @package int varPackage;
29 // CHECK: ObjCImplementationDecl{{.*}} TestObjCIvarDecl
30 // CHECK-NEXT: ObjCInterface{{.*}} 'TestObjCIvarDecl'
31 // CHECK-NEXT: ObjCIvarDecl{{.*}} varDefault 'int' private
32 // CHECK-NEXT: ObjCIvarDecl{{.*}} varPrivate 'int' private
33 // CHECK-NEXT: ObjCIvarDecl{{.*}} varProtected 'int' protected
34 // CHECK-NEXT: ObjCIvarDecl{{.*}} varPublic 'int' public
35 // CHECK-NEXT: ObjCIvarDecl{{.*}} varPackage 'int' package
37 @interface testObjCMethodDecl : A {
39 - (int) TestObjCMethodDecl: (int)i, ...;
40 // CHECK: ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int' variadic
41 // CHECK-NEXT: ParmVarDecl{{.*}} i 'int'
44 @implementation testObjCMethodDecl
45 - (int) TestObjCMethodDecl: (int)i, ... {
48 // CHECK: ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int' variadic
49 // CHECK-NEXT: ImplicitParamDecl{{.*}} self
50 // CHECK-NEXT: ImplicitParamDecl{{.*}} _cmd
51 // CHECK-NEXT: ParmVarDecl{{.*}} i 'int'
52 // CHECK-NEXT: CompoundStmt
55 @protocol TestObjCProtocolDecl
58 // CHECK: ObjCProtocolDecl{{.*}} TestObjCProtocolDecl
59 // CHECK-NEXT: ObjCMethodDecl{{.*}} foo
61 @interface TestObjCClass : A <P>
64 // CHECK: ObjCInterfaceDecl{{.*}} TestObjCClass
65 // CHECK-NEXT: super ObjCInterface{{.*}} 'A'
66 // CHECK-NEXT: ObjCImplementation{{.*}} 'TestObjCClass'
67 // CHECK-NEXT: ObjCProtocol{{.*}} 'P'
68 // CHECK-NEXT: ObjCMethodDecl{{.*}} foo
70 @implementation TestObjCClass : A {
76 // CHECK: ObjCImplementationDecl{{.*}} TestObjCClass
77 // CHECK-NEXT: super ObjCInterface{{.*}} 'A'
78 // CHECK-NEXT: ObjCInterface{{.*}} 'TestObjCClass'
79 // CHECK-NEXT: ObjCIvarDecl{{.*}} i
80 // CHECK-NEXT: ObjCMethodDecl{{.*}} foo
82 @interface TestObjCClass (TestObjCCategoryDecl) <P>
85 // CHECK: ObjCCategoryDecl{{.*}} TestObjCCategoryDecl
86 // CHECK-NEXT: ObjCInterface{{.*}} 'TestObjCClass'
87 // CHECK-NEXT: ObjCCategoryImpl{{.*}} 'TestObjCCategoryDecl'
88 // CHECK-NEXT: ObjCProtocol{{.*}} 'P'
89 // CHECK-NEXT: ObjCMethodDecl{{.*}} bar
91 @interface TestGenericInterface<T> : A<P> {
94 // CHECK: ObjCInterfaceDecl{{.*}} TestGenericInterface
95 // CHECK-NEXT: -super ObjCInterface {{.+}} 'A'
96 // CHECK-NEXT: -ObjCProtocol {{.+}} 'P'
97 // CHECK-NEXT: -ObjCTypeParamDecl {{.+}} <col:33> col:33 T 'id':'id'
99 @implementation TestObjCClass (TestObjCCategoryDecl)
103 // CHECK: ObjCCategoryImplDecl{{.*}} TestObjCCategoryDecl
104 // CHECK-NEXT: ObjCInterface{{.*}} 'TestObjCClass'
105 // CHECK-NEXT: ObjCCategory{{.*}} 'TestObjCCategoryDecl'
106 // CHECK-NEXT: ObjCMethodDecl{{.*}} bar
108 @compatibility_alias TestObjCCompatibleAliasDecl A;
109 // CHECK: ObjCCompatibleAliasDecl{{.*}} TestObjCCompatibleAliasDecl
110 // CHECK-NEXT: ObjCInterface{{.*}} 'A'
112 @interface TestObjCProperty: A
113 @property(getter=getterFoo, setter=setterFoo:) int foo;
116 // CHECK: ObjCInterfaceDecl{{.*}} TestObjCProperty
117 // CHECK: ObjCPropertyDecl{{.*}} foo 'int' assign readwrite atomic unsafe_unretained
118 // CHECK-NEXT: getter ObjCMethod{{.*}} 'getterFoo'
119 // CHECK-NEXT: setter ObjCMethod{{.*}} 'setterFoo:'
120 // CHECK-NEXT: ObjCPropertyDecl{{.*}} bar 'int' assign readwrite atomic unsafe_unretained
121 // CHECK-NEXT: ObjCMethodDecl{{.*}} getterFoo
122 // CHECK-NEXT: ObjCMethodDecl{{.*}} setterFoo:
123 // CHECK-NEXT: ParmVarDecl{{.*}} foo
124 // CHECK-NEXT: ObjCMethodDecl{{.*}} bar
125 // CHECK-NEXT: ObjCMethodDecl{{.*}} setBar:
126 // CHECK-NEXT: ParmVarDecl{{.*}} bar
128 @implementation TestObjCProperty {
134 // CHECK: ObjCImplementationDecl{{.*}} TestObjCProperty
135 // CHECK: ObjCPropertyImplDecl{{.*}} foo synthesize
136 // CHECK-NEXT: ObjCProperty{{.*}} 'foo'
137 // CHECK-NEXT: ObjCIvar{{.*}} 'i' 'int'
138 // CHECK-NEXT: ObjCIvarDecl{{.*}} bar 'int' synthesize private
139 // CHECK-NEXT: ObjCPropertyImplDecl{{.*}} bar synthesize
140 // CHECK-NEXT: ObjCProperty{{.*}} 'bar'
141 // CHECK-NEXT: ObjCIvar{{.*}} 'bar' 'int'
143 void TestBlockDecl(int x) {
146 // CHECK: FunctionDecl{{.*}}TestBlockDecl
147 // CHECK: BlockDecl {{.+}} <col:3, col:21> col:3 variadic
148 // CHECK-NEXT: ParmVarDecl{{.*}} y 'int'
149 // CHECK-NEXT: capture ParmVar{{.*}} 'x' 'int'
150 // CHECK-NEXT: CompoundStmt
157 __typeof__(B.foo) Test;
159 // CHECK: VarDecl{{.*}}Test 'typeof (B.foo)':'int'