aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-02-01 22:56:20 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-02-01 22:56:20 +0000
commit52b6236427e7b608eadaac2bf8f5a24dd16a1130 (patch)
tree7b920cd97ef93d7dfa287320464b6b4a8f12abc4 /lib/Sema/SemaExprObjC.cpp
parent873488a9d5ab7774bdcccada7ef0f90e5e5eda14 (diff)
Look for declaration of CFBridgingRetain/CFBridgingRetain before
changing the diagnostic. Also use correct spelling for both. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149554 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprObjC.cpp')
-rw-r--r--lib/Sema/SemaExprObjC.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 483e7eab23..82e8171d66 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -1902,6 +1902,13 @@ namespace {
};
}
+static bool
+KnownName(Sema &S, const char *name) {
+ LookupResult R(S, &S.Context.Idents.get(name), SourceLocation(),
+ Sema::LookupOrdinaryName);
+ return S.LookupName(R, S.TUScope, false);
+}
+
static void
diagnoseObjCARCConversion(Sema &S, SourceRange castRange,
QualType castType, ARCConversionTypeClass castACTC,
@@ -1937,6 +1944,7 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange,
// Bridge from an ARC type to a CF type.
if (castACTC == ACTC_retainable && isAnyRetainable(exprACTC)) {
+
S.Diag(loc, diag::err_arc_cast_requires_bridge)
<< unsigned(CCK == Sema::CCK_ImplicitConversion) // cast|implicit
<< 2 // of C pointer type
@@ -1945,20 +1953,22 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange,
<< castType
<< castRange
<< castExpr->getSourceRange();
-
+ bool br = KnownName(S, "CFBridgingRelease");
S.Diag(noteLoc, diag::note_arc_bridge)
<< (CCK != Sema::CCK_CStyleCast ? FixItHint() :
FixItHint::CreateInsertion(afterLParen, "__bridge "));
S.Diag(noteLoc, diag::note_arc_bridge_transfer)
- << castExprType
+ << castExprType << br
<< (CCK != Sema::CCK_CStyleCast ? FixItHint() :
- FixItHint::CreateInsertion(afterLParen, "CFBridgeRelease "));
+ FixItHint::CreateInsertion(afterLParen,
+ br ? "CFBridgingRelease " : "__bridge_transfer "));
return;
}
// Bridge from a CF type to an ARC type.
if (exprACTC == ACTC_retainable && isAnyRetainable(castACTC)) {
+ bool br = KnownName(S, "CFBridgingRetain");
S.Diag(loc, diag::err_arc_cast_requires_bridge)
<< unsigned(CCK == Sema::CCK_ImplicitConversion) // cast|implicit
<< unsigned(castExprType->isBlockPointerType()) // of ObjC|block type
@@ -1972,9 +1982,10 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange,
<< (CCK != Sema::CCK_CStyleCast ? FixItHint() :
FixItHint::CreateInsertion(afterLParen, "__bridge "));
S.Diag(noteLoc, diag::note_arc_bridge_retained)
- << castType
+ << castType << br
<< (CCK != Sema::CCK_CStyleCast ? FixItHint() :
- FixItHint::CreateInsertion(afterLParen, "CFBridgeRetain "));
+ FixItHint::CreateInsertion(afterLParen,
+ br ? "CFBridgingRetain " : "__bridge_retained"));
return;
}
@@ -2205,7 +2216,8 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc,
case OBC_Bridge:
break;
- case OBC_BridgeRetained:
+ case OBC_BridgeRetained: {
+ bool br = KnownName(*this, "CFBridgingRelease");
Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
<< 2
<< FromType
@@ -2216,12 +2228,14 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc,
Diag(BridgeKeywordLoc, diag::note_arc_bridge)
<< FixItHint::CreateReplacement(BridgeKeywordLoc, "__bridge");
Diag(BridgeKeywordLoc, diag::note_arc_bridge_transfer)
- << FromType
+ << FromType << br
<< FixItHint::CreateReplacement(BridgeKeywordLoc,
- "CFBridgeRelease ");
+ br ? "CFBridgingRelease "
+ : "__bridge_transfer ");
Kind = OBC_Bridge;
break;
+ }
case OBC_BridgeTransfer:
// We must consume the Objective-C object produced by the cast.
@@ -2245,7 +2259,8 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc,
SubExpr, 0, VK_RValue);
break;
- case OBC_BridgeTransfer:
+ case OBC_BridgeTransfer: {
+ bool br = KnownName(*this, "CFBridgingRetain");
Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
<< (FromType->isBlockPointerType()? 1 : 0)
<< FromType
@@ -2257,12 +2272,14 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc,
Diag(BridgeKeywordLoc, diag::note_arc_bridge)
<< FixItHint::CreateReplacement(BridgeKeywordLoc, "__bridge ");
Diag(BridgeKeywordLoc, diag::note_arc_bridge_retained)
- << T
- << FixItHint::CreateReplacement(BridgeKeywordLoc, "CFBridgeRetain ");
+ << T << br
+ << FixItHint::CreateReplacement(BridgeKeywordLoc,
+ br ? "CFBridgingRetain " : "__bridge_retained");
Kind = OBC_Bridge;
break;
}
+ }
} else {
Diag(LParenLoc, diag::err_arc_bridge_cast_incompatible)
<< FromType << T << Kind