blob: 7e9b8c96f288372c01d9019e1ea2eca95986ee10 [file] [log] [blame]
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001//===--- UnusedParametersCheck.h - clang-tidy--------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_PARAMETERS_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_PARAMETERS_H
11
12#include "../ClangTidyCheck.h"
13
14namespace clang {
15namespace tidy {
16namespace misc {
17
18/// Finds unused parameters and fixes them, so that `-Wunused-parameter` can be
19/// turned on.
20class UnusedParametersCheck : public ClangTidyCheck {
21public:
22 UnusedParametersCheck(StringRef Name, ClangTidyContext *Context);
23 ~UnusedParametersCheck();
24 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
25 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
26 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
27
28private:
29 const bool StrictMode;
30 class IndexerVisitor;
31 std::unique_ptr<IndexerVisitor> Indexer;
32
33 void
34 warnOnUnusedParameter(const ast_matchers::MatchFinder::MatchResult &Result,
35 const FunctionDecl *Function, unsigned ParamIndex);
36};
37
38} // namespace misc
39} // namespace tidy
40} // namespace clang
41
42#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_PARAMETERS_H