bitwise-ops.c revision bf7f77ac1cd1f31fc6bf2072327eeee7baed5c6a
1// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s
2
3void clang_analyzer_eval(int);
4#define CHECK(expr) if (!(expr)) return; clang_analyzer_eval(expr)
5
6void testPersistentConstraints(int x, int y) {
7  // Sanity check
8  CHECK(x); // expected-warning{{TRUE}}
9  CHECK(x & 1); // expected-warning{{TRUE}}
10
11  // False positives due to SValBuilder giving up on certain kinds of exprs.
12  CHECK(1 - x); // expected-warning{{UNKNOWN}}
13  CHECK(x & y); // expected-warning{{UNKNOWN}}
14}