Author: fjahanian
Date: Tue Apr 12 11:34:14 2011
New Revision: 129363
URL: http://llvm.org/viewvc/llvm-project?rev=129363&view=rev
Log:
Fix a regression where the initializer implements
the initialized's protocol and yet clang warns.
objective-c issue, // rdar://9267196
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/SemaObjC/unqualified-to-qualified-class-warn.m
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=129363&r1=129362&r2=129363&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Tue Apr 12 11:34:14 2011
@@ -629,27 +629,6 @@
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) {
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=129363&r1=129362&r2=129363&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Apr 12 11:34:14 2011
@@ -4987,15 +4987,15 @@
// 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;
Modified: cfe/trunk/test/SemaObjC/unqualified-to-qualified-class-warn.m
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unqualified-to-qualified-class-warn.m?rev=129363&r1=129362&r2=129363&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/unqualified-to-qualified-class-warn.m (original)
+++ cfe/trunk/test/SemaObjC/unqualified-to-qualified-class-warn.m Tue Apr 12
11:34:14 2011
@@ -29,3 +29,44 @@
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
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits