diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-08-15 17:33:34 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-08-15 17:33:34 +0000 |
commit | 31c3fa9c24c532f513d6f216e51f821a15ba2685 (patch) | |
tree | a8d3b04bf3241bec0602d20471e8f67ec8d7da1a /clang/test/Analysis/reinterpret-cast.cpp | |
parent | 1c0b3c6b84d34c1f20227c1678bf7045a79e87d4 (diff) | |
download | bcm5719-llvm-31c3fa9c24c532f513d6f216e51f821a15ba2685.tar.gz bcm5719-llvm-31c3fa9c24c532f513d6f216e51f821a15ba2685.zip |
[analyzer] Only adjust the type of 'this' when we devirtualize a method call.
With reinterpret_cast, we can get completely unrelated types in a region
hierarchy together; this was resulting in CXXBaseObjectRegions being layered
directly on an (untyped) SymbolicRegion, whose symbol was from a completely
different type hierarchy. This was what was causing the internal buildbot to
fail.
Reverts r161911, which merely masked the problem.
llvm-svn: 161960
Diffstat (limited to 'clang/test/Analysis/reinterpret-cast.cpp')
-rw-r--r-- | clang/test/Analysis/reinterpret-cast.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/Analysis/reinterpret-cast.cpp b/clang/test/Analysis/reinterpret-cast.cpp new file mode 100644 index 00000000000..73f2e2de738 --- /dev/null +++ b/clang/test/Analysis/reinterpret-cast.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -verify %s + +void clang_analyzer_eval(bool); + +typedef struct Opaque *Data; +struct IntWrapper { + int x; +}; + +struct Child : public IntWrapper { + void set() { x = 42; } +}; + +void test(Data data) { + Child *wrapper = reinterpret_cast<Child*>(data); + // Don't crash when upcasting here. + // We don't actually know if 'data' is a Child. + wrapper->set(); + clang_analyzer_eval(wrapper->x == 42); // expected-warning{{TRUE}} +} |