[cfe-commits] r117739 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclObjC.cpp test/SemaObjC/category-1.m test/SemaObjC/compare-qualified-id.m test/SemaObjC/method-arg-decay.m test/SemaObjC/method-undef-category-warn-1.m test/SemaObjC/method-undef-extension-warn-1.m test/SemaObjC/undef-protocol-methods-1.m

Fariborz Jahanian fjahanian at apple.com
Fri Oct 29 16:20:05 PDT 2010


Author: fjahanian
Date: Fri Oct 29 18:20:05 2010
New Revision: 117739

URL: http://llvm.org/viewvc/llvm-project?rev=117739&view=rev
Log:
Improve diagnostics reporting of un-implemented
methods in protocols when protocols are in system
headers and thus ignored. //rdar: //8227199

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/category-1.m
    cfe/trunk/test/SemaObjC/compare-qualified-id.m
    cfe/trunk/test/SemaObjC/method-arg-decay.m
    cfe/trunk/test/SemaObjC/method-undef-category-warn-1.m
    cfe/trunk/test/SemaObjC/method-undef-extension-warn-1.m
    cfe/trunk/test/SemaObjC/undef-protocol-methods-1.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=117739&r1=117738&r2=117739&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 29 18:20:05 2010
@@ -348,6 +348,7 @@
 def warn_accessor_property_type_mismatch : Warning<
   "type of property %0 does not match type of accessor %1">;
 def note_declared_at : Note<"declared here">;
+def note_method_declared_at : Note<"method declared here">;
 def err_setter_type_void : Error<"type of setter must be void">;
 def err_duplicate_method_decl : Error<"duplicate declaration of method %0">;
 def warn_missing_atend : Warning<"'@end' is missing in implementation context">;

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=117739&r1=117738&r2=117739&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Oct 29 18:20:05 2010
@@ -745,8 +745,10 @@
     Diag(ImpLoc, diag::warn_incomplete_impl);
     IncompleteImpl = true;
   }
-  Diag(method->getLocation(), DiagID) 
-    << method->getDeclName();
+  if (DiagID == diag::warn_unimplemented_protocol_method)
+    Diag(ImpLoc, DiagID) << method->getDeclName();
+  else
+    Diag(method->getLocation(), DiagID) << method->getDeclName();
 }
 
 /// Determines if type B can be substituted for type A.  Returns true if we can
@@ -969,6 +971,7 @@
               unsigned DIAG = diag::warn_unimplemented_protocol_method;
               if (Diags.getDiagnosticLevel(DIAG) != Diagnostic::Ignored) {
                 WarnUndefinedMethod(ImpLoc, method, IncompleteImpl, DIAG);
+                Diag(method->getLocation(), diag::note_method_declared_at);
                 Diag(CDecl->getLocation(), diag::note_required_for_protocol_at)
                   << PDecl->getDeclName();
               }
@@ -986,6 +989,7 @@
       unsigned DIAG = diag::warn_unimplemented_protocol_method;
       if (Diags.getDiagnosticLevel(DIAG) != Diagnostic::Ignored) {
         WarnUndefinedMethod(ImpLoc, method, IncompleteImpl, DIAG);
+        Diag(method->getLocation(), diag::note_method_declared_at);
         Diag(IDecl->getLocation(), diag::note_required_for_protocol_at) <<
           PDecl->getDeclName();
       }

Modified: cfe/trunk/test/SemaObjC/category-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/category-1.m?rev=117739&r1=117738&r2=117739&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/category-1.m (original)
+++ cfe/trunk/test/SemaObjC/category-1.m Fri Oct 29 18:20:05 2010
@@ -62,7 +62,7 @@
 // <rdar://problem/7249233>
 
 @protocol MultipleCat_P
--(void) im0; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+-(void) im0; // expected-note {{method declared here}}
 @end
 
 @interface MultipleCat_I @end // expected-note {{required for direct or indirect protocol 'MultipleCat_P'}}
@@ -71,7 +71,8 @@
 
 @interface MultipleCat_I() <MultipleCat_P>  @end
 
- at implementation MultipleCat_I // expected-warning {{incomplete implementation}}
+ at implementation MultipleCat_I // expected-warning {{incomplete implementation}} \
+                              // expected-warning {{method in protocol not implemented [-Wprotocol]}}
 @end
 
 // <rdar://problem/7680391> - Handle nameless categories with no name that refer

