xref: /minix3/external/bsd/llvm/dist/clang/test/Index/comment-objc-decls.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: rm -rf %t
2*f4a2713aSLionel Sambuc// RUN: mkdir %t
3*f4a2713aSLionel Sambuc// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 %s > %t/out
4*f4a2713aSLionel Sambuc// RUN: FileCheck %s < %t/out
5*f4a2713aSLionel Sambuc
6*f4a2713aSLionel Sambuc// Ensure that XML we generate is not invalid.
7*f4a2713aSLionel Sambuc// RUN: FileCheck %s -check-prefix=WRONG < %t/out
8*f4a2713aSLionel Sambuc// WRONG-NOT: CommentXMLInvalid
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambuc// rdar://12378714
11*f4a2713aSLionel Sambuc
12*f4a2713aSLionel Sambuc/**
13*f4a2713aSLionel Sambuc * \brief This is a protocol definition
14*f4a2713aSLionel Sambuc*/
15*f4a2713aSLionel Sambuc@protocol MyProto
16*f4a2713aSLionel Sambuc@optional
17*f4a2713aSLionel Sambuc/**
18*f4a2713aSLionel Sambuc * \brief MethodMyProto method
19*f4a2713aSLionel Sambuc * \param[in] anObject input value
20*f4a2713aSLionel Sambuc * \param[in] range output value is unsigned int
21*f4a2713aSLionel Sambuc * \result return index
22*f4a2713aSLionel Sambuc */
23*f4a2713aSLionel Sambuc- (unsigned int)MethodMyProto:(id)anObject inRange:(unsigned int)range;
24*f4a2713aSLionel Sambuc/**
25*f4a2713aSLionel Sambuc * \brief PropertyMyProto - This is protocol's property.
26*f4a2713aSLionel Sambuc*/
27*f4a2713aSLionel Sambuc@property (copy) id PropertyMyProto;
28*f4a2713aSLionel Sambuc/**
29*f4a2713aSLionel Sambuc * \brief ClassMethodMyProto
30*f4a2713aSLionel Sambuc*/
31*f4a2713aSLionel Sambuc+ ClassMethodMyProto;
32*f4a2713aSLionel Sambuc@end
33*f4a2713aSLionel Sambuc// CHECK: <Declaration>@protocol MyProto\n@end</Declaration>
34*f4a2713aSLionel Sambuc// CHECK: <Declaration>- (unsigned int)MethodMyProto:(id)anObject inRange:(unsigned int)range;</Declaration>
35*f4a2713aSLionel Sambuc// CHECK: <Declaration>@optional\n@property(readwrite, copy, atomic) id PropertyMyProto;</Declaration>
36*f4a2713aSLionel Sambuc// CHECK: <Declaration>+ (id)ClassMethodMyProto;</Declaration>
37*f4a2713aSLionel Sambuc
38*f4a2713aSLionel Sambuc/**
39*f4a2713aSLionel Sambuc * \brief NSObject is the root class.
40*f4a2713aSLionel Sambuc*/
41*f4a2713aSLionel Sambuc@interface NSObject {
42*f4a2713aSLionel Sambuc/**
43*f4a2713aSLionel Sambuc * \brief IvarNSObject
44*f4a2713aSLionel Sambuc*/
45*f4a2713aSLionel Sambuc  id IvarNSObject;
46*f4a2713aSLionel Sambuc}
47*f4a2713aSLionel Sambuc@end
48*f4a2713aSLionel Sambuc// CHECK: Declaration>@interface NSObject {\n  id IvarNSObject;\n}\n@end</Declaration>
49*f4a2713aSLionel Sambuc// CHECK: <Declaration>id IvarNSObject</Declaration>
50*f4a2713aSLionel Sambuc
51*f4a2713aSLionel Sambuc/**
52*f4a2713aSLionel Sambuc * \brief MyClass - primary class.
53*f4a2713aSLionel Sambuc*/
54*f4a2713aSLionel Sambuc@interface MyClass : NSObject<MyProto>
55*f4a2713aSLionel Sambuc{
56*f4a2713aSLionel Sambuc/**
57*f4a2713aSLionel Sambuc * \brief IvarMyClass - IvarMyClass of values.
58*f4a2713aSLionel Sambuc*/
59*f4a2713aSLionel Sambuc  id IvarMyClass;
60*f4a2713aSLionel Sambuc}
61*f4a2713aSLionel Sambuc/**
62*f4a2713aSLionel Sambuc * \brief MethodMyClass is instance method.
63*f4a2713aSLionel Sambuc*/
64*f4a2713aSLionel Sambuc- MethodMyClass;
65*f4a2713aSLionel Sambuc
66*f4a2713aSLionel Sambuc/**
67*f4a2713aSLionel Sambuc * \brief ClassMethodMyClass is class method.
68*f4a2713aSLionel Sambuc*/
69*f4a2713aSLionel Sambuc+ ClassMethodMyClass;
70*f4a2713aSLionel Sambuc
71*f4a2713aSLionel Sambuc/**
72*f4a2713aSLionel Sambuc * \brief PropertyMyClass - This is class's property.
73*f4a2713aSLionel Sambuc*/
74*f4a2713aSLionel Sambuc@property (copy) id PropertyMyClass;
75*f4a2713aSLionel Sambuc@end
76*f4a2713aSLionel Sambuc// CHECK: <Declaration>@interface MyClass : NSObject &lt;MyProto&gt; {\n    id IvarMyClass;\n}\n@end</Declaration>
77*f4a2713aSLionel Sambuc// CHECK: <Declaration>id IvarMyClass</Declaration>
78*f4a2713aSLionel Sambuc// CHECK: <Declaration>- (id)MethodMyClass;</Declaration>
79*f4a2713aSLionel Sambuc// CHECK: <Declaration>+ (id)ClassMethodMyClass;</Declaration>
80*f4a2713aSLionel Sambuc// CHECK: <Declaration>@property(readwrite, copy, atomic) id PropertyMyClass;</Declaration
81*f4a2713aSLionel Sambuc
82*f4a2713aSLionel Sambuc/**
83*f4a2713aSLionel Sambuc * \brief - This is class extension of MyClass
84*f4a2713aSLionel Sambuc*/
85*f4a2713aSLionel Sambuc@interface MyClass()
86*f4a2713aSLionel Sambuc{
87*f4a2713aSLionel Sambuc/**
88*f4a2713aSLionel Sambuc * \brief IvarMyClassExtension - IvarMyClassExtension private to class extension
89*f4a2713aSLionel Sambuc*/
90*f4a2713aSLionel Sambuc  id IvarMyClassExtension;
91*f4a2713aSLionel Sambuc}
92*f4a2713aSLionel Sambuc@end
93*f4a2713aSLionel Sambuc// CHECK: <Declaration>@interface MyClass () {\n  id IvarMyClassExtension;\n}\n@end</Declaration>
94*f4a2713aSLionel Sambuc// CHECK: <Declaration>id IvarMyClassExtension</Declaration>
95*f4a2713aSLionel Sambuc
96*f4a2713aSLionel Sambuc
97*f4a2713aSLionel Sambuc/**
98*f4a2713aSLionel Sambuc * \brief MyClass (Category) is private to MyClass.
99*f4a2713aSLionel Sambuc*/
100*f4a2713aSLionel Sambuc@interface MyClass (Category)
101*f4a2713aSLionel Sambuc/**
102*f4a2713aSLionel Sambuc * \brief This is private to MyClass
103*f4a2713aSLionel Sambuc */
104*f4a2713aSLionel Sambuc- (void)MethodMyClassCategory;
105*f4a2713aSLionel Sambuc
106*f4a2713aSLionel Sambuc/**
107*f4a2713aSLionel Sambuc * \brief PropertyMyClassCategory - This is class's private property.
108*f4a2713aSLionel Sambuc*/
109*f4a2713aSLionel Sambuc@property (copy) id PropertyMyClassCategory;
110*f4a2713aSLionel Sambuc@end
111*f4a2713aSLionel Sambuc// CHECK: <Declaration>@interface MyClass (Category)\n@end</Declaration>
112*f4a2713aSLionel Sambuc// CHECK: <Declaration>- (void)MethodMyClassCategory;</Declaration>
113*f4a2713aSLionel Sambuc// CHECK: <Declaration>@property(readwrite, copy, atomic) id PropertyMyClassCategory;</Declaration>
114*f4a2713aSLionel Sambuc// CHECK: <Declaration>- (id)PropertyMyClassCategory;</Declaration>
115*f4a2713aSLionel Sambuc// CHECK: <Declaration>- (void)setPropertyMyClassCategory:(id)arg;</Declaration>
116*f4a2713aSLionel Sambuc
117*f4a2713aSLionel Sambuc/// @implementation's
118*f4a2713aSLionel Sambuc
119*f4a2713aSLionel Sambuc/**
120*f4a2713aSLionel Sambuc * \brief implementation of MyClass class.
121*f4a2713aSLionel Sambuc*/
122*f4a2713aSLionel Sambuc@implementation MyClass {
123*f4a2713aSLionel Sambuc/**
124*f4a2713aSLionel Sambuc * \brief IvarPrivateToMyClassImpl.
125*f4a2713aSLionel Sambuc*/
126*f4a2713aSLionel Sambuc  id IvarPrivateToMyClassImpl;
127*f4a2713aSLionel Sambuc}
128*f4a2713aSLionel Sambuc/**
129*f4a2713aSLionel Sambuc * \brief MethodMyClass is instance method implementation.
130*f4a2713aSLionel Sambuc*/
131*f4a2713aSLionel Sambuc- MethodMyClass {
132*f4a2713aSLionel Sambuc  return 0;
133*f4a2713aSLionel Sambuc}
134*f4a2713aSLionel Sambuc
135*f4a2713aSLionel Sambuc/**
136*f4a2713aSLionel Sambuc * \brief ClassMethodMyClass is class method implementation.
137*f4a2713aSLionel Sambuc*/
138*f4a2713aSLionel Sambuc+ ClassMethodMyClass {
139*f4a2713aSLionel Sambuc  return 0;
140*f4a2713aSLionel Sambuc}
141*f4a2713aSLionel Sambuc@end
142*f4a2713aSLionel Sambuc// CHECK: <Declaration>@implementation MyClass {\n  id IvarPrivateToMyClassImpl;\n  id _PropertyMyClass;\n}\n@end</Declaration>
143*f4a2713aSLionel Sambuc// CHECK: <Declaration>id IvarPrivateToMyClassImpl</Declaration>
144*f4a2713aSLionel Sambuc// CHECK: <Declaration>- (id)MethodMyClass;</Declaration>
145*f4a2713aSLionel Sambuc// CHECK: <Declaration>+ (id)ClassMethodMyClass;</Declaration>
146*f4a2713aSLionel Sambuc
147*f4a2713aSLionel Sambuc/**
148*f4a2713aSLionel Sambuc * \brief MyClass (Category) is implementation of private to MyClass.
149*f4a2713aSLionel Sambuc*/
150*f4a2713aSLionel Sambuc@implementation MyClass (Category)
151*f4a2713aSLionel Sambuc/**
152*f4a2713aSLionel Sambuc * \brief This is private to MyClass
153*f4a2713aSLionel Sambuc */
154*f4a2713aSLionel Sambuc- (void)MethodMyClassCategory {}
155*f4a2713aSLionel Sambuc/**
156*f4a2713aSLionel Sambuc * \brief property getter
157*f4a2713aSLionel Sambuc*/
158*f4a2713aSLionel Sambuc- (id) PropertyMyClassCategory { return 0; }
159*f4a2713aSLionel Sambuc
160*f4a2713aSLionel Sambuc/**
161*f4a2713aSLionel Sambuc * \brief property setter
162*f4a2713aSLionel Sambuc*/
163*f4a2713aSLionel Sambuc- (void) setPropertyMyClassCategory : (id) arg {}
164*f4a2713aSLionel Sambuc@end
165*f4a2713aSLionel Sambuc// CHECK: <Declaration>@implementation MyClass (Category)\n@end</Declaration>
166*f4a2713aSLionel Sambuc// CHECK: <Declaration>- (void)MethodMyClassCategory;</Declaration>
167*f4a2713aSLionel Sambuc// CHECK: <Declaration>- (id)PropertyMyClassCategory;</Declaration>
168*f4a2713aSLionel Sambuc// CHECK: <Declaration>- (void)setPropertyMyClassCategory:(id)arg;</Declaration>
169*f4a2713aSLionel Sambuc
170*f4a2713aSLionel Sambuc/**
171*f4a2713aSLionel Sambuc * \brief NSObject implementation
172*f4a2713aSLionel Sambuc*/
173*f4a2713aSLionel Sambuc@implementation NSObject
174*f4a2713aSLionel Sambuc@end
175*f4a2713aSLionel Sambuc// CHECK: <Declaration>@implementation NSObject\n@end</Declaration>
176