method-call.cpp revision 7f660857309a14c036a80ef90b40bf8f68fda9da
1// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -analyzer-store region -verify %s 2 3void clang_analyzer_eval(bool); 4 5 6struct A { 7 int x; 8 A(int a) { x = a; } 9 int getx() const { return x; } 10}; 11 12void testNullObject(A *a) { 13 clang_analyzer_eval(a); // expected-warning{{UNKNOWN}} 14 (void)a->getx(); // assume we know what we're doing 15 clang_analyzer_eval(a); // expected-warning{{TRUE}} 16} 17 18 19// FIXME: These require constructor inlining to be enabled. 20 21void f1() { 22 A x(3); 23 // should be TRUE 24 clang_analyzer_eval(x.getx() == 3); // expected-warning{{UNKNOWN}} 25} 26 27void f2() { 28 const A &x = A(3); 29 // should be TRUE 30 clang_analyzer_eval(x.getx() == 3); // expected-warning{{UNKNOWN}} 31} 32 33void f3() { 34 const A &x = (A)3; 35 // should be TRUE 36 clang_analyzer_eval(x.getx() == 3); // expected-warning{{UNKNOWN}} 37} 38