diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-12-21 19:45:30 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-12-21 19:45:30 +0000 |
commit | b29b30f9631937916786dc2e06c2842acf9c1500 (patch) | |
tree | 3e0eec452735484739ebdd9bad219b239030b22d /lib/Sema/SemaChecking.cpp | |
parent | eb4c01ec1743caa49e68a1afa12744e57522ec9e (diff) |
Sink call to checkUnsafeAssignLiteral() into checkUnsafeAssignObject().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170919 91177308-0d34-0410-b5e6-96231b3b80d8
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; } } } |