diff options
author | Devin Coughlin <dcoughlin@apple.com> | 2015-12-05 00:22:36 +0000 |
---|---|---|
committer | Devin Coughlin <dcoughlin@apple.com> | 2015-12-05 00:22:36 +0000 |
commit | 316669967e3e6cf6b8e093c98e270c994de37268 (patch) | |
tree | 7da82a524a7cba8850527fa7acc7125c1434f07f /test | |
parent | 3b59f3512f9b80365b2d93caa2ef52fae2a03e57 (diff) | |
download | clang-316669967e3e6cf6b8e093c98e270c994de37268.tar.gz |
[analyzer] Fix MemRegion crash casting non-struct to derived struct (PR25426).
This commit prevents MemRegion::getAsOffset() from crashing when the analyzed
program casts a symbolic region of a non-record type to some derived type and
then attempts to access a field of the base type.
rdar://problem/23458069
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254806 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Analysis/reinterpret-cast.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/Analysis/reinterpret-cast.cpp b/test/Analysis/reinterpret-cast.cpp index cb7cbfd325..f3b0a7b257 100644 --- a/test/Analysis/reinterpret-cast.cpp +++ b/test/Analysis/reinterpret-cast.cpp @@ -102,4 +102,17 @@ int radar_13146953(void) { set_x1(x); set_x2((void *&)y); return *x + *y; // no warning -}
\ No newline at end of file +} + +namespace PR25426 { + struct Base { + int field; + }; + + struct Derived : Base { }; + + void foo(int &p) { + Derived &d = (Derived &)(p); + d.field = 2; + } +} |