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_retained) ||
|
||||||
Tok.is(tok::kw___bridge_retain)));
|
Tok.is(tok::kw___bridge_retain)));
|
||||||
if (BridgeCast && !getLangOpts().ObjCAutoRefCount) {
|
if (BridgeCast && !getLangOpts().ObjCAutoRefCount) {
|
||||||
|
if (Tok.isNot(tok::kw___bridge)) {
|
||||||
StringRef BridgeCastName = Tok.getName();
|
StringRef BridgeCastName = Tok.getName();
|
||||||
SourceLocation BridgeKeywordLoc = ConsumeToken();
|
SourceLocation BridgeKeywordLoc = ConsumeToken();
|
||||||
if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
|
if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
|
||||||
Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
|
Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
|
||||||
<< BridgeCastName
|
<< BridgeCastName
|
||||||
<< FixItHint::CreateReplacement(BridgeKeywordLoc, "");
|
<< FixItHint::CreateReplacement(BridgeKeywordLoc, "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ConsumeToken(); // consume __bridge
|
||||||
BridgeCast = false;
|
BridgeCast = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
void foo(void *p) {
|
void foo(void *p) {
|
||||||
I *i = (__bridge I*)p;
|
I *i = (__bridge_transfer I*)p;
|
||||||
I *i2 = (__bridge/*cake*/I*)p;
|
I *i2 = (__bridge_transfer/*cake*/I*)p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHECK: {7:11-7:20}:""
|
// CHECK: {7:11-7:29}:""
|
||||||
// CHECK: {8:12-8:20}:""
|
// CHECK: {8:12-8:29}:""
|
||||||
|
|
|
@ -18,17 +18,16 @@ NSString *CreateNSString();
|
||||||
void from_cf() {
|
void from_cf() {
|
||||||
id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
|
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}}
|
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}} \
|
(__bridge int*)CFCreateSomething(); // expected-warning {{expression result unused}}
|
||||||
// expected-warning {{expression result unused}}
|
id obj3 = (__bridge id)CFGetSomething();
|
||||||
id obj3 = (__bridge id)CFGetSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
|
id obj4 = (__bridge NSString*)CFGetString();
|
||||||
id obj4 = (__bridge NSString*)CFGetString(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void to_cf(id obj) {
|
void to_cf(id obj) {
|
||||||
CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}}
|
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}}
|
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}}
|
CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething();
|
||||||
CFStringRef cf4 = (__bridge CFStringRef)CreateNSString(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
|
CFStringRef cf4 = (__bridge CFStringRef)CreateNSString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void fixits() {
|
void fixits() {
|
||||||
|
|
Loading…
Reference in New Issue