[PATCH] D95736: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with `typedef` and `const &` diagnostics

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 16 10:54:03 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:706
+            UniqueBindPower({LType, RType})) {
+          // FIXME: Don't emit multiple combinations here either.
+          StringRef DiagText = "a call site binds an expression to '%0' and "
----------------
whisperity wrote:
> This is a stale FIXME, the uniqueing of the emission is in the line right above...
Heh, I was sort of wondering about that. Please remove the FIXME before committing.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:707-708
+          // FIXME: Don't emit multiple combinations here either.
+          StringRef DiagText = "a call site binds an expression to '%0' and "
+                               "'%1' with the same force";
+          diag(M.Second->getOuterLocStart(), DiagText, DiagnosticIDs::Note)
----------------
whisperity wrote:
> aaron.ballman wrote:
> > I think "with the same force" is going to be hard for users to make sense of. I'm at a bit of a loss for how to word it though. The issue is that `T` and `const T&` parameters *might* be easily swapped, so maybe it's best to call it out that way?
> This is a note tag to explain the reason behind the mix. The warning itself has been emitted before. How about
> 
> > a `T` and `const T&` parameter accepts all values of `T`
> 
> ?
I think that'd be significantly more clear, yes!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95736



More information about the cfe-commits mailing list