[PATCH] D30158: [clang-tidy] modernize: Find usage of random_shuffle and replace it with shuffle.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 10 15:30:42 PDT 2017


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

There are a few small nits I've mentioned, but otherwise LGTM.



================
Comment at: clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp:34-35
+
+  const auto first = hasArgument(0, expr().bind("one"));
+  const auto second = hasArgument(1, expr().bind("two"));
+  const auto third = hasArgument(2, expr().bind("three"));
----------------
No need to bind either of these -- the bound name never gets used.


================
Comment at: clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp:36
+  const auto second = hasArgument(1, expr().bind("two"));
+  const auto third = hasArgument(2, expr().bind("three"));
+  Finder->addMatcher(
----------------
Can likely pick a better name to bind than "three". ;-) I would recommend "RandomFunc" since that's what the parameter represents.


================
Comment at: clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp:70
+    if (MatchedCallExpr->getNumArgs() == 3) {
+      auto DiagL = diag(MatchedCallExpr->getLocStart(), "'std::random_shuffle' has been removed in C++17; use 'std::shuffle' and an alternative random mechanism instead");
+      DiagL << FixItHint::CreateReplacement(
----------------
Wrap for 80-column (here and elsewhere).


https://reviews.llvm.org/D30158





More information about the cfe-commits mailing list