Home | History | Annotate | Download | only in Misc
      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{{.*}} 'TestObjCClass'
     81 // CHECK-NEXT:   ObjCProtocol{{.*}} 'P'
     82 // CHECK-NEXT:   ObjCMethodDecl{{.*}} bar
     83 
     84 @implementation TestObjCClass (TestObjCCategoryDecl)
     85 - (void) bar {
     86 }
     87 @end
     88 // CHECK:      ObjCCategoryImplDecl{{.*}} TestObjCClass
     89 // CHECK-NEXT:   ObjCInterface{{.*}} 'TestObjCClass'
     90 // CHECK-NEXT:   ObjCCategory{{.*}} 'TestObjCCategoryDecl'
     91 // CHECK-NEXT:   ObjCMethodDecl{{.*}} bar
     92 
     93 @compatibility_alias TestObjCCompatibleAliasDecl A;
     94 // CHECK:      ObjCCompatibleAliasDecl{{.*}} TestObjCCompatibleAliasDecl
     95 // CHECK-NEXT:   ObjCInterface{{.*}} 'A'
     96 
     97 @interface TestObjCProperty: A
     98 @property(getter=getterFoo, setter=setterFoo:) int foo;
     99 @property int bar;
    100 @end
    101 // CHECK:      ObjCInterfaceDecl{{.*}} TestObjCProperty
    102 // CHECK:        ObjCPropertyDecl{{.*}} foo 'int' assign readwrite atomic unsafe_unretained
    103 // CHECK-NEXT:     getter ObjCMethod{{.*}} 'getterFoo'
    104 // CHECK-NEXT:     setter ObjCMethod{{.*}} 'setterFoo:'
    105 // CHECK-NEXT:   ObjCPropertyDecl{{.*}} bar 'int' assign readwrite atomic unsafe_unretained
    106 // CHECK-NEXT:   ObjCMethodDecl{{.*}} getterFoo
    107 // CHECK-NEXT:   ObjCMethodDecl{{.*}} setterFoo:
    108 // CHECK-NEXT:     ParmVarDecl{{.*}} foo
    109 // CHECK-NEXT:   ObjCMethodDecl{{.*}} bar
    110 // CHECK-NEXT:   ObjCMethodDecl{{.*}} setBar:
    111 // CHECK-NEXT:     ParmVarDecl{{.*}} bar
    112 
    113 @implementation TestObjCProperty {
    114   int i;
    115 }
    116 @synthesize foo=i;
    117 @synthesize bar;
    118 @end
    119 // CHECK:      ObjCImplementationDecl{{.*}} TestObjCProperty
    120 // CHECK:        ObjCPropertyImplDecl{{.*}} foo synthesize
    121 // CHECK-NEXT:     ObjCProperty{{.*}} 'foo'
    122 // CHECK-NEXT:     ObjCIvar{{.*}} 'i' 'int'
    123 // CHECK-NEXT:   ObjCIvarDecl{{.*}} bar 'int' synthesize private
    124 // CHECK-NEXT:   ObjCPropertyImplDecl{{.*}} bar synthesize
    125 // CHECK-NEXT:     ObjCProperty{{.*}} 'bar'
    126 // CHECK-NEXT:     ObjCIvar{{.*}} 'bar' 'int'
    127 
    128 void TestBlockDecl(int x) {
    129   ^(int y, ...){ x; };
    130 }
    131 // CHECK:      FunctionDecl{{.*}}TestBlockDecl
    132 // CHECK:      BlockDecl
    133 // CHECK-NEXT:   ParmVarDecl{{.*}} y 'int'
    134 // CHECK-NEXT:   ...
    135 // CHECK-NEXT:   capture ParmVar{{.*}} 'x' 'int'
    136 // CHECK-NEXT:   CompoundStmt
    137 
    138 @interface B
    139 + (int) foo;
    140 @end
    141 
    142 void f() {
    143   __typeof__(B.foo) Test;
    144 }
    145 // CHECK: VarDecl{{.*}}Test 'typeof (B.foo)':'int'
    146