RedundantMemberInitCheck.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //===--- RedundantMemberInitCheck.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_REDUNDANT_MEMBER_INIT_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_MEMBER_INIT_H
  10. #include "../ClangTidyCheck.h"
  11. namespace clang::tidy::readability {
  12. /// Finds member initializations that are unnecessary because the same default
  13. /// constructor would be called if they were not present.
  14. ///
  15. /// For the user-facing documentation see:
  16. /// http://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html
  17. class RedundantMemberInitCheck : public ClangTidyCheck {
  18. public:
  19. RedundantMemberInitCheck(StringRef Name, ClangTidyContext *Context)
  20. : ClangTidyCheck(Name, Context),
  21. IgnoreBaseInCopyConstructors(
  22. Options.get("IgnoreBaseInCopyConstructors", false)) {}
  23. bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
  24. return LangOpts.CPlusPlus;
  25. }
  26. void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
  27. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  28. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  29. std::optional<TraversalKind> getCheckTraversalKind() const override {
  30. return TK_IgnoreUnlessSpelledInSource;
  31. }
  32. private:
  33. bool IgnoreBaseInCopyConstructors;
  34. };
  35. } // namespace clang::tidy::readability
  36. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_MEMBER_INIT_H