1 // RUN: %clang_analyze_cc1 -std=c++17 %s\
2 // RUN: -analyzer-checker=core,cplusplus,alpha.cplusplus.STLAlgorithmModeling,debug.DebugIteratorModeling,debug.ExprInspection\
3 // RUN: -analyzer-config aggressive-binary-operation-simplification=true\
4 // RUN: -analyzer-config alpha.cplusplus.STLAlgorithmModeling:AggressiveStdFindModeling=true\
5 // RUN: -verify
6
7 #include "Inputs/system-header-simulator-cxx.h"
8
9 void clang_analyzer_eval(bool);
10
11 template <typename Iterator>
12 long clang_analyzer_iterator_position(const Iterator&);
13
14 template <typename Iter> Iter return_any_iterator(const Iter &It);
15
test_find1(std::vector<int> V,int n)16 void test_find1(std::vector<int> V, int n) {
17 const auto i1 = return_any_iterator(V.begin());
18 const auto i2 = return_any_iterator(V.begin());
19
20 const auto i3 = std::find(i1, i2, n);
21
22 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
23
24 if (i3 != i2) {
25 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
26 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
27 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
28 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
29
30 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
31 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
32 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
33 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
34 }
35 }
36
test_find2(std::vector<int> V,int n)37 void test_find2(std::vector<int> V, int n) {
38 const auto i1 = return_any_iterator(V.begin());
39 const auto i2 = return_any_iterator(V.begin());
40
41 const auto i3 = std::find(std::execution::sequenced_policy(), i1, i2, n);
42
43 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
44
45 if (i3 != i2) {
46 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
47 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
48 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
49 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
50
51 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
52 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
53 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
54 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
55 }
56 }
57
odd(int i)58 bool odd(int i) { return i % 2; }
59
test_find_if1(std::vector<int> V)60 void test_find_if1(std::vector<int> V) {
61 const auto i1 = return_any_iterator(V.begin());
62 const auto i2 = return_any_iterator(V.begin());
63
64 const auto i3 = std::find_if(i1, i2, odd);
65
66 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
67
68 if (i3 != i2) {
69 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
70 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
71 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
72 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
73
74 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
75 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
76 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
77 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
78 }
79 }
80
test_find_if2(std::vector<int> V)81 void test_find_if2(std::vector<int> V) {
82 const auto i1 = return_any_iterator(V.begin());
83 const auto i2 = return_any_iterator(V.begin());
84
85 const auto i3 = std::find_if(std::execution::sequenced_policy(), i1, i2, odd);
86
87 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
88
89 if (i3 != i2) {
90 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
91 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
92 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
93 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
94
95 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
96 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
97 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
98 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
99 }
100 }
101
test_find_if_not1(std::vector<int> V)102 void test_find_if_not1(std::vector<int> V) {
103 const auto i1 = return_any_iterator(V.begin());
104 const auto i2 = return_any_iterator(V.begin());
105
106 const auto i3 = std::find_if_not(i1, i2, odd);
107
108 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
109
110 if (i3 != i2) {
111 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
112 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
113 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
114 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
115
116 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
117 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
118 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
119 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
120 }
121 }
122
test_find_if_not2(std::vector<int> V)123 void test_find_if_not2(std::vector<int> V) {
124 const auto i1 = return_any_iterator(V.begin());
125 const auto i2 = return_any_iterator(V.begin());
126
127 const auto i3 = std::find_if_not(std::execution::sequenced_policy(), i1, i2,
128 odd);
129
130 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
131
132 if (i3 != i2) {
133 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
134 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
135 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
136 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
137
138 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
139 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
140 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
141 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
142 }
143 }
144
test_find_first_of1(std::vector<int> V1,std::vector<int> V2)145 void test_find_first_of1(std::vector<int> V1, std::vector<int> V2) {
146 const auto i1 = return_any_iterator(V1.begin());
147 const auto i2 = return_any_iterator(V1.begin());
148 const auto i3 = return_any_iterator(V2.begin());
149 const auto i4 = return_any_iterator(V2.begin());
150
151 const auto i5 = std::find_first_of(i1, i2, i3, i4);
152
153 clang_analyzer_eval(i5 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
154
155 if (i5 != i2) {
156 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
157 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
158 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
159 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
160
161 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
162 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
163 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
164 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
165 }
166 }
167
test_find_first_of2(std::vector<int> V1,std::vector<int> V2)168 void test_find_first_of2(std::vector<int> V1, std::vector<int> V2) {
169 const auto i1 = return_any_iterator(V1.begin());
170 const auto i2 = return_any_iterator(V1.begin());
171 const auto i3 = return_any_iterator(V2.begin());
172 const auto i4 = return_any_iterator(V2.begin());
173
174 const auto i5 = std::find_first_of(std::execution::sequenced_policy(),
175 i1, i2, i3, i4);
176
177 clang_analyzer_eval(i5 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
178
179 if (i5 != i2) {
180 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
181 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
182 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
183 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
184
185 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
186 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
187 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
188 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
189 }
190 }
191
test_find_first_of3(std::vector<int> V1,std::vector<int> V2)192 void test_find_first_of3(std::vector<int> V1, std::vector<int> V2) {
193 const auto i1 = return_any_iterator(V1.begin());
194 const auto i2 = return_any_iterator(V1.begin());
195 const auto i3 = return_any_iterator(V2.begin());
196 const auto i4 = return_any_iterator(V2.begin());
197
198 const auto i5 = std::find_first_of(i1, i2, i3, i4, odd);
199
200 clang_analyzer_eval(i5 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
201
202 if (i5 != i2) {
203 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
204 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
205 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
206 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
207
208 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
209 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
210 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
211 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
212 }
213 }
214
test_find_first_of4(std::vector<int> V1,std::vector<int> V2)215 void test_find_first_of4(std::vector<int> V1, std::vector<int> V2) {
216 const auto i1 = return_any_iterator(V1.begin());
217 const auto i2 = return_any_iterator(V1.begin());
218 const auto i3 = return_any_iterator(V2.begin());
219 const auto i4 = return_any_iterator(V2.begin());
220
221 const auto i5 = std::find_first_of(std::execution::sequenced_policy(),
222 i1, i2, i3, i4, odd);
223
224 clang_analyzer_eval(i5 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
225
226 if (i5 != i2) {
227 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
228 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
229 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
230 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
231
232 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
233 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
234 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
235 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
236 }
237 }
238
test_find_end1(std::vector<int> V1,std::vector<int> V2)239 void test_find_end1(std::vector<int> V1, std::vector<int> V2) {
240 const auto i1 = return_any_iterator(V1.begin());
241 const auto i2 = return_any_iterator(V1.begin());
242 const auto i3 = return_any_iterator(V2.begin());
243 const auto i4 = return_any_iterator(V2.begin());
244
245 const auto i5 = std::find_end(i1, i2, i3, i4);
246
247 clang_analyzer_eval(i5 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
248
249 if (i5 != i2) {
250 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
251 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
252 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
253 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
254
255 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
256 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
257 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
258 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
259 }
260 }
261
test_find_end2(std::vector<int> V1,std::vector<int> V2)262 void test_find_end2(std::vector<int> V1, std::vector<int> V2) {
263 const auto i1 = return_any_iterator(V1.begin());
264 const auto i2 = return_any_iterator(V1.begin());
265 const auto i3 = return_any_iterator(V2.begin());
266 const auto i4 = return_any_iterator(V2.begin());
267
268 const auto i5 = std::find_end(std::execution::sequenced_policy(),
269 i1, i2, i3, i4);
270
271 clang_analyzer_eval(i5 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
272
273 if (i5 != i2) {
274 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
275 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
276 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
277 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
278
279 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
280 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
281 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
282 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
283 }
284 }
285
test_find_end3(std::vector<int> V1,std::vector<int> V2)286 void test_find_end3(std::vector<int> V1, std::vector<int> V2) {
287 const auto i1 = return_any_iterator(V1.begin());
288 const auto i2 = return_any_iterator(V1.begin());
289 const auto i3 = return_any_iterator(V2.begin());
290 const auto i4 = return_any_iterator(V2.begin());
291
292 const auto i5 = std::find_end(i1, i2, i3, i4, odd);
293
294 clang_analyzer_eval(i5 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
295
296 if (i5 != i2) {
297 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
298 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
299 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
300 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
301
302 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
303 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
304 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
305 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
306 }
307 }
308
test_find_end4(std::vector<int> V1,std::vector<int> V2)309 void test_find_end4(std::vector<int> V1, std::vector<int> V2) {
310 const auto i1 = return_any_iterator(V1.begin());
311 const auto i2 = return_any_iterator(V1.begin());
312 const auto i3 = return_any_iterator(V2.begin());
313 const auto i4 = return_any_iterator(V2.begin());
314
315 const auto i5 = std::find_end(std::execution::sequenced_policy(),
316 i1, i2, i3, i4, odd);
317
318 clang_analyzer_eval(i5 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
319
320 if (i5 != i2) {
321 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
322 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
323 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
324 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
325
326 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
327 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
328 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
329 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
330 }
331 }
332
333 bool compare(int, int);
334
test_lower_bound1(std::vector<int> V,int n)335 void test_lower_bound1(std::vector<int> V, int n) {
336 const auto i1 = return_any_iterator(V.begin());
337 const auto i2 = return_any_iterator(V.begin());
338
339 const auto i3 = std::lower_bound(i1, i2, n);
340
341 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
342
343 if (i3 != i2) {
344 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
345 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
346 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
347 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
348
349 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
350 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
351 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
352 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
353 }
354 }
355
test_lower_bound2(std::vector<int> V,int n)356 void test_lower_bound2(std::vector<int> V, int n) {
357 const auto i1 = return_any_iterator(V.begin());
358 const auto i2 = return_any_iterator(V.begin());
359
360 const auto i3 = std::lower_bound(i1, i2, n, compare);
361
362 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
363
364 if (i3 != i2) {
365 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
366 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
367 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
368 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
369
370 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
371 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
372 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
373 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
374 }
375 }
376
test_upper_bound1(std::vector<int> V,int n)377 void test_upper_bound1(std::vector<int> V, int n) {
378 const auto i1 = return_any_iterator(V.begin());
379 const auto i2 = return_any_iterator(V.begin());
380
381 const auto i3 = std::upper_bound(i1, i2, n);
382
383 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
384
385 if (i3 != i2) {
386 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
387 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
388 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
389 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
390
391 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
392 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
393 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
394 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
395 }
396 }
397
test_upper_bound2(std::vector<int> V,int n)398 void test_upper_bound2(std::vector<int> V, int n) {
399 const auto i1 = return_any_iterator(V.begin());
400 const auto i2 = return_any_iterator(V.begin());
401
402 const auto i3 = std::upper_bound(i1, i2, n, compare);
403
404 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
405
406 if (i3 != i2) {
407 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
408 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
409 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
410 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
411
412 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
413 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
414 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
415 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
416 }
417 }
418
test_search1(std::vector<int> V1,std::vector<int> V2)419 void test_search1(std::vector<int> V1, std::vector<int> V2) {
420 const auto i1 = return_any_iterator(V1.begin());
421 const auto i2 = return_any_iterator(V1.begin());
422 const auto i3 = return_any_iterator(V2.begin());
423 const auto i4 = return_any_iterator(V2.begin());
424
425 const auto i5 = std::search(i1, i2, i3, i4);
426
427 clang_analyzer_eval(i5 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
428
429 if (i5 != i2) {
430 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
431 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
432 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
433 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
434
435 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
436 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
437 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
438 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
439 }
440 }
441
test_search2(std::vector<int> V1,std::vector<int> V2)442 void test_search2(std::vector<int> V1, std::vector<int> V2) {
443 const auto i1 = return_any_iterator(V1.begin());
444 const auto i2 = return_any_iterator(V1.begin());
445 const auto i3 = return_any_iterator(V2.begin());
446 const auto i4 = return_any_iterator(V2.begin());
447
448 const auto i5 = std::search(std::execution::sequenced_policy(),
449 i1, i2, i3, i4);
450
451 clang_analyzer_eval(i5 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
452
453 if (i5 != i2) {
454 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
455 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
456 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
457 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
458
459 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
460 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
461 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
462 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
463 }
464 }
465
test_search3(std::vector<int> V1,std::vector<int> V2)466 void test_search3(std::vector<int> V1, std::vector<int> V2) {
467 const auto i1 = return_any_iterator(V1.begin());
468 const auto i2 = return_any_iterator(V1.begin());
469 const auto i3 = return_any_iterator(V2.begin());
470 const auto i4 = return_any_iterator(V2.begin());
471
472 const auto i5 = std::search(i1, i2, i3, i4, odd);
473
474 clang_analyzer_eval(i5 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
475
476 if (i5 != i2) {
477 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
478 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
479 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
480 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
481
482 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
483 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
484 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
485 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
486 }
487 }
488
test_search4(std::vector<int> V1,std::vector<int> V2)489 void test_search4(std::vector<int> V1, std::vector<int> V2) {
490 const auto i1 = return_any_iterator(V1.begin());
491 const auto i2 = return_any_iterator(V1.begin());
492 const auto i3 = return_any_iterator(V2.begin());
493 const auto i4 = return_any_iterator(V2.begin());
494
495 const auto i5 = std::search(std::execution::sequenced_policy(),
496 i1, i2, i3, i4, odd);
497
498 clang_analyzer_eval(i5 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
499
500 if (i5 != i2) {
501 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
502 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
503 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
504 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
505
506 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
507 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
508 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
509 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
510 }
511 }
512
test_search5(std::vector<int> V1,std::vector<int> V2)513 void test_search5(std::vector<int> V1, std::vector<int> V2) {
514 const auto i1 = return_any_iterator(V1.begin());
515 const auto i2 = return_any_iterator(V1.begin());
516 const auto i3 = return_any_iterator(V2.begin());
517 const auto i4 = return_any_iterator(V2.begin());
518
519 const auto i5 = std::search(i1, i2, std::default_searcher(i3, i4));
520
521 clang_analyzer_eval(i5 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
522
523 if (i5 != i2) {
524 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
525 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
526 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
527 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
528
529 clang_analyzer_eval(clang_analyzer_iterator_position(i5) <
530 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
531 clang_analyzer_eval(clang_analyzer_iterator_position(i5) >=
532 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
533 }
534 }
535
test_search_n1(std::vector<int> V,int n)536 void test_search_n1(std::vector<int> V, int n) {
537 const auto i1 = return_any_iterator(V.begin());
538 const auto i2 = return_any_iterator(V.begin());
539
540 const auto i3 = std::search_n(i1, i2, 2, n);
541
542 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
543
544 if (i3 != i2) {
545 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
546 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
547 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
548 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
549
550 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
551 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
552 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
553 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
554 }
555 }
556
test_search_n2(std::vector<int> V,int n)557 void test_search_n2(std::vector<int> V, int n) {
558 const auto i1 = return_any_iterator(V.begin());
559 const auto i2 = return_any_iterator(V.begin());
560
561 const auto i3 = std::search_n(std::execution::sequenced_policy(),
562 i1, i2, 2, n);
563
564 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
565
566 if (i3 != i2) {
567 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
568 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
569 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
570 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
571
572 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
573 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
574 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
575 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
576 }
577 }
578
test_search_n3(std::vector<int> V,int n)579 void test_search_n3(std::vector<int> V, int n) {
580 const auto i1 = return_any_iterator(V.begin());
581 const auto i2 = return_any_iterator(V.begin());
582
583 const auto i3 = std::search_n(i1, i2, 2, n, compare);
584
585 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
586
587 if (i3 != i2) {
588 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
589 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
590 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
591 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
592
593 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
594 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
595 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
596 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
597 }
598 }
599
test_search_n4(std::vector<int> V,int n)600 void test_search_n4(std::vector<int> V, int n) {
601 const auto i1 = return_any_iterator(V.begin());
602 const auto i2 = return_any_iterator(V.begin());
603
604 const auto i3 = std::search_n(std::execution::sequenced_policy(),
605 i1, i2, 2, n, compare);
606
607 clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
608
609 if (i3 != i2) {
610 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
611 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{TRUE}}
612 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
613 clang_analyzer_iterator_position(i1)); // expected-warning@-1{{FALSE}}
614
615 clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
616 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
617 clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
618 clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
619 }
620 }
621