Home | History | Annotate | Download | only in Sema

Lines Matching refs:Method

30 /// Check whether the given method, which must be in the 'init'
39 bool Sema::checkInitMethod(ObjCMethodDecl *method,
41 if (method->isInvalidDecl()) return true;
49 const ObjCObjectType *result = method->getResultType()
64 !isa<ObjCImplementationDecl>(method->getDeclContext()))
69 // If this method was declared in a protocol, we can't check
72 if (isa<ObjCProtocolDecl>(method->getDeclContext())) {
82 receiverClass = method->getClassInterface();
83 assert(receiverClass && "method not associated with a class!");
93 SourceLocation loc = method->getLocation();
96 // the method unusable.
98 method->addAttr(new (Context) UnavailableAttr(loc, Context,
99 "init method returns a type unrelated to its receiver type"));
105 method->setInvalidDecl();
114 // This can only happen when the method follows a naming convention that
115 // implies a related result type, and the original (overridden) method has
116 // a suitable return type, but the new (overriding) method does not have
124 // Figure out which class this method is part of, if any.
158 /// \brief Check for consistency between a given method declaration and the
161 /// This method walks the inheritance hierarchy starting at the given
163 /// the given new method (\p NewMethod) and any method it directly overrides
174 // Look for this method. If we find it, we're done.
252 /// \brief Check a method declaration for compatibility with the Objective-C
254 static bool CheckARCMethodDecl(Sema &S, ObjCMethodDecl *method) {
255 ObjCMethodFamily family = method->getMethodFamily();
267 // If the method doesn't obey the init rules, don't bother annotating it.
268 if (S.checkInitMethod(method, QualType()))
271 method->addAttr(new (S.Context) NSConsumesSelfAttr(SourceLocation(),
276 if (method->hasAttr<NSReturnsRetainedAttr>())
284 if (method->hasAttr<NSReturnsRetainedAttr>() ||
285 method->hasAttr<NSReturnsNotRetainedAttr>() ||
286 method->hasAttr<NSReturnsAutoreleasedAttr>())
296 method->addAttr(new (S.Context) NSReturnsRetainedAttr(SourceLocation(),
315 /// and user declared, in the method definition's AST.
317 assert(getCurMethodDecl() == 0 && "Method parsing confused");
320 // If we don't have a valid method decl, simply return.
324 // Allow the rest of sema to find private method decl implementations.
330 // Allow all of Sema to see that we are entering a method definition.
694 /// a class method in its extension.
712 ObjCMethodDecl *Method = *i;
713 const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
714 if (PrevMethod && !MatchTwoMethodDeclarations(Method, PrevMethod)) {
715 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
716 << Method->getDeclName();
774 // the enclosing method declarations. We mark the decl invalid
1084 void Sema::WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method,
1086 // No point warning no definition of method which is 'unavailable'.
1087 if (method->hasAttr<UnavailableAttr>())
1094 Diag(ImpLoc, DiagID) << method->getDeclName();
1096 Diag(method->getLocation(), DiagID) << method->getDeclName();
1115 /// have more accurate ones. For example, a method may privately accept
1118 /// by a valid A*. Similarly, a method may return a subclass of the class that
1121 /// This is most important when considering subclassing. A method in a
1127 /// subclass method must be a valid object of the kind that the superclass
1300 case OMF_None: llvm_unreachable("logic error, no method convention");
1382 // check to see if class implements forwardInvocation method and objects
1385 // Under such conditions, which means that every method possible is
1386 // implemented in the class, we should not issue "Method definition not
1388 // FIXME: Use a general GetUnarySelector method for this.
1397 // If a method lookup fails locally we still need to look and see if
1398 // the method was implemented by a base class or an inherited
1406 ObjCMethodDecl *method = *I;
1407 if (method->getImplementationControl() != ObjCMethodDecl::Optional &&
1408 !method->isSynthesized() && !InsMap.count(method->getSelector()) &&
1410 !Super->lookupInstanceMethod(method->getSelector()))) {
1411 // Ugly, but necessary. Method declared in protcol might have
1415 IDecl->lookupInstanceMethod(method->getSelector());
1420 WarnUndefinedMethod(ImpLoc, method, IncompleteImpl, DIAG);
1421 Diag(method->getLocation(), diag::note_method_declared_at);
1432 ObjCMethodDecl *method = *I;
1433 if (method->getImplementationControl() != ObjCMethodDecl::Optional &&
1434 !ClsMap.count(method->getSelector()) &&
1435 (!Super || !Super->lookupClassMethod(method->getSelector()))) {
1438 WarnUndefinedMethod(ImpLoc, method, IncompleteImpl, DIAG);
1439 Diag(method->getLocation(), diag::note_method_declared_at);
1784 /// \brief Read the contents of the method pool for a given selector from
1787 /// This routine should only be called once, when the method pool has no entry
1792 "Selector data already loaded into the method pool");
1794 // Read the method list from the external source.
1800 void Sema::AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl,
1802 GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector());
1805 Pos = ReadMethodPool(Method->getSelector());
1807 Pos = MethodPool.insert(std::make_pair(Method->getSelector(),
1810 Method->setDefined(impl);
1812 if (Entry.Method == 0) {
1813 // Haven't seen a method with this selector name yet - add it.
1814 Entry.Method = Method;
1819 // We've seen a method with this name, see if we have already seen this type
1822 bool match = MatchTwoMethodDeclarations(Method, List->Method);
1825 ObjCMethodDecl *PrevObjCMethod = List->Method;
1827 // If a method is deprecated, push it in the global pool.
1829 if (Method->isDeprecated()) {
1831 List->Method = Method;
1833 // If new method is unavailable, push it into global pool
1835 if (Method->isUnavailable()) {
1837 List->Method = Method;
1843 // We have a new signature for an existing method - add it.
1846 Entry.Next = new (Mem) ObjCMethodList(Method, Entry.Next);
1850 /// method pool. This exists mostly as a hack to get around certain
1852 /// Really, what we want is a way to take a method out of the global
1853 /// method pool.
1863 // Don't complain about mismatches for -length if the method we
1881 if (warn && MethList.Method && MethList.Next) {
1885 // method signature.
1893 if (!MatchTwoMethodDeclarations(MethList.Method, Next->Method,
1907 if (!MatchTwoMethodDeclarations(MethList.Method, Next->Method,
1909 !isAcceptableMethodMismatch(MethList.Method, Next->Method)) {
1925 Diag(MethList.Method->getLocStart(),
1927 << MethList.Method->getSourceRange();
1929 Diag(Next->Method->getLocStart(), diag::note_also_found)
1930 << Next->Method->getSourceRange();
1933 return MethList.Method;
1943 if (Methods.first.Method && Methods.first.Method->isDefined())
1944 return Methods.first.Method;
1945 if (Methods.second.Method && Methods.second.Method->isDefined())
1946 return Methods.second.Method;
1954 ObjCMethodDecl *Method,
1961 SD->lookupMethod(Method->getSelector(), IsInstance);
1966 ObjCMethodDecl::param_iterator ParamI = Method->param_begin(),
1967 E = Method->param_end();
1974 // If type of argument of method in this class does not match its
1975 // respective argument type in the super class method, issue warning;
2042 ObjCMethodDecl *Method =
2045 if (!Method) continue; // Already issued a diagnostic.
2046 if (Method->isInstanceMethod()) {
2047 /// Check for instance method of the same name with incompatible types
2048 const ObjCMethodDecl *&PrevMethod = InsMap[Method->getSelector()];
2049 bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod)
2053 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
2054 << Method->getDeclName();
2056 Method->setInvalidDecl();
2058 InsMap[Method->getSelector()] = Method;
2060 AddInstanceMethodToGlobalPool(Method);
2061 // verify that the instance method conforms to the same definition of
2063 CompareMethodParamsInBaseAndSuper(ClassDecl, Method, true);
2066 /// Check for class method of the same name with incompatible types
2067 const ObjCMethodDecl *&PrevMethod = ClsMap[Method->getSelector()];
2068 bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod)
2072 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
2073 << Method->getDeclName();
2075 Method->setInvalidDecl();
2077 ClsMap[Method->getSelector()] = Method;
2079 AddFactoryMethodToGlobalPool(Method);
2080 // verify that the class method conforms to the same definition of
2082 CompareMethodParamsInBaseAndSuper(ClassDecl, Method, false);
2107 // and adds them to the DeclContext and global method pools.
2202 // The 'ibaction' attribute is allowed on method definitions because of
2203 // how the IBAction macro is used on both method declarations and definitions.
2204 // If the method definitions contains any other attributes, return true.
2212 /// method declaration is compatible with the method's class.
2215 CheckRelatedResultTypeCompatibility(Sema &S, ObjCMethodDecl *Method,
2217 QualType ResultType = Method->getResultType();
2219 if (const TypeSourceInfo *ResultTypeInfo = Method->getResultTypeSourceInfo())
2222 // If an Objective-C method inherits its related result type, then its
2235 // - it is the same as the method's class type, or
2239 // - it is a superclass of the method's class type
2249 /// \brief Determine if any method in the global method pool has an inferred
2263 if (M->Method && M->Method->hasRelatedResultType())
2283 // Make sure we can establish a context for the method.
2397 // Add the method now.
2433 // You can never have two method definitions with the same name.
2439 // If this Objective-C method does not have a related result type, but we
2441 // method family.