[X86] Move getGFNICtrlMask before CTLZ/CTTZ lowering. NFC.
[llvm-project.git] / clang / test / SemaCXX / warn-unsafe-buffer-usage-fixits-array-assign-to-ptr.cpp
blob5764ffabcf4ae8aad0d004dfdec7a6d5d1a4179e
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) {
6 int buffer[10];
7 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
8 int* ptr;
9 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
10 ptr = buffer;
11 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
14 void safe_array_assigned_to_unsafe_ptr(unsigned idx) {
15 int buffer[10];
16 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
17 int* ptr;
18 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:7}:"std::span<int>"
19 ptr = buffer;
20 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
21 ptr[idx] = 0;
24 void unsafe_array_assigned_to_safe_ptr(unsigned idx) {
25 int buffer[10];
26 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:17}:"std::array<int, 10> buffer"
27 int* ptr;
28 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
29 ptr = buffer;
30 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:15-[[@LINE-1]]:15}:".data()"
31 buffer[idx] = 0;
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) {
37 int buffer[10];
38 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:{{.*}}
39 int* ptr;
40 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:{{.*}}
41 ptr = buffer;
42 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:{{.*}}
43 buffer[idx] = 0;
44 ptr[idx] = 0;