r175715 - [analyzer] Add another reinterpret_cast behavior test.
Jordan Rose
jordan_rose at apple.com
Wed Feb 20 19:12:26 PST 2013
Author: jrose
Date: Wed Feb 20 21:12:26 2013
New Revision: 175715
URL: http://llvm.org/viewvc/llvm-project?rev=175715&view=rev
Log:
[analyzer] Add another reinterpret_cast behavior test.
The test is similar to <rdar://problem/13239840> but doesn't actually test
the case that fails there. It's still a good test, though.
Modified:
cfe/trunk/test/Analysis/reinterpret-cast.cpp
Modified: cfe/trunk/test/Analysis/reinterpret-cast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/reinterpret-cast.cpp?rev=175715&r1=175714&r2=175715&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/reinterpret-cast.cpp (original)
+++ cfe/trunk/test/Analysis/reinterpret-cast.cpp Wed Feb 20 21:12:26 2013
@@ -46,3 +46,21 @@ namespace PR14872 {
f2(p);
}
}
+
+namespace rdar13249297 {
+ struct IntWrapperSubclass : public IntWrapper {};
+
+ struct IntWrapperWrapper {
+ IntWrapper w;
+ };
+
+ void test(IntWrapperWrapper *ww) {
+ reinterpret_cast<IntWrapperSubclass *>(ww)->x = 42;
+ clang_analyzer_eval(reinterpret_cast<IntWrapperSubclass *>(ww)->x == 42); // expected-warning{{TRUE}}
+
+ clang_analyzer_eval(ww->w.x == 42); // expected-warning{{TRUE}}
+ ww->w.x = 0;
+
+ clang_analyzer_eval(reinterpret_cast<IntWrapperSubclass *>(ww)->x == 42); // expected-warning{{FALSE}}
+ }
+}
More information about the cfe-commits
mailing list