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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197207 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2013-12-13 05:58:51 +00:00
parent 9758c05355
commit 7171f14eae
10 changed files with 32 additions and 32 deletions

View File

@ -852,7 +852,7 @@ def warn_unimplemented_selector: Warning<
def warning_multiple_selectors: Warning< def warning_multiple_selectors: Warning<
"multiple selectors named %0 found">, InGroup<SelectorTypeMismatch>, DefaultIgnore; "multiple selectors named %0 found">, InGroup<SelectorTypeMismatch>, DefaultIgnore;
def warn_unimplemented_protocol_method : Warning< 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 // C++ declarations
def err_static_assert_expression_is_not_constant : Error< def err_static_assert_expression_is_not_constant : Error<

View File

@ -1228,7 +1228,8 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
static void WarnUndefinedMethod(Sema &S, SourceLocation ImpLoc, static void WarnUndefinedMethod(Sema &S, SourceLocation ImpLoc,
ObjCMethodDecl *method, ObjCMethodDecl *method,
bool &IncompleteImpl, bool &IncompleteImpl,
unsigned DiagID) { unsigned DiagID,
NamedDecl *NeededFor = 0) {
// No point warning no definition of method which is 'unavailable'. // No point warning no definition of method which is 'unavailable'.
switch (method->getAvailability()) { switch (method->getAvailability()) {
case AR_Available: case AR_Available:
@ -1246,7 +1247,12 @@ static void WarnUndefinedMethod(Sema &S, SourceLocation ImpLoc,
// warning, but some users strongly voiced that they would prefer // warning, but some users strongly voiced that they would prefer
// separate warnings. We will give that approach a try, as that // separate warnings. We will give that approach a try, as that
// matches what we do with protocols. // 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. // Issue a note to the original declaration.
SourceLocation MethodLoc = method->getLocStart(); SourceLocation MethodLoc = method->getLocStart();
@ -1702,9 +1708,8 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc,
unsigned DIAG = diag::warn_unimplemented_protocol_method; unsigned DIAG = diag::warn_unimplemented_protocol_method;
if (Diags.getDiagnosticLevel(DIAG, ImpLoc) if (Diags.getDiagnosticLevel(DIAG, ImpLoc)
!= DiagnosticsEngine::Ignored) { != DiagnosticsEngine::Ignored) {
WarnUndefinedMethod(*this, ImpLoc, method, IncompleteImpl, DIAG); WarnUndefinedMethod(*this, ImpLoc, method, IncompleteImpl, DIAG,
Diag(CDecl->getLocation(), diag::note_required_for_protocol_at) PDecl);
<< PDecl->getDeclName();
} }
} }
} }
@ -1730,9 +1735,7 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc,
unsigned DIAG = diag::warn_unimplemented_protocol_method; unsigned DIAG = diag::warn_unimplemented_protocol_method;
if (Diags.getDiagnosticLevel(DIAG, ImpLoc) != if (Diags.getDiagnosticLevel(DIAG, ImpLoc) !=
DiagnosticsEngine::Ignored) { DiagnosticsEngine::Ignored) {
WarnUndefinedMethod(*this, ImpLoc, method, IncompleteImpl, DIAG); WarnUndefinedMethod(*this, ImpLoc, method, IncompleteImpl, DIAG, PDecl);
Diag(IDecl->getLocation(), diag::note_required_for_protocol_at) <<
PDecl->getDeclName();
} }
} }
} }

View File

@ -67,12 +67,12 @@ extern NSMutableArray *XCFindPossibleKeyModules(PBXModule *module, BOOL useExpos
@interface XCExtendedTabView : NSTabView <XCDockViewHeader> { @interface XCExtendedTabView : NSTabView <XCDockViewHeader> {
} }
@end @class PBXProjectDocument, PBXFileReference, PBXModule, XCWindowTool; @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; XCExtendedTabView *_perspectivesTabView;
} }
- (PBXModule *) moduleForTab:(NSTabViewItem *)item; - (PBXModule *) moduleForTab:(NSTabViewItem *)item;
@end @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 { + (void) openForProjectDocument:(PBXProjectDocument *)projectDocument {
} }
- (PBXModule *) type:(Class)type inPerspective:(id)perspectiveIdentifer matchingFunction:(BOOL (void *, void *))comparator usingData:(void *)data { - (PBXModule *) type:(Class)type inPerspective:(id)perspectiveIdentifer matchingFunction:(BOOL (void *, void *))comparator usingData:(void *)data {

View File

@ -65,13 +65,13 @@
-(void) im0; // expected-note {{method 'im0' declared here}} -(void) im0; // expected-note {{method 'im0' declared here}}
@end @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() @end
@interface MultipleCat_I() <MultipleCat_P> @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 @end
// <rdar://problem/7680391> - Handle nameless categories with no name that refer // <rdar://problem/7680391> - Handle nameless categories with no name that refer

View File

@ -15,7 +15,7 @@ typedef struct {} NSFastEnumerationState;
@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey; @end // expected-note {{receiver is instance of class declared here}} @interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey; @end // expected-note {{receiver is instance of class declared here}}
extern NSString * const NSTaskDidTerminateNotification; extern NSString * const NSTaskDidTerminateNotification;
@interface XCPropertyExpansionContext : NSObject <NSCopying> { // expected-note {{required for direct or indirect protocol 'NSCopying'}} @interface XCPropertyExpansionContext : NSObject <NSCopying> {
NSMutableDictionary * _propNamesToPropValuesCache; NSMutableDictionary * _propNamesToPropValuesCache;
} @end } @end
@ -23,7 +23,7 @@ extern NSString * const NSTaskDidTerminateNotification;
- (NSString *)evaluateAsStringInContext:(XCPropertyExpansionContext *)context withNestingState:(const void *)state; - (NSString *)evaluateAsStringInContext:(XCPropertyExpansionContext *)context withNestingState:(const void *)state;
@end @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 { - (NSString *)expandedValueForProperty:(NSString *)property {
id <XCPropertyValues> cachedValueNode = [_propNamesToPropValuesCache objectForKey:property]; // expected-warning {{method '-objectForKey:' not found (return type defaults to 'id')}} id <XCPropertyValues> cachedValueNode = [_propNamesToPropValuesCache objectForKey:property]; // expected-warning {{method '-objectForKey:' not found (return type defaults to 'id')}}
if (cachedValueNode == ((void *)0)) { } if (cachedValueNode == ((void *)0)) { }

View File

@ -12,9 +12,9 @@
@protocol DVTInvalidation; @protocol DVTInvalidation;
@interface IBImageCatalogDocument : NSObject <DVTInvalidation> // expected-note {{required for direct or indirect protocol 'DVTInvalidation'}} @interface IBImageCatalogDocument : NSObject <DVTInvalidation>
@end @end
@implementation IBImageCatalogDocument // expected-warning {{auto property synthesis will not synthesize property 'Prop' declared in protocol 'DVTInvalidation'}} \ @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 @end

View File

@ -8,20 +8,20 @@
- (void) Pmeth1; // expected-note {{method 'Pmeth1' declared here}} - (void) Pmeth1; // expected-note {{method 'Pmeth1' declared here}}
@end @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}} - (void) meth2; // expected-note {{method 'meth2' declared here}}
@end @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}} // expected-warning {{method definition for 'meth2' not found}}
- (void) Pmeth1{} - (void) Pmeth1{}
@end @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}} - (void)ppp; // expected-note {{method 'ppp' declared here}}
@end @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}} // expected-warning {{method definition for 'ppp' not found}}
- (void) Pmeth {} - (void) Pmeth {}
@end @end

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s // 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 @end
@protocol P @protocol P
@ -18,7 +18,7 @@
- (void)categoryMethod; - (void)categoryMethod;
@end @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}} // expected-warning {{method definition for 'meth2' not found}}
- (void)Pmeth {} - (void)Pmeth {}
@end @end

View File

@ -18,10 +18,10 @@ __attribute__((objc_protocol_requires_explicit_implementation))
// This class subclasses ClassA (which adopts 'Protocol'), // This class subclasses ClassA (which adopts 'Protocol'),
// but does not provide the needed implementation. // 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 @end
@implementation ClassB // expected-warning {{method 'theBestOfTimes' in protocol not implemented}} @implementation ClassB // expected-warning {{method 'theBestOfTimes' in protocol 'Protocol' not implemented}}
@end @end
// Test that inherited protocols do not get the explicit conformance requirement. // Test that inherited protocols do not get the explicit conformance requirement.
@ -37,10 +37,10 @@ __attribute__((objc_protocol_requires_explicit_implementation))
@interface ClassC <Inherited> @interface ClassC <Inherited>
@end @end
@interface ClassD : ClassC <Derived> // expected-note {{required for direct or indirect protocol 'Derived'}} @interface ClassD : ClassC <Derived>
@end @end
@implementation ClassD // expected-warning {{method 'foulIsFair' in protocol not implemented}} @implementation ClassD // expected-warning {{method 'foulIsFair' in protocol 'Derived' not implemented}}
@end @end
// Test that the attribute is used correctly. // Test that the attribute is used correctly.

View File

@ -22,13 +22,10 @@
+ (void) cls_meth : (int) arg1; // expected-note {{method 'cls_meth:' declared here}} + (void) cls_meth : (int) arg1; // expected-note {{method 'cls_meth:' declared here}}
@end @end
@interface INTF <PROTO> // expected-note 3 {{required for direct or indirect protocol 'PROTO'}} \ @interface INTF <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'}}
@end @end
@implementation INTF // expected-warning 9 {{in protocol not implemented}} @implementation INTF // expected-warning 9 {{in protocol '}}
- (void) DefP1proto{} - (void) DefP1proto{}
+ (void) DefClsP3Proto{} + (void) DefClsP3Proto{}
@end @end