Chris Lattner | 10318b8 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 1 | //===--- 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 Dunbar | de30073 | 2008-08-11 04:54:23 +0000 | [diff] [blame] | 16 | #include "clang/AST/Stmt.h" |
Steve Naroff | d85ba92 | 2009-02-22 19:35:57 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 10318b8 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 18 | using namespace clang; |
| 19 | |
Chris Lattner | 114add6 | 2008-03-16 00:49:28 +0000 | [diff] [blame] | 20 | //===----------------------------------------------------------------------===// |
Chris Lattner | 217eb8c | 2009-02-20 21:16:26 +0000 | [diff] [blame] | 21 | // ObjCListBase |
| 22 | //===----------------------------------------------------------------------===// |
| 23 | |
Chris Lattner | df6133b | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 24 | void ObjCListBase::Destroy(ASTContext &Ctx) { |
Chris Lattner | cf6c828 | 2009-02-20 21:44:01 +0000 | [diff] [blame] | 25 | Ctx.Deallocate(List); |
Chris Lattner | 217eb8c | 2009-02-20 21:16:26 +0000 | [diff] [blame] | 26 | NumElts = 0; |
| 27 | List = 0; |
| 28 | } |
| 29 | |
Chris Lattner | df6133b | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 30 | void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) { |
Chris Lattner | 217eb8c | 2009-02-20 21:16:26 +0000 | [diff] [blame] | 31 | assert(List == 0 && "Elements already set!"); |
| 32 | if (Elts == 0) return; // Setting to an empty list is a noop. |
| 33 | |
Chris Lattner | cf6c828 | 2009-02-20 21:44:01 +0000 | [diff] [blame] | 34 | |
| 35 | List = new (Ctx) void*[Elts]; |
Chris Lattner | 217eb8c | 2009-02-20 21:16:26 +0000 | [diff] [blame] | 36 | NumElts = Elts; |
| 37 | memcpy(List, InList, sizeof(void*)*Elts); |
| 38 | } |
| 39 | |
| 40 | |
| 41 | //===----------------------------------------------------------------------===// |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 42 | // ObjCInterfaceDecl |
Chris Lattner | 114add6 | 2008-03-16 00:49:28 +0000 | [diff] [blame] | 43 | //===----------------------------------------------------------------------===// |
| 44 | |
Fariborz Jahanian | 074cf97 | 2009-06-05 18:16:35 +0000 | [diff] [blame] | 45 | /// getIvarDecl - This method looks up an ivar in this ContextDecl. |
| 46 | /// |
| 47 | ObjCIvarDecl * |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 48 | ObjCContainerDecl::getIvarDecl(IdentifierInfo *Id) const { |
Fariborz Jahanian | 074cf97 | 2009-06-05 18:16:35 +0000 | [diff] [blame] | 49 | lookup_const_iterator Ivar, IvarEnd; |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 50 | for (llvm::tie(Ivar, IvarEnd) = lookup(Id); Ivar != IvarEnd; ++Ivar) { |
Fariborz Jahanian | 074cf97 | 2009-06-05 18:16:35 +0000 | [diff] [blame] | 51 | if (ObjCIvarDecl *ivar = dyn_cast<ObjCIvarDecl>(*Ivar)) |
| 52 | return ivar; |
| 53 | } |
| 54 | return 0; |
| 55 | } |
| 56 | |
Argiris Kirtzidis | 7a7757b | 2009-07-25 22:15:22 +0000 | [diff] [blame] | 57 | // Get the local instance/class method declared in this interface. |
Douglas Gregor | c55b0b0 | 2009-04-09 21:40:53 +0000 | [diff] [blame] | 58 | ObjCMethodDecl * |
Argiris Kirtzidis | 7a7757b | 2009-07-25 22:15:22 +0000 | [diff] [blame] | 59 | ObjCContainerDecl::getMethod(Selector Sel, bool isInstance) const { |
Steve Naroff | d85ba92 | 2009-02-22 19:35:57 +0000 | [diff] [blame] | 60 | // 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; |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 69 | for (llvm::tie(Meth, MethEnd) = lookup(Sel); Meth != MethEnd; ++Meth) { |
Steve Naroff | d85ba92 | 2009-02-22 19:35:57 +0000 | [diff] [blame] | 70 | ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth); |
Argiris Kirtzidis | 7a7757b | 2009-07-25 22:15:22 +0000 | [diff] [blame] | 71 | if (MD && MD->isInstanceMethod() == isInstance) |
Steve Naroff | d85ba92 | 2009-02-22 19:35:57 +0000 | [diff] [blame] | 72 | return MD; |
| 73 | } |
Steve Naroff | ab63fd6 | 2009-01-08 17:28:14 +0000 | [diff] [blame] | 74 | return 0; |
| 75 | } |
| 76 | |
Fariborz Jahanian | ef8a3df | 2008-04-21 19:04:53 +0000 | [diff] [blame] | 77 | /// FindPropertyDeclaration - Finds declaration of the property given its name |
| 78 | /// in 'PropertyId' and returns it. It returns 0, if not found. |
Steve Naroff | dcf1e84 | 2009-01-11 12:47:58 +0000 | [diff] [blame] | 79 | /// FIXME: Convert to DeclContext lookup... |
Fariborz Jahanian | ef8a3df | 2008-04-21 19:04:53 +0000 | [diff] [blame] | 80 | /// |
| 81 | ObjCPropertyDecl * |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 82 | ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const { |
| 83 | for (prop_iterator I = prop_begin(), E = prop_end(); I != E; ++I) |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 84 | if ((*I)->getIdentifier() == PropertyId) |
| 85 | return *I; |
| 86 | |
Fariborz Jahanian | faca5e2 | 2009-01-09 21:04:52 +0000 | [diff] [blame] | 87 | const ObjCProtocolDecl *PID = dyn_cast<ObjCProtocolDecl>(this); |
| 88 | if (PID) { |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 89 | for (ObjCProtocolDecl::protocol_iterator I = PID->protocol_begin(), |
| 90 | E = PID->protocol_end(); I != E; ++I) |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 91 | if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId)) |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 92 | return P; |
Fariborz Jahanian | faca5e2 | 2009-01-09 21:04:52 +0000 | [diff] [blame] | 93 | } |
| 94 | |
Fariborz Jahanian | 6b0ed6f | 2009-01-19 18:16:19 +0000 | [diff] [blame] | 95 | if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(this)) { |
Steve Naroff | 451f83c | 2009-01-09 15:36:25 +0000 | [diff] [blame] | 96 | // Look through categories. |
| 97 | for (ObjCCategoryDecl *Category = OID->getCategoryList(); |
| 98 | Category; Category = Category->getNextClassCategory()) { |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 99 | if (ObjCPropertyDecl *P = Category->FindPropertyDeclaration(PropertyId)) |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 100 | return P; |
Steve Naroff | 451f83c | 2009-01-09 15:36:25 +0000 | [diff] [blame] | 101 | } |
| 102 | // Look through protocols. |
| 103 | for (ObjCInterfaceDecl::protocol_iterator I = OID->protocol_begin(), |
| 104 | E = OID->protocol_end(); I != E; ++I) { |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 105 | if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId)) |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 106 | return P; |
Steve Naroff | 451f83c | 2009-01-09 15:36:25 +0000 | [diff] [blame] | 107 | } |
| 108 | if (OID->getSuperClass()) |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 109 | return OID->getSuperClass()->FindPropertyDeclaration(PropertyId); |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 110 | } else if (const ObjCCategoryDecl *OCD = dyn_cast<ObjCCategoryDecl>(this)) { |
Fariborz Jahanian | 6b0ed6f | 2009-01-19 18:16:19 +0000 | [diff] [blame] | 111 | // Look through protocols. |
| 112 | for (ObjCInterfaceDecl::protocol_iterator I = OCD->protocol_begin(), |
| 113 | E = OCD->protocol_end(); I != E; ++I) { |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 114 | if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId)) |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 115 | return P; |
Fariborz Jahanian | 6b0ed6f | 2009-01-19 18:16:19 +0000 | [diff] [blame] | 116 | } |
| 117 | } |
Steve Naroff | d1f0eb4 | 2008-06-05 13:55:23 +0000 | [diff] [blame] | 118 | return 0; |
| 119 | } |
| 120 | |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 121 | ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(IdentifierInfo *ID, |
| 122 | ObjCInterfaceDecl *&clsDeclared) { |
Chris Lattner | 10318b8 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 123 | ObjCInterfaceDecl* ClassDecl = this; |
| 124 | while (ClassDecl != NULL) { |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 125 | if (ObjCIvarDecl *I = ClassDecl->getIvarDecl(ID)) { |
Fariborz Jahanian | 074cf97 | 2009-06-05 18:16:35 +0000 | [diff] [blame] | 126 | clsDeclared = ClassDecl; |
| 127 | return I; |
Chris Lattner | 10318b8 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 128 | } |
| 129 | ClassDecl = ClassDecl->getSuperClass(); |
| 130 | } |
| 131 | return NULL; |
| 132 | } |
| 133 | |
Fariborz Jahanian | c0672e4 | 2009-05-22 17:12:32 +0000 | [diff] [blame] | 134 | /// lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super |
| 135 | /// class whose name is passed as argument. If it is not one of the super classes |
| 136 | /// the it returns NULL. |
| 137 | ObjCInterfaceDecl *ObjCInterfaceDecl::lookupInheritedClass( |
| 138 | const IdentifierInfo*ICName) { |
| 139 | ObjCInterfaceDecl* ClassDecl = this; |
| 140 | while (ClassDecl != NULL) { |
| 141 | if (ClassDecl->getIdentifier() == ICName) |
| 142 | return ClassDecl; |
| 143 | ClassDecl = ClassDecl->getSuperClass(); |
| 144 | } |
| 145 | return NULL; |
| 146 | } |
| 147 | |
Argiris Kirtzidis | 9ac39f3 | 2009-07-25 22:15:51 +0000 | [diff] [blame] | 148 | /// lookupMethod - This method returns an instance/class method by looking in |
Chris Lattner | 10318b8 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 149 | /// the class, its categories, and its super classes (using a linear search). |
Argiris Kirtzidis | 9ac39f3 | 2009-07-25 22:15:51 +0000 | [diff] [blame] | 150 | ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, |
| 151 | bool isInstance) const { |
| 152 | const ObjCInterfaceDecl* ClassDecl = this; |
Chris Lattner | 10318b8 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 153 | ObjCMethodDecl *MethodDecl = 0; |
| 154 | |
| 155 | while (ClassDecl != NULL) { |
Argiris Kirtzidis | 9ac39f3 | 2009-07-25 22:15:51 +0000 | [diff] [blame] | 156 | if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance))) |
Chris Lattner | 10318b8 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 157 | return MethodDecl; |
| 158 | |
| 159 | // Didn't find one yet - look through protocols. |
Chris Lattner | 8bcb525 | 2008-07-21 18:19:38 +0000 | [diff] [blame] | 160 | const ObjCList<ObjCProtocolDecl> &Protocols = |
| 161 | ClassDecl->getReferencedProtocols(); |
| 162 | for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(), |
| 163 | E = Protocols.end(); I != E; ++I) |
Argiris Kirtzidis | 9ac39f3 | 2009-07-25 22:15:51 +0000 | [diff] [blame] | 164 | if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance))) |
Chris Lattner | 10318b8 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 165 | return MethodDecl; |
Chris Lattner | 8bcb525 | 2008-07-21 18:19:38 +0000 | [diff] [blame] | 166 | |
Chris Lattner | 10318b8 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 167 | // Didn't find one yet - now look through categories. |
| 168 | ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList(); |
| 169 | while (CatDecl) { |
Argiris Kirtzidis | 9ac39f3 | 2009-07-25 22:15:51 +0000 | [diff] [blame] | 170 | if ((MethodDecl = CatDecl->getMethod(Sel, isInstance))) |
Chris Lattner | 10318b8 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 171 | return MethodDecl; |
Steve Naroff | af15180 | 2008-12-08 20:57:28 +0000 | [diff] [blame] | 172 | |
| 173 | // Didn't find one yet - look through protocols. |
| 174 | const ObjCList<ObjCProtocolDecl> &Protocols = |
| 175 | CatDecl->getReferencedProtocols(); |
| 176 | for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(), |
| 177 | E = Protocols.end(); I != E; ++I) |
Argiris Kirtzidis | 9ac39f3 | 2009-07-25 22:15:51 +0000 | [diff] [blame] | 178 | if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance))) |
Steve Naroff | 0ba2484 | 2009-02-26 11:32:02 +0000 | [diff] [blame] | 179 | return MethodDecl; |
Chris Lattner | 10318b8 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 180 | CatDecl = CatDecl->getNextClassCategory(); |
| 181 | } |
| 182 | ClassDecl = ClassDecl->getSuperClass(); |
| 183 | } |
| 184 | return NULL; |
| 185 | } |
| 186 | |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 187 | |
| 188 | |
| 189 | //===----------------------------------------------------------------------===// |
| 190 | // ObjCMethodDecl |
| 191 | //===----------------------------------------------------------------------===// |
| 192 | |
| 193 | ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C, |
| 194 | SourceLocation beginLoc, |
| 195 | SourceLocation endLoc, |
| 196 | Selector SelInfo, QualType T, |
| 197 | DeclContext *contextDecl, |
| 198 | bool isInstance, |
| 199 | bool isVariadic, |
| 200 | bool isSynthesized, |
| 201 | ImplementationControl impControl) { |
| 202 | return new (C) ObjCMethodDecl(beginLoc, endLoc, |
| 203 | SelInfo, T, contextDecl, |
| 204 | isInstance, |
| 205 | isVariadic, isSynthesized, impControl); |
Chris Lattner | 10318b8 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 206 | } |
| 207 | |
Chris Lattner | df6133b | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 208 | void ObjCMethodDecl::Destroy(ASTContext &C) { |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 209 | if (Body) Body->Destroy(C); |
| 210 | if (SelfDecl) SelfDecl->Destroy(C); |
| 211 | |
| 212 | for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I) |
| 213 | if (*I) (*I)->Destroy(C); |
| 214 | |
Chris Lattner | df6133b | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 215 | ParamInfo.Destroy(C); |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 216 | |
| 217 | Decl::Destroy(C); |
Chris Lattner | 10318b8 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 218 | } |
| 219 | |
Argiris Kirtzidis | 29c3387 | 2009-07-21 00:06:36 +0000 | [diff] [blame] | 220 | /// \brief A definition will return its interface declaration. |
| 221 | /// An interface declaration will return its definition. |
| 222 | /// Otherwise it will return itself. |
| 223 | ObjCMethodDecl *ObjCMethodDecl::getNextRedeclaration() { |
| 224 | ASTContext &Ctx = getASTContext(); |
| 225 | ObjCMethodDecl *Redecl = 0; |
| 226 | Decl *CtxD = cast<Decl>(getDeclContext()); |
| 227 | |
| 228 | if (ObjCInterfaceDecl *IFD = dyn_cast<ObjCInterfaceDecl>(CtxD)) { |
| 229 | if (ObjCImplementationDecl *ImplD = Ctx.getObjCImplementation(IFD)) |
| 230 | Redecl = ImplD->getMethod(getSelector(), isInstanceMethod()); |
| 231 | |
| 232 | } else if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(CtxD)) { |
| 233 | if (ObjCCategoryImplDecl *ImplD = Ctx.getObjCImplementation(CD)) |
| 234 | Redecl = ImplD->getMethod(getSelector(), isInstanceMethod()); |
| 235 | |
Argiris Kirtzidis | 0f3b842 | 2009-07-28 05:11:05 +0000 | [diff] [blame^] | 236 | } else if (ObjCImplementationDecl *ImplD = |
| 237 | dyn_cast<ObjCImplementationDecl>(CtxD)) { |
Argiris Kirtzidis | 29c3387 | 2009-07-21 00:06:36 +0000 | [diff] [blame] | 238 | if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface()) |
| 239 | Redecl = IFD->getMethod(getSelector(), isInstanceMethod()); |
Argiris Kirtzidis | 0f3b842 | 2009-07-28 05:11:05 +0000 | [diff] [blame^] | 240 | |
| 241 | } else if (ObjCCategoryImplDecl *CImplD = |
| 242 | dyn_cast<ObjCCategoryImplDecl>(CtxD)) { |
| 243 | if (ObjCCategoryDecl *CatD = CImplD->getCategoryClass()) |
| 244 | Redecl = CatD->getMethod(getSelector(), isInstanceMethod()); |
Argiris Kirtzidis | 29c3387 | 2009-07-21 00:06:36 +0000 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | return Redecl ? Redecl : this; |
| 248 | } |
| 249 | |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 250 | void ObjCMethodDecl::createImplicitParams(ASTContext &Context, |
| 251 | const ObjCInterfaceDecl *OID) { |
| 252 | QualType selfTy; |
| 253 | if (isInstanceMethod()) { |
| 254 | // There may be no interface context due to error in declaration |
| 255 | // of the interface (which has been reported). Recover gracefully. |
| 256 | if (OID) { |
Daniel Dunbar | be1ff27 | 2009-04-22 04:34:53 +0000 | [diff] [blame] | 257 | selfTy = Context.getObjCInterfaceType(OID); |
Steve Naroff | 329ec22 | 2009-07-10 23:34:53 +0000 | [diff] [blame] | 258 | selfTy = Context.getObjCObjectPointerType(selfTy); |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 259 | } else { |
| 260 | selfTy = Context.getObjCIdType(); |
| 261 | } |
| 262 | } else // we have a factory method. |
| 263 | selfTy = Context.getObjCClassType(); |
| 264 | |
Steve Naroff | 79ea0e0 | 2009-04-20 15:06:07 +0000 | [diff] [blame] | 265 | setSelfDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(), |
| 266 | &Context.Idents.get("self"), selfTy)); |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 267 | |
Steve Naroff | 79ea0e0 | 2009-04-20 15:06:07 +0000 | [diff] [blame] | 268 | setCmdDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(), |
| 269 | &Context.Idents.get("_cmd"), |
| 270 | Context.getObjCSelType())); |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | |
| 274 | |
| 275 | /// getSynthesizedMethodSize - Compute size of synthesized method name |
| 276 | /// as done be the rewrite. |
Fariborz Jahanian | 6834228 | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 277 | /// |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 278 | unsigned ObjCMethodDecl::getSynthesizedMethodSize() const { |
| 279 | // syntesized method name is a concatenation of -/+[class-name selector] |
| 280 | // Get length of this name. |
| 281 | unsigned length = 3; // _I_ or _C_ |
| 282 | length += getClassInterface()->getNameAsString().size()+1; // extra for _ |
| 283 | if (const ObjCCategoryImplDecl *CID = |
| 284 | dyn_cast<ObjCCategoryImplDecl>(getDeclContext())) |
| 285 | length += CID->getNameAsString().size()+1; |
| 286 | length += getSelector().getAsString().size(); // selector name |
| 287 | return length; |
| 288 | } |
| 289 | |
| 290 | ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() { |
| 291 | if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(getDeclContext())) |
| 292 | return ID; |
| 293 | if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(getDeclContext())) |
| 294 | return CD->getClassInterface(); |
Argiris Kirtzidis | a06e3ba | 2009-07-28 05:10:52 +0000 | [diff] [blame] | 295 | if (ObjCImplDecl *IMD = dyn_cast<ObjCImplDecl>(getDeclContext())) |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 296 | return IMD->getClassInterface(); |
Argiris Kirtzidis | a06e3ba | 2009-07-28 05:10:52 +0000 | [diff] [blame] | 297 | |
| 298 | assert(!isa<ObjCProtocolDecl>(getDeclContext()) && "It's a protocol method"); |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 299 | assert(false && "unknown method context"); |
Fariborz Jahanian | 6834228 | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 300 | return 0; |
| 301 | } |
| 302 | |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 303 | //===----------------------------------------------------------------------===// |
| 304 | // ObjCInterfaceDecl |
| 305 | //===----------------------------------------------------------------------===// |
| 306 | |
| 307 | ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C, |
| 308 | DeclContext *DC, |
| 309 | SourceLocation atLoc, |
| 310 | IdentifierInfo *Id, |
| 311 | SourceLocation ClassLoc, |
| 312 | bool ForwardDecl, bool isInternal){ |
| 313 | return new (C) ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, ForwardDecl, |
| 314 | isInternal); |
| 315 | } |
| 316 | |
| 317 | ObjCInterfaceDecl:: |
| 318 | ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, |
| 319 | SourceLocation CLoc, bool FD, bool isInternal) |
| 320 | : ObjCContainerDecl(ObjCInterface, DC, atLoc, Id), |
| 321 | TypeForDecl(0), SuperClass(0), |
| 322 | CategoryList(0), ForwardDecl(FD), InternalInterface(isInternal), |
| 323 | ClassLoc(CLoc) { |
| 324 | } |
| 325 | |
| 326 | void ObjCInterfaceDecl::Destroy(ASTContext &C) { |
Chris Lattner | eff36ed | 2009-03-31 08:36:08 +0000 | [diff] [blame] | 327 | for (ivar_iterator I = ivar_begin(), E = ivar_end(); I != E; ++I) |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 328 | if (*I) (*I)->Destroy(C); |
| 329 | |
Chris Lattner | df6133b | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 330 | IVars.Destroy(C); |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 331 | // FIXME: CategoryList? |
| 332 | |
| 333 | // FIXME: Because there is no clear ownership |
| 334 | // role between ObjCInterfaceDecls and the ObjCPropertyDecls that they |
| 335 | // reference, we destroy ObjCPropertyDecls in ~TranslationUnit. |
| 336 | Decl::Destroy(C); |
| 337 | } |
| 338 | |
Argiris Kirtzidis | 3a4d983 | 2009-07-21 00:05:53 +0000 | [diff] [blame] | 339 | ObjCImplementationDecl *ObjCInterfaceDecl::getImplementation() const { |
| 340 | return getASTContext().getObjCImplementation( |
| 341 | const_cast<ObjCInterfaceDecl*>(this)); |
| 342 | } |
| 343 | |
| 344 | void ObjCInterfaceDecl::setImplementation(ObjCImplementationDecl *ImplD) { |
| 345 | getASTContext().setObjCImplementation(this, ImplD); |
| 346 | } |
| 347 | |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 348 | |
| 349 | /// FindCategoryDeclaration - Finds category declaration in the list of |
| 350 | /// categories for this class and returns it. Name of the category is passed |
| 351 | /// in 'CategoryId'. If category not found, return 0; |
Fariborz Jahanian | 6834228 | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 352 | /// |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 353 | ObjCCategoryDecl * |
| 354 | ObjCInterfaceDecl::FindCategoryDeclaration(IdentifierInfo *CategoryId) const { |
| 355 | for (ObjCCategoryDecl *Category = getCategoryList(); |
| 356 | Category; Category = Category->getNextClassCategory()) |
| 357 | if (Category->getIdentifier() == CategoryId) |
| 358 | return Category; |
Fariborz Jahanian | 6834228 | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 359 | return 0; |
| 360 | } |
| 361 | |
Argiris Kirtzidis | 2009686 | 2009-07-21 00:06:20 +0000 | [diff] [blame] | 362 | ObjCMethodDecl * |
| 363 | ObjCInterfaceDecl::getCategoryInstanceMethod(Selector Sel) const { |
| 364 | for (ObjCCategoryDecl *Category = getCategoryList(); |
| 365 | Category; Category = Category->getNextClassCategory()) |
| 366 | if (ObjCCategoryImplDecl *Impl = Category->getImplementation()) |
| 367 | if (ObjCMethodDecl *MD = Impl->getInstanceMethod(Sel)) |
| 368 | return MD; |
| 369 | return 0; |
| 370 | } |
| 371 | |
| 372 | ObjCMethodDecl *ObjCInterfaceDecl::getCategoryClassMethod(Selector Sel) const { |
| 373 | for (ObjCCategoryDecl *Category = getCategoryList(); |
| 374 | Category; Category = Category->getNextClassCategory()) |
| 375 | if (ObjCCategoryImplDecl *Impl = Category->getImplementation()) |
| 376 | if (ObjCMethodDecl *MD = Impl->getClassMethod(Sel)) |
| 377 | return MD; |
| 378 | return 0; |
| 379 | } |
| 380 | |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 381 | //===----------------------------------------------------------------------===// |
| 382 | // ObjCIvarDecl |
| 383 | //===----------------------------------------------------------------------===// |
| 384 | |
| 385 | ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, DeclContext *DC, |
| 386 | SourceLocation L, IdentifierInfo *Id, |
| 387 | QualType T, AccessControl ac, Expr *BW) { |
| 388 | return new (C) ObjCIvarDecl(DC, L, Id, T, ac, BW); |
| 389 | } |
| 390 | |
| 391 | |
| 392 | |
| 393 | //===----------------------------------------------------------------------===// |
| 394 | // ObjCAtDefsFieldDecl |
| 395 | //===----------------------------------------------------------------------===// |
| 396 | |
| 397 | ObjCAtDefsFieldDecl |
| 398 | *ObjCAtDefsFieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, |
| 399 | IdentifierInfo *Id, QualType T, Expr *BW) { |
| 400 | return new (C) ObjCAtDefsFieldDecl(DC, L, Id, T, BW); |
| 401 | } |
| 402 | |
| 403 | void ObjCAtDefsFieldDecl::Destroy(ASTContext& C) { |
| 404 | this->~ObjCAtDefsFieldDecl(); |
| 405 | C.Deallocate((void *)this); |
| 406 | } |
| 407 | |
| 408 | //===----------------------------------------------------------------------===// |
| 409 | // ObjCProtocolDecl |
| 410 | //===----------------------------------------------------------------------===// |
| 411 | |
| 412 | ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC, |
| 413 | SourceLocation L, |
| 414 | IdentifierInfo *Id) { |
| 415 | return new (C) ObjCProtocolDecl(DC, L, Id); |
| 416 | } |
| 417 | |
| 418 | void ObjCProtocolDecl::Destroy(ASTContext &C) { |
Chris Lattner | df6133b | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 419 | ReferencedProtocols.Destroy(C); |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 420 | ObjCContainerDecl::Destroy(C); |
| 421 | } |
| 422 | |
Steve Naroff | 98e71b8 | 2009-03-01 16:12:44 +0000 | [diff] [blame] | 423 | ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) { |
| 424 | ObjCProtocolDecl *PDecl = this; |
| 425 | |
| 426 | if (Name == getIdentifier()) |
| 427 | return PDecl; |
| 428 | |
| 429 | for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I) |
| 430 | if ((PDecl = (*I)->lookupProtocolNamed(Name))) |
| 431 | return PDecl; |
| 432 | |
| 433 | return NULL; |
| 434 | } |
| 435 | |
Argiris Kirtzidis | aba400c | 2009-07-25 22:15:38 +0000 | [diff] [blame] | 436 | // lookupMethod - Lookup a instance/class method in the protocol and protocols |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 437 | // it inherited. |
Argiris Kirtzidis | aba400c | 2009-07-25 22:15:38 +0000 | [diff] [blame] | 438 | ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel, |
| 439 | bool isInstance) const { |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 440 | ObjCMethodDecl *MethodDecl = NULL; |
| 441 | |
Argiris Kirtzidis | aba400c | 2009-07-25 22:15:38 +0000 | [diff] [blame] | 442 | if ((MethodDecl = getMethod(Sel, isInstance))) |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 443 | return MethodDecl; |
| 444 | |
| 445 | for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I) |
Argiris Kirtzidis | aba400c | 2009-07-25 22:15:38 +0000 | [diff] [blame] | 446 | if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance))) |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 447 | return MethodDecl; |
| 448 | return NULL; |
| 449 | } |
| 450 | |
| 451 | //===----------------------------------------------------------------------===// |
| 452 | // ObjCClassDecl |
| 453 | //===----------------------------------------------------------------------===// |
| 454 | |
Chris Lattner | df6133b | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 455 | ObjCClassDecl::ObjCClassDecl(DeclContext *DC, SourceLocation L, |
| 456 | ObjCInterfaceDecl *const *Elts, unsigned nElts, |
| 457 | ASTContext &C) |
| 458 | : Decl(ObjCClass, DC, L) { |
| 459 | ForwardDecls.set(Elts, nElts, C); |
| 460 | } |
| 461 | |
| 462 | |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 463 | ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC, |
| 464 | SourceLocation L, |
| 465 | ObjCInterfaceDecl *const *Elts, |
| 466 | unsigned nElts) { |
Chris Lattner | df6133b | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 467 | return new (C) ObjCClassDecl(DC, L, Elts, nElts, C); |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | void ObjCClassDecl::Destroy(ASTContext &C) { |
| 471 | |
| 472 | // FIXME: There is no clear ownership policy now for referenced |
| 473 | // ObjCInterfaceDecls. Some of them can be forward declarations that |
| 474 | // are never later defined (in which case the ObjCClassDecl owns them) |
| 475 | // or the ObjCInterfaceDecl later becomes a real definition later. Ideally |
| 476 | // we should have separate objects for forward declarations and definitions, |
| 477 | // obviating this problem. Because of this situation, referenced |
| 478 | // ObjCInterfaceDecls are destroyed in ~TranslationUnit. |
| 479 | |
Chris Lattner | df6133b | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 480 | ForwardDecls.Destroy(C); |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 481 | Decl::Destroy(C); |
| 482 | } |
| 483 | |
| 484 | //===----------------------------------------------------------------------===// |
| 485 | // ObjCForwardProtocolDecl |
| 486 | //===----------------------------------------------------------------------===// |
| 487 | |
Chris Lattner | df6133b | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 488 | ObjCForwardProtocolDecl:: |
| 489 | ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L, |
| 490 | ObjCProtocolDecl *const *Elts, unsigned nElts, |
| 491 | ASTContext &C) |
| 492 | : Decl(ObjCForwardProtocol, DC, L) { |
| 493 | ReferencedProtocols.set(Elts, nElts, C); |
| 494 | } |
| 495 | |
| 496 | |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 497 | ObjCForwardProtocolDecl * |
| 498 | ObjCForwardProtocolDecl::Create(ASTContext &C, DeclContext *DC, |
| 499 | SourceLocation L, |
| 500 | ObjCProtocolDecl *const *Elts, |
| 501 | unsigned NumElts) { |
Chris Lattner | df6133b | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 502 | return new (C) ObjCForwardProtocolDecl(DC, L, Elts, NumElts, C); |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | void ObjCForwardProtocolDecl::Destroy(ASTContext &C) { |
Chris Lattner | df6133b | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 506 | ReferencedProtocols.Destroy(C); |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 507 | Decl::Destroy(C); |
| 508 | } |
| 509 | |
| 510 | //===----------------------------------------------------------------------===// |
| 511 | // ObjCCategoryDecl |
| 512 | //===----------------------------------------------------------------------===// |
| 513 | |
| 514 | ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, DeclContext *DC, |
| 515 | SourceLocation L, |
| 516 | IdentifierInfo *Id) { |
| 517 | return new (C) ObjCCategoryDecl(DC, L, Id); |
| 518 | } |
| 519 | |
Argiris Kirtzidis | 3a4d983 | 2009-07-21 00:05:53 +0000 | [diff] [blame] | 520 | ObjCCategoryImplDecl *ObjCCategoryDecl::getImplementation() const { |
| 521 | return getASTContext().getObjCImplementation( |
| 522 | const_cast<ObjCCategoryDecl*>(this)); |
| 523 | } |
| 524 | |
| 525 | void ObjCCategoryDecl::setImplementation(ObjCCategoryImplDecl *ImplD) { |
| 526 | getASTContext().setObjCImplementation(this, ImplD); |
| 527 | } |
| 528 | |
| 529 | |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 530 | //===----------------------------------------------------------------------===// |
| 531 | // ObjCCategoryImplDecl |
| 532 | //===----------------------------------------------------------------------===// |
| 533 | |
| 534 | ObjCCategoryImplDecl * |
| 535 | ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC, |
| 536 | SourceLocation L,IdentifierInfo *Id, |
| 537 | ObjCInterfaceDecl *ClassInterface) { |
| 538 | return new (C) ObjCCategoryImplDecl(DC, L, Id, ClassInterface); |
| 539 | } |
| 540 | |
Argiris Kirtzidis | 0f3b842 | 2009-07-28 05:11:05 +0000 | [diff] [blame^] | 541 | ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryClass() const { |
| 542 | return getClassInterface()->FindCategoryDeclaration(getIdentifier()); |
| 543 | } |
| 544 | |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 545 | |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 546 | void ObjCImplDecl::addPropertyImplementation(ObjCPropertyImplDecl *property) { |
Douglas Gregor | bd336c5 | 2009-04-23 02:42:49 +0000 | [diff] [blame] | 547 | // FIXME: The context should be correct before we get here. |
Douglas Gregor | cd19b57 | 2009-04-23 01:02:12 +0000 | [diff] [blame] | 548 | property->setLexicalDeclContext(this); |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 549 | addDecl(property); |
Douglas Gregor | cd19b57 | 2009-04-23 01:02:12 +0000 | [diff] [blame] | 550 | } |
| 551 | |
Argiris Kirtzidis | 3a4d983 | 2009-07-21 00:05:53 +0000 | [diff] [blame] | 552 | void ObjCImplDecl::setClassInterface(ObjCInterfaceDecl *IFace) { |
| 553 | ASTContext &Ctx = getASTContext(); |
| 554 | |
| 555 | if (ObjCImplementationDecl *ImplD |
Duncan Sands | 57f4dfe | 2009-07-21 07:56:29 +0000 | [diff] [blame] | 556 | = dyn_cast_or_null<ObjCImplementationDecl>(this)) { |
Argiris Kirtzidis | 3a4d983 | 2009-07-21 00:05:53 +0000 | [diff] [blame] | 557 | if (IFace) |
| 558 | Ctx.setObjCImplementation(IFace, ImplD); |
| 559 | |
Duncan Sands | 57f4dfe | 2009-07-21 07:56:29 +0000 | [diff] [blame] | 560 | } else if (ObjCCategoryImplDecl *ImplD = |
Argiris Kirtzidis | 3a4d983 | 2009-07-21 00:05:53 +0000 | [diff] [blame] | 561 | dyn_cast_or_null<ObjCCategoryImplDecl>(this)) { |
| 562 | if (ObjCCategoryDecl *CD = IFace->FindCategoryDeclaration(getIdentifier())) |
| 563 | Ctx.setObjCImplementation(CD, ImplD); |
| 564 | } |
| 565 | |
| 566 | ClassInterface = IFace; |
| 567 | } |
| 568 | |
Fariborz Jahanian | 6834228 | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 569 | /// FindPropertyImplIvarDecl - This method lookup the ivar in the list of |
Chris Lattner | 715e848 | 2009-02-16 19:24:31 +0000 | [diff] [blame] | 570 | /// properties implemented in this category @implementation block and returns |
| 571 | /// the implemented property that uses it. |
Fariborz Jahanian | 6834228 | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 572 | /// |
Chris Lattner | 649b3da | 2009-02-28 18:42:10 +0000 | [diff] [blame] | 573 | ObjCPropertyImplDecl *ObjCImplDecl:: |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 574 | FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const { |
| 575 | for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i){ |
Fariborz Jahanian | 6834228 | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 576 | ObjCPropertyImplDecl *PID = *i; |
| 577 | if (PID->getPropertyIvarDecl() && |
| 578 | PID->getPropertyIvarDecl()->getIdentifier() == ivarId) |
| 579 | return PID; |
| 580 | } |
| 581 | return 0; |
| 582 | } |
| 583 | |
| 584 | /// FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl |
| 585 | /// added to the list of those properties @synthesized/@dynamic in this |
| 586 | /// category @implementation block. |
| 587 | /// |
Chris Lattner | 649b3da | 2009-02-28 18:42:10 +0000 | [diff] [blame] | 588 | ObjCPropertyImplDecl *ObjCImplDecl:: |
Argiris Kirtzidis | ab6e38a | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 589 | FindPropertyImplDecl(IdentifierInfo *Id) const { |
| 590 | for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i){ |
Fariborz Jahanian | 6834228 | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 591 | ObjCPropertyImplDecl *PID = *i; |
| 592 | if (PID->getPropertyDecl()->getIdentifier() == Id) |
| 593 | return PID; |
| 594 | } |
| 595 | return 0; |
| 596 | } |
| 597 | |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 598 | //===----------------------------------------------------------------------===// |
| 599 | // ObjCImplementationDecl |
| 600 | //===----------------------------------------------------------------------===// |
| 601 | |
| 602 | ObjCImplementationDecl * |
| 603 | ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC, |
| 604 | SourceLocation L, |
| 605 | ObjCInterfaceDecl *ClassInterface, |
| 606 | ObjCInterfaceDecl *SuperDecl) { |
| 607 | return new (C) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl); |
| 608 | } |
| 609 | |
Chris Lattner | 13f6360 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 610 | //===----------------------------------------------------------------------===// |
| 611 | // ObjCCompatibleAliasDecl |
| 612 | //===----------------------------------------------------------------------===// |
| 613 | |
| 614 | ObjCCompatibleAliasDecl * |
| 615 | ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC, |
| 616 | SourceLocation L, |
| 617 | IdentifierInfo *Id, |
| 618 | ObjCInterfaceDecl* AliasedClass) { |
| 619 | return new (C) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass); |
| 620 | } |
| 621 | |
| 622 | //===----------------------------------------------------------------------===// |
| 623 | // ObjCPropertyDecl |
| 624 | //===----------------------------------------------------------------------===// |
| 625 | |
| 626 | ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, DeclContext *DC, |
| 627 | SourceLocation L, |
| 628 | IdentifierInfo *Id, |
| 629 | QualType T, |
| 630 | PropertyControl propControl) { |
| 631 | return new (C) ObjCPropertyDecl(DC, L, Id, T); |
| 632 | } |
| 633 | |
| 634 | |
| 635 | //===----------------------------------------------------------------------===// |
| 636 | // ObjCPropertyImplDecl |
| 637 | //===----------------------------------------------------------------------===// |
| 638 | |
Fariborz Jahanian | dc0569e | 2008-04-23 00:06:01 +0000 | [diff] [blame] | 639 | ObjCPropertyImplDecl *ObjCPropertyImplDecl::Create(ASTContext &C, |
Douglas Gregor | 6e4fa2c | 2009-01-09 00:49:46 +0000 | [diff] [blame] | 640 | DeclContext *DC, |
Fariborz Jahanian | dc0569e | 2008-04-23 00:06:01 +0000 | [diff] [blame] | 641 | SourceLocation atLoc, |
| 642 | SourceLocation L, |
| 643 | ObjCPropertyDecl *property, |
Daniel Dunbar | 14117fc | 2008-08-26 04:47:31 +0000 | [diff] [blame] | 644 | Kind PK, |
Fariborz Jahanian | dc0569e | 2008-04-23 00:06:01 +0000 | [diff] [blame] | 645 | ObjCIvarDecl *ivar) { |
Steve Naroff | 5abb028 | 2009-01-27 21:25:57 +0000 | [diff] [blame] | 646 | return new (C) ObjCPropertyImplDecl(DC, atLoc, L, property, PK, ivar); |
Fariborz Jahanian | dc0569e | 2008-04-23 00:06:01 +0000 | [diff] [blame] | 647 | } |
Chris Lattner | 4485961 | 2008-03-17 01:19:02 +0000 | [diff] [blame] | 648 | |
Chris Lattner | eee57c0 | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 649 | |