]> granicus.if.org Git - clang/commit
-Warc-repeated-use-of-weak: allow single reads in loops from local variables.
authorJordan Rose <jordan_rose@apple.com>
Mon, 29 Oct 2012 17:46:47 +0000 (17:46 +0000)
committerJordan Rose <jordan_rose@apple.com>
Mon, 29 Oct 2012 17:46:47 +0000 (17:46 +0000)
commitc0e44454bd78b8b4f3d70f08cf1edd5466b0c798
tree5814023de0f1188eea089f95b58fec382d4d4e65
parent6a329ee7567cf3267ffab2bc755ea8c773d967e7
-Warc-repeated-use-of-weak: allow single reads in loops from local variables.

Previously, the warning would erroneously fire on this:

for (Test *a in someArray)
  use(a.weakProp);

...because it looks like the same property is being accessed over and over.
However, clearly this is not the case. We now ignore loops like this for
local variables, but continue to warn if the base object is a parameter,
global variable, or instance variable, on the assumption that these are
not repeatedly usually assigned to within loops.

Additionally, do-while loops where the condition is 'false' are not really
loops at all; usually they're just used for semicolon-swallowing macros or
using "break" like "goto".

<rdar://problem/12578785&12578849>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166942 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Sema/ScopeInfo.h
lib/Sema/AnalysisBasedWarnings.cpp
test/SemaObjC/arc-repeated-weak.mm