r278742 - Objective-C diagnostics: isObjCNSObjectType should check through AttributedType.
Manman Ren via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 15 14:05:00 PDT 2016
Author: mren
Date: Mon Aug 15 16:05:00 2016
New Revision: 278742
URL: http://llvm.org/viewvc/llvm-project?rev=278742&view=rev
Log:
Objective-C diagnostics: isObjCNSObjectType should check through AttributedType.
For the following example:
typedef __attribute__((NSObject)) CGColorRef ColorAttrRef;
@property (strong, nullable) ColorAttrRef color;
The property type should be ObjC NSObject type and the compiler should not emit
error: property with 'retain (or strong)' attribute must be of object type
rdar://problem/27747154
Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/test/SemaObjC/nsobject-attribute.m
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=278742&r1=278741&r2=278742&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Mon Aug 15 16:05:00 2016
@@ -3686,10 +3686,18 @@ bool Type::isObjCARCImplicitlyUnretained
}
bool Type::isObjCNSObjectType() const {
- if (const TypedefType *typedefType = dyn_cast<TypedefType>(this))
- return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
- return false;
+ const Type *cur = this;
+ while (true) {
+ if (const TypedefType *typedefType = dyn_cast<TypedefType>(cur))
+ return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
+
+ // Single-step desugar until we run out of sugar.
+ QualType next = cur->getLocallyUnqualifiedSingleStepDesugaredType();
+ if (next.getTypePtr() == cur) return false;
+ cur = next.getTypePtr();
+ }
}
+
bool Type::isObjCIndependentClassType() const {
if (const TypedefType *typedefType = dyn_cast<TypedefType>(this))
return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
Modified: cfe/trunk/test/SemaObjC/nsobject-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/nsobject-attribute.m?rev=278742&r1=278741&r2=278742&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/nsobject-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/nsobject-attribute.m Mon Aug 15 16:05:00 2016
@@ -21,6 +21,8 @@ typedef struct CGColor * __attribute__((
@property (nonatomic, retain) CGColorRefNoNSObject color;
// rdar://problem/12197822
@property (strong) __attribute__((NSObject)) CFTypeRef myObj; // no-warning
+//rdar://problem/27747154
+ at property (strong, nullable) CGColorRefNoNSObject color2; // no-warning
@end
void setProperty(id self, id value) {
More information about the cfe-commits
mailing list