[cfe-commits] r170919 - /cfe/trunk/lib/Sema/SemaChecking.cpp
Ted Kremenek
kremenek at apple.com
Fri Dec 21 11:45:30 PST 2012
Author: kremenek
Date: Fri Dec 21 13:45:30 2012
New Revision: 170919
URL: http://llvm.org/viewvc/llvm-project?rev=170919&view=rev
Log:
Sink call to checkUnsafeAssignLiteral() into checkUnsafeAssignObject().
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=170919&r1=170918&r2=170919&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Dec 21 13:45:30 2012
@@ -5747,23 +5747,6 @@
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 @@
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 @@
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 @@
else if (Attributes & ObjCPropertyDecl::OBJC_PR_weak) {
if (checkUnsafeAssignObject(*this, Loc, Qualifiers::OCL_Weak, RHS, true))
return;
- if (checkUnsafeAssignLiteral(*this, Loc, RHS, true))
- return;
}
}
}
More information about the cfe-commits
mailing list