1 // RUN: %check_clang_tidy %s modernize-replace-random-shuffle %t
2 
3 //CHECK-FIXES: #include <random>
4 
5 namespace std {
6 template <typename T> struct vec_iterator {
7   T *ptr;
8   vec_iterator operator++(int);
9 };
10 
11 template <typename T> struct vector {
12   typedef vec_iterator<T> iterator;
13 
14   iterator begin();
15   iterator end();
16 };
17 
18 template <typename FwIt>
19 void random_shuffle(FwIt begin, FwIt end);
20 
21 template <typename FwIt, typename randomFunc>
22 void random_shuffle(FwIt begin, FwIt end, randomFunc& randomfunc);
23 
24 template <typename FwIt>
25 void shuffle(FwIt begin, FwIt end);
26 } // namespace std
27 
28 // Random Func
myrandom(int i)29 int myrandom (int i) { return i;}
30 
31 using namespace std;
32 
main()33 int main() {
34   std::vector<int> vec;
35 
36   std::random_shuffle(vec.begin(), vec.end());
37   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'std::random_shuffle' has been removed in C++17; use 'std::shuffle' instead
38   // CHECK-FIXES: std::shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()()));
39 
40   std::shuffle(vec.begin(), vec.end());
41 
42   random_shuffle(vec.begin(), vec.end());
43   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'std::random_shuffle' has been removed in C++17; use 'std::shuffle' instead
44   // CHECK-FIXES: shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()()));
45 
46   std::random_shuffle(vec.begin(), vec.end(), myrandom);
47   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'std::random_shuffle' has been removed in C++17; use 'std::shuffle' and an alternative random mechanism instead
48   // CHECK-FIXES: std::shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()()));
49 
50   random_shuffle(vec.begin(), vec.end(), myrandom);
51   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'std::random_shuffle' has been removed in C++17; use 'std::shuffle' and an alternative random mechanism instead
52   // CHECK-FIXES: shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()()));
53 
54   shuffle(vec.begin(), vec.end());
55 
56   return 0;
57 }
58