[clang-tidy] Extend 'bugprone-easily-swappable-parameters' with `typedef` and `const...
authorWhisperity <whisperity@gmail.com>
Fri, 8 Nov 2019 18:58:23 +0000 (19:58 +0100)
committerWhisperity <whisperity@gmail.com>
Mon, 28 Jun 2021 08:49:37 +0000 (10:49 +0200)
commit26d864b44b9d3326984a7041124aa0f9e8ebc5cb
tree9285e74506574c20cecd5b06ac2aaeb9ac29c85b
parent499e39c5983dba35861b5482bd298a8da726f1b6
[clang-tidy] Extend 'bugprone-easily-swappable-parameters' with `typedef` and `const &` diagnostics

The base patch only deals with strict (canonical) type equality, which is
merely a subset of all the dangerous function interfaces that we intend to
find.
In addition, in the base patch, canonical type equivalence is not diagnosed in
a way that is immediately apparent to the user.

This patch extends the check with two features:

 * Proper typedef diagnostics and explanations to the user.
 * "Reference bind power" matching.

Case 2 is a necessary addition because in every case someone encounters a
function `f(T t, const T& tr)`, any expression that might be passed to either
can be passed to both. Thus, such adjacent parameter sequences should be
matched.

Reviewed By: aaron.ballman

Differential Revision: http://reviews.llvm.org/D95736
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp