1 // Check the bugpath related to the reports.
2 // RUN: %clang_analyze_cc1 %s \
3 // RUN: -analyzer-checker=core \
4 // RUN: -analyzer-checker=alpha.unix.StdCLibraryFunctions \
5 // RUN: -analyzer-checker=debug.StdCLibraryFunctionsTester \
6 // RUN: -analyzer-checker=debug.ExprInspection \
7 // RUN: -triple x86_64-unknown-linux-gnu \
8 // RUN: -analyzer-output=text \
9 // RUN: -verify=bugpath
11 typedef typeof(sizeof(int)) size_t;
13 int __buf_size_arg_constraint(const void *, size_t);
14 void test_buf_size_concrete(void) {
15 char buf
[3]; // bugpath-note{{'buf' initialized here}}
16 int s
= 4; // bugpath-note{{'s' initialized to 4}}
17 __buf_size_arg_constraint(buf
, s
); // \
18 // bugpath-warning{{The 1st argument to '__buf_size_arg_constraint' is a buffer with size 3 but should be a buffer with size equal to or greater than the value of the 2nd argument}} \
19 // bugpath-note{{The 1st argument to '__buf_size_arg_constraint' is a buffer with size 3 but should be a buffer with size equal to or greater than the value of the 2nd argument}}
22 int __buf_size_arg_constraint_mul(const void *, size_t, size_t);
23 void test_buf_size_concrete_with_multiplication(void) {
24 short buf
[3]; // bugpath-note{{'buf' initialized here}}
25 int s1
= 4; // bugpath-note{{'s1' initialized to 4}}
26 int s2
= sizeof(short); // bugpath-note{{'s2' initialized to}}
27 __buf_size_arg_constraint_mul(buf
, s1
, s2
); // \
28 // bugpath-warning{{The 1st argument to '__buf_size_arg_constraint_mul' is a buffer with size 6 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 4) times the 3rd argument (which is 2)}} \
29 // bugpath-note{{The 1st argument to '__buf_size_arg_constraint_mul' is a buffer with size 6 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 4) times the 3rd argument (which is 2)}}