31 lines · cpp
1// RUN: %clang_analyze_cc1 %s \2// RUN: -analyzer-checker=core \3// RUN: -analyzer-checker=debug.ExprInspection \4// RUN: -analyzer-config eagerly-assume=false \5// RUN: -verify6 7// Here we test whether the SValBuilder is capable to simplify existing8// SVals based on a newly added constraints when evaluating a BinOp.9 10void clang_analyzer_eval(bool);11 12void test_evalBinOp_simplifies_lhs(int y) {13 int x = y / 77;14 if (y != 77)15 return;16 17 // Below `x` is the LHS being simplified.18 clang_analyzer_eval(x == 1); // expected-warning{{TRUE}}19 (void)(x * y);20}21 22void test_evalBinOp_simplifies_rhs(int y) {23 int x = y / 77;24 if (y != 77)25 return;26 27 // Below `x` is the RHS being simplified.28 clang_analyzer_eval(1 == x); // expected-warning{{TRUE}}29 (void)(x * y);30}31