]> granicus.if.org Git - clang/commitdiff
Further improvement to point to category
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 27 Mar 2010 21:10:05 +0000 (21:10 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 27 Mar 2010 21:10:05 +0000 (21:10 +0000)
whose protocolls methods needs implementation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99730 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.h
lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/method-undef-category-warn-1.m

index 5436aa940d68df6598cd2a48f0b5a0b391570e31..7187f529ce2d64d8ed77618cc66c9b615cd53fc4 100644 (file)
@@ -1452,7 +1452,7 @@ public:
                                bool& IncompleteImpl,
                                const llvm::DenseSet<Selector> &InsMap,
                                const llvm::DenseSet<Selector> &ClsMap,
-                               ObjCInterfaceDecl *IDecl);
+                               ObjCContainerDecl *CDecl);
 
   /// CheckImplementationIvars - This routine checks if the instance variables
   /// listed in the implelementation match those listed in the interface.
index 79a664f2e1f8f6807f75e7e429bf2db1200eb830..cf7ffae23610233e012da970c6fff61bc5a67e3f 100644 (file)
@@ -769,7 +769,14 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc,
                                    bool& IncompleteImpl,
                                    const llvm::DenseSet<Selector> &InsMap,
                                    const llvm::DenseSet<Selector> &ClsMap,
-                                   ObjCInterfaceDecl *IDecl) {
+                                   ObjCContainerDecl *CDecl) {
+  ObjCInterfaceDecl *IDecl;
+  if (ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl))
+    IDecl = C->getClassInterface();
+  else
+    IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl);
+  assert (IDecl && "CheckProtocolMethodDefs - IDecl is null");
+  
   ObjCInterfaceDecl *Super = IDecl->getSuperClass();
   ObjCInterfaceDecl *NSIDecl = 0;
   if (getLangOptions().NeXTRuntime) {
@@ -809,7 +816,7 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc,
             IDecl->lookupInstanceMethod(method->getSelector());
             if (!MethodInClass || !MethodInClass->isSynthesized()) {
               WarnUndefinedMethod(ImpLoc, method, IncompleteImpl);
-              Diag(IDecl->getLocation(), diag::note_required_for_protocol_at) <<
+              Diag(CDecl->getLocation(), diag::note_required_for_protocol_at) <<
                 PDecl->getDeclName();
             }
           }
@@ -955,7 +962,7 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
       for (ObjCCategoryDecl::protocol_iterator PI = C->protocol_begin(),
            E = C->protocol_end(); PI != E; ++PI)
         CheckProtocolMethodDefs(IMPDecl->getLocation(), *PI, IncompleteImpl,
-                                InsMap, ClsMap, C->getClassInterface());
+                                InsMap, ClsMap, CDecl);
       // Report unimplemented properties in the category as well.
       // When reporting on missing setter/getters, do not report when
       // setter/getter is implemented in category's primary class 
index dace8ab2949bd37755720130251f5f628dcc3321..7f3604992317d45a08e252f6e8ae8a71eaa61343 100644 (file)
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-@interface MyClass1  // expected-note 2 {{required for direct or indirect protocol 'P'}}
+@interface MyClass1
 @end
 
 @protocol P
@@ -8,7 +8,7 @@
 - (void) Pmeth1;   // expected-note {{method definition for 'Pmeth1' not found}}
 @end
 
-@interface MyClass1(CAT) <P>
+@interface MyClass1(CAT) <P> // expected-note {{required for direct or indirect protocol 'P'}}
 - (void) meth2;         // expected-note {{method definition for 'meth2' not found}}
 @end
 
@@ -16,7 +16,7 @@
 - (void) Pmeth1{}
 @end
 
-@interface MyClass1(DOG) <P>
+@interface MyClass1(DOG) <P> // expected-note {{required for direct or indirect protocol 'P'}}
 - (void)ppp;    // expected-note {{method definition for 'ppp' not found}}
 @end