Gabor Marton | 94061df | 2020-03-20 16:20:53 +0100 | [diff] [blame^] | 1 | // Check the basic reporting/warning and the application of constraints. |
| 2 | // RUN: %clang_analyze_cc1 %s \ |
| 3 | // RUN: -analyzer-checker=core \ |
| 4 | // RUN: -analyzer-checker=apiModeling.StdCLibraryFunctions \ |
| 5 | // RUN: -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \ |
| 6 | // RUN: -analyzer-checker=debug.ExprInspection \ |
| 7 | // RUN: -triple x86_64-unknown-linux-gnu \ |
| 8 | // RUN: -verify=report |
| 9 | |
| 10 | // Check the bugpath related to the reports. |
| 11 | // RUN: %clang_analyze_cc1 %s \ |
| 12 | // RUN: -analyzer-checker=core \ |
| 13 | // RUN: -analyzer-checker=apiModeling.StdCLibraryFunctions \ |
| 14 | // RUN: -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \ |
| 15 | // RUN: -analyzer-checker=debug.ExprInspection \ |
| 16 | // RUN: -triple x86_64-unknown-linux-gnu \ |
| 17 | // RUN: -analyzer-output=text \ |
| 18 | // RUN: -verify=bugpath |
| 19 | |
| 20 | void clang_analyzer_eval(int); |
| 21 | |
| 22 | int glob; |
| 23 | |
| 24 | #define EOF -1 |
| 25 | |
| 26 | int isalnum(int); |
| 27 | |
| 28 | void test_alnum_concrete(int v) { |
| 29 | int ret = isalnum(256); // \ |
| 30 | // report-warning{{Function argument constraint is not satisfied}} \ |
| 31 | // bugpath-warning{{Function argument constraint is not satisfied}} \ |
| 32 | // bugpath-note{{Function argument constraint is not satisfied}} |
| 33 | (void)ret; |
| 34 | } |
| 35 | |
| 36 | void test_alnum_symbolic(int x) { |
| 37 | int ret = isalnum(x); |
| 38 | (void)ret; |
| 39 | |
| 40 | clang_analyzer_eval(EOF <= x && x <= 255); // \ |
| 41 | // report-warning{{TRUE}} \ |
| 42 | // bugpath-warning{{TRUE}} \ |
| 43 | // bugpath-note{{TRUE}} \ |
| 44 | // bugpath-note{{Left side of '&&' is true}} \ |
| 45 | // bugpath-note{{'x' is <= 255}} |
| 46 | |
| 47 | } |
| 48 | |
| 49 | void test_alnum_symbolic2(int x) { |
| 50 | if (x > 255) { // \ |
| 51 | // bugpath-note{{Assuming 'x' is > 255}} \ |
| 52 | // bugpath-note{{Taking true branch}} |
| 53 | |
| 54 | int ret = isalnum(x); // \ |
| 55 | // report-warning{{Function argument constraint is not satisfied}} \ |
| 56 | // bugpath-warning{{Function argument constraint is not satisfied}} \ |
| 57 | // bugpath-note{{Function argument constraint is not satisfied}} |
| 58 | |
| 59 | (void)ret; |
| 60 | } |
| 61 | } |