@@ -83,12 +83,27 @@ void unsafe_method_invocation_single_param() {
83
83
84
84
}
85
85
86
+ void unsafe_method_invocation_single_param_array () {
87
+ int p[32 ];
88
+ // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"std::array<int, 32> p"
89
+
90
+ int tmp = p[5 ];
91
+ foo (p);
92
+ // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:8-[[@LINE-1]]:8}:".data()"
93
+ }
94
+
86
95
void safe_method_invocation_single_param () {
87
96
int * p = new int [10 ];
88
97
// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:{{.*}}-[[@LINE-1]]:{{.*}}}
89
98
foo (p);
90
99
}
91
100
101
+ void safe_method_invocation_single_param_array () {
102
+ int p[10 ];
103
+ foo (p);
104
+ // CHECK-NO: fix-it:"{{.*}}":{[[@LINE-1]]:{{.*}}-[[@LINE-1]]:{{.*}}}:".data()"
105
+ }
106
+
92
107
void unsafe_method_invocation_double_param () {
93
108
int * p = new int [10 ];
94
109
// CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:11}:"std::span<int> p"
@@ -111,6 +126,20 @@ void unsafe_method_invocation_double_param() {
111
126
m1 (q, q, 8 );
112
127
}
113
128
129
+ void unsafe_method_invocation_double_param_array () {
130
+ int p[14 ];
131
+ // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"std::array<int, 14> p"
132
+
133
+ int q[40 ];
134
+ // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"std::array<int, 40> q"
135
+
136
+ q[5 ] = p[5 ];
137
+
138
+ m1 (p, p, 10 );
139
+ // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:7}:".data()"
140
+ // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:".data()"
141
+ }
142
+
114
143
void unsafe_access_in_lamda () {
115
144
int * p = new int [10 ];
116
145
// CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:11}:"std::span<int> p"
@@ -177,4 +206,23 @@ void fixits_in_lambda_capture_rename() {
177
206
};
178
207
179
208
p[5 ] = 10 ;
180
- }
209
+ }
210
+
211
+ bool ptr_comparison (int * ptr, unsigned idx) {
212
+ int arr[10 ];
213
+ // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:14}:"std::array<int, 10> arr"
214
+ arr[idx] = idx;
215
+
216
+ return arr > ptr;
217
+ // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:".data()"
218
+ }
219
+
220
+ int long long ptr_distance (int * ptr, unsigned idx) {
221
+ int arr[10 ];
222
+ // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:14}:"std::array<int, 10> arr"
223
+ arr[idx] = idx;
224
+
225
+ int long long dist = arr - ptr;
226
+ // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:27-[[@LINE-1]]:27}:".data()"
227
+ return dist;
228
+ }
0 commit comments