r194881 - ObjectiveC ARC. Only briding of pointer to struct CF object is allowed.
Fariborz Jahanian
fjahanian at apple.com
Fri Nov 15 15:14:45 PST 2013
Author: fjahanian
Date: Fri Nov 15 17:14:45 2013
New Revision: 194881
URL: http://llvm.org/viewvc/llvm-project?rev=194881&view=rev
Log:
ObjectiveC ARC. Only briding of pointer to struct CF object is allowed.
Improve on wording on illegal objc_bridge argumment.
// rdar://15454846
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/SemaObjC/objcbridge-attribute.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=194881&r1=194880&r2=194881&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Nov 15 17:14:45 2013
@@ -2445,11 +2445,10 @@ def err_objc_bridge_attribute : Error<
"'objc_bridge' attribute must be put on a typedef only">;
def err_objc_bridge_not_cftype : Error<
"'objc_bridge' attribute must be applied to definition of CF types">;
-def err_objc_bridge_not_pointertype : Error<
- "'objc_bridge' attribute must be applied to a pointer type">;
+def err_objc_bridge_not_pointert_to_struct : Error<
+ "'objc_bridge' attribute must be applied to a pointer to struct type">;
def err_objc_bridged_not_interface : Error<
- "CF object of type %0 with 'objc_bridge' attribute which has parameter that"
- " does not name an Objective-C class">;
+ "CF object of type %0 is bridged to '%1', which is not an Objective-C class">;
// Function Parameter Semantic Analysis.
def err_param_with_void_type : Error<"argument may not have 'void' type">;
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=194881&r1=194880&r2=194881&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Nov 15 17:14:45 2013
@@ -4403,13 +4403,18 @@ static void handleObjCBridgeAttr(Sema &S
if (T->isRecordType()) {
RecordDecl *RD = T->getAs<RecordType>()->getDecl();
if (!RD || RD->isUnion()) {
- S.Diag(D->getLocStart(), diag::err_attribute_wrong_decl_type)
- << Attr.getRange() << Attr.getName() << ExpectedStruct;
+ S.Diag(D->getLocStart(), diag::err_objc_bridge_not_pointert_to_struct)
+ << Attr.getRange();
return;
}
+ } else {
+ S.Diag(TD->getLocStart(), diag::err_objc_bridge_not_pointert_to_struct)
+ << Attr.getRange();
+ return;
}
} else {
- S.Diag(TD->getLocStart(), diag::err_objc_bridge_not_pointertype);
+ S.Diag(TD->getLocStart(), diag::err_objc_bridge_not_pointert_to_struct)
+ << Attr.getRange();
return;
}
// Check for T being a CFType goes here.
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=194881&r1=194880&r2=194881&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Fri Nov 15 17:14:45 2013
@@ -3180,13 +3180,13 @@ static bool CheckObjCBridgeCast(Sema &S,
NamedDecl *Target = R.getFoundDecl();
if (Target && !isa<ObjCInterfaceDecl>(Target)) {
S.Diag(castExpr->getLocStart(), diag::err_objc_bridged_not_interface)
- << castExpr->getType();
+ << castExpr->getType() << Parm->getName();
S.Diag(TDNDecl->getLocStart(), diag::note_declared_at);
S.Diag(Target->getLocStart(), diag::note_declared_at);
}
} else {
S.Diag(castExpr->getLocStart(), diag::err_objc_bridged_not_interface)
- << castExpr->getType();
+ << castExpr->getType() << Parm->getName();
S.Diag(TDNDecl->getLocStart(), diag::note_declared_at);
}
}
Modified: cfe/trunk/test/SemaObjC/objcbridge-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objcbridge-attribute.m?rev=194881&r1=194880&r2=194881&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/objcbridge-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/objcbridge-attribute.m Fri Nov 15 17:14:45 2013
@@ -7,19 +7,19 @@ typedef struct __CFMyColor * __attribut
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(NSURL))) CFURLRef;
+typedef void * __attribute__ ((objc_bridge(NSURL))) CFURLRef; // expected-error {{'objc_bridge' attribute must be applied to a pointer to struct type}}
-typedef void * CFStringRef __attribute__ ((objc_bridge(NSString)));
+typedef void * CFStringRef __attribute__ ((objc_bridge(NSString))); // expected-error {{'objc_bridge' attribute must be applied to a pointer to struct type}}
typedef struct __CFLocale * __attribute__((objc_bridge(NSLocale, NSError))) CFLocaleRef;// expected-error {{use of undeclared identifier 'NSError'}}
-typedef struct __CFData __attribute__((objc_bridge(NSData))) CFDataRef; // expected-error {{'objc_bridge' attribute must be applied to a pointer type}}
+typedef struct __CFData __attribute__((objc_bridge(NSData))) CFDataRef; // expected-error {{'objc_bridge' attribute must be applied to a pointer to struct type}}
typedef struct __attribute__((objc_bridge(NSDictionary))) __CFDictionary * CFDictionaryRef; // expected-error {{'objc_bridge' attribute must be put on a typedef only}}
typedef struct __CFSetRef * CFSetRef __attribute__((objc_bridge(NSSet)));
-typedef union __CFUColor * __attribute__((objc_bridge(NSUColor))) CFUColorRef; // expected-error {{'objc_bridge' attribute only applies to structs}}
+typedef union __CFUColor * __attribute__((objc_bridge(NSUColor))) CFUColorRef; // expected-error {{'objc_bridge' attribute must be applied to a pointer to struct type}}
@interface I
{
@@ -34,7 +34,7 @@ typedef union __CFUColor * __attribute__
typedef struct __CFError * __attribute__((objc_bridge(NSTesting))) CFTestingRef; // expected-note {{declared here}}
id Test1(CFTestingRef cf) {
- return (NSString *)cf; // expected-error {{CF object of type 'CFTestingRef' (aka 'struct __CFError *') with 'objc_bridge' attribute which has parameter that does not name an Objective-C class}}
+ return (NSString *)cf; // expected-error {{CF object of type 'CFTestingRef' (aka 'struct __CFError *') is bridged to 'NSTesting', which is not an Objective-C class}}
}
typedef CFErrorRef CFErrorRef1;
More information about the cfe-commits
mailing list