[CodeGenPrepare] Drop nsw flags in `optimizeLoadExt` (#118180)
[llvm-project.git] / clang / test / SemaCXX / warn-unsafe-buffer-usage-source-ranges.cpp
blobfe3a95269655756de6e35ff4d8dcff9b84539099
1 // RUN: %clang_cc1 -Wno-everything -Wunsafe-buffer-usage \
2 // RUN: -fsafe-buffer-usage-suggestions \
3 // RUN: -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s
5 void foo(int i) {
6 int * ptr;
8 ptr++;
9 // CHECK: {[[@LINE-1]]:3-[[@LINE-1]]:6}
10 ptr--;
11 // CHECK: {[[@LINE-1]]:3-[[@LINE-1]]:6}
12 ++ptr;
13 // CHECK: {[[@LINE-1]]:5-[[@LINE-1]]:8}
14 --ptr;
15 // CHECK: {[[@LINE-1]]:5-[[@LINE-1]]:8}
18 ptr + 1;
19 // CHECK: {[[@LINE-1]]:3-[[@LINE-1]]:6}
20 2 + ptr;
21 // CHECK: {[[@LINE-1]]:7-[[@LINE-1]]:10}
22 ptr + i;
23 // CHECK: {[[@LINE-1]]:3-[[@LINE-1]]:6}
24 i + ptr;
25 // CHECK: {[[@LINE-1]]:7-[[@LINE-1]]:10}
28 ptr - 3;
29 // CHECK: {[[@LINE-1]]:3-[[@LINE-1]]:6}
30 ptr - i;
31 // CHECK: {[[@LINE-1]]:3-[[@LINE-1]]:6}
34 ptr += 4;
35 // CHECK: {[[@LINE-1]]:3-[[@LINE-1]]:6}
36 ptr += i;
37 // CHECK: {[[@LINE-1]]:3-[[@LINE-1]]:6}
40 ptr -= 5;
41 // CHECK: {[[@LINE-1]]:3-[[@LINE-1]]:6}
42 ptr -= i;
43 // CHECK: {[[@LINE-1]]:3-[[@LINE-1]]:6}
46 ptr[5];
47 // CHECK: {[[@LINE-1]]:3-[[@LINE-1]]:6}
48 5[ptr];
49 // CHECK: {[[@LINE-1]]:5-[[@LINE-1]]:8}