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::set(void *const* InList, unsigned Elts, ASTContext &Ctx) { |
Douglas Gregor | ff331c1 | 2010-07-25 18:17:45 +0000 | [diff] [blame] | 25 | List = 0; |
Chris Lattner | 11e1e1a | 2009-02-20 21:16:26 +0000 | [diff] [blame] | 26 | if (Elts == 0) return; // Setting to an empty list is a noop. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 27 | |
| 28 | |
Chris Lattner | 4ee413b | 2009-02-20 21:44:01 +0000 | [diff] [blame] | 29 | List = new (Ctx) void*[Elts]; |
Chris Lattner | 11e1e1a | 2009-02-20 21:16:26 +0000 | [diff] [blame] | 30 | NumElts = Elts; |
| 31 | memcpy(List, InList, sizeof(void*)*Elts); |
| 32 | } |
| 33 | |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 34 | void ObjCProtocolList::set(ObjCProtocolDecl* const* InList, unsigned Elts, |
| 35 | const SourceLocation *Locs, ASTContext &Ctx) { |
| 36 | if (Elts == 0) |
| 37 | return; |
| 38 | |
| 39 | Locations = new (Ctx) SourceLocation[Elts]; |
| 40 | memcpy(Locations, Locs, sizeof(SourceLocation) * Elts); |
| 41 | set(InList, Elts, Ctx); |
| 42 | } |
| 43 | |
Chris Lattner | 11e1e1a | 2009-02-20 21:16:26 +0000 | [diff] [blame] | 44 | //===----------------------------------------------------------------------===// |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 45 | // ObjCInterfaceDecl |
Chris Lattner | 6c4ae5d | 2008-03-16 00:49:28 +0000 | [diff] [blame] | 46 | //===----------------------------------------------------------------------===// |
| 47 | |
Fariborz Jahanian | 496b5a8 | 2009-06-05 18:16:35 +0000 | [diff] [blame] | 48 | /// getIvarDecl - This method looks up an ivar in this ContextDecl. |
| 49 | /// |
| 50 | ObjCIvarDecl * |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 51 | ObjCContainerDecl::getIvarDecl(IdentifierInfo *Id) const { |
Fariborz Jahanian | 496b5a8 | 2009-06-05 18:16:35 +0000 | [diff] [blame] | 52 | lookup_const_iterator Ivar, IvarEnd; |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 53 | for (llvm::tie(Ivar, IvarEnd) = lookup(Id); Ivar != IvarEnd; ++Ivar) { |
Fariborz Jahanian | 496b5a8 | 2009-06-05 18:16:35 +0000 | [diff] [blame] | 54 | if (ObjCIvarDecl *ivar = dyn_cast<ObjCIvarDecl>(*Ivar)) |
| 55 | return ivar; |
| 56 | } |
| 57 | return 0; |
| 58 | } |
| 59 | |
Argyrios Kyrtzidis | 467c0b1 | 2009-07-25 22:15:22 +0000 | [diff] [blame] | 60 | // Get the local instance/class method declared in this interface. |
Douglas Gregor | 6ab3524 | 2009-04-09 21:40:53 +0000 | [diff] [blame] | 61 | ObjCMethodDecl * |
Argyrios Kyrtzidis | 467c0b1 | 2009-07-25 22:15:22 +0000 | [diff] [blame] | 62 | ObjCContainerDecl::getMethod(Selector Sel, bool isInstance) const { |
Steve Naroff | 0de21fd | 2009-02-22 19:35:57 +0000 | [diff] [blame] | 63 | // Since instance & class methods can have the same name, the loop below |
| 64 | // ensures we get the correct method. |
| 65 | // |
| 66 | // @interface Whatever |
| 67 | // - (int) class_method; |
| 68 | // + (float) class_method; |
| 69 | // @end |
| 70 | // |
| 71 | lookup_const_iterator Meth, MethEnd; |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 72 | for (llvm::tie(Meth, MethEnd) = lookup(Sel); Meth != MethEnd; ++Meth) { |
Steve Naroff | 0de21fd | 2009-02-22 19:35:57 +0000 | [diff] [blame] | 73 | ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth); |
Argyrios Kyrtzidis | 467c0b1 | 2009-07-25 22:15:22 +0000 | [diff] [blame] | 74 | if (MD && MD->isInstanceMethod() == isInstance) |
Steve Naroff | 0de21fd | 2009-02-22 19:35:57 +0000 | [diff] [blame] | 75 | return MD; |
| 76 | } |
Steve Naroff | 0701bbb | 2009-01-08 17:28:14 +0000 | [diff] [blame] | 77 | return 0; |
| 78 | } |
| 79 | |
Ted Kremenek | 9f550ff | 2010-03-15 20:11:46 +0000 | [diff] [blame] | 80 | ObjCPropertyDecl * |
Ted Kremenek | de09d0c | 2010-03-15 20:11:53 +0000 | [diff] [blame] | 81 | ObjCPropertyDecl::findPropertyDecl(const DeclContext *DC, |
Ted Kremenek | 9f550ff | 2010-03-15 20:11:46 +0000 | [diff] [blame] | 82 | IdentifierInfo *propertyID) { |
| 83 | |
Ted Kremenek | de09d0c | 2010-03-15 20:11:53 +0000 | [diff] [blame] | 84 | DeclContext::lookup_const_iterator I, E; |
Ted Kremenek | 9f550ff | 2010-03-15 20:11:46 +0000 | [diff] [blame] | 85 | llvm::tie(I, E) = DC->lookup(propertyID); |
| 86 | for ( ; I != E; ++I) |
| 87 | if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(*I)) |
| 88 | return PD; |
| 89 | |
| 90 | return 0; |
| 91 | } |
| 92 | |
Fariborz Jahanian | 559c0c4 | 2008-04-21 19:04:53 +0000 | [diff] [blame] | 93 | /// FindPropertyDeclaration - Finds declaration of the property given its name |
| 94 | /// in 'PropertyId' and returns it. It returns 0, if not found. |
Fariborz Jahanian | 559c0c4 | 2008-04-21 19:04:53 +0000 | [diff] [blame] | 95 | ObjCPropertyDecl * |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 96 | ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 97 | |
Ted Kremenek | de09d0c | 2010-03-15 20:11:53 +0000 | [diff] [blame] | 98 | if (ObjCPropertyDecl *PD = |
| 99 | ObjCPropertyDecl::findPropertyDecl(cast<DeclContext>(this), PropertyId)) |
| 100 | return PD; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 101 | |
Ted Kremenek | de09d0c | 2010-03-15 20:11:53 +0000 | [diff] [blame] | 102 | switch (getKind()) { |
| 103 | default: |
| 104 | break; |
| 105 | case Decl::ObjCProtocol: { |
| 106 | const ObjCProtocolDecl *PID = cast<ObjCProtocolDecl>(this); |
| 107 | for (ObjCProtocolDecl::protocol_iterator I = PID->protocol_begin(), |
| 108 | E = PID->protocol_end(); I != E; ++I) |
Fariborz Jahanian | 2576061 | 2010-02-15 21:55:26 +0000 | [diff] [blame] | 109 | if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId)) |
| 110 | return P; |
Ted Kremenek | de09d0c | 2010-03-15 20:11:53 +0000 | [diff] [blame] | 111 | break; |
| 112 | } |
| 113 | case Decl::ObjCInterface: { |
| 114 | const ObjCInterfaceDecl *OID = cast<ObjCInterfaceDecl>(this); |
| 115 | // Look through categories. |
| 116 | for (ObjCCategoryDecl *Cat = OID->getCategoryList(); |
| 117 | Cat; Cat = Cat->getNextClassCategory()) |
| 118 | if (!Cat->IsClassExtension()) |
| 119 | if (ObjCPropertyDecl *P = Cat->FindPropertyDeclaration(PropertyId)) |
| 120 | return P; |
| 121 | |
| 122 | // Look through protocols. |
| 123 | for (ObjCInterfaceDecl::protocol_iterator |
| 124 | I = OID->protocol_begin(), E = OID->protocol_end(); I != E; ++I) |
| 125 | if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId)) |
| 126 | return P; |
| 127 | |
| 128 | // Finally, check the super class. |
| 129 | if (const ObjCInterfaceDecl *superClass = OID->getSuperClass()) |
| 130 | return superClass->FindPropertyDeclaration(PropertyId); |
| 131 | break; |
| 132 | } |
| 133 | case Decl::ObjCCategory: { |
| 134 | const ObjCCategoryDecl *OCD = cast<ObjCCategoryDecl>(this); |
| 135 | // Look through protocols. |
| 136 | if (!OCD->IsClassExtension()) |
| 137 | for (ObjCCategoryDecl::protocol_iterator |
| 138 | I = OCD->protocol_begin(), E = OCD->protocol_end(); I != E; ++I) |
| 139 | if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId)) |
| 140 | return P; |
| 141 | |
| 142 | break; |
Fariborz Jahanian | f034e9c | 2009-01-19 18:16:19 +0000 | [diff] [blame] | 143 | } |
| 144 | } |
Steve Naroff | 3d2c22b | 2008-06-05 13:55:23 +0000 | [diff] [blame] | 145 | return 0; |
| 146 | } |
| 147 | |
Fariborz Jahanian | a6f14e1 | 2009-11-02 22:45:15 +0000 | [diff] [blame] | 148 | /// FindPropertyVisibleInPrimaryClass - Finds declaration of the property |
| 149 | /// with name 'PropertyId' in the primary class; including those in protocols |
Ted Kremenek | 37cafb0 | 2010-03-15 20:30:07 +0000 | [diff] [blame] | 150 | /// (direct or indirect) used by the primary class. |
Fariborz Jahanian | a6f14e1 | 2009-11-02 22:45:15 +0000 | [diff] [blame] | 151 | /// |
| 152 | ObjCPropertyDecl * |
Ted Kremenek | 37cafb0 | 2010-03-15 20:30:07 +0000 | [diff] [blame] | 153 | ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass( |
Fariborz Jahanian | a6f14e1 | 2009-11-02 22:45:15 +0000 | [diff] [blame] | 154 | IdentifierInfo *PropertyId) const { |
Ted Kremenek | 37cafb0 | 2010-03-15 20:30:07 +0000 | [diff] [blame] | 155 | if (ObjCPropertyDecl *PD = |
| 156 | ObjCPropertyDecl::findPropertyDecl(cast<DeclContext>(this), PropertyId)) |
| 157 | return PD; |
| 158 | |
Fariborz Jahanian | a6f14e1 | 2009-11-02 22:45:15 +0000 | [diff] [blame] | 159 | // Look through protocols. |
Ted Kremenek | 37cafb0 | 2010-03-15 20:30:07 +0000 | [diff] [blame] | 160 | for (ObjCInterfaceDecl::protocol_iterator |
| 161 | I = protocol_begin(), E = protocol_end(); I != E; ++I) |
Fariborz Jahanian | a6f14e1 | 2009-11-02 22:45:15 +0000 | [diff] [blame] | 162 | if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId)) |
| 163 | return P; |
Ted Kremenek | 37cafb0 | 2010-03-15 20:30:07 +0000 | [diff] [blame] | 164 | |
Fariborz Jahanian | a6f14e1 | 2009-11-02 22:45:15 +0000 | [diff] [blame] | 165 | return 0; |
| 166 | } |
| 167 | |
Fariborz Jahanian | 339798e | 2009-10-05 20:41:32 +0000 | [diff] [blame] | 168 | void ObjCInterfaceDecl::mergeClassExtensionProtocolList( |
| 169 | ObjCProtocolDecl *const* ExtList, unsigned ExtNum, |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 170 | const SourceLocation *Locs, |
Fariborz Jahanian | 339798e | 2009-10-05 20:41:32 +0000 | [diff] [blame] | 171 | ASTContext &C) |
| 172 | { |
| 173 | if (ReferencedProtocols.empty()) { |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 174 | ReferencedProtocols.set(ExtList, ExtNum, Locs, C); |
Fariborz Jahanian | 339798e | 2009-10-05 20:41:32 +0000 | [diff] [blame] | 175 | return; |
| 176 | } |
| 177 | // Check for duplicate protocol in class's protocol list. |
| 178 | // This is (O)2. But it is extremely rare and number of protocols in |
| 179 | // class or its extension are very few. |
| 180 | llvm::SmallVector<ObjCProtocolDecl*, 8> ProtocolRefs; |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 181 | llvm::SmallVector<SourceLocation, 8> ProtocolLocs; |
Fariborz Jahanian | 339798e | 2009-10-05 20:41:32 +0000 | [diff] [blame] | 182 | for (unsigned i = 0; i < ExtNum; i++) { |
| 183 | bool protocolExists = false; |
| 184 | ObjCProtocolDecl *ProtoInExtension = ExtList[i]; |
| 185 | for (protocol_iterator p = protocol_begin(), e = protocol_end(); |
| 186 | p != e; p++) { |
| 187 | ObjCProtocolDecl *Proto = (*p); |
| 188 | if (C.ProtocolCompatibleWithProtocol(ProtoInExtension, Proto)) { |
| 189 | protocolExists = true; |
| 190 | break; |
| 191 | } |
| 192 | } |
| 193 | // Do we want to warn on a protocol in extension class which |
| 194 | // already exist in the class? Probably not. |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 195 | if (!protocolExists) { |
Fariborz Jahanian | 339798e | 2009-10-05 20:41:32 +0000 | [diff] [blame] | 196 | ProtocolRefs.push_back(ProtoInExtension); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 197 | ProtocolLocs.push_back(Locs[i]); |
| 198 | } |
Fariborz Jahanian | 339798e | 2009-10-05 20:41:32 +0000 | [diff] [blame] | 199 | } |
| 200 | if (ProtocolRefs.empty()) |
| 201 | return; |
Fariborz Jahanian | b106fc6 | 2009-10-05 21:32:49 +0000 | [diff] [blame] | 202 | // Merge ProtocolRefs into class's protocol list; |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 203 | protocol_loc_iterator pl = protocol_loc_begin(); |
Fariborz Jahanian | 339798e | 2009-10-05 20:41:32 +0000 | [diff] [blame] | 204 | for (protocol_iterator p = protocol_begin(), e = protocol_end(); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 205 | p != e; ++p, ++pl) { |
Fariborz Jahanian | 339798e | 2009-10-05 20:41:32 +0000 | [diff] [blame] | 206 | ProtocolRefs.push_back(*p); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 207 | ProtocolLocs.push_back(*pl); |
| 208 | } |
Fariborz Jahanian | 339798e | 2009-10-05 20:41:32 +0000 | [diff] [blame] | 209 | unsigned NumProtoRefs = ProtocolRefs.size(); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 210 | setProtocolList(ProtocolRefs.data(), NumProtoRefs, ProtocolLocs.data(), C); |
Fariborz Jahanian | 339798e | 2009-10-05 20:41:32 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Fariborz Jahanian | 80aa1cd | 2010-06-22 23:20:40 +0000 | [diff] [blame] | 213 | /// getFirstClassExtension - Find first class extension of the given class. |
| 214 | ObjCCategoryDecl* ObjCInterfaceDecl::getFirstClassExtension() const { |
| 215 | for (ObjCCategoryDecl *CDecl = getCategoryList(); CDecl; |
Fariborz Jahanian | 0e5ad25 | 2010-02-23 01:26:30 +0000 | [diff] [blame] | 216 | CDecl = CDecl->getNextClassCategory()) |
| 217 | if (CDecl->IsClassExtension()) |
| 218 | return CDecl; |
| 219 | return 0; |
| 220 | } |
| 221 | |
Fariborz Jahanian | 80aa1cd | 2010-06-22 23:20:40 +0000 | [diff] [blame] | 222 | /// getNextClassCategory - Find next class extension in list of categories. |
| 223 | const ObjCCategoryDecl* ObjCCategoryDecl::getNextClassExtension() const { |
| 224 | for (const ObjCCategoryDecl *CDecl = getNextClassCategory(); CDecl; |
| 225 | CDecl = CDecl->getNextClassCategory()) |
| 226 | if (CDecl->IsClassExtension()) |
| 227 | return CDecl; |
| 228 | return 0; |
| 229 | } |
| 230 | |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 231 | ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(IdentifierInfo *ID, |
| 232 | ObjCInterfaceDecl *&clsDeclared) { |
Chris Lattner | 1e03a56 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 233 | ObjCInterfaceDecl* ClassDecl = this; |
| 234 | while (ClassDecl != NULL) { |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 235 | if (ObjCIvarDecl *I = ClassDecl->getIvarDecl(ID)) { |
Fariborz Jahanian | 496b5a8 | 2009-06-05 18:16:35 +0000 | [diff] [blame] | 236 | clsDeclared = ClassDecl; |
| 237 | return I; |
Chris Lattner | 1e03a56 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 238 | } |
Fariborz Jahanian | 80aa1cd | 2010-06-22 23:20:40 +0000 | [diff] [blame] | 239 | for (const ObjCCategoryDecl *CDecl = ClassDecl->getFirstClassExtension(); |
| 240 | CDecl; CDecl = CDecl->getNextClassExtension()) { |
Fariborz Jahanian | 0e5ad25 | 2010-02-23 01:26:30 +0000 | [diff] [blame] | 241 | if (ObjCIvarDecl *I = CDecl->getIvarDecl(ID)) { |
| 242 | clsDeclared = ClassDecl; |
| 243 | return I; |
| 244 | } |
Fariborz Jahanian | 80aa1cd | 2010-06-22 23:20:40 +0000 | [diff] [blame] | 245 | } |
Fariborz Jahanian | 0e5ad25 | 2010-02-23 01:26:30 +0000 | [diff] [blame] | 246 | |
Chris Lattner | 1e03a56 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 247 | ClassDecl = ClassDecl->getSuperClass(); |
| 248 | } |
| 249 | return NULL; |
| 250 | } |
| 251 | |
Fariborz Jahanian | cd18762 | 2009-05-22 17:12:32 +0000 | [diff] [blame] | 252 | /// lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super |
| 253 | /// class whose name is passed as argument. If it is not one of the super classes |
| 254 | /// the it returns NULL. |
| 255 | ObjCInterfaceDecl *ObjCInterfaceDecl::lookupInheritedClass( |
| 256 | const IdentifierInfo*ICName) { |
| 257 | ObjCInterfaceDecl* ClassDecl = this; |
| 258 | while (ClassDecl != NULL) { |
| 259 | if (ClassDecl->getIdentifier() == ICName) |
| 260 | return ClassDecl; |
| 261 | ClassDecl = ClassDecl->getSuperClass(); |
| 262 | } |
| 263 | return NULL; |
| 264 | } |
| 265 | |
Argyrios Kyrtzidis | aa5420c | 2009-07-25 22:15:51 +0000 | [diff] [blame] | 266 | /// lookupMethod - This method returns an instance/class method by looking in |
Chris Lattner | 1e03a56 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 267 | /// the class, its categories, and its super classes (using a linear search). |
Argyrios Kyrtzidis | aa5420c | 2009-07-25 22:15:51 +0000 | [diff] [blame] | 268 | ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, |
| 269 | bool isInstance) const { |
| 270 | const ObjCInterfaceDecl* ClassDecl = this; |
Chris Lattner | 1e03a56 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 271 | ObjCMethodDecl *MethodDecl = 0; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 272 | |
Chris Lattner | 1e03a56 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 273 | while (ClassDecl != NULL) { |
Argyrios Kyrtzidis | aa5420c | 2009-07-25 22:15:51 +0000 | [diff] [blame] | 274 | if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance))) |
Chris Lattner | 1e03a56 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 275 | return MethodDecl; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 276 | |
Chris Lattner | 1e03a56 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 277 | // Didn't find one yet - look through protocols. |
Chris Lattner | 3db6cae | 2008-07-21 18:19:38 +0000 | [diff] [blame] | 278 | const ObjCList<ObjCProtocolDecl> &Protocols = |
| 279 | ClassDecl->getReferencedProtocols(); |
| 280 | for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(), |
| 281 | E = Protocols.end(); I != E; ++I) |
Argyrios Kyrtzidis | aa5420c | 2009-07-25 22:15:51 +0000 | [diff] [blame] | 282 | if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance))) |
Chris Lattner | 1e03a56 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 283 | return MethodDecl; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 284 | |
Chris Lattner | 1e03a56 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 285 | // Didn't find one yet - now look through categories. |
| 286 | ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList(); |
| 287 | while (CatDecl) { |
Argyrios Kyrtzidis | aa5420c | 2009-07-25 22:15:51 +0000 | [diff] [blame] | 288 | if ((MethodDecl = CatDecl->getMethod(Sel, isInstance))) |
Chris Lattner | 1e03a56 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 289 | return MethodDecl; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 290 | |
Steve Naroff | b79c01e | 2008-12-08 20:57:28 +0000 | [diff] [blame] | 291 | // Didn't find one yet - look through protocols. |
| 292 | const ObjCList<ObjCProtocolDecl> &Protocols = |
| 293 | CatDecl->getReferencedProtocols(); |
| 294 | for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(), |
| 295 | E = Protocols.end(); I != E; ++I) |
Argyrios Kyrtzidis | aa5420c | 2009-07-25 22:15:51 +0000 | [diff] [blame] | 296 | if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance))) |
Steve Naroff | b558422 | 2009-02-26 11:32:02 +0000 | [diff] [blame] | 297 | return MethodDecl; |
Chris Lattner | 1e03a56 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 298 | CatDecl = CatDecl->getNextClassCategory(); |
| 299 | } |
| 300 | ClassDecl = ClassDecl->getSuperClass(); |
| 301 | } |
| 302 | return NULL; |
| 303 | } |
| 304 | |
Steve Naroff | d789d3d | 2009-10-01 23:46:04 +0000 | [diff] [blame] | 305 | ObjCMethodDecl *ObjCInterfaceDecl::lookupPrivateInstanceMethod( |
| 306 | const Selector &Sel) { |
| 307 | ObjCMethodDecl *Method = 0; |
| 308 | if (ObjCImplementationDecl *ImpDecl = getImplementation()) |
| 309 | Method = ImpDecl->getInstanceMethod(Sel); |
| 310 | |
| 311 | if (!Method && getSuperClass()) |
| 312 | return getSuperClass()->lookupPrivateInstanceMethod(Sel); |
| 313 | return Method; |
| 314 | } |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 315 | |
| 316 | //===----------------------------------------------------------------------===// |
| 317 | // ObjCMethodDecl |
| 318 | //===----------------------------------------------------------------------===// |
| 319 | |
| 320 | ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 321 | SourceLocation beginLoc, |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 322 | SourceLocation endLoc, |
| 323 | Selector SelInfo, QualType T, |
Douglas Gregor | 4bc1cb6 | 2010-03-08 14:59:44 +0000 | [diff] [blame] | 324 | TypeSourceInfo *ResultTInfo, |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 325 | DeclContext *contextDecl, |
| 326 | bool isInstance, |
| 327 | bool isVariadic, |
| 328 | bool isSynthesized, |
Fariborz Jahanian | 3fe1041 | 2010-07-22 18:24:20 +0000 | [diff] [blame] | 329 | bool isDefined, |
Fariborz Jahanian | 7732cc9 | 2010-04-08 21:29:11 +0000 | [diff] [blame] | 330 | ImplementationControl impControl, |
| 331 | unsigned numSelectorArgs) { |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 332 | return new (C) ObjCMethodDecl(beginLoc, endLoc, |
Douglas Gregor | 4bc1cb6 | 2010-03-08 14:59:44 +0000 | [diff] [blame] | 333 | SelInfo, T, ResultTInfo, contextDecl, |
| 334 | isInstance, |
Fariborz Jahanian | 3fe1041 | 2010-07-22 18:24:20 +0000 | [diff] [blame] | 335 | isVariadic, isSynthesized, isDefined, |
| 336 | impControl, |
Fariborz Jahanian | 7732cc9 | 2010-04-08 21:29:11 +0000 | [diff] [blame] | 337 | numSelectorArgs); |
Chris Lattner | 1e03a56 | 2008-03-16 00:19:01 +0000 | [diff] [blame] | 338 | } |
| 339 | |
Argyrios Kyrtzidis | 57ea6be | 2009-07-21 00:06:36 +0000 | [diff] [blame] | 340 | /// \brief A definition will return its interface declaration. |
| 341 | /// An interface declaration will return its definition. |
| 342 | /// Otherwise it will return itself. |
| 343 | ObjCMethodDecl *ObjCMethodDecl::getNextRedeclaration() { |
| 344 | ASTContext &Ctx = getASTContext(); |
| 345 | ObjCMethodDecl *Redecl = 0; |
| 346 | Decl *CtxD = cast<Decl>(getDeclContext()); |
| 347 | |
| 348 | if (ObjCInterfaceDecl *IFD = dyn_cast<ObjCInterfaceDecl>(CtxD)) { |
| 349 | if (ObjCImplementationDecl *ImplD = Ctx.getObjCImplementation(IFD)) |
| 350 | Redecl = ImplD->getMethod(getSelector(), isInstanceMethod()); |
| 351 | |
| 352 | } else if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(CtxD)) { |
| 353 | if (ObjCCategoryImplDecl *ImplD = Ctx.getObjCImplementation(CD)) |
| 354 | Redecl = ImplD->getMethod(getSelector(), isInstanceMethod()); |
| 355 | |
Argyrios Kyrtzidis | 4292073 | 2009-07-28 05:11:05 +0000 | [diff] [blame] | 356 | } else if (ObjCImplementationDecl *ImplD = |
| 357 | dyn_cast<ObjCImplementationDecl>(CtxD)) { |
Argyrios Kyrtzidis | 57ea6be | 2009-07-21 00:06:36 +0000 | [diff] [blame] | 358 | if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface()) |
| 359 | Redecl = IFD->getMethod(getSelector(), isInstanceMethod()); |
Argyrios Kyrtzidis | 4292073 | 2009-07-28 05:11:05 +0000 | [diff] [blame] | 360 | |
| 361 | } else if (ObjCCategoryImplDecl *CImplD = |
| 362 | dyn_cast<ObjCCategoryImplDecl>(CtxD)) { |
Steve Naroff | 0d69b8c | 2009-10-29 21:11:04 +0000 | [diff] [blame] | 363 | if (ObjCCategoryDecl *CatD = CImplD->getCategoryDecl()) |
Argyrios Kyrtzidis | 4292073 | 2009-07-28 05:11:05 +0000 | [diff] [blame] | 364 | Redecl = CatD->getMethod(getSelector(), isInstanceMethod()); |
Argyrios Kyrtzidis | 57ea6be | 2009-07-21 00:06:36 +0000 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | return Redecl ? Redecl : this; |
| 368 | } |
| 369 | |
Argyrios Kyrtzidis | e7f9d30 | 2009-07-28 05:11:17 +0000 | [diff] [blame] | 370 | ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() { |
| 371 | Decl *CtxD = cast<Decl>(getDeclContext()); |
| 372 | |
| 373 | if (ObjCImplementationDecl *ImplD = dyn_cast<ObjCImplementationDecl>(CtxD)) { |
| 374 | if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface()) |
| 375 | if (ObjCMethodDecl *MD = IFD->getMethod(getSelector(), |
| 376 | isInstanceMethod())) |
| 377 | return MD; |
| 378 | |
| 379 | } else if (ObjCCategoryImplDecl *CImplD = |
| 380 | dyn_cast<ObjCCategoryImplDecl>(CtxD)) { |
Steve Naroff | 0d69b8c | 2009-10-29 21:11:04 +0000 | [diff] [blame] | 381 | if (ObjCCategoryDecl *CatD = CImplD->getCategoryDecl()) |
Argyrios Kyrtzidis | e7f9d30 | 2009-07-28 05:11:17 +0000 | [diff] [blame] | 382 | if (ObjCMethodDecl *MD = CatD->getMethod(getSelector(), |
| 383 | isInstanceMethod())) |
| 384 | return MD; |
| 385 | } |
| 386 | |
| 387 | return this; |
| 388 | } |
| 389 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 390 | void ObjCMethodDecl::createImplicitParams(ASTContext &Context, |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 391 | const ObjCInterfaceDecl *OID) { |
| 392 | QualType selfTy; |
| 393 | if (isInstanceMethod()) { |
| 394 | // There may be no interface context due to error in declaration |
| 395 | // of the interface (which has been reported). Recover gracefully. |
| 396 | if (OID) { |
Daniel Dunbar | 3b3a458 | 2009-04-22 04:34:53 +0000 | [diff] [blame] | 397 | selfTy = Context.getObjCInterfaceType(OID); |
Steve Naroff | 14108da | 2009-07-10 23:34:53 +0000 | [diff] [blame] | 398 | selfTy = Context.getObjCObjectPointerType(selfTy); |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 399 | } else { |
| 400 | selfTy = Context.getObjCIdType(); |
| 401 | } |
| 402 | } else // we have a factory method. |
| 403 | selfTy = Context.getObjCClassType(); |
| 404 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 405 | setSelfDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(), |
Steve Naroff | 53c9d8a | 2009-04-20 15:06:07 +0000 | [diff] [blame] | 406 | &Context.Idents.get("self"), selfTy)); |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 407 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 408 | setCmdDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(), |
| 409 | &Context.Idents.get("_cmd"), |
Steve Naroff | 53c9d8a | 2009-04-20 15:06:07 +0000 | [diff] [blame] | 410 | Context.getObjCSelType())); |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 411 | } |
| 412 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 413 | ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() { |
| 414 | if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(getDeclContext())) |
| 415 | return ID; |
| 416 | if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(getDeclContext())) |
| 417 | return CD->getClassInterface(); |
Argyrios Kyrtzidis | a853037 | 2009-07-28 05:10:52 +0000 | [diff] [blame] | 418 | if (ObjCImplDecl *IMD = dyn_cast<ObjCImplDecl>(getDeclContext())) |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 419 | return IMD->getClassInterface(); |
Argyrios Kyrtzidis | a853037 | 2009-07-28 05:10:52 +0000 | [diff] [blame] | 420 | |
| 421 | assert(!isa<ObjCProtocolDecl>(getDeclContext()) && "It's a protocol method"); |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 422 | assert(false && "unknown method context"); |
Fariborz Jahanian | ae6f6fd | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 423 | return 0; |
| 424 | } |
| 425 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 426 | //===----------------------------------------------------------------------===// |
| 427 | // ObjCInterfaceDecl |
| 428 | //===----------------------------------------------------------------------===// |
| 429 | |
| 430 | ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C, |
| 431 | DeclContext *DC, |
| 432 | SourceLocation atLoc, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 433 | IdentifierInfo *Id, |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 434 | SourceLocation ClassLoc, |
| 435 | bool ForwardDecl, bool isInternal){ |
Douglas Gregor | deacbdc | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 436 | return new (C) ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, ForwardDecl, |
| 437 | isInternal); |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | ObjCInterfaceDecl:: |
| 441 | ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, |
Douglas Gregor | deacbdc | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 442 | SourceLocation CLoc, bool FD, bool isInternal) |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 443 | : ObjCContainerDecl(ObjCInterface, DC, atLoc, Id), |
| 444 | TypeForDecl(0), SuperClass(0), |
| 445 | CategoryList(0), ForwardDecl(FD), InternalInterface(isInternal), |
| 446 | ClassLoc(CLoc) { |
| 447 | } |
| 448 | |
Argyrios Kyrtzidis | 8a1d722 | 2009-07-21 00:05:53 +0000 | [diff] [blame] | 449 | ObjCImplementationDecl *ObjCInterfaceDecl::getImplementation() const { |
| 450 | return getASTContext().getObjCImplementation( |
| 451 | const_cast<ObjCInterfaceDecl*>(this)); |
| 452 | } |
| 453 | |
| 454 | void ObjCInterfaceDecl::setImplementation(ObjCImplementationDecl *ImplD) { |
| 455 | getASTContext().setObjCImplementation(this, ImplD); |
| 456 | } |
| 457 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 458 | |
| 459 | /// FindCategoryDeclaration - Finds category declaration in the list of |
| 460 | /// categories for this class and returns it. Name of the category is passed |
| 461 | /// in 'CategoryId'. If category not found, return 0; |
Fariborz Jahanian | ae6f6fd | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 462 | /// |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 463 | ObjCCategoryDecl * |
| 464 | ObjCInterfaceDecl::FindCategoryDeclaration(IdentifierInfo *CategoryId) const { |
| 465 | for (ObjCCategoryDecl *Category = getCategoryList(); |
| 466 | Category; Category = Category->getNextClassCategory()) |
| 467 | if (Category->getIdentifier() == CategoryId) |
| 468 | return Category; |
Fariborz Jahanian | ae6f6fd | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 469 | return 0; |
| 470 | } |
| 471 | |
Argyrios Kyrtzidis | 1cb35dd | 2009-07-21 00:06:20 +0000 | [diff] [blame] | 472 | ObjCMethodDecl * |
| 473 | ObjCInterfaceDecl::getCategoryInstanceMethod(Selector Sel) const { |
| 474 | for (ObjCCategoryDecl *Category = getCategoryList(); |
| 475 | Category; Category = Category->getNextClassCategory()) |
| 476 | if (ObjCCategoryImplDecl *Impl = Category->getImplementation()) |
| 477 | if (ObjCMethodDecl *MD = Impl->getInstanceMethod(Sel)) |
| 478 | return MD; |
| 479 | return 0; |
| 480 | } |
| 481 | |
| 482 | ObjCMethodDecl *ObjCInterfaceDecl::getCategoryClassMethod(Selector Sel) const { |
| 483 | for (ObjCCategoryDecl *Category = getCategoryList(); |
| 484 | Category; Category = Category->getNextClassCategory()) |
| 485 | if (ObjCCategoryImplDecl *Impl = Category->getImplementation()) |
| 486 | if (ObjCMethodDecl *MD = Impl->getClassMethod(Sel)) |
| 487 | return MD; |
| 488 | return 0; |
| 489 | } |
| 490 | |
Fariborz Jahanian | 0fd8904 | 2009-08-11 22:02:25 +0000 | [diff] [blame] | 491 | /// ClassImplementsProtocol - Checks that 'lProto' protocol |
| 492 | /// has been implemented in IDecl class, its super class or categories (if |
| 493 | /// lookupCategory is true). |
| 494 | bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto, |
| 495 | bool lookupCategory, |
| 496 | bool RHSIsQualifiedID) { |
| 497 | ObjCInterfaceDecl *IDecl = this; |
| 498 | // 1st, look up the class. |
| 499 | const ObjCList<ObjCProtocolDecl> &Protocols = |
| 500 | IDecl->getReferencedProtocols(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 501 | |
Fariborz Jahanian | 0fd8904 | 2009-08-11 22:02:25 +0000 | [diff] [blame] | 502 | for (ObjCList<ObjCProtocolDecl>::iterator PI = Protocols.begin(), |
| 503 | E = Protocols.end(); PI != E; ++PI) { |
| 504 | if (getASTContext().ProtocolCompatibleWithProtocol(lProto, *PI)) |
| 505 | return true; |
| 506 | // This is dubious and is added to be compatible with gcc. In gcc, it is |
| 507 | // also allowed assigning a protocol-qualified 'id' type to a LHS object |
| 508 | // when protocol in qualified LHS is in list of protocols in the rhs 'id' |
| 509 | // object. This IMO, should be a bug. |
| 510 | // FIXME: Treat this as an extension, and flag this as an error when GCC |
| 511 | // extensions are not enabled. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 512 | if (RHSIsQualifiedID && |
Fariborz Jahanian | 0fd8904 | 2009-08-11 22:02:25 +0000 | [diff] [blame] | 513 | getASTContext().ProtocolCompatibleWithProtocol(*PI, lProto)) |
| 514 | return true; |
| 515 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 516 | |
Fariborz Jahanian | 0fd8904 | 2009-08-11 22:02:25 +0000 | [diff] [blame] | 517 | // 2nd, look up the category. |
| 518 | if (lookupCategory) |
| 519 | for (ObjCCategoryDecl *CDecl = IDecl->getCategoryList(); CDecl; |
| 520 | CDecl = CDecl->getNextClassCategory()) { |
| 521 | for (ObjCCategoryDecl::protocol_iterator PI = CDecl->protocol_begin(), |
| 522 | E = CDecl->protocol_end(); PI != E; ++PI) |
| 523 | if (getASTContext().ProtocolCompatibleWithProtocol(lProto, *PI)) |
| 524 | return true; |
| 525 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 526 | |
Fariborz Jahanian | 0fd8904 | 2009-08-11 22:02:25 +0000 | [diff] [blame] | 527 | // 3rd, look up the super class(s) |
| 528 | if (IDecl->getSuperClass()) |
| 529 | return |
| 530 | IDecl->getSuperClass()->ClassImplementsProtocol(lProto, lookupCategory, |
| 531 | RHSIsQualifiedID); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 532 | |
Fariborz Jahanian | 0fd8904 | 2009-08-11 22:02:25 +0000 | [diff] [blame] | 533 | return false; |
| 534 | } |
| 535 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 536 | //===----------------------------------------------------------------------===// |
| 537 | // ObjCIvarDecl |
| 538 | //===----------------------------------------------------------------------===// |
| 539 | |
Daniel Dunbar | a065492 | 2010-04-02 20:10:03 +0000 | [diff] [blame] | 540 | ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, ObjCContainerDecl *DC, |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 541 | SourceLocation L, IdentifierInfo *Id, |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 542 | QualType T, TypeSourceInfo *TInfo, |
Fariborz Jahanian | ad51e74 | 2010-07-17 00:59:30 +0000 | [diff] [blame] | 543 | AccessControl ac, Expr *BW, |
| 544 | bool synthesized) { |
Daniel Dunbar | a065492 | 2010-04-02 20:10:03 +0000 | [diff] [blame] | 545 | if (DC) { |
| 546 | // Ivar's can only appear in interfaces, implementations (via synthesized |
| 547 | // properties), and class extensions (via direct declaration, or synthesized |
| 548 | // properties). |
| 549 | // |
| 550 | // FIXME: This should really be asserting this: |
| 551 | // (isa<ObjCCategoryDecl>(DC) && |
| 552 | // cast<ObjCCategoryDecl>(DC)->IsClassExtension())) |
| 553 | // but unfortunately we sometimes place ivars into non-class extension |
| 554 | // categories on error. This breaks an AST invariant, and should not be |
| 555 | // fixed. |
| 556 | assert((isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl>(DC) || |
| 557 | isa<ObjCCategoryDecl>(DC)) && |
| 558 | "Invalid ivar decl context!"); |
| 559 | } |
| 560 | |
Fariborz Jahanian | ad51e74 | 2010-07-17 00:59:30 +0000 | [diff] [blame] | 561 | return new (C) ObjCIvarDecl(DC, L, Id, T, TInfo, ac, BW, synthesized); |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 562 | } |
| 563 | |
Daniel Dunbar | 27a961a | 2010-04-02 21:13:59 +0000 | [diff] [blame] | 564 | const ObjCInterfaceDecl *ObjCIvarDecl::getContainingInterface() const { |
| 565 | const ObjCContainerDecl *DC = cast<ObjCContainerDecl>(getDeclContext()); |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 566 | |
Daniel Dunbar | 27a961a | 2010-04-02 21:13:59 +0000 | [diff] [blame] | 567 | switch (DC->getKind()) { |
| 568 | default: |
| 569 | case ObjCCategoryImpl: |
| 570 | case ObjCProtocol: |
| 571 | assert(0 && "invalid ivar container!"); |
| 572 | return 0; |
| 573 | |
| 574 | // Ivars can only appear in class extension categories. |
| 575 | case ObjCCategory: { |
| 576 | const ObjCCategoryDecl *CD = cast<ObjCCategoryDecl>(DC); |
| 577 | assert(CD->IsClassExtension() && "invalid container for ivar!"); |
| 578 | return CD->getClassInterface(); |
| 579 | } |
| 580 | |
| 581 | case ObjCImplementation: |
| 582 | return cast<ObjCImplementationDecl>(DC)->getClassInterface(); |
| 583 | |
| 584 | case ObjCInterface: |
| 585 | return cast<ObjCInterfaceDecl>(DC); |
| 586 | } |
| 587 | } |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 588 | |
| 589 | //===----------------------------------------------------------------------===// |
| 590 | // ObjCAtDefsFieldDecl |
| 591 | //===----------------------------------------------------------------------===// |
| 592 | |
| 593 | ObjCAtDefsFieldDecl |
| 594 | *ObjCAtDefsFieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, |
| 595 | IdentifierInfo *Id, QualType T, Expr *BW) { |
| 596 | return new (C) ObjCAtDefsFieldDecl(DC, L, Id, T, BW); |
| 597 | } |
| 598 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 599 | //===----------------------------------------------------------------------===// |
| 600 | // ObjCProtocolDecl |
| 601 | //===----------------------------------------------------------------------===// |
| 602 | |
| 603 | ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 604 | SourceLocation L, |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 605 | IdentifierInfo *Id) { |
| 606 | return new (C) ObjCProtocolDecl(DC, L, Id); |
| 607 | } |
| 608 | |
Steve Naroff | 91b0b0c | 2009-03-01 16:12:44 +0000 | [diff] [blame] | 609 | ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) { |
| 610 | ObjCProtocolDecl *PDecl = this; |
| 611 | |
| 612 | if (Name == getIdentifier()) |
| 613 | return PDecl; |
| 614 | |
| 615 | for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I) |
| 616 | if ((PDecl = (*I)->lookupProtocolNamed(Name))) |
| 617 | return PDecl; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 618 | |
Steve Naroff | 91b0b0c | 2009-03-01 16:12:44 +0000 | [diff] [blame] | 619 | return NULL; |
| 620 | } |
| 621 | |
Argyrios Kyrtzidis | 094e2bb | 2009-07-25 22:15:38 +0000 | [diff] [blame] | 622 | // lookupMethod - Lookup a instance/class method in the protocol and protocols |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 623 | // it inherited. |
Argyrios Kyrtzidis | 094e2bb | 2009-07-25 22:15:38 +0000 | [diff] [blame] | 624 | ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel, |
| 625 | bool isInstance) const { |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 626 | ObjCMethodDecl *MethodDecl = NULL; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 627 | |
Argyrios Kyrtzidis | 094e2bb | 2009-07-25 22:15:38 +0000 | [diff] [blame] | 628 | if ((MethodDecl = getMethod(Sel, isInstance))) |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 629 | return MethodDecl; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 630 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 631 | for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I) |
Argyrios Kyrtzidis | 094e2bb | 2009-07-25 22:15:38 +0000 | [diff] [blame] | 632 | if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance))) |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 633 | return MethodDecl; |
| 634 | return NULL; |
| 635 | } |
| 636 | |
| 637 | //===----------------------------------------------------------------------===// |
| 638 | // ObjCClassDecl |
| 639 | //===----------------------------------------------------------------------===// |
| 640 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 641 | ObjCClassDecl::ObjCClassDecl(DeclContext *DC, SourceLocation L, |
Ted Kremenek | 321c22f | 2009-11-18 00:28:11 +0000 | [diff] [blame] | 642 | ObjCInterfaceDecl *const *Elts, |
| 643 | const SourceLocation *Locs, |
| 644 | unsigned nElts, |
Chris Lattner | 38af2de | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 645 | ASTContext &C) |
| 646 | : Decl(ObjCClass, DC, L) { |
Ted Kremenek | 321c22f | 2009-11-18 00:28:11 +0000 | [diff] [blame] | 647 | setClassList(C, Elts, Locs, nElts); |
Chris Lattner | 38af2de | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 648 | } |
| 649 | |
Ted Kremenek | 321c22f | 2009-11-18 00:28:11 +0000 | [diff] [blame] | 650 | void ObjCClassDecl::setClassList(ASTContext &C, ObjCInterfaceDecl*const*List, |
| 651 | const SourceLocation *Locs, unsigned Num) { |
| 652 | ForwardDecls = (ObjCClassRef*) C.Allocate(sizeof(ObjCClassRef)*Num, |
| 653 | llvm::alignof<ObjCClassRef>()); |
| 654 | for (unsigned i = 0; i < Num; ++i) |
| 655 | new (&ForwardDecls[i]) ObjCClassRef(List[i], Locs[i]); |
| 656 | |
| 657 | NumDecls = Num; |
| 658 | } |
Chris Lattner | 38af2de | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 659 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 660 | ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC, |
| 661 | SourceLocation L, |
| 662 | ObjCInterfaceDecl *const *Elts, |
Ted Kremenek | 321c22f | 2009-11-18 00:28:11 +0000 | [diff] [blame] | 663 | const SourceLocation *Locs, |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 664 | unsigned nElts) { |
Ted Kremenek | 321c22f | 2009-11-18 00:28:11 +0000 | [diff] [blame] | 665 | return new (C) ObjCClassDecl(DC, L, Elts, Locs, nElts, C); |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 666 | } |
| 667 | |
Ted Kremenek | 2dbdd62 | 2009-11-18 01:26:56 +0000 | [diff] [blame] | 668 | SourceRange ObjCClassDecl::getSourceRange() const { |
| 669 | // FIXME: We should include the semicolon |
| 670 | assert(NumDecls); |
| 671 | return SourceRange(getLocation(), ForwardDecls[NumDecls-1].getLocation()); |
| 672 | } |
| 673 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 674 | //===----------------------------------------------------------------------===// |
| 675 | // ObjCForwardProtocolDecl |
| 676 | //===----------------------------------------------------------------------===// |
| 677 | |
Chris Lattner | 38af2de | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 678 | ObjCForwardProtocolDecl:: |
| 679 | ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L, |
| 680 | ObjCProtocolDecl *const *Elts, unsigned nElts, |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 681 | const SourceLocation *Locs, ASTContext &C) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 682 | : Decl(ObjCForwardProtocol, DC, L) { |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 683 | ReferencedProtocols.set(Elts, nElts, Locs, C); |
Chris Lattner | 38af2de | 2009-02-20 21:35:13 +0000 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 687 | ObjCForwardProtocolDecl * |
| 688 | ObjCForwardProtocolDecl::Create(ASTContext &C, DeclContext *DC, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 689 | SourceLocation L, |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 690 | ObjCProtocolDecl *const *Elts, |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 691 | unsigned NumElts, |
| 692 | const SourceLocation *Locs) { |
| 693 | return new (C) ObjCForwardProtocolDecl(DC, L, Elts, NumElts, Locs, C); |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 694 | } |
| 695 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 696 | //===----------------------------------------------------------------------===// |
| 697 | // ObjCCategoryDecl |
| 698 | //===----------------------------------------------------------------------===// |
| 699 | |
| 700 | ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, DeclContext *DC, |
Douglas Gregor | 3db211b | 2010-01-16 16:38:58 +0000 | [diff] [blame] | 701 | SourceLocation AtLoc, |
| 702 | SourceLocation ClassNameLoc, |
| 703 | SourceLocation CategoryNameLoc, |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 704 | IdentifierInfo *Id) { |
Douglas Gregor | 3db211b | 2010-01-16 16:38:58 +0000 | [diff] [blame] | 705 | return new (C) ObjCCategoryDecl(DC, AtLoc, ClassNameLoc, CategoryNameLoc, Id); |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 706 | } |
| 707 | |
Argyrios Kyrtzidis | 8a1d722 | 2009-07-21 00:05:53 +0000 | [diff] [blame] | 708 | ObjCCategoryImplDecl *ObjCCategoryDecl::getImplementation() const { |
| 709 | return getASTContext().getObjCImplementation( |
| 710 | const_cast<ObjCCategoryDecl*>(this)); |
| 711 | } |
| 712 | |
| 713 | void ObjCCategoryDecl::setImplementation(ObjCCategoryImplDecl *ImplD) { |
| 714 | getASTContext().setObjCImplementation(this, ImplD); |
| 715 | } |
| 716 | |
| 717 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 718 | //===----------------------------------------------------------------------===// |
| 719 | // ObjCCategoryImplDecl |
| 720 | //===----------------------------------------------------------------------===// |
| 721 | |
| 722 | ObjCCategoryImplDecl * |
| 723 | ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC, |
| 724 | SourceLocation L,IdentifierInfo *Id, |
| 725 | ObjCInterfaceDecl *ClassInterface) { |
| 726 | return new (C) ObjCCategoryImplDecl(DC, L, Id, ClassInterface); |
| 727 | } |
| 728 | |
Steve Naroff | 0d69b8c | 2009-10-29 21:11:04 +0000 | [diff] [blame] | 729 | ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryDecl() const { |
Ted Kremenek | ebfa339 | 2010-03-19 20:39:03 +0000 | [diff] [blame] | 730 | // The class interface might be NULL if we are working with invalid code. |
| 731 | if (const ObjCInterfaceDecl *ID = getClassInterface()) |
| 732 | return ID->FindCategoryDeclaration(getIdentifier()); |
| 733 | return 0; |
Argyrios Kyrtzidis | 4292073 | 2009-07-28 05:11:05 +0000 | [diff] [blame] | 734 | } |
| 735 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 736 | |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 737 | void ObjCImplDecl::addPropertyImplementation(ObjCPropertyImplDecl *property) { |
Douglas Gregor | 2c2d43c | 2009-04-23 02:42:49 +0000 | [diff] [blame] | 738 | // FIXME: The context should be correct before we get here. |
Douglas Gregor | 653f1b1 | 2009-04-23 01:02:12 +0000 | [diff] [blame] | 739 | property->setLexicalDeclContext(this); |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 740 | addDecl(property); |
Douglas Gregor | 653f1b1 | 2009-04-23 01:02:12 +0000 | [diff] [blame] | 741 | } |
| 742 | |
Argyrios Kyrtzidis | 8a1d722 | 2009-07-21 00:05:53 +0000 | [diff] [blame] | 743 | void ObjCImplDecl::setClassInterface(ObjCInterfaceDecl *IFace) { |
| 744 | ASTContext &Ctx = getASTContext(); |
| 745 | |
| 746 | if (ObjCImplementationDecl *ImplD |
Duncan Sands | 98f2cca | 2009-07-21 07:56:29 +0000 | [diff] [blame] | 747 | = dyn_cast_or_null<ObjCImplementationDecl>(this)) { |
Argyrios Kyrtzidis | 8a1d722 | 2009-07-21 00:05:53 +0000 | [diff] [blame] | 748 | if (IFace) |
| 749 | Ctx.setObjCImplementation(IFace, ImplD); |
| 750 | |
Duncan Sands | 98f2cca | 2009-07-21 07:56:29 +0000 | [diff] [blame] | 751 | } else if (ObjCCategoryImplDecl *ImplD = |
Argyrios Kyrtzidis | 8a1d722 | 2009-07-21 00:05:53 +0000 | [diff] [blame] | 752 | dyn_cast_or_null<ObjCCategoryImplDecl>(this)) { |
| 753 | if (ObjCCategoryDecl *CD = IFace->FindCategoryDeclaration(getIdentifier())) |
| 754 | Ctx.setObjCImplementation(CD, ImplD); |
| 755 | } |
| 756 | |
| 757 | ClassInterface = IFace; |
| 758 | } |
| 759 | |
Fariborz Jahanian | ae6f6fd | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 760 | /// FindPropertyImplIvarDecl - This method lookup the ivar in the list of |
Chris Lattner | d6eed1c | 2009-02-16 19:24:31 +0000 | [diff] [blame] | 761 | /// properties implemented in this category @implementation block and returns |
| 762 | /// the implemented property that uses it. |
Fariborz Jahanian | ae6f6fd | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 763 | /// |
Chris Lattner | 3aa1861 | 2009-02-28 18:42:10 +0000 | [diff] [blame] | 764 | ObjCPropertyImplDecl *ObjCImplDecl:: |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 765 | FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const { |
| 766 | for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i){ |
Fariborz Jahanian | ae6f6fd | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 767 | ObjCPropertyImplDecl *PID = *i; |
| 768 | if (PID->getPropertyIvarDecl() && |
| 769 | PID->getPropertyIvarDecl()->getIdentifier() == ivarId) |
| 770 | return PID; |
| 771 | } |
| 772 | return 0; |
| 773 | } |
| 774 | |
| 775 | /// FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl |
| 776 | /// added to the list of those properties @synthesized/@dynamic in this |
| 777 | /// category @implementation block. |
| 778 | /// |
Chris Lattner | 3aa1861 | 2009-02-28 18:42:10 +0000 | [diff] [blame] | 779 | ObjCPropertyImplDecl *ObjCImplDecl:: |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 780 | FindPropertyImplDecl(IdentifierInfo *Id) const { |
| 781 | for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i){ |
Fariborz Jahanian | ae6f6fd | 2008-12-05 22:32:48 +0000 | [diff] [blame] | 782 | ObjCPropertyImplDecl *PID = *i; |
| 783 | if (PID->getPropertyDecl()->getIdentifier() == Id) |
| 784 | return PID; |
| 785 | } |
| 786 | return 0; |
| 787 | } |
| 788 | |
Benjamin Kramer | 900fc63 | 2010-04-17 09:33:03 +0000 | [diff] [blame] | 789 | llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS, |
| 790 | const ObjCCategoryImplDecl *CID) { |
| 791 | OS << CID->getName(); |
| 792 | return OS; |
| 793 | } |
| 794 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 795 | //===----------------------------------------------------------------------===// |
| 796 | // ObjCImplementationDecl |
| 797 | //===----------------------------------------------------------------------===// |
| 798 | |
| 799 | ObjCImplementationDecl * |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 800 | ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC, |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 801 | SourceLocation L, |
| 802 | ObjCInterfaceDecl *ClassInterface, |
| 803 | ObjCInterfaceDecl *SuperDecl) { |
| 804 | return new (C) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl); |
| 805 | } |
| 806 | |
Benjamin Kramer | 900fc63 | 2010-04-17 09:33:03 +0000 | [diff] [blame] | 807 | llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS, |
| 808 | const ObjCImplementationDecl *ID) { |
| 809 | OS << ID->getName(); |
| 810 | return OS; |
| 811 | } |
| 812 | |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 813 | //===----------------------------------------------------------------------===// |
| 814 | // ObjCCompatibleAliasDecl |
| 815 | //===----------------------------------------------------------------------===// |
| 816 | |
| 817 | ObjCCompatibleAliasDecl * |
| 818 | ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC, |
| 819 | SourceLocation L, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 820 | IdentifierInfo *Id, |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 821 | ObjCInterfaceDecl* AliasedClass) { |
| 822 | return new (C) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass); |
| 823 | } |
| 824 | |
| 825 | //===----------------------------------------------------------------------===// |
| 826 | // ObjCPropertyDecl |
| 827 | //===----------------------------------------------------------------------===// |
| 828 | |
| 829 | ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, DeclContext *DC, |
| 830 | SourceLocation L, |
| 831 | IdentifierInfo *Id, |
Fariborz Jahanian | d050240 | 2010-01-21 17:36:00 +0000 | [diff] [blame] | 832 | SourceLocation AtLoc, |
John McCall | 83a230c | 2010-06-04 20:50:08 +0000 | [diff] [blame] | 833 | TypeSourceInfo *T, |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 834 | PropertyControl propControl) { |
Fariborz Jahanian | d050240 | 2010-01-21 17:36:00 +0000 | [diff] [blame] | 835 | return new (C) ObjCPropertyDecl(DC, L, Id, AtLoc, T); |
Chris Lattner | ab35163 | 2009-02-20 20:59:54 +0000 | [diff] [blame] | 836 | } |
| 837 | |
| 838 | |
| 839 | //===----------------------------------------------------------------------===// |
| 840 | // ObjCPropertyImplDecl |
| 841 | //===----------------------------------------------------------------------===// |
| 842 | |
Fariborz Jahanian | 628b96f | 2008-04-23 00:06:01 +0000 | [diff] [blame] | 843 | ObjCPropertyImplDecl *ObjCPropertyImplDecl::Create(ASTContext &C, |
Douglas Gregor | d043410 | 2009-01-09 00:49:46 +0000 | [diff] [blame] | 844 | DeclContext *DC, |
Fariborz Jahanian | 628b96f | 2008-04-23 00:06:01 +0000 | [diff] [blame] | 845 | SourceLocation atLoc, |
| 846 | SourceLocation L, |
| 847 | ObjCPropertyDecl *property, |
Daniel Dunbar | 9f0afd4 | 2008-08-26 04:47:31 +0000 | [diff] [blame] | 848 | Kind PK, |
Fariborz Jahanian | 628b96f | 2008-04-23 00:06:01 +0000 | [diff] [blame] | 849 | ObjCIvarDecl *ivar) { |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame] | 850 | return new (C) ObjCPropertyImplDecl(DC, atLoc, L, property, PK, ivar); |
Fariborz Jahanian | 628b96f | 2008-04-23 00:06:01 +0000 | [diff] [blame] | 851 | } |
Chris Lattner | f4af515 | 2008-03-17 01:19:02 +0000 | [diff] [blame] | 852 | |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 853 | |