BranchCloneCheck.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. //===--- BranchCloneCheck.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_BRANCHCLONECHECK_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_BRANCHCLONECHECK_H
  10. #include "../ClangTidyCheck.h"
  11. namespace clang::tidy::bugprone {
  12. /// A check for detecting if/else if/else chains where two or more branches are
  13. /// Type I clones of each other (that is, they contain identical code), for
  14. /// detecting switch statements where two or more consecutive branches are
  15. /// Type I clones of each other, and for detecting conditional operators where
  16. /// the true and false expressions are Type I clones of each other.
  17. ///
  18. /// For the user-facing documentation see:
  19. /// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/branch-clone.html
  20. class BranchCloneCheck : public ClangTidyCheck {
  21. public:
  22. BranchCloneCheck(StringRef Name, ClangTidyContext *Context)
  23. : ClangTidyCheck(Name, Context) {}
  24. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  25. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  26. };
  27. } // namespace clang::tidy::bugprone
  28. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_BRANCHCLONECHECK_H