|
1 |
| -// RUN: %check_clang_tidy -std=c++20 %s modernize-use-ranges %t -- -- -I %S/Inputs/use-ranges/ |
2 |
| -// RUN: %check_clang_tidy -std=c++23 %s modernize-use-ranges %t -check-suffixes=,CPP23 -- -I %S/Inputs/use-ranges/ |
| 1 | +// RUN: %check_clang_tidy -std=c++20 %s modernize-use-ranges %t -- -- -I %S/Inputs/ |
| 2 | +// RUN: %check_clang_tidy -std=c++23 %s modernize-use-ranges %t -check-suffixes=,CPP23 -- -I %S/Inputs/ |
| 3 | +// Example: ./check_clang_tidy.py -std=c++20 checkers/modernize/use-ranges.cpp modernize-use-ranges temp.txt -- -- -I ~/llvm-project/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/ |
3 | 4 |
|
4 | 5 | // CHECK-FIXES: #include <algorithm>
|
5 | 6 | // CHECK-FIXES-CPP23: #include <numeric>
|
6 | 7 | // CHECK-FIXES: #include <ranges>
|
7 | 8 |
|
8 |
| -#include "fake_std.h" |
| 9 | +#include "use-ranges/fake_std.h" |
| 10 | +#include "smart-ptr/unique_ptr.h" |
9 | 11 |
|
10 | 12 | void Positives() {
|
11 | 13 | std::vector<int> I, J;
|
| 14 | + std::vector<std::unique_ptr<int>> K; |
| 15 | + |
| 16 | + // Expect to have no check messages |
| 17 | + std::find(K.begin(), K.end(), nullptr); |
| 18 | + |
| 19 | + std::find(K.begin(), K.end(), std::unique_ptr<int>()); |
| 20 | + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a ranges version of this algorithm |
| 21 | + // CHECK-FIXES: std::ranges::find(K, std::unique_ptr<int>()); |
| 22 | + |
12 | 23 | std::find(I.begin(), I.end(), 0);
|
13 | 24 | // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a ranges version of this algorithm
|
14 | 25 | // CHECK-FIXES: std::ranges::find(I, 0);
|
@@ -76,6 +87,15 @@ void Positives() {
|
76 | 87 |
|
77 | 88 | void Reverse(){
|
78 | 89 | std::vector<int> I, J;
|
| 90 | + std::vector<std::unique_ptr<int>> K; |
| 91 | + |
| 92 | + // Expect to have no check messages |
| 93 | + std::find(K.rbegin(), K.rend(), nullptr); |
| 94 | + |
| 95 | + std::find(K.rbegin(), K.rend(), std::unique_ptr<int>()); |
| 96 | + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a ranges version of this algorithm |
| 97 | + // CHECK-FIXES: std::ranges::find(std::ranges::reverse_view(K), std::unique_ptr<int>()); |
| 98 | + |
79 | 99 | std::find(I.rbegin(), I.rend(), 0);
|
80 | 100 | // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a ranges version of this algorithm
|
81 | 101 | // CHECK-FIXES: std::ranges::find(std::ranges::reverse_view(I), 0);
|
|
0 commit comments