From: Ted Kremenek Date: Fri, 21 Dec 2012 19:45:30 +0000 (+0000) Subject: Sink call to checkUnsafeAssignLiteral() into checkUnsafeAssignObject(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b29b30f9631937916786dc2e06c2842acf9c1500;p=clang Sink call to checkUnsafeAssignLiteral() into checkUnsafeAssignObject(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170919 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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(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(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; } } }