1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config c++-inlining=constructors -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc void clang_analyzer_eval(bool); 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc 6*f4a2713aSLionel Sambuc struct A { 7*f4a2713aSLionel Sambuc int x; AA8*f4a2713aSLionel Sambuc A(int a) { x = a; } getxA9*f4a2713aSLionel Sambuc int getx() const { return x; } 10*f4a2713aSLionel Sambuc }; 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc struct B{ 13*f4a2713aSLionel Sambuc int x; 14*f4a2713aSLionel Sambuc }; 15*f4a2713aSLionel Sambuc testNullObject(A * a)16*f4a2713aSLionel Sambucvoid testNullObject(A *a) { 17*f4a2713aSLionel Sambuc clang_analyzer_eval(a); // expected-warning{{UNKNOWN}} 18*f4a2713aSLionel Sambuc (void)a->getx(); // assume we know what we're doing 19*f4a2713aSLionel Sambuc clang_analyzer_eval(a); // expected-warning{{TRUE}} 20*f4a2713aSLionel Sambuc } 21*f4a2713aSLionel Sambuc f1()22*f4a2713aSLionel Sambucvoid f1() { 23*f4a2713aSLionel Sambuc A x(3); 24*f4a2713aSLionel Sambuc clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}} 25*f4a2713aSLionel Sambuc } 26*f4a2713aSLionel Sambuc f2()27*f4a2713aSLionel Sambucvoid f2() { 28*f4a2713aSLionel Sambuc const A &x = A(3); 29*f4a2713aSLionel Sambuc clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}} 30*f4a2713aSLionel Sambuc } 31*f4a2713aSLionel Sambuc f3()32*f4a2713aSLionel Sambucvoid f3() { 33*f4a2713aSLionel Sambuc const A &x = (A)3; 34*f4a2713aSLionel Sambuc clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}} 35*f4a2713aSLionel Sambuc } 36*f4a2713aSLionel Sambuc f4()37*f4a2713aSLionel Sambucvoid f4() { 38*f4a2713aSLionel Sambuc A x = 3; 39*f4a2713aSLionel Sambuc clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}} 40*f4a2713aSLionel Sambuc } 41*f4a2713aSLionel Sambuc checkThatCopyConstructorDoesNotInvalidateObjectBeingCopied()42*f4a2713aSLionel Sambucvoid checkThatCopyConstructorDoesNotInvalidateObjectBeingCopied() { 43*f4a2713aSLionel Sambuc B t; 44*f4a2713aSLionel Sambuc t.x = 0; 45*f4a2713aSLionel Sambuc B t2(t); 46*f4a2713aSLionel Sambuc clang_analyzer_eval(t.x == 0); // expected-warning{{TRUE}} 47*f4a2713aSLionel Sambuc } 48