UseEqualsDeleteCheck.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //===--- UseEqualsDeleteCheck.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_MODERNIZE_USE_EQUALS_DELETE_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_EQUALS_DELETE_H
  10. #include "../ClangTidyCheck.h"
  11. namespace clang::tidy::modernize {
  12. /// Mark unimplemented private special member functions with '= delete'.
  13. /// \code
  14. /// struct A {
  15. /// private:
  16. /// A(const A&);
  17. /// A& operator=(const A&);
  18. /// };
  19. /// \endcode
  20. /// Is converted to:
  21. /// \code
  22. /// struct A {
  23. /// private:
  24. /// A(const A&) = delete;
  25. /// A& operator=(const A&) = delete;
  26. /// };
  27. /// \endcode
  28. ///
  29. /// For the user-facing documentation see:
  30. /// http://clang.llvm.org/extra/clang-tidy/checks/modernize/use-equals-delete.html
  31. class UseEqualsDeleteCheck : public ClangTidyCheck {
  32. public:
  33. UseEqualsDeleteCheck(StringRef Name, ClangTidyContext *Context)
  34. : ClangTidyCheck(Name, Context),
  35. IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
  36. bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
  37. return LangOpts.CPlusPlus;
  38. }
  39. void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
  40. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  41. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  42. private:
  43. const bool IgnoreMacros;
  44. };
  45. } // namespace clang::tidy::modernize
  46. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_EQUALS_DELETE_H