[PATCH] [clang-tidy] Add a checker for swapped literal arguments.

Nico Weber thakis at chromium.org
Thu Jul 10 08:38:41 PDT 2014


Wouldn't this make sense as a regular warning?


On Thu, Jul 10, 2014 at 4:52 AM, Alexander Kornienko <alexfh at google.com>
wrote:

> ================
> Comment at: clang-tidy/misc/CMakeLists.txt:6
> @@ -5,2 +5,3 @@
>    BoolPointerImplicitConversion.cpp
> +  ImplicitArgumentConversion.cpp
>    MiscTidyModule.cpp
> ----------------
> Daniel Jasper wrote:
> > ImplicitArgumentConversion is not exactly what this does, I think. Maybe
> SwappedArgumentsCheck?
> +1 for SwappedArgumentsCheck.
>
> ================
> Comment at: clang-tidy/misc/ImplicitArgumentConversion.cpp:52
> @@ +51,3 @@
> +  // most likely a swap.
> +  if (NumConversions >= 2 && DeclTypes == CallTypes) {
> +    diag(Call->getLocStart(),
> ----------------
> Daniel Jasper wrote:
> > Mhmm. This seems like a very crude way of doing this. Might be ok for a
> first iteration, but it seems like we could actually be much smarter and
> check if there is a re-ordering that would fit better (and even extend the
> analysis to more than two parameters, no)?
> Instead, I'd check if swapping each consecutive pair of arguments
> decreases the number of conversions by 2. It would also be nice to specify
> which pair of arguments is likely to be swapped.
>
> http://reviews.llvm.org/D4457
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140710/5d0dad59/attachment.html>


More information about the cfe-commits mailing list