Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fblocks -emit-pch -x objective-c %s -o %t.ast |
Ted Kremenek | f5d9c93 | 2009-11-17 18:09:14 +0000 | [diff] [blame] | 2 | // RUN: c-index-test -test-load-tu %t.ast all | FileCheck %s |
Douglas Gregor | 1adb082 | 2010-01-16 17:14:40 +0000 | [diff] [blame] | 3 | |
Steve Naroff | ff9e18c | 2009-09-24 20:03:06 +0000 | [diff] [blame] | 4 | @interface Foo |
| 5 | { |
Ted Kremenek | 09dfa37 | 2010-02-18 05:46:33 +0000 | [diff] [blame] | 6 | __attribute__((iboutlet)) id myoutlet; |
Steve Naroff | ff9e18c | 2009-09-24 20:03:06 +0000 | [diff] [blame] | 7 | } |
Ted Kremenek | 9e04935 | 2010-02-18 23:05:16 +0000 | [diff] [blame] | 8 | - (void) __attribute__((ibaction)) myMessage:(id)msg; |
Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 9 | - foo __attribute__((deprecated)); |
Steve Naroff | ff9e18c | 2009-09-24 20:03:06 +0000 | [diff] [blame] | 10 | + fooC; |
| 11 | |
| 12 | @end |
| 13 | |
| 14 | @interface Bar : Foo |
| 15 | { |
| 16 | } |
| 17 | |
| 18 | @end |
| 19 | |
| 20 | @interface Foo (FooCat) |
| 21 | - (int) catMethodWithFloat:(float) fArg; |
| 22 | - (float) floatMethod; |
| 23 | @end |
| 24 | |
| 25 | @protocol Proto |
| 26 | - pMethod; |
| 27 | @end |
| 28 | |
| 29 | @protocol SubP <Proto> |
| 30 | - spMethod; |
Douglas Gregor | 6309737 | 2010-10-05 14:55:45 +0000 | [diff] [blame^] | 31 | @endxb |
Steve Naroff | ff9e18c | 2009-09-24 20:03:06 +0000 | [diff] [blame] | 32 | |
| 33 | @interface Baz : Bar <SubP> |
| 34 | { |
| 35 | int _anIVar; |
| 36 | } |
| 37 | |
| 38 | - (Foo *) bazMethod; |
| 39 | |
| 40 | @end |
| 41 | |
| 42 | enum { |
| 43 | someEnum |
| 44 | }; |
| 45 | |
Steve Naroff | ff9e18c | 2009-09-24 20:03:06 +0000 | [diff] [blame] | 46 | int main (int argc, const char * argv[]) { |
| 47 | Baz * bee; |
| 48 | id a = [bee foo]; |
| 49 | id <SubP> c = [Foo fooC]; |
| 50 | id <Proto> d; |
| 51 | d = c; |
| 52 | [d pMethod]; |
| 53 | [bee catMethodWithFloat:[bee floatMethod]]; |
| 54 | main(someEnum, (const char **)bee); |
| 55 | } |
| 56 | |
Ted Kremenek | 857e918 | 2010-05-19 17:38:06 +0000 | [diff] [blame] | 57 | // Test attribute traversal. |
| 58 | #define IBOutlet __attribute__((iboutlet)) |
Ted Kremenek | 95f3355 | 2010-08-26 01:42:22 +0000 | [diff] [blame] | 59 | #define IBOutletCollection(ClassName) __attribute__((iboutletcollection(ClassName))) |
Ted Kremenek | 857e918 | 2010-05-19 17:38:06 +0000 | [diff] [blame] | 60 | #define IBAction void)__attribute__((ibaction) |
| 61 | |
| 62 | @interface TestAttributes { |
| 63 | IBOutlet char * anOutlet; |
| 64 | IBOutletCollection(id) id anOutletCollection; |
| 65 | } |
| 66 | - (IBAction) actionMethod:(id)arg; |
| 67 | @end |
| 68 | |
Douglas Gregor | 773eb03 | 2010-07-14 04:45:33 +0000 | [diff] [blame] | 69 | typedef struct X0 X1; |
| 70 | struct X0; |
| 71 | struct X0 {}; |
| 72 | |
Ted Kremenek | 09dfa37 | 2010-02-18 05:46:33 +0000 | [diff] [blame] | 73 | // CHECK: c-index-api-loadTU-test.m:4:12: ObjCInterfaceDecl=Foo:4:12 Extent=[4:1 - 12:5] |
Ted Kremenek | 09dfa37 | 2010-02-18 05:46:33 +0000 | [diff] [blame] | 74 | // CHECK: c-index-api-loadTU-test.m:6:32: ObjCIvarDecl=myoutlet:6:32 (Definition) Extent=[6:32 - 6:40] |
Ted Kremenek | 9a700d2 | 2010-05-12 06:16:13 +0000 | [diff] [blame] | 75 | // CHECK: <invalid loc>:0:0: attribute(iboutlet)= |
Ted Kremenek | 09dfa37 | 2010-02-18 05:46:33 +0000 | [diff] [blame] | 76 | // CHECK: c-index-api-loadTU-test.m:6:29: TypeRef=id:0:0 Extent=[6:29 - 6:31] |
Ted Kremenek | 9e04935 | 2010-02-18 23:05:16 +0000 | [diff] [blame] | 77 | // CHECK: c-index-api-loadTU-test.m:8:1: ObjCInstanceMethodDecl=myMessage::8:1 Extent=[8:1 - 8:54] |
Ted Kremenek | 9a700d2 | 2010-05-12 06:16:13 +0000 | [diff] [blame] | 78 | // CHECK: <invalid loc>:0:0: attribute(ibaction)= |
Ted Kremenek | 9e04935 | 2010-02-18 23:05:16 +0000 | [diff] [blame] | 79 | // CHECK: c-index-api-loadTU-test.m:8:50: ParmDecl=msg:8:50 (Definition) Extent=[8:47 - 8:53] |
| 80 | // CHECK: c-index-api-loadTU-test.m:8:47: TypeRef=id:0:0 Extent=[8:47 - 8:49] |
Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 81 | // CHECK: c-index-api-loadTU-test.m:9:1: ObjCInstanceMethodDecl=foo:9:1 (deprecated) Extent=[9:1 - 9:35] |
Ted Kremenek | 09dfa37 | 2010-02-18 05:46:33 +0000 | [diff] [blame] | 82 | // CHECK: c-index-api-loadTU-test.m:10:1: ObjCClassMethodDecl=fooC:10:1 Extent=[10:1 - 10:8] |
| 83 | // CHECK: c-index-api-loadTU-test.m:14:12: ObjCInterfaceDecl=Bar:14:12 Extent=[14:1 - 18:5] |
| 84 | // CHECK: c-index-api-loadTU-test.m:14:18: ObjCSuperClassRef=Foo:4:12 Extent=[14:18 - 14:21] |
| 85 | // CHECK: c-index-api-loadTU-test.m:20:12: ObjCCategoryDecl=FooCat:20:12 Extent=[20:1 - 23:5] |
| 86 | // CHECK: c-index-api-loadTU-test.m:20:12: ObjCClassRef=Foo:4:12 Extent=[20:12 - 20:15] |
| 87 | // CHECK: c-index-api-loadTU-test.m:21:1: ObjCInstanceMethodDecl=catMethodWithFloat::21:1 Extent=[21:1 - 21:41] |
| 88 | // CHECK: c-index-api-loadTU-test.m:21:36: ParmDecl=fArg:21:36 (Definition) Extent=[21:29 - 21:40] |
| 89 | // CHECK: c-index-api-loadTU-test.m:22:1: ObjCInstanceMethodDecl=floatMethod:22:1 Extent=[22:1 - 22:23] |
| 90 | // CHECK: c-index-api-loadTU-test.m:25:1: ObjCProtocolDecl=Proto:25:1 (Definition) Extent=[25:1 - 27:5] |
| 91 | // CHECK: c-index-api-loadTU-test.m:26:1: ObjCInstanceMethodDecl=pMethod:26:1 Extent=[26:1 - 26:11] |
| 92 | // CHECK: c-index-api-loadTU-test.m:29:1: ObjCProtocolDecl=SubP:29:1 (Definition) Extent=[29:1 - 31:5] |
| 93 | // CHECK: c-index-api-loadTU-test.m:29:17: ObjCProtocolRef=Proto:25:1 Extent=[29:17 - 29:22] |
| 94 | // CHECK: c-index-api-loadTU-test.m:30:1: ObjCInstanceMethodDecl=spMethod:30:1 Extent=[30:1 - 30:12] |
| 95 | // CHECK: c-index-api-loadTU-test.m:33:12: ObjCInterfaceDecl=Baz:33:12 Extent=[33:1 - 40:5] |
| 96 | // CHECK: c-index-api-loadTU-test.m:33:18: ObjCSuperClassRef=Bar:14:12 Extent=[33:18 - 33:21] |
| 97 | // CHECK: c-index-api-loadTU-test.m:33:23: ObjCProtocolRef=SubP:29:1 Extent=[33:23 - 33:27] |
| 98 | // CHECK: c-index-api-loadTU-test.m:35:9: ObjCIvarDecl=_anIVar:35:9 (Definition) Extent=[35:9 - 35:16] |
| 99 | // CHECK: c-index-api-loadTU-test.m:38:1: ObjCInstanceMethodDecl=bazMethod:38:1 Extent=[38:1 - 38:21] |
Ted Kremenek | 9a700d2 | 2010-05-12 06:16:13 +0000 | [diff] [blame] | 100 | // CHECK: c-index-api-loadTU-test.m:38:4: ObjCClassRef=Foo:4:12 Extent=[38:4 - 38:7] |
Ted Kremenek | 09dfa37 | 2010-02-18 05:46:33 +0000 | [diff] [blame] | 101 | // CHECK: c-index-api-loadTU-test.m:42:1: EnumDecl=:42:1 (Definition) Extent=[42:1 - 44:2] |
| 102 | // CHECK: c-index-api-loadTU-test.m:43:3: EnumConstantDecl=someEnum:43:3 (Definition) Extent=[43:3 - 43:11] |
| 103 | // CHECK: c-index-api-loadTU-test.m:46:5: FunctionDecl=main:46:5 (Definition) Extent=[46:5 - 55:2] |
| 104 | // CHECK: c-index-api-loadTU-test.m:46:15: ParmDecl=argc:46:15 (Definition) Extent=[46:11 - 46:19] |
| 105 | // CHECK: c-index-api-loadTU-test.m:46:34: ParmDecl=argv:46:34 (Definition) Extent=[46:27 - 46:38] |
Ted Kremenek | 09dfa37 | 2010-02-18 05:46:33 +0000 | [diff] [blame] | 106 | // CHECK: c-index-api-loadTU-test.m:47:8: VarDecl=bee:47:8 (Definition) Extent=[47:2 - 47:11] |
| 107 | // CHECK: c-index-api-loadTU-test.m:47:2: ObjCClassRef=Baz:33:12 Extent=[47:2 - 47:5] |
Ted Kremenek | 09dfa37 | 2010-02-18 05:46:33 +0000 | [diff] [blame] | 108 | // CHECK: c-index-api-loadTU-test.m:48:5: VarDecl=a:48:5 (Definition) Extent=[48:2 - 48:18] |
Daniel Dunbar | 8f0bf81 | 2010-02-14 08:32:51 +0000 | [diff] [blame] | 109 | // CHECK: c-index-api-loadTU-test.m:48:2: TypeRef=id:0:0 Extent=[48:2 - 48:4] |
Ted Kremenek | 09dfa37 | 2010-02-18 05:46:33 +0000 | [diff] [blame] | 110 | // CHECK: c-index-api-loadTU-test.m:48:9: ObjCMessageExpr=foo:9:1 Extent=[48:9 - 48:18] |
| 111 | // CHECK: c-index-api-loadTU-test.m:48:10: DeclRefExpr=bee:47:8 Extent=[48:10 - 48:13] |
Ted Kremenek | 09dfa37 | 2010-02-18 05:46:33 +0000 | [diff] [blame] | 112 | // CHECK: c-index-api-loadTU-test.m:49:12: VarDecl=c:49:12 (Definition) Extent=[49:2 - 49:26] |
Daniel Dunbar | 8f0bf81 | 2010-02-14 08:32:51 +0000 | [diff] [blame] | 113 | // CHECK: c-index-api-loadTU-test.m:49:2: TypeRef=id:0:0 Extent=[49:2 - 49:4] |
Ted Kremenek | 09dfa37 | 2010-02-18 05:46:33 +0000 | [diff] [blame] | 114 | // CHECK: c-index-api-loadTU-test.m:49:6: ObjCProtocolRef=SubP:29:1 Extent=[49:6 - 49:10] |
| 115 | // CHECK: c-index-api-loadTU-test.m:49:16: UnexposedExpr=fooC:10:1 Extent=[49:16 - 49:26] |
| 116 | // CHECK: c-index-api-loadTU-test.m:49:16: ObjCMessageExpr=fooC:10:1 Extent=[49:16 - 49:26] |
Ted Kremenek | 9a700d2 | 2010-05-12 06:16:13 +0000 | [diff] [blame] | 117 | // CHECK: c-index-api-loadTU-test.m:49:17: ObjCClassRef=Foo:4:12 Extent=[49:17 - 49:20] |
Ted Kremenek | 09dfa37 | 2010-02-18 05:46:33 +0000 | [diff] [blame] | 118 | // CHECK: c-index-api-loadTU-test.m:50:13: VarDecl=d:50:13 (Definition) Extent=[50:2 - 50:14] |
| 119 | // CHECK: c-index-api-loadTU-test.m:50:2: TypeRef=id:0:0 Extent=[50:2 - 50:4] |
| 120 | // CHECK: c-index-api-loadTU-test.m:50:6: ObjCProtocolRef=Proto:25:1 Extent=[50:6 - 50:11] |
| 121 | // CHECK: c-index-api-loadTU-test.m:51:2: UnexposedExpr= Extent=[51:2 - 51:7] |
| 122 | // CHECK: c-index-api-loadTU-test.m:51:2: DeclRefExpr=d:50:13 Extent=[51:2 - 51:3] |
| 123 | // CHECK: c-index-api-loadTU-test.m:51:6: UnexposedExpr=c:49:12 Extent=[51:6 - 51:7] |
| 124 | // CHECK: c-index-api-loadTU-test.m:51:6: DeclRefExpr=c:49:12 Extent=[51:6 - 51:7] |
| 125 | // CHECK: c-index-api-loadTU-test.m:52:2: ObjCMessageExpr=pMethod:26:1 Extent=[52:2 - 52:13] |
| 126 | // CHECK: c-index-api-loadTU-test.m:52:3: DeclRefExpr=d:50:13 Extent=[52:3 - 52:4] |
| 127 | // CHECK: c-index-api-loadTU-test.m:53:2: ObjCMessageExpr=catMethodWithFloat::21:1 Extent=[53:2 - 53:44] |
| 128 | // CHECK: c-index-api-loadTU-test.m:53:3: DeclRefExpr=bee:47:8 Extent=[53:3 - 53:6] |
| 129 | // CHECK: c-index-api-loadTU-test.m:53:26: ObjCMessageExpr=floatMethod:22:1 Extent=[53:26 - 53:43] |
| 130 | // CHECK: c-index-api-loadTU-test.m:53:27: DeclRefExpr=bee:47:8 Extent=[53:27 - 53:30] |
| 131 | // CHECK: c-index-api-loadTU-test.m:54:3: CallExpr=main:46:5 Extent=[54:3 - 54:37] |
| 132 | // CHECK: c-index-api-loadTU-test.m:54:3: UnexposedExpr=main:46:5 Extent=[54:3 - 54:7] |
| 133 | // CHECK: c-index-api-loadTU-test.m:54:3: DeclRefExpr=main:46:5 Extent=[54:3 - 54:7] |
| 134 | // CHECK: c-index-api-loadTU-test.m:54:8: DeclRefExpr=someEnum:43:3 Extent=[54:8 - 54:16] |
| 135 | // CHECK: c-index-api-loadTU-test.m:54:18: UnexposedExpr=bee:47:8 Extent=[54:18 - 54:36] |
| 136 | // CHECK: c-index-api-loadTU-test.m:54:33: DeclRefExpr=bee:47:8 Extent=[54:33 - 54:36] |
Ted Kremenek | 857e918 | 2010-05-19 17:38:06 +0000 | [diff] [blame] | 137 | // CHECK: c-index-api-loadTU-test.m:62:12: ObjCInterfaceDecl=TestAttributes:62:12 Extent=[62:1 - 67:5] |
| 138 | // CHECK: c-index-api-loadTU-test.m:63:19: ObjCIvarDecl=anOutlet:63:19 (Definition) Extent=[63:19 - 63:27] |
| 139 | // CHECK: <invalid loc>:0:0: attribute(iboutlet)= |
| 140 | // CHECK: c-index-api-loadTU-test.m:64:29: ObjCIvarDecl=anOutletCollection:64:29 (Definition) Extent=[64:29 - 64:47] |
Ted Kremenek | 95f3355 | 2010-08-26 01:42:22 +0000 | [diff] [blame] | 141 | // CHECK: <invalid loc>:0:0: attribute(iboutletcollection)= [IBOutletCollection=ObjCObjectPointer] |
Ted Kremenek | 857e918 | 2010-05-19 17:38:06 +0000 | [diff] [blame] | 142 | // CHECK: c-index-api-loadTU-test.m:64:26: TypeRef=id:0:0 Extent=[64:26 - 64:28] |
| 143 | // CHECK: c-index-api-loadTU-test.m:66:1: ObjCInstanceMethodDecl=actionMethod::66:1 Extent=[66:1 - 66:35] |
| 144 | // CHECK: <invalid loc>:0:0: attribute(ibaction)= |
| 145 | // CHECK: c-index-api-loadTU-test.m:66:31: ParmDecl=arg:66:31 (Definition) Extent=[66:28 - 66:34] |
| 146 | // CHECK: c-index-api-loadTU-test.m:66:28: TypeRef=id:0:0 Extent=[66:28 - 66:30] |
Ted Kremenek | 95f3355 | 2010-08-26 01:42:22 +0000 | [diff] [blame] | 147 | // CHECK: c-index-api-loadTU-test.m:69:16: StructDecl=X0:69:16 Extent=[69:9 - 69:18] |
| 148 | // CHECK: c-index-api-loadTU-test.m:69:19: TypedefDecl=X1:69:19 (Definition) Extent=[69:19 - 69:21] |
| 149 | // CHECK: c-index-api-loadTU-test.m:69:16: TypeRef=struct X0:71:8 Extent=[69:16 - 69:18] |
| 150 | // CHECK: c-index-api-loadTU-test.m:70:8: StructDecl=X0:70:8 Extent=[70:1 - 70:10] |
| 151 | // CHECK: c-index-api-loadTU-test.m:71:8: StructDecl=X0:71:8 (Definition) Extent=[71:1 - 71:14] |
Ted Kremenek | 09dfa37 | 2010-02-18 05:46:33 +0000 | [diff] [blame] | 152 | |