Author: kremenek
Date: Thu Dec 12 23:58:51 2013
New Revision: 197207

URL: http://llvm.org/viewvc/llvm-project?rev=197207&view=rev
Log:
Change 'method X in protocol not implemented' warning to include the name of 
the protocol.

This removes an extra "note:", which wasn't really all that more useful
and overall reduces the diagnostic spew for this case.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/Analysis/method-arg-decay.m
    cfe/trunk/test/SemaObjC/category-1.m
    cfe/trunk/test/SemaObjC/compare-qualified-id.m
    cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.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/protocols-suppress-conformance.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=197207&r1=197206&r2=197207&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Dec 12 23:58:51 
2013
@@ -852,7 +852,7 @@ def warn_unimplemented_selector:  Warnin
 def warning_multiple_selectors: Warning<
   "multiple selectors named %0 found">, InGroup<SelectorTypeMismatch>, 
DefaultIgnore;
 def warn_unimplemented_protocol_method : Warning<
-  "method %0 in protocol not implemented">, InGroup<Protocol>;
+  "method %0 in protocol %1 not implemented">, InGroup<Protocol>;
 
 // C++ declarations
 def err_static_assert_expression_is_not_constant : Error<

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=197207&r1=197206&r2=197207&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Dec 12 23:58:51 2013
@@ -1228,7 +1228,8 @@ void Sema::CheckImplementationIvars(ObjC
 static void WarnUndefinedMethod(Sema &S, SourceLocation ImpLoc,
                                 ObjCMethodDecl *method,
                                 bool &IncompleteImpl,
-                                unsigned DiagID) {
+                                unsigned DiagID,
+                                NamedDecl *NeededFor = 0) {
   // No point warning no definition of method which is 'unavailable'.
   switch (method->getAvailability()) {
   case AR_Available:
@@ -1246,7 +1247,12 @@ static void WarnUndefinedMethod(Sema &S,
   // warning, but some users strongly voiced that they would prefer
   // separate warnings.  We will give that approach a try, as that
   // matches what we do with protocols.
-  S.Diag(ImpLoc, DiagID) << method->getDeclName();
+  {
+    const Sema::SemaDiagnosticBuilder &B = S.Diag(ImpLoc, DiagID);
+    B << method;
+    if (NeededFor)
+      B << NeededFor;
+  }
 
   // Issue a note to the original declaration.
   SourceLocation MethodLoc = method->getLocStart();
@@ -1702,9 +1708,8 @@ void Sema::CheckProtocolMethodDefs(Sourc
             unsigned DIAG = diag::warn_unimplemented_protocol_method;
             if (Diags.getDiagnosticLevel(DIAG, ImpLoc)
                 != DiagnosticsEngine::Ignored) {
-              WarnUndefinedMethod(*this, ImpLoc, method, IncompleteImpl, DIAG);
-              Diag(CDecl->getLocation(), diag::note_required_for_protocol_at)
-                << PDecl->getDeclName();
+              WarnUndefinedMethod(*this, ImpLoc, method, IncompleteImpl, DIAG,
+                                  PDecl);
             }
           }
     }
@@ -1730,9 +1735,7 @@ void Sema::CheckProtocolMethodDefs(Sourc
       unsigned DIAG = diag::warn_unimplemented_protocol_method;
       if (Diags.getDiagnosticLevel(DIAG, ImpLoc) !=
             DiagnosticsEngine::Ignored) {
-        WarnUndefinedMethod(*this, ImpLoc, method, IncompleteImpl, DIAG);
-        Diag(IDecl->getLocation(), diag::note_required_for_protocol_at) <<
-          PDecl->getDeclName();
+        WarnUndefinedMethod(*this, ImpLoc, method, IncompleteImpl, DIAG, 
PDecl);
       }
     }
   }

Modified: cfe/trunk/test/Analysis/method-arg-decay.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/method-arg-decay.m?rev=197207&r1=197206&r2=197207&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/method-arg-decay.m (original)
+++ cfe/trunk/test/Analysis/method-arg-decay.m Thu Dec 12 23:58:51 2013
@@ -67,12 +67,12 @@ extern NSMutableArray *XCFindPossibleKey
 @interface XCExtendedTabView : NSTabView <XCDockViewHeader> {
 }
 @end     @class PBXProjectDocument, PBXFileReference, PBXModule, XCWindowTool;
-@interface XCPerspectiveModule : PBXProjectModule <PBXSelectionTarget> { // 
expected-note {{required for direct or indirect protocol 'PBXSelectionTarget'}}
+@interface XCPerspectiveModule : PBXProjectModule <PBXSelectionTarget> {
   XCExtendedTabView *_perspectivesTabView;
 }
 - (PBXModule *) moduleForTab:(NSTabViewItem *)item;
 @end  
-@implementation XCPerspectiveModule // expected-warning {{method 
'performAction:withSelection:' in protocol not implemented}}}
+@implementation XCPerspectiveModule // expected-warning {{method 
'performAction:withSelection:' in protocol 'PBXSelectionTarget' not 
implemented}}}
 + (void) openForProjectDocument:(PBXProjectDocument *)projectDocument {
 }
 - (PBXModule *) type:(Class)type inPerspective:(id)perspectiveIdentifer  
