1 // RUN: %clang_analyze_cc1 %s \
2 // RUN: -analyzer-checker=core \
3 // RUN: -analyzer-checker=debug.ExprInspection \
4 // RUN: -analyzer-config eagerly-assume=false \
7 // Here we test that if it turns out that the parent state is infeasible then
8 // both children States (more precisely the ExplodedNodes) are marked as a
10 // We rely on existing defects of the underlying constraint solver. However,
11 // in the future we might strengthen the solver to discover the infeasibility
12 // right when we create the parent state. At that point some of these tests
13 // will fail, and either we shall find another solver weakness to have the test
14 // case functioning, or we shall simply remove that.
16 void clang_analyzer_warnIfReached();
17 void clang_analyzer_eval(int);
25 // { x^2 == 4 and x:[0,1] }
26 // This state is already infeasible.
28 // Perfectly constraining 'x' will trigger constant folding,
29 // when we realize we were already infeasible.
30 // The same happens for the 'else' branch.
32 clang_analyzer_warnIfReached(); // no-warning
34 clang_analyzer_warnIfReached(); // no-warning
36 clang_analyzer_warnIfReached(); // no-warning
56 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
58 /* The BASELINE passes these checks ('wrning' is used to avoid lit to match)
59 // The parent state is already infeasible, look at this contradiction:
60 clang_analyzer_eval(b > 0); // expected-wrning{{FALSE}}
61 clang_analyzer_eval(b <= 0); // expected-wrning{{FALSE}}
62 // Crashes with expensive checks.
64 clang_analyzer_warnIfReached(); // no-warning, OK
67 // Should not be reachable.
68 clang_analyzer_warnIfReached(); // expected-wrning{{REACHABLE}}
71 // The parent state is already infeasible, but we realize that only if b is
73 clang_analyzer_eval(b
> 0); // expected-warning{{UNKNOWN}}
74 clang_analyzer_eval(b
<= 0); // expected-warning{{UNKNOWN}}
76 clang_analyzer_warnIfReached(); // no-warning
79 clang_analyzer_warnIfReached(); // no-warning