1 // RUN: %clang_cc1 -Wno-pointer-bool-conversion -analyze -analyzer-checker=core,debug.ExprInspection -verify %s
2 
3 void clang_analyzer_eval(int);
4 
testAnd(int i,int * p)5 void testAnd(int i, int *p) {
6   int *nullP = 0;
7   int *knownP = &i;
8   clang_analyzer_eval((knownP && knownP) == 1); // expected-warning{{TRUE}}
9   clang_analyzer_eval((knownP && nullP) == 0); // expected-warning{{TRUE}}
10   clang_analyzer_eval((knownP && p) == 1); // expected-warning{{UNKNOWN}}
11 }
12 
testOr(int i,int * p)13 void testOr(int i, int *p) {
14   int *nullP = 0;
15   int *knownP = &i;
16   clang_analyzer_eval((nullP || knownP) == 1); // expected-warning{{TRUE}}
17   clang_analyzer_eval((nullP || nullP) == 0); // expected-warning{{TRUE}}
18   clang_analyzer_eval((nullP || p) == 1); // expected-warning{{UNKNOWN}}
19 }
20 
21 
22 // PR13461
testTypeIsInt(int i,void * p)23 int testTypeIsInt(int i, void *p) {
24   if (i | (p && p))
25     return 1;
26   return 0;
27 }
28 
29 // These crashed the analyzer at some point.
between(char * x)30 int between(char *x) {
31   extern char start[];
32   extern char end[];
33   return x >= start && x < end;
34 }
35 
undef(void)36 int undef(void) {} // expected-warning{{control reaches end of non-void function}}
useUndef(void)37 void useUndef(void) { 0 || undef(); }
38 
testPointer(void)39 void testPointer(void) { (void) (1 && testPointer && 0); }
40