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] Make messages of StdCLibraryFunctionsChecker user-friendly
Warnings and notes of checker alpha.unix.StdLibraryFunctionArgs are
improved. Previously one warning and one note was emitted for every
finding, now one warning is emitted only that contains a detailed
description of the found issue.
Reviewed By: Szelethus
Differential Revision: https://reviews.llvm.org/D143194
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 is not NULL}}
22
+
__not_null(x); // expected-note{{Assuming 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 is within the range [0, 0]}}
36
+
__single_val_0(x); // expected-note{{Assuming 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 is equal to or greater than the value of 10}}
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}}
// expected-note{{The size of the 1st argument should be equal to or greater than the value of 10}} \
33
-
// expected-warning{{}}
31
+
// expected-warning{{The size of the 1st argument to '__buf_size_arg_constraint_concrete' should be equal to or greater than 10}}
34
32
break;
35
33
}
36
34
case2: {
37
35
char buf[3];
38
36
__buf_size_arg_constraint(buf, 4); // \
39
-
// expected-note{{The size of the 1st argument should be equal to or greater than the value of the 2nd arg}} \
40
-
// expected-warning{{}}
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}}
41
38
break;
42
39
}
43
40
case3: {
44
41
char buf[3];
45
42
__buf_size_arg_constraint_mul(buf, 4, 2); // \
46
-
// expected-note{{The size of the 1st argument should be equal to or greater than the value of the 2nd argument times the 3rd argument}} \
47
-
// expected-warning{{}}
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}}
48
44
break;
49
45
}
50
46
}
51
47
}
52
48
53
49
// Check the RangeConstraint violation notes.
54
-
int__single_val_1(int); // [1, 1]
55
-
int__range_1_2(int); // [1, 2]
56
-
int__range_1_2__4_5(int); // [1, 2], [4, 5]
57
-
voidtest_range(int x) {
58
-
__single_val_1(2); // \
59
-
// expected-note{{The 1st argument should be within the range [1, 1]}} \
60
-
// expected-warning{{}}
61
-
}
62
-
// Do more specific check against the range strings.
// bugpath-warning{{Function argument constraint is not satisfied}} \
31
-
// bugpath-note{{}} \
32
-
// bugpath-note{{Function argument constraint is not satisfied}}
29
+
// 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}}
0 commit comments