]> granicus.if.org Git - clang/commit
[analyzer] When forced to fake a block type, do it correctly.
authorJordan Rose <jordan_rose@apple.com>
Fri, 10 Jul 2015 21:41:59 +0000 (21:41 +0000)
committerJordan Rose <jordan_rose@apple.com>
Fri, 10 Jul 2015 21:41:59 +0000 (21:41 +0000)
commit22ea838f1b9234b1876fa0220d7a76bcb2a1b27a
tree73436808b9ca21ddd1fc93c563fa72335a15f8af
parent79bfc7f39fdfd61ca80fe41b9de47e63adcccf8c
[analyzer] When forced to fake a block type, do it correctly.

BlockDecl has a poor AST representation because it doesn't carry its type
with it. Instead, the containing BlockExpr has the full type. This almost
never matters for the analyzer, but if the block decl contains static
local variables we need to synthesize a region to put them in, and this
region will necessarily not have the right type.

Even /that/ doesn't matter, unless

(1) the block calls the function or method containing the block, and
(2) the value of the block expr is used in some interesting way.

In this case, we actually end up needing the type of the block region,
and it will be set to our synthesized type. It turns out we've been doing
a terrible job faking that type -- it wasn't a block pointer type at all.
This commit fixes that to at least guarantee a block pointer type, using
the signature written by the user if there is one.

This is not really a correct answer because the block region's type will
/still/ be wrong, but further efforts to make this right in the analyzer
would probably be silly. We should just change the AST.

rdar://problem/21698099

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241944 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/MemRegion.cpp
test/Analysis/blocks.m