summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2014-11-07 23:51:15 +0000
committerFariborz Jahanian <fjahanian@apple.com>2014-11-07 23:51:15 +0000
commit05e77f83496710ab950c3f833dbfc847a80d071c (patch)
tree3edd3cce7ab41b7ede5e30772151a5b6bb8997c9
parent02862bc83acd8d10a0a8b6cea4b63a25f46ad68a (diff)
downloadbcm5719-llvm-05e77f83496710ab950c3f833dbfc847a80d071c.tar.gz
bcm5719-llvm-05e77f83496710ab950c3f833dbfc847a80d071c.zip
[Objective-C Sema]. Issue availability/deprecated warning when
there is a uinque method found when message is sent to receiver of 'id' type. // rdar://18848183 llvm-svn: 221562
-rw-r--r--clang/lib/Sema/SemaExprObjC.cpp6
-rw-r--r--clang/test/ARCMT/checking.m11
-rw-r--r--clang/test/SemaObjC/attr-deprecated.m14
3 files changed, 25 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index ae9942b1c3e..0730cf6e7bf 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -2448,10 +2448,14 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
Method = LookupFactoryMethodInGlobalPool(Sel,
SourceRange(LBracLoc,RBracLoc),
receiverIsId);
- if (Method)
+ if (Method) {
if (ObjCMethodDecl *BestMethod =
SelectBestMethod(Sel, ArgsIn, Method->isInstanceMethod()))
Method = BestMethod;
+ SmallVector<ObjCMethodDecl*, 4> Methods;
+ if (!CollectMultipleMethodsInGlobalPool(Sel, Methods, Method->isInstanceMethod()))
+ DiagnoseUseOfDecl(Method, SelLoc);
+ }
} else if (ReceiverType->isObjCClassType() ||
ReceiverType->isObjCQualifiedClassType()) {
// Handle messages to Class.
diff --git a/clang/test/ARCMT/checking.m b/clang/test/ARCMT/checking.m
index d8ccf167523..76c44430767 100644
--- a/clang/test/ARCMT/checking.m
+++ b/clang/test/ARCMT/checking.m
@@ -14,9 +14,9 @@ typedef int BOOL;
typedef unsigned NSUInteger;
@protocol NSObject
-- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
+- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note {{'retain' has been explicitly marked unavailable here}}
- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
+- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note 4 {{'release' has been explicitly marked unavailable here}}
- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
@end
@@ -74,16 +74,20 @@ id global_foo;
void test1(A *a, BOOL b, struct UnsafeS *unsafeS) {
[[a delegate] release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \
+ // expected-error {{'release' is unavailable: not available in automatic reference counting mode}} \
// expected-error {{ARC forbids explicit message send}}
[a.delegate release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \
+ // expected-error {{'release' is unavailable: not available in automatic reference counting mode}} \
// expected-error {{ARC forbids explicit message send}}
[unsafeS->unsafeObj retain]; // expected-error {{it is not safe to remove 'retain' message on an __unsafe_unretained type}} \
// expected-error {{ARC forbids explicit message send}} \
// expected-error {{'retain' is unavailable}}
id foo = [unsafeS->unsafeObj retain]; // no warning.
[global_foo retain]; // expected-error {{it is not safe to remove 'retain' message on a global variable}} \
+ // expected-error {{'retain' is unavailable: not available in automatic reference counting mode}} \
// expected-error {{ARC forbids explicit message send}}
[global_foo release]; // expected-error {{it is not safe to remove 'release' message on a global variable}} \
+ // expected-error {{'release' is unavailable: not available in automatic reference counting mode}} \
// expected-error {{ARC forbids explicit message send}}
[a dealloc];
[a retain];
@@ -304,7 +308,8 @@ void rdar9491791(int p) {
// rdar://9504750
void rdar9504750(id p) {
- RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}}
+ RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}} \
+ // expected-error {{'release' is unavailable: not available in automatic reference counting mode}}
}
// rdar://8939557
diff --git a/clang/test/SemaObjC/attr-deprecated.m b/clang/test/SemaObjC/attr-deprecated.m
index 4eb56ee7d74..20d8c1066eb 100644
--- a/clang/test/SemaObjC/attr-deprecated.m
+++ b/clang/test/SemaObjC/attr-deprecated.m
@@ -5,7 +5,7 @@
int X __attribute__((deprecated)); // expected-note 2 {{'X' has been explicitly marked deprecated here}}
}
+ (void)F __attribute__((deprecated)); // expected-note 2 {{'F' has been explicitly marked deprecated here}}
-- (void)f __attribute__((deprecated)); // expected-note 4 {{'f' has been explicitly marked deprecated here}}
+- (void)f __attribute__((deprecated)); // expected-note 5 {{'f' has been explicitly marked deprecated here}}
@end
@implementation A
@@ -54,7 +54,7 @@ void t1(A *a)
void t2(id a)
{
- [a f];
+ [a f]; // expected-warning {{'f' is deprecated}}
}
void t3(A<P>* a)
@@ -228,3 +228,13 @@ expected-note {{property declared here}}
@end
+// rdar://18848183
+@interface NSString
+- (const char *)cString __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.4,message="" ))); // expected-note {{'cString' has been explicitly marked deprecated here}}
+@end
+
+id PID = 0;
+const char * func() {
+ return [PID cString]; // expected-warning {{'cString' is deprecated: first deprecated in OS X 10.4}}
+}
+
OpenPOWER on IntegriCloud