[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check
Whisperity via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 27 11:09:21 PST 2021
whisperity added inline comments.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp:10
+
+void declaration(int Param, int Other); // NO-WARN: No chance to change this function.
+
----------------
aaron.ballman wrote:
> I think this is a case where we could warn when the declaration is outside of a system header (perhaps as an option).
>
> Thinking about it a bit more, declarations and definitions provide a novel way to get another kind of swap:
> ```
> void func(int x, int y);
> void func(int y, int x) {} // Oops, the swap was probably not intentional
> ```
> which may or may not be interesting for a check (or its heuristics).
I gave this some thought. It is a very good idea, but I believe not for //this// check, but D20689. What do you think of that? Maybe simply saying "call site v. function node that was called" could be extended with a completely analogous, string distance function based "function definition node v. redecl chain" case.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69560/new/
https://reviews.llvm.org/D69560
More information about the cfe-commits
mailing list