matchingFunction:(BOOL (void *, void *))comparator usingData:(void *)data {

Modified: cfe/trunk/test/SemaObjC/category-1.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/category-1.m?rev=197207&r1=197206&r2=197207&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/category-1.m (original)
+++ cfe/trunk/test/SemaObjC/category-1.m Thu Dec 12 23:58:51 2013
@@ -65,13 +65,13 @@
 -(void) im0; // expected-note {{method 'im0' declared here}}
 @end
 
-@interface MultipleCat_I @end // expected-note {{required for direct or 
indirect protocol 'MultipleCat_P'}}
+@interface MultipleCat_I @end
 
 @interface MultipleCat_I()  @end
 
 @interface MultipleCat_I() <MultipleCat_P>  @end
 
-@implementation MultipleCat_I // expected-warning {{method 'im0' in protocol 
not implemented}}
+@implementation MultipleCat_I // expected-warning {{method 'im0' in protocol 
'MultipleCat_P' not implemented}}
 @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=197207&r1=197206&r2=197207&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/compare-qualified-id.m (original)
+++ cfe/trunk/test/SemaObjC/compare-qualified-id.m Thu Dec 12 23:58:51 2013
@@ -15,7 +15,7 @@ typedef struct {} NSFastEnumerationState
 @interface NSMutableDictionary : NSDictionary  - 
(void)removeObjectForKey:(id)aKey; @end // expected-note {{receiver is instance 
of class declared here}}
 extern NSString * const NSTaskDidTerminateNotification;
 
-@interface XCPropertyExpansionContext : NSObject <NSCopying> { // 
expected-note {{required for direct or indirect protocol 'NSCopying'}}
+@interface XCPropertyExpansionContext : NSObject <NSCopying> {
   NSMutableDictionary * _propNamesToPropValuesCache;
 } @end
 
@@ -23,7 +23,7 @@ extern NSString * const NSTaskDidTermina
 - (NSString *)evaluateAsStringInContext:(XCPropertyExpansionContext *)context 
withNestingState:(const void *)state;
 @end
 
-@implementation XCPropertyExpansionContext // expected-warning {{method 
'copyWithZone:' in protocol not implemented}}
+@implementation XCPropertyExpansionContext // expected-warning {{method 
'copyWithZone:' in protocol 'NSCopying' not implemented}}
 - (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/forward-protocol-incomplete-impl-warn.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.m?rev=197207&r1=197206&r2=197207&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.m (original)
+++ cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.m Thu Dec 12 
23:58:51 2013
@@ -12,9 +12,9 @@
 
 @protocol DVTInvalidation;
 
-@interface IBImageCatalogDocument : NSObject <DVTInvalidation> // 
expected-note {{required for direct or indirect protocol 'DVTInvalidation'}}
+@interface IBImageCatalogDocument : NSObject <DVTInvalidation>
 @end
 
 @implementation IBImageCatalogDocument // expected-warning {{auto property 
synthesis will not synthesize property 'Prop' declared in protocol 
'DVTInvalidation'}} \ 
-                                      // expected-warning {{method 
'invalidate' in protocol not implemented}}
+                                      // expected-warning {{method 
'invalidate' in protocol 'DVTInvalidation' not implemented}}
 @end

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=197207&r1=197206&r2=197207&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/method-undef-category-warn-1.m (original)
+++ cfe/trunk/test/SemaObjC/method-undef-category-warn-1.m Thu Dec 12 23:58:51 
2013
@@ -8,20 +8,20 @@
 - (void) Pmeth1;  // expected-note {{method 'Pmeth1' declared here}}
 @end
 
-@interface MyClass1(CAT) <P> // expected-note {{required for direct or 
indirect protocol 'P'}}
+@interface MyClass1(CAT) <P>
 - (void) meth2;              // expected-note {{method 'meth2' declared here}}
 @end
 
