[PATCH] D30158: [clang-tidy] modernize: Find usage of random_shuffle and replace it with shuffle.
Mads Ravn via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 23 12:03:51 PST 2017
madsravn marked 18 inline comments as done.
madsravn added inline comments.
================
Comment at: test/clang-tidy/modernize-replace-random-shuffle.cpp:50
+ // CHECK-MESSAGE: [[@LINE-1]]:3: warning: do not use 'random_shuffle'. It is deprecated and replaced by 'shuffle'. The old user defined 'RandomFunction' is not usable for shuffle. You need to make additional changes if you want a specific random function
+ // CHECK-FIXES: shuffle(vec.begin(), vec.begin(), std::mt19937(std::random_device()()));
+
----------------
xazax.hun wrote:
> This check-fix might match the previous fix instead of this one. You might want to make the fixes unique, e.g.: with a comment after a line. Note that it is also worth to test that line ending comments are preserved.
>
> Also, are you sure you want to do the fixit when a custom random function is passed to random_shuffle?
I re-arranged them. This way the check-fixes does not say the same twice in a row. I am not sure what you mean by 'line ending comments are preserved'. Why shouldn't they be?
The fixit should also be done when a custom random function is passed. random_shuffle will be removed and the signature of the custom random function will be changed. It's hard to do much differently than just issuing a warning.
https://reviews.llvm.org/D30158
More information about the cfe-commits
mailing list