-Warc-repeated-use-of-weak: look through explicit casts on assigned values.

Reading from a weak property, casting the result, and assigning to a
strong pointer should still be considered safe.

llvm-svn: 165629
This commit is contained in:
Jordan Rose 2012-10-10 16:43:06 +00:00
parent 2bd991a1c0
commit e723a27ffe
2 changed files with 12 additions and 1 deletions

View File

@ -115,7 +115,7 @@ FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(
}
void FunctionScopeInfo::markSafeWeakUse(const Expr *E) {
E = E->IgnoreParenImpCasts();
E = E->IgnoreParenCasts();
if (const PseudoObjectExpr *POE = dyn_cast<PseudoObjectExpr>(E)) {
markSafeWeakUse(POE->getSyntacticForm());

View File

@ -147,6 +147,17 @@ void testBlock(Test *a) {
});
}
void assignToStrongWithCasts(Test *a) {
if (condition()) {
Test *val = (Test *)a.weakProp; // no-warning
(void)val;
} else {
id val;
val = (Test *)a.weakProp; // no-warning
(void)val;
}
}
@interface Test (Methods)
@end