r194640 - ObjectiveC ARC. objc_bridge attribute should be applied to

Fariborz Jahanian fjahanian at apple.com
Wed Nov 13 16:43:05 PST 2013


Author: fjahanian
Date: Wed Nov 13 18:43:05 2013
New Revision: 194640

URL: http://llvm.org/viewvc/llvm-project?rev=194640&view=rev
Log:
ObjectiveC ARC. objc_bridge attribute should be applied to
toll-free bridging cf types only. // rdar//15454846 wip.

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

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=194640&r1=194639&r2=194640&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Nov 13 18:43:05 2013
@@ -207,10 +207,9 @@ static inline bool isCFStringType(QualTy
   return RD->getIdentifier() == &Ctx.Idents.get("__CFString");
 }
 
-static inline bool isCFRefType(TypedefNameDecl *TD, ASTContext &Ctx) {
+static inline bool isTollFreeBridgeCFRefType(TypedefNameDecl *TD, ASTContext &Ctx) {
   StringRef TDName = TD->getIdentifier()->getName();
-  return ((TDName.startswith("CF") || TDName.startswith("CG")) &&
-          (TDName.rfind("Ref") != StringRef::npos));
+  return (TDName.startswith("CF") && TDName.endswith("Ref"));
 }
 
 static unsigned getNumAttributeArgs(const AttributeList &Attr) {
@@ -4414,7 +4413,7 @@ static void handleObjCBridgeAttr(Sema &S
       return;
     }
     // Check for T being a CFType goes here.
-    if (!isCFRefType(TD, S.Context)) {
+    if (!isTollFreeBridgeCFRefType(TD, S.Context)) {
       S.Diag(TD->getLocStart(), diag::err_objc_bridge_not_cftype);
       return;
     }

Modified: cfe/trunk/test/SemaObjC/objcbridge-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objcbridge-attribute.m?rev=194640&r1=194639&r2=194640&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/objcbridge-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/objcbridge-attribute.m Wed Nov 13 18:43:05 2013
@@ -1,25 +1,25 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 // rdar://15454846
 
-typedef struct CGColor * __attribute__ ((objc_bridge(NSError))) CGColorRef;
+typedef struct __CFColor * __attribute__ ((objc_bridge(NSError))) CFColorRef;
 
-typedef struct CGColor * __attribute__((objc_bridge(12))) CFMyColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
+typedef struct __CFMyColor  * __attribute__((objc_bridge(12))) CFMyColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
 
-typedef struct S1 *  __attribute__ ((objc_bridge)) CGColorRef1; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
+typedef struct __CFArray *  __attribute__ ((objc_bridge)) CFArrayRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
 
-typedef void *  __attribute__ ((objc_bridge(NSString))) CGColorRef2; 
+typedef void *  __attribute__ ((objc_bridge(NSString))) CFRef; 
 
 typedef void * CFTypeRef __attribute__ ((objc_bridge(NSError)));
 
-typedef struct CGColor * __attribute__((objc_bridge(NSString, NSError))) CGColorRefNoNSObject;// expected-error {{use of undeclared identifier 'NSError'}}
+typedef struct __CFLocale * __attribute__((objc_bridge(NSString, NSError))) CFLocaleRef;// expected-error {{use of undeclared identifier 'NSError'}}
 
-typedef struct CGColor __attribute__((objc_bridge(NSError))) CGColorRefNoNSObject2; // expected-error {{'objc_bridge' attribute must be applied to a pointer type}}
+typedef struct __CFData __attribute__((objc_bridge(NSError))) CFDataRef; // expected-error {{'objc_bridge' attribute must be applied to a pointer type}}
 
-typedef struct __attribute__((objc_bridge(NSError))) CFColor * CFColorRefNoNSObject; // expected-error {{'objc_bridge' attribute must be put on a typedef only}}
+typedef struct __attribute__((objc_bridge(NSError))) __CFDictionary * CFDictionaryRef; // expected-error {{'objc_bridge' attribute must be put on a typedef only}}
 
-typedef struct __attribute__((objc_bridge(NSError))) CFColor * CFColorRefNoNSObject1;
+typedef struct __CFObject * CFObjectRef __attribute__((objc_bridge(NSError)));
 
-typedef union CFUColor * __attribute__((objc_bridge(NSError))) CFColorRefNoNSObject2; // expected-error {{'objc_bridge' attribute only applies to structs}}
+typedef union __CFUColor * __attribute__((objc_bridge(NSError))) CFUColorRef; // expected-error {{'objc_bridge' attribute only applies to structs}}
 
 @interface I
 {





More information about the cfe-commits mailing list