Lines Matching defs:Method
32 /// Check whether the given method, which must be in the 'init'
41 bool Sema::checkInitMethod(ObjCMethodDecl *method,
43 if (method->isInvalidDecl()) return true;
52 method->getReturnType()->castAs<ObjCObjectPointerType>()->getObjectType();
66 !isa<ObjCImplementationDecl>(method->getDeclContext()))
71 // If this method was declared in a protocol, we can't check
74 if (isa<ObjCProtocolDecl>(method->getDeclContext())) {
84 receiverClass = method->getClassInterface();
85 assert(receiverClass && "method not associated with a class!");
95 SourceLocation loc = method->getLocation();
98 // the method unusable.
100 method->addAttr(UnavailableAttr::CreateImplicit(Context,
101 "init method returns a type unrelated to its receiver type",
108 method->setInvalidDecl();
116 // This can only happen when the method follows a naming convention that
117 // implies a related result type, and the original (overridden) method has
118 // a suitable return type, but the new (overriding) method does not have
123 // Figure out which class this method is part of, if any.
153 << /*overridden method*/ 0
165 << "method";
172 << "method";
192 /// \brief Check a method declaration for compatibility with the Objective-C
194 bool Sema::CheckARCMethodDecl(ObjCMethodDecl *method) {
195 ObjCMethodFamily family = method->getMethodFamily();
209 if (!Context.hasSameType(method->getReturnType(), Context.VoidTy)) {
210 SourceRange ResultTypeRange = method->getReturnTypeSourceRange();
212 Diag(method->getLocation(), diag::error_dealloc_bad_result_type)
213 << method->getReturnType()
214 << FixItHint::CreateInsertion(method->getSelectorLoc(0), "(void)");
216 Diag(method->getLocation(), diag::error_dealloc_bad_result_type)
217 << method->getReturnType()
224 // If the method doesn't obey the init rules, don't bother annotating it.
225 if (checkInitMethod(method, QualType()))
228 method->addAttr(NSConsumesSelfAttr::CreateImplicit(Context));
232 if (method->hasAttr<NSReturnsRetainedAttr>())
240 if (method->hasAttr<NSReturnsRetainedAttr>() ||
241 method->hasAttr<NSReturnsNotRetainedAttr>() ||
242 method->hasAttr<NSReturnsAutoreleasedAttr>())
247 method->addAttr(NSReturnsRetainedAttr::CreateImplicit(Context));
265 /// AddAnyMethodToGlobalPool - Add any method, instance or factory to global
270 // If we don't have a valid method decl, simply return.
299 /// and user declared, in the method definition's AST.
304 // If we don't have a valid method decl, simply return.
308 // Allow all of Sema to see that we are entering a method definition.
827 /// a class method in its extension.
840 for (const auto *Method : CAT->methods()) {
841 const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
843 (PrevMethod->isInstanceMethod() == Method->isInstanceMethod()) &&
844 !MatchTwoMethodDeclarations(Method, PrevMethod)) {
845 Diag(Method
846 << Method->getDeclName();
902 // the enclosing method declarations. We mark the decl invalid
1239 ObjCMethodDecl *method,
1243 // No point warning no definition of method which is 'unavailable'.
1244 switch (method->getAvailability()) {
1262 B << method;
1268 SourceLocation MethodLoc = method->getLocStart();
1270 S.Diag(MethodLoc, diag::note_method_declared_at) << method;
1289 /// have more accurate ones. For example, a method may privately accept
1292 /// by a valid A*. Similarly, a method may return a subclass of the class that
1295 /// This is most important when considering subclassing. A method in a
1301 /// subclass method must be a valid object of the kind that the superclass
1510 case OMF_None: llvm_unreachable("logic error, no method convention");
1574 void Sema::CheckConflictingOverridingMethod(ObjCMethodDecl *Method,
1578 CheckMethodOverrideReturn(*this, Method, Overridden,
1582 for (ObjCMethodDecl::param_iterator IM = Method->param_begin(),
1583 IF = Overridden->param_begin(), EM = Method->param_end(),
1586 CheckMethodOverrideParam(*this, Method, Overridden, *IM, *IF,
1590 if (Method->isVariadic() != Overridden->isVariadic()) {
1591 Diag(Method->getLocation(),
1597 /// WarnExactTypedMethods - This routine issues a warning if method
1602 // don't issue warning when protocol method is optional because primary
1607 // don't issue warning when primary class's method is
1715 // check to see if class implements forwardInvocation method and objects
1718 // Under such conditions, which means that every method possible is
1719 // implemented in the class, we should not issue "Method definition not
1721 // FIXME: Use a general GetUnarySelector method for this.
1735 // If a method lookup fails locally we still need to look and see if
1736 // the method was implemented by a base class or an inherited
1742 for (auto *method : PDecl->instance_methods()) {
1743 if (method->getImplementationControl() != ObjCMethodDecl::Optional &&
1744 !method->isPropertyAccessor() &&
1745 !InsMap.count(method->getSelector()) &&
1746 (!Super || !Super->lookupMethod(method->getSelector(),
1751 // If a method is not implemented in the category implementation but
1754 // This is because method will be implemented in the primary class
1757 // Ugly, but necessary. Method declared in protcol might have
1761 IDecl->lookupMethod(method->getSelector(),
1769 WarnUndefinedMethod(S, ImpLoc, method, IncompleteImpl, DIAG,
1775 for (auto *method : PDecl->class_methods()) {
1776 if (method->getImplementationControl() != ObjCMethodDecl::Optional &&
1777 !ClsMap.count(method->getSelector()) &&
1778 (!Super || !Super->lookupMethod(method->getSelector(),
1779 false /* class method */,
1783 // See above comment for instance method lookups.
1784 if (C && IDecl->lookupMethod(method->getSelector(),
1792 WarnUndefinedMethod(S, ImpLoc, method, IncompleteImpl, DIAG, PDecl);
1829 "Expected to find the method through lookup as well");
1854 "Expected to find the method through lookup as well");
1924 // the super class must implement the method.
2220 ObjCMethodDecl *Method) {
2224 dyn_cast<ObjCCategoryDecl>(Method->getDeclContext()))
2230 List->setMethod(Method);
2235 // We've seen a method with this name, see if we have already seen this type
2243 if (!MatchTwoMethodDeclarations(Method, List->getMethod())) {
2244 // Even if two method types do not match, we would like to say
2247 if (!Method->isDefined())
2255 if (Method->isDefined())
2259 // @implementation. So if Method is not defined and there already is
2260 // an entry for this type signature, Method has to be for a different
2265 // If a method is deprecated, push it in the global pool.
2267 if (Method->isDeprecated()) {
2269 List->setMethod(Method);
2271 // If the new method is unavailable, push it into global pool
2273 if (Method->isUnavailable()) {
2275 List->setMethod(Method);
2281 // We have a new signature for an existing method - add it.
2284 Previous->setNext(new (Mem) ObjCMethodList(Method));
2287 /// \brief Read the contents of the method pool for a given selector from
2294 void Sema::AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl,
2297 if (cast<Decl>(Method->getDeclContext())->isInvalidDecl())
2301 ReadMethodPool(Method->getSelector());
2303 GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector());
2305 Pos = MethodPool.insert(std::make_pair(Method->getSelector(),
2308 Method->setDefined(impl);
2311 addMethodToGlobalList(&Entry, Method);
2315 /// method pool. This exists mostly as a hack to get around certain
2317 /// Really, what we want is a way to take a method out of the global
2318 /// method pool.
2328 // Don't complain about mismatches for -length if the method we
2353 // Test for no method in the pool which should not trigger any warning by
2360 // Diagnose finding more than one method in global pool
2400 // method signature.
2453 for (const ObjCMethodList *Method = &Methods.first; Method;
2454 Method = Method->getNext())
2455 if (Method->getMethod() &&
2456 (Method->getMethod()->isDefined() ||
2457 Method->getMethod()->isPropertyAccessor()))
2458 return Method->getMethod();
2460 for (const ObjCMethodList *Method = &Methods.second; Method;
2461 Method = Method->getNext())
2462 if (Method->getMethod() &&
2463 (Method->getMethod()->isDefined() ||
2464 Method->getMethod()->isPropertyAccessor()))
2465 return Method->getMethod();
2472 StringRef Typo, const ObjCMethodDecl * Method) {
2475 std::string MethodName = Method->getSelector().getAsString();
2485 BestMethod.push_back(Method);
2488 BestMethod.push_back(Method);
2496 if (S.LookupMethodInObjectType(Sel, ObjectType, true/*Instance method*/))
2498 return S.LookupMethodInObjectType(Sel, ObjectType, false/*Class method*/) !=
2622 ObjCMethodDecl *Method =
2625 if (!Method) continue; // Already issued a diagnostic.
2626 if (Method->isInstanceMethod()) {
2627 /// Check for instance method of the same name with incompatible types
2628 const ObjCMethodDecl *&PrevMethod = InsMap[Method->getSelector()];
2629 bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod)
2633 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
2634 << Method->getDeclName();
2636 Method->setInvalidDecl();
2639 Method->setAsRedeclaration(PrevMethod);
2641 Method->getLocation()))
2642 Diag(Method->getLocation(), diag::warn_duplicate_method_decl)
2643 << Method->getDeclName();
2646 InsMap[Method->getSelector()] = Method;
2648 AddInstanceMethodToGlobalPool(Method);
2651 /// Check for class method of the same name with incompatible types
2652 const ObjCMethodDecl *&PrevMethod = ClsMap[Method->getSelector()];
2653 bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod)
2657 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
2658 << Method->getDeclName();
2660 Method->setInvalidDecl();
2663 Method->setAsRedeclaration(PrevMethod);
2665 Method->getLocation()))
2666 Diag(Method->getLocation(), diag::warn_duplicate_method_decl)
2667 << Method->getDeclName();
2670 ClsMap[Method->getSelector()] = Method;
2671 AddFactoryMethodToGlobalPool(Method);
2691 // and adds them to the DeclContext and global method pools.
2812 /// method declaration is compatible with the method's class.
2815 CheckRelatedResultTypeCompatibility(Sema &S, ObjCMethodDecl *Method,
2817 QualType ResultType = Method->getReturnType();
2819 // If an Objective-C method inherits its related result type, then its
2832 // - it is the same as the method's class type, or
2836 // - it is a superclass of the method's class type
2842 // method; we just don't know.
2851 /// A helper class for searching for methods which a particular method
2856 ObjCMethodDecl *Method;
2861 OverrideSearch(Sema &S, ObjCMethodDecl *method) : S(S), Method(method) {
2862 Selector selector = method->getSelector();
2864 // Bypass this search if we've never seen an instance/class method
2876 method->isInstanceMethod() ? it->second.first : it->second.second;
2880 = cast<ObjCContainerDecl>(method->getDeclContext());
2919 // A method in a protocol declaration overrides declarations from
2925 // A method in a category declaration overrides declarations from
2932 // A method in a category definition that has a category
2947 // A method in a class declaration overrides declarations from
2964 // A method in a class implementation overrides declarations from
2978 // Check for a method in this container which matches this selector.
2979 ObjCMethodDecl *meth = container->getMethod(Method->getSelector(),
2980 Method->isInstanceMethod(),
2989 // Otherwise, search for methods that a hypothetical method here
3005 // Keep track if the method overrides any method in the class's base classes,
3008 // For this info, a method in an implementation is not considered as
3009 // overriding the same method in the interface or its categories.
3022 // OverrideSearch will return as "overridden" the same method in the
3024 // check whether a category of a base class introduced a method with the
3025 // same selector, after the interface method declaration.
3036 // If the method is in a category we'll do lookup if there were at
3084 // If type of argument of method in this class does not match its
3085 // respective argument type in the super class method, issue warning;
3112 // Make sure we can establish a context for the method.
3219 // Add the method now.
3252 // You can never have two method definitions with the same name.
3260 // If this Objective-C method does not have a related result type, but we
3262 // method family.
3514 Sema::GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method,
3516 if (Method->isClassMethod())
3518 const ObjCInterfaceDecl *IDecl = Method->getClassInterface();
3521 Method = IDecl->lookupMethod(Method->getSelector(), /*isInstance=*/true,
3524 if (!Method || !Method->isPropertyAccessor())
3526 if ((PDecl = Method->findPropertyDecl()))
3545 const ObjCMethodDecl *Method;
3550 UnusedBackingIvarChecker(Sema &S, const ObjCMethodDecl *Method,
3552 : S(S), Method(Method), IvarD(IvarD),
3567 S.isSelfExpr(E->getInstanceReceiver(), Method)) {
3598 // cases where the ivar is accessed by another method that the accessor