Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 1 | //===--- SemaExprObjC.cpp - Semantic Analysis for ObjC Expressions --------===// |
| 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 semantic analysis for Objective-C expressions. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "Sema.h" |
| 15 | #include "clang/AST/ASTContext.h" |
| 16 | #include "clang/AST/DeclObjC.h" |
Steve Naroff | f494b57 | 2008-05-29 21:12:08 +0000 | [diff] [blame] | 17 | #include "clang/AST/ExprObjC.h" |
Daniel Dunbar | 12bc692 | 2008-08-11 03:27:53 +0000 | [diff] [blame] | 18 | #include "clang/Basic/Diagnostic.h" |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 19 | using namespace clang; |
| 20 | |
| 21 | Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs, |
| 22 | ExprTy **Strings, |
| 23 | unsigned NumStrings) { |
| 24 | SourceLocation AtLoc = AtLocs[0]; |
| 25 | StringLiteral* S = static_cast<StringLiteral *>(Strings[0]); |
| 26 | if (NumStrings > 1) { |
| 27 | // Concatenate objc strings. |
| 28 | StringLiteral* ES = static_cast<StringLiteral *>(Strings[NumStrings-1]); |
| 29 | SourceLocation EndLoc = ES->getSourceRange().getEnd(); |
| 30 | unsigned Length = 0; |
| 31 | for (unsigned i = 0; i < NumStrings; i++) |
| 32 | Length += static_cast<StringLiteral *>(Strings[i])->getByteLength(); |
| 33 | char *strBuf = new char [Length]; |
| 34 | char *p = strBuf; |
| 35 | bool isWide = false; |
| 36 | for (unsigned i = 0; i < NumStrings; i++) { |
| 37 | S = static_cast<StringLiteral *>(Strings[i]); |
| 38 | if (S->isWide()) |
| 39 | isWide = true; |
| 40 | memcpy(p, S->getStrData(), S->getByteLength()); |
| 41 | p += S->getByteLength(); |
| 42 | delete S; |
| 43 | } |
| 44 | S = new StringLiteral(strBuf, Length, |
| 45 | isWide, Context.getPointerType(Context.CharTy), |
| 46 | AtLoc, EndLoc); |
| 47 | } |
| 48 | |
| 49 | if (CheckBuiltinCFStringArgument(S)) |
| 50 | return true; |
| 51 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 52 | if (Context.getObjCConstantStringInterface().isNull()) { |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 53 | // Initialize the constant string interface lazily. This assumes |
| 54 | // the NSConstantString interface is seen in this translation unit. |
| 55 | IdentifierInfo *NSIdent = &Context.Idents.get("NSConstantString"); |
Steve Naroff | b327ce0 | 2008-04-02 14:35:35 +0000 | [diff] [blame] | 56 | Decl *IFace = LookupDecl(NSIdent, Decl::IDNS_Ordinary, TUScope); |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 57 | ObjCInterfaceDecl *strIFace = dyn_cast_or_null<ObjCInterfaceDecl>(IFace); |
Chris Lattner | 13fd7e5 | 2008-06-21 21:44:18 +0000 | [diff] [blame] | 58 | if (strIFace) |
| 59 | Context.setObjCConstantStringInterface(strIFace); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 60 | } |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 61 | QualType t = Context.getObjCConstantStringInterface(); |
Chris Lattner | 13fd7e5 | 2008-06-21 21:44:18 +0000 | [diff] [blame] | 62 | // If there is no NSConstantString interface defined then treat constant |
| 63 | // strings as untyped objects and let the runtime figure it out later. |
| 64 | if (t == QualType()) { |
| 65 | t = Context.getObjCIdType(); |
| 66 | } else { |
| 67 | t = Context.getPointerType(t); |
| 68 | } |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 69 | return new ObjCStringLiteral(S, t, AtLoc); |
| 70 | } |
| 71 | |
| 72 | Sema::ExprResult Sema::ParseObjCEncodeExpression(SourceLocation AtLoc, |
| 73 | SourceLocation EncodeLoc, |
| 74 | SourceLocation LParenLoc, |
| 75 | TypeTy *Ty, |
| 76 | SourceLocation RParenLoc) { |
| 77 | QualType EncodedType = QualType::getFromOpaquePtr(Ty); |
| 78 | |
| 79 | QualType t = Context.getPointerType(Context.CharTy); |
| 80 | return new ObjCEncodeExpr(t, EncodedType, AtLoc, RParenLoc); |
| 81 | } |
| 82 | |
| 83 | Sema::ExprResult Sema::ParseObjCSelectorExpression(Selector Sel, |
| 84 | SourceLocation AtLoc, |
| 85 | SourceLocation SelLoc, |
| 86 | SourceLocation LParenLoc, |
| 87 | SourceLocation RParenLoc) { |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 88 | QualType t = Context.getObjCSelType(); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 89 | return new ObjCSelectorExpr(t, Sel, AtLoc, RParenLoc); |
| 90 | } |
| 91 | |
| 92 | Sema::ExprResult Sema::ParseObjCProtocolExpression(IdentifierInfo *ProtocolId, |
| 93 | SourceLocation AtLoc, |
| 94 | SourceLocation ProtoLoc, |
| 95 | SourceLocation LParenLoc, |
| 96 | SourceLocation RParenLoc) { |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 97 | ObjCProtocolDecl* PDecl = ObjCProtocols[ProtocolId]; |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 98 | if (!PDecl) { |
| 99 | Diag(ProtoLoc, diag::err_undeclared_protocol, ProtocolId->getName()); |
| 100 | return true; |
| 101 | } |
| 102 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 103 | QualType t = Context.getObjCProtoType(); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 104 | if (t.isNull()) |
| 105 | return true; |
| 106 | t = Context.getPointerType(t); |
| 107 | return new ObjCProtocolExpr(t, PDecl, AtLoc, RParenLoc); |
| 108 | } |
| 109 | |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 110 | bool Sema::CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs, |
| 111 | Selector Sel, ObjCMethodDecl *Method, |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 112 | const char *PrefixStr, |
| 113 | SourceLocation lbrac, SourceLocation rbrac, |
| 114 | QualType &ReturnType) { |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 115 | if (!Method) { |
Daniel Dunbar | 6660c8a | 2008-09-11 00:04:36 +0000 | [diff] [blame] | 116 | // Apply default argument promotion as for (C99 6.5.2.2p6). |
| 117 | for (unsigned i = 0; i != NumArgs; i++) |
| 118 | DefaultArgumentPromotion(Args[i]); |
| 119 | |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 120 | Diag(lbrac, diag::warn_method_not_found, std::string(PrefixStr), |
| 121 | Sel.getName(), SourceRange(lbrac, rbrac)); |
| 122 | ReturnType = Context.getObjCIdType(); |
| 123 | return false; |
| 124 | } else { |
| 125 | ReturnType = Method->getResultType(); |
| 126 | } |
| 127 | |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 128 | unsigned NumNamedArgs = Sel.getNumArgs(); |
| 129 | assert(NumArgs >= NumNamedArgs && "Too few arguments for selector!"); |
| 130 | |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 131 | bool anyIncompatibleArgs = false; |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 132 | for (unsigned i = 0; i < NumNamedArgs; i++) { |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 133 | Expr *argExpr = Args[i]; |
| 134 | assert(argExpr && "CheckMessageArgumentTypes(): missing expression"); |
| 135 | |
| 136 | QualType lhsType = Method->getParamDecl(i)->getType(); |
| 137 | QualType rhsType = argExpr->getType(); |
| 138 | |
| 139 | // If necessary, apply function/array conversion. C99 6.7.5.3p[7,8]. |
Chris Lattner | 987798a | 2008-04-02 17:17:33 +0000 | [diff] [blame] | 140 | if (lhsType->isArrayType()) |
| 141 | lhsType = Context.getArrayDecayedType(lhsType); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 142 | else if (lhsType->isFunctionType()) |
| 143 | lhsType = Context.getPointerType(lhsType); |
| 144 | |
Chris Lattner | 987798a | 2008-04-02 17:17:33 +0000 | [diff] [blame] | 145 | AssignConvertType Result = |
| 146 | CheckSingleAssignmentConstraints(lhsType, argExpr); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 147 | if (Args[i] != argExpr) // The expression was converted. |
| 148 | Args[i] = argExpr; // Make sure we store the converted expression. |
| 149 | |
| 150 | anyIncompatibleArgs |= |
| 151 | DiagnoseAssignmentResult(Result, argExpr->getLocStart(), lhsType, rhsType, |
| 152 | argExpr, "sending"); |
| 153 | } |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 154 | |
| 155 | // Promote additional arguments to variadic methods. |
| 156 | if (Method->isVariadic()) { |
| 157 | for (unsigned i = NumNamedArgs; i < NumArgs; ++i) |
| 158 | DefaultArgumentPromotion(Args[i]); |
| 159 | } else { |
| 160 | // Check for extra arguments to non-variadic methods. |
| 161 | if (NumArgs != NumNamedArgs) { |
| 162 | Diag(Args[NumNamedArgs]->getLocStart(), |
| 163 | diag::err_typecheck_call_too_many_args, |
| 164 | Method->getSourceRange(), |
| 165 | SourceRange(Args[NumNamedArgs]->getLocStart(), |
| 166 | Args[NumArgs-1]->getLocEnd())); |
| 167 | } |
| 168 | } |
| 169 | |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 170 | return anyIncompatibleArgs; |
| 171 | } |
| 172 | |
| 173 | // ActOnClassMessage - used for both unary and keyword messages. |
| 174 | // ArgExprs is optional - if it is present, the number of expressions |
| 175 | // is obtained from Sel.getNumArgs(). |
| 176 | Sema::ExprResult Sema::ActOnClassMessage( |
| 177 | Scope *S, |
| 178 | IdentifierInfo *receiverName, Selector Sel, |
| 179 | SourceLocation lbrac, SourceLocation rbrac, ExprTy **Args, unsigned NumArgs) |
| 180 | { |
| 181 | assert(receiverName && "missing receiver class name"); |
| 182 | |
| 183 | Expr **ArgExprs = reinterpret_cast<Expr **>(Args); |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 184 | ObjCInterfaceDecl* ClassDecl = 0; |
Steve Naroff | fc93d52 | 2008-07-24 19:44:33 +0000 | [diff] [blame] | 185 | bool isSuper = false; |
| 186 | |
Daniel Dunbar | 662e8b5 | 2008-08-14 22:04:54 +0000 | [diff] [blame] | 187 | if (receiverName == SuperID && getCurMethodDecl()) { |
Steve Naroff | fc93d52 | 2008-07-24 19:44:33 +0000 | [diff] [blame] | 188 | isSuper = true; |
Argyrios Kyrtzidis | 53d0ea5 | 2008-06-28 06:07:14 +0000 | [diff] [blame] | 189 | ClassDecl = getCurMethodDecl()->getClassInterface()->getSuperClass(); |
Steve Naroff | 9511096 | 2008-03-28 21:37:05 +0000 | [diff] [blame] | 190 | if (!ClassDecl) |
| 191 | return Diag(lbrac, diag::error_no_super_class, |
Argyrios Kyrtzidis | 53d0ea5 | 2008-06-28 06:07:14 +0000 | [diff] [blame] | 192 | getCurMethodDecl()->getClassInterface()->getName()); |
| 193 | if (getCurMethodDecl()->isInstance()) { |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 194 | QualType superTy = Context.getObjCInterfaceType(ClassDecl); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 195 | superTy = Context.getPointerType(superTy); |
Douglas Gregor | cd9b46e | 2008-11-04 14:56:14 +0000 | [diff] [blame] | 196 | ExprResult ReceiverExpr = new ObjCSuperExpr(SourceLocation(), superTy); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 197 | // We are really in an instance method, redirect. |
| 198 | return ActOnInstanceMessage(ReceiverExpr.Val, Sel, lbrac, rbrac, |
| 199 | Args, NumArgs); |
| 200 | } |
| 201 | // We are sending a message to 'super' within a class method. Do nothing, |
| 202 | // the receiver will pass through as 'super' (how convenient:-). |
| 203 | } else |
| 204 | ClassDecl = getObjCInterfaceDecl(receiverName); |
| 205 | |
Steve Naroff | 7c778f1 | 2008-07-25 19:39:00 +0000 | [diff] [blame] | 206 | // The following code allows for the following GCC-ism: |
Steve Naroff | cb28be6 | 2008-06-04 23:08:38 +0000 | [diff] [blame] | 207 | // |
| 208 | // typedef XCElementDisplayRect XCElementGraphicsRect; |
| 209 | // |
| 210 | // @implementation XCRASlice |
| 211 | // - whatever { // Note that XCElementGraphicsRect is a typedef name. |
| 212 | // _sGraphicsDelegate =[[XCElementGraphicsRect alloc] init]; |
| 213 | // } |
| 214 | // |
Steve Naroff | 7c778f1 | 2008-07-25 19:39:00 +0000 | [diff] [blame] | 215 | // If necessary, the following lookup could move to getObjCInterfaceDecl(). |
| 216 | if (!ClassDecl) { |
| 217 | Decl *IDecl = LookupDecl(receiverName, Decl::IDNS_Ordinary, 0, false); |
| 218 | if (TypedefDecl *OCTD = dyn_cast_or_null<TypedefDecl>(IDecl)) { |
| 219 | const ObjCInterfaceType *OCIT; |
| 220 | OCIT = OCTD->getUnderlyingType()->getAsObjCInterfaceType(); |
| 221 | if (OCIT) |
| 222 | ClassDecl = OCIT->getDecl(); |
| 223 | } |
| 224 | } |
| 225 | assert(ClassDecl && "missing interface declaration"); |
Steve Naroff | cb28be6 | 2008-06-04 23:08:38 +0000 | [diff] [blame] | 226 | ObjCMethodDecl *Method = 0; |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 227 | QualType returnType; |
Steve Naroff | 7c778f1 | 2008-07-25 19:39:00 +0000 | [diff] [blame] | 228 | Method = ClassDecl->lookupClassMethod(Sel); |
| 229 | |
| 230 | // If we have an implementation in scope, check "private" methods. |
| 231 | if (!Method) { |
| 232 | if (ObjCImplementationDecl *ImpDecl = |
| 233 | ObjCImplementations[ClassDecl->getIdentifier()]) |
| 234 | Method = ImpDecl->getClassMethod(Sel); |
Steve Naroff | e84a864 | 2008-09-28 14:55:53 +0000 | [diff] [blame] | 235 | |
| 236 | // Look through local category implementations associated with the class. |
| 237 | if (!Method) { |
| 238 | for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Method; i++) { |
| 239 | if (ObjCCategoryImpls[i]->getClassInterface() == ClassDecl) |
| 240 | Method = ObjCCategoryImpls[i]->getClassMethod(Sel); |
| 241 | } |
| 242 | } |
Steve Naroff | 9ad23d6 | 2008-06-04 14:43:54 +0000 | [diff] [blame] | 243 | } |
Steve Naroff | 7c778f1 | 2008-07-25 19:39:00 +0000 | [diff] [blame] | 244 | // Before we give up, check if the selector is an instance method. |
| 245 | if (!Method) |
| 246 | Method = ClassDecl->lookupInstanceMethod(Sel); |
| 247 | |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 248 | if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, "+", |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 249 | lbrac, rbrac, returnType)) |
| 250 | return true; |
Ted Kremenek | 4df728e | 2008-06-24 15:50:53 +0000 | [diff] [blame] | 251 | |
| 252 | // If we have the ObjCInterfaceDecl* for the class that is receiving |
| 253 | // the message, use that to construct the ObjCMessageExpr. Otherwise |
| 254 | // pass on the IdentifierInfo* for the class. |
Steve Naroff | fc93d52 | 2008-07-24 19:44:33 +0000 | [diff] [blame] | 255 | // FIXME: need to do a better job handling 'super' usage within a class |
| 256 | // For now, we simply pass the "super" identifier through (which isn't |
| 257 | // consistent with instance methods. |
Steve Naroff | 7c778f1 | 2008-07-25 19:39:00 +0000 | [diff] [blame] | 258 | if (isSuper) |
Steve Naroff | fc93d52 | 2008-07-24 19:44:33 +0000 | [diff] [blame] | 259 | return new ObjCMessageExpr(receiverName, Sel, returnType, Method, |
Ted Kremenek | 4df728e | 2008-06-24 15:50:53 +0000 | [diff] [blame] | 260 | lbrac, rbrac, ArgExprs, NumArgs); |
| 261 | else |
Steve Naroff | fc93d52 | 2008-07-24 19:44:33 +0000 | [diff] [blame] | 262 | return new ObjCMessageExpr(ClassDecl, Sel, returnType, Method, |
Ted Kremenek | 4df728e | 2008-06-24 15:50:53 +0000 | [diff] [blame] | 263 | lbrac, rbrac, ArgExprs, NumArgs); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | // ActOnInstanceMessage - used for both unary and keyword messages. |
| 267 | // ArgExprs is optional - if it is present, the number of expressions |
| 268 | // is obtained from Sel.getNumArgs(). |
Chris Lattner | 1565e03 | 2008-07-21 06:31:05 +0000 | [diff] [blame] | 269 | Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel, |
Chris Lattner | b77792e | 2008-07-26 22:17:49 +0000 | [diff] [blame] | 270 | SourceLocation lbrac, |
| 271 | SourceLocation rbrac, |
| 272 | ExprTy **Args, unsigned NumArgs) { |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 273 | assert(receiver && "missing receiver expression"); |
| 274 | |
| 275 | Expr **ArgExprs = reinterpret_cast<Expr **>(Args); |
| 276 | Expr *RExpr = static_cast<Expr *>(receiver); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 277 | QualType returnType; |
Steve Naroff | 94a82c9 | 2008-05-31 02:19:15 +0000 | [diff] [blame] | 278 | |
Chris Lattner | b77792e | 2008-07-26 22:17:49 +0000 | [diff] [blame] | 279 | QualType ReceiverCType = |
| 280 | Context.getCanonicalType(RExpr->getType()).getUnqualifiedType(); |
Steve Naroff | 87d3ef0 | 2008-11-17 22:29:32 +0000 | [diff] [blame] | 281 | |
| 282 | // Handle messages to 'super'. |
| 283 | if (isa<ObjCSuperExpr>(RExpr)) { |
| 284 | ObjCMethodDecl *Method = 0; |
| 285 | if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) { |
| 286 | // If we have an interface in scope, check 'super' methods. |
| 287 | if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) |
| 288 | if (ObjCInterfaceDecl *SuperDecl = ClassDecl->getSuperClass()) |
| 289 | Method = SuperDecl->lookupInstanceMethod(Sel); |
| 290 | } |
| 291 | if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, "-", |
| 292 | lbrac, rbrac, returnType)) |
| 293 | return true; |
| 294 | return new ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac, rbrac, |
| 295 | ArgExprs, NumArgs); |
| 296 | } |
| 297 | |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 298 | // Handle messages to id. |
Steve Naroff | 6c4088e | 2008-09-29 16:51:41 +0000 | [diff] [blame] | 299 | if (ReceiverCType == Context.getCanonicalType(Context.getObjCIdType()) || |
| 300 | ReceiverCType->getAsBlockPointerType()) { |
Steve Naroff | 037cda5 | 2008-09-30 14:38:43 +0000 | [diff] [blame] | 301 | ObjCMethodDecl *Method = LookupInstanceMethodInGlobalPool( |
| 302 | Sel, SourceRange(lbrac,rbrac)); |
Chris Lattner | 6e10a08 | 2008-02-01 06:57:39 +0000 | [diff] [blame] | 303 | if (!Method) |
| 304 | Method = FactoryMethodPool[Sel].Method; |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 305 | if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, "-", |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 306 | lbrac, rbrac, returnType)) |
| 307 | return true; |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 308 | return new ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac, rbrac, |
| 309 | ArgExprs, NumArgs); |
| 310 | } |
| 311 | |
| 312 | // Handle messages to Class. |
Chris Lattner | b77792e | 2008-07-26 22:17:49 +0000 | [diff] [blame] | 313 | if (ReceiverCType == Context.getCanonicalType(Context.getObjCClassType())) { |
Chris Lattner | 2b1cc8b | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 314 | ObjCMethodDecl *Method = 0; |
Chris Lattner | 6562fda | 2008-07-21 06:44:27 +0000 | [diff] [blame] | 315 | if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) { |
Steve Naroff | e2af8b1 | 2008-06-05 14:49:39 +0000 | [diff] [blame] | 316 | // If we have an implementation in scope, check "private" methods. |
Chris Lattner | 6562fda | 2008-07-21 06:44:27 +0000 | [diff] [blame] | 317 | if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) |
Steve Naroff | e2af8b1 | 2008-06-05 14:49:39 +0000 | [diff] [blame] | 318 | if (ObjCImplementationDecl *ImpDecl = |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 319 | ObjCImplementations[ClassDecl->getIdentifier()]) |
Steve Naroff | e2af8b1 | 2008-06-05 14:49:39 +0000 | [diff] [blame] | 320 | Method = ImpDecl->getClassMethod(Sel); |
| 321 | } |
| 322 | if (!Method) |
| 323 | Method = FactoryMethodPool[Sel].Method; |
| 324 | if (!Method) |
Steve Naroff | 037cda5 | 2008-09-30 14:38:43 +0000 | [diff] [blame] | 325 | Method = LookupInstanceMethodInGlobalPool( |
| 326 | Sel, SourceRange(lbrac,rbrac)); |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 327 | if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, "-", |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 328 | lbrac, rbrac, returnType)) |
| 329 | return true; |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 330 | return new ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac, rbrac, |
| 331 | ArgExprs, NumArgs); |
| 332 | } |
| 333 | |
Chris Lattner | 2b1cc8b | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 334 | ObjCMethodDecl *Method = 0; |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 335 | ObjCInterfaceDecl* ClassDecl = 0; |
Chris Lattner | 2b1cc8b | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 336 | |
| 337 | // We allow sending a message to a qualified ID ("id<foo>"), which is ok as |
| 338 | // long as one of the protocols implements the selector (if not, warn). |
Chris Lattner | b77792e | 2008-07-26 22:17:49 +0000 | [diff] [blame] | 339 | if (ObjCQualifiedIdType *QIT = dyn_cast<ObjCQualifiedIdType>(ReceiverCType)) { |
Chris Lattner | 2b1cc8b | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 340 | // Search protocols |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 341 | for (unsigned i = 0; i < QIT->getNumProtocols(); i++) { |
| 342 | ObjCProtocolDecl *PDecl = QIT->getProtocols(i); |
| 343 | if (PDecl && (Method = PDecl->lookupInstanceMethod(Sel))) |
| 344 | break; |
| 345 | } |
| 346 | if (!Method) |
| 347 | Diag(lbrac, diag::warn_method_not_found_in_protocol, |
| 348 | std::string("-"), Sel.getName(), |
Chris Lattner | 0b2f7ea | 2008-07-21 06:16:07 +0000 | [diff] [blame] | 349 | RExpr->getSourceRange()); |
Chris Lattner | 2b1cc8b | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 350 | } else if (const ObjCInterfaceType *OCIReceiver = |
Chris Lattner | b77792e | 2008-07-26 22:17:49 +0000 | [diff] [blame] | 351 | ReceiverCType->getAsPointerToObjCInterfaceType()) { |
Chris Lattner | 2b1cc8b | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 352 | // We allow sending a message to a pointer to an interface (an object). |
Chris Lattner | fb8cc1d | 2008-02-01 06:43:02 +0000 | [diff] [blame] | 353 | |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 354 | ClassDecl = OCIReceiver->getDecl(); |
Steve Naroff | 037cda5 | 2008-09-30 14:38:43 +0000 | [diff] [blame] | 355 | // FIXME: consider using LookupInstanceMethodInGlobalPool, since it will be |
| 356 | // faster than the following method (which can do *many* linear searches). |
| 357 | // The idea is to add class info to InstanceMethodPool. |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 358 | Method = ClassDecl->lookupInstanceMethod(Sel); |
| 359 | |
| 360 | if (!Method) { |
| 361 | // Search protocol qualifiers. |
| 362 | for (ObjCQualifiedIdType::qual_iterator QI = OCIReceiver->qual_begin(), |
| 363 | E = OCIReceiver->qual_end(); QI != E; ++QI) { |
| 364 | if ((Method = (*QI)->lookupInstanceMethod(Sel))) |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 365 | break; |
| 366 | } |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 367 | } |
Chris Lattner | c188d30 | 2008-07-21 05:27:51 +0000 | [diff] [blame] | 368 | |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 369 | if (!Method && !OCIReceiver->qual_empty()) |
| 370 | Diag(lbrac, diag::warn_method_not_found_in_protocol, |
| 371 | std::string("-"), Sel.getName(), |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 372 | SourceRange(lbrac, rbrac)); |
Chris Lattner | 2b1cc8b | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 373 | } else { |
| 374 | Diag(lbrac, diag::error_bad_receiver_type, |
Chris Lattner | 0b2f7ea | 2008-07-21 06:16:07 +0000 | [diff] [blame] | 375 | RExpr->getType().getAsString(), RExpr->getSourceRange()); |
Chris Lattner | 2b1cc8b | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 376 | return true; |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | if (!Method) { |
| 380 | // If we have an implementation in scope, check "private" methods. |
| 381 | if (ClassDecl) |
| 382 | if (ObjCImplementationDecl *ImpDecl = |
| 383 | ObjCImplementations[ClassDecl->getIdentifier()]) |
| 384 | Method = ImpDecl->getInstanceMethod(Sel); |
| 385 | // If we still haven't found a method, look in the global pool. This |
| 386 | // behavior isn't very desirable, however we need it for GCC |
| 387 | // compatibility. |
| 388 | if (!Method) |
Steve Naroff | 037cda5 | 2008-09-30 14:38:43 +0000 | [diff] [blame] | 389 | Method = LookupInstanceMethodInGlobalPool( |
| 390 | Sel, SourceRange(lbrac,rbrac)); |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 391 | } |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 392 | if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, "-", |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 393 | lbrac, rbrac, returnType)) |
| 394 | return true; |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 395 | return new ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac, rbrac, |
| 396 | ArgExprs, NumArgs); |
| 397 | } |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 398 | |
| 399 | //===----------------------------------------------------------------------===// |
| 400 | // ObjCQualifiedIdTypesAreCompatible - Compatibility testing for qualified id's. |
| 401 | //===----------------------------------------------------------------------===// |
| 402 | |
| 403 | /// ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the |
| 404 | /// inheritance hierarchy of 'rProto'. |
| 405 | static bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, |
| 406 | ObjCProtocolDecl *rProto) { |
| 407 | if (lProto == rProto) |
| 408 | return true; |
Chris Lattner | 780f329 | 2008-07-21 21:32:27 +0000 | [diff] [blame] | 409 | for (ObjCProtocolDecl::protocol_iterator PI = rProto->protocol_begin(), |
| 410 | E = rProto->protocol_end(); PI != E; ++PI) |
| 411 | if (ProtocolCompatibleWithProtocol(lProto, *PI)) |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 412 | return true; |
| 413 | return false; |
| 414 | } |
| 415 | |
| 416 | /// ClassImplementsProtocol - Checks that 'lProto' protocol |
| 417 | /// has been implemented in IDecl class, its super class or categories (if |
| 418 | /// lookupCategory is true). |
| 419 | static bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, |
| 420 | ObjCInterfaceDecl *IDecl, |
Fariborz Jahanian | 2663170 | 2008-06-04 19:00:03 +0000 | [diff] [blame] | 421 | bool lookupCategory, |
| 422 | bool RHSIsQualifiedID = false) { |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 423 | |
| 424 | // 1st, look up the class. |
Chris Lattner | 3db6cae | 2008-07-21 18:19:38 +0000 | [diff] [blame] | 425 | const ObjCList<ObjCProtocolDecl> &Protocols = |
| 426 | IDecl->getReferencedProtocols(); |
| 427 | |
| 428 | for (ObjCList<ObjCProtocolDecl>::iterator PI = Protocols.begin(), |
| 429 | E = Protocols.end(); PI != E; ++PI) { |
| 430 | if (ProtocolCompatibleWithProtocol(lProto, *PI)) |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 431 | return true; |
Fariborz Jahanian | 2663170 | 2008-06-04 19:00:03 +0000 | [diff] [blame] | 432 | // This is dubious and is added to be compatible with gcc. |
| 433 | // In gcc, it is also allowed assigning a protocol-qualified 'id' |
| 434 | // type to a LHS object when protocol in qualified LHS is in list |
| 435 | // of protocols in the rhs 'id' object. This IMO, should be a bug. |
Ted Kremenek | fd5b2ce | 2008-06-04 20:48:08 +0000 | [diff] [blame] | 436 | // FIXME: Treat this as an extension, and flag this as an error when |
| 437 | // GCC extensions are not enabled. |
Chris Lattner | 3db6cae | 2008-07-21 18:19:38 +0000 | [diff] [blame] | 438 | if (RHSIsQualifiedID && ProtocolCompatibleWithProtocol(*PI, lProto)) |
Fariborz Jahanian | 2663170 | 2008-06-04 19:00:03 +0000 | [diff] [blame] | 439 | return true; |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | // 2nd, look up the category. |
| 443 | if (lookupCategory) |
| 444 | for (ObjCCategoryDecl *CDecl = IDecl->getCategoryList(); CDecl; |
| 445 | CDecl = CDecl->getNextClassCategory()) { |
Chris Lattner | 780f329 | 2008-07-21 21:32:27 +0000 | [diff] [blame] | 446 | for (ObjCCategoryDecl::protocol_iterator PI = CDecl->protocol_begin(), |
| 447 | E = CDecl->protocol_end(); PI != E; ++PI) |
| 448 | if (ProtocolCompatibleWithProtocol(lProto, *PI)) |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 449 | return true; |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | // 3rd, look up the super class(s) |
| 453 | if (IDecl->getSuperClass()) |
| 454 | return |
Fariborz Jahanian | 2663170 | 2008-06-04 19:00:03 +0000 | [diff] [blame] | 455 | ClassImplementsProtocol(lProto, IDecl->getSuperClass(), lookupCategory, |
| 456 | RHSIsQualifiedID); |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 457 | |
| 458 | return false; |
| 459 | } |
| 460 | |
Chris Lattner | b1698cf | 2008-04-20 02:09:31 +0000 | [diff] [blame] | 461 | /// ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an |
| 462 | /// ObjCQualifiedIDType. |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 463 | bool Sema::ObjCQualifiedIdTypesAreCompatible(QualType lhs, QualType rhs, |
| 464 | bool compare) { |
| 465 | // Allow id<P..> and an 'id' or void* type in all cases. |
| 466 | if (const PointerType *PT = lhs->getAsPointerType()) { |
| 467 | QualType PointeeTy = PT->getPointeeType(); |
| 468 | if (Context.isObjCIdType(PointeeTy) || PointeeTy->isVoidType()) |
| 469 | return true; |
| 470 | } else if (const PointerType *PT = rhs->getAsPointerType()) { |
| 471 | QualType PointeeTy = PT->getPointeeType(); |
| 472 | if (Context.isObjCIdType(PointeeTy) || PointeeTy->isVoidType()) |
| 473 | return true; |
| 474 | } |
| 475 | |
Chris Lattner | b1698cf | 2008-04-20 02:09:31 +0000 | [diff] [blame] | 476 | if (const ObjCQualifiedIdType *lhsQID = lhs->getAsObjCQualifiedIdType()) { |
| 477 | const ObjCQualifiedIdType *rhsQID = rhs->getAsObjCQualifiedIdType(); |
| 478 | const ObjCQualifiedInterfaceType *rhsQI = 0; |
Steve Naroff | 289d9f2 | 2008-06-01 02:43:50 +0000 | [diff] [blame] | 479 | QualType rtype; |
| 480 | |
Chris Lattner | b1698cf | 2008-04-20 02:09:31 +0000 | [diff] [blame] | 481 | if (!rhsQID) { |
| 482 | // Not comparing two ObjCQualifiedIdType's? |
| 483 | if (!rhs->isPointerType()) return false; |
Steve Naroff | 289d9f2 | 2008-06-01 02:43:50 +0000 | [diff] [blame] | 484 | |
| 485 | rtype = rhs->getAsPointerType()->getPointeeType(); |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 486 | rhsQI = rtype->getAsObjCQualifiedInterfaceType(); |
Chris Lattner | b1698cf | 2008-04-20 02:09:31 +0000 | [diff] [blame] | 487 | if (rhsQI == 0) { |
Steve Naroff | 289d9f2 | 2008-06-01 02:43:50 +0000 | [diff] [blame] | 488 | // If the RHS is a unqualified interface pointer "NSString*", |
| 489 | // make sure we check the class hierarchy. |
Chris Lattner | b1698cf | 2008-04-20 02:09:31 +0000 | [diff] [blame] | 490 | if (const ObjCInterfaceType *IT = rtype->getAsObjCInterfaceType()) { |
| 491 | ObjCInterfaceDecl *rhsID = IT->getDecl(); |
| 492 | for (unsigned i = 0; i != lhsQID->getNumProtocols(); ++i) { |
| 493 | // when comparing an id<P> on lhs with a static type on rhs, |
| 494 | // see if static class implements all of id's protocols, directly or |
| 495 | // through its super class and categories. |
| 496 | if (!ClassImplementsProtocol(lhsQID->getProtocols(i), rhsID, true)) |
| 497 | return false; |
| 498 | } |
| 499 | return true; |
| 500 | } |
| 501 | } |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 502 | } |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 503 | |
| 504 | ObjCQualifiedIdType::qual_iterator RHSProtoI, RHSProtoE; |
Steve Naroff | 289d9f2 | 2008-06-01 02:43:50 +0000 | [diff] [blame] | 505 | if (rhsQI) { // We have a qualified interface (e.g. "NSObject<Proto> *"). |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 506 | RHSProtoI = rhsQI->qual_begin(); |
| 507 | RHSProtoE = rhsQI->qual_end(); |
Steve Naroff | 289d9f2 | 2008-06-01 02:43:50 +0000 | [diff] [blame] | 508 | } else if (rhsQID) { // We have a qualified id (e.g. "id<Proto> *"). |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 509 | RHSProtoI = rhsQID->qual_begin(); |
| 510 | RHSProtoE = rhsQID->qual_end(); |
Chris Lattner | b1698cf | 2008-04-20 02:09:31 +0000 | [diff] [blame] | 511 | } else { |
| 512 | return false; |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | for (unsigned i =0; i < lhsQID->getNumProtocols(); i++) { |
| 516 | ObjCProtocolDecl *lhsProto = lhsQID->getProtocols(i); |
| 517 | bool match = false; |
| 518 | |
| 519 | // when comparing an id<P> on lhs with a static type on rhs, |
| 520 | // see if static class implements all of id's protocols, directly or |
| 521 | // through its super class and categories. |
Chris Lattner | b1698cf | 2008-04-20 02:09:31 +0000 | [diff] [blame] | 522 | for (; RHSProtoI != RHSProtoE; ++RHSProtoI) { |
| 523 | ObjCProtocolDecl *rhsProto = *RHSProtoI; |
| 524 | if (ProtocolCompatibleWithProtocol(lhsProto, rhsProto) || |
| 525 | compare && ProtocolCompatibleWithProtocol(rhsProto, lhsProto)) { |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 526 | match = true; |
| 527 | break; |
| 528 | } |
| 529 | } |
Steve Naroff | 289d9f2 | 2008-06-01 02:43:50 +0000 | [diff] [blame] | 530 | if (rhsQI) { |
| 531 | // If the RHS is a qualified interface pointer "NSString<P>*", |
| 532 | // make sure we check the class hierarchy. |
| 533 | if (const ObjCInterfaceType *IT = rtype->getAsObjCInterfaceType()) { |
| 534 | ObjCInterfaceDecl *rhsID = IT->getDecl(); |
| 535 | for (unsigned i = 0; i != lhsQID->getNumProtocols(); ++i) { |
| 536 | // when comparing an id<P> on lhs with a static type on rhs, |
| 537 | // see if static class implements all of id's protocols, directly or |
| 538 | // through its super class and categories. |
| 539 | if (ClassImplementsProtocol(lhsQID->getProtocols(i), rhsID, true)) { |
| 540 | match = true; |
| 541 | break; |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | } |
Chris Lattner | b1698cf | 2008-04-20 02:09:31 +0000 | [diff] [blame] | 546 | if (!match) |
| 547 | return false; |
| 548 | } |
| 549 | |
| 550 | return true; |
| 551 | } |
| 552 | |
| 553 | const ObjCQualifiedIdType *rhsQID = rhs->getAsObjCQualifiedIdType(); |
| 554 | assert(rhsQID && "One of the LHS/RHS should be id<x>"); |
| 555 | |
| 556 | if (!lhs->isPointerType()) |
| 557 | return false; |
| 558 | |
| 559 | QualType ltype = lhs->getAsPointerType()->getPointeeType(); |
| 560 | if (const ObjCQualifiedInterfaceType *lhsQI = |
| 561 | ltype->getAsObjCQualifiedInterfaceType()) { |
| 562 | ObjCQualifiedIdType::qual_iterator LHSProtoI = lhsQI->qual_begin(); |
| 563 | ObjCQualifiedIdType::qual_iterator LHSProtoE = lhsQI->qual_end(); |
| 564 | for (; LHSProtoI != LHSProtoE; ++LHSProtoI) { |
| 565 | bool match = false; |
| 566 | ObjCProtocolDecl *lhsProto = *LHSProtoI; |
| 567 | for (unsigned j = 0; j < rhsQID->getNumProtocols(); j++) { |
| 568 | ObjCProtocolDecl *rhsProto = rhsQID->getProtocols(j); |
| 569 | if (ProtocolCompatibleWithProtocol(lhsProto, rhsProto) || |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 570 | compare && ProtocolCompatibleWithProtocol(rhsProto, lhsProto)) { |
Chris Lattner | b1698cf | 2008-04-20 02:09:31 +0000 | [diff] [blame] | 571 | match = true; |
| 572 | break; |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 573 | } |
| 574 | } |
Chris Lattner | b1698cf | 2008-04-20 02:09:31 +0000 | [diff] [blame] | 575 | if (!match) |
| 576 | return false; |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 577 | } |
Chris Lattner | b1698cf | 2008-04-20 02:09:31 +0000 | [diff] [blame] | 578 | return true; |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 579 | } |
Chris Lattner | b1698cf | 2008-04-20 02:09:31 +0000 | [diff] [blame] | 580 | |
| 581 | if (const ObjCInterfaceType *IT = ltype->getAsObjCInterfaceType()) { |
| 582 | // for static type vs. qualified 'id' type, check that class implements |
| 583 | // all of 'id's protocols. |
| 584 | ObjCInterfaceDecl *lhsID = IT->getDecl(); |
| 585 | for (unsigned j = 0; j < rhsQID->getNumProtocols(); j++) { |
| 586 | ObjCProtocolDecl *rhsProto = rhsQID->getProtocols(j); |
Fariborz Jahanian | 2663170 | 2008-06-04 19:00:03 +0000 | [diff] [blame] | 587 | if (!ClassImplementsProtocol(rhsProto, lhsID, compare, true)) |
Chris Lattner | b1698cf | 2008-04-20 02:09:31 +0000 | [diff] [blame] | 588 | return false; |
| 589 | } |
| 590 | return true; |
| 591 | } |
| 592 | return false; |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 593 | } |
| 594 | |