UnusedParametersCheck.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_PARAMETERS_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_PARAMETERS_H
  10. #include "../ClangTidyCheck.h"
  11. namespace clang::tidy::misc {
  12. /// Finds unused parameters and fixes them, so that `-Wunused-parameter` can be
  13. /// turned on.
  14. class UnusedParametersCheck : public ClangTidyCheck {
  15. public:
  16. UnusedParametersCheck(StringRef Name, ClangTidyContext *Context);
  17. ~UnusedParametersCheck();
  18. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  19. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  20. void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
  21. private:
  22. const bool StrictMode;
  23. class IndexerVisitor;
  24. std::unique_ptr<IndexerVisitor> Indexer;
  25. void
  26. warnOnUnusedParameter(const ast_matchers::MatchFinder::MatchResult &Result,
  27. const FunctionDecl *Function, unsigned ParamIndex);
  28. };
  29. } // namespace clang::tidy::misc
  30. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_PARAMETERS_H