| 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 |
| 11 |
|
| 12 |
@protocol P |
| 13 |
@end |
| 14 |
|
| 15 |
@interface A |
| 16 |
@end |
| 17 |
|
| 18 |
@interface TestObjCIvarDecl : A |
| 19 |
@end |
| 20 |
|
| 21 |
@implementation TestObjCIvarDecl { |
| 22 |
int varDefault; |
| 23 |
@private int varPrivate; |
| 24 |
@protected int varProtected; |
| 25 |
@public int varPublic; |
| 26 |
@package int varPackage; |
| 27 |
} |
| 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 |
| 36 |
|
| 37 |
@interface testObjCMethodDecl : A { |
| 38 |
} |
| 39 |
- (int) TestObjCMethodDecl: (int)i, ...; |
| 40 |
// CHECK: ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int' variadic |
| 41 |
// CHECK-NEXT: ParmVarDecl{{.*}} i 'int' |
| 42 |
@end |
| 43 |
|
| 44 |
@implementation testObjCMethodDecl |
| 45 |
- (int) TestObjCMethodDecl: (int)i, ... { |
| 46 |
return 0; |
| 47 |
} |
| 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 |
| 54 |
|
| 55 |
@protocol TestObjCProtocolDecl |
| 56 |
- (void) foo; |
| 57 |
@end |
| 58 |
// CHECK: ObjCProtocolDecl{{.*}} TestObjCProtocolDecl |
| 59 |
// CHECK-NEXT: ObjCMethodDecl{{.*}} foo |
| 60 |
|
| 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 |
| 69 |
|
| 70 |
@implementation TestObjCClass : A { |
| 71 |
int i; |
| 72 |
} |
| 73 |
- (void) foo { |
| 74 |
} |
| 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 |
| 81 |
|
| 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 |
| 90 |
|
| 91 |
@interface TestGenericInterface<T> : A<P> { |
| 92 |
} |
| 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' |
| 98 |
|
| 99 |
@implementation TestObjCClass (TestObjCCategoryDecl) |
| 100 |
- (void) bar { |
| 101 |
} |
| 102 |
@end |
| 103 |
// CHECK: ObjCCategoryImplDecl{{.*}} TestObjCCategoryDecl |
| 104 |
// CHECK-NEXT: ObjCInterface{{.*}} 'TestObjCClass' |
| 105 |
// CHECK-NEXT: ObjCCategory{{.*}} 'TestObjCCategoryDecl' |
| 106 |
// CHECK-NEXT: ObjCMethodDecl{{.*}} bar |
| 107 |
|
| 108 |
@compatibility_alias TestObjCCompatibleAliasDecl A; |
| 109 |
// CHECK: ObjCCompatibleAliasDecl{{.*}} TestObjCCompatibleAliasDecl |
| 110 |
// CHECK-NEXT: ObjCInterface{{.*}} 'A' |
| 111 |
|
| 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 |
| 127 |
|
| 128 |
@implementation TestObjCProperty { |
| 129 |
int i; |
| 130 |
} |
| 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' |
| 142 |
|
| 143 |
void TestBlockDecl(int x) { |
| 144 |
^(int y, ...){ x; }; |
| 145 |
int z; |
| 146 |
} |
| 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 |
| 156 |
|
| 157 |
@interface B |
| 158 |
+ (int) foo; |
| 159 |
@end |
| 160 |
|
| 161 |
void f(void) { |
| 162 |
__typeof__(B.foo) Test; |
| 163 |
} |
| 164 |
// CHECK: VarDecl{{.*}}Test 'typeof (B.foo)':'int' |