| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s |
| 2 |
// RUN: %clang_analyze_cc1 -triple i686-unknown-linux -analyzer-checker=core,unix.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s |
| 3 |
// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=core,unix.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s |
| 4 |
// RUN: %clang_analyze_cc1 -triple armv7-a15-linux -analyzer-checker=core,unix.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s |
| 5 |
// RUN: %clang_analyze_cc1 -triple thumbv7-a15-linux -analyzer-checker=core,unix.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s |
| 6 |
|
| 7 |
void clang_analyzer_eval(int); |
| 8 |
|
| 9 |
typedef struct FILE FILE; |
| 10 |
// Unorthodox EOF value. |
| 11 |
#define EOF (-2) |
| 12 |
|
| 13 |
int getc(FILE *); |
| 14 |
void test_getc(FILE *fp) { |
| 15 |
|
| 16 |
int x; |
| 17 |
while ((x = getc(fp)) != EOF) { |
| 18 |
clang_analyzer_eval(x > 255); // expected-warning{{FALSE}} |
| 19 |
clang_analyzer_eval(x >= 0); // expected-warning{{TRUE}} |
| 20 |
} |
| 21 |
|
| 22 |
int y = getc(fp); |
| 23 |
if (y < 0) { |
| 24 |
clang_analyzer_eval(y == -2); // expected-warning{{TRUE}} |
| 25 |
} |
| 26 |
} |