diff options
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 1664d30847..8b0d579423 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -5747,23 +5747,6 @@ void Sema::checkRetainCycles(VarDecl *Var, Expr *Init) { diagnoseRetainCycle(*this, Capturer, Owner); } -static bool checkUnsafeAssignObject(Sema &S, SourceLocation Loc, - Qualifiers::ObjCLifetime LT, - Expr *RHS, bool isProperty) { - // Strip off any implicit cast added to get to the one ARC-specific. - while (ImplicitCastExpr *cast = dyn_cast<ImplicitCastExpr>(RHS)) { - if (cast->getCastKind() == CK_ARCConsumeObject) { - S.Diag(Loc, diag::warn_arc_retained_assign) - << (LT == Qualifiers::OCL_ExplicitNone) - << (isProperty ? 0 : 1) - << RHS->getSourceRange(); - return true; - } - RHS = cast->getSubExpr(); - } - return false; -} - static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc, Expr *RHS, bool isProperty) { // Check if RHS is an Objective-C object literal, which also can get @@ -5797,6 +5780,28 @@ static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc, return false; } +static bool checkUnsafeAssignObject(Sema &S, SourceLocation Loc, + Qualifiers::ObjCLifetime LT, + Expr *RHS, bool isProperty) { + // Strip off any implicit cast added to get to the one ARC-specific. + while (ImplicitCastExpr *cast = dyn_cast<ImplicitCastExpr>(RHS)) { + if (cast->getCastKind() == CK_ARCConsumeObject) { + S.Diag(Loc, diag::warn_arc_retained_assign) + << (LT == Qualifiers::OCL_ExplicitNone) + << (isProperty ? 0 : 1) + << RHS->getSourceRange(); + return true; + } + RHS = cast->getSubExpr(); + } + + if (LT == Qualifiers::OCL_Weak && + checkUnsafeAssignLiteral(S, Loc, RHS, isProperty)) + return true; + + return false; +} + bool Sema::checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS) { Qualifiers::ObjCLifetime LT = LHS.getObjCLifetime(); @@ -5807,10 +5812,6 @@ bool Sema::checkUnsafeAssigns(SourceLocation Loc, if (checkUnsafeAssignObject(*this, Loc, LT, RHS, false)) return true; - if (LT == Qualifiers::OCL_Weak && - checkUnsafeAssignLiteral(*this, Loc, RHS, false)) - return true; - return false; } @@ -5875,8 +5876,6 @@ void Sema::checkUnsafeExprAssigns(SourceLocation Loc, else if (Attributes & ObjCPropertyDecl::OBJC_PR_weak) { if (checkUnsafeAssignObject(*this, Loc, Qualifiers::OCL_Weak, RHS, true)) return; - if (checkUnsafeAssignLiteral(*this, Loc, RHS, true)) - return; } } } |