summaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-tidy
diff options
context:
space:
mode:
authorPiotr Zegar <me@piotrzegar.pl>2023-04-10 14:41:32 +0000
committerPiotr Zegar <me@piotrzegar.pl>2023-04-10 14:41:32 +0000
commit225d255a583ea3d50bbba49d949ca76be6a880bf (patch)
treec3cd92cef8487775b475b9cab4d71874572dd137 /clang-tools-extra/clang-tidy
parent27f8a62a541e650d8d6ee4b7001b78e976519306 (diff)
downloadllvm-225d255a583ea3d50bbba49d949ca76be6a880bf.tar.gz
[clang-tidy] Added IgnoreVirtual option to misc-unused-parameters
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. Reviewed By: njames93 Differential Revision: https://reviews.llvm.org/D147918
Diffstat (limited to 'clang-tools-extra/clang-tidy')
-rw-r--r--clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp9
-rw-r--r--clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.h1
2 files changed, 8 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
index 2c69cb0df713..3f1d2f9f5809 100644
--- a/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
@@ -123,10 +123,12 @@ UnusedParametersCheck::~UnusedParametersCheck() = default;
UnusedParametersCheck::UnusedParametersCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
- StrictMode(Options.getLocalOrGlobal("StrictMode", false)) {}
+ StrictMode(Options.getLocalOrGlobal("StrictMode", false)),
+ IgnoreVirtual(Options.get("IgnoreVirtual", false)) {}
void UnusedParametersCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "StrictMode", StrictMode);
+ Options.store(Opts, "IgnoreVirtual", IgnoreVirtual);
}
void UnusedParametersCheck::warnOnUnusedParameter(
@@ -176,9 +178,12 @@ void UnusedParametersCheck::check(const MatchFinder::MatchResult &Result) {
const auto *Function = Result.Nodes.getNodeAs<FunctionDecl>("function");
if (!Function->hasWrittenPrototype() || Function->isTemplateInstantiation())
return;
- if (const auto *Method = dyn_cast<CXXMethodDecl>(Function))
+ if (const auto *Method = dyn_cast<CXXMethodDecl>(Function)) {
+ if (IgnoreVirtual && Method->isVirtual())
+ return;
if (Method->isLambdaStaticInvoker())
return;
+ }
for (unsigned I = 0, E = Function->getNumParams(); I != E; ++I) {
const auto *Param = Function->getParamDecl(I);
if (Param->isUsed() || Param->isReferenced() || !Param->getDeclName() ||
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.h b/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.h
index 684c95daaae7..90097ed415d3 100644
--- a/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.h
+++ b/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.h
@@ -25,6 +25,7 @@ public:
private:
const bool StrictMode;
+ const bool IgnoreVirtual;
class IndexerVisitor;
std::unique_ptr<IndexerVisitor> Indexer;