]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/AST/ast-dump-decl.m
Vendor import of clang trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / 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'
32 // CHECK-NEXT:   ParmVarDecl{{.*}} i 'int'
33 // CHECK-NEXT:   ...
34 @end
35
36 @implementation testObjCMethodDecl
37 - (int) TestObjCMethodDecl: (int)i, ... {
38   return 0;
39 }
40 // CHECK:      ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int'
41 // CHECK-NEXT:   ImplicitParamDecl{{.*}} self
42 // CHECK-NEXT:   ImplicitParamDecl{{.*}} _cmd
43 // CHECK-NEXT:   ParmVarDecl{{.*}} i 'int'
44 // CHECK-NEXT:   ...
45 // CHECK-NEXT:   CompoundStmt
46 @end
47
48 @protocol TestObjCProtocolDecl
49 - (void) foo;
50 @end
51 // CHECK:      ObjCProtocolDecl{{.*}} TestObjCProtocolDecl
52 // CHECK-NEXT:   ObjCMethodDecl{{.*}} foo
53
54 @interface TestObjCClass : A <P>
55 - (void) foo;
56 @end
57 // CHECK:      ObjCInterfaceDecl{{.*}} TestObjCClass
58 // CHECK-NEXT:   super ObjCInterface{{.*}} 'A'
59 // CHECK-NEXT:   ObjCImplementation{{.*}} 'TestObjCClass'
60 // CHECK-NEXT:   ObjCProtocol{{.*}} 'P'
61 // CHECK-NEXT:   ObjCMethodDecl{{.*}} foo
62
63 @implementation TestObjCClass : A {
64   int i;
65 }
66 - (void) foo {
67 }
68 @end
69 // CHECK:      ObjCImplementationDecl{{.*}} TestObjCClass
70 // CHECK-NEXT:   super ObjCInterface{{.*}} 'A'
71 // CHECK-NEXT:   ObjCInterface{{.*}} 'TestObjCClass'
72 // CHECK-NEXT:   ObjCIvarDecl{{.*}} i
73 // CHECK-NEXT:   ObjCMethodDecl{{.*}} foo
74
75 @interface TestObjCClass (TestObjCCategoryDecl) <P>
76 - (void) bar;
77 @end
78 // CHECK:      ObjCCategoryDecl{{.*}} TestObjCCategoryDecl
79 // CHECK-NEXT:   ObjCInterface{{.*}} 'TestObjCClass'
80 // CHECK-NEXT:   ObjCCategoryImpl{{.*}} 'TestObjCCategoryDecl'
81 // CHECK-NEXT:   ObjCProtocol{{.*}} 'P'
82 // CHECK-NEXT:   ObjCMethodDecl{{.*}} bar
83
84 @interface TestGenericInterface<T> : A<P> {
85 }
86 @end
87 // CHECK:      ObjCInterfaceDecl{{.*}} TestGenericInterface
88 // CHECK-NEXT:   -super ObjCInterface {{.+}} 'A'
89 // CHECK-NEXT:   -ObjCProtocol {{.+}} 'P'
90 // CHECK-NEXT:   -ObjCTypeParamDecl {{.+}} <col:33> col:33 T 'id':'id'
91
92 @implementation TestObjCClass (TestObjCCategoryDecl)
93 - (void) bar {
94 }
95 @end
96 // CHECK:      ObjCCategoryImplDecl{{.*}} TestObjCCategoryDecl
97 // CHECK-NEXT:   ObjCInterface{{.*}} 'TestObjCClass'
98 // CHECK-NEXT:   ObjCCategory{{.*}} 'TestObjCCategoryDecl'
99 // CHECK-NEXT:   ObjCMethodDecl{{.*}} bar
100
101 @compatibility_alias TestObjCCompatibleAliasDecl A;
102 // CHECK:      ObjCCompatibleAliasDecl{{.*}} TestObjCCompatibleAliasDecl
103 // CHECK-NEXT:   ObjCInterface{{.*}} 'A'
104
105 @interface TestObjCProperty: A
106 @property(getter=getterFoo, setter=setterFoo:) int foo;
107 @property int bar;
108 @end
109 // CHECK:      ObjCInterfaceDecl{{.*}} TestObjCProperty
110 // CHECK:        ObjCPropertyDecl{{.*}} foo 'int' assign readwrite atomic unsafe_unretained
111 // CHECK-NEXT:     getter ObjCMethod{{.*}} 'getterFoo'
112 // CHECK-NEXT:     setter ObjCMethod{{.*}} 'setterFoo:'
113 // CHECK-NEXT:   ObjCPropertyDecl{{.*}} bar 'int' assign readwrite atomic unsafe_unretained
114 // CHECK-NEXT:   ObjCMethodDecl{{.*}} getterFoo
115 // CHECK-NEXT:   ObjCMethodDecl{{.*}} setterFoo:
116 // CHECK-NEXT:     ParmVarDecl{{.*}} foo
117 // CHECK-NEXT:   ObjCMethodDecl{{.*}} bar
118 // CHECK-NEXT:   ObjCMethodDecl{{.*}} setBar:
119 // CHECK-NEXT:     ParmVarDecl{{.*}} bar
120
121 @implementation TestObjCProperty {
122   int i;
123 }
124 @synthesize foo=i;
125 @synthesize bar;
126 @end
127 // CHECK:      ObjCImplementationDecl{{.*}} TestObjCProperty
128 // CHECK:        ObjCPropertyImplDecl{{.*}} foo synthesize
129 // CHECK-NEXT:     ObjCProperty{{.*}} 'foo'
130 // CHECK-NEXT:     ObjCIvar{{.*}} 'i' 'int'
131 // CHECK-NEXT:   ObjCIvarDecl{{.*}} bar 'int' synthesize private
132 // CHECK-NEXT:   ObjCPropertyImplDecl{{.*}} bar synthesize
133 // CHECK-NEXT:     ObjCProperty{{.*}} 'bar'
134 // CHECK-NEXT:     ObjCIvar{{.*}} 'bar' 'int'
135
136 void TestBlockDecl(int x) {
137   ^(int y, ...){ x; };
138 }
139 // CHECK:      FunctionDecl{{.*}}TestBlockDecl
140 // CHECK:      BlockDecl
141 // CHECK-NEXT:   ParmVarDecl{{.*}} y 'int'
142 // CHECK-NEXT:   ...
143 // CHECK-NEXT:   capture ParmVar{{.*}} 'x' 'int'
144 // CHECK-NEXT:   CompoundStmt
145
146 @interface B
147 + (int) foo;
148 @end
149
150 void f() {
151   __typeof__(B.foo) Test;
152 }
153 // CHECK: VarDecl{{.*}}Test 'typeof (B.foo)':'int'