diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-02-25 18:36:15 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-02-25 18:36:15 +0000 |
commit | f9e9a9f41bef7b0200deefa27786bb3b8e25b25d (patch) | |
tree | 0781207d84c220d6206f7f8400a0ef8a2b628d00 /clang/test/Analysis/reinterpret-cast.cpp | |
parent | 8b90511e6b4565a916872933ec99986286cb297b (diff) | |
download | bcm5719-llvm-f9e9a9f41bef7b0200deefa27786bb3b8e25b25d.tar.gz bcm5719-llvm-f9e9a9f41bef7b0200deefa27786bb3b8e25b25d.zip |
[analyzer] Base regions may be invalid when layered on symbolic regions.
While RegionStore checks to make sure casts on TypedValueRegions are valid,
it does not do the same for SymbolicRegions, which do not have perfect type
info anyway. Additionally, MemRegion::getAsOffset does not take a
ProgramState, so it can't use dynamic type info to determine a better type
for the regions. (This could also be dangerous if the type of a super-region
changes!)
Account for this by checking that a base object region is valid on top of a
symbolic region, and falling back to "symbolic offset" mode if not.
Fixes PR15345.
llvm-svn: 176034
Diffstat (limited to 'clang/test/Analysis/reinterpret-cast.cpp')
-rw-r--r-- | clang/test/Analysis/reinterpret-cast.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/test/Analysis/reinterpret-cast.cpp b/clang/test/Analysis/reinterpret-cast.cpp index d1aed80a0c3..59e6a539a11 100644 --- a/clang/test/Analysis/reinterpret-cast.cpp +++ b/clang/test/Analysis/reinterpret-cast.cpp @@ -64,3 +64,25 @@ namespace rdar13249297 { clang_analyzer_eval(reinterpret_cast<IntWrapperSubclass *>(ww)->x == 42); // expected-warning{{FALSE}} } } + +namespace PR15345 { + class C {}; + + class Base { + public: + void (*f)(); + int x; + }; + + class Derived : public Base {}; + + void test() { + Derived* p; + *(reinterpret_cast<void**>(&p)) = new C; + p->f(); + + // We should still be able to do some reasoning about bindings. + p->x = 42; + clang_analyzer_eval(p->x == 42); // expected-warning{{TRUE}} + }; +} |