class CloneDetector
Declaration
class CloneDetector { /* full declaration omitted */ };
Description
Searches for similar subtrees in the AST. First, this class needs several declarations with statement bodies which can be passed via analyzeCodeBody. Afterwards all statements can be searched for clones by calling findClones with a given list of constraints that should specify the wanted properties of the clones. The result of findClones can be further constrained with the constrainClones method. This class only searches for clones in executable source code (e.g. function bodies). Other clones (e.g. cloned comments or declarations) are not supported.
Declared at: clang/include/clang/Analysis/CloneDetection.h:166
Member Variables
- private clang::CloneDetector::CloneGroup Sequences
Method Overview
- public void analyzeCodeBody(const clang::Decl * D)
- public template <typename T>static void constrainClones(std::vector<CloneGroup> & CloneGroups, T C)
- public template <typename T1, typename... Ts>static void constrainClones(std::vector<CloneGroup> & CloneGroups, T1 C, Ts... ConstraintList)
- public template <typename... Ts>void findClones(std::vector<CloneGroup> & Result, Ts... ConstraintList)
Methods
¶void analyzeCodeBody(const clang::Decl* D)
void analyzeCodeBody(const clang::Decl* D)
Description
Generates and stores search data for all statements in the body of the given Decl.
Declared at: clang/include/clang/Analysis/CloneDetection.h:174
Parameters
- const clang::Decl* D
¶template <typename T>
static void constrainClones(
std::vector<CloneGroup>& CloneGroups,
T C)
template <typename T>
static void constrainClones(
std::vector<CloneGroup>& CloneGroups,
T C)
Description
Constrains the given list of clone groups with the given constraint. The constraint is expected to have a method with the signature `void constrain(std::vector <CloneDetector ::CloneGroup> &Sequences )` as this is the interface that the CloneDetector uses for applying the constraint. The constraint is supposed to directly modify the passed list so that all clones in the list fulfill the specific property this constraint ensures.
Declared at: clang/include/clang/Analysis/CloneDetection.h:185
Templates
- T
Parameters
- std::vector<CloneGroup>& CloneGroups
- T C
¶template <typename T1, typename... Ts>
static void constrainClones(
std::vector<CloneGroup>& CloneGroups,
T1 C,
Ts... ConstraintList)
template <typename T1, typename... Ts>
static void constrainClones(
std::vector<CloneGroup>& CloneGroups,
T1 C,
Ts... ConstraintList)
Description
Constrains the given list of clone groups with the given list of constraints. The constraints are applied in sequence in the order in which they are passed to this function.
Declared at: clang/include/clang/Analysis/CloneDetection.h:195
Templates
- T1
- Ts
Parameters
- std::vector<CloneGroup>& CloneGroups
- T1 C
- Ts... ConstraintList
¶template <typename... Ts>
void findClones(std::vector<CloneGroup>& Result,
Ts... ConstraintList)
template <typename... Ts>
void findClones(std::vector<CloneGroup>& Result,
Ts... ConstraintList)
Description
Searches for clones in all previously passed statements.
Declared at: clang/include/clang/Analysis/CloneDetection.h:207
Templates
- Ts
Parameters
- std::vector<CloneGroup>& Result
- Output parameter to which all created clone groups are added.
- Ts... ConstraintList
- The constraints that should be applied to the