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" |
Chris Lattner | 39c28bb | 2009-02-18 06:48:40 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/SmallString.h" |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 19 | #include "clang/Lex/Preprocessor.h" |
| 20 | |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 21 | using namespace clang; |
| 22 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 23 | Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs, |
Chris Lattner | 39c28bb | 2009-02-18 06:48:40 +0000 | [diff] [blame] | 24 | ExprTy **strings, |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 25 | unsigned NumStrings) { |
Chris Lattner | 39c28bb | 2009-02-18 06:48:40 +0000 | [diff] [blame] | 26 | StringLiteral **Strings = reinterpret_cast<StringLiteral**>(strings); |
| 27 | |
Chris Lattner | f4b136f | 2009-02-18 06:13:04 +0000 | [diff] [blame] | 28 | // Most ObjC strings are formed out of a single piece. However, we *can* |
| 29 | // have strings formed out of multiple @ strings with multiple pptokens in |
| 30 | // each one, e.g. @"foo" "bar" @"baz" "qux" which need to be turned into one |
| 31 | // StringLiteral for ObjCStringLiteral to hold onto. |
Chris Lattner | 39c28bb | 2009-02-18 06:48:40 +0000 | [diff] [blame] | 32 | StringLiteral *S = Strings[0]; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 33 | |
Chris Lattner | f4b136f | 2009-02-18 06:13:04 +0000 | [diff] [blame] | 34 | // If we have a multi-part string, merge it all together. |
| 35 | if (NumStrings != 1) { |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 36 | // Concatenate objc strings. |
Chris Lattner | 39c28bb | 2009-02-18 06:48:40 +0000 | [diff] [blame] | 37 | llvm::SmallString<128> StrBuf; |
| 38 | llvm::SmallVector<SourceLocation, 8> StrLocs; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 39 | |
Chris Lattner | 726e168 | 2009-02-18 05:49:11 +0000 | [diff] [blame] | 40 | for (unsigned i = 0; i != NumStrings; ++i) { |
Chris Lattner | 39c28bb | 2009-02-18 06:48:40 +0000 | [diff] [blame] | 41 | S = Strings[i]; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 42 | |
Chris Lattner | 39c28bb | 2009-02-18 06:48:40 +0000 | [diff] [blame] | 43 | // ObjC strings can't be wide. |
Chris Lattner | f4b136f | 2009-02-18 06:13:04 +0000 | [diff] [blame] | 44 | if (S->isWide()) { |
| 45 | Diag(S->getLocStart(), diag::err_cfstring_literal_not_string_constant) |
| 46 | << S->getSourceRange(); |
| 47 | return true; |
| 48 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 49 | |
Chris Lattner | 39c28bb | 2009-02-18 06:48:40 +0000 | [diff] [blame] | 50 | // Get the string data. |
| 51 | StrBuf.append(S->getStrData(), S->getStrData()+S->getByteLength()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 52 | |
Chris Lattner | 39c28bb | 2009-02-18 06:48:40 +0000 | [diff] [blame] | 53 | // Get the locations of the string tokens. |
| 54 | StrLocs.append(S->tokloc_begin(), S->tokloc_end()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 55 | |
Chris Lattner | 39c28bb | 2009-02-18 06:48:40 +0000 | [diff] [blame] | 56 | // Free the temporary string. |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 57 | S->Destroy(Context); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 58 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 59 | |
Chris Lattner | 39c28bb | 2009-02-18 06:48:40 +0000 | [diff] [blame] | 60 | // Create the aggregate string with the appropriate content and location |
| 61 | // information. |
| 62 | S = StringLiteral::Create(Context, &StrBuf[0], StrBuf.size(), false, |
Chris Lattner | 2085fd6 | 2009-02-18 06:40:38 +0000 | [diff] [blame] | 63 | Context.getPointerType(Context.CharTy), |
Chris Lattner | 39c28bb | 2009-02-18 06:48:40 +0000 | [diff] [blame] | 64 | &StrLocs[0], StrLocs.size()); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 65 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 66 | |
Chris Lattner | 6903981 | 2009-02-18 06:01:06 +0000 | [diff] [blame] | 67 | // Verify that this composite string is acceptable for ObjC strings. |
| 68 | if (CheckObjCString(S)) |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 69 | return true; |
Chris Lattner | a0af1fe | 2009-02-18 06:06:56 +0000 | [diff] [blame] | 70 | |
| 71 | // Initialize the constant string interface lazily. This assumes |
Steve Naroff | d9fd764 | 2009-04-07 14:18:33 +0000 | [diff] [blame] | 72 | // the NSString interface is seen in this translation unit. Note: We |
| 73 | // don't use NSConstantString, since the runtime team considers this |
| 74 | // interface private (even though it appears in the header files). |
Chris Lattner | a0af1fe | 2009-02-18 06:06:56 +0000 | [diff] [blame] | 75 | QualType Ty = Context.getObjCConstantStringInterface(); |
| 76 | if (!Ty.isNull()) { |
Steve Naroff | 14108da | 2009-07-10 23:34:53 +0000 | [diff] [blame] | 77 | Ty = Context.getObjCObjectPointerType(Ty); |
Chris Lattner | 13fd7e5 | 2008-06-21 21:44:18 +0000 | [diff] [blame] | 78 | } else { |
Steve Naroff | d9fd764 | 2009-04-07 14:18:33 +0000 | [diff] [blame] | 79 | IdentifierInfo *NSIdent = &Context.Idents.get("NSString"); |
Chris Lattner | a0af1fe | 2009-02-18 06:06:56 +0000 | [diff] [blame] | 80 | NamedDecl *IF = LookupName(TUScope, NSIdent, LookupOrdinaryName); |
| 81 | if (ObjCInterfaceDecl *StrIF = dyn_cast_or_null<ObjCInterfaceDecl>(IF)) { |
| 82 | Context.setObjCConstantStringInterface(StrIF); |
| 83 | Ty = Context.getObjCConstantStringInterface(); |
Steve Naroff | 14108da | 2009-07-10 23:34:53 +0000 | [diff] [blame] | 84 | Ty = Context.getObjCObjectPointerType(Ty); |
Chris Lattner | a0af1fe | 2009-02-18 06:06:56 +0000 | [diff] [blame] | 85 | } else { |
Steve Naroff | d9fd764 | 2009-04-07 14:18:33 +0000 | [diff] [blame] | 86 | // If there is no NSString interface defined then treat constant |
Chris Lattner | a0af1fe | 2009-02-18 06:06:56 +0000 | [diff] [blame] | 87 | // strings as untyped objects and let the runtime figure it out later. |
| 88 | Ty = Context.getObjCIdType(); |
| 89 | } |
Chris Lattner | 13fd7e5 | 2008-06-21 21:44:18 +0000 | [diff] [blame] | 90 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 91 | |
Chris Lattner | f4b136f | 2009-02-18 06:13:04 +0000 | [diff] [blame] | 92 | return new (Context) ObjCStringLiteral(S, Ty, AtLocs[0]); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 93 | } |
| 94 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 95 | Expr *Sema::BuildObjCEncodeExpression(SourceLocation AtLoc, |
Anders Carlsson | fc0f021 | 2009-06-07 18:45:35 +0000 | [diff] [blame] | 96 | QualType EncodedType, |
| 97 | SourceLocation RParenLoc) { |
| 98 | QualType StrTy; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 99 | if (EncodedType->isDependentType()) |
Anders Carlsson | fc0f021 | 2009-06-07 18:45:35 +0000 | [diff] [blame] | 100 | StrTy = Context.DependentTy; |
| 101 | else { |
| 102 | std::string Str; |
| 103 | Context.getObjCEncodingForType(EncodedType, Str); |
| 104 | |
| 105 | // The type of @encode is the same as the type of the corresponding string, |
| 106 | // which is an array type. |
| 107 | StrTy = Context.CharTy; |
| 108 | // A C++ string literal has a const-qualified element type (C++ 2.13.4p1). |
| 109 | if (getLangOptions().CPlusPlus) |
| 110 | StrTy.addConst(); |
| 111 | StrTy = Context.getConstantArrayType(StrTy, llvm::APInt(32, Str.size()+1), |
| 112 | ArrayType::Normal, 0); |
| 113 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 114 | |
Anders Carlsson | fc0f021 | 2009-06-07 18:45:35 +0000 | [diff] [blame] | 115 | return new (Context) ObjCEncodeExpr(StrTy, EncodedType, AtLoc, RParenLoc); |
| 116 | } |
| 117 | |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 118 | Sema::ExprResult Sema::ParseObjCEncodeExpression(SourceLocation AtLoc, |
| 119 | SourceLocation EncodeLoc, |
| 120 | SourceLocation LParenLoc, |
Chris Lattner | a0af1fe | 2009-02-18 06:06:56 +0000 | [diff] [blame] | 121 | TypeTy *ty, |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 122 | SourceLocation RParenLoc) { |
Argyrios Kyrtzidis | e866190 | 2009-08-19 01:28:28 +0000 | [diff] [blame] | 123 | // FIXME: Preserve type source info ? |
| 124 | QualType EncodedType = GetTypeFromParser(ty); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 125 | |
Anders Carlsson | fc0f021 | 2009-06-07 18:45:35 +0000 | [diff] [blame] | 126 | return BuildObjCEncodeExpression(AtLoc, EncodedType, RParenLoc); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | Sema::ExprResult Sema::ParseObjCSelectorExpression(Selector Sel, |
| 130 | SourceLocation AtLoc, |
| 131 | SourceLocation SelLoc, |
| 132 | SourceLocation LParenLoc, |
| 133 | SourceLocation RParenLoc) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 134 | ObjCMethodDecl *Method = LookupInstanceMethodInGlobalPool(Sel, |
Fariborz Jahanian | 835ed7f | 2009-08-22 21:13:55 +0000 | [diff] [blame] | 135 | SourceRange(LParenLoc, RParenLoc), false); |
Fariborz Jahanian | 7ff22de | 2009-06-16 16:25:00 +0000 | [diff] [blame] | 136 | if (!Method) |
| 137 | Method = LookupFactoryMethodInGlobalPool(Sel, |
| 138 | SourceRange(LParenLoc, RParenLoc)); |
| 139 | if (!Method) |
| 140 | Diag(SelLoc, diag::warn_undeclared_selector) << Sel; |
| 141 | |
Chris Lattner | a0af1fe | 2009-02-18 06:06:56 +0000 | [diff] [blame] | 142 | QualType Ty = Context.getObjCSelType(); |
| 143 | return new (Context) ObjCSelectorExpr(Ty, Sel, AtLoc, RParenLoc); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | Sema::ExprResult Sema::ParseObjCProtocolExpression(IdentifierInfo *ProtocolId, |
| 147 | SourceLocation AtLoc, |
| 148 | SourceLocation ProtoLoc, |
| 149 | SourceLocation LParenLoc, |
| 150 | SourceLocation RParenLoc) { |
Douglas Gregor | 6e378de | 2009-04-23 23:18:26 +0000 | [diff] [blame] | 151 | ObjCProtocolDecl* PDecl = LookupProtocol(ProtocolId); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 152 | if (!PDecl) { |
Chris Lattner | 3c73c41 | 2008-11-19 08:23:25 +0000 | [diff] [blame] | 153 | Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId; |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 154 | return true; |
| 155 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 156 | |
Chris Lattner | a0af1fe | 2009-02-18 06:06:56 +0000 | [diff] [blame] | 157 | QualType Ty = Context.getObjCProtoType(); |
| 158 | if (Ty.isNull()) |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 159 | return true; |
Steve Naroff | 14108da | 2009-07-10 23:34:53 +0000 | [diff] [blame] | 160 | Ty = Context.getObjCObjectPointerType(Ty); |
Chris Lattner | a0af1fe | 2009-02-18 06:06:56 +0000 | [diff] [blame] | 161 | return new (Context) ObjCProtocolExpr(Ty, PDecl, AtLoc, RParenLoc); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 162 | } |
| 163 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 164 | bool Sema::CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs, |
| 165 | Selector Sel, ObjCMethodDecl *Method, |
Chris Lattner | 077bf5e | 2008-11-24 03:33:13 +0000 | [diff] [blame] | 166 | bool isClassMessage, |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 167 | SourceLocation lbrac, SourceLocation rbrac, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 168 | QualType &ReturnType) { |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 169 | if (!Method) { |
Daniel Dunbar | 6660c8a | 2008-09-11 00:04:36 +0000 | [diff] [blame] | 170 | // Apply default argument promotion as for (C99 6.5.2.2p6). |
| 171 | for (unsigned i = 0; i != NumArgs; i++) |
| 172 | DefaultArgumentPromotion(Args[i]); |
| 173 | |
Chris Lattner | 077bf5e | 2008-11-24 03:33:13 +0000 | [diff] [blame] | 174 | unsigned DiagID = isClassMessage ? diag::warn_class_method_not_found : |
| 175 | diag::warn_inst_method_not_found; |
| 176 | Diag(lbrac, DiagID) |
| 177 | << Sel << isClassMessage << SourceRange(lbrac, rbrac); |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 178 | ReturnType = Context.getObjCIdType(); |
| 179 | return false; |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 180 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 181 | |
Chris Lattner | 077bf5e | 2008-11-24 03:33:13 +0000 | [diff] [blame] | 182 | ReturnType = Method->getResultType(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 183 | |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 184 | unsigned NumNamedArgs = Sel.getNumArgs(); |
| 185 | assert(NumArgs >= NumNamedArgs && "Too few arguments for selector!"); |
| 186 | |
Chris Lattner | 312531a | 2009-04-12 08:11:20 +0000 | [diff] [blame] | 187 | bool IsError = false; |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 188 | for (unsigned i = 0; i < NumNamedArgs; i++) { |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 189 | Expr *argExpr = Args[i]; |
| 190 | assert(argExpr && "CheckMessageArgumentTypes(): missing expression"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 191 | |
Chris Lattner | 89951a8 | 2009-02-20 18:43:26 +0000 | [diff] [blame] | 192 | QualType lhsType = Method->param_begin()[i]->getType(); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 193 | QualType rhsType = argExpr->getType(); |
| 194 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 195 | // 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] | 196 | if (lhsType->isArrayType()) |
| 197 | lhsType = Context.getArrayDecayedType(lhsType); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 198 | else if (lhsType->isFunctionType()) |
| 199 | lhsType = Context.getPointerType(lhsType); |
| 200 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 201 | AssignConvertType Result = |
Chris Lattner | 987798a | 2008-04-02 17:17:33 +0000 | [diff] [blame] | 202 | CheckSingleAssignmentConstraints(lhsType, argExpr); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 203 | if (Args[i] != argExpr) // The expression was converted. |
| 204 | Args[i] = argExpr; // Make sure we store the converted expression. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 205 | |
| 206 | IsError |= |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 207 | DiagnoseAssignmentResult(Result, argExpr->getLocStart(), lhsType, rhsType, |
| 208 | argExpr, "sending"); |
| 209 | } |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 210 | |
| 211 | // Promote additional arguments to variadic methods. |
| 212 | if (Method->isVariadic()) { |
Anders Carlsson | dce5e2c | 2009-01-16 16:48:51 +0000 | [diff] [blame] | 213 | for (unsigned i = NumNamedArgs; i < NumArgs; ++i) |
Chris Lattner | 312531a | 2009-04-12 08:11:20 +0000 | [diff] [blame] | 214 | IsError |= DefaultVariadicArgumentPromotion(Args[i], VariadicMethod); |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 215 | } else { |
| 216 | // Check for extra arguments to non-variadic methods. |
| 217 | if (NumArgs != NumNamedArgs) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 218 | Diag(Args[NumNamedArgs]->getLocStart(), |
Chris Lattner | fa25bbb | 2008-11-19 05:08:23 +0000 | [diff] [blame] | 219 | diag::err_typecheck_call_too_many_args) |
Chris Lattner | 2c21a07 | 2008-11-21 18:44:24 +0000 | [diff] [blame] | 220 | << 2 /*method*/ << Method->getSourceRange() |
Chris Lattner | fa25bbb | 2008-11-19 05:08:23 +0000 | [diff] [blame] | 221 | << SourceRange(Args[NumNamedArgs]->getLocStart(), |
| 222 | Args[NumArgs-1]->getLocEnd()); |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 223 | } |
| 224 | } |
| 225 | |
Chris Lattner | 312531a | 2009-04-12 08:11:20 +0000 | [diff] [blame] | 226 | return IsError; |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Steve Naroff | 6b9dfd4 | 2009-03-04 15:11:40 +0000 | [diff] [blame] | 229 | bool Sema::isSelfExpr(Expr *RExpr) { |
| 230 | if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(RExpr)) |
| 231 | if (DRE->getDecl()->getIdentifier() == &Context.Idents.get("self")) |
| 232 | return true; |
| 233 | return false; |
| 234 | } |
| 235 | |
Steve Naroff | f1afaf6 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 236 | // Helper method for ActOnClassMethod/ActOnInstanceMethod. |
| 237 | // Will search "local" class/category implementations for a method decl. |
Fariborz Jahanian | 175ba1e | 2009-03-04 18:15:57 +0000 | [diff] [blame] | 238 | // If failed, then we search in class's root for an instance method. |
Steve Naroff | f1afaf6 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 239 | // Returns 0 if no method is found. |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 240 | ObjCMethodDecl *Sema::LookupPrivateClassMethod(Selector Sel, |
Steve Naroff | f1afaf6 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 241 | ObjCInterfaceDecl *ClassDecl) { |
| 242 | ObjCMethodDecl *Method = 0; |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 243 | // lookup in class and all superclasses |
| 244 | while (ClassDecl && !Method) { |
Argyrios Kyrtzidis | 8701877 | 2009-07-21 00:06:04 +0000 | [diff] [blame] | 245 | if (ObjCImplementationDecl *ImpDecl = ClassDecl->getImplementation()) |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 246 | Method = ImpDecl->getClassMethod(Sel); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 247 | |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 248 | // Look through local category implementations associated with the class. |
Argyrios Kyrtzidis | 1cb35dd | 2009-07-21 00:06:20 +0000 | [diff] [blame] | 249 | if (!Method) |
| 250 | Method = ClassDecl->getCategoryClassMethod(Sel); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 251 | |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 252 | // Before we give up, check if the selector is an instance method. |
| 253 | // But only in the root. This matches gcc's behaviour and what the |
| 254 | // runtime expects. |
| 255 | if (!Method && !ClassDecl->getSuperClass()) { |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 256 | Method = ClassDecl->lookupInstanceMethod(Sel); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 257 | // Look through local category implementations associated |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 258 | // with the root class. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 259 | if (!Method) |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 260 | Method = LookupPrivateInstanceMethod(Sel, ClassDecl); |
| 261 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 262 | |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 263 | ClassDecl = ClassDecl->getSuperClass(); |
Steve Naroff | f1afaf6 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 264 | } |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 265 | return Method; |
| 266 | } |
| 267 | |
| 268 | ObjCMethodDecl *Sema::LookupPrivateInstanceMethod(Selector Sel, |
| 269 | ObjCInterfaceDecl *ClassDecl) { |
| 270 | ObjCMethodDecl *Method = 0; |
| 271 | while (ClassDecl && !Method) { |
| 272 | // If we have implementations in scope, check "private" methods. |
Argyrios Kyrtzidis | 8701877 | 2009-07-21 00:06:04 +0000 | [diff] [blame] | 273 | if (ObjCImplementationDecl *ImpDecl = ClassDecl->getImplementation()) |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 274 | Method = ImpDecl->getInstanceMethod(Sel); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 275 | |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 276 | // Look through local category implementations associated with the class. |
Argyrios Kyrtzidis | 1cb35dd | 2009-07-21 00:06:20 +0000 | [diff] [blame] | 277 | if (!Method) |
| 278 | Method = ClassDecl->getCategoryInstanceMethod(Sel); |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 279 | ClassDecl = ClassDecl->getSuperClass(); |
Fariborz Jahanian | 175ba1e | 2009-03-04 18:15:57 +0000 | [diff] [blame] | 280 | } |
Steve Naroff | f1afaf6 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 281 | return Method; |
| 282 | } |
| 283 | |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 284 | Action::OwningExprResult Sema::ActOnClassPropertyRefExpr( |
| 285 | IdentifierInfo &receiverName, |
| 286 | IdentifierInfo &propertyName, |
| 287 | SourceLocation &receiverNameLoc, |
| 288 | SourceLocation &propertyNameLoc) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 289 | |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 290 | ObjCInterfaceDecl *IFace = getObjCInterfaceDecl(&receiverName); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 291 | |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 292 | // Search for a declared property first. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 293 | |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 294 | Selector Sel = PP.getSelectorTable().getNullarySelector(&propertyName); |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 295 | ObjCMethodDecl *Getter = IFace->lookupClassMethod(Sel); |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 296 | |
| 297 | // If this reference is in an @implementation, check for 'private' methods. |
| 298 | if (!Getter) |
| 299 | if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) |
| 300 | if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) |
Argyrios Kyrtzidis | 8701877 | 2009-07-21 00:06:04 +0000 | [diff] [blame] | 301 | if (ObjCImplementationDecl *ImpDecl = ClassDecl->getImplementation()) |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 302 | Getter = ImpDecl->getClassMethod(Sel); |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 303 | |
| 304 | if (Getter) { |
| 305 | // FIXME: refactor/share with ActOnMemberReference(). |
| 306 | // Check if we can reference this property. |
| 307 | if (DiagnoseUseOfDecl(Getter, propertyNameLoc)) |
| 308 | return ExprError(); |
| 309 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 310 | |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 311 | // Look for the matching setter, in case it is needed. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 312 | Selector SetterSel = |
| 313 | SelectorTable::constructSetterName(PP.getIdentifierTable(), |
Steve Naroff | fdc92b7 | 2009-03-10 17:24:38 +0000 | [diff] [blame] | 314 | PP.getSelectorTable(), &propertyName); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 315 | |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 316 | ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel); |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 317 | if (!Setter) { |
| 318 | // If this reference is in an @implementation, also check for 'private' |
| 319 | // methods. |
| 320 | if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) |
| 321 | if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) |
Argyrios Kyrtzidis | 8701877 | 2009-07-21 00:06:04 +0000 | [diff] [blame] | 322 | if (ObjCImplementationDecl *ImpDecl = ClassDecl->getImplementation()) |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 323 | Setter = ImpDecl->getClassMethod(SetterSel); |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 324 | } |
| 325 | // Look through local category implementations associated with the class. |
Argyrios Kyrtzidis | 1cb35dd | 2009-07-21 00:06:20 +0000 | [diff] [blame] | 326 | if (!Setter) |
| 327 | Setter = IFace->getCategoryClassMethod(SetterSel); |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 328 | |
| 329 | if (Setter && DiagnoseUseOfDecl(Setter, propertyNameLoc)) |
| 330 | return ExprError(); |
| 331 | |
| 332 | if (Getter || Setter) { |
| 333 | QualType PType; |
| 334 | |
| 335 | if (Getter) |
| 336 | PType = Getter->getResultType(); |
| 337 | else { |
| 338 | for (ObjCMethodDecl::param_iterator PI = Setter->param_begin(), |
| 339 | E = Setter->param_end(); PI != E; ++PI) |
| 340 | PType = (*PI)->getType(); |
| 341 | } |
Fariborz Jahanian | 09105f5 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 342 | return Owned(new (Context) ObjCImplicitSetterGetterRefExpr( |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 343 | Getter, PType, Setter, |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 344 | propertyNameLoc, IFace, receiverNameLoc)); |
| 345 | } |
| 346 | return ExprError(Diag(propertyNameLoc, diag::err_property_not_found) |
| 347 | << &propertyName << Context.getObjCInterfaceType(IFace)); |
| 348 | } |
| 349 | |
| 350 | |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 351 | // ActOnClassMessage - used for both unary and keyword messages. |
| 352 | // ArgExprs is optional - if it is present, the number of expressions |
| 353 | // is obtained from Sel.getNumArgs(). |
| 354 | Sema::ExprResult Sema::ActOnClassMessage( |
| 355 | Scope *S, |
| 356 | IdentifierInfo *receiverName, Selector Sel, |
Anders Carlsson | ff975cf | 2009-02-14 18:21:46 +0000 | [diff] [blame] | 357 | SourceLocation lbrac, SourceLocation receiverLoc, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 358 | SourceLocation selectorLoc, SourceLocation rbrac, |
| 359 | ExprTy **Args, unsigned NumArgs) { |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 360 | assert(receiverName && "missing receiver class name"); |
| 361 | |
| 362 | Expr **ArgExprs = reinterpret_cast<Expr **>(Args); |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 363 | ObjCInterfaceDecl* ClassDecl = 0; |
Steve Naroff | fc93d52 | 2008-07-24 19:44:33 +0000 | [diff] [blame] | 364 | bool isSuper = false; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 365 | |
Chris Lattner | 8469265 | 2008-11-20 05:35:30 +0000 | [diff] [blame] | 366 | if (receiverName->isStr("super")) { |
Steve Naroff | 5cb93b8 | 2008-11-19 15:54:23 +0000 | [diff] [blame] | 367 | if (getCurMethodDecl()) { |
| 368 | isSuper = true; |
Fariborz Jahanian | 4b1e275 | 2009-01-07 21:01:41 +0000 | [diff] [blame] | 369 | ObjCInterfaceDecl *OID = getCurMethodDecl()->getClassInterface(); |
| 370 | if (!OID) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 371 | return Diag(lbrac, diag::error_no_super_class_message) |
Fariborz Jahanian | 4b1e275 | 2009-01-07 21:01:41 +0000 | [diff] [blame] | 372 | << getCurMethodDecl()->getDeclName(); |
| 373 | ClassDecl = OID->getSuperClass(); |
Steve Naroff | 5cb93b8 | 2008-11-19 15:54:23 +0000 | [diff] [blame] | 374 | if (!ClassDecl) |
Fariborz Jahanian | 4b1e275 | 2009-01-07 21:01:41 +0000 | [diff] [blame] | 375 | return Diag(lbrac, diag::error_no_super_class) << OID->getDeclName(); |
Douglas Gregor | f8d49f6 | 2009-01-09 17:18:27 +0000 | [diff] [blame] | 376 | if (getCurMethodDecl()->isInstanceMethod()) { |
Steve Naroff | 5cb93b8 | 2008-11-19 15:54:23 +0000 | [diff] [blame] | 377 | QualType superTy = Context.getObjCInterfaceType(ClassDecl); |
Steve Naroff | 14108da | 2009-07-10 23:34:53 +0000 | [diff] [blame] | 378 | superTy = Context.getObjCObjectPointerType(superTy); |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 379 | ExprResult ReceiverExpr = new (Context) ObjCSuperExpr(SourceLocation(), |
| 380 | superTy); |
Steve Naroff | 5cb93b8 | 2008-11-19 15:54:23 +0000 | [diff] [blame] | 381 | // We are really in an instance method, redirect. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 382 | return ActOnInstanceMessage(ReceiverExpr.get(), Sel, lbrac, |
Anders Carlsson | ff975cf | 2009-02-14 18:21:46 +0000 | [diff] [blame] | 383 | selectorLoc, rbrac, Args, NumArgs); |
Steve Naroff | 5cb93b8 | 2008-11-19 15:54:23 +0000 | [diff] [blame] | 384 | } |
| 385 | // We are sending a message to 'super' within a class method. Do nothing, |
| 386 | // the receiver will pass through as 'super' (how convenient:-). |
| 387 | } else { |
| 388 | // 'super' has been used outside a method context. If a variable named |
| 389 | // 'super' has been declared, redirect. If not, produce a diagnostic. |
Douglas Gregor | 47b9a1c | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 390 | NamedDecl *SuperDecl = LookupName(S, receiverName, LookupOrdinaryName); |
Steve Naroff | 5cb93b8 | 2008-11-19 15:54:23 +0000 | [diff] [blame] | 391 | ValueDecl *VD = dyn_cast_or_null<ValueDecl>(SuperDecl); |
| 392 | if (VD) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 393 | ExprResult ReceiverExpr = new (Context) DeclRefExpr(VD, VD->getType(), |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 394 | receiverLoc); |
Steve Naroff | 5cb93b8 | 2008-11-19 15:54:23 +0000 | [diff] [blame] | 395 | // We are really in an instance method, redirect. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 396 | return ActOnInstanceMessage(ReceiverExpr.get(), Sel, lbrac, |
Anders Carlsson | ff975cf | 2009-02-14 18:21:46 +0000 | [diff] [blame] | 397 | selectorLoc, rbrac, Args, NumArgs); |
Steve Naroff | 5cb93b8 | 2008-11-19 15:54:23 +0000 | [diff] [blame] | 398 | } |
Chris Lattner | 08631c5 | 2008-11-23 21:45:46 +0000 | [diff] [blame] | 399 | return Diag(receiverLoc, diag::err_undeclared_var_use) << receiverName; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 400 | } |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 401 | } else |
| 402 | ClassDecl = getObjCInterfaceDecl(receiverName); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 403 | |
Steve Naroff | 7c778f1 | 2008-07-25 19:39:00 +0000 | [diff] [blame] | 404 | // The following code allows for the following GCC-ism: |
Steve Naroff | cb28be6 | 2008-06-04 23:08:38 +0000 | [diff] [blame] | 405 | // |
| 406 | // typedef XCElementDisplayRect XCElementGraphicsRect; |
| 407 | // |
| 408 | // @implementation XCRASlice |
| 409 | // - whatever { // Note that XCElementGraphicsRect is a typedef name. |
| 410 | // _sGraphicsDelegate =[[XCElementGraphicsRect alloc] init]; |
| 411 | // } |
| 412 | // |
Steve Naroff | 7c778f1 | 2008-07-25 19:39:00 +0000 | [diff] [blame] | 413 | // If necessary, the following lookup could move to getObjCInterfaceDecl(). |
| 414 | if (!ClassDecl) { |
Douglas Gregor | 47b9a1c | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 415 | NamedDecl *IDecl = LookupName(TUScope, receiverName, LookupOrdinaryName); |
Steve Naroff | 7c778f1 | 2008-07-25 19:39:00 +0000 | [diff] [blame] | 416 | if (TypedefDecl *OCTD = dyn_cast_or_null<TypedefDecl>(IDecl)) { |
| 417 | const ObjCInterfaceType *OCIT; |
John McCall | 183700f | 2009-09-21 23:43:11 +0000 | [diff] [blame^] | 418 | OCIT = OCTD->getUnderlyingType()->getAs<ObjCInterfaceType>(); |
Chris Lattner | 64540d7 | 2009-03-29 05:01:10 +0000 | [diff] [blame] | 419 | if (!OCIT) { |
| 420 | Diag(receiverLoc, diag::err_invalid_receiver_to_message); |
| 421 | return true; |
| 422 | } |
Fariborz Jahanian | ebff1fe | 2009-01-16 20:35:09 +0000 | [diff] [blame] | 423 | ClassDecl = OCIT->getDecl(); |
Steve Naroff | 7c778f1 | 2008-07-25 19:39:00 +0000 | [diff] [blame] | 424 | } |
| 425 | } |
| 426 | assert(ClassDecl && "missing interface declaration"); |
Steve Naroff | cb28be6 | 2008-06-04 23:08:38 +0000 | [diff] [blame] | 427 | ObjCMethodDecl *Method = 0; |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 428 | QualType returnType; |
Fariborz Jahanian | 89bc314 | 2009-05-08 23:02:36 +0000 | [diff] [blame] | 429 | if (ClassDecl->isForwardDecl()) { |
| 430 | // A forward class used in messaging is tread as a 'Class' |
Fariborz Jahanian | 9f8f026 | 2009-05-08 23:45:49 +0000 | [diff] [blame] | 431 | Diag(lbrac, diag::warn_receiver_forward_class) << ClassDecl->getDeclName(); |
Fariborz Jahanian | 89bc314 | 2009-05-08 23:02:36 +0000 | [diff] [blame] | 432 | Method = LookupFactoryMethodInGlobalPool(Sel, SourceRange(lbrac,rbrac)); |
| 433 | if (Method) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 434 | Diag(Method->getLocation(), diag::note_method_sent_forward_class) |
Fariborz Jahanian | 9f8f026 | 2009-05-08 23:45:49 +0000 | [diff] [blame] | 435 | << Method->getDeclName(); |
Fariborz Jahanian | 89bc314 | 2009-05-08 23:02:36 +0000 | [diff] [blame] | 436 | } |
| 437 | if (!Method) |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 438 | Method = ClassDecl->lookupClassMethod(Sel); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 439 | |
Steve Naroff | 7c778f1 | 2008-07-25 19:39:00 +0000 | [diff] [blame] | 440 | // If we have an implementation in scope, check "private" methods. |
Steve Naroff | f1afaf6 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 441 | if (!Method) |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 442 | Method = LookupPrivateClassMethod(Sel, ClassDecl); |
Steve Naroff | 7c778f1 | 2008-07-25 19:39:00 +0000 | [diff] [blame] | 443 | |
Douglas Gregor | 48f3bb9 | 2009-02-18 21:56:37 +0000 | [diff] [blame] | 444 | if (Method && DiagnoseUseOfDecl(Method, receiverLoc)) |
| 445 | return true; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 446 | |
| 447 | if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, true, |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 448 | lbrac, rbrac, returnType)) |
| 449 | return true; |
Ted Kremenek | 4df728e | 2008-06-24 15:50:53 +0000 | [diff] [blame] | 450 | |
Anders Carlsson | 187ba15 | 2009-05-26 15:22:25 +0000 | [diff] [blame] | 451 | returnType = returnType.getNonReferenceType(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 452 | |
Mike Stump | 390b4cc | 2009-05-16 07:39:55 +0000 | [diff] [blame] | 453 | // If we have the ObjCInterfaceDecl* for the class that is receiving the |
| 454 | // message, use that to construct the ObjCMessageExpr. Otherwise pass on the |
| 455 | // IdentifierInfo* for the class. |
| 456 | // FIXME: need to do a better job handling 'super' usage within a class. For |
| 457 | // now, we simply pass the "super" identifier through (which isn't consistent |
| 458 | // with instance methods. |
Steve Naroff | 7c778f1 | 2008-07-25 19:39:00 +0000 | [diff] [blame] | 459 | if (isSuper) |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 460 | return new (Context) ObjCMessageExpr(receiverName, Sel, returnType, Method, |
| 461 | lbrac, rbrac, ArgExprs, NumArgs); |
Ted Kremenek | 4df728e | 2008-06-24 15:50:53 +0000 | [diff] [blame] | 462 | else |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 463 | return new (Context) ObjCMessageExpr(ClassDecl, Sel, returnType, Method, |
| 464 | lbrac, rbrac, ArgExprs, NumArgs); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | // ActOnInstanceMessage - used for both unary and keyword messages. |
| 468 | // ArgExprs is optional - if it is present, the number of expressions |
| 469 | // is obtained from Sel.getNumArgs(). |
Chris Lattner | 1565e03 | 2008-07-21 06:31:05 +0000 | [diff] [blame] | 470 | Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 471 | SourceLocation lbrac, |
Anders Carlsson | ff975cf | 2009-02-14 18:21:46 +0000 | [diff] [blame] | 472 | SourceLocation receiverLoc, |
Chris Lattner | b77792e | 2008-07-26 22:17:49 +0000 | [diff] [blame] | 473 | SourceLocation rbrac, |
| 474 | ExprTy **Args, unsigned NumArgs) { |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 475 | assert(receiver && "missing receiver expression"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 476 | |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 477 | Expr **ArgExprs = reinterpret_cast<Expr **>(Args); |
| 478 | Expr *RExpr = static_cast<Expr *>(receiver); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 479 | |
Chris Lattner | d0d4599 | 2009-04-29 05:48:32 +0000 | [diff] [blame] | 480 | // If necessary, apply function/array conversion to the receiver. |
| 481 | // C99 6.7.5.3p[7,8]. |
| 482 | DefaultFunctionArrayConversion(RExpr); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 483 | |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 484 | QualType returnType; |
Chris Lattner | b77792e | 2008-07-26 22:17:49 +0000 | [diff] [blame] | 485 | QualType ReceiverCType = |
| 486 | Context.getCanonicalType(RExpr->getType()).getUnqualifiedType(); |
Steve Naroff | 87d3ef0 | 2008-11-17 22:29:32 +0000 | [diff] [blame] | 487 | |
| 488 | // Handle messages to 'super'. |
Steve Naroff | 279d896 | 2009-02-23 15:40:48 +0000 | [diff] [blame] | 489 | if (isa<ObjCSuperExpr>(RExpr)) { |
Steve Naroff | 87d3ef0 | 2008-11-17 22:29:32 +0000 | [diff] [blame] | 490 | ObjCMethodDecl *Method = 0; |
| 491 | if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) { |
| 492 | // If we have an interface in scope, check 'super' methods. |
| 493 | if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 494 | if (ObjCInterfaceDecl *SuperDecl = ClassDecl->getSuperClass()) { |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 495 | Method = SuperDecl->lookupInstanceMethod(Sel); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 496 | |
| 497 | if (!Method) |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 498 | // If we have implementations in scope, check "private" methods. |
| 499 | Method = LookupPrivateInstanceMethod(Sel, SuperDecl); |
| 500 | } |
Steve Naroff | 87d3ef0 | 2008-11-17 22:29:32 +0000 | [diff] [blame] | 501 | } |
Anders Carlsson | ff975cf | 2009-02-14 18:21:46 +0000 | [diff] [blame] | 502 | |
Douglas Gregor | 48f3bb9 | 2009-02-18 21:56:37 +0000 | [diff] [blame] | 503 | if (Method && DiagnoseUseOfDecl(Method, receiverLoc)) |
| 504 | return true; |
Anders Carlsson | 59843ad | 2009-02-14 19:08:58 +0000 | [diff] [blame] | 505 | |
Chris Lattner | 077bf5e | 2008-11-24 03:33:13 +0000 | [diff] [blame] | 506 | if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, false, |
Steve Naroff | 87d3ef0 | 2008-11-17 22:29:32 +0000 | [diff] [blame] | 507 | lbrac, rbrac, returnType)) |
| 508 | return true; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 509 | |
Anders Carlsson | 187ba15 | 2009-05-26 15:22:25 +0000 | [diff] [blame] | 510 | returnType = returnType.getNonReferenceType(); |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 511 | return new (Context) ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac, |
| 512 | rbrac, ArgExprs, NumArgs); |
Steve Naroff | 87d3ef0 | 2008-11-17 22:29:32 +0000 | [diff] [blame] | 513 | } |
| 514 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 515 | // Handle messages to id. |
Steve Naroff | 470301b | 2009-07-22 16:07:01 +0000 | [diff] [blame] | 516 | if (ReceiverCType->isObjCIdType() || ReceiverCType->isBlockPointerType() || |
Fariborz Jahanian | 636bed1 | 2009-05-21 21:04:28 +0000 | [diff] [blame] | 517 | Context.isObjCNSObjectType(RExpr->getType())) { |
Steve Naroff | 037cda5 | 2008-09-30 14:38:43 +0000 | [diff] [blame] | 518 | ObjCMethodDecl *Method = LookupInstanceMethodInGlobalPool( |
| 519 | Sel, SourceRange(lbrac,rbrac)); |
Chris Lattner | 6e10a08 | 2008-02-01 06:57:39 +0000 | [diff] [blame] | 520 | if (!Method) |
Douglas Gregor | f0aaf7a | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 521 | Method = LookupFactoryMethodInGlobalPool(Sel, SourceRange(lbrac, rbrac)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 522 | if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, false, |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 523 | lbrac, rbrac, returnType)) |
| 524 | return true; |
Anders Carlsson | 187ba15 | 2009-05-26 15:22:25 +0000 | [diff] [blame] | 525 | returnType = returnType.getNonReferenceType(); |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 526 | return new (Context) ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac, |
| 527 | rbrac, ArgExprs, NumArgs); |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 528 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 529 | |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 530 | // Handle messages to Class. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 531 | if (ReceiverCType->isObjCClassType() || |
Steve Naroff | 470301b | 2009-07-22 16:07:01 +0000 | [diff] [blame] | 532 | ReceiverCType->isObjCQualifiedClassType()) { |
Chris Lattner | 2b1cc8b | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 533 | ObjCMethodDecl *Method = 0; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 534 | |
Chris Lattner | 6562fda | 2008-07-21 06:44:27 +0000 | [diff] [blame] | 535 | if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) { |
Steve Naroff | d526c2f | 2009-02-23 02:25:40 +0000 | [diff] [blame] | 536 | if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) { |
| 537 | // First check the public methods in the class interface. |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 538 | Method = ClassDecl->lookupClassMethod(Sel); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 539 | |
Steve Naroff | f1afaf6 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 540 | if (!Method) |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 541 | Method = LookupPrivateClassMethod(Sel, ClassDecl); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 542 | |
| 543 | // FIXME: if we still haven't found a method, we need to look in |
Steve Naroff | 470301b | 2009-07-22 16:07:01 +0000 | [diff] [blame] | 544 | // protocols (if we have qualifiers). |
Steve Naroff | d526c2f | 2009-02-23 02:25:40 +0000 | [diff] [blame] | 545 | } |
Douglas Gregor | 48f3bb9 | 2009-02-18 21:56:37 +0000 | [diff] [blame] | 546 | if (Method && DiagnoseUseOfDecl(Method, receiverLoc)) |
| 547 | return true; |
Steve Naroff | d526c2f | 2009-02-23 02:25:40 +0000 | [diff] [blame] | 548 | } |
Steve Naroff | 6b9dfd4 | 2009-03-04 15:11:40 +0000 | [diff] [blame] | 549 | if (!Method) { |
| 550 | // If not messaging 'self', look for any factory method named 'Sel'. |
| 551 | if (!isSelfExpr(RExpr)) { |
Douglas Gregor | f0aaf7a | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 552 | Method = LookupFactoryMethodInGlobalPool(Sel, SourceRange(lbrac,rbrac)); |
Fariborz Jahanian | b1006c7 | 2009-03-04 17:50:39 +0000 | [diff] [blame] | 553 | if (!Method) { |
Fariborz Jahanian | 041f2fd | 2009-05-05 18:34:37 +0000 | [diff] [blame] | 554 | // If no class (factory) method was found, check if an _instance_ |
| 555 | // method of the same name exists in the root class only. |
Steve Naroff | 6b9dfd4 | 2009-03-04 15:11:40 +0000 | [diff] [blame] | 556 | Method = LookupInstanceMethodInGlobalPool( |
| 557 | Sel, SourceRange(lbrac,rbrac)); |
Fariborz Jahanian | 041f2fd | 2009-05-05 18:34:37 +0000 | [diff] [blame] | 558 | if (Method) |
| 559 | if (const ObjCInterfaceDecl *ID = |
| 560 | dyn_cast<ObjCInterfaceDecl>(Method->getDeclContext())) { |
| 561 | if (ID->getSuperClass()) |
| 562 | Diag(lbrac, diag::warn_root_inst_method_not_found) |
| 563 | << Sel << SourceRange(lbrac, rbrac); |
| 564 | } |
Fariborz Jahanian | b1006c7 | 2009-03-04 17:50:39 +0000 | [diff] [blame] | 565 | } |
Steve Naroff | 6b9dfd4 | 2009-03-04 15:11:40 +0000 | [diff] [blame] | 566 | } |
| 567 | } |
Chris Lattner | 077bf5e | 2008-11-24 03:33:13 +0000 | [diff] [blame] | 568 | if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, false, |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 569 | lbrac, rbrac, returnType)) |
| 570 | return true; |
Anders Carlsson | 187ba15 | 2009-05-26 15:22:25 +0000 | [diff] [blame] | 571 | returnType = returnType.getNonReferenceType(); |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 572 | return new (Context) ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac, |
| 573 | rbrac, ArgExprs, NumArgs); |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 574 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 575 | |
Chris Lattner | 2b1cc8b | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 576 | ObjCMethodDecl *Method = 0; |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 577 | ObjCInterfaceDecl* ClassDecl = 0; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 578 | |
| 579 | // We allow sending a message to a qualified ID ("id<foo>"), which is ok as |
Chris Lattner | 2b1cc8b | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 580 | // long as one of the protocols implements the selector (if not, warn). |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 581 | if (const ObjCObjectPointerType *QIdTy = |
Steve Naroff | d1b3c2d | 2009-06-17 22:40:22 +0000 | [diff] [blame] | 582 | ReceiverCType->getAsObjCQualifiedIdType()) { |
Steve Naroff | f7f52e7 | 2009-02-21 21:17:01 +0000 | [diff] [blame] | 583 | // Search protocols for instance methods. |
Steve Naroff | d1b3c2d | 2009-06-17 22:40:22 +0000 | [diff] [blame] | 584 | for (ObjCObjectPointerType::qual_iterator I = QIdTy->qual_begin(), |
Steve Naroff | 446ee4e | 2009-05-27 16:21:00 +0000 | [diff] [blame] | 585 | E = QIdTy->qual_end(); I != E; ++I) { |
| 586 | ObjCProtocolDecl *PDecl = *I; |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 587 | if (PDecl && (Method = PDecl->lookupInstanceMethod(Sel))) |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 588 | break; |
Steve Naroff | ebaa768 | 2009-04-07 15:07:57 +0000 | [diff] [blame] | 589 | // Since we aren't supporting "Class<foo>", look for a class method. |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 590 | if (PDecl && (Method = PDecl->lookupClassMethod(Sel))) |
Steve Naroff | ebaa768 | 2009-04-07 15:07:57 +0000 | [diff] [blame] | 591 | break; |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 592 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 593 | } else if (const ObjCObjectPointerType *OCIType = |
Steve Naroff | 14108da | 2009-07-10 23:34:53 +0000 | [diff] [blame] | 594 | ReceiverCType->getAsObjCInterfacePointerType()) { |
Chris Lattner | 2b1cc8b | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 595 | // We allow sending a message to a pointer to an interface (an object). |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 596 | |
Steve Naroff | 14108da | 2009-07-10 23:34:53 +0000 | [diff] [blame] | 597 | ClassDecl = OCIType->getInterfaceDecl(); |
Steve Naroff | 037cda5 | 2008-09-30 14:38:43 +0000 | [diff] [blame] | 598 | // FIXME: consider using LookupInstanceMethodInGlobalPool, since it will be |
Mike Stump | 390b4cc | 2009-05-16 07:39:55 +0000 | [diff] [blame] | 599 | // faster than the following method (which can do *many* linear searches). |
Steve Naroff | 037cda5 | 2008-09-30 14:38:43 +0000 | [diff] [blame] | 600 | // The idea is to add class info to InstanceMethodPool. |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 601 | Method = ClassDecl->lookupInstanceMethod(Sel); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 602 | |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 603 | if (!Method) { |
| 604 | // Search protocol qualifiers. |
Steve Naroff | 14108da | 2009-07-10 23:34:53 +0000 | [diff] [blame] | 605 | for (ObjCObjectPointerType::qual_iterator QI = OCIType->qual_begin(), |
Steve Naroff | 279d896 | 2009-02-23 15:40:48 +0000 | [diff] [blame] | 606 | E = OCIType->qual_end(); QI != E; ++QI) { |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 607 | if ((Method = (*QI)->lookupInstanceMethod(Sel))) |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 608 | break; |
| 609 | } |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 610 | } |
Steve Naroff | 0de21fd | 2009-02-22 19:35:57 +0000 | [diff] [blame] | 611 | if (!Method) { |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 612 | // If we have implementations in scope, check "private" methods. |
| 613 | Method = LookupPrivateInstanceMethod(Sel, ClassDecl); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 614 | |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 615 | if (!Method && !isSelfExpr(RExpr)) { |
Steve Naroff | 6b9dfd4 | 2009-03-04 15:11:40 +0000 | [diff] [blame] | 616 | // If we still haven't found a method, look in the global pool. This |
| 617 | // behavior isn't very desirable, however we need it for GCC |
| 618 | // compatibility. FIXME: should we deviate?? |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 619 | if (OCIType->qual_empty()) { |
Steve Naroff | 6b9dfd4 | 2009-03-04 15:11:40 +0000 | [diff] [blame] | 620 | Method = LookupInstanceMethodInGlobalPool( |
| 621 | Sel, SourceRange(lbrac,rbrac)); |
Steve Naroff | 14108da | 2009-07-10 23:34:53 +0000 | [diff] [blame] | 622 | if (Method && !OCIType->getInterfaceDecl()->isForwardDecl()) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 623 | Diag(lbrac, diag::warn_maynot_respond) |
Steve Naroff | 14108da | 2009-07-10 23:34:53 +0000 | [diff] [blame] | 624 | << OCIType->getInterfaceDecl()->getIdentifier()->getName() << Sel; |
Steve Naroff | 6b9dfd4 | 2009-03-04 15:11:40 +0000 | [diff] [blame] | 625 | } |
Fariborz Jahanian | 268bc8c | 2009-03-03 22:19:15 +0000 | [diff] [blame] | 626 | } |
Steve Naroff | 0de21fd | 2009-02-22 19:35:57 +0000 | [diff] [blame] | 627 | } |
Douglas Gregor | 48f3bb9 | 2009-02-18 21:56:37 +0000 | [diff] [blame] | 628 | if (Method && DiagnoseUseOfDecl(Method, receiverLoc)) |
| 629 | return true; |
Chris Lattner | 0c73f37 | 2009-03-09 21:19:16 +0000 | [diff] [blame] | 630 | } else if (!Context.getObjCIdType().isNull() && |
| 631 | (ReceiverCType->isPointerType() || |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 632 | (ReceiverCType->isIntegerType() && |
Chris Lattner | 0c73f37 | 2009-03-09 21:19:16 +0000 | [diff] [blame] | 633 | ReceiverCType->isScalarType()))) { |
| 634 | // Implicitly convert integers and pointers to 'id' but emit a warning. |
Steve Naroff | 8e2945a | 2009-03-01 17:14:31 +0000 | [diff] [blame] | 635 | Diag(lbrac, diag::warn_bad_receiver_type) |
Chris Lattner | d162584 | 2008-11-24 06:25:27 +0000 | [diff] [blame] | 636 | << RExpr->getType() << RExpr->getSourceRange(); |
Chris Lattner | 0c73f37 | 2009-03-09 21:19:16 +0000 | [diff] [blame] | 637 | ImpCastExprToType(RExpr, Context.getObjCIdType()); |
| 638 | } else { |
| 639 | // Reject other random receiver types (e.g. structs). |
| 640 | Diag(lbrac, diag::err_bad_receiver_type) |
| 641 | << RExpr->getType() << RExpr->getSourceRange(); |
Chris Lattner | 2b1cc8b | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 642 | return true; |
Chris Lattner | fe1a553 | 2008-07-21 05:57:44 +0000 | [diff] [blame] | 643 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 644 | |
Fariborz Jahanian | 5b53005 | 2009-05-13 18:09:35 +0000 | [diff] [blame] | 645 | if (Method) |
| 646 | DiagnoseSentinelCalls(Method, receiverLoc, ArgExprs, NumArgs); |
Chris Lattner | 077bf5e | 2008-11-24 03:33:13 +0000 | [diff] [blame] | 647 | if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, false, |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 648 | lbrac, rbrac, returnType)) |
| 649 | return true; |
Anders Carlsson | 187ba15 | 2009-05-26 15:22:25 +0000 | [diff] [blame] | 650 | returnType = returnType.getNonReferenceType(); |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 651 | return new (Context) ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac, |
| 652 | rbrac, ArgExprs, NumArgs); |
Chris Lattner | 85a932e | 2008-01-04 22:32:30 +0000 | [diff] [blame] | 653 | } |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 654 | |