r178592 - Objective-C arc [qui]. Don't issue the bridge cast
Fariborz Jahanian
fjahanian at apple.com
Tue Apr 2 16:49:00 PDT 2013
Author: fjahanian
Date: Tue Apr 2 18:48:59 2013
New Revision: 178592
URL: http://llvm.org/viewvc/llvm-project?rev=178592&view=rev
Log:
Objective-C arc [qui]. Don't issue the bridge cast
warning when doing a __bride cast in non-arc
mode (which has no retain count effect).
// rdar://13514210
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/FixIt/bridge-in-non-arc.m
cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=178592&r1=178591&r2=178592&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue Apr 2 18:48:59 2013
@@ -1961,12 +1961,16 @@ Parser::ParseParenExpression(ParenParseO
Tok.is(tok::kw___bridge_retained) ||
Tok.is(tok::kw___bridge_retain)));
if (BridgeCast && !getLangOpts().ObjCAutoRefCount) {
- StringRef BridgeCastName = Tok.getName();
- SourceLocation BridgeKeywordLoc = ConsumeToken();
- if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
- Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
- << BridgeCastName
- << FixItHint::CreateReplacement(BridgeKeywordLoc, "");
+ if (Tok.isNot(tok::kw___bridge)) {
+ StringRef BridgeCastName = Tok.getName();
+ SourceLocation BridgeKeywordLoc = ConsumeToken();
+ if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
+ Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
+ << BridgeCastName
+ << FixItHint::CreateReplacement(BridgeKeywordLoc, "");
+ }
+ else
+ ConsumeToken(); // consume __bridge
BridgeCast = false;
}
Modified: cfe/trunk/test/FixIt/bridge-in-non-arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/bridge-in-non-arc.m?rev=178592&r1=178591&r2=178592&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/bridge-in-non-arc.m (original)
+++ cfe/trunk/test/FixIt/bridge-in-non-arc.m Tue Apr 2 18:48:59 2013
@@ -4,9 +4,9 @@
@end
void foo(void *p) {
- I *i = (__bridge I*)p;
- I *i2 = (__bridge/*cake*/I*)p;
+ I *i = (__bridge_transfer I*)p;
+ I *i2 = (__bridge_transfer/*cake*/I*)p;
}
-// CHECK: {7:11-7:20}:""
-// CHECK: {8:12-8:20}:""
+// CHECK: {7:11-7:29}:""
+// CHECK: {8:12-8:29}:""
Modified: cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m?rev=178592&r1=178591&r2=178592&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m (original)
+++ cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m Tue Apr 2 18:48:59 2013
@@ -18,17 +18,16 @@ NSString *CreateNSString();
void from_cf() {
id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
id obj2 = (__bridge_transfer NSString*)CFCreateString(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
- (__bridge int*)CFCreateSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}} \
- // expected-warning {{expression result unused}}
- id obj3 = (__bridge id)CFGetSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
- id obj4 = (__bridge NSString*)CFGetString(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
+ (__bridge int*)CFCreateSomething(); // expected-warning {{expression result unused}}
+ id obj3 = (__bridge id)CFGetSomething();
+ id obj4 = (__bridge NSString*)CFGetString();
}
void to_cf(id obj) {
CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}}
CFStringRef cf2 = (__bridge_retained CFStringRef)CreateNSString(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}}
- CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
- CFStringRef cf4 = (__bridge CFStringRef)CreateNSString(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
+ CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething();
+ CFStringRef cf4 = (__bridge CFStringRef)CreateNSString();
}
void fixits() {
More information about the cfe-commits
mailing list