[PATCH] D69560: [clang-tidy] Add 'cppcoreguidelines-avoid-adjacent-arguments-of-same-type' check

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 4 17:00:24 PST 2019


NoQ added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/AdjacentArgumentsOfSameTypeCheck.cpp:488
+void AdjacentArgumentsOfSameTypeCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+    return;
----------------
whisperity wrote:
> whisperity wrote:
> > Eugene.Zelenko wrote:
> > > Check seems to be useful for C and probably for Objective-C.
> > I'm not knowledgeable about Objective-C at all to make a decision on how the "adjacent argument ranges" could be calculated and what mixups are possible. As for C, should a `cppcoreguidelines-` check be enabled for C? Or you mean we should allow it to work, and the user will toggle how they see fit.
> I've added a  `FIXME` for ObjC as I'm really not qualified in that language. C support has been added.
The check should keep working on Objective-C to check C-style calls, and it should also keep working on Objective-C++ to check C++-style method calls. You should be able to test this by renaming any of your `.c`/`.cpp` test files to `.m`/`.mm` (of course you don't *have* to duplicate your tests; just keep a couple of functions to see that the warning is still there).

However, the check shouldn't try to check Objective-C message expressions / method declarations, because Objective-C message syntax has so-called "parameter labels": the caller is forced to spell out which parameter it's passing, which effectively mitigates the problem.

Note that `ObjCMethodDecl` is not a sub-class of `FunctionDecl`, so your checker is already working correctly (as long as you remove the explicit suppression).


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

https://reviews.llvm.org/D69560





More information about the cfe-commits mailing list