-@implementation MyClass1(CAT) // expected-warning {{method 'Pmeth' in protocol 
not implemented}} \
+@implementation MyClass1(CAT) // expected-warning {{method 'Pmeth' in protocol 
'P' not implemented}} \
                               // expected-warning {{method definition for 
'meth2' not found}}
 - (void) Pmeth1{}
 @end
 
-@interface MyClass1(DOG) <P> // expected-note {{required for direct or 
indirect protocol 'P'}}
+@interface MyClass1(DOG) <P>
 - (void)ppp;                 // expected-note {{method 'ppp' declared here}}
 @end
 
-@implementation MyClass1(DOG) // expected-warning {{method 'Pmeth1' in 
protocol not implemented}} \
+@implementation MyClass1(DOG) // expected-warning {{method 'Pmeth1' in 
protocol 'P' not implemented}} \
                               // expected-warning {{method definition for 
'ppp' not found}}
 - (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=197207&r1=197206&r2=197207&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/method-undef-extension-warn-1.m (original)
+++ cfe/trunk/test/SemaObjC/method-undef-extension-warn-1.m Thu Dec 12 23:58:51 
2013
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
-@interface MyClass // expected-note {{required for direct or indirect protocol 
'P'}}
+@interface MyClass
 @end
 
 @protocol P
@@ -18,7 +18,7 @@
 - (void)categoryMethod;
 @end
 
-@implementation MyClass // expected-warning {{method 'Pmeth1' in protocol not 
implemented}} \
+@implementation MyClass // expected-warning {{method 'Pmeth1' in protocol 'P' 
not implemented}} \
                         // expected-warning {{method definition for 'meth2' 
not found}}
 - (void)Pmeth {}
 @end

Modified: cfe/trunk/test/SemaObjC/protocols-suppress-conformance.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/protocols-suppress-conformance.m?rev=197207&r1=197206&r2=197207&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/protocols-suppress-conformance.m (original)
+++ cfe/trunk/test/SemaObjC/protocols-suppress-conformance.m Thu Dec 12 
23:58:51 2013
@@ -18,10 +18,10 @@ __attribute__((objc_protocol_requires_ex
 
 // This class subclasses ClassA (which adopts 'Protocol'),
 // but does not provide the needed implementation.
-@interface ClassB : ClassA <Protocol> // expected-note {{required for direct 
or indirect protocol 'Protocol'}}
+@interface ClassB : ClassA <Protocol>
 @end
 
-@implementation ClassB // expected-warning {{method 'theBestOfTimes' in 
protocol not implemented}}
+@implementation ClassB // expected-warning {{method 'theBestOfTimes' in 
protocol 'Protocol' not implemented}}
 @end
 
 // Test that inherited protocols do not get the explicit conformance 
requirement.
@@ -37,10 +37,10 @@ __attribute__((objc_protocol_requires_ex
 @interface ClassC <Inherited>
 @end
 
-@interface ClassD : ClassC <Derived> // expected-note {{required for direct or 
indirect protocol 'Derived'}}
+@interface ClassD : ClassC <Derived>
 @end
 
-@implementation ClassD // expected-warning {{method 'foulIsFair' in protocol 
not implemented}}
+@implementation ClassD // expected-warning {{method 'foulIsFair' in protocol 
'Derived' not implemented}}
 @end
 
 // Test that the attribute is used correctly.

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=197207&r1=197206&r2=197207&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/undef-protocol-methods-1.m (original)
+++ cfe/trunk/test/SemaObjC/undef-protocol-methods-1.m Thu Dec 12 23:58:51 2013
@@ -22,13 +22,10 @@
 + (void) cls_meth : (int) arg1;   // expected-note {{method 'cls_meth:' 
declared here}}
 @end
 
-@interface INTF <PROTO> // expected-note 3 {{required for direct or indirect 
protocol 'PROTO'}} \
-                       // expected-note 2 {{required for direct or indirect 
protocol 'P1'}} \
-                       // expected-note 2 {{required for direct or indirect 
protocol 'P3'}} \
-                       // expected-note 2 {{required for direct or indirect 
protocol 'P2'}}
+@interface INTF <PROTO>
 @end
 
-@implementation INTF // expected-warning 9 {{in protocol not implemented}}
+@implementation INTF // expected-warning 9 {{in protocol '}}
 - (void) DefP1proto{}
 + (void) DefClsP3Proto{}
 @end


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to