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

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 20 02:35:28 PST 2017


xazax.hun added inline comments.


================
Comment at: clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp:81
+  Stream << "shuffle(";
+  FirstArgument->printPretty(Stream, nullptr, Ctx.getPrintingPolicy());
+  Stream << ", ";
----------------
madsravn wrote:
> xazax.hun wrote:
> > madsravn wrote:
> > > xazax.hun wrote:
> > > > Wouldn't just using the original source range of the argument work?
> > > > What about preserving the comments next to the arguments? 
> > > I am not sure what you mean about the original source range. Can I just put that onto the Stream? 
> > > 
> > > Do you have an idea for the comments? Do you mean something like
> > > 
> > > 
> > > ```
> > > std::random_shuffle(
> > >    vec.begin(), // Comment
> > >    vec.end() // Comment
> > > );
> > > ```
> > Or even:
> > 
> > 
> > ```
> > std::random_shuffle(vec.begin(), /*inlinecomment*/ vec.end());
> > ```
> Thanks for you other comments. Can you elaborate on how I might fix this?
You might do a different strategy, like not touching the arguments at all, but only inserting a new argument before the closing paren of the function call. This way all the comments should be preserved. 


https://reviews.llvm.org/D30158





More information about the cfe-commits mailing list