]> granicus.if.org Git - clang/commit
[analyzer] Treat reinterpret_cast like a base cast in certain cases.
authorJordan Rose <jordan_rose@apple.com>
Mon, 22 Apr 2013 21:36:49 +0000 (21:36 +0000)
committerJordan Rose <jordan_rose@apple.com>
Mon, 22 Apr 2013 21:36:49 +0000 (21:36 +0000)
commitf2edbec1d9817df109304f9c19ae2b34fec1feea
tree6d7af3bf8ffca90a253c75e08fcc044e5609b458
parentfbc4444eb2675934b44f3720ef9a5f368ecbeb0a
[analyzer] Treat reinterpret_cast like a base cast in certain cases.

The analyzer represents all pointer-to-pointer bitcasts the same way, but
this can be problematic if an implicit base cast gets layered on top of a
manual base cast (performed with reinterpret_cast instead of static_cast).
Fix this (and avoid a valid assertion) by looking through cast regions.

Using reinterpret_cast this way is only valid if the base class is at the
same offset as the derived class; this is checked by -Wreinterpret-base-class.
In the interest of performance, the analyzer doesn't repeat this check
anywhere; it will just silently do the wrong thing (use the wrong offsets
for fields of the base class) if the user code is wrong.

PR15394

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180052 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/Store.cpp
test/Analysis/derived-to-base.cpp