]> granicus.if.org Git - clang/commitdiff
ObjectiveC migrator. Improve on definition, use
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 22 Nov 2013 00:02:22 +0000 (00:02 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 22 Nov 2013 00:02:22 +0000 (00:02 +0000)
and testing of objc_bridgmutable attribute per
Aaron Ballman's comments.
// rdar://15498044

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195396 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 416da743623de9f84152cd547564d2714f685ca8..33115c664e62c1812e95b6999208dbf7fb34ed71 100644 (file)
@@ -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 {
index 8b3d738c60b95285a57a1f085bc71364b3577db2..1f6e40164ca5bacff066b0ff3c85633c0e47c547 100644 (file)
@@ -4348,9 +4348,7 @@ static void handleObjCBridgeAttr(Sema &S, Scope *Sc, Decl *D,
     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(Sema &S, Scope *Sc, Decl *D,
     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;
index 9b67523a50ca07e1e2eed9fd88183b53d83e0eec..b2830ff82d93ba7aa65fdd7839152c03e3f7da47 100644 (file)
@@ -7,7 +7,7 @@ typedef struct __attribute__ ((objc_bridge(MyError))) __CFMyErrorRef * CFMyError
 
 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}}
 
index 8be4b2d5f04d5314413dbe8bcc0b2e82d06ed7ab..36b3d604c75b340988913e25310135bfab6ea1a9 100644 (file)
@@ -7,7 +7,7 @@ typedef struct __attribute__ ((objc_bridge(MyError))) __CFMyErrorRef * CFMyError
 
 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}}
 
index 52989f960caa9c0ec564c842416e630ecf919568..4ec8de0b54887f1b5dc8b65bfca0907bf89e2fbd 100644 (file)
@@ -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) {
+@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}}
+  
 }
 
index fa67dfb72d788719a24e51bfac603cb6887eeb3e..39cba2a8425d839a06a5a79df13f470c605a5f14 100644 (file)
@@ -7,7 +7,7 @@ typedef struct __attribute__ ((objc_bridge(MyError))) __CFMyErrorRef * CFMyError
 
 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}}
 
index 3e23cdbba4a47da499677cbcad30d3ccde81de83..d7a9c65da8ea4843d035d71bb52c5c327c3810f2 100644 (file)
@@ -7,7 +7,7 @@ typedef struct __attribute__ ((objc_bridge(MyError))) __CFMyErrorRef * CFMyError
 
 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}}