//===--- BranchCloneCheck.cpp - clang-tidy --------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "BranchCloneCheck.h" #include "../utils/ASTUtils.h" #include "clang/AST/ASTContext.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Analysis/CloneDetection.h" #include "clang/Lex/Lexer.h" #include "llvm/Support/Casting.h" usingnamespaceclang; usingnamespaceclang::ast_matchers; namespace { /// A branch in a switch may consist of several statements; while a branch in /// an if/else if/else chain is one statement (which may be a CompoundStmt). SwitchBranch; } // anonymous namespace /// Determines if the bodies of two branches in a switch statements are Type I /// clones of each other. This function only examines the body of the branch /// and ignores the `case X:` or `default:` at the start of the branch. static bool areSwitchBranchesIdentical(const SwitchBranch &LHS, const SwitchBranch &RHS, const ASTContext &Context) { … } static bool isFallthroughSwitchBranch(const SwitchBranch &Branch) { … } namespace clang::tidy::bugprone { void BranchCloneCheck::registerMatchers(MatchFinder *Finder) { … } void BranchCloneCheck::check(const MatchFinder::MatchResult &Result) { … } } // namespace clang::tidy::bugprone