blob: 85b8ec14e045f606a10d03caf86c70cea11f0fd1 [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"
Chris Lattner1e03a562008-03-16 00:19:01 +000017using namespace clang;
18
Chris Lattner6c4ae5d2008-03-16 00:49:28 +000019//===----------------------------------------------------------------------===//
20// ObjC Decl Allocation/Deallocation Method Implementations
21//===----------------------------------------------------------------------===//
22
Chris Lattner0ed844b2008-04-04 06:12:32 +000023ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C,
24 SourceLocation beginLoc,
Chris Lattner6c4ae5d2008-03-16 00:49:28 +000025 SourceLocation endLoc,
26 Selector SelInfo, QualType T,
27 Decl *contextDecl,
Daniel Dunbarf6414922008-08-20 18:02:42 +000028 bool isInstance,
Chris Lattner6c4ae5d2008-03-16 00:49:28 +000029 bool isVariadic,
Fariborz Jahanian46070342008-05-07 20:53:44 +000030 bool isSynthesized,
Chris Lattnerb06fa3b2008-03-16 00:58:16 +000031 ImplementationControl impControl) {
Chris Lattner6c4ae5d2008-03-16 00:49:28 +000032 void *Mem = C.getAllocator().Allocate<ObjCMethodDecl>();
Chris Lattner0ed844b2008-04-04 06:12:32 +000033 return new (Mem) ObjCMethodDecl(beginLoc, endLoc,
34 SelInfo, T, contextDecl,
Daniel Dunbarf6414922008-08-20 18:02:42 +000035 isInstance,
Fariborz Jahanian46070342008-05-07 20:53:44 +000036 isVariadic, isSynthesized, impControl);
Chris Lattner0e77ba02008-03-16 01:15:50 +000037}
Chris Lattner6c4ae5d2008-03-16 00:49:28 +000038
Ted Kremenek8a779312008-06-06 16:45:15 +000039ObjCMethodDecl::~ObjCMethodDecl() {
40 delete [] ParamInfo;
Ted Kremenek8a779312008-06-06 16:45:15 +000041}
42
43void ObjCMethodDecl::Destroy(ASTContext& C) {
44 if (Body) Body->Destroy(C);
45 if (SelfDecl) SelfDecl->Destroy(C);
46
47 for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
48 if (*I) (*I)->Destroy(C);
49
50 Decl::Destroy(C);
51}
52
Chris Lattner0ed844b2008-04-04 06:12:32 +000053ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C,
54 SourceLocation atLoc,
Steve Naroffd6a07aa2008-04-11 19:35:35 +000055 IdentifierInfo *Id,
56 SourceLocation ClassLoc,
Chris Lattner0e77ba02008-03-16 01:15:50 +000057 bool ForwardDecl, bool isInternal){
58 void *Mem = C.getAllocator().Allocate<ObjCInterfaceDecl>();
Chris Lattnerb752f282008-07-21 07:06:49 +000059 return new (Mem) ObjCInterfaceDecl(atLoc, Id, ClassLoc, ForwardDecl,
Chris Lattner0e77ba02008-03-16 01:15:50 +000060 isInternal);
61}
62
Ted Kremenek8a779312008-06-06 16:45:15 +000063ObjCInterfaceDecl::~ObjCInterfaceDecl() {
64 delete [] Ivars;
65 delete [] InstanceMethods;
66 delete [] ClassMethods;
67 delete [] PropertyDecl;
68 // FIXME: CategoryList?
69}
70
71void ObjCInterfaceDecl::Destroy(ASTContext& C) {
72 for (ivar_iterator I=ivar_begin(), E=ivar_end(); I!=E; ++I)
73 if (*I) (*I)->Destroy(C);
74
75 for (instmeth_iterator I=instmeth_begin(), E=instmeth_end(); I!=E; ++I)
76 if (*I) (*I)->Destroy(C);
77
78 for (classmeth_iterator I=classmeth_begin(), E=classmeth_end(); I!=E; ++I)
79 if (*I) (*I)->Destroy(C);
Ted Kremenek1a726d72008-06-06 17:21:42 +000080
81 // FIXME: Because there is no clear ownership
82 // role between ObjCInterfaceDecls and the ObjCPropertyDecls that they
83 // reference, we destroy ObjCPropertyDecls in ~TranslationUnit.
84
Ted Kremenek8a779312008-06-06 16:45:15 +000085 Decl::Destroy(C);
86}
87
88
Chris Lattnerb048c982008-04-06 04:47:34 +000089ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, SourceLocation L,
Ted Kremenekb8db21d2008-07-23 18:04:17 +000090 IdentifierInfo *Id, QualType T,
91 AccessControl ac, Expr *BW) {
Chris Lattner0e77ba02008-03-16 01:15:50 +000092 void *Mem = C.getAllocator().Allocate<ObjCIvarDecl>();
Ted Kremenekb8db21d2008-07-23 18:04:17 +000093 return new (Mem) ObjCIvarDecl(L, Id, T, ac, BW);
Chris Lattner6c4ae5d2008-03-16 00:49:28 +000094}
95
Ted Kremenek01e67792008-08-20 03:26:33 +000096
97ObjCAtDefsFieldDecl
98*ObjCAtDefsFieldDecl::Create(ASTContext &C, SourceLocation L,
99 IdentifierInfo *Id, QualType T, Expr *BW) {
100 void *Mem = C.getAllocator().Allocate<ObjCAtDefsFieldDecl>();
101 return new (Mem) ObjCAtDefsFieldDecl(L, Id, T, BW);
102}
103
104void ObjCAtDefsFieldDecl::Destroy(ASTContext& C) {
105 this->~ObjCAtDefsFieldDecl();
106 C.getAllocator().Deallocate((void *)this);
107}
108
Chris Lattner0ed844b2008-04-04 06:12:32 +0000109ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C,
110 SourceLocation L,
Chris Lattnerc8581052008-03-16 20:19:15 +0000111 IdentifierInfo *Id) {
Chris Lattnercca59d72008-03-16 01:23:04 +0000112 void *Mem = C.getAllocator().Allocate<ObjCProtocolDecl>();
Chris Lattner780f3292008-07-21 21:32:27 +0000113 return new (Mem) ObjCProtocolDecl(L, Id);
Chris Lattnercca59d72008-03-16 01:23:04 +0000114}
115
Ted Kremenek1c8a4132008-06-06 19:48:57 +0000116ObjCProtocolDecl::~ObjCProtocolDecl() {
Ted Kremenek1c8a4132008-06-06 19:48:57 +0000117 delete [] InstanceMethods;
118 delete [] ClassMethods;
119 delete [] PropertyDecl;
120}
121
122void ObjCProtocolDecl::Destroy(ASTContext& C) {
123
124 // Referenced Protocols are not owned, so don't Destroy them.
125
126 for (instmeth_iterator I=instmeth_begin(), E=instmeth_end(); I!=E; ++I)
127 if (*I) (*I)->Destroy(C);
128
129 for (classmeth_iterator I=classmeth_begin(), E=classmeth_end(); I!=E; ++I)
130 if (*I) (*I)->Destroy(C);
131
132 // FIXME: Because there is no clear ownership
133 // role between ObjCProtocolDecls and the ObjCPropertyDecls that they
134 // reference, we destroy ObjCPropertyDecls in ~TranslationUnit.
135
136 Decl::Destroy(C);
137}
138
139
Chris Lattner0ed844b2008-04-04 06:12:32 +0000140ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C,
141 SourceLocation L,
Chris Lattner61f9d412008-03-16 20:34:23 +0000142 ObjCInterfaceDecl **Elts, unsigned nElts) {
143 void *Mem = C.getAllocator().Allocate<ObjCClassDecl>();
144 return new (Mem) ObjCClassDecl(L, Elts, nElts);
145}
146
Ted Kremenek400d95f2008-06-06 20:11:53 +0000147ObjCClassDecl::~ObjCClassDecl() {
148 delete [] ForwardDecls;
149}
150
151void ObjCClassDecl::Destroy(ASTContext& C) {
152
153 // FIXME: There is no clear ownership policy now for referenced
154 // ObjCInterfaceDecls. Some of them can be forward declarations that
155 // are never later defined (in which case the ObjCClassDecl owns them)
156 // or the ObjCInterfaceDecl later becomes a real definition later. Ideally
157 // we should have separate objects for forward declarations and definitions,
158 // obviating this problem. Because of this situation, referenced
159 // ObjCInterfaceDecls are destroyed in ~TranslationUnit.
160
161 Decl::Destroy(C);
162}
163
Chris Lattner61f9d412008-03-16 20:34:23 +0000164ObjCForwardProtocolDecl *
Chris Lattner0ed844b2008-04-04 06:12:32 +0000165ObjCForwardProtocolDecl::Create(ASTContext &C,
166 SourceLocation L,
Chris Lattner61f9d412008-03-16 20:34:23 +0000167 ObjCProtocolDecl **Elts, unsigned NumElts) {
168 void *Mem = C.getAllocator().Allocate<ObjCForwardProtocolDecl>();
169 return new (Mem) ObjCForwardProtocolDecl(L, Elts, NumElts);
170}
171
Ted Kremenek05ac3ef2008-06-06 21:05:33 +0000172ObjCForwardProtocolDecl::~ObjCForwardProtocolDecl() {
173 delete [] ReferencedProtocols;
174}
175
Chris Lattner0ed844b2008-04-04 06:12:32 +0000176ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C,
177 SourceLocation L,
Chris Lattner61f9d412008-03-16 20:34:23 +0000178 IdentifierInfo *Id) {
179 void *Mem = C.getAllocator().Allocate<ObjCCategoryDecl>();
Chris Lattner68c82cf2008-03-16 20:47:45 +0000180 return new (Mem) ObjCCategoryDecl(L, Id);
Chris Lattner61f9d412008-03-16 20:34:23 +0000181}
182
Chris Lattner75c9cae2008-03-16 20:53:07 +0000183ObjCCategoryImplDecl *
Chris Lattner0ed844b2008-04-04 06:12:32 +0000184ObjCCategoryImplDecl::Create(ASTContext &C,
185 SourceLocation L,IdentifierInfo *Id,
Chris Lattner75c9cae2008-03-16 20:53:07 +0000186 ObjCInterfaceDecl *ClassInterface) {
187 void *Mem = C.getAllocator().Allocate<ObjCCategoryImplDecl>();
188 return new (Mem) ObjCCategoryImplDecl(L, Id, ClassInterface);
189}
190
191ObjCImplementationDecl *
Chris Lattner0ed844b2008-04-04 06:12:32 +0000192ObjCImplementationDecl::Create(ASTContext &C,
193 SourceLocation L,
Chris Lattner75c9cae2008-03-16 20:53:07 +0000194 IdentifierInfo *Id,
195 ObjCInterfaceDecl *ClassInterface,
196 ObjCInterfaceDecl *SuperDecl) {
197 void *Mem = C.getAllocator().Allocate<ObjCImplementationDecl>();
198 return new (Mem) ObjCImplementationDecl(L, Id, ClassInterface, SuperDecl);
199}
Chris Lattner1e03a562008-03-16 00:19:01 +0000200
Chris Lattnerf8d17a52008-03-16 21:17:37 +0000201ObjCCompatibleAliasDecl *
Chris Lattner0ed844b2008-04-04 06:12:32 +0000202ObjCCompatibleAliasDecl::Create(ASTContext &C,
203 SourceLocation L,
Chris Lattnerf8d17a52008-03-16 21:17:37 +0000204 IdentifierInfo *Id,
205 ObjCInterfaceDecl* AliasedClass) {
206 void *Mem = C.getAllocator().Allocate<ObjCCompatibleAliasDecl>();
207 return new (Mem) ObjCCompatibleAliasDecl(L, Id, AliasedClass);
208}
209
Chris Lattner0ed844b2008-04-04 06:12:32 +0000210ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C,
Fariborz Jahaniandae1a1a2008-04-11 23:40:25 +0000211 SourceLocation L,
Fariborz Jahanian1de1e742008-04-14 23:36:35 +0000212 IdentifierInfo *Id,
Fariborz Jahanian46b55e52008-05-05 18:51:55 +0000213 QualType T,
214 PropertyControl propControl) {
Chris Lattnerf8d17a52008-03-16 21:17:37 +0000215 void *Mem = C.getAllocator().Allocate<ObjCPropertyDecl>();
Fariborz Jahanian1de1e742008-04-14 23:36:35 +0000216 return new (Mem) ObjCPropertyDecl(L, Id, T);
Chris Lattnerf8d17a52008-03-16 21:17:37 +0000217}
218
Chris Lattner1e03a562008-03-16 00:19:01 +0000219//===----------------------------------------------------------------------===//
220// Objective-C Decl Implementation
221//===----------------------------------------------------------------------===//
222
Daniel Dunbar08a356c2008-08-26 06:08:30 +0000223void ObjCMethodDecl::createImplicitParams(ASTContext &Context) {
224 QualType selfTy;
225 if (isInstance()) {
226 // There may be no interface context due to error in declaration
227 // of the interface (which has been reported). Recover gracefully.
228 if (ObjCInterfaceDecl *OID = getClassInterface()) {
229 selfTy = Context.getObjCInterfaceType(OID);
230 selfTy = Context.getPointerType(selfTy);
231 } else {
232 selfTy = Context.getObjCIdType();
233 }
234 } else // we have a factory method.
235 selfTy = Context.getObjCClassType();
236
237 SelfDecl = ImplicitParamDecl::Create(Context, this,
238 SourceLocation(),
239 &Context.Idents.get("self"),
240 selfTy, 0);
241
242 CmdDecl = ImplicitParamDecl::Create(Context, this,
243 SourceLocation(),
244 &Context.Idents.get("_cmd"),
245 Context.getObjCSelType(), 0);
246}
247
Chris Lattner1e03a562008-03-16 00:19:01 +0000248void ObjCMethodDecl::setMethodParams(ParmVarDecl **NewParamInfo,
249 unsigned NumParams) {
250 assert(ParamInfo == 0 && "Already has param info!");
251
252 // Zero params -> null pointer.
253 if (NumParams) {
254 ParamInfo = new ParmVarDecl*[NumParams];
255 memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams);
256 NumMethodParams = NumParams;
257 }
258}
259
Fariborz Jahanian31afbf02008-11-25 21:48:26 +0000260/// isPropertyReadonly - Return true if property is a readonly, by seaching
261/// for the property in the class and in its categories.
262///
263bool ObjCInterfaceDecl::isPropertyReadonly(ObjCPropertyDecl *PDecl) const
264{
265 if (PDecl->isReadOnly()) {
266 // Main class has the property as 'readyonly'. Must search
267 // through the category list to see if the property's
268 // attribute has been over-ridden to 'readwrite'.
269 for (ObjCCategoryDecl *Category = getCategoryList();
270 Category; Category = Category->getNextClassCategory()) {
271 PDecl= Category->FindPropertyDeclaration(PDecl->getIdentifier());
272 if (PDecl && !PDecl->isReadOnly())
273 return false;
274 }
275 return true;
276 }
277 return false;
278}
279
Fariborz Jahanian559c0c42008-04-21 19:04:53 +0000280/// FindPropertyDeclaration - Finds declaration of the property given its name
281/// in 'PropertyId' and returns it. It returns 0, if not found.
282///
283ObjCPropertyDecl *
284 ObjCInterfaceDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
285 for (ObjCInterfaceDecl::classprop_iterator I = classprop_begin(),
286 E = classprop_end(); I != E; ++I) {
287 ObjCPropertyDecl *property = *I;
288 if (property->getIdentifier() == PropertyId)
289 return property;
290 }
Steve Naroff6c930f22008-06-04 04:46:04 +0000291 // Look through categories.
292 for (ObjCCategoryDecl *Category = getCategoryList();
293 Category; Category = Category->getNextClassCategory()) {
294 ObjCPropertyDecl *property = Category->FindPropertyDeclaration(PropertyId);
295 if (property)
296 return property;
297 }
Steve Naroff3d2c22b2008-06-05 13:55:23 +0000298 // Look through protocols.
299 for (ObjCInterfaceDecl::protocol_iterator I = protocol_begin(),
300 E = protocol_end(); I != E; ++I) {
301 ObjCProtocolDecl *Protocol = *I;
302 ObjCPropertyDecl *property = Protocol->FindPropertyDeclaration(PropertyId);
303 if (property)
304 return property;
305 }
Fariborz Jahanianc70bee82008-04-21 23:57:08 +0000306 if (getSuperClass())
307 return getSuperClass()->FindPropertyDeclaration(PropertyId);
Fariborz Jahanian559c0c42008-04-21 19:04:53 +0000308 return 0;
309}
310
311/// FindCategoryDeclaration - Finds category declaration in the list of
312/// categories for this class and returns it. Name of the category is passed
313/// in 'CategoryId'. If category not found, return 0;
314///
315ObjCCategoryDecl *
316 ObjCInterfaceDecl::FindCategoryDeclaration(IdentifierInfo *CategoryId) const {
317 for (ObjCCategoryDecl *Category = getCategoryList();
318 Category; Category = Category->getNextClassCategory())
319 if (Category->getIdentifier() == CategoryId)
320 return Category;
321 return 0;
322}
323
324/// FindIvarDeclaration - Find an Ivar declaration in this class given its
325/// name in 'IvarId'. On failure to find, return 0;
326///
327ObjCIvarDecl *
328 ObjCInterfaceDecl::FindIvarDeclaration(IdentifierInfo *IvarId) const {
329 for (ObjCInterfaceDecl::ivar_iterator IVI = ivar_begin(),
330 IVE = ivar_end(); IVI != IVE; ++IVI) {
331 ObjCIvarDecl* Ivar = (*IVI);
332 if (Ivar->getIdentifier() == IvarId)
333 return Ivar;
334 }
Fariborz Jahanianc70bee82008-04-21 23:57:08 +0000335 if (getSuperClass())
336 return getSuperClass()->FindIvarDeclaration(IvarId);
Fariborz Jahanian559c0c42008-04-21 19:04:53 +0000337 return 0;
338}
339
Chris Lattner1e03a562008-03-16 00:19:01 +0000340/// ObjCAddInstanceVariablesToClass - Inserts instance variables
341/// into ObjCInterfaceDecl's fields.
342///
343void ObjCInterfaceDecl::addInstanceVariablesToClass(ObjCIvarDecl **ivars,
344 unsigned numIvars,
345 SourceLocation RBrac) {
346 NumIvars = numIvars;
347 if (numIvars) {
348 Ivars = new ObjCIvarDecl*[numIvars];
349 memcpy(Ivars, ivars, numIvars*sizeof(ObjCIvarDecl*));
350 }
351 setLocEnd(RBrac);
352}
353
354/// ObjCAddInstanceVariablesToClassImpl - Checks for correctness of Instance
355/// Variables (Ivars) relative to what declared in @implementation;s class.
356/// Ivars into ObjCImplementationDecl's fields.
357///
358void ObjCImplementationDecl::ObjCAddInstanceVariablesToClassImpl(
359 ObjCIvarDecl **ivars, unsigned numIvars) {
360 NumIvars = numIvars;
361 if (numIvars) {
362 Ivars = new ObjCIvarDecl*[numIvars];
363 memcpy(Ivars, ivars, numIvars*sizeof(ObjCIvarDecl*));
364 }
365}
366
367/// addMethods - Insert instance and methods declarations into
368/// ObjCInterfaceDecl's InsMethods and ClsMethods fields.
369///
370void ObjCInterfaceDecl::addMethods(ObjCMethodDecl **insMethods,
371 unsigned numInsMembers,
372 ObjCMethodDecl **clsMethods,
373 unsigned numClsMembers,
374 SourceLocation endLoc) {
375 NumInstanceMethods = numInsMembers;
376 if (numInsMembers) {
377 InstanceMethods = new ObjCMethodDecl*[numInsMembers];
378 memcpy(InstanceMethods, insMethods, numInsMembers*sizeof(ObjCMethodDecl*));
379 }
380 NumClassMethods = numClsMembers;
381 if (numClsMembers) {
382 ClassMethods = new ObjCMethodDecl*[numClsMembers];
383 memcpy(ClassMethods, clsMethods, numClsMembers*sizeof(ObjCMethodDecl*));
384 }
385 AtEndLoc = endLoc;
386}
387
Fariborz Jahanian7e7e3872008-04-16 21:08:45 +0000388/// addProperties - Insert property declaration AST nodes into
389/// ObjCInterfaceDecl's PropertyDecl field.
Chris Lattner55d13b42008-03-16 21:23:50 +0000390///
391void ObjCInterfaceDecl::addProperties(ObjCPropertyDecl **Properties,
392 unsigned NumProperties) {
393 if (NumProperties == 0) return;
394
395 NumPropertyDecl = NumProperties;
396 PropertyDecl = new ObjCPropertyDecl*[NumProperties];
397 memcpy(PropertyDecl, Properties, NumProperties*sizeof(ObjCPropertyDecl*));
398}
399
Fariborz Jahanianaebf0cb2008-05-02 19:17:30 +0000400/// mergeProperties - Adds properties to the end of list of current properties
401/// for this class.
402
403void ObjCInterfaceDecl::mergeProperties(ObjCPropertyDecl **Properties,
404 unsigned NumNewProperties) {
405 if (NumNewProperties == 0) return;
406
407 if (PropertyDecl) {
408 ObjCPropertyDecl **newPropertyDecl =
409 new ObjCPropertyDecl*[NumNewProperties + NumPropertyDecl];
410 ObjCPropertyDecl **buf = newPropertyDecl;
411 // put back original properties in buffer.
412 memcpy(buf, PropertyDecl, NumPropertyDecl*sizeof(ObjCPropertyDecl*));
413 // Add new properties to this buffer.
414 memcpy(buf+NumPropertyDecl, Properties,
415 NumNewProperties*sizeof(ObjCPropertyDecl*));
Nuno Lopes6b3502c2008-05-10 10:31:54 +0000416 delete[] PropertyDecl;
Fariborz Jahanianaebf0cb2008-05-02 19:17:30 +0000417 PropertyDecl = newPropertyDecl;
418 NumPropertyDecl += NumNewProperties;
419 }
420 else {
Nuno Lopes6b3502c2008-05-10 10:31:54 +0000421 addProperties(Properties, NumNewProperties);
Fariborz Jahanianaebf0cb2008-05-02 19:17:30 +0000422 }
423}
424
Daniel Dunbar7b473222008-08-27 02:09:39 +0000425static void
426addPropertyMethods(Decl *D,
427 ASTContext &Context,
428 ObjCPropertyDecl *property,
Fariborz Jahanianb85cce62008-12-02 00:19:12 +0000429 llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods,
430 llvm::DenseMap<Selector, const ObjCMethodDecl*> &InsMap) {
Daniel Dunbare86d9232008-08-27 05:13:46 +0000431 ObjCMethodDecl *GetterDecl, *SetterDecl = 0;
Fariborz Jahanianb85cce62008-12-02 00:19:12 +0000432
433 GetterDecl = const_cast<ObjCMethodDecl*>(InsMap[property->getGetterName()]);
434 if (!property->isReadOnly())
435 SetterDecl = const_cast<ObjCMethodDecl*>(InsMap[property->getSetterName()]);
436
Daniel Dunbar3216dcd2008-08-26 06:53:45 +0000437 // FIXME: The synthesized property we set here is misleading. We
438 // almost always synthesize these methods unless the user explicitly
439 // provided prototypes (which is odd, but allowed). Sema should be
440 // typechecking that the declarations jive in that situation (which
441 // it is not currently).
442
Fariborz Jahanian33de3f02008-05-07 17:43:59 +0000443 // Find the default getter and if one not found, add one.
Daniel Dunbar4d7da2f2008-08-26 02:32:45 +0000444 if (!GetterDecl) {
Fariborz Jahanian33de3f02008-05-07 17:43:59 +0000445 // No instance method of same name as property getter name was found.
446 // Declare a getter method and add it to the list of methods
447 // for this class.
Daniel Dunbar4d7da2f2008-08-26 02:32:45 +0000448 GetterDecl =
449 ObjCMethodDecl::Create(Context, property->getLocation(),
450 property->getLocation(),
451 property->getGetterName(),
452 property->getType(),
Daniel Dunbar7b473222008-08-27 02:09:39 +0000453 D,
Daniel Dunbar4d7da2f2008-08-26 02:32:45 +0000454 true, false, true, ObjCMethodDecl::Required);
455 insMethods.push_back(GetterDecl);
Fariborz Jahanianb85cce62008-12-02 00:19:12 +0000456 InsMap[property->getGetterName()] = GetterDecl;
Fariborz Jahanian33de3f02008-05-07 17:43:59 +0000457 }
Daniel Dunbar4d7da2f2008-08-26 02:32:45 +0000458 property->setGetterMethodDecl(GetterDecl);
459
Daniel Dunbar394d33f2008-08-26 07:16:44 +0000460 // Skip setter if property is read-only.
461 if (property->isReadOnly())
462 return;
463
Daniel Dunbar4d7da2f2008-08-26 02:32:45 +0000464 // Find the default setter and if one not found, add one.
Daniel Dunbar4d7da2f2008-08-26 02:32:45 +0000465 if (!SetterDecl) {
466 // No instance method of same name as property setter name was found.
467 // Declare a setter method and add it to the list of methods
468 // for this class.
469 SetterDecl =
470 ObjCMethodDecl::Create(Context, property->getLocation(),
471 property->getLocation(),
472 property->getSetterName(),
Daniel Dunbar5fa63312008-08-26 02:53:23 +0000473 Context.VoidTy,
Daniel Dunbar7b473222008-08-27 02:09:39 +0000474 D,
Daniel Dunbar4d7da2f2008-08-26 02:32:45 +0000475 true, false, true, ObjCMethodDecl::Required);
476 insMethods.push_back(SetterDecl);
Fariborz Jahanianb85cce62008-12-02 00:19:12 +0000477 InsMap[property->getSetterName()] = SetterDecl;
Daniel Dunbar4d7da2f2008-08-26 02:32:45 +0000478 // Invent the arguments for the setter. We don't bother making a
479 // nice name for the argument.
480 ParmVarDecl *Argument = ParmVarDecl::Create(Context,
481 SetterDecl,
482 SourceLocation(),
483 property->getIdentifier(),
484 property->getType(),
485 VarDecl::None,
486 0, 0);
487 SetterDecl->setMethodParams(&Argument, 1);
488 }
489 property->setSetterMethodDecl(SetterDecl);
Fariborz Jahanian33de3f02008-05-07 17:43:59 +0000490}
491
Daniel Dunbar7b473222008-08-27 02:09:39 +0000492/// addPropertyMethods - Goes through list of properties declared in this class
493/// and builds setter/getter method declartions depending on the setter/getter
494/// attributes of the property.
495///
496void ObjCInterfaceDecl::addPropertyMethods(
497 ASTContext &Context,
498 ObjCPropertyDecl *property,
Fariborz Jahanianb85cce62008-12-02 00:19:12 +0000499 llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods,
500 llvm::DenseMap<Selector, const ObjCMethodDecl*> &InsMap) {
501 ::addPropertyMethods(this, Context, property, insMethods, InsMap);
Daniel Dunbar7b473222008-08-27 02:09:39 +0000502}
503
504/// addPropertyMethods - Goes through list of properties declared in this class
505/// and builds setter/getter method declartions depending on the setter/getter
506/// attributes of the property.
507///
508void ObjCCategoryDecl::addPropertyMethods(
509 ASTContext &Context,
510 ObjCPropertyDecl *property,
Fariborz Jahanianb85cce62008-12-02 00:19:12 +0000511 llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods,
512 llvm::DenseMap<Selector, const ObjCMethodDecl*> &InsMap) {
513 ::addPropertyMethods(this, Context, property, insMethods, InsMap);
Daniel Dunbar7b473222008-08-27 02:09:39 +0000514}
515
Fariborz Jahanian1ac2bc42008-12-06 23:03:39 +0000516/// mergeProperties - Adds properties to the end of list of current properties
517/// for this category.
518
519void ObjCCategoryDecl::mergeProperties(ObjCPropertyDecl **Properties,
520 unsigned NumNewProperties) {
521 if (NumNewProperties == 0) return;
522
523 if (PropertyDecl) {
524 ObjCPropertyDecl **newPropertyDecl =
525 new ObjCPropertyDecl*[NumNewProperties + NumPropertyDecl];
526 ObjCPropertyDecl **buf = newPropertyDecl;
527 // put back original properties in buffer.
528 memcpy(buf, PropertyDecl, NumPropertyDecl*sizeof(ObjCPropertyDecl*));
529 // Add new properties to this buffer.
530 memcpy(buf+NumPropertyDecl, Properties,
531 NumNewProperties*sizeof(ObjCPropertyDecl*));
532 delete[] PropertyDecl;
533 PropertyDecl = newPropertyDecl;
534 NumPropertyDecl += NumNewProperties;
535 }
536 else {
537 addProperties(Properties, NumNewProperties);
538 }
539}
540
Daniel Dunbar7b473222008-08-27 02:09:39 +0000541/// addPropertyMethods - Goes through list of properties declared in this class
542/// and builds setter/getter method declartions depending on the setter/getter
543/// attributes of the property.
544///
545void ObjCProtocolDecl::addPropertyMethods(
546 ASTContext &Context,
547 ObjCPropertyDecl *property,
Fariborz Jahanianb85cce62008-12-02 00:19:12 +0000548 llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods,
549 llvm::DenseMap<Selector, const ObjCMethodDecl*> &InsMap) {
550 ::addPropertyMethods(this, Context, property, insMethods, InsMap);
Daniel Dunbar7b473222008-08-27 02:09:39 +0000551}
552
Fariborz Jahanian7e7e3872008-04-16 21:08:45 +0000553/// addProperties - Insert property declaration AST nodes into
Fariborz Jahanian3dd4ba42008-04-17 18:25:18 +0000554/// ObjCProtocolDecl's PropertyDecl field.
555///
556void ObjCProtocolDecl::addProperties(ObjCPropertyDecl **Properties,
557 unsigned NumProperties) {
558 if (NumProperties == 0) return;
559
560 NumPropertyDecl = NumProperties;
561 PropertyDecl = new ObjCPropertyDecl*[NumProperties];
562 memcpy(PropertyDecl, Properties, NumProperties*sizeof(ObjCPropertyDecl*));
563}
564
565/// addProperties - Insert property declaration AST nodes into
Fariborz Jahaniand9a3c332008-04-16 21:11:25 +0000566/// ObjCCategoryDecl's PropertyDecl field.
Fariborz Jahanian7e7e3872008-04-16 21:08:45 +0000567///
568void ObjCCategoryDecl::addProperties(ObjCPropertyDecl **Properties,
569 unsigned NumProperties) {
570 if (NumProperties == 0) return;
571
572 NumPropertyDecl = NumProperties;
573 PropertyDecl = new ObjCPropertyDecl*[NumProperties];
574 memcpy(PropertyDecl, Properties, NumProperties*sizeof(ObjCPropertyDecl*));
575}
576
Chris Lattner55d13b42008-03-16 21:23:50 +0000577/// addMethods - Insert instance and methods declarations into
Chris Lattner1e03a562008-03-16 00:19:01 +0000578/// ObjCProtocolDecl's ProtoInsMethods and ProtoClsMethods fields.
579///
580void ObjCProtocolDecl::addMethods(ObjCMethodDecl **insMethods,
581 unsigned numInsMembers,
582 ObjCMethodDecl **clsMethods,
583 unsigned numClsMembers,
584 SourceLocation endLoc) {
585 NumInstanceMethods = numInsMembers;
586 if (numInsMembers) {
587 InstanceMethods = new ObjCMethodDecl*[numInsMembers];
588 memcpy(InstanceMethods, insMethods, numInsMembers*sizeof(ObjCMethodDecl*));
589 }
590 NumClassMethods = numClsMembers;
591 if (numClsMembers) {
592 ClassMethods = new ObjCMethodDecl*[numClsMembers];
593 memcpy(ClassMethods, clsMethods, numClsMembers*sizeof(ObjCMethodDecl*));
594 }
595 AtEndLoc = endLoc;
596}
597
Chris Lattner68c82cf2008-03-16 20:47:45 +0000598
599
Chris Lattner1e03a562008-03-16 00:19:01 +0000600/// addMethods - Insert instance and methods declarations into
601/// ObjCCategoryDecl's CatInsMethods and CatClsMethods fields.
602///
603void ObjCCategoryDecl::addMethods(ObjCMethodDecl **insMethods,
604 unsigned numInsMembers,
605 ObjCMethodDecl **clsMethods,
606 unsigned numClsMembers,
607 SourceLocation endLoc) {
608 NumInstanceMethods = numInsMembers;
609 if (numInsMembers) {
610 InstanceMethods = new ObjCMethodDecl*[numInsMembers];
611 memcpy(InstanceMethods, insMethods, numInsMembers*sizeof(ObjCMethodDecl*));
612 }
613 NumClassMethods = numClsMembers;
614 if (numClsMembers) {
615 ClassMethods = new ObjCMethodDecl*[numClsMembers];
616 memcpy(ClassMethods, clsMethods, numClsMembers*sizeof(ObjCMethodDecl*));
617 }
618 AtEndLoc = endLoc;
619}
620
Fariborz Jahanian559c0c42008-04-21 19:04:53 +0000621/// FindPropertyDeclaration - Finds declaration of the property given its name
622/// in 'PropertyId' and returns it. It returns 0, if not found.
623///
624ObjCPropertyDecl *
625ObjCCategoryDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
626 for (ObjCCategoryDecl::classprop_iterator I = classprop_begin(),
627 E = classprop_end(); I != E; ++I) {
628 ObjCPropertyDecl *property = *I;
629 if (property->getIdentifier() == PropertyId)
630 return property;
631 }
632 return 0;
633}
634
Steve Naroff3d2c22b2008-06-05 13:55:23 +0000635/// FindPropertyDeclaration - Finds declaration of the property given its name
636/// in 'PropertyId' and returns it. It returns 0, if not found.
637///
638ObjCPropertyDecl *
639ObjCProtocolDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
640 for (ObjCProtocolDecl::classprop_iterator I = classprop_begin(),
641 E = classprop_end(); I != E; ++I) {
642 ObjCPropertyDecl *property = *I;
643 if (property->getIdentifier() == PropertyId)
644 return property;
645 }
646 return 0;
647}
648
Chris Lattner1e03a562008-03-16 00:19:01 +0000649ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(
650 IdentifierInfo *ID, ObjCInterfaceDecl *&clsDeclared) {
651 ObjCInterfaceDecl* ClassDecl = this;
652 while (ClassDecl != NULL) {
653 for (ivar_iterator I = ClassDecl->ivar_begin(), E = ClassDecl->ivar_end();
654 I != E; ++I) {
655 if ((*I)->getIdentifier() == ID) {
656 clsDeclared = ClassDecl;
657 return *I;
658 }
659 }
660 ClassDecl = ClassDecl->getSuperClass();
661 }
662 return NULL;
663}
664
665/// lookupInstanceMethod - This method returns an instance method by looking in
666/// the class, its categories, and its super classes (using a linear search).
667ObjCMethodDecl *ObjCInterfaceDecl::lookupInstanceMethod(Selector Sel) {
668 ObjCInterfaceDecl* ClassDecl = this;
669 ObjCMethodDecl *MethodDecl = 0;
670
671 while (ClassDecl != NULL) {
672 if ((MethodDecl = ClassDecl->getInstanceMethod(Sel)))
673 return MethodDecl;
674
675 // Didn't find one yet - look through protocols.
Chris Lattner3db6cae2008-07-21 18:19:38 +0000676 const ObjCList<ObjCProtocolDecl> &Protocols =
677 ClassDecl->getReferencedProtocols();
678 for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
679 E = Protocols.end(); I != E; ++I)
680 if ((MethodDecl = (*I)->getInstanceMethod(Sel)))
Chris Lattner1e03a562008-03-16 00:19:01 +0000681 return MethodDecl;
Chris Lattner3db6cae2008-07-21 18:19:38 +0000682
Chris Lattner1e03a562008-03-16 00:19:01 +0000683 // Didn't find one yet - now look through categories.
684 ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList();
685 while (CatDecl) {
686 if ((MethodDecl = CatDecl->getInstanceMethod(Sel)))
687 return MethodDecl;
Steve Naroffb79c01e2008-12-08 20:57:28 +0000688
689 // Didn't find one yet - look through protocols.
690 const ObjCList<ObjCProtocolDecl> &Protocols =
691 CatDecl->getReferencedProtocols();
692 for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
693 E = Protocols.end(); I != E; ++I)
694 if ((MethodDecl = (*I)->getInstanceMethod(Sel)))
695 return MethodDecl;
Chris Lattner1e03a562008-03-16 00:19:01 +0000696 CatDecl = CatDecl->getNextClassCategory();
697 }
698 ClassDecl = ClassDecl->getSuperClass();
699 }
700 return NULL;
701}
702
703// lookupClassMethod - This method returns a class method by looking in the
704// class, its categories, and its super classes (using a linear search).
705ObjCMethodDecl *ObjCInterfaceDecl::lookupClassMethod(Selector Sel) {
706 ObjCInterfaceDecl* ClassDecl = this;
707 ObjCMethodDecl *MethodDecl = 0;
708
709 while (ClassDecl != NULL) {
710 if ((MethodDecl = ClassDecl->getClassMethod(Sel)))
711 return MethodDecl;
712
713 // Didn't find one yet - look through protocols.
Chris Lattner780f3292008-07-21 21:32:27 +0000714 for (ObjCInterfaceDecl::protocol_iterator I = ClassDecl->protocol_begin(),
715 E = ClassDecl->protocol_end(); I != E; ++I)
Chris Lattner3db6cae2008-07-21 18:19:38 +0000716 if ((MethodDecl = (*I)->getClassMethod(Sel)))
Chris Lattner1e03a562008-03-16 00:19:01 +0000717 return MethodDecl;
Chris Lattner780f3292008-07-21 21:32:27 +0000718
Chris Lattner1e03a562008-03-16 00:19:01 +0000719 // Didn't find one yet - now look through categories.
720 ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList();
721 while (CatDecl) {
722 if ((MethodDecl = CatDecl->getClassMethod(Sel)))
723 return MethodDecl;
724 CatDecl = CatDecl->getNextClassCategory();
725 }
726 ClassDecl = ClassDecl->getSuperClass();
727 }
728 return NULL;
729}
730
Daniel Dunbar3216dcd2008-08-26 06:53:45 +0000731/// getInstanceMethod - This method returns an instance method by
732/// looking in the class implementation. Unlike interfaces, we don't
733/// look outside the implementation.
734ObjCMethodDecl *ObjCImplementationDecl::getInstanceMethod(Selector Sel) const {
Chris Lattner1e03a562008-03-16 00:19:01 +0000735 for (instmeth_iterator I = instmeth_begin(), E = instmeth_end(); I != E; ++I)
736 if ((*I)->getSelector() == Sel)
737 return *I;
738 return NULL;
739}
740
Daniel Dunbar3216dcd2008-08-26 06:53:45 +0000741/// getClassMethod - This method returns a class method by looking in
742/// the class implementation. Unlike interfaces, we don't look outside
743/// the implementation.
744ObjCMethodDecl *ObjCImplementationDecl::getClassMethod(Selector Sel) const {
Chris Lattner1e03a562008-03-16 00:19:01 +0000745 for (classmeth_iterator I = classmeth_begin(), E = classmeth_end();
746 I != E; ++I)
747 if ((*I)->getSelector() == Sel)
748 return *I;
749 return NULL;
750}
751
Fariborz Jahanianae6f6fd2008-12-05 22:32:48 +0000752/// FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl
753/// added to the list of those properties @synthesized/@dynamic in this
754/// @implementation block.
755///
756ObjCPropertyImplDecl *ObjCImplementationDecl::FindPropertyImplDecl(IdentifierInfo *Id) const {
757 for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i) {
758 ObjCPropertyImplDecl *PID = *i;
759 if (PID->getPropertyDecl()->getIdentifier() == Id)
760 return PID;
761 }
762 return 0;
763}
764
765/// FindPropertyImplIvarDecl - This method lookup the ivar in the list of
Fariborz Jahanian9482a4f2008-12-05 22:36:19 +0000766/// properties implemented in this @implementation block and returns the
767/// implemented property that uses it.
Fariborz Jahanianae6f6fd2008-12-05 22:32:48 +0000768///
769ObjCPropertyImplDecl *ObjCImplementationDecl::FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const {
770 for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i) {
771 ObjCPropertyImplDecl *PID = *i;
772 if (PID->getPropertyIvarDecl() &&
773 PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
774 return PID;
775 }
776 return 0;
777}
778
779/// FindPropertyImplIvarDecl - This method lookup the ivar in the list of
Fariborz Jahanian9482a4f2008-12-05 22:36:19 +0000780/// properties implemented in this category @implementation block and returns the
781/// implemented property that uses it.
Fariborz Jahanianae6f6fd2008-12-05 22:32:48 +0000782///
783ObjCPropertyImplDecl *ObjCCategoryImplDecl::FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const {
784 for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i) {
785 ObjCPropertyImplDecl *PID = *i;
786 if (PID->getPropertyIvarDecl() &&
787 PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
788 return PID;
789 }
790 return 0;
791}
792
793/// FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl
794/// added to the list of those properties @synthesized/@dynamic in this
795/// category @implementation block.
796///
797ObjCPropertyImplDecl *ObjCCategoryImplDecl::FindPropertyImplDecl(IdentifierInfo *Id) const {
798 for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i) {
799 ObjCPropertyImplDecl *PID = *i;
800 if (PID->getPropertyDecl()->getIdentifier() == Id)
801 return PID;
802 }
803 return 0;
804}
805
Chris Lattner1e03a562008-03-16 00:19:01 +0000806// lookupInstanceMethod - This method returns an instance method by looking in
807// the class implementation. Unlike interfaces, we don't look outside the
808// implementation.
Daniel Dunbar3216dcd2008-08-26 06:53:45 +0000809ObjCMethodDecl *ObjCCategoryImplDecl::getInstanceMethod(Selector Sel) const {
Chris Lattner1e03a562008-03-16 00:19:01 +0000810 for (instmeth_iterator I = instmeth_begin(), E = instmeth_end(); I != E; ++I)
811 if ((*I)->getSelector() == Sel)
812 return *I;
813 return NULL;
814}
815
816// lookupClassMethod - This method returns an instance method by looking in
817// the class implementation. Unlike interfaces, we don't look outside the
818// implementation.
Daniel Dunbar3216dcd2008-08-26 06:53:45 +0000819ObjCMethodDecl *ObjCCategoryImplDecl::getClassMethod(Selector Sel) const {
Chris Lattner1e03a562008-03-16 00:19:01 +0000820 for (classmeth_iterator I = classmeth_begin(), E = classmeth_end();
821 I != E; ++I)
822 if ((*I)->getSelector() == Sel)
823 return *I;
824 return NULL;
825}
826
827// lookupInstanceMethod - Lookup a instance method in the protocol and protocols
828// it inherited.
829ObjCMethodDecl *ObjCProtocolDecl::lookupInstanceMethod(Selector Sel) {
830 ObjCMethodDecl *MethodDecl = NULL;
831
832 if ((MethodDecl = getInstanceMethod(Sel)))
833 return MethodDecl;
834
Chris Lattner780f3292008-07-21 21:32:27 +0000835 for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I)
836 if ((MethodDecl = (*I)->getInstanceMethod(Sel)))
837 return MethodDecl;
Chris Lattner1e03a562008-03-16 00:19:01 +0000838 return NULL;
839}
840
841// lookupInstanceMethod - Lookup a class method in the protocol and protocols
842// it inherited.
843ObjCMethodDecl *ObjCProtocolDecl::lookupClassMethod(Selector Sel) {
844 ObjCMethodDecl *MethodDecl = NULL;
845
846 if ((MethodDecl = getClassMethod(Sel)))
847 return MethodDecl;
848
Chris Lattner780f3292008-07-21 21:32:27 +0000849 for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I)
850 if ((MethodDecl = (*I)->getClassMethod(Sel)))
851 return MethodDecl;
Chris Lattner1e03a562008-03-16 00:19:01 +0000852 return NULL;
853}
854
855/// getSynthesizedMethodSize - Compute size of synthesized method name
856/// as done be the rewrite.
857///
858unsigned ObjCMethodDecl::getSynthesizedMethodSize() const {
859 // syntesized method name is a concatenation of -/+[class-name selector]
860 // Get length of this name.
861 unsigned length = 3; // _I_ or _C_
Chris Lattner8ec03f52008-11-24 03:54:41 +0000862 length += getClassInterface()->getNameAsString().size()+1; // extra for _
Chris Lattner1e03a562008-03-16 00:19:01 +0000863 NamedDecl *MethodContext = getMethodContext();
864 if (ObjCCategoryImplDecl *CID =
865 dyn_cast<ObjCCategoryImplDecl>(MethodContext))
Chris Lattner8ec03f52008-11-24 03:54:41 +0000866 length += CID->getNameAsString().size()+1;
Chris Lattner077bf5e2008-11-24 03:33:13 +0000867 length += getSelector().getAsString().size(); // selector name
Chris Lattner1e03a562008-03-16 00:19:01 +0000868 return length;
869}
870
Chris Lattner56196882008-04-06 05:25:03 +0000871ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() {
Chris Lattner1e03a562008-03-16 00:19:01 +0000872 if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(MethodContext))
873 return ID;
874 if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(MethodContext))
875 return CD->getClassInterface();
876 if (ObjCImplementationDecl *IMD =
Chris Lattner56196882008-04-06 05:25:03 +0000877 dyn_cast<ObjCImplementationDecl>(MethodContext))
Chris Lattner1e03a562008-03-16 00:19:01 +0000878 return IMD->getClassInterface();
Chris Lattner56196882008-04-06 05:25:03 +0000879 if (ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(MethodContext))
Chris Lattner1e03a562008-03-16 00:19:01 +0000880 return CID->getClassInterface();
881 assert(false && "unknown method context");
882 return 0;
883}
Chris Lattnerf4af5152008-03-17 01:19:02 +0000884
Fariborz Jahanian628b96f2008-04-23 00:06:01 +0000885ObjCPropertyImplDecl *ObjCPropertyImplDecl::Create(ASTContext &C,
886 SourceLocation atLoc,
887 SourceLocation L,
888 ObjCPropertyDecl *property,
Daniel Dunbar9f0afd42008-08-26 04:47:31 +0000889 Kind PK,
Fariborz Jahanian628b96f2008-04-23 00:06:01 +0000890 ObjCIvarDecl *ivar) {
891 void *Mem = C.getAllocator().Allocate<ObjCPropertyImplDecl>();
Daniel Dunbar9f0afd42008-08-26 04:47:31 +0000892 return new (Mem) ObjCPropertyImplDecl(atLoc, L, property, PK, ivar);
Fariborz Jahanian628b96f2008-04-23 00:06:01 +0000893}
Chris Lattnerf4af5152008-03-17 01:19:02 +0000894
Chris Lattner0ed844b2008-04-04 06:12:32 +0000895