[cfe-commits] r154434 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/Store.h lib/StaticAnalyzer/Core/ExprEngineC.cpp lib/StaticAnalyzer/Core/RegionStore.cpp test/Analysis/dynamic-cast.cpp

Anna Zaks ganna at apple.com
Wed Apr 11 14:40:32 PDT 2012


On Apr 10, 2012, at 8:51 PM, Richard Smith wrote:

> On Tue, Apr 10, 2012 at 1:59 PM, Anna Zaks <ganna at apple.com> wrote:
> Added: cfe/trunk/test/Analysis/dynamic-cast.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dynamic-cast.cpp?rev=154434&view=auto
> ==============================================================================
> --- cfe/trunk/test/Analysis/dynamic-cast.cpp (added)
> +++ cfe/trunk/test/Analysis/dynamic-cast.cpp Tue Apr 10 15:59:00 2012
> [...] 
> +// False negatives.
> +
> +// Symbolic regions are not typed, so we cannot deduce that the cast will
> +// always fail in this case.
> 
> The cast won't always fail:
> 
> class D : public B, public C {};
> int main() {
>   D d;
>   testDynCastFail1(&d);
> }
> 

Thanks Richard! Looks like we cannot tell for sure unless we see the object creation site.

We still should track Types of symbolic regions in cases it can be proved that the cast succeeds, but should special case and not assume that the cast fails if the region is symbolic.

I'll commit an amended test case.

> +int testDynCastFail1(class C *c) {
> +  B *b = 0;
> +  b = dynamic_cast<B*>(c);
> +  return b->m;
> +}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120411/f22184d7/attachment.html>


More information about the cfe-commits mailing list