• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===--- 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 
14 namespace clang {
15 namespace tidy {
16 namespace misc {
17 
18 /// Finds unused parameters and fixes them, so that `-Wunused-parameter` can be
19 /// turned on.
20 class UnusedParametersCheck : public ClangTidyCheck {
21 public:
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 
28 private:
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
43