[cfe-commits] r133300 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseExpr.cpp test/SemaObjC/Inputs/arc-system-header.h test/SemaObjC/arc-bridged-cast.m test/SemaObjC/arc-system-header.m
John McCall
rjmccall at apple.com
Fri Jun 17 14:56:12 PDT 2011
Author: rjmccall
Date: Fri Jun 17 16:56:12 2011
New Revision: 133300
URL: http://llvm.org/viewvc/llvm-project?rev=133300&view=rev
Log:
Only accept __bridge_retain in system headers, as Doug suggested.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/SemaObjC/Inputs/arc-system-header.h
cfe/trunk/test/SemaObjC/arc-bridged-cast.m
cfe/trunk/test/SemaObjC/arc-system-header.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=133300&r1=133299&r2=133300&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Jun 17 16:56:12 2011
@@ -263,6 +263,11 @@
def err_objc_unknown_at : Error<"expected an Objective-C directive after '@'">;
def err_illegal_super_cast : Error<
"cannot cast 'super' (it isn't an expression)">;
+
+let CategoryName = "Automatic Reference Counting Issue" in {
+def err_arc_bridge_retain : Error<
+ "unknown cast annotation __bridge_retain; did you mean __bridge_retained?">;
+}
def err_objc_illegal_visibility_spec : Error<
"illegal visibility specification">;
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=133300&r1=133299&r2=133300&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri Jun 17 16:56:12 2011
@@ -1781,17 +1781,29 @@
(Tok.is(tok::kw___bridge) ||
Tok.is(tok::kw___bridge_transfer) ||
Tok.is(tok::kw___bridge_retained) ||
- Tok.is(tok::kw___bridge_retain))) { // FIXME: temporary workaround
+ Tok.is(tok::kw___bridge_retain))) {
+ tok::TokenKind tokenKind = Tok.getKind();
+ SourceLocation BridgeKeywordLoc = ConsumeToken();
+
// Parse an Objective-C ARC ownership cast expression.
ObjCBridgeCastKind Kind;
- if (Tok.is(tok::kw___bridge))
+ if (tokenKind == tok::kw___bridge)
Kind = OBC_Bridge;
- else if (Tok.is(tok::kw___bridge_transfer))
+ else if (tokenKind == tok::kw___bridge_transfer)
Kind = OBC_BridgeTransfer;
- else
+ else if (tokenKind == tok::kw___bridge_retained)
+ Kind = OBC_BridgeRetained;
+ else {
+ // As a hopefully temporary workaround, allow __bridge_retain as
+ // a synonym for __bridge_retained, but only in system headers.
+ assert(tokenKind == tok::kw___bridge_retain);
Kind = OBC_BridgeRetained;
+ if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
+ Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
+ << FixItHint::CreateReplacement(BridgeKeywordLoc,
+ "__bridge_retained");
+ }
- SourceLocation BridgeKeywordLoc = ConsumeToken();
TypeResult Ty = ParseTypeName();
SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, OpenLoc);
ExprResult SubExpr = ParseCastExpression(false, false, ParsedType());
Modified: cfe/trunk/test/SemaObjC/Inputs/arc-system-header.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/Inputs/arc-system-header.h?rev=133300&r1=133299&r2=133300&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/Inputs/arc-system-header.h (original)
+++ cfe/trunk/test/SemaObjC/Inputs/arc-system-header.h Fri Jun 17 16:56:12 2011
@@ -40,3 +40,13 @@
@interface Test7
@property id *prop;
@end
+
+
+
+
+
+
+
+static inline void *test8(id ptr) {
+ return (__bridge_retain void*) ptr;
+}
Modified: cfe/trunk/test/SemaObjC/arc-bridged-cast.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-bridged-cast.m?rev=133300&r1=133299&r2=133300&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-bridged-cast.m (original)
+++ cfe/trunk/test/SemaObjC/arc-bridged-cast.m Fri Jun 17 16:56:12 2011
@@ -30,7 +30,7 @@
CFStringRef cf4 = (__bridge CFStringRef)CreateNSString();
// rdar://problem/9629566 - temporary workaround
- CFTypeRef cf5 = (__bridge_retain CFTypeRef)CreateSomething();
+ CFTypeRef cf5 = (__bridge_retain CFTypeRef)CreateSomething(); // expected-error {{unknown cast annotation __bridge_retain; did you mean __bridge_retained?}}
}
void fixits() {
Modified: cfe/trunk/test/SemaObjC/arc-system-header.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-system-header.m?rev=133300&r1=133299&r2=133300&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-system-header.m (original)
+++ cfe/trunk/test/SemaObjC/arc-system-header.m Fri Jun 17 16:56:12 2011
@@ -46,3 +46,5 @@
[p setProp: 0]; // expected-error {{'setProp:' is unavailable: this system declaration uses an unsupported type}}
}
#endif
+
+// test8 in header
More information about the cfe-commits
mailing list