1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
3 void clang_analyzer_eval(bool);
5 typedef struct Opaque
*Data
;
10 struct Child
: public IntWrapper
{
11 void set() { x
= 42; }
14 void test(Data data
) {
15 Child
*wrapper
= reinterpret_cast<Child
*>(data
);
16 // Don't crash when upcasting here.
17 // We don't actually know if 'data' is a Child.
19 clang_analyzer_eval(wrapper
->x
== 42); // expected-warning{{TRUE}}
24 class Derived1
: public Base1
{};
29 class Derived2
: public Base2
{};
43 f3(reinterpret_cast<void**>(&p
));
44 // Don't crash when upcasting here.
45 // In this case, 'p' actually refers to a Derived1.
50 namespace rdar13249297
{
51 struct IntWrapperSubclass
: public IntWrapper
{};
53 struct IntWrapperWrapper
{
57 void test(IntWrapperWrapper
*ww
) {
58 reinterpret_cast<IntWrapperSubclass
*>(ww
)->x
= 42;
59 clang_analyzer_eval(reinterpret_cast<IntWrapperSubclass
*>(ww
)->x
== 42); // expected-warning{{TRUE}}
61 clang_analyzer_eval(ww
->w
.x
== 42); // expected-warning{{TRUE}}
64 clang_analyzer_eval(reinterpret_cast<IntWrapperSubclass
*>(ww
)->x
== 42); // expected-warning{{FALSE}}
77 class Derived
: public Base
{};
81 *(reinterpret_cast<void**>(&p
)) = new C
;
82 p
->f(); // expected-warning{{Called function pointer is an uninitialized pointer value [core.CallAndMessage]}}
84 } // namespace PR15345
86 int trackpointer_std_addressof() {
88 int *p
= (int*)&reinterpret_cast<const volatile char&>(x
);
90 return x
; // no warning
95 int radar_13146953(void) {
100 return *x
+ *y
; // no warning
108 struct Derived
: Base
{ };
111 Derived
&d
= (Derived
&)(p
);