summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-10-29 23:20:05 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-10-29 23:20:05 +0000
commite5c1bda4d177f2420d2e9b7fd725dd7e199a5bd0 (patch)
treebb2619efc746c538e3f679d8a2d86b48e3dd914e /clang
parent58018e62a817923dc063fd1b908eb0c10269da64 (diff)
downloadbcm5719-llvm-e5c1bda4d177f2420d2e9b7fd725dd7e199a5bd0.tar.gz
bcm5719-llvm-e5c1bda4d177f2420d2e9b7fd725dd7e199a5bd0.zip
Improve diagnostics reporting of un-implemented
methods in protocols when protocols are in system headers and thus ignored. //rdar: //8227199 llvm-svn: 117739
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td1
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp8
-rw-r--r--clang/test/SemaObjC/category-1.m5
-rw-r--r--clang/test/SemaObjC/compare-qualified-id.m5
-rw-r--r--clang/test/SemaObjC/method-arg-decay.m5
-rw-r--r--clang/test/SemaObjC/method-undef-category-warn-1.m12
-rw-r--r--clang/test/SemaObjC/method-undef-extension-warn-1.m5
-rw-r--r--clang/test/SemaObjC/undef-protocol-methods-1.m21
8 files changed, 37 insertions, 25 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 17a6fe7e4f5..88e3126f28a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -348,6 +348,7 @@ def warn_strict_multiple_method_decl : Warning<
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">;
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index bd16fa39947..57c19222924 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -745,8 +745,10 @@ void Sema::WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method,
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 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc,
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 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc,
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();
}
diff --git a/clang/test/SemaObjC/category-1.m b/clang/test/SemaObjC/category-1.m
index 18cbb83fef3..82a7b030334 100644
--- a/clang/test/SemaObjC/category-1.m
+++ b/clang/test/SemaObjC/category-1.m
@@ -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
-@implementation MultipleCat_I // expected-warning {{incomplete implementation}}
+@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
diff --git a/clang/test/SemaObjC/compare-qualified-id.m b/clang/test/SemaObjC/compare-qualified-id.m
index 08fb3668830..ce0db191ea9 100644
--- a/clang/test/SemaObjC/compare-qualified-id.m
+++ b/clang/test/SemaObjC/compare-qualified-id.m
@@ -5,7 +5,7 @@ typedef unsigned int NSUInteger;
typedef struct _NSZone NSZone;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
@protocol NSObject - (BOOL)isEqual:(id)object; @end
-@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+@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 @@ extern NSString * const NSTaskDidTerminateNotification;
- (NSString *)evaluateAsStringInContext:(XCPropertyExpansionContext *)context withNestingState:(const void *)state;
@end
-@implementation XCPropertyExpansionContext // expected-warning {{incomplete implementation}}
+@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)) { }
diff --git a/clang/test/SemaObjC/method-arg-decay.m b/clang/test/SemaObjC/method-arg-decay.m
index 012a3eeba0d..6e11e97898d 100644
--- a/clang/test/SemaObjC/method-arg-decay.m
+++ b/clang/test/SemaObjC/method-arg-decay.m
@@ -56,7 +56,7 @@ PBXFindMatchContains, PBXFindMatchStartsWith, PBXFindMatchWholeWords,
@interface PBXProjectModule : PBXModule <PBXFindableText> {
}
@end @class PBXBookmark;
-@protocol PBXSelectionTarget - (NSObject <PBXSelectionTarget> *) performAction:(id)action withSelection:(NSArray *)selection; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+@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 @@ extern NSMutableArray *XCFindPossibleKeyModules(PBXModule *module, BOOL useExpos
}
- (PBXModule *) moduleForTab:(NSTabViewItem *)item; // expected-note {{method definition for 'moduleForTab:' not found}}
@end
-@implementation XCPerspectiveModule // expected-warning {{incomplete implementation}}
+@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 {
diff --git a/clang/test/SemaObjC/method-undef-category-warn-1.m b/clang/test/SemaObjC/method-undef-category-warn-1.m
index b367801242e..532ecfca9e0 100644
--- a/clang/test/SemaObjC/method-undef-category-warn-1.m
+++ b/clang/test/SemaObjC/method-undef-category-warn-1.m
@@ -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
-@implementation MyClass1(CAT) // expected-warning {{incomplete implementation}}
+@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
-@implementation MyClass1(DOG) // expected-warning {{incomplete implementation}}
+@implementation MyClass1(DOG) // expected-warning {{incomplete implementation}} \
+ // expected-warning {{method in protocol not implemented [-Wprotocol]}}
- (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 1addcf7df71..ade861e52ee 100644
--- a/clang/test/SemaObjC/method-undef-extension-warn-1.m
+++ b/clang/test/SemaObjC/method-undef-extension-warn-1.m
@@ -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
-@implementation MyClass // expected-warning {{incomplete implementation}}
+@implementation MyClass // expected-warning {{incomplete implementation}} \
+ // expected-warning {{method in protocol not implemented [-Wprotocol]}}
- (void)Pmeth {}
@end
diff --git a/clang/test/SemaObjC/undef-protocol-methods-1.m b/clang/test/SemaObjC/undef-protocol-methods-1.m
index cbef3e5f4b5..44d384c6394 100644
--- a/clang/test/SemaObjC/undef-protocol-methods-1.m
+++ b/clang/test/SemaObjC/undef-protocol-methods-1.m
@@ -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
-@implementation INTF // expected-warning {{incomplete implementation}}
+@implementation INTF // expected-warning {{incomplete implementation}} \
+ // expected-warning 9 {{method in protocol not implemented [-Wprotocol}}
- (void) DefP1proto{}
+ (void) DefClsP3Proto{}
OpenPOWER on IntegriCloud