blob: 07a9df9526fc8dbaa24587c64013e42ffac3b967 [file] [log] [blame]
Gabor Marton94061df2020-03-20 16:20:53 +01001// 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
20void clang_analyzer_eval(int);
21
22int glob;
23
24#define EOF -1
25
26int isalnum(int);
27
28void 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
36void 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
49void 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}