forked from OSchip/llvm-project
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
This commit is contained in:
parent
f87decdb67
commit
2ccf19e1ab
|
@ -852,7 +852,7 @@ def warn_unimplemented_selector: Warning<
|
|||
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<
|
||||
|
|
|
@ -1228,7 +1228,8 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
|
|||
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, SourceLocation ImpLoc,
|
|||
// 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(SourceLocation ImpLoc,
|
|||
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(SourceLocation ImpLoc,
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,12 +67,12 @@ extern NSMutableArray *XCFindPossibleKeyModules(PBXModule *module, BOOL useExpos
|
|||
@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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 NSTaskDidTerminateNotification;
|
|||
- (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)) { }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -18,10 +18,10 @@ __attribute__((objc_protocol_requires_explicit_implementation))
|
|||
|
||||
// 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_explicit_implementation))
|
|||
@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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue