[cfe-commits] r162872 - in /cfe/trunk: lib/Sema/SemaDeclAttr.cpp test/SemaObjC/nsobject-attribute.m

Ted Kremenek kremenek at apple.com
Wed Aug 29 15:54:47 PDT 2012


Author: kremenek
Date: Wed Aug 29 17:54:47 2012
New Revision: 162872

URL: http://llvm.org/viewvc/llvm-project?rev=162872&view=rev
Log:
Fix serious regression introduced in r157780 where __attribute__((NSObject))
could not be attached to a CFTypeRef.

Fixes <rdar://problem/12197822>

Modified:
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/test/SemaObjC/nsobject-attribute.m

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=162872&r1=162871&r2=162872&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Aug 29 17:54:47 2012
@@ -2268,16 +2268,14 @@
   }
   if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) {
     QualType T = TD->getUnderlyingType();
-    if (!T->isPointerType() ||
-        !T->getAs<PointerType>()->getPointeeType()->isRecordType()) {
+    if (!T->isCARCBridgableType()) {
       S.Diag(TD->getLocation(), diag::err_nsobject_attribute);
       return;
     }
   }
   else if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(D)) {
     QualType T = PD->getType();
-    if (!T->isPointerType() ||
-        !T->getAs<PointerType>()->getPointeeType()->isRecordType()) {
+    if (!T->isCARCBridgableType()) {
       S.Diag(PD->getLocation(), diag::err_nsobject_attribute);
       return;
     }

Modified: cfe/trunk/test/SemaObjC/nsobject-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/nsobject-attribute.m?rev=162872&r1=162871&r2=162872&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/nsobject-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/nsobject-attribute.m Wed Aug 29 17:54:47 2012
@@ -5,8 +5,8 @@
 static CGColorRef tmp = 0;
 
 typedef struct S1  __attribute__ ((NSObject)) CGColorRef1; // expected-error {{__attribute ((NSObject)) is for pointer types only}}
-typedef void *  __attribute__ ((NSObject)) CGColorRef2; // expected-error {{__attribute ((NSObject)) is for pointer types only}}
-
+typedef void *  __attribute__ ((NSObject)) CGColorRef2; // no-warning
+typedef void * CFTypeRef;
 
 @interface HandTested {
 @public
@@ -14,9 +14,11 @@
 }
 
 @property(copy) CGColorRef x;
-// rdar: // 7809460
-typedef struct CGColor * __attribute__((NSObject)) CGColorRefNoNSObject;
+// rdar://problem/7809460
+typedef struct CGColor * __attribute__((NSObject)) CGColorRefNoNSObject; // no-warning
 @property (nonatomic, retain) CGColorRefNoNSObject color;
+// rdar://problem/12197822
+ at property (strong) __attribute__((NSObject)) CFTypeRef myObj; // no-warning
 @end
 
 void setProperty(id self, id value)  {





More information about the cfe-commits mailing list