You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[clang][analyzer] Improve bug reports of StdLibraryFunctionsChecker.
Add an additional explanation of what is wrong if a constraint is
not satisfied, in some cases.
Additionally the bug report generation is changed to use raw_ostream.
Reviewed By: Szelethus, NoQ
Differential Revision: https://reviews.llvm.org/D144003
Copy file name to clipboardExpand all lines: clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ int clang_analyzer_getExtent(void *);
19
19
// Check NotNullConstraint assumption notes.
20
20
int__not_null(int *);
21
21
inttest_not_null_note(int *x, int y) {
22
-
__not_null(x); // expected-note{{Assuming the 1st argument to '__not_null' is not NULL}}
22
+
__not_null(x); // expected-note{{Assuming that the 1st argument to '__not_null' is not NULL}}
23
23
if (x) // expected-note{{'x' is non-null}} \
24
24
// expected-note{{Taking true branch}}
25
25
if (!y) // expected-note{{Assuming 'y' is 0}} \
@@ -33,15 +33,15 @@ int test_not_null_note(int *x, int y) {
33
33
// Check the RangeConstraint assumption notes.
34
34
int__single_val_0(int); // [0, 0]
35
35
inttest_range_constraint_note(int x, int y) {
36
-
__single_val_0(x); // expected-note{{Assuming the 1st argument to '__single_val_0' is zero}}
36
+
__single_val_0(x); // expected-note{{Assuming that the 1st argument to '__single_val_0' is zero}}
37
37
return y / x; // expected-warning{{Division by zero}} \
38
38
// expected-note{{Division by zero}}
39
39
}
40
40
41
41
// Check the BufferSizeConstraint assumption notes.
42
42
int__buf_size_arg_constraint_concrete(constvoid *buf); // size of buf must be >= 10
43
43
voidtest_buffer_size_note(char *buf, int y) {
44
-
__buf_size_arg_constraint_concrete(buf); // expected-note {{Assuming the size of the 1st argument to '__buf_size_arg_constraint_concrete' is equal to or greater than 10}}
44
+
__buf_size_arg_constraint_concrete(buf); // expected-note {{Assuming that the 1st argument to '__buf_size_arg_constraint_concrete' is a buffer with size equal to or greater than 10}}
// expected-warning{{The size of the 1st argument to '__buf_size_arg_constraint_concrete' should be equal to or greater than 10}}
31
+
// expected-warning{{The 1st argument to '__buf_size_arg_constraint_concrete' is out of the accepted range; It should be a buffer with size equal to or greater than 10 [}}
32
32
break;
33
33
}
34
34
case2: {
35
35
char buf[3];
36
36
__buf_size_arg_constraint(buf, 4); // \
37
-
// expected-warning{{The size of the 1st argument to '__buf_size_arg_constraint' should be equal to or greater than the value of the 2nd argument}}
37
+
// expected-warning{{The 1st argument to '__buf_size_arg_constraint' is out of the accepted range; It should be a buffer with size equal to or greater than the value of the 2nd argument}}
38
38
break;
39
39
}
40
40
case3: {
41
41
char buf[3];
42
42
__buf_size_arg_constraint_mul(buf, 4, 2); // \
43
-
// expected-warning{{The size of the 1st argument to '__buf_size_arg_constraint_mul' should be equal to or greater than the value of the 2nd argument times the 3rd argument}}
43
+
// expected-warning{{The 1st argument to '__buf_size_arg_constraint_mul' is out of the accepted range; It should be a buffer with size equal to or greater than the value of the 2nd argument times the 3rd argument}}
44
44
break;
45
45
}
46
46
}
@@ -78,109 +78,160 @@ int __range_out_minf_1(int); // [-inf, 1]
// bugpath-warning{{The size of the 1st argument to '__buf_size_arg_constraint' should be equal to or greater than the value of the 2nd argument}} \
20
-
// bugpath-note{{The size of the 1st argument to '__buf_size_arg_constraint' should be equal to or greater than the value of the 2nd argument}}
19
+
// bugpath-warning{{The 1st argument to '__buf_size_arg_constraint' is out of the accepted range; It should be a buffer with size equal to or greater than the value of the 2nd argument}} \
20
+
// bugpath-note{{The 1st argument to '__buf_size_arg_constraint' is out of the accepted range; It should be a buffer with size equal to or greater than the value of the 2nd argument}}
// bugpath-warning{{The size of the 1st argument to '__buf_size_arg_constraint_mul' should be equal to or greater than the value of the 2nd argument times the 3rd argument}} \
30
-
// bugpath-note{{The size of the 1st argument to '__buf_size_arg_constraint_mul' should be equal to or greater than the value of the 2nd argument times the 3rd argument}}
29
+
// bugpath-warning{{The 1st argument to '__buf_size_arg_constraint_mul' is out of the accepted range; It should be a buffer with size equal to or greater than the value of the 2nd argument times the 3rd argument}} \
30
+
// bugpath-note{{The 1st argument to '__buf_size_arg_constraint_mul' is out of the accepted range; It should be a buffer with size equal to or greater than the value of the 2nd argument times the 3rd argument}}
0 commit comments