[ELF] Avoid make in elf::writeARMCmseImportLib
[llvm-project.git] / clang / test / Analysis / constraint-assignor.c
blob8210e576c98bd21cb3b41d03963c96b4d38c0e67
1 // RUN: %clang_analyze_cc1 %s \
2 // RUN: -analyzer-checker=core \
3 // RUN: -analyzer-checker=debug.ExprInspection \
4 // RUN: -verify
6 void clang_analyzer_warnIfReached(void);
7 void clang_analyzer_eval(int);
9 void rem_constant_rhs_ne_zero(int x, int y) {
10 if (x % 3 == 0) // x % 3 != 0 -> x != 0
11 return;
12 if (x * y != 0) // x * y == 0
13 return;
14 if (y != 1) // y == 1 -> x == 0
15 return;
16 clang_analyzer_warnIfReached(); // no-warning
17 (void)x; // keep the constraints alive.
20 void rem_symbolic_rhs_ne_zero(int x, int y, int z) {
21 if (x % z == 0) // x % z != 0 -> x != 0
22 return;
23 if (x * y != 0) // x * y == 0
24 return;
25 if (y != 1) // y == 1 -> x == 0
26 return;
27 clang_analyzer_warnIfReached(); // no-warning
28 (void)x; // keep the constraints alive.
31 void rem_symbolic_rhs_ne_zero_nested(int w, int x, int y, int z) {
32 if (w % x % z == 0) // w % x % z != 0 -> w % x != 0
33 return;
34 if (w % x * y != 0) // w % x * y == 0
35 return;
36 if (y != 1) // y == 1 -> w % x == 0
37 return;
38 clang_analyzer_warnIfReached(); // no-warning
39 (void)(w * x); // keep the constraints alive.
42 void rem_constant_rhs_ne_zero_early_contradiction(int x, int y) {
43 if ((x + y) != 0) // (x + y) == 0
44 return;
45 if ((x + y) % 3 == 0) // (x + y) % 3 != 0 -> (x + y) != 0 -> contradiction
46 return;
47 clang_analyzer_warnIfReached(); // no-warning
48 (void)x; // keep the constraints alive.
51 void rem_symbolic_rhs_ne_zero_early_contradiction(int x, int y, int z) {
52 if ((x + y) != 0) // (x + y) == 0
53 return;
54 if ((x + y) % z == 0) // (x + y) % z != 0 -> (x + y) != 0 -> contradiction
55 return;
56 clang_analyzer_warnIfReached(); // no-warning
57 (void)x; // keep the constraints alive.
60 void internal_unsigned_signed_mismatch(unsigned a) {
61 int d = a;
62 // Implicit casts are not handled, thus the analyzer models `d % 2` as
63 // `(reg_$0<unsigned int a>) % 2`
64 // However, this should not result in internal signedness mismatch error when
65 // we assign new constraints below.
66 if (d % 2 != 0)
67 return;
70 void remainder_with_adjustment(int x) {
71 if ((x + 1) % 3 == 0) // (x + 1) % 3 != 0 -> x + 1 != 0 -> x != -1
72 return;
73 clang_analyzer_eval(x + 1 != 0); // expected-warning{{TRUE}}
74 clang_analyzer_eval(x != -1); // expected-warning{{TRUE}}
75 (void)x; // keep the constraints alive.
78 void remainder_with_adjustment_of_composit_lhs(int x, int y) {
79 if ((x + y + 1) % 3 == 0) // (x + 1) % 3 != 0 -> x + 1 != 0 -> x != -1
80 return;
81 clang_analyzer_eval(x + y + 1 != 0); // expected-warning{{TRUE}}
82 clang_analyzer_eval(x + y != -1); // expected-warning{{TRUE}}
83 (void)(x * y); // keep the constraints alive.