[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Analysis / logical-ops.c
blobbe68569fcd8e5109307bb235f56695eea8a71dff
1 // RUN: %clang_analyze_cc1 -w -analyzer-checker=core,debug.ExprInspection\
2 // RUN: -analyzer-config eagerly-assume=false -verify %s
4 void clang_analyzer_eval(int);
6 void testAnd(int i, int *p) {
7 int *nullP = 0;
8 int *knownP = &i;
9 clang_analyzer_eval((knownP && knownP) == 1); // expected-warning{{TRUE}}
10 clang_analyzer_eval((knownP && nullP) == 0); // expected-warning{{TRUE}}
11 clang_analyzer_eval((knownP && p) == 1); // expected-warning{{UNKNOWN}}
14 void testOr(int i, int *p) {
15 int *nullP = 0;
16 int *knownP = &i;
17 clang_analyzer_eval((nullP || knownP) == 1); // expected-warning{{TRUE}}
18 clang_analyzer_eval((nullP || nullP) == 0); // expected-warning{{TRUE}}
19 clang_analyzer_eval((nullP || p) == 1); // expected-warning{{UNKNOWN}}
23 // PR13461
24 int testTypeIsInt(int i, void *p) {
25 if (i | (p && p))
26 return 1;
27 return 0;
30 // These crashed the analyzer at some point.
31 int between(char *x) {
32 extern char start[];
33 extern char end[];
34 return x >= start && x < end;
37 int undef(void) {}
38 void useUndef(void) { 0 || undef(); }
40 void testPointer(void) { (void) (1 && testPointer && 0); }
42 char *global_ap, *global_bp, *global_cp;
43 void ambiguous_backtrack_1(void) {
44 for (;;) {
45 (global_bp - global_ap ? global_cp[global_bp - global_ap] : 0) || 1;
46 global_bp++;
50 int global_a, global_b;
51 void ambiguous_backtrack_2(int x) {
52 global_a = x >= 2 ? 1 : x;
53 global_b == x && 9 || 2;