Home | History | Annotate | Download | only in Sema

Lines Matching refs:Method

147 /// \brief Emits an error if the given method does not exist, or if the return
151 Selector Sel, const ObjCMethodDecl *Method) {
152 if (!Method) {
159 QualType ReturnType = Method->getReturnType();
163 S.Diag(Method->getLocation(), diag::note_objc_literal_method_return)
242 /// \brief Retrieve the NSNumber factory method that should be used to create
259 // If we already looked up this method, we're done.
284 // Look for the appropriate method within NSNumber.
285 ObjCMethodDecl *Method = S.NSNumberDecl->lookupClassMethod(Sel);
286 if (!Method && S.getLangOpts().DebuggerObjCLiteral) {
287 // create a stub definition this NSNumber factory method.
289 Method =
297 ParmVarDecl *value = ParmVarDecl::Create(S.Context, Method,
302 Method->setMethodParams(S.Context, value, None);
305 if (!validateBoxingMethod(S, Loc, S.NSNumberDecl, Sel, Method))
311 S.NSNumberLiteralMethods[*Kind] = Method;
312 return Method;
342 // Look for the appropriate method within NSNumber.
345 ObjCMethodDecl *Method = getNSNumberFactoryMethod(*this, AtLoc, NumberType,
347 if (!Method)
351 ParmVarDecl *ParamDecl = Method->parameters()[0];
363 new (Context) ObjCBoxedExpr(Number, NSNumberPointer, Method,
535 // Look for the appropriate method within NSString.
602 // Look for the appropriate method within NSNumber.
640 // Look for the appropriate method within NSValue.
778 // Find the arrayWithObjects:count: method, if we haven't done so already.
783 ObjCMethodDecl *Method = NSArrayDecl->lookupClassMethod(Sel);
784 if (!Method && getLangOpts().DebuggerObjCLiteral) {
786 Method = ObjCMethodDecl::Create(
794 ParmVarDecl *objects = ParmVarDecl::Create(Context, Method,
802 ParmVarDecl *cnt = ParmVarDecl::Create(Context, Method,
810 Method->setMethodParams(Context, Params, None);
813 if (!validateBoxingMethod(*this, Loc, NSArrayDecl, Sel, Method))
817 QualType T = Method->parameters()[0]->getType();
823 Diag(Method->parameters()[0]->getLocation(),
831 if (!Method->parameters()[1]->getType()->isIntegerType()) {
834 Diag(Method->parameters()[1]->getLocation(),
837 << Method->parameters()[1]->getType()
842 // We've found a good +arrayWithObjects:count: method. Save it!
843 ArrayWithObjectsMethod = Method;
884 // Find the dictionaryWithObjects:forKeys:count: method, if we haven't done
890 ObjCMethodDecl *Method = NSDictionaryDecl->lookupClassMethod(Sel);
891 if (!Method && getLangOpts().DebuggerObjCLiteral) {
892 Method = ObjCMethodDecl::Create(Context,
903 ParmVarDecl *objects = ParmVarDecl::Create(Context, Method,
911 ParmVarDecl *keys = ParmVarDecl::Create(Context, Method,
919 ParmVarDecl *cnt = ParmVarDecl::Create(Context, Method,
927 Method->setMethodParams(Context, Params, None);
931 Method))
935 QualType ValueT = Method->parameters()[0]->getType();
941 Diag(Method->parameters()[0]->getLocation(),
949 QualType KeyT = Method->parameters()[1]->getType();
978 Diag(Method->parameters()[1]->getLocation(),
987 QualType CountType = Method->parameters()[2]->getType();
991 Diag(Method->parameters()[2]->getLocation(),
998 // We've found a good +dictionaryWithObjects:keys:count: method; save it!
999 DictionaryWithObjectsMethod = Method;
1104 ObjCMethodDecl *Method,
1110 if (MatchingMethodDecl == Method ||
1112 MatchingMethodDecl->getSelector() != Method->getSelector())
1114 if (!S.MatchTwoMethodDeclarations(Method,
1119 << Method->getSelector() << FixItHint::CreateInsertion(LParenLoc, "(")
1121 S.Diag(Method->getLocation(), diag::note_method_declared_at)
1122 << Method->getDeclName();
1132 ObjCMethodDecl *Method,
1145 Method, InstMethList))
1151 Method, ClsMethList) || Warned)
1162 ObjCMethodDecl *Method = LookupInstanceMethodInGlobalPool(Sel,
1164 if (!Method)
1165 Method = LookupFactoryMethodInGlobalPool(Sel,
1167 if (!Method) {
1179 DiagnoseMismatchedSelectors(*this, AtLoc, Method, LParenLoc, RParenLoc,
1182 if (Method &&
1183 Method->getImplementationControl() != ObjCMethodDecl::Optional &&
1184 !getSourceManager().isInSystemHeader(Method->getLocation()))
1242 // If we're not in an ObjC method, error out. Note that, unlike the
1243 // C++ case, we don't require an instance method --- class methods
1245 ObjCMethodDecl *method = dyn_cast<ObjCMethodDecl>(DC);
1246 if (!method)
1249 tryCaptureVariable(method->getSelfDecl(), Loc);
1251 return method;
1274 /// method, and the kind of message send.
1280 ObjCMethodDecl *Method,
1283 assert(Method && "Must have a method");
1284 if (!Method->hasRelatedResultType())
1285 return Method->getSendResultType(ReceiverType);
1289 // Local function that transfers the nullability of the method's
1292 // If the method's result type has nullability, extract it.
1293 if (auto nullability = Method->getSendResultType(ReceiverType)
1298 // Form a new attributed type using the method result type's nullability.
1308 // If a method has a related return type:
1309 // - if the method found is an instance method, but the message send
1310 // was a class message send, T is the declared return type of the method
1312 if (Method->isInstanceMethod() && isClassMessage)
1314 Method->getSendResultType(ReceiverType));
1317 // enclosing method definition
1331 // T is the declared return type of the method.
1335 Method->getSendResultType(ReceiverType));
1344 ObjCMethodDecl *Method,
1349 Method,
1407 /// Look for an ObjC method whose result type exactly matches the given type.
1414 // For these purposes, a method in an @implementation overrides a
1443 // Only complain if we're in an ObjC method and the required return
1444 // type doesn't match the method's declared return type.
1450 // Look for a method overridden by this method which explicitly uses
1459 << /*current method*/ 1 << range;
1463 // Otherwise, if we have an interesting method family, note that.
1467 << /*current method*/ 1
1477 const ObjCMethodDecl *Method = MsgSend->getMethodDecl();
1478 if (!Method)
1481 if (!Method->hasRelatedResultType())
1485 Method->getReturnType().getNonReferenceType(), MsgSend->getType()))
1488 if (!Context.hasSameUnqualifiedType(Method->getReturnType(),
1492 Diag(Method->getLocation(), diag::note_related_result_type_inferred)
1493 << Method->isInstanceMethod() << Method->getSelector()
1501 ObjCMethodDecl *Method,
1512 if (!Method) {
1582 ReturnType = getMessageSendResultType(ReceiverType, Method, isClassMessage,
1584 VK = Expr::getValueKindForType(Method->getReturnType());
1587 // Method might have more arguments than selector indicates. This is due
1588 // to addition of c-style arguments in method.
1589 if (Method->param_size() > Sel.getNumArgs())
1590 NumNamedArgs = Method->param_size();
1601 = ReceiverType->getObjCSubstitutions(Method->getDeclContext());
1610 ParmVarDecl *param = Method->parameters()[i];
1670 if (Method->isVariadic()) {
1685 << 2 /*method*/ << NumNamedArgs << static_cast<unsigned>(Args.size())
1686 << Method->getSourceRange()
1692 DiagnoseSentinelCalls(Method, SelLoc, Args);
1694 // Do additional checkings on method.
1696 Method, SelLoc, makeArrayRef(Args.data(), Args.size()));
1702 // 'self' is objc 'self' in an objc method only.
1703 ObjCMethodDecl *Method =
1705 return isSelfExpr(RExpr, Method);
1708 bool Sema::isSelfExpr(Expr *receiver, const ObjCMethodDecl *method) {
1709 if (!method) return false;
1713 if (DRE->getDecl() == method->getSelfDecl())
1718 /// LookupMethodInType - Look up a method in an ObjCObjectType.
1724 if (ObjCMethodDecl *method = iface->lookupMethod(sel, isInstance))
1725 return method;
1729 if (ObjCMethodDecl *method = iface->lookupPrivateMethod(sel, isInstance))
1730 return method;
1735 if (ObjCMethodDecl *method = I->lookupMethod(sel, isInstance))
1736 return method;
1741 /// LookupMethodInQualifiedType - Lookups up a method in protocol qualifier
1935 // If the "receiver" is 'super' in a method, handle it as an expression-like
1958 // Otherwise, if this is a class method, try dispatching to our
2025 ObjCInterfaceOrSuperCCC(ObjCMethodDecl *Method) {
2027 if (Method && Method->getClassInterface())
2028 WantObjCSuper = Method->getClassInterface()->getSuperClass();
2059 // Objective-C method, look for ivars. If we find one, we're done!
2062 if (ObjCMethodDecl *Method = getCurMethodDecl()) {
2063 if (!Method->getClassInterface()) {
2069 if (Method->getClassInterface()->lookupInstanceVariable(Name,
2144 // Determine whether we are inside a method or not.
2145 ObjCMethodDecl *Method = tryCaptureObjCSelf(SuperLoc);
2146 if (!Method) {
2151 ObjCInterfaceDecl *Class = Method->getClassInterface();
2154 << Method->getDeclName();
2166 // We are in a method whose class has a superclass, so 'super'
2168 if (Method->getSelector() == Sel)
2171 if (Method->isInstanceMethod()) {
2172 // Since we are in an instance method, this is an instance
2176 Sel, /*Method=*/nullptr,
2180 // Since we are in a class method, this is a class message to
2184 SuperLoc, Sel, /*Method=*/nullptr,
2193 ObjCMethodDecl *Method,
2201 Sel, Method, Loc, Loc, Loc, Args,
2251 /// as formatting string to formatting method.
2254 ObjCMethodDecl *Method,
2264 else if (Method) {
2265 for (const auto *I : Method->specific_attrs<FormatAttr>()) {
2282 if (Method)
2283 S.Diag(Method->getLocation(), diag::note_method_declared_at)
2284 << Method->getDeclName();
2309 /// \param Method The method that this class message is invoking, if
2321 ObjCMethodDecl *Method,
2348 SelectorLocs, /*Method=*/nullptr, makeArrayRef(Args, NumArgs), RBracLoc,
2364 // Find the method we are messaging.
2365 if (!Method) {
2375 Method = LookupFactoryMethodInGlobalPool(Sel,
2377 if (Method && !getLangOpts().ObjCAutoRefCount)
2378 Diag(Method->getLocation(), diag::note_method_sent_forward_class)
2379 << Method->getDeclName();
2381 if (!Method)
2382 Method = Class->lookupClassMethod(Sel);
2385 if (!Method)
2386 Method = Class->lookupPrivateClassMethod(Sel);
2388 if (Method && DiagnoseUseOfDecl(Method, SelLoc))
2400 Method, true,
2406 if (Method && !Method->getReturnType()->isVoidType() &&
2407 RequireCompleteType(LBracLoc, Method->getReturnType(),
2412 if (Method && Method->getMethodFamily() == OMF_initialize) {
2415 dyn_cast<ObjCInterfaceDecl>(Method->getDeclContext());
2418 Diag(Method->getLocation(), diag::note_method_declared_at)
2419 << Method->getDeclName();
2426 Diag(Method->getLocation(), diag::note_method_declared_at)
2427 << Method->getDeclName();
2434 DiagnoseCStringFormatDirectiveInObjCAPI(*this, Method, Sel, Args, NumArgs);
2442 Method, makeArrayRef(Args, NumArgs),
2447 Method, makeArrayRef(Args, NumArgs),
2476 /*Method=*/nullptr, LBracLoc, SelectorLocs, RBracLoc,
2484 ObjCMethodDecl *Method,
2488 Sel, Method, Loc, Loc, Loc, Args,
2512 /// \param Method The method that this instance message is invoking, if
2524 ObjCMethodDecl *Method,
2567 SelectorLocs, /*Method=*/nullptr, makeArrayRef(Args, NumArgs),
2620 // won't actually have a method unless we also don't need to do some
2623 if (!Method) {
2625 // global method pool).
2633 Method = LookupInstanceMethodInGlobalPool(Sel,
2636 if (!Method)
2637 Method = LookupFactoryMethodInGlobalPool(Sel,
2640 if (Method) {
2642 SelectBestMethod(Sel, ArgsIn, Method->isInstanceMethod()))
2643 Method = BestMethod;
2644 if (!AreMultipleMethodsInGlobalPool(Sel, Method,
2647 DiagnoseUseOfDecl(Method, SelLoc);
2660 Method = LookupMethodInQualifiedType(Sel, QClassTy, false);
2661 if (!Method) {
2662 Method = LookupMethodInQualifiedType(Sel, QClassTy, true);
2663 // warn if instance method found for a Class message.
2664 if (Method) {
2666 << Method->getSelector() << Sel;
2667 Diag(Method->getLocation(), diag::note_method_declared_at)
2668 << Method->getDeclName();
2675 Method = ClassDecl->lookupClassMethod(Sel);
2677 if (!Method)
2678 Method = ClassDecl->lookupPrivateClassMethod(Sel);
2680 if (Method && DiagnoseUseOfDecl(Method, SelLoc))
2683 if (!Method) {
2684 // If not messaging 'self', look for any factory method named 'Sel'.
2686 Method = LookupFactoryMethodInGlobalPool(Sel,
2688 if (!Method) {
2689 // If no class (factory) method was found, check if an _instance_
2690 // method of the same name exists in the root class only.
2691 Method = LookupInstanceMethodInGlobalPool(Sel,
2693 if (Method)
2695 dyn_cast<ObjCInterfaceDecl>(Method->getDeclContext())) {
2701 if (Method)
2703 SelectBestMethod(Sel, ArgsIn, Method->isInstanceMethod()))
2704 Method = BestMethod;
2717 Method = LookupMethodInQualifiedType(Sel, QIdTy, true);
2718 if (!Method)
2719 Method = LookupMethodInQualifiedType(Sel, QIdTy, false);
2720 if (Method && DiagnoseUseOfDecl(Method, SelLoc))
2744 Method = nullptr;
2746 Method = ClassDecl->lookupInstanceMethod(Sel);
2749 if (!Method)
2751 Method = LookupMethodInQualifiedType(Sel, OCIType, true);
2753 if (!Method) {
2755 Method = ClassDecl->lookupPrivateMethod(Sel);
2757 if (!Method && getLangOpts().ObjCAutoRefCount) {
2764 if (!Method && (!Receiver || !isSelfExpr(Receiver))) {
2765 // If we still haven't found a method, look in the global pool. This
2769 Method = LookupInstanceMethodInGlobalPool(Sel,
2771 if (Method) {
2773 SelectBestMethod(Sel, ArgsIn, Method->isInstanceMethod()))
2774 Method = BestMethod;
2775 AreMultipleMethodsInGlobalPool(Sel, Method,
2779 if (Method && !forwardClass)
2786 if (Method && DiagnoseUseOfDecl(Method, SelLoc, forwardClass))
2798 (Method && Method->getMethodFamily() == OMF_init)
2851 Sel, SelectorLocs, Method,
2856 if (Method && !Method->getReturnType()->isVoidType() &&
2857 RequireCompleteType(LBracLoc, Method->getReturnType(),
2865 (Method ? Method->getMethodFamily() : Sel.getMethodFamily());
2868 if (Method)
2869 checkInitMethod(Method, ReceiverType);
2891 if (Method && NumArgs >= 1) {
2912 // selector names a +1 method
2922 // selector names a +1 method
2941 DiagnoseCStringFormatDirectiveInObjCAPI(*this, Method, Sel, Args, NumArgs);
2948 ReceiverType, Sel, SelectorLocs, Method,
2953 Receiver, Sel, SelectorLocs, Method,
2966 ObjCMethodDecl *method = dyn_cast<ObjCMethodDecl>(CurContext);
2967 if (method && method->getMethodFamily() == OMF_init) {
2979 if (!isImplicit && Method) {
2980 if (const ObjCPropertyDecl *Prop = Method->findPropertyDecl()) {
3037 /*Method=*/nullptr, LBracLoc, SelectorLocs,
3294 ObjCMethodDecl *method;
3296 method = e->getExplicitProperty()->getGetterMethodDecl();
3298 method = e->getImplicitPropertyGetter();
3299 return checkCallToMethod(method);
3302 ACCResult checkCallToMethod(ObjCMethodDecl *method) {
3303 if (!method) return ACC_invalid;
3308 if (!isAnyRetainable(TargetClass) || !isCFType(method->getReturnType()))
3311 // If the method is explicitly marked not-retained, it's +0.
3312 if (method->hasAttr<CFReturnsNotRetainedAttr>())
3315 // If the method is explicitly marked as returning retained, or its
3317 if (method->hasAttr<CFReturnsRetainedAttr>())
3320 switch (method->getSelector().getMethodFamily()) {
3854 // Check for an existing class method with the given selector name.
3866 // Check for an existing instance method with the given selector name.