]> granicus.if.org Git - clang/commit
[analyzer] Try constant-evaluation for all variables, not just globals.
authorJordan Rose <jordan_rose@apple.com>
Thu, 14 Feb 2013 19:06:11 +0000 (19:06 +0000)
committerJordan Rose <jordan_rose@apple.com>
Thu, 14 Feb 2013 19:06:11 +0000 (19:06 +0000)
commit697a68590a75f5cd2326c8f686a6c666b51688b6
tree83d0f0919301c58779038e92506a06d3dd9b3a10
parent33ace0669393acb84c24a7ff7a80e8759777b3e8
[analyzer] Try constant-evaluation for all variables, not just globals.

In C++, constants captured by lambdas (and blocks) are not actually stored
in the closure object, since they can be expanded at compile time. In this
case, they will have no binding when we go to look them up. Previously,
RegionStore thought they were uninitialized stack variables; now, it checks
to see if they are a constant we know how to evaluate, using the same logic
as r175026.

This particular code path is only for scalar variables. Constant arrays and
structs are still unfortunately unhandled; we'll need a stronger solution
for those.

This may have a small performance impact, but only for truly-undefined
local variables, captures in a non-inlined block, and non-constant globals.
Even then, in the non-constant case we're only doing a quick type check.

<rdar://problem/13105553>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175194 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/RegionStore.cpp
test/Analysis/blocks-no-inline.c