Home | History | Annotate | Download | only in Sema

Lines Matching refs:Method

34 /// Check whether the given method, which must be in the 'init'
43 bool Sema::checkInitMethod(ObjCMethodDecl *method,
45 if (method->isInvalidDecl()) return true;
54 method->getReturnType()->castAs<ObjCObjectPointerType>()->getObjectType();
68 !isa<ObjCImplementationDecl>(method->getDeclContext()))
73 // If this method was declared in a protocol, we can't check
76 if (isa<ObjCProtocolDecl>(method->getDeclContext())) {
86 receiverClass = method->getClassInterface();
87 assert(receiverClass && "method not associated with a class!");
97 SourceLocation loc = method->getLocation();
100 // the method unusable.
102 method->addAttr(UnavailableAttr::CreateImplicit(Context, "",
109 method->setInvalidDecl();
117 // This can only happen when the method follows a naming convention that
118 // implies a related result type, and the original (overridden) method has
119 // a suitable return type, but the new (overriding) method does not have
124 // Figure out which class this method is part of, if any.
154 << /*overridden method*/ 0
166 << "method";
173 << "method";
193 /// \brief Check a method declaration for compatibility with the Objective-C
195 bool Sema::CheckARCMethodDecl(ObjCMethodDecl *method) {
196 ObjCMethodFamily family = method->getMethodFamily();
210 if (!Context.hasSameType(method->getReturnType(), Context.VoidTy)) {
211 SourceRange ResultTypeRange = method->getReturnTypeSourceRange();
213 Diag(method->getLocation(), diag::error_dealloc_bad_result_type)
214 << method->getReturnType()
215 << FixItHint::CreateInsertion(method->getSelectorLoc(0), "(void)");
217 Diag(method->getLocation(), diag::error_dealloc_bad_result_type)
218 << method->getReturnType()
225 // If the method doesn't obey the init rules, don't bother annotating it.
226 if (checkInitMethod(method, QualType()))
229 method->addAttr(NSConsumesSelfAttr::CreateImplicit(Context));
233 if (method->hasAttr<NSReturnsRetainedAttr>())
241 if (method->hasAttr<NSReturnsRetainedAttr>() ||
242 method->hasAttr<NSReturnsNotRetainedAttr>() ||
243 method->hasAttr<NSReturnsAutoreleasedAttr>())
248 method->addAttr(NSReturnsRetainedAttr::CreateImplicit(Context));
266 /// AddAnyMethodToGlobalPool - Add any method, instance or factory to global
271 // If we don't have a valid method decl, simply return.
300 /// and user declared, in the method definition's AST.
305 // If we don't have a valid method decl, simply return.
309 // Allow all of Sema to see that we are entering a method definition.
1648 /// a class method in its extension.
1661 for (const auto *Method : CAT->methods()) {
1662 const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
1664 (PrevMethod->isInstanceMethod() == Method->isInstanceMethod()) &&
1665 Method, PrevMethod)) {
1666 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
1667 << Method->getDeclName();
1723 // the enclosing method declarations. We mark the decl invalid
2088 ObjCMethodDecl *method,
2092 // No point warning no definition of method which is 'unavailable'.
2093 switch (method->getAvailability()) {
2111 B << method;
2117 SourceLocation MethodLoc = method->getLocStart();
2119 S.Diag(MethodLoc, diag::note_method_declared_at) << method;
2138 /// have more accurate ones. For example, a method may privately accept
2141 /// by a valid A*. Similarly, a method may return a subclass of the class that
2144 /// This is most important when considering subclassing. A method in a
2150 /// subclass method must be a valid object of the kind that the superclass
2401 case OMF_None: llvm_unreachable("logic error, no method convention");
2465 void Sema::CheckConflictingOverridingMethod(ObjCMethodDecl *Method,
2469 CheckMethodOverrideReturn(*this, Method, Overridden,
2473 for (ObjCMethodDecl::param_iterator IM = Method->param_begin(),
2474 IF = Overridden->param_begin(), EM = Method->param_end(),
2477 CheckMethodOverrideParam(*this, Method, Overridden, *IM, *IF,
2481 if (Method->isVariadic() != Overridden->isVariadic()) {
2482 Diag(Method->getLocation(),
2488 /// WarnExactTypedMethods - This routine issues a warning if method
2493 // don't issue warning when protocol method is optional because primary
2498 // don't issue warning when primary class's method is
2606 // check to see if class implements forwardInvocation method and objects
2609 // Under such conditions, which means that every method possible is
2610 // implemented in the class, we should not issue "Method definition not
2612 // FIXME: Use a general GetUnarySelector method for this.
2626 // If a method lookup fails locally we still need to look and see if
2627 // the method was implemented by a base class or an inherited
2633 for (auto *method : PDecl->instance_methods()) {
2634 if (method->getImplementationControl() != ObjCMethodDecl::Optional &&
2635 !method->isPropertyAccessor() &&
2636 !InsMap.count(method->getSelector()) &&
2637 (!Super || !Super->lookupMethod(method->getSelector(),
2642 // If a method is not implemented in the category implementation but
2645 // This is because method will be implemented in the primary class
2648 // Ugly, but necessary. Method declared in protcol might have
2652 IDecl->lookupMethod(method->getSelector(),
2660 WarnUndefinedMethod(S, ImpLoc, method, IncompleteImpl, DIAG,
2666 for (auto *method : PDecl->class_methods()) {
2667 if (method->getImplementationControl() != ObjCMethodDecl::Optional &&
2668 !ClsMap.count(method->getSelector()) &&
2669 (!Super || !Super->lookupMethod(method->getSelector(),
2670 false /* class method */,
2674 // See above comment for instance method lookups.
2675 if (C && IDecl->lookupMethod(method->getSelector(),
2683 WarnUndefinedMethod(S, ImpLoc, method, IncompleteImpl, DIAG, PDecl);
2720 "Expected to find the method through lookup as well");
2745 "Expected to find the method through lookup as well");
2816 // the super class must implement the method.
3151 ObjCMethodDecl *Method) {
3155 dyn_cast<ObjCCategoryDecl>(Method->getDeclContext()))
3161 List->setMethod(Method);
3166 // We've seen a method with this name, see if we have already seen this type
3174 if (!MatchTwoMethodDeclarations(Method, List->getMethod())) {
3175 // Even if two method types do not match, we would like to say
3178 if (!Method->isDefined())
3186 if (Method->isDefined())
3190 // @implementation. So if Method is not defined and there already is
3191 // an entry for this type signature, Method has to be for a different
3196 // If a method is deprecated, push it in the global pool.
3198 if (Method->isDeprecated()) {
3200 List->setMethod(Method);
3202 // If the new method is unavailable, push it into global pool
3204 if (Method->isUnavailable()) {
3206 Method);
3212 // We have a new signature for an existing method - add it.
3215 Previous->setNext(new (Mem) ObjCMethodList(Method));
3218 /// \brief Read the contents of the method pool for a given selector from
3225 void Sema::AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl,
3228 if (cast<Decl>(Method->getDeclContext())->isInvalidDecl())
3232 ReadMethodPool(Method->getSelector());
3234 GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector());
3236 Pos = MethodPool.insert(std::make_pair(Method->getSelector(),
3239 Method->setDefined(impl);
3242 addMethodToGlobalList(&Entry, Method);
3246 /// method pool. This exists mostly as a hack to get around certain
3248 /// Really, what we want is a way to take a method out of the global
3249 /// method pool.
3259 // Don't complain about mismatches for -length if the method we
3284 // Test for no method in the pool which should not trigger any warning by
3291 // Diagnose finding more than one method in global pool
3331 // method signature.
3384 for (const ObjCMethodList *Method = &Methods.first; Method;
3385 Method = Method->getNext())
3386 if (Method->getMethod() &&
3387 (Method->getMethod()->isDefined() ||
3388 Method->getMethod()->isPropertyAccessor()))
3389 return Method->getMethod();
3391 for (const ObjCMethodList *Method = &Methods.second; Method;
3392 Method = Method->getNext())
3393 if (Method->getMethod() &&
3394 (Method->getMethod()->isDefined() ||
3395 Method->getMethod()->isPropertyAccessor()))
3396 return Method->getMethod();
3403 StringRef Typo, const ObjCMethodDecl * Method) {
3406 std::string MethodName = Method->getSelector().getAsString();
3416 BestMethod.push_back(Method);
3419 BestMethod.push_back(Method);
3427 if (S.LookupMethodInObjectType(Sel, ObjectType, true/*Instance method*/))
3429 return S.LookupMethodInObjectType(Sel, ObjectType, false/*Class method*/) !=
3570 ObjCMethodDecl *Method =
3573 if (!Method) continue; // Already issued a diagnostic.
3574 if (Method->isInstanceMethod()) {
3575 /// Check for instance method of the same name with incompatible types
3576 const ObjCMethodDecl *&PrevMethod = InsMap[Method->getSelector()];
3577 bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod)
3581 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
3582 << Method->getDeclName();
3584 Method->setInvalidDecl();
3587 Method->setAsRedeclaration(PrevMethod);
3589 Method->getLocation()))
3590 Diag(Method->getLocation(), diag::warn_duplicate_method_decl)
3591 << Method->getDeclName();
3594 InsMap[Method->getSelector()] = Method;
3596 AddInstanceMethodToGlobalPool(Method);
3599 /// Check for class method of the same name with incompatible types
3600 const ObjCMethodDecl *&PrevMethod = ClsMap[Method->getSelector()];
3601 bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod)
3605 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
3606 << Method->getDeclName();
3608 Method->setInvalidDecl();
3611 Method->setAsRedeclaration(PrevMethod);
3613 Method->getLocation()))
3614 Diag(Method->getLocation(), diag::warn_duplicate_method_decl)
3615 << Method->getDeclName();
3618 ClsMap[Method->getSelector()] = Method;
3619 AddFactoryMethodToGlobalPool(Method);
3639 // and adds them to the DeclContext and global method pools.
3760 /// method declaration is compatible with the method's class.
3763 CheckRelatedResultTypeCompatibility(Sema &S, ObjCMethodDecl *Method,
3765 QualType ResultType = Method->getReturnType();
3767 // If an Objective-C method inherits its related result type, then its
3780 // - it is the same as the method's class type, or
3784 // - it is a superclass of the method's class type
3790 // method; we just don't know.
3799 /// A helper class for searching for methods which a particular method
3804 ObjCMethodDecl *Method;
3809 OverrideSearch(Sema &S, ObjCMethodDecl *method) : S(S), Method(method) {
3810 Selector selector = method->getSelector();
3812 // Bypass this search if we've never seen an instance/class method
3824 method->isInstanceMethod() ? it->second.first : it->second.second;
3828 = cast<ObjCContainerDecl>(method->getDeclContext());
3867 // A method in a protocol declaration overrides declarations from
3873 // A method in a category declaration overrides declarations from
3880 // A method in a category definition that has a category
3895 // A method in a class declaration overrides declarations from
3912 // A method in a class implementation overrides declarations from
3925 // Check for a method in this container which matches this selector.
3926 ObjCMethodDecl *meth = container->getMethod(Method->getSelector(),
3927 Method->isInstanceMethod(),
3936 // Otherwise, search for methods that a hypothetical method here
3952 // Keep track if the method overrides any method in the class's base classes,
3955 // For this info, a method in an implementation is not considered as
3956 // overriding the same method in the interface or its categories.
3969 // OverrideSearch will return as "overridden" the same method in the
3971 // check whether a category of a base class introduced a method with the
3972 // same selector, after the interface method declaration.
3983 // If the method is in a category we'll do lookup if there were at
4031 // If type of argument of method in this class does not match its
4032 // respective argument type in the super class method, issue warning;
4085 /// Merge information from the declaration of a method in the \@interface
4086 /// (or a category/extension) into the corresponding method in the
4089 ObjCMethodDecl *method,
4093 !method->hasAttr<ObjCRequiresSuperAttr>()) {
4095 method->addAttr(
4097 method->getLocation()));
4103 S, method->getReturnTypeSourceRange().getBegin(),
4104 method->getReturnType(),
4105 method->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability,
4109 method->setReturnType(newReturnType);
4112 unsigned numParams = method->param_size();
4115 ParmVarDecl *param = method->param_begin()[i];
4142 // Make sure we can establish a context for the method.
4251 // Add the method now.
4282 // You can never have two method definitions with the same name.
4290 // If this Objective-C method does not have a related result type, but we
4292 // method family.
4543 Sema::GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method,
4545 if (Method->isClassMethod())
4547 const ObjCInterfaceDecl *IDecl = Method->getClassInterface();
4550 Method = IDecl->lookupMethod(Method->getSelector(), /*isInstance=*/true,
4553 if (!Method || !Method->isPropertyAccessor())
4555 if ((PDecl = Method->findPropertyDecl()))
4574 const ObjCMethodDecl *Method;
4579 UnusedBackingIvarChecker(Sema &S, const ObjCMethodDecl *Method,
4581 : S(S), Method(Method), IvarD(IvarD),
4596 S.isSelfExpr(E->getInstanceReceiver(), Method)) {
4627 // cases where the ivar is accessed by another method that the accessor