InconsistentDeclarationParameterNameCheck.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //===- InconsistentDeclarationParameterNameCheck.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_READABILITY_INCONSISTENT_DECLARATION_PARAMETER_NAME_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_INCONSISTENT_DECLARATION_PARAMETER_NAME_H
  10. #include "../ClangTidyCheck.h"
  11. #include "llvm/ADT/DenseSet.h"
  12. namespace clang::tidy::readability {
  13. /// Checks for declarations of functions which differ in parameter names.
  14. ///
  15. /// For detailed documentation see:
  16. /// http://clang.llvm.org/extra/clang-tidy/checks/readability/inconsistent-declaration-parameter-name.html
  17. ///
  18. class InconsistentDeclarationParameterNameCheck : public ClangTidyCheck {
  19. public:
  20. InconsistentDeclarationParameterNameCheck(StringRef Name,
  21. ClangTidyContext *Context)
  22. : ClangTidyCheck(Name, Context),
  23. IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)),
  24. Strict(Options.getLocalOrGlobal("Strict", false)) {}
  25. void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
  26. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  27. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  28. std::optional<TraversalKind> getCheckTraversalKind() const override {
  29. return TK_IgnoreUnlessSpelledInSource;
  30. }
  31. private:
  32. void markRedeclarationsAsVisited(const FunctionDecl *FunctionDeclaration);
  33. llvm::DenseSet<const FunctionDecl *> VisitedDeclarations;
  34. const bool IgnoreMacros;
  35. const bool Strict;
  36. };
  37. } // namespace clang::tidy::readability
  38. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_INCONSISTENT_DECLARATION_PARAMETER_NAME_H