summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-04-12 16:34:14 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-04-12 16:34:14 +0000
commit240400b7460f9a9eab6d5a4faad991ade8633b1e (patch)
tree04c9a9a730afdba465601b0714d945c3f94a88c1
parent1ec0f46169b52b7340f76bb8317fc3c17d803280 (diff)
downloadbcm5719-llvm-240400b7460f9a9eab6d5a4faad991ade8633b1e.tar.gz
bcm5719-llvm-240400b7460f9a9eab6d5a4faad991ade8633b1e.zip
Fix a regression where the initializer implements
the initialized's protocol and yet clang warns. objective-c issue, // rdar://9267196 llvm-svn: 129363
-rw-r--r--clang/include/clang/AST/DeclObjC.h21
-rw-r--r--clang/lib/AST/ASTContext.cpp8
-rw-r--r--clang/test/SemaObjC/unqualified-to-qualified-class-warn.m41
3 files changed, 45 insertions, 25 deletions
diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h
index 241d76c4487..84e7a63b029 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -629,27 +629,6 @@ public:
return false;
}
- /// getImmSubClassOf - Returns Immediate sub-class of the specified interface class
- /// if 'Super' is a superclass of this class. null if no such super class.
- /// So in this example if 'this' is 'BClass' and 'Super' is 'AClass' then 'BClass'
- /// is returned.
- /// \code
- /// @interface BClass : AClass <SubFooable>
- /// @end
- /// \endcode
-
- ObjCInterfaceDecl *getImmSubClassOf(const ObjCInterfaceDecl *Super) {
- ObjCInterfaceDecl *ImmSubClass = this;
- ObjCInterfaceDecl *I = this->getSuperClass();
- while (I != NULL) {
- if (Super == I)
- return ImmSubClass;
- ImmSubClass = I;
- I = I->getSuperClass();
- }
- return NULL;
- }
-
ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName,
ObjCInterfaceDecl *&ClassDeclared);
ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) {
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 420fcd398d2..7317928d971 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -4987,15 +4987,15 @@ bool ASTContext::canAssignObjCInterfaces(const ObjCObjectType *LHS,
// OK, if LHS is a superclass of RHS *and*
// this superclass is assignment compatible with LHS.
// false otherwise.
- ObjCInterfaceDecl *SuperClass =
- RHS->getInterface()->getImmSubClassOf(LHS->getInterface());
- if (SuperClass) {
+ bool IsSuperClass =
+ LHS->getInterface()->isSuperClassOf(RHS->getInterface());
+ if (IsSuperClass) {
// OK if conversion of LHS to SuperClass results in narrowing of types
// ; i.e., SuperClass may implement at least one of the protocols
// in LHS's protocol list. Example, SuperObj<P1> = lhs<P1,P2> is ok.
// But not SuperObj<P1,P2,P3> = lhs<P1,P2>.
llvm::SmallPtrSet<ObjCProtocolDecl *, 8> SuperClassInheritedProtocols;
- CollectInheritedProtocols(SuperClass, SuperClassInheritedProtocols);
+ CollectInheritedProtocols(RHS->getInterface(), SuperClassInheritedProtocols);
// If super class has no protocols, it is not a match.
if (SuperClassInheritedProtocols.empty())
return false;
diff --git a/clang/test/SemaObjC/unqualified-to-qualified-class-warn.m b/clang/test/SemaObjC/unqualified-to-qualified-class-warn.m
index 5bbbfd9fcc2..e6fa13850fb 100644
--- a/clang/test/SemaObjC/unqualified-to-qualified-class-warn.m
+++ b/clang/test/SemaObjC/unqualified-to-qualified-class-warn.m
@@ -29,3 +29,44 @@ int main () {
functionTakingAClassConformingToAProtocol(bobject); // Shouldn't warn - does implement Fooable
return 0;
}
+
+// rdar://9267196
+@interface NSObject @end
+
+@protocol MyProtocol
+@end
+
+@interface MyClass : NSObject
+{
+}
+@end
+
+@implementation MyClass
+@end
+
+@interface MySubclass : MyClass <MyProtocol>
+{
+}
+@end
+
+@interface MyTestClass : NSObject
+{
+@private
+ NSObject <MyProtocol> *someObj;
+}
+
+@property (nonatomic, assign) NSObject <MyProtocol> *someObj;
+
+@end
+
+@implementation MyTestClass
+
+@synthesize someObj;
+
+- (void)someMethod
+{
+ MySubclass *foo;
+ [self setSomeObj:foo]; // no warning here!
+}
+
+@end
OpenPOWER on IntegriCloud