[PATCH] D78652: [clang-tidy] Suppress reports to similarly used parameters in 'bugprone-easily-swappable-parameters'

Whisperity via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 16 10:59:35 PDT 2021


whisperity added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:481
+
+      assert(TargetIdx.hasValue() && "Matched, but didn't find index?");
+      TargetParams[PassedParamOfThisFn].insert(
----------------
aaron.ballman wrote:
> I *think* you could run into this assert with K&R C function where there is a `FunctionDecl` to get back to but the decl claims it has no params because it has no prototype (while the call expression actually has the arguments). However, there may be other code that protects us from this case.
At face value, I would say the fact that a K&R function //has no params// declared means that the matcher above will not be able to do `forEachArgumentWithParam`, because the argument vector is N long, but the parameter vector is empty.

Nevertheless, it won't hurt to add a test case for this though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78652/new/

https://reviews.llvm.org/D78652



More information about the cfe-commits mailing list