blob: c33720f5633a915a9a3600027d5aaac45dec1fc9 [file] [log] [blame]
Chris Lattner1e03a562008-03-16 00:19:01 +00001//===--- DeclObjC.cpp - ObjC Declaration AST Node Implementation ----------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the Objective-C related Decl classes.
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/AST/DeclObjC.h"
15#include "clang/AST/ASTContext.h"
Daniel Dunbare91593e2008-08-11 04:54:23 +000016#include "clang/AST/Stmt.h"
Steve Naroff0de21fd2009-02-22 19:35:57 +000017#include "llvm/ADT/STLExtras.h"
Chris Lattner1e03a562008-03-16 00:19:01 +000018using namespace clang;
19
Chris Lattner6c4ae5d2008-03-16 00:49:28 +000020//===----------------------------------------------------------------------===//
Chris Lattner11e1e1a2009-02-20 21:16:26 +000021// ObjCListBase
22//===----------------------------------------------------------------------===//
23
Chris Lattner38af2de2009-02-20 21:35:13 +000024void ObjCListBase::Destroy(ASTContext &Ctx) {
Chris Lattner4ee413b2009-02-20 21:44:01 +000025 Ctx.Deallocate(List);
Chris Lattner11e1e1a2009-02-20 21:16:26 +000026 NumElts = 0;
27 List = 0;
28}
29
Chris Lattner38af2de2009-02-20 21:35:13 +000030void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) {
Chris Lattner11e1e1a2009-02-20 21:16:26 +000031 assert(List == 0 && "Elements already set!");
32 if (Elts == 0) return; // Setting to an empty list is a noop.
Mike Stump1eb44332009-09-09 15:08:12 +000033
34
Chris Lattner4ee413b2009-02-20 21:44:01 +000035 List = new (Ctx) void*[Elts];
Chris Lattner11e1e1a2009-02-20 21:16:26 +000036 NumElts = Elts;
37 memcpy(List, InList, sizeof(void*)*Elts);
38}
39
40
41//===----------------------------------------------------------------------===//
Chris Lattnerab351632009-02-20 20:59:54 +000042// ObjCInterfaceDecl
Chris Lattner6c4ae5d2008-03-16 00:49:28 +000043//===----------------------------------------------------------------------===//
44
Fariborz Jahanian496b5a82009-06-05 18:16:35 +000045/// getIvarDecl - This method looks up an ivar in this ContextDecl.
46///
47ObjCIvarDecl *
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +000048ObjCContainerDecl::getIvarDecl(IdentifierInfo *Id) const {
Fariborz Jahanian496b5a82009-06-05 18:16:35 +000049 lookup_const_iterator Ivar, IvarEnd;
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +000050 for (llvm::tie(Ivar, IvarEnd) = lookup(Id); Ivar != IvarEnd; ++Ivar) {
Fariborz Jahanian496b5a82009-06-05 18:16:35 +000051 if (ObjCIvarDecl *ivar = dyn_cast<ObjCIvarDecl>(*Ivar))
52 return ivar;
53 }
54 return 0;
55}
56
Argyrios Kyrtzidis467c0b12009-07-25 22:15:22 +000057// Get the local instance/class method declared in this interface.
Douglas Gregor6ab35242009-04-09 21:40:53 +000058ObjCMethodDecl *
Argyrios Kyrtzidis467c0b12009-07-25 22:15:22 +000059ObjCContainerDecl::getMethod(Selector Sel, bool isInstance) const {
Steve Naroff0de21fd2009-02-22 19:35:57 +000060 // Since instance & class methods can have the same name, the loop below
61 // ensures we get the correct method.
62 //
63 // @interface Whatever
64 // - (int) class_method;
65 // + (float) class_method;
66 // @end
67 //
68 lookup_const_iterator Meth, MethEnd;
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +000069 for (llvm::tie(Meth, MethEnd) = lookup(Sel); Meth != MethEnd; ++Meth) {
Steve Naroff0de21fd2009-02-22 19:35:57 +000070 ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth);
Argyrios Kyrtzidis467c0b12009-07-25 22:15:22 +000071 if (MD && MD->isInstanceMethod() == isInstance)
Steve Naroff0de21fd2009-02-22 19:35:57 +000072 return MD;
73 }
Steve Naroff0701bbb2009-01-08 17:28:14 +000074 return 0;
75}
76
Fariborz Jahanian559c0c42008-04-21 19:04:53 +000077/// FindPropertyDeclaration - Finds declaration of the property given its name
78/// in 'PropertyId' and returns it. It returns 0, if not found.
Steve Naroff93983f82009-01-11 12:47:58 +000079/// FIXME: Convert to DeclContext lookup...
Fariborz Jahanian559c0c42008-04-21 19:04:53 +000080///
81ObjCPropertyDecl *
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +000082ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
83 for (prop_iterator I = prop_begin(), E = prop_end(); I != E; ++I)
Chris Lattnerab351632009-02-20 20:59:54 +000084 if ((*I)->getIdentifier() == PropertyId)
85 return *I;
Mike Stump1eb44332009-09-09 15:08:12 +000086
Fariborz Jahaniana66793e2009-01-09 21:04:52 +000087 const ObjCProtocolDecl *PID = dyn_cast<ObjCProtocolDecl>(this);
88 if (PID) {
Mike Stump1eb44332009-09-09 15:08:12 +000089 for (ObjCProtocolDecl::protocol_iterator I = PID->protocol_begin(),
Chris Lattnerab351632009-02-20 20:59:54 +000090 E = PID->protocol_end(); I != E; ++I)
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +000091 if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId))
Chris Lattnerab351632009-02-20 20:59:54 +000092 return P;
Fariborz Jahaniana66793e2009-01-09 21:04:52 +000093 }
Mike Stump1eb44332009-09-09 15:08:12 +000094
Fariborz Jahanianf034e9c2009-01-19 18:16:19 +000095 if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(this)) {
Steve Naroff09c47192009-01-09 15:36:25 +000096 // Look through categories.
97 for (ObjCCategoryDecl *Category = OID->getCategoryList();
98 Category; Category = Category->getNextClassCategory()) {
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +000099 if (ObjCPropertyDecl *P = Category->FindPropertyDeclaration(PropertyId))
Chris Lattnerab351632009-02-20 20:59:54 +0000100 return P;
Steve Naroff09c47192009-01-09 15:36:25 +0000101 }
102 // Look through protocols.
103 for (ObjCInterfaceDecl::protocol_iterator I = OID->protocol_begin(),
104 E = OID->protocol_end(); I != E; ++I) {
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +0000105 if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId))
Chris Lattnerab351632009-02-20 20:59:54 +0000106 return P;
Steve Naroff09c47192009-01-09 15:36:25 +0000107 }
108 if (OID->getSuperClass())
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +0000109 return OID->getSuperClass()->FindPropertyDeclaration(PropertyId);
Chris Lattnerab351632009-02-20 20:59:54 +0000110 } else if (const ObjCCategoryDecl *OCD = dyn_cast<ObjCCategoryDecl>(this)) {
Fariborz Jahanianf034e9c2009-01-19 18:16:19 +0000111 // Look through protocols.
112 for (ObjCInterfaceDecl::protocol_iterator I = OCD->protocol_begin(),
113 E = OCD->protocol_end(); I != E; ++I) {
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +0000114 if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId))
Chris Lattnerab351632009-02-20 20:59:54 +0000115 return P;
Fariborz Jahanianf034e9c2009-01-19 18:16:19 +0000116 }
117 }
Steve Naroff3d2c22b2008-06-05 13:55:23 +0000118 return 0;
119}
120
Fariborz Jahaniana6f14e12009-11-02 22:45:15 +0000121/// FindPropertyVisibleInPrimaryClass - Finds declaration of the property
122/// with name 'PropertyId' in the primary class; including those in protocols
123/// (direct or indirect) used by the promary class.
124/// FIXME: Convert to DeclContext lookup...
125///
126ObjCPropertyDecl *
127ObjCContainerDecl::FindPropertyVisibleInPrimaryClass(
128 IdentifierInfo *PropertyId) const {
129 assert(isa<ObjCInterfaceDecl>(this) && "FindPropertyVisibleInPrimaryClass");
130 for (prop_iterator I = prop_begin(), E = prop_end(); I != E; ++I)
131 if ((*I)->getIdentifier() == PropertyId)
132 return *I;
133 const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(this);
134 // Look through protocols.
135 for (ObjCInterfaceDecl::protocol_iterator I = OID->protocol_begin(),
136 E = OID->protocol_end(); I != E; ++I)
137 if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId))
138 return P;
139 return 0;
140}
141
Fariborz Jahanian339798e2009-10-05 20:41:32 +0000142void ObjCInterfaceDecl::mergeClassExtensionProtocolList(
143 ObjCProtocolDecl *const* ExtList, unsigned ExtNum,
144 ASTContext &C)
145{
146 if (ReferencedProtocols.empty()) {
147 ReferencedProtocols.set(ExtList, ExtNum, C);
148 return;
149 }
150 // Check for duplicate protocol in class's protocol list.
151 // This is (O)2. But it is extremely rare and number of protocols in
152 // class or its extension are very few.
153 llvm::SmallVector<ObjCProtocolDecl*, 8> ProtocolRefs;
154 for (unsigned i = 0; i < ExtNum; i++) {
155 bool protocolExists = false;
156 ObjCProtocolDecl *ProtoInExtension = ExtList[i];
157 for (protocol_iterator p = protocol_begin(), e = protocol_end();
158 p != e; p++) {
159 ObjCProtocolDecl *Proto = (*p);
160 if (C.ProtocolCompatibleWithProtocol(ProtoInExtension, Proto)) {
161 protocolExists = true;
162 break;
163 }
164 }
165 // Do we want to warn on a protocol in extension class which
166 // already exist in the class? Probably not.
167 if (!protocolExists)
168 ProtocolRefs.push_back(ProtoInExtension);
169 }
170 if (ProtocolRefs.empty())
171 return;
Fariborz Jahanianb106fc62009-10-05 21:32:49 +0000172 // Merge ProtocolRefs into class's protocol list;
Fariborz Jahanian339798e2009-10-05 20:41:32 +0000173 for (protocol_iterator p = protocol_begin(), e = protocol_end();
174 p != e; p++)
175 ProtocolRefs.push_back(*p);
176 ReferencedProtocols.Destroy(C);
177 unsigned NumProtoRefs = ProtocolRefs.size();
178 setProtocolList((ObjCProtocolDecl**)&ProtocolRefs[0], NumProtoRefs, C);
Fariborz Jahanian339798e2009-10-05 20:41:32 +0000179}
180
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +0000181ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(IdentifierInfo *ID,
182 ObjCInterfaceDecl *&clsDeclared) {
Chris Lattner1e03a562008-03-16 00:19:01 +0000183 ObjCInterfaceDecl* ClassDecl = this;
184 while (ClassDecl != NULL) {
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +0000185 if (ObjCIvarDecl *I = ClassDecl->getIvarDecl(ID)) {
Fariborz Jahanian496b5a82009-06-05 18:16:35 +0000186 clsDeclared = ClassDecl;
187 return I;
Chris Lattner1e03a562008-03-16 00:19:01 +0000188 }
189 ClassDecl = ClassDecl->getSuperClass();
190 }
191 return NULL;
192}
193
Fariborz Jahaniancd187622009-05-22 17:12:32 +0000194/// lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super
195/// class whose name is passed as argument. If it is not one of the super classes
196/// the it returns NULL.
197ObjCInterfaceDecl *ObjCInterfaceDecl::lookupInheritedClass(
198 const IdentifierInfo*ICName) {
199 ObjCInterfaceDecl* ClassDecl = this;
200 while (ClassDecl != NULL) {
201 if (ClassDecl->getIdentifier() == ICName)
202 return ClassDecl;
203 ClassDecl = ClassDecl->getSuperClass();
204 }
205 return NULL;
206}
207
Argyrios Kyrtzidisaa5420c2009-07-25 22:15:51 +0000208/// lookupMethod - This method returns an instance/class method by looking in
Chris Lattner1e03a562008-03-16 00:19:01 +0000209/// the class, its categories, and its super classes (using a linear search).
Argyrios Kyrtzidisaa5420c2009-07-25 22:15:51 +0000210ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
211 bool isInstance) const {
212 const ObjCInterfaceDecl* ClassDecl = this;
Chris Lattner1e03a562008-03-16 00:19:01 +0000213 ObjCMethodDecl *MethodDecl = 0;
Mike Stump1eb44332009-09-09 15:08:12 +0000214
Chris Lattner1e03a562008-03-16 00:19:01 +0000215 while (ClassDecl != NULL) {
Argyrios Kyrtzidisaa5420c2009-07-25 22:15:51 +0000216 if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance)))
Chris Lattner1e03a562008-03-16 00:19:01 +0000217 return MethodDecl;
Mike Stump1eb44332009-09-09 15:08:12 +0000218
Chris Lattner1e03a562008-03-16 00:19:01 +0000219 // Didn't find one yet - look through protocols.
Chris Lattner3db6cae2008-07-21 18:19:38 +0000220 const ObjCList<ObjCProtocolDecl> &Protocols =
221 ClassDecl->getReferencedProtocols();
222 for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
223 E = Protocols.end(); I != E; ++I)
Argyrios Kyrtzidisaa5420c2009-07-25 22:15:51 +0000224 if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
Chris Lattner1e03a562008-03-16 00:19:01 +0000225 return MethodDecl;
Mike Stump1eb44332009-09-09 15:08:12 +0000226
Chris Lattner1e03a562008-03-16 00:19:01 +0000227 // Didn't find one yet - now look through categories.
228 ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList();
229 while (CatDecl) {
Argyrios Kyrtzidisaa5420c2009-07-25 22:15:51 +0000230 if ((MethodDecl = CatDecl->getMethod(Sel, isInstance)))
Chris Lattner1e03a562008-03-16 00:19:01 +0000231 return MethodDecl;
Mike Stump1eb44332009-09-09 15:08:12 +0000232
Steve Naroffb79c01e2008-12-08 20:57:28 +0000233 // Didn't find one yet - look through protocols.
234 const ObjCList<ObjCProtocolDecl> &Protocols =
235 CatDecl->getReferencedProtocols();
236 for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
237 E = Protocols.end(); I != E; ++I)
Argyrios Kyrtzidisaa5420c2009-07-25 22:15:51 +0000238 if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
Steve Naroffb5584222009-02-26 11:32:02 +0000239 return MethodDecl;
Chris Lattner1e03a562008-03-16 00:19:01 +0000240 CatDecl = CatDecl->getNextClassCategory();
241 }
242 ClassDecl = ClassDecl->getSuperClass();
243 }
244 return NULL;
245}
246
Steve Naroffd789d3d2009-10-01 23:46:04 +0000247ObjCMethodDecl *ObjCInterfaceDecl::lookupPrivateInstanceMethod(
248 const Selector &Sel) {
249 ObjCMethodDecl *Method = 0;
250 if (ObjCImplementationDecl *ImpDecl = getImplementation())
251 Method = ImpDecl->getInstanceMethod(Sel);
252
253 if (!Method && getSuperClass())
254 return getSuperClass()->lookupPrivateInstanceMethod(Sel);
255 return Method;
256}
Chris Lattnerab351632009-02-20 20:59:54 +0000257
258//===----------------------------------------------------------------------===//
259// ObjCMethodDecl
260//===----------------------------------------------------------------------===//
261
262ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C,
Mike Stump1eb44332009-09-09 15:08:12 +0000263 SourceLocation beginLoc,
Chris Lattnerab351632009-02-20 20:59:54 +0000264 SourceLocation endLoc,
265 Selector SelInfo, QualType T,
266 DeclContext *contextDecl,
267 bool isInstance,
268 bool isVariadic,
269 bool isSynthesized,
270 ImplementationControl impControl) {
271 return new (C) ObjCMethodDecl(beginLoc, endLoc,
272 SelInfo, T, contextDecl,
Mike Stump1eb44332009-09-09 15:08:12 +0000273 isInstance,
Chris Lattnerab351632009-02-20 20:59:54 +0000274 isVariadic, isSynthesized, impControl);
Chris Lattner1e03a562008-03-16 00:19:01 +0000275}
276
Chris Lattner38af2de2009-02-20 21:35:13 +0000277void ObjCMethodDecl::Destroy(ASTContext &C) {
Chris Lattnerab351632009-02-20 20:59:54 +0000278 if (Body) Body->Destroy(C);
279 if (SelfDecl) SelfDecl->Destroy(C);
Mike Stump1eb44332009-09-09 15:08:12 +0000280
Chris Lattnerab351632009-02-20 20:59:54 +0000281 for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
282 if (*I) (*I)->Destroy(C);
283
Chris Lattner38af2de2009-02-20 21:35:13 +0000284 ParamInfo.Destroy(C);
Chris Lattnerab351632009-02-20 20:59:54 +0000285
286 Decl::Destroy(C);
Chris Lattner1e03a562008-03-16 00:19:01 +0000287}
288
Argyrios Kyrtzidis57ea6be2009-07-21 00:06:36 +0000289/// \brief A definition will return its interface declaration.
290/// An interface declaration will return its definition.
291/// Otherwise it will return itself.
292ObjCMethodDecl *ObjCMethodDecl::getNextRedeclaration() {
293 ASTContext &Ctx = getASTContext();
294 ObjCMethodDecl *Redecl = 0;
295 Decl *CtxD = cast<Decl>(getDeclContext());
296
297 if (ObjCInterfaceDecl *IFD = dyn_cast<ObjCInterfaceDecl>(CtxD)) {
298 if (ObjCImplementationDecl *ImplD = Ctx.getObjCImplementation(IFD))
299 Redecl = ImplD->getMethod(getSelector(), isInstanceMethod());
300
301 } else if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(CtxD)) {
302 if (ObjCCategoryImplDecl *ImplD = Ctx.getObjCImplementation(CD))
303 Redecl = ImplD->getMethod(getSelector(), isInstanceMethod());
304
Argyrios Kyrtzidis42920732009-07-28 05:11:05 +0000305 } else if (ObjCImplementationDecl *ImplD =
306 dyn_cast<ObjCImplementationDecl>(CtxD)) {
Argyrios Kyrtzidis57ea6be2009-07-21 00:06:36 +0000307 if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface())
308 Redecl = IFD->getMethod(getSelector(), isInstanceMethod());
Argyrios Kyrtzidis42920732009-07-28 05:11:05 +0000309
310 } else if (ObjCCategoryImplDecl *CImplD =
311 dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
Steve Naroff0d69b8c2009-10-29 21:11:04 +0000312 if (ObjCCategoryDecl *CatD = CImplD->getCategoryDecl())
Argyrios Kyrtzidis42920732009-07-28 05:11:05 +0000313 Redecl = CatD->getMethod(getSelector(), isInstanceMethod());
Argyrios Kyrtzidis57ea6be2009-07-21 00:06:36 +0000314 }
315
316 return Redecl ? Redecl : this;
317}
318
Argyrios Kyrtzidise7f9d302009-07-28 05:11:17 +0000319ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() {
320 Decl *CtxD = cast<Decl>(getDeclContext());
321
322 if (ObjCImplementationDecl *ImplD = dyn_cast<ObjCImplementationDecl>(CtxD)) {
323 if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface())
324 if (ObjCMethodDecl *MD = IFD->getMethod(getSelector(),
325 isInstanceMethod()))
326 return MD;
327
328 } else if (ObjCCategoryImplDecl *CImplD =
329 dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
Steve Naroff0d69b8c2009-10-29 21:11:04 +0000330 if (ObjCCategoryDecl *CatD = CImplD->getCategoryDecl())
Argyrios Kyrtzidise7f9d302009-07-28 05:11:17 +0000331 if (ObjCMethodDecl *MD = CatD->getMethod(getSelector(),
332 isInstanceMethod()))
333 return MD;
334 }
335
336 return this;
337}
338
Mike Stump1eb44332009-09-09 15:08:12 +0000339void ObjCMethodDecl::createImplicitParams(ASTContext &Context,
Chris Lattnerab351632009-02-20 20:59:54 +0000340 const ObjCInterfaceDecl *OID) {
341 QualType selfTy;
342 if (isInstanceMethod()) {
343 // There may be no interface context due to error in declaration
344 // of the interface (which has been reported). Recover gracefully.
345 if (OID) {
Daniel Dunbar3b3a4582009-04-22 04:34:53 +0000346 selfTy = Context.getObjCInterfaceType(OID);
Steve Naroff14108da2009-07-10 23:34:53 +0000347 selfTy = Context.getObjCObjectPointerType(selfTy);
Chris Lattnerab351632009-02-20 20:59:54 +0000348 } else {
349 selfTy = Context.getObjCIdType();
350 }
351 } else // we have a factory method.
352 selfTy = Context.getObjCClassType();
353
Mike Stump1eb44332009-09-09 15:08:12 +0000354 setSelfDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(),
Steve Naroff53c9d8a2009-04-20 15:06:07 +0000355 &Context.Idents.get("self"), selfTy));
Chris Lattnerab351632009-02-20 20:59:54 +0000356
Mike Stump1eb44332009-09-09 15:08:12 +0000357 setCmdDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(),
358 &Context.Idents.get("_cmd"),
Steve Naroff53c9d8a2009-04-20 15:06:07 +0000359 Context.getObjCSelType()));
Chris Lattnerab351632009-02-20 20:59:54 +0000360}
361
Chris Lattnerab351632009-02-20 20:59:54 +0000362ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() {
363 if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(getDeclContext()))
364 return ID;
365 if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(getDeclContext()))
366 return CD->getClassInterface();
Argyrios Kyrtzidisa8530372009-07-28 05:10:52 +0000367 if (ObjCImplDecl *IMD = dyn_cast<ObjCImplDecl>(getDeclContext()))
Chris Lattnerab351632009-02-20 20:59:54 +0000368 return IMD->getClassInterface();
Argyrios Kyrtzidisa8530372009-07-28 05:10:52 +0000369
370 assert(!isa<ObjCProtocolDecl>(getDeclContext()) && "It's a protocol method");
Chris Lattnerab351632009-02-20 20:59:54 +0000371 assert(false && "unknown method context");
Fariborz Jahanianae6f6fd2008-12-05 22:32:48 +0000372 return 0;
373}
374
Chris Lattnerab351632009-02-20 20:59:54 +0000375//===----------------------------------------------------------------------===//
376// ObjCInterfaceDecl
377//===----------------------------------------------------------------------===//
378
379ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C,
380 DeclContext *DC,
381 SourceLocation atLoc,
Mike Stump1eb44332009-09-09 15:08:12 +0000382 IdentifierInfo *Id,
Chris Lattnerab351632009-02-20 20:59:54 +0000383 SourceLocation ClassLoc,
384 bool ForwardDecl, bool isInternal){
385 return new (C) ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, ForwardDecl,
386 isInternal);
387}
388
389ObjCInterfaceDecl::
390ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id,
391 SourceLocation CLoc, bool FD, bool isInternal)
392 : ObjCContainerDecl(ObjCInterface, DC, atLoc, Id),
393 TypeForDecl(0), SuperClass(0),
394 CategoryList(0), ForwardDecl(FD), InternalInterface(isInternal),
395 ClassLoc(CLoc) {
396}
397
Mike Stump1eb44332009-09-09 15:08:12 +0000398void ObjCInterfaceDecl::Destroy(ASTContext &C) {
Chris Lattnerd13d3022009-03-31 08:36:08 +0000399 for (ivar_iterator I = ivar_begin(), E = ivar_end(); I != E; ++I)
Chris Lattnerab351632009-02-20 20:59:54 +0000400 if (*I) (*I)->Destroy(C);
Mike Stump1eb44332009-09-09 15:08:12 +0000401
Chris Lattner38af2de2009-02-20 21:35:13 +0000402 IVars.Destroy(C);
Chris Lattnerab351632009-02-20 20:59:54 +0000403 // FIXME: CategoryList?
Mike Stump1eb44332009-09-09 15:08:12 +0000404
Chris Lattnerab351632009-02-20 20:59:54 +0000405 // FIXME: Because there is no clear ownership
406 // role between ObjCInterfaceDecls and the ObjCPropertyDecls that they
407 // reference, we destroy ObjCPropertyDecls in ~TranslationUnit.
408 Decl::Destroy(C);
409}
410
Argyrios Kyrtzidis8a1d7222009-07-21 00:05:53 +0000411ObjCImplementationDecl *ObjCInterfaceDecl::getImplementation() const {
412 return getASTContext().getObjCImplementation(
413 const_cast<ObjCInterfaceDecl*>(this));
414}
415
416void ObjCInterfaceDecl::setImplementation(ObjCImplementationDecl *ImplD) {
417 getASTContext().setObjCImplementation(this, ImplD);
418}
419
Chris Lattnerab351632009-02-20 20:59:54 +0000420
421/// FindCategoryDeclaration - Finds category declaration in the list of
422/// categories for this class and returns it. Name of the category is passed
423/// in 'CategoryId'. If category not found, return 0;
Fariborz Jahanianae6f6fd2008-12-05 22:32:48 +0000424///
Chris Lattnerab351632009-02-20 20:59:54 +0000425ObjCCategoryDecl *
426ObjCInterfaceDecl::FindCategoryDeclaration(IdentifierInfo *CategoryId) const {
427 for (ObjCCategoryDecl *Category = getCategoryList();
428 Category; Category = Category->getNextClassCategory())
429 if (Category->getIdentifier() == CategoryId)
430 return Category;
Fariborz Jahanianae6f6fd2008-12-05 22:32:48 +0000431 return 0;
432}
433
Argyrios Kyrtzidis1cb35dd2009-07-21 00:06:20 +0000434ObjCMethodDecl *
435ObjCInterfaceDecl::getCategoryInstanceMethod(Selector Sel) const {
436 for (ObjCCategoryDecl *Category = getCategoryList();
437 Category; Category = Category->getNextClassCategory())
438 if (ObjCCategoryImplDecl *Impl = Category->getImplementation())
439 if (ObjCMethodDecl *MD = Impl->getInstanceMethod(Sel))
440 return MD;
441 return 0;
442}
443
444ObjCMethodDecl *ObjCInterfaceDecl::getCategoryClassMethod(Selector Sel) const {
445 for (ObjCCategoryDecl *Category = getCategoryList();
446 Category; Category = Category->getNextClassCategory())
447 if (ObjCCategoryImplDecl *Impl = Category->getImplementation())
448 if (ObjCMethodDecl *MD = Impl->getClassMethod(Sel))
449 return MD;
450 return 0;
451}
452
Fariborz Jahanian0fd89042009-08-11 22:02:25 +0000453/// ClassImplementsProtocol - Checks that 'lProto' protocol
454/// has been implemented in IDecl class, its super class or categories (if
455/// lookupCategory is true).
456bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto,
457 bool lookupCategory,
458 bool RHSIsQualifiedID) {
459 ObjCInterfaceDecl *IDecl = this;
460 // 1st, look up the class.
461 const ObjCList<ObjCProtocolDecl> &Protocols =
462 IDecl->getReferencedProtocols();
Mike Stump1eb44332009-09-09 15:08:12 +0000463
Fariborz Jahanian0fd89042009-08-11 22:02:25 +0000464 for (ObjCList<ObjCProtocolDecl>::iterator PI = Protocols.begin(),
465 E = Protocols.end(); PI != E; ++PI) {
466 if (getASTContext().ProtocolCompatibleWithProtocol(lProto, *PI))
467 return true;
468 // This is dubious and is added to be compatible with gcc. In gcc, it is
469 // also allowed assigning a protocol-qualified 'id' type to a LHS object
470 // when protocol in qualified LHS is in list of protocols in the rhs 'id'
471 // object. This IMO, should be a bug.
472 // FIXME: Treat this as an extension, and flag this as an error when GCC
473 // extensions are not enabled.
Mike Stump1eb44332009-09-09 15:08:12 +0000474 if (RHSIsQualifiedID &&
Fariborz Jahanian0fd89042009-08-11 22:02:25 +0000475 getASTContext().ProtocolCompatibleWithProtocol(*PI, lProto))
476 return true;
477 }
Mike Stump1eb44332009-09-09 15:08:12 +0000478
Fariborz Jahanian0fd89042009-08-11 22:02:25 +0000479 // 2nd, look up the category.
480 if (lookupCategory)
481 for (ObjCCategoryDecl *CDecl = IDecl->getCategoryList(); CDecl;
482 CDecl = CDecl->getNextClassCategory()) {
483 for (ObjCCategoryDecl::protocol_iterator PI = CDecl->protocol_begin(),
484 E = CDecl->protocol_end(); PI != E; ++PI)
485 if (getASTContext().ProtocolCompatibleWithProtocol(lProto, *PI))
486 return true;
487 }
Mike Stump1eb44332009-09-09 15:08:12 +0000488
Fariborz Jahanian0fd89042009-08-11 22:02:25 +0000489 // 3rd, look up the super class(s)
490 if (IDecl->getSuperClass())
491 return
492 IDecl->getSuperClass()->ClassImplementsProtocol(lProto, lookupCategory,
493 RHSIsQualifiedID);
Mike Stump1eb44332009-09-09 15:08:12 +0000494
Fariborz Jahanian0fd89042009-08-11 22:02:25 +0000495 return false;
496}
497
Chris Lattnerab351632009-02-20 20:59:54 +0000498//===----------------------------------------------------------------------===//
499// ObjCIvarDecl
500//===----------------------------------------------------------------------===//
501
502ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, DeclContext *DC,
503 SourceLocation L, IdentifierInfo *Id,
Argyrios Kyrtzidisa1d56622009-08-19 01:27:57 +0000504 QualType T, DeclaratorInfo *DInfo,
505 AccessControl ac, Expr *BW) {
506 return new (C) ObjCIvarDecl(DC, L, Id, T, DInfo, ac, BW);
Chris Lattnerab351632009-02-20 20:59:54 +0000507}
508
509
510
511//===----------------------------------------------------------------------===//
512// ObjCAtDefsFieldDecl
513//===----------------------------------------------------------------------===//
514
515ObjCAtDefsFieldDecl
516*ObjCAtDefsFieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
517 IdentifierInfo *Id, QualType T, Expr *BW) {
518 return new (C) ObjCAtDefsFieldDecl(DC, L, Id, T, BW);
519}
520
521void ObjCAtDefsFieldDecl::Destroy(ASTContext& C) {
522 this->~ObjCAtDefsFieldDecl();
Mike Stump1eb44332009-09-09 15:08:12 +0000523 C.Deallocate((void *)this);
Chris Lattnerab351632009-02-20 20:59:54 +0000524}
525
526//===----------------------------------------------------------------------===//
527// ObjCProtocolDecl
528//===----------------------------------------------------------------------===//
529
530ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC,
Mike Stump1eb44332009-09-09 15:08:12 +0000531 SourceLocation L,
Chris Lattnerab351632009-02-20 20:59:54 +0000532 IdentifierInfo *Id) {
533 return new (C) ObjCProtocolDecl(DC, L, Id);
534}
535
536void ObjCProtocolDecl::Destroy(ASTContext &C) {
Chris Lattner38af2de2009-02-20 21:35:13 +0000537 ReferencedProtocols.Destroy(C);
Chris Lattnerab351632009-02-20 20:59:54 +0000538 ObjCContainerDecl::Destroy(C);
539}
540
Steve Naroff91b0b0c2009-03-01 16:12:44 +0000541ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) {
542 ObjCProtocolDecl *PDecl = this;
543
544 if (Name == getIdentifier())
545 return PDecl;
546
547 for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I)
548 if ((PDecl = (*I)->lookupProtocolNamed(Name)))
549 return PDecl;
Mike Stump1eb44332009-09-09 15:08:12 +0000550
Steve Naroff91b0b0c2009-03-01 16:12:44 +0000551 return NULL;
552}
553
Argyrios Kyrtzidis094e2bb2009-07-25 22:15:38 +0000554// lookupMethod - Lookup a instance/class method in the protocol and protocols
Chris Lattnerab351632009-02-20 20:59:54 +0000555// it inherited.
Argyrios Kyrtzidis094e2bb2009-07-25 22:15:38 +0000556ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel,
557 bool isInstance) const {
Chris Lattnerab351632009-02-20 20:59:54 +0000558 ObjCMethodDecl *MethodDecl = NULL;
Mike Stump1eb44332009-09-09 15:08:12 +0000559
Argyrios Kyrtzidis094e2bb2009-07-25 22:15:38 +0000560 if ((MethodDecl = getMethod(Sel, isInstance)))
Chris Lattnerab351632009-02-20 20:59:54 +0000561 return MethodDecl;
Mike Stump1eb44332009-09-09 15:08:12 +0000562
Chris Lattnerab351632009-02-20 20:59:54 +0000563 for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I)
Argyrios Kyrtzidis094e2bb2009-07-25 22:15:38 +0000564 if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
Chris Lattnerab351632009-02-20 20:59:54 +0000565 return MethodDecl;
566 return NULL;
567}
568
569//===----------------------------------------------------------------------===//
570// ObjCClassDecl
571//===----------------------------------------------------------------------===//
572
Mike Stump1eb44332009-09-09 15:08:12 +0000573ObjCClassDecl::ObjCClassDecl(DeclContext *DC, SourceLocation L,
Ted Kremenek321c22f2009-11-18 00:28:11 +0000574 ObjCInterfaceDecl *const *Elts,
575 const SourceLocation *Locs,
576 unsigned nElts,
Chris Lattner38af2de2009-02-20 21:35:13 +0000577 ASTContext &C)
578 : Decl(ObjCClass, DC, L) {
Ted Kremenek321c22f2009-11-18 00:28:11 +0000579 setClassList(C, Elts, Locs, nElts);
Chris Lattner38af2de2009-02-20 21:35:13 +0000580}
581
Ted Kremenek321c22f2009-11-18 00:28:11 +0000582void ObjCClassDecl::setClassList(ASTContext &C, ObjCInterfaceDecl*const*List,
583 const SourceLocation *Locs, unsigned Num) {
584 ForwardDecls = (ObjCClassRef*) C.Allocate(sizeof(ObjCClassRef)*Num,
585 llvm::alignof<ObjCClassRef>());
586 for (unsigned i = 0; i < Num; ++i)
587 new (&ForwardDecls[i]) ObjCClassRef(List[i], Locs[i]);
588
589 NumDecls = Num;
590}
Chris Lattner38af2de2009-02-20 21:35:13 +0000591
Chris Lattnerab351632009-02-20 20:59:54 +0000592ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC,
593 SourceLocation L,
594 ObjCInterfaceDecl *const *Elts,
Ted Kremenek321c22f2009-11-18 00:28:11 +0000595 const SourceLocation *Locs,
Chris Lattnerab351632009-02-20 20:59:54 +0000596 unsigned nElts) {
Ted Kremenek321c22f2009-11-18 00:28:11 +0000597 return new (C) ObjCClassDecl(DC, L, Elts, Locs, nElts, C);
Chris Lattnerab351632009-02-20 20:59:54 +0000598}
599
600void ObjCClassDecl::Destroy(ASTContext &C) {
Ted Kremenek321c22f2009-11-18 00:28:11 +0000601 // ObjCInterfaceDecls registered with a DeclContext will get destroyed
602 // when the DeclContext is destroyed. For those created only by a forward
603 // declaration, the first @class that created the ObjCInterfaceDecl gets
604 // to destroy it.
605 // FIXME: Note that this ownership role is very brittle; a better
606 // polict is surely need in the future.
607 for (iterator I = begin(), E = end(); I !=E ; ++I) {
608 ObjCInterfaceDecl *ID = I->getInterface();
609 if (ID->isForwardDecl() && ID->getLocStart() == getLocStart())
610 ID->Destroy(C);
611 }
612
613 C.Deallocate(ForwardDecls);
Chris Lattnerab351632009-02-20 20:59:54 +0000614 Decl::Destroy(C);
615}
616
Ted Kremenek2dbdd622009-11-18 01:26:56 +0000617SourceRange ObjCClassDecl::getSourceRange() const {
618 // FIXME: We should include the semicolon
619 assert(NumDecls);
620 return SourceRange(getLocation(), ForwardDecls[NumDecls-1].getLocation());
621}
622
Chris Lattnerab351632009-02-20 20:59:54 +0000623//===----------------------------------------------------------------------===//
624// ObjCForwardProtocolDecl
625//===----------------------------------------------------------------------===//
626
Chris Lattner38af2de2009-02-20 21:35:13 +0000627ObjCForwardProtocolDecl::
628ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L,
629 ObjCProtocolDecl *const *Elts, unsigned nElts,
630 ASTContext &C)
Mike Stump1eb44332009-09-09 15:08:12 +0000631: Decl(ObjCForwardProtocol, DC, L) {
Chris Lattner38af2de2009-02-20 21:35:13 +0000632 ReferencedProtocols.set(Elts, nElts, C);
633}
634
635
Chris Lattnerab351632009-02-20 20:59:54 +0000636ObjCForwardProtocolDecl *
637ObjCForwardProtocolDecl::Create(ASTContext &C, DeclContext *DC,
Mike Stump1eb44332009-09-09 15:08:12 +0000638 SourceLocation L,
Chris Lattnerab351632009-02-20 20:59:54 +0000639 ObjCProtocolDecl *const *Elts,
640 unsigned NumElts) {
Chris Lattner38af2de2009-02-20 21:35:13 +0000641 return new (C) ObjCForwardProtocolDecl(DC, L, Elts, NumElts, C);
Chris Lattnerab351632009-02-20 20:59:54 +0000642}
643
644void ObjCForwardProtocolDecl::Destroy(ASTContext &C) {
Chris Lattner38af2de2009-02-20 21:35:13 +0000645 ReferencedProtocols.Destroy(C);
Chris Lattnerab351632009-02-20 20:59:54 +0000646 Decl::Destroy(C);
647}
648
649//===----------------------------------------------------------------------===//
650// ObjCCategoryDecl
651//===----------------------------------------------------------------------===//
652
653ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, DeclContext *DC,
654 SourceLocation L,
655 IdentifierInfo *Id) {
656 return new (C) ObjCCategoryDecl(DC, L, Id);
657}
658
Argyrios Kyrtzidis8a1d7222009-07-21 00:05:53 +0000659ObjCCategoryImplDecl *ObjCCategoryDecl::getImplementation() const {
660 return getASTContext().getObjCImplementation(
661 const_cast<ObjCCategoryDecl*>(this));
662}
663
664void ObjCCategoryDecl::setImplementation(ObjCCategoryImplDecl *ImplD) {
665 getASTContext().setObjCImplementation(this, ImplD);
666}
667
668
Chris Lattnerab351632009-02-20 20:59:54 +0000669//===----------------------------------------------------------------------===//
670// ObjCCategoryImplDecl
671//===----------------------------------------------------------------------===//
672
673ObjCCategoryImplDecl *
674ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC,
675 SourceLocation L,IdentifierInfo *Id,
676 ObjCInterfaceDecl *ClassInterface) {
677 return new (C) ObjCCategoryImplDecl(DC, L, Id, ClassInterface);
678}
679
Steve Naroff0d69b8c2009-10-29 21:11:04 +0000680ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryDecl() const {
Argyrios Kyrtzidis42920732009-07-28 05:11:05 +0000681 return getClassInterface()->FindCategoryDeclaration(getIdentifier());
682}
683
Chris Lattnerab351632009-02-20 20:59:54 +0000684
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +0000685void ObjCImplDecl::addPropertyImplementation(ObjCPropertyImplDecl *property) {
Douglas Gregor2c2d43c2009-04-23 02:42:49 +0000686 // FIXME: The context should be correct before we get here.
Douglas Gregor653f1b12009-04-23 01:02:12 +0000687 property->setLexicalDeclContext(this);
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +0000688 addDecl(property);
Douglas Gregor653f1b12009-04-23 01:02:12 +0000689}
690
Argyrios Kyrtzidis8a1d7222009-07-21 00:05:53 +0000691void ObjCImplDecl::setClassInterface(ObjCInterfaceDecl *IFace) {
692 ASTContext &Ctx = getASTContext();
693
694 if (ObjCImplementationDecl *ImplD
Duncan Sands98f2cca2009-07-21 07:56:29 +0000695 = dyn_cast_or_null<ObjCImplementationDecl>(this)) {
Argyrios Kyrtzidis8a1d7222009-07-21 00:05:53 +0000696 if (IFace)
697 Ctx.setObjCImplementation(IFace, ImplD);
698
Duncan Sands98f2cca2009-07-21 07:56:29 +0000699 } else if (ObjCCategoryImplDecl *ImplD =
Argyrios Kyrtzidis8a1d7222009-07-21 00:05:53 +0000700 dyn_cast_or_null<ObjCCategoryImplDecl>(this)) {
701 if (ObjCCategoryDecl *CD = IFace->FindCategoryDeclaration(getIdentifier()))
702 Ctx.setObjCImplementation(CD, ImplD);
703 }
704
705 ClassInterface = IFace;
706}
707
Fariborz Jahanianae6f6fd2008-12-05 22:32:48 +0000708/// FindPropertyImplIvarDecl - This method lookup the ivar in the list of
Chris Lattnerd6eed1c2009-02-16 19:24:31 +0000709/// properties implemented in this category @implementation block and returns
710/// the implemented property that uses it.
Fariborz Jahanianae6f6fd2008-12-05 22:32:48 +0000711///
Chris Lattner3aa18612009-02-28 18:42:10 +0000712ObjCPropertyImplDecl *ObjCImplDecl::
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +0000713FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const {
714 for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i){
Fariborz Jahanianae6f6fd2008-12-05 22:32:48 +0000715 ObjCPropertyImplDecl *PID = *i;
716 if (PID->getPropertyIvarDecl() &&
717 PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
718 return PID;
719 }
720 return 0;
721}
722
723/// FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl
724/// added to the list of those properties @synthesized/@dynamic in this
725/// category @implementation block.
726///
Chris Lattner3aa18612009-02-28 18:42:10 +0000727ObjCPropertyImplDecl *ObjCImplDecl::
Argyrios Kyrtzidis17945a02009-06-30 02:36:12 +0000728FindPropertyImplDecl(IdentifierInfo *Id) const {
729 for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i){
Fariborz Jahanianae6f6fd2008-12-05 22:32:48 +0000730 ObjCPropertyImplDecl *PID = *i;
731 if (PID->getPropertyDecl()->getIdentifier() == Id)
732 return PID;
733 }
734 return 0;
735}
736
Chris Lattnerab351632009-02-20 20:59:54 +0000737//===----------------------------------------------------------------------===//
738// ObjCImplementationDecl
739//===----------------------------------------------------------------------===//
740
741ObjCImplementationDecl *
Mike Stump1eb44332009-09-09 15:08:12 +0000742ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC,
Chris Lattnerab351632009-02-20 20:59:54 +0000743 SourceLocation L,
744 ObjCInterfaceDecl *ClassInterface,
745 ObjCInterfaceDecl *SuperDecl) {
746 return new (C) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl);
747}
748
Chris Lattnerab351632009-02-20 20:59:54 +0000749//===----------------------------------------------------------------------===//
750// ObjCCompatibleAliasDecl
751//===----------------------------------------------------------------------===//
752
753ObjCCompatibleAliasDecl *
754ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC,
755 SourceLocation L,
Mike Stump1eb44332009-09-09 15:08:12 +0000756 IdentifierInfo *Id,
Chris Lattnerab351632009-02-20 20:59:54 +0000757 ObjCInterfaceDecl* AliasedClass) {
758 return new (C) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass);
759}
760
761//===----------------------------------------------------------------------===//
762// ObjCPropertyDecl
763//===----------------------------------------------------------------------===//
764
765ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, DeclContext *DC,
766 SourceLocation L,
767 IdentifierInfo *Id,
768 QualType T,
769 PropertyControl propControl) {
770 return new (C) ObjCPropertyDecl(DC, L, Id, T);
771}
772
773
774//===----------------------------------------------------------------------===//
775// ObjCPropertyImplDecl
776//===----------------------------------------------------------------------===//
777
Fariborz Jahanian628b96f2008-04-23 00:06:01 +0000778ObjCPropertyImplDecl *ObjCPropertyImplDecl::Create(ASTContext &C,
Douglas Gregord0434102009-01-09 00:49:46 +0000779 DeclContext *DC,
Fariborz Jahanian628b96f2008-04-23 00:06:01 +0000780 SourceLocation atLoc,
781 SourceLocation L,
782 ObjCPropertyDecl *property,
Daniel Dunbar9f0afd42008-08-26 04:47:31 +0000783 Kind PK,
Fariborz Jahanian628b96f2008-04-23 00:06:01 +0000784 ObjCIvarDecl *ivar) {
Steve Naroff3e970492009-01-27 21:25:57 +0000785 return new (C) ObjCPropertyImplDecl(DC, atLoc, L, property, PK, ivar);
Fariborz Jahanian628b96f2008-04-23 00:06:01 +0000786}
Chris Lattnerf4af5152008-03-17 01:19:02 +0000787
Chris Lattner0ed844b2008-04-04 06:12:32 +0000788