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.
llvm-svn: 197207
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index b0deed75..9f17663 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -852,7 +852,7 @@
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<
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 0ecd980..723fbdb 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -1228,7 +1228,8 @@
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 @@
// 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 @@
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 @@
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);
}
}
}
diff --git a/clang/test/Analysis/method-arg-decay.m b/clang/test/Analysis/method-arg-decay.m
index 0af9e3e..a222346 100644
--- a/clang/test/Analysis/method-arg-decay.m
+++ b/clang/test/Analysis/method-arg-decay.m
@@ -67,12 +67,12 @@
@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 {
diff --git a/clang/test/SemaObjC/category-1.m b/clang/test/SemaObjC/category-1.m
index 18b872a..3c2f7d0 100644
--- a/clang/test/SemaObjC/category-1.m
+++ b/clang/test/SemaObjC/category-1.m
@@ -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
diff --git a/clang/test/SemaObjC/compare-qualified-id.m b/clang/test/SemaObjC/compare-qualified-id.m
index 02fa86e..7da7749 100644
--- a/clang/test/SemaObjC/compare-qualified-id.m
+++ b/clang/test/SemaObjC/compare-qualified-id.m
@@ -15,7 +15,7 @@
@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 @@
- (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)) { }
diff --git a/clang/test/SemaObjC/forward-protocol-incomplete-impl-warn.m b/clang/test/SemaObjC/forward-protocol-incomplete-impl-warn.m
index 654ef59..94a516a 100644
--- a/clang/test/SemaObjC/forward-protocol-incomplete-impl-warn.m
+++ b/clang/test/SemaObjC/forward-protocol-incomplete-impl-warn.m
@@ -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
diff --git a/clang/test/SemaObjC/method-undef-category-warn-1.m b/clang/test/SemaObjC/method-undef-category-warn-1.m
index 98d732b..c951db2 100644
--- a/clang/test/SemaObjC/method-undef-category-warn-1.m
+++ b/clang/test/SemaObjC/method-undef-category-warn-1.m
@@ -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
diff --git a/clang/test/SemaObjC/method-undef-extension-warn-1.m b/clang/test/SemaObjC/method-undef-extension-warn-1.m
index fbc21bd..819d6ed 100644
--- a/clang/test/SemaObjC/method-undef-extension-warn-1.m
+++ b/clang/test/SemaObjC/method-undef-extension-warn-1.m
@@ -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
diff --git a/clang/test/SemaObjC/protocols-suppress-conformance.m b/clang/test/SemaObjC/protocols-suppress-conformance.m
index 3349f7f..f62b285 100644
--- a/clang/test/SemaObjC/protocols-suppress-conformance.m
+++ b/clang/test/SemaObjC/protocols-suppress-conformance.m
@@ -18,10 +18,10 @@
// 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 @@
@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.
diff --git a/clang/test/SemaObjC/undef-protocol-methods-1.m b/clang/test/SemaObjC/undef-protocol-methods-1.m
index 25b1dad..4858faf 100644
--- a/clang/test/SemaObjC/undef-protocol-methods-1.m
+++ b/clang/test/SemaObjC/undef-protocol-methods-1.m
@@ -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