Author: mren Date: Fri May 20 12:29:43 2016 New Revision: 270241 URL: http://llvm.org/viewvc/llvm-project?rev=270241&view=rev Log: ObjectiveC: canonicalize "kindof id" to "id".
There is no need to apply kindof on an unqualified id type. rdar://24753825 Modified: cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/SemaObjC/kindof.m Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=270241&r1=270240&r2=270241&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Fri May 20 12:29:43 2016 @@ -5900,10 +5900,11 @@ bool Sema::checkObjCKindOfType(QualType // Rebuild the "equivalent" type, which pushes __kindof down into // the object type. - QualType equivType = Context.getObjCObjectType(objType->getBaseType(), - objType->getTypeArgsAsWritten(), - objType->getProtocols(), - /*isKindOf=*/true); + // There is no need to apply kindof on an unqualified id type. + QualType equivType = Context.getObjCObjectType( + objType->getBaseType(), objType->getTypeArgsAsWritten(), + objType->getProtocols(), + /*isKindOf=*/objType->isObjCUnqualifiedId() ? false : true); // If we started with an object pointer type, rebuild it. if (ptrType) { Modified: cfe/trunk/test/SemaObjC/kindof.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/kindof.m?rev=270241&r1=270240&r2=270241&view=diff ============================================================================== --- cfe/trunk/test/SemaObjC/kindof.m (original) +++ cfe/trunk/test/SemaObjC/kindof.m Fri May 20 12:29:43 2016 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only %s -verify +// RUN: %clang_cc1 -fblocks -fsyntax-only %s -verify -Wmethod-signatures // Tests Objective-C 'kindof' types. @@ -374,6 +374,27 @@ void testNullability() { processCopyable(0); // expected-warning{{null passed to a callee that requires a non-null argument}} } +// Make sure that we don't emit a warning about conflicting parameter types +// between __kindof id and id. +@interface A2 : NSObject +- (void)test:(__kindof id)T; +@end +@implementation A2 +- (void)test:(id)T { +} +@end + +@interface NSGeneric<ObjectType> : NSObject +- (void)test:(__kindof ObjectType)T; +- (void)mapUsingBlock:(id (^)(__kindof ObjectType))block; +@end +@implementation NSGeneric +- (void)test:(id)T { +} +- (void)mapUsingBlock:(id (^)(id))block { +} +@end + // Check that clang doesn't crash when a type parameter is illegal. @interface Array1<T> : NSObject @end _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits