forked from OSchip/llvm-project
-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:
parent
2bd991a1c0
commit
e723a27ffe
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue