2018-08-30 04:29:17 +08:00
|
|
|
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection,core.builtin -analyzer-config aggressive-binary-operation-simplification=true -verify -analyzer-config eagerly-assume=false %s
|
2018-04-11 14:21:12 +08:00
|
|
|
|
|
|
|
void clang_analyzer_eval(int x);
|
2018-09-26 07:50:53 +08:00
|
|
|
void clang_analyzer_denote(int x, const char *literal);
|
|
|
|
void clang_analyzer_express(int x);
|
2018-04-11 14:21:12 +08:00
|
|
|
|
|
|
|
void exit(int);
|
|
|
|
|
|
|
|
#define UINT_MAX (~0U)
|
|
|
|
#define INT_MAX (UINT_MAX & (UINT_MAX >> 1))
|
|
|
|
|
|
|
|
extern void __assert_fail (__const char *__assertion, __const char *__file,
|
|
|
|
unsigned int __line, __const char *__function)
|
|
|
|
__attribute__ ((__noreturn__));
|
|
|
|
#define assert(expr) \
|
|
|
|
((expr) ? (void)(0) : __assert_fail (#expr, __FILE__, __LINE__, __func__))
|
|
|
|
|
|
|
|
int g();
|
|
|
|
int f() {
|
|
|
|
int x = g();
|
|
|
|
// Assert that no overflows occur in this test file.
|
|
|
|
// Assuming that concrete integers are also within that range.
|
|
|
|
assert(x <= ((int)INT_MAX / 4));
|
|
|
|
assert(x >= -((int)INT_MAX / 4));
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_equal() {
|
|
|
|
int x = f(), y = f();
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x - $y == 0}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x += 1;
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$y - $x == 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x -= 1;
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x - $y == 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_right_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
y += 2;
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 2}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x - $y == 2}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_right_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
y -= 2;
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 2}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$y - $x == 2}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_plus_right_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x += 2;
|
|
|
|
y += 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 1}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$y - $x == 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_minus_right_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x += 2;
|
|
|
|
y -= 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 1}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$y - $x == 3}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_plus_right_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x -= 2;
|
|
|
|
y += 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 1}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x - $y == 3}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_minus_right_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x -= 2;
|
|
|
|
y -= 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 1}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x - $y == 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_equal() {
|
|
|
|
int x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_eval(x == y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_int_equal() {
|
|
|
|
int x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_eval(x == y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_int_equal() {
|
|
|
|
int x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_eval(x == y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_right_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_eval(x == y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_right_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_eval(x == y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_plus_right_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_eval(x == y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_minus_right_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_eval(x == y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_plus_right_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_eval(x == y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_minus_right_int_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_eval(x == y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_less_or_equal() {
|
|
|
|
int x = f(), y = f();
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x - $y <= 0}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x += 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$y - $x >= 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x -= 1;
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x - $y <= 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_right_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
y += 2;
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x - $y <= 2}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_right_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
y -= 2;
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 2}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$y - $x >= 2}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_plus_right_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x += 2;
|
|
|
|
y += 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 1}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$y - $x >= 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_minus_right_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x += 2;
|
|
|
|
y -= 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 1}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$y - $x >= 3}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_plus_right_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x -= 2;
|
|
|
|
y += 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 1}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x - $y <= 3}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_minus_right_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x -= 2;
|
|
|
|
y -= 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 1}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x - $y <= 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_less_or_equal() {
|
|
|
|
int x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_eval(x <= y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_int_less_or_equal() {
|
|
|
|
int x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_eval(x <= y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_int_less_or_equal() {
|
|
|
|
int x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_eval(x <= y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_right_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_eval(x <= y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_right_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_eval(x <= y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_plus_right_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_eval(x <= y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_minus_right_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_eval(x <= y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_plus_right_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_eval(x <= y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_minus_right_int_less_or_equal() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_eval(x <= y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_less() {
|
|
|
|
int x = f(), y = f();
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x - $y < 0}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x += 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$y - $x > 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x -= 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x - $y < 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_right_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
y += 2;
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 2}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x - $y < 2}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_right_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
y -= 2;
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 2}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$y - $x > 2}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_plus_right_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x += 2;
|
|
|
|
y += 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 1}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$y - $x > 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_minus_right_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x += 2;
|
|
|
|
y -= 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 1}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$y - $x > 3}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_plus_right_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x -= 2;
|
|
|
|
y += 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 1}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x - $y < 3}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_minus_right_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = f();
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
x -= 2;
|
|
|
|
y -= 1;
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 1}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x - $y < 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_less() {
|
|
|
|
int x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_eval(x < y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_int_less() {
|
|
|
|
int x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_eval(x < y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_int_less() {
|
|
|
|
int x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_eval(x < y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_right_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_eval(x < y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_right_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_eval(x < y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_plus_right_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_eval(x < y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_minus_right_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_eval(x < y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_plus_right_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_eval(x < y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_minus_right_int_less() {
|
2018-09-26 07:50:53 +08:00
|
|
|
int x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_eval(x < y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_equal_unsigned() {
|
|
|
|
unsigned x = f(), y = f();
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x - $y == 0}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() + 1, y = f();
|
|
|
|
clang_analyzer_denote(x - 1, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$y - $x == 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() - 1, y = f();
|
|
|
|
clang_analyzer_denote(x + 1, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x - $y == 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_right_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = f() + 2;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y - 2, "$y");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 2}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x - $y == 2}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_right_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = f() - 2;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y + 2, "$y");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 2}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$y - $x == 2}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_plus_right_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() + 2, y = f() + 1;
|
|
|
|
clang_analyzer_denote(x - 2, "$x");
|
|
|
|
clang_analyzer_denote(y - 1, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 1}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$y - $x == 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_minus_right_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() + 2, y = f() - 1;
|
|
|
|
clang_analyzer_denote(x - 2, "$x");
|
|
|
|
clang_analyzer_denote(y + 1, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 1}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$y - $x == 3}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_plus_right_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() - 2, y = f() + 1;
|
|
|
|
clang_analyzer_denote(x + 2, "$x");
|
|
|
|
clang_analyzer_denote(y - 1, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 1}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x - $y == 3}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_minus_right_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() - 2, y = f() - 1;
|
|
|
|
clang_analyzer_denote(x + 2, "$x");
|
|
|
|
clang_analyzer_denote(y + 1, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 1}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x - $y == 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_equal_unsigned() {
|
|
|
|
unsigned x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_eval(x == y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_int_equal_unsigned() {
|
|
|
|
unsigned x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x + 1U == $x}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_int_equal_unsigned() {
|
|
|
|
unsigned x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x - 1U == $x}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_right_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x == $x + 1U}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_right_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x == $x - 1U}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_plus_right_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_eval(x == y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_minus_right_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x + 1U == $x - 1U}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_plus_right_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x - 1U == $x + 1U}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_minus_right_int_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_eval(x == y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_less_or_equal_unsigned() {
|
|
|
|
unsigned x = f(), y = f();
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x - $y <= 0}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() + 1, y = f();
|
|
|
|
clang_analyzer_denote(x - 1, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$y - $x >= 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() - 1, y = f();
|
|
|
|
clang_analyzer_denote(x + 1, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x - $y <= 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_right_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = f() + 2;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y - 2, "$y");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 2}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x - $y <= 2}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_right_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = f() - 2;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y + 2, "$y");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 2}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$y - $x >= 2}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_plus_right_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() + 2, y = f() + 1;
|
|
|
|
clang_analyzer_denote(x - 2, "$x");
|
|
|
|
clang_analyzer_denote(y - 1, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 1}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$y - $x >= 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_minus_right_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() + 2, y = f() - 1;
|
|
|
|
clang_analyzer_denote(x - 2, "$x");
|
|
|
|
clang_analyzer_denote(y + 1, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 1}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$y - $x >= 3}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_plus_right_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() - 2, y = f() + 1;
|
|
|
|
clang_analyzer_denote(x + 2, "$x");
|
|
|
|
clang_analyzer_denote(y - 1, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 1}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x - $y <= 3}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_minus_right_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() - 2, y = f() - 1;
|
|
|
|
clang_analyzer_denote(x + 2, "$x");
|
|
|
|
clang_analyzer_denote(y + 1, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 1}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x - $y <= 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_less_or_equal_unsigned() {
|
|
|
|
unsigned x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_eval(x <= y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_int_less_or_equal_unsigned() {
|
|
|
|
unsigned x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x + 1U <= $x}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_int_less_or_equal_unsigned() {
|
|
|
|
unsigned x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x - 1U <= $x}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_right_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x <= $x + 1U}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_right_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x <= $x - 1U}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_plus_right_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_eval(x <= y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_minus_right_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x + 1U <= $x - 1U}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_plus_right_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(x <= y); // expected-warning {{$x - 1U <= $x + 1U}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_minus_right_int_less_or_equal_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_eval(x <= y); // expected-warning {{TRUE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_less_unsigned() {
|
|
|
|
unsigned x = f(), y = f();
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x - $y < 0}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() + 1, y = f();
|
|
|
|
clang_analyzer_denote(x - 1, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$y - $x > 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() - 1, y = f();
|
|
|
|
clang_analyzer_denote(x + 1, "$x");
|
|
|
|
clang_analyzer_denote(y, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x - $y < 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_right_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = f() + 2;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y - 2, "$y");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 2}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x - $y < 2}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_right_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = f() - 2;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_denote(y + 2, "$y");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 2}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$y - $x > 2}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_plus_right_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() + 2, y = f() + 1;
|
|
|
|
clang_analyzer_denote(x - 2, "$x");
|
|
|
|
clang_analyzer_denote(y - 1, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 1}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$y - $x > 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_plus_left_minus_right_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() + 2, y = f() - 1;
|
|
|
|
clang_analyzer_denote(x - 2, "$x");
|
|
|
|
clang_analyzer_denote(y + 1, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 1}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$y - $x > 3}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_plus_right_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() - 2, y = f() + 1;
|
|
|
|
clang_analyzer_denote(x + 2, "$x");
|
|
|
|
clang_analyzer_denote(y - 1, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y + 1}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x - $y < 3}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_different_symbol_minus_left_minus_right_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f() - 2, y = f() - 1;
|
|
|
|
clang_analyzer_denote(x + 2, "$x");
|
|
|
|
clang_analyzer_denote(y + 1, "$y");
|
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 2}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y - 1}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x - $y < 1}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_less_unsigned() {
|
|
|
|
unsigned x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_eval(x < y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_int_less_unsigned() {
|
|
|
|
unsigned x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x + 1U < $x}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_int_less_unsigned() {
|
|
|
|
unsigned x = f(), y = x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x - 1U < $x}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_right_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x < $x + 1U}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_right_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x < $x - 1U}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_plus_right_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_eval(x < y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_plus_left_minus_right_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
++x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x + 1U < $x - 1U}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_plus_right_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x + 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x + 1}}
|
|
|
|
clang_analyzer_express(x < y); // expected-warning {{$x - 1U < $x + 1U}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void compare_same_symbol_minus_left_minus_right_int_less_unsigned() {
|
2018-09-26 07:50:53 +08:00
|
|
|
unsigned x = f(), y = x - 1;
|
|
|
|
clang_analyzer_denote(x, "$x");
|
2018-04-11 14:21:12 +08:00
|
|
|
--x;
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_express(x); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$x - 1}}
|
|
|
|
clang_analyzer_eval(x < y); // expected-warning {{FALSE}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void overflow(signed char n, signed char m) {
|
|
|
|
if (n + 0 > m + 0) {
|
2018-09-26 07:50:53 +08:00
|
|
|
clang_analyzer_eval(n - 126 == m + 3); // expected-warning {{UNKNOWN}}
|
2018-04-11 14:21:12 +08:00
|
|
|
}
|
|
|
|
}
|
2018-04-14 04:23:02 +08:00
|
|
|
|
|
|
|
int mixed_integer_types(int x, int y) {
|
|
|
|
short a = x - 1U;
|
|
|
|
return a - y;
|
|
|
|
}
|
2018-11-30 18:37:44 +08:00
|
|
|
|
|
|
|
unsigned gu();
|
|
|
|
unsigned fu() {
|
|
|
|
unsigned x = gu();
|
|
|
|
// Assert that no overflows occur in this test file.
|
|
|
|
// Assuming that concrete integers are also within that range.
|
|
|
|
assert(x <= ((unsigned)UINT_MAX / 4));
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
void unsigned_concrete_int_no_crash() {
|
|
|
|
unsigned x = fu() + 1U, y = fu() + 1U;
|
|
|
|
clang_analyzer_denote(x - 1U, "$x");
|
|
|
|
clang_analyzer_denote(y - 1U, "$y");
|
|
|
|
clang_analyzer_express(y); // expected-warning {{$y}}
|
|
|
|
clang_analyzer_express(x == y); // expected-warning {{$x + 1U == $y + 1U}}
|
|
|
|
}
|