forked from OSchip/llvm-project
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 llvm-svn: 178592
This commit is contained in:
parent
235af9c1f5
commit
896ae920d5
|
@ -1961,12 +1961,16 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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}:""
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue