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
[-Wunsafe-buffer-usage] Use Strategy to determine whether to fix a parameter
- Use Strategy to determine whether to fix a parameter
- Fix the `Strategy` construction so that only variables on the graph
are assigned the `std::span` strategy
Reviewed by: t-rasmud (Rashmi Mudduluru), NoQ (Artem Dergachev)
Differential revision: https://reviews.llvm.org/D157441
int * x; // expected-warning{{'x' is an unsafe pointer used for buffer access}} \
75
-
expected-note{{change type of 'x' to 'std::span' to preserve bounds information, and change 'p', 'z', and 'r' to safe types to make function 'multiParmLocalAllFix' bounds-safe}}
int * z; // expected-warning{{'z' is an unsafe pointer used for buffer access}} \
78
-
expected-note{{change type of 'z' to 'std::span' to preserve bounds information, and change 'x', 'p', and 'r' to safe types to make function 'multiParmLocalAllFix' bounds-safe}}
71
+
// CHECK-NOT: fix-it:{{.*}}:{[[@LINE-1]]:
72
+
// CHECK-NOT: fix-it:{{.*}}:{[[@LINE+1]]:
73
+
int * x; // expected-warning{{'x' is an unsafe pointer used for buffer access}}
74
+
// CHECK-NOT: fix-it:{{.*}}:{[[@LINE+1]]:
75
+
int * z; // expected-warning{{'z' is an unsafe pointer used for buffer access}}
79
76
int * y;
80
77
81
78
x = p;
82
-
y = x;
79
+
y = x;// FIXME: we do not fix `y = x` here as the `.data()` fix-it is not generally correct
83
80
// `x` needs to be fixed so does the pointer assigned to `x`, i.e.,`p`
84
81
x[5] = 5; // expected-note{{used in buffer access here}}
voidmultiParmLocalAllFix2(int *p, int * r) { // expected-warning{{'p' is an unsafe pointer used for buffer access}} \
99
-
expected-note{{change type of 'p' to 'std::span' to preserve bounds information, and change 'x', 'r', and 'z' to safe types to make function 'multiParmLocalAllFix2' bounds-safe}} \
100
-
expected-warning{{'r' is an unsafe pointer used for buffer access}} \
101
-
expected-note{{change type of 'r' to 'std::span' to preserve bounds information, and change 'p', 'x', and 'z' to safe types to make function 'multiParmLocalAllFix2' bounds-safe}}
95
+
expected-warning{{'r' is an unsafe pointer used for buffer access}}
Copy file name to clipboardExpand all lines: clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-ptr-init.cpp
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -27,17 +27,17 @@ void rhs_span3() {
27
27
int *q = newint[6];
28
28
int *p = q; // expected-warning{{'p' is an unsafe pointer used for buffer access}}
29
29
p[5] = 10; // expected-note{{used in buffer access here}}
30
-
int *r = q;
30
+
int *r = q;// FIXME: we do not fix `int *r = q` here as the `.data()` fix-it is not generally correct
31
31
}
32
32
33
33
voidtest_grouping() {
34
34
int *z = newint[8];
35
35
int tmp;
36
-
int *y = newint[10]; // expected-warning{{'y' is an unsafe pointer used for buffer access}} expected-note{{change type of 'y' to 'std::span' to preserve bounds information}}
36
+
int *y = newint[10]; // expected-warning{{'y' is an unsafe pointer used for buffer access}}
37
37
tmp = y[5]; // expected-note{{used in buffer access here}}
38
38
39
39
int *x = newint[10];
40
-
x = y;
40
+
x = y;// FIXME: we do not fix `x = y` here as the `.data()` fix-it is not generally correct
0 commit comments