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