[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / clang / test / AST / ast-dump-decl.m
blob5f09b6042f409fb79693ab8ebb3d7b4ed6fc7a7f
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 //
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
12 @protocol P
13 @end
15 @interface A
16 @end
18 @interface TestObjCIvarDecl : A
19 @end
21 @implementation TestObjCIvarDecl {
22   int varDefault;
23   @private int varPrivate;
24   @protected int varProtected;
25   @public int varPublic;
26   @package int varPackage;
28 @end
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'
42 @end
44 @implementation testObjCMethodDecl
45 - (int) TestObjCMethodDecl: (int)i, ... {
46   return 0;
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
53 @end
55 @protocol TestObjCProtocolDecl
56 - (void) foo;
57 @end
58 // CHECK:      ObjCProtocolDecl{{.*}} TestObjCProtocolDecl
59 // CHECK-NEXT:   ObjCMethodDecl{{.*}} foo
61 @interface TestObjCClass : A <P>
62 - (void) foo;
63 @end
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 {
71   int i;
73 - (void) foo {
75 @end
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>
83 - (void) bar;
84 @end
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> {
93 @end
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'
99 @implementation TestObjCClass (TestObjCCategoryDecl)
100 - (void) bar {
102 @end
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;
114 @property int bar;
115 @end
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 {
129   int i;
131 @synthesize foo=i;
132 @synthesize bar;
133 @end
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) {
144   ^(int y, ...){ x; };
145   int z;
147 // CHECK:      FunctionDecl{{.*}}TestBlockDecl
148 // CHECK:      BlockDecl {{.+}} <col:3, col:21> col:3 variadic
149 // CHECK-NEXT:   ParmVarDecl{{.*}} y 'int'
150 // CHECK-NEXT:   capture ParmVar{{.*}} 'x' 'int'
151 // CHECK-NEXT:   CompoundStmt
152 // CHECK-NEXT:     ImplicitCastExpr
153 // CHECK-NEXT:       DeclRefExpr{{.*}} 'x'
154 // CHECK-NEXT: DeclStmt
155 // CHECK-NEXT:   VarDecl{{.*}} z
157 @interface B
158 + (int) foo;
159 @end
161 void f(void) {
162   __typeof__(B.foo) Test;
164 // CHECK: VarDecl{{.*}}Test 'typeof (B.foo)':'int'