2012-05-17 00:01:10 +08:00
|
|
|
// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -analyzer-store region -verify %s
|
2010-11-01 17:09:44 +08:00
|
|
|
|
2012-05-17 00:01:10 +08:00
|
|
|
void clang_analyzer_eval(bool);
|
|
|
|
|
2012-08-16 05:56:23 +08:00
|
|
|
|
2010-04-20 13:48:57 +08:00
|
|
|
struct A {
|
|
|
|
int x;
|
|
|
|
A(int a) { x = a; }
|
2010-11-24 21:48:50 +08:00
|
|
|
int getx() const { return x; }
|
2010-04-20 13:48:57 +08:00
|
|
|
};
|
|
|
|
|
2012-08-16 05:56:23 +08:00
|
|
|
void testNullObject(A *a) {
|
|
|
|
clang_analyzer_eval(a); // expected-warning{{UNKNOWN}}
|
|
|
|
(void)a->getx(); // assume we know what we're doing
|
|
|
|
clang_analyzer_eval(a); // expected-warning{{TRUE}}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: These require constructor inlining to be enabled.
|
|
|
|
|
2010-04-20 13:48:57 +08:00
|
|
|
void f1() {
|
|
|
|
A x(3);
|
2012-08-16 05:56:23 +08:00
|
|
|
// should be TRUE
|
|
|
|
clang_analyzer_eval(x.getx() == 3); // expected-warning{{UNKNOWN}}
|
2010-04-20 13:48:57 +08:00
|
|
|
}
|
|
|
|
|
2010-11-25 11:18:57 +08:00
|
|
|
void f2() {
|
|
|
|
const A &x = A(3);
|
2012-08-16 05:56:23 +08:00
|
|
|
// should be TRUE
|
|
|
|
clang_analyzer_eval(x.getx() == 3); // expected-warning{{UNKNOWN}}
|
2010-11-25 11:18:57 +08:00
|
|
|
}
|
|
|
|
|
2011-02-19 09:08:37 +08:00
|
|
|
void f3() {
|
|
|
|
const A &x = (A)3;
|
2012-08-16 05:56:23 +08:00
|
|
|
// should be TRUE
|
|
|
|
clang_analyzer_eval(x.getx() == 3); // expected-warning{{UNKNOWN}}
|
2011-02-19 09:08:37 +08:00
|
|
|
}
|