UnhandledSelfAssignmentCheck.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //===--- UnhandledSelfAssignmentCheck.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_BUGPRONE_UNHANDLEDSELFASSIGNMENTCHECK_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_UNHANDLEDSELFASSIGNMENTCHECK_H
  10. #include "../ClangTidyCheck.h"
  11. namespace clang::tidy::bugprone {
  12. /// Finds user-defined copy assignment operators which do not protect the code
  13. /// against self-assignment either by checking self-assignment explicitly or
  14. /// using the copy-and-swap or the copy-and-move method.
  15. ///
  16. /// For the user-facing documentation see:
  17. /// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/unhandled-self-assignment.html
  18. class UnhandledSelfAssignmentCheck : public ClangTidyCheck {
  19. public:
  20. UnhandledSelfAssignmentCheck(StringRef Name, ClangTidyContext *Context);
  21. bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
  22. return LangOpts.CPlusPlus;
  23. }
  24. void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
  25. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  26. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  27. private:
  28. const bool WarnOnlyIfThisHasSuspiciousField;
  29. };
  30. } // namespace clang::tidy::bugprone
  31. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_UNHANDLEDSELFASSIGNMENTCHECK_H