blob: 87830a7af1d18508f56492a01a91fdc76bb2b657 [file] [log] [blame]
Ted Kremenek23173d72010-05-18 21:09:07 +00001// Test that @properties within class extensions are visited by
2// clang_visitChildren only in the class extension, not the original
3// @interface (where we have a duplicate declaration - to be removed).
4@interface Foo {} @end
5@interface Foo (Cat)
Ted Kremenek8254aa62010-09-21 18:28:43 +00006@property int a;
Ted Kremenek23173d72010-05-18 21:09:07 +00007@end
8@interface Foo ()
Ted Kremenek8254aa62010-09-21 18:28:43 +00009@property int b;
10- (void) bar;
11@end
12
13// Test that 'setter' methods defined by @property in the class extension
14// but not the in @interface are only presented in the class extension.
15@interface Bar
16@property (readonly) id bar;
17@end
18@interface Bar ()
19@property (readwrite) id bar;
Ted Kremenek23173d72010-05-18 21:09:07 +000020@end
21
Ted Kremenek4a2e9ea2010-09-23 21:18:05 +000022// Another test, this one involving protocols, where the @property should
23// not appear in the @interface.
24@class Rdar8467189_Bar;
25@protocol Rdar8467189_FooProtocol
26@property (readonly) Rdar8467189_Bar *Rdar8467189_Bar;
27@end
28@interface Rdar8467189_Foo <Rdar8467189_FooProtocol>
29@end
30@interface Rdar8467189_Foo ()
31@property (readwrite) Rdar8467189_Bar *Rdar8467189_Bar;
32@end
33
Ted Kremenek0d22d222010-09-23 21:25:13 +000034// Test if the @property added in an extension is not reported in the @interface.
35@interface Qux
36@end
37@interface Qux ()
38@property (assign, readwrite) id qux;
39@end
40
Douglas Gregore3c60a72010-11-17 00:13:31 +000041@implementation Qux
42@dynamic qux;
43@end
44
Ted Kremenek23173d72010-05-18 21:09:07 +000045// RUN: c-index-test -test-load-source local %s | FileCheck %s
46// CHECK: properties-class-extensions.m:4:12: ObjCInterfaceDecl=Foo:4:12 Extent=[4:1 - 4:23]
Ted Kremenek4a2e9ea2010-09-23 21:18:05 +000047// CHECK-NOT: properties-class-extensions.m:9:15: ObjCInstanceMethodDecl=setB::9:15 Extent=[9:15 - 9:16]
48// CHECK-NOT: properties-class-extensions.m:9:15: ParmDecl=b:9:15 (Definition) Extent=[9:15 - 9:16]
Ted Kremenek23173d72010-05-18 21:09:07 +000049// CHECK: properties-class-extensions.m:5:12: ObjCCategoryDecl=Cat:5:12 Extent=[5:1 - 7:5]
50// CHECK: properties-class-extensions.m:5:12: ObjCClassRef=Foo:4:12 Extent=[5:12 - 5:15]
Douglas Gregore3c60a72010-11-17 00:13:31 +000051// CHECK: properties-class-extensions.m:6:15: ObjCPropertyDecl=a:6:15 Extent=[6:1 - 6:16]
Argyrios Kyrtzidis65ab9072011-09-26 19:05:37 +000052// CHECK: properties-class-extensions.m:6:15: ObjCInstanceMethodDecl=a:6:15 Extent=[6:15 - 6:16]
53// CHECK: properties-class-extensions.m:6:15: ObjCInstanceMethodDecl=setA::6:15 Extent=[6:15 - 6:16]
54// CHECK: properties-class-extensions.m:6:15: ParmDecl=a:6:15 (Definition) Extent=[6:15 - 6:16]
Ted Kremenek23173d72010-05-18 21:09:07 +000055// CHECK: properties-class-extensions.m:8:12: ObjCCategoryDecl=:8:12 Extent=[8:1 - 11:5]
56// CHECK: properties-class-extensions.m:8:12: ObjCClassRef=Foo:4:12 Extent=[8:12 - 8:15]
Douglas Gregore3c60a72010-11-17 00:13:31 +000057// CHECK: properties-class-extensions.m:9:15: ObjCPropertyDecl=b:9:15 Extent=[9:1 - 9:16]
Argyrios Kyrtzidis65ab9072011-09-26 19:05:37 +000058// CHECK: properties-class-extensions.m:9:15: ObjCInstanceMethodDecl=b:9:15 Extent=[9:15 - 9:16]
59// CHECK: properties-class-extensions.m:9:15: ObjCInstanceMethodDecl=setB::9:15 Extent=[9:15 - 9:16]
60// CHECK: properties-class-extensions.m:9:15: ParmDecl=b:9:15 (Definition) Extent=[9:15 - 9:16]
Ted Kremenek8254aa62010-09-21 18:28:43 +000061// CHECK: properties-class-extensions.m:10:1: ObjCInstanceMethodDecl=bar:10:1 Extent=[10:1 - 10:14]
62// CHECK: properties-class-extensions.m:15:12: ObjCInterfaceDecl=Bar:15:12 Extent=[15:1 - 17:5]
Douglas Gregore3c60a72010-11-17 00:13:31 +000063// CHECK: properties-class-extensions.m:16:25: ObjCPropertyDecl=bar:16:25 Extent=[16:1 - 16:28]
Ted Kremenek8254aa62010-09-21 18:28:43 +000064// CHECK: properties-class-extensions.m:16:22: TypeRef=id:0:0 Extent=[16:22 - 16:24]
Argyrios Kyrtzidis65ab9072011-09-26 19:05:37 +000065// CHECK: properties-class-extensions.m:16:25: ObjCInstanceMethodDecl=bar:16:25 Extent=[16:25 - 16:28]
Ted Kremenek8254aa62010-09-21 18:28:43 +000066// CHECK: properties-class-extensions.m:18:12: ObjCCategoryDecl=:18:12 Extent=[18:1 - 20:5]
67// CHECK: properties-class-extensions.m:18:12: ObjCClassRef=Bar:15:12 Extent=[18:12 - 18:15]
Douglas Gregore3c60a72010-11-17 00:13:31 +000068// CHECK: properties-class-extensions.m:19:26: ObjCPropertyDecl=bar:19:26 Extent=[19:1 - 19:29]
Ted Kremenek8254aa62010-09-21 18:28:43 +000069// CHECK: properties-class-extensions.m:19:23: TypeRef=id:0:0 Extent=[19:23 - 19:25]
Ted Kremenek4a2e9ea2010-09-23 21:18:05 +000070// CHECK-NOT: properties-class-extensions.m:16:25: ObjCInstanceMethodDecl=bar:16:25 Extent=[16:25 - 16:28]
Argyrios Kyrtzidis65ab9072011-09-26 19:05:37 +000071// CHECK: properties-class-extensions.m:19:26: ObjCInstanceMethodDecl=setBar::19:26 Extent=[19:26 - 19:29]
72// CHECK: properties-class-extensions.m:19:26: ParmDecl=bar:19:26 (Definition) Extent=[19:26 - 19:29]
Argyrios Kyrtzidisc15707d2012-01-24 21:39:26 +000073// CHECK: properties-class-extensions.m:24:8: ObjCInterfaceDecl=Rdar8467189_Bar:24:8 Extent=[24:1 - 24:23]
Ted Kremenek4a2e9ea2010-09-23 21:18:05 +000074// CHECK: properties-class-extensions.m:24:8: ObjCClassRef=Rdar8467189_Bar:24:8 Extent=[24:8 - 24:23]
Argyrios Kyrtzidis1711fc92011-10-04 04:48:02 +000075// CHECK: properties-class-extensions.m:25:11: ObjCProtocolDecl=Rdar8467189_FooProtocol:25:11 (Definition) Extent=[25:1 - 27:5]
Douglas Gregore3c60a72010-11-17 00:13:31 +000076// CHECK: properties-class-extensions.m:26:39: ObjCPropertyDecl=Rdar8467189_Bar:26:39 Extent=[26:1 - 26:54]
Ted Kremenek4a2e9ea2010-09-23 21:18:05 +000077// CHECK: properties-class-extensions.m:26:22: ObjCClassRef=Rdar8467189_Bar:24:8 Extent=[26:22 - 26:37]
Argyrios Kyrtzidis65ab9072011-09-26 19:05:37 +000078// CHECK: properties-class-extensions.m:26:39: ObjCInstanceMethodDecl=Rdar8467189_Bar:26:39 Extent=[26:39 - 26:54]
Ted Kremenek4a2e9ea2010-09-23 21:18:05 +000079// CHECK: properties-class-extensions.m:28:12: ObjCInterfaceDecl=Rdar8467189_Foo:28:12 Extent=[28:1 - 29:5]
Argyrios Kyrtzidis1711fc92011-10-04 04:48:02 +000080// CHECK: properties-class-extensions.m:28:29: ObjCProtocolRef=Rdar8467189_FooProtocol:25:11 Extent=[28:29 - 28:52]
Ted Kremenek4a2e9ea2010-09-23 21:18:05 +000081// CHECK-NOT: properties-class-extensions.m:31:40: ObjCPropertyDecl=Rdar8467189_Bar:31:40 Extent=[31:40 - 31:55]
82// CHECK-NOT: properties-class-extensions.m:31:23: ObjCClassRef=Rdar8467189_Bar:24:8 Extent=[31:23 - 31:38]
83// CHECK: properties-class-extensions.m:30:12: ObjCCategoryDecl=:30:12 Extent=[30:1 - 32:5]
84// CHECK: properties-class-extensions.m:30:12: ObjCClassRef=Rdar8467189_Foo:28:12 Extent=[30:12 - 30:27]
Douglas Gregore3c60a72010-11-17 00:13:31 +000085// CHECK: properties-class-extensions.m:31:40: ObjCPropertyDecl=Rdar8467189_Bar:31:40 Extent=[31:1 - 31:55]
Ted Kremenek4a2e9ea2010-09-23 21:18:05 +000086// CHECK: properties-class-extensions.m:31:23: ObjCClassRef=Rdar8467189_Bar:24:8 Extent=[31:23 - 31:38]
Argyrios Kyrtzidis65ab9072011-09-26 19:05:37 +000087// CHECK: properties-class-extensions.m:31:40: ObjCInstanceMethodDecl=Rdar8467189_Bar:31:40 [Overrides @26:39] Extent=[31:40 - 31:55]
88// CHECK: properties-class-extensions.m:31:40: ObjCInstanceMethodDecl=setRdar8467189_Bar::31:40 Extent=[31:40 - 31:55]
89// CHECK: properties-class-extensions.m:31:40: ParmDecl=Rdar8467189_Bar:31:40 (Definition) Extent=[31:40 - 31:55]
Ted Kremenek0d22d222010-09-23 21:25:13 +000090// CHECK: properties-class-extensions.m:35:12: ObjCInterfaceDecl=Qux:35:12 Extent=[35:1 - 36:5]
91// CHECK: properties-class-extensions.m:37:12: ObjCCategoryDecl=:37:12 Extent=[37:1 - 39:5]
92// CHECK: properties-class-extensions.m:37:12: ObjCClassRef=Qux:35:12 Extent=[37:12 - 37:15]
Douglas Gregore3c60a72010-11-17 00:13:31 +000093// CHECK: properties-class-extensions.m:38:34: ObjCPropertyDecl=qux:38:34 Extent=[38:1 - 38:37]
Ted Kremenek0d22d222010-09-23 21:25:13 +000094// CHECK: properties-class-extensions.m:38:31: TypeRef=id:0:0 Extent=[38:31 - 38:33]
Argyrios Kyrtzidis65ab9072011-09-26 19:05:37 +000095// CHECK: properties-class-extensions.m:38:34: ObjCInstanceMethodDecl=qux:38:34 Extent=[38:34 - 38:37]
96// CHECK: properties-class-extensions.m:38:34: ObjCInstanceMethodDecl=setQux::38:34 Extent=[38:34 - 38:37]
97// CHECK: properties-class-extensions.m:38:34: ParmDecl=qux:38:34 (Definition) Extent=[38:34 - 38:37]
Douglas Gregor352697a2011-06-03 23:08:58 +000098// CHECK: properties-class-extensions.m:42:10: ObjCDynamicDecl=qux:38:34 (Definition) Extent=[42:1 - 42:13]
Ted Kremenek23173d72010-05-18 21:09:07 +000099