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