diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2013-11-14 00:43:05 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-11-14 00:43:05 +0000 |
| commit | ae02d1552f1707f6854332fe28e2f2eb65e75c26 (patch) | |
| tree | b8ab59ebc3d9340ae75c49b3caff753cd5824e67 | |
| parent | 7981f5b86c7738939b1912a067dc2a35520096dc (diff) | |
| download | bcm5719-llvm-ae02d1552f1707f6854332fe28e2f2eb65e75c26.tar.gz bcm5719-llvm-ae02d1552f1707f6854332fe28e2f2eb65e75c26.zip | |
ObjectiveC ARC. objc_bridge attribute should be applied to
toll-free bridging cf types only. // rdar//15454846 wip.
llvm-svn: 194640
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 7 | ||||
| -rw-r--r-- | clang/test/SemaObjC/objcbridge-attribute.m | 18 |
2 files changed, 12 insertions, 13 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 46a85c59b52..30ddd4d51d6 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -207,10 +207,9 @@ static inline bool isCFStringType(QualType T, ASTContext &Ctx) { 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, Scope *Sc, Decl *D, 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; } diff --git a/clang/test/SemaObjC/objcbridge-attribute.m b/clang/test/SemaObjC/objcbridge-attribute.m index 797f00be546..33c0e3f27af 100644 --- a/clang/test/SemaObjC/objcbridge-attribute.m +++ b/clang/test/SemaObjC/objcbridge-attribute.m @@ -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 { |

