r195396 - ObjectiveC migrator. Improve on definition, use

Fariborz Jahanian fjahanian at apple.com
Thu Nov 21 16:02:22 PST 2013


Author: fjahanian
Date: Thu Nov 21 18:02:22 2013
New Revision: 195396

URL: http://llvm.org/viewvc/llvm-project?rev=195396&view=rev
Log:
ObjectiveC migrator. Improve on definition, use
and testing of objc_bridgmutable attribute per
Aaron Ballman's comments.
// rdar://15498044

Modified:
    cfe/trunk/include/clang/Basic/Attr.td
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/test/SemaObjC/objcbridge-attribute-arc.m
    cfe/trunk/test/SemaObjC/objcbridge-attribute.m
    cfe/trunk/test/SemaObjC/objcbridgemutable-attribute.m
    cfe/trunk/test/SemaObjCXX/objcbridge-attribute-arc.mm
    cfe/trunk/test/SemaObjCXX/objcbridge-attribute.mm

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=195396&r1=195395&r2=195396&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Nov 21 18:02:22 2013
@@ -548,13 +548,13 @@ def NSBridged : InheritableAttr {
 def ObjCBridge : InheritableAttr {
   let Spellings = [GNU<"objc_bridge">];
   let Subjects = [Record];
-  let Args = [IdentifierArgument<"BridgedType", 1>];
+  let Args = [IdentifierArgument<"BridgedType">];
 }
 
 def ObjCBridgeMutable : InheritableAttr {
   let Spellings = [GNU<"objc_bridge_mutable">];
   let Subjects = [Record];
-  let Args = [IdentifierArgument<"BridgedType", 1>];
+  let Args = [IdentifierArgument<"BridgedType">];
 }
 
 def NSReturnsRetained : InheritableAttr {

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=195396&r1=195395&r2=195396&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Nov 21 18:02:22 2013
@@ -4348,9 +4348,7 @@ static void handleObjCBridgeAttr(Sema &S
     return;
   }
 
-  IdentifierLoc *Parm = 0;
-  if (Attr.getNumArgs() == 1)
-    Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : 0;
+  IdentifierLoc * Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : 0;
 
   if (!Parm) {
     S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0;
@@ -4372,9 +4370,7 @@ static void handleObjCBridgeMutableAttr(
     return;
   }
   
-  IdentifierLoc *Parm = 0;
-  if (Attr.getNumArgs() == 1)
-    Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : 0;
+  IdentifierLoc * Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : 0;
   
   if (!Parm) {
     S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0;

Modified: cfe/trunk/test/SemaObjC/objcbridge-attribute-arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objcbridge-attribute-arc.m?rev=195396&r1=195395&r2=195396&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/objcbridge-attribute-arc.m (original)
+++ cfe/trunk/test/SemaObjC/objcbridge-attribute-arc.m Thu Nov 21 18:02:22 2013
@@ -7,7 +7,7 @@ typedef struct __attribute__ ((objc_brid
 
 typedef struct __attribute__((objc_bridge(12))) __CFMyColor  *CFMyColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
 
-typedef struct __attribute__ ((objc_bridge)) __CFArray *CFArrayRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
+typedef struct __attribute__ ((objc_bridge)) __CFArray *CFArrayRef; // expected-error {{'objc_bridge' attribute takes one argument}}
 
 typedef void *  __attribute__ ((objc_bridge(NSURL))) CFURLRef;  // expected-error {{'objc_bridge' attribute only applies to struct or union}}
 

Modified: cfe/trunk/test/SemaObjC/objcbridge-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objcbridge-attribute.m?rev=195396&r1=195395&r2=195396&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/objcbridge-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/objcbridge-attribute.m Thu Nov 21 18:02:22 2013
@@ -7,7 +7,7 @@ typedef struct __attribute__ ((objc_brid
 
 typedef struct __attribute__((objc_bridge(12))) __CFMyColor  *CFMyColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
 
-typedef struct __attribute__ ((objc_bridge)) __CFArray *CFArrayRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
+typedef struct __attribute__ ((objc_bridge)) __CFArray *CFArrayRef; // expected-error {{'objc_bridge' attribute takes one argument}}
 
 typedef void *  __attribute__ ((objc_bridge(NSURL))) CFURLRef;  // expected-error {{'objc_bridge' attribute only applies to struct or union}}
 

Modified: cfe/trunk/test/SemaObjC/objcbridgemutable-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objcbridgemutable-attribute.m?rev=195396&r1=195395&r2=195396&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/objcbridgemutable-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/objcbridgemutable-attribute.m Thu Nov 21 18:02:22 2013
@@ -3,17 +3,29 @@
 
 typedef struct __attribute__((objc_bridge_mutable(NSMutableDictionary))) __CFDictionary * CFMutableDictionaryRef; // expected-note {{declared here}}
 
+typedef struct __attribute__((objc_bridge_mutable(12))) __CFDictionaryB1 * CFMutableDictionaryB1Ref; // expected-error {{parameter of 'objc_bridge_mutable' attribute must be a single name of an Objective-C class}}
+
+typedef struct __attribute__((objc_bridge_mutable(P))) __CFDictionaryB2 * CFMutableDictionaryB2Ref; // expected-note {{declared here}}
+
+typedef struct __attribute__((objc_bridge_mutable(NSMutableDictionary, Unknown))) __CFDictionaryB3 * CFMutableDictionaryB3Ref;  // expected-error {{use of undeclared identifier 'Unknown'}}
+
+typedef struct __attribute__((objc_bridge_mutable)) __CFDictionaryB4 * CFMutableDictionaryB4Ref;  // expected-error {{'objc_bridge_mutable' attribute takes one argument}}
+
 @interface NSDictionary
 @end
 
 @interface NSMutableDictionary : NSDictionary
 @end
 
-void Test(NSMutableDictionary *md, NSDictionary *nd, CFMutableDictionaryRef mcf) {
+ at protocol P @end
+
+void Test(NSMutableDictionary *md, NSDictionary *nd, CFMutableDictionaryRef mcf, CFMutableDictionaryB2Ref bmcf) {
 
   (void) (CFMutableDictionaryRef)md;
   (void) (CFMutableDictionaryRef)nd; // expected-warning {{'NSDictionary' cannot bridge to 'CFMutableDictionaryRef' (aka 'struct __CFDictionary *')}}
   (void) (NSDictionary *)mcf;  // expected-warning {{'CFMutableDictionaryRef' (aka 'struct __CFDictionary *') bridges to NSMutableDictionary, not 'NSDictionary'}}
   (void) (NSMutableDictionary *)mcf; // ok;
+  (void) (NSMutableDictionary *)bmcf; // expected-error {{CF object of type 'CFMutableDictionaryB2Ref' (aka 'struct __CFDictionaryB2 *') is bridged to 'P', which is not an Objective-C class}}
+  
 }
 

Modified: cfe/trunk/test/SemaObjCXX/objcbridge-attribute-arc.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/objcbridge-attribute-arc.mm?rev=195396&r1=195395&r2=195396&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/objcbridge-attribute-arc.mm (original)
+++ cfe/trunk/test/SemaObjCXX/objcbridge-attribute-arc.mm Thu Nov 21 18:02:22 2013
@@ -7,7 +7,7 @@ typedef struct __attribute__ ((objc_brid
 
 typedef struct __attribute__((objc_bridge(12))) __CFMyColor  *CFMyColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
 
-typedef struct __attribute__ ((objc_bridge)) __CFArray *CFArrayRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
+typedef struct __attribute__ ((objc_bridge)) __CFArray *CFArrayRef; // expected-error {{'objc_bridge' attribute takes one argument}}
 
 typedef void *  __attribute__ ((objc_bridge(NSURL))) CFURLRef;  // expected-error {{'objc_bridge' attribute only applies to struct, union or class}}
 

Modified: cfe/trunk/test/SemaObjCXX/objcbridge-attribute.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/objcbridge-attribute.mm?rev=195396&r1=195395&r2=195396&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/objcbridge-attribute.mm (original)
+++ cfe/trunk/test/SemaObjCXX/objcbridge-attribute.mm Thu Nov 21 18:02:22 2013
@@ -7,7 +7,7 @@ typedef struct __attribute__ ((objc_brid
 
 typedef struct __attribute__((objc_bridge(12))) __CFMyColor  *CFMyColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
 
-typedef struct __attribute__ ((objc_bridge)) __CFArray *CFArrayRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
+typedef struct __attribute__ ((objc_bridge)) __CFArray *CFArrayRef; // expected-error {{'objc_bridge' attribute takes one argument}}
 
 typedef void *  __attribute__ ((objc_bridge(NSURL))) CFURLRef;  // expected-error {{'objc_bridge' attribute only applies to struct, union or class}}
 





More information about the cfe-commits mailing list