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

Alexander Kornienko alexfh at google.com
Thu Jul 10 04:52:37 PDT 2014

Comment at: clang-tidy/misc/CMakeLists.txt:6
@@ -5,2 +5,3 @@
+  ImplicitArgumentConversion.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.


More information about the cfe-commits mailing list