This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Added IgnoreVirtual option to misc-unused-parameters
ClosedPublic

Authored by PiotrZSL on Apr 10 2023, 1:03 AM.

Details

Summary

Added option to ignore virtual methods in this check.
This allows to quickly get rid of big number of
potentialy false-positive issues without inserting
not-needed comments.

Fixes #55665.

Diff Detail

Event Timeline

PiotrZSL created this revision.Apr 10 2023, 1:03 AM
Herald added a project: Restricted Project. · View Herald Transcript
PiotrZSL requested review of this revision.Apr 10 2023, 1:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 10 2023, 1:03 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Looks good, small comments!

clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
185

Since these 2 conditions are unrelated, I believe it's better to put them in separate ifs:

if (IgnoreVirtual && Method->isVirtual())
  return;

if (Method->isLambdaStaticInvoker())
  return;
clang-tools-extra/test/clang-tidy/checkers/misc/unused-parameters-virtual.cpp
5

We typically call it Base. Class can also be confusing since it's a struct ;)

Have you thought about handling CRTP overrides

template <typename T>
class Base {
  int getThing(int x) {
    return x;
  }
};

class Derived : public Base<Derived> {
  int getThing(int x) {
    return 0;
  }
};

I'm not saying update this to work for that, but could be a good direction in the future.

clang-tools-extra/docs/ReleaseNotes.rst
225

Don't really need to specify the default here, that's what the check documentation is for

310–311

Please revert this change, it's unrelated.

clang-tools-extra/test/clang-tidy/checkers/misc/unused-parameters-virtual.cpp
8

The Regex line start and end markers aren't necessary

18

Small nit: Insert override here so it's obvious to readers of the test that this is a virtual function

PiotrZSL updated this revision to Diff 512122.Apr 10 2023, 5:39 AM
PiotrZSL marked 6 inline comments as done.

Review fixes

CRTP not planed.
Not in scope of #55665.

njames93 accepted this revision.Apr 10 2023, 6:10 AM

LGTM.

This revision is now accepted and ready to land.Apr 10 2023, 6:10 AM
This revision was landed with ongoing or failed builds.Apr 10 2023, 7:56 AM
This revision was automatically updated to reflect the committed changes.