Modified: cfe/trunk/test/SemaObjC/compare-qualified-id.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/compare-qualified-id.m?rev=117739&r1=117738&r2=117739&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/compare-qualified-id.m (original)
+++ cfe/trunk/test/SemaObjC/compare-qualified-id.m Fri Oct 29 18:20:05 2010
@@ -5,7 +5,7 @@
 typedef struct _NSZone NSZone;
 @class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
 @protocol NSObject  - (BOOL)isEqual:(id)object; @end
- at protocol NSCopying  - (id)copyWithZone:(NSZone *)zone; @end // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+ at protocol NSCopying  - (id)copyWithZone:(NSZone *)zone; @end // expected-note {{method declared here}}
 @protocol NSMutableCopying  - (id)mutableCopyWithZone:(NSZone *)zone; @end
 @protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder; @end
 @interface NSObject <NSObject> {} @end
@@ -23,7 +23,8 @@
 - (NSString *)evaluateAsStringInContext:(XCPropertyExpansionContext *)context withNestingState:(const void *)state;
 @end
 
- at implementation XCPropertyExpansionContext // expected-warning {{incomplete implementation}}
+ at implementation XCPropertyExpansionContext // expected-warning {{incomplete implementation}} \
+					   // expected-warning {{method in protocol not implemented [-Wprotocol]}}
 - (NSString *)expandedValueForProperty:(NSString *)property {
   id <XCPropertyValues> cachedValueNode = [_propNamesToPropValuesCache objectForKey:property]; // expected-warning {{method '-objectForKey:' not found (return type defaults to 'id')}}
   if (cachedValueNode == ((void *)0)) { }

Modified: cfe/trunk/test/SemaObjC/method-arg-decay.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-arg-decay.m?rev=117739&r1=117738&r2=117739&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/method-arg-decay.m (original)
+++ cfe/trunk/test/SemaObjC/method-arg-decay.m Fri Oct 29 18:20:05 2010
@@ -56,7 +56,7 @@
 @interface PBXProjectModule : PBXModule <PBXFindableText> {
 }
 @end @class PBXBookmark;
- at protocol PBXSelectionTarget - (NSObject <PBXSelectionTarget> *) performAction:(id)action withSelection:(NSArray *)selection; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+ at protocol PBXSelectionTarget - (NSObject <PBXSelectionTarget> *) performAction:(id)action withSelection:(NSArray *)selection;  // expected-note {{method declared here}}
 @end @class XCPropertyDictionary, XCPropertyCondition, XCPropertyConditionSet, XCMutablePropertyConditionSet;
 extern NSMutableArray *XCFindPossibleKeyModules(PBXModule *module, BOOL useExposedModulesOnly);
 @interface NSString (StringUtilities) - (NSString *) trimToLength:(NSInteger)length preserveRange:(NSRange)range;
@@ -72,7 +72,8 @@
 }
 - (PBXModule *) moduleForTab:(NSTabViewItem *)item; // expected-note {{method definition for 'moduleForTab:' not found}}
 @end  
- at implementation XCPerspectiveModule // expected-warning {{incomplete implementation}}
+ at implementation XCPerspectiveModule // expected-warning {{incomplete implementation}} \
+				    // expected-warning {{method in protocol not implemented [-Wprotocol]}}
 + (void) openForProjectDocument:(PBXProjectDocument *)projectDocument {
 }
 - (PBXModule *) type:(Class)type inPerspective:(id)perspectiveIdentifer  matchingFunction:(BOOL (void *, void *))comparator usingData:(void *)data {

Modified: cfe/trunk/test/SemaObjC/method-undef-category-warn-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-undef-category-warn-1.m?rev=117739&r1=117738&r2=117739&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/method-undef-category-warn-1.m (original)
+++ cfe/trunk/test/SemaObjC/method-undef-category-warn-1.m Fri Oct 29 18:20:05 2010
@@ -4,23 +4,25 @@
 @end
 
 @protocol P
-- (void) Pmeth;	 // expected-warning {{method in protocol not implemented [-Wprotocol]}}
-- (void) Pmeth1;   // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+- (void) Pmeth;	  // expected-note {{method declared here }}
+- (void) Pmeth1;    // expected-note {{method declared here }}
 @end
 
 @interface MyClass1(CAT) <P> // expected-note {{required for direct or indirect protocol 'P'}}
 - (void) meth2;	 // expected-note {{method definition for 'meth2' not found}}
 @end
 
- at implementation MyClass1(CAT) // expected-warning {{incomplete implementation}} 
+ at implementation MyClass1(CAT) // expected-warning {{incomplete implementation}}  \
+				// expected-warning {{method in protocol not implemented [-Wprotocol]}}
 - (void) Pmeth1{}
 @end
 
 @interface MyClass1(DOG) <P> // expected-note {{required for direct or indirect protocol 'P'}}
-- (void)ppp;    // expected-note {{method definition for 'ppp' not found}}
+- (void)ppp;    // expected-note {{method definition for 'ppp' not found}} 
 @end
 
- at implementation MyClass1(DOG) // expected-warning {{incomplete implementation}}
+ at implementation MyClass1(DOG) // expected-warning {{incomplete implementation}} \
+		// expected-warning {{method in protocol not implemented [-Wprotocol]}}
 - (void) Pmeth {}
 @end
 

Modified: cfe/trunk/test/SemaObjC/method-undef-extension-warn-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-undef-extension-warn-1.m?rev=117739&r1=117738&r2=117739&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/method-undef-extension-warn-1.m (original)
+++ cfe/trunk/test/SemaObjC/method-undef-extension-warn-1.m Fri Oct 29 18:20:05 2010
@@ -5,7 +5,7 @@
 
 @protocol P
 - (void)Pmeth;
-- (void)Pmeth1; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+- (void)Pmeth1; // expected-note {{method declared here}}
 @end
 
 // Class extension
@@ -18,6 +18,7 @@
 - (void)categoryMethod;
 @end
 
- at implementation MyClass // expected-warning {{incomplete implementation}} 
+ at implementation MyClass // expected-warning {{incomplete implementation}}  \
+			// expected-warning {{method in protocol not implemented [-Wprotocol]}}
 - (void)Pmeth {}
 @end

Modified: cfe/trunk/test/SemaObjC/undef-protocol-methods-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/undef-protocol-methods-1.m?rev=117739&r1=117738&r2=117739&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/undef-protocol-methods-1.m (original)
+++ cfe/trunk/test/SemaObjC/undef-protocol-methods-1.m Fri Oct 29 18:20:05 2010
@@ -1,25 +1,25 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
 @protocol P1
-- (void) P1proto; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
-+ (void) ClsP1Proto;   // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+- (void) P1proto;  // expected-note {{method declared here}}
++ (void) ClsP1Proto;    // expected-note {{method declared here}}
 - (void) DefP1proto;
 @end
 @protocol P2
-- (void) P2proto;   // expected-warning {{method in protocol not implemented [-Wprotocol]}}
-+ (void) ClsP2Proto;  // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+- (void) P2proto;   // expected-note {{method declared here}}
++ (void) ClsP2Proto;  // expected-note {{method declared here}}
 @end
 
 @protocol P3<P2>
-- (void) P3proto;  // expected-warning {{method in protocol not implemented [-Wprotocol]}}
-+ (void) ClsP3Proto;  // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+- (void) P3proto;   // expected-note {{method declared here}}
++ (void) ClsP3Proto;   // expected-note {{method declared here}}
 + (void) DefClsP3Proto;
 @end
 
 @protocol PROTO<P1, P3>
-- (void) meth;		 // expected-warning {{method in protocol not implemented [-Wprotocol]}}
-- (void) meth : (int) arg1;  // expected-warning {{method in protocol not implemented [-Wprotocol]}}
-+ (void) cls_meth : (int) arg1;  // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+- (void) meth;		  // expected-note {{method declared here}}
+- (void) meth : (int) arg1;   // expected-note {{method declared here}}
++ (void) cls_meth : (int) arg1;   // expected-note {{method declared here}}
 @end
 
 @interface INTF <PROTO> // expected-note 3 {{required for direct or indirect protocol 'PROTO'}} \
@@ -28,7 +28,8 @@
 			// expected-note 2 {{required for direct or indirect protocol 'P2'}}
 @end
 
- at implementation INTF   // expected-warning {{incomplete implementation}} 
+ at implementation INTF   // expected-warning {{incomplete implementation}} \
+                       // expected-warning 9 {{method in protocol not implemented [-Wprotocol}}
 - (void) DefP1proto{}
 
 + (void) DefClsP3Proto{}





More information about the cfe-commits mailing list