summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-11-22 00:02:22 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-11-22 00:02:22 +0000
commit2651ac5445a2da742dc158a5621e6484703677af (patch)
treeac2909c0c7737819e5ea592c8baaf4e45cd13edc
parentde61cecd1ccfd4024ddf527bda37c12806296427 (diff)
downloadbcm5719-llvm-2651ac5445a2da742dc158a5621e6484703677af.tar.gz
bcm5719-llvm-2651ac5445a2da742dc158a5621e6484703677af.zip
ObjectiveC migrator. Improve on definition, use
and testing of objc_bridgmutable attribute per Aaron Ballman's comments. // rdar://15498044 llvm-svn: 195396
-rw-r--r--clang/include/clang/Basic/Attr.td4
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp8
-rw-r--r--clang/test/SemaObjC/objcbridge-attribute-arc.m2
-rw-r--r--clang/test/SemaObjC/objcbridge-attribute.m2
-rw-r--r--clang/test/SemaObjC/objcbridgemutable-attribute.m14
-rw-r--r--clang/test/SemaObjCXX/objcbridge-attribute-arc.mm2
-rw-r--r--clang/test/SemaObjCXX/objcbridge-attribute.mm2
7 files changed, 21 insertions, 13 deletions
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 416da743623..33115c664e6 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -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 {
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 8b3d738c60b..1f6e40164ca 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -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;
diff --git a/clang/test/SemaObjC/objcbridge-attribute-arc.m b/clang/test/SemaObjC/objcbridge-attribute-arc.m
index 9b67523a50c..b2830ff82d9 100644
--- a/clang/test/SemaObjC/objcbridge-attribute-arc.m
+++ b/clang/test/SemaObjC/objcbridge-attribute-arc.m
@@ -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}}
diff --git a/clang/test/SemaObjC/objcbridge-attribute.m b/clang/test/SemaObjC/objcbridge-attribute.m
index 8be4b2d5f04..36b3d604c75 100644
--- a/clang/test/SemaObjC/objcbridge-attribute.m
+++ b/clang/test/SemaObjC/objcbridge-attribute.m
@@ -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}}
diff --git a/clang/test/SemaObjC/objcbridgemutable-attribute.m b/clang/test/SemaObjC/objcbridgemutable-attribute.m
index 52989f960ca..4ec8de0b548 100644
--- a/clang/test/SemaObjC/objcbridgemutable-attribute.m
+++ b/clang/test/SemaObjC/objcbridgemutable-attribute.m
@@ -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}}
+
}
diff --git a/clang/test/SemaObjCXX/objcbridge-attribute-arc.mm b/clang/test/SemaObjCXX/objcbridge-attribute-arc.mm
index fa67dfb72d7..39cba2a8425 100644
--- a/clang/test/SemaObjCXX/objcbridge-attribute-arc.mm
+++ b/clang/test/SemaObjCXX/objcbridge-attribute-arc.mm
@@ -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}}
diff --git a/clang/test/SemaObjCXX/objcbridge-attribute.mm b/clang/test/SemaObjCXX/objcbridge-attribute.mm
index 3e23cdbba4a..d7a9c65da8e 100644
--- a/clang/test/SemaObjCXX/objcbridge-attribute.mm
+++ b/clang/test/SemaObjCXX/objcbridge-attribute.mm
@@ -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}}
OpenPOWER on IntegriCloud