[cfe-commits] r165629 - in /cfe/trunk: lib/Sema/ScopeInfo.cpp test/SemaObjC/arc-repeated-weak.mm
Jordan Rose
jordan_rose at apple.com
Wed Oct 10 09:43:06 PDT 2012
Author: jrose
Date: Wed Oct 10 11:43:06 2012
New Revision: 165629
URL: http://llvm.org/viewvc/llvm-project?rev=165629&view=rev
Log:
-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.
Modified:
cfe/trunk/lib/Sema/ScopeInfo.cpp
cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
Modified: cfe/trunk/lib/Sema/ScopeInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ScopeInfo.cpp?rev=165629&r1=165628&r2=165629&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/ScopeInfo.cpp (original)
+++ cfe/trunk/lib/Sema/ScopeInfo.cpp Wed Oct 10 11:43:06 2012
@@ -115,7 +115,7 @@
}
void FunctionScopeInfo::markSafeWeakUse(const Expr *E) {
- E = E->IgnoreParenImpCasts();
+ E = E->IgnoreParenCasts();
if (const PseudoObjectExpr *POE = dyn_cast<PseudoObjectExpr>(E)) {
markSafeWeakUse(POE->getSyntacticForm());
Modified: cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-repeated-weak.mm?rev=165629&r1=165628&r2=165629&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-repeated-weak.mm (original)
+++ cfe/trunk/test/SemaObjC/arc-repeated-weak.mm Wed Oct 10 11:43:06 2012
@@ -147,6 +147,17 @@
});
}
+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
More information about the cfe-commits
mailing list