1 // RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage \
2 // RUN: -fsafe-buffer-usage-suggestions \
3 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
5 void safe_array_assigned_to_safe_ptr(unsigned idx
) {
7 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
9 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
11 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
14 void safe_array_assigned_to_unsafe_ptr(unsigned idx
) {
16 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
18 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:7}:"std::span<int>"
20 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
24 void unsafe_array_assigned_to_safe_ptr(unsigned idx
) {
26 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:17}:"std::array<int, 10> buffer"
28 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
30 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:15-[[@LINE-1]]:15}:".data()"
34 // FIXME: Implement fixit/s for this case.
35 // See comment in CArrayToPtrAssignmentGadget::getFixits to learn why this hasn't been implemented.
36 void unsafe_array_assigned_to_unsafe_ptr(unsigned idx
) {
38 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:{{.*}}
40 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:{{.*}}
42 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:{{.*}}