Clever provides several
operations to deal with analysis and consistent updating of
clones and their changes:
Clone Matching and Differencing
Clone Matching and Differencing is based on Treed. From
the editing script returned by Treed for two clones or two versions
of a clone, their matches and differences are computed
from the nodes and subtrees mapped by the edit script. For
example, the differences are unmapped, updated, or moved
elements of such clones (or versions).
After matched and different elements of two clones are
identified, Clever finds the inconsistencies between them using
Clone Consistency Validating operation.
Clone Consistency Validating
Clever aims to detect only the inconsistencies involving 1)
the changes of identifiers, 2) control structures, and 3) literals,
which have been shown to be the major sources of clonerelated
bugs. Clever applies the following criteria
on the mapped elements between clones and their changes to
find the inconsistencies:
- Identifier Consistency
- Structural Change Consistency
- Value Change Consistency
Clone Synchronizing
Clone Synchronizing is the operation designed for two scenarios of clone change (cloning and one-side change), that is, when there is only one clone that was changed.
Clone Synchronizing works as follows. For the identifier inconsistencies, Clever recommends the mapping with the most frequencies.For changes to control structures, literals, and method calls, Clever recommends those changes to the mapped elements in the unchanged clone.
Clone Merging

Clone Merging is used for the two-side clone change scenario, when two clones are modified at the same time.We assume that both A and B are modified, but only changes of A need to be synchronized into B' (since A' was committed before B').
Clone Merging operation can be solved by two operations: Clone Synchronization and a classic three-way code merging operation in traditional SCM tools.
When B' is committed into the repository, Clever checks and sees that A, a clone of B, was modified. Thus, clone merging is required. Clever will perform a Clone Merging operation in two steps (see Figure 7):
1) Clone Synchronization is applied on B by taking into
consideration the changes from A to A'. That is, the
change to A is incorporated into B to produce a temporary
version B*.
2) A three-way Code Merge operation is applied to B*
and B' to produce the final merging result B". This is
a three-way code merge because both B* and B0 were
modified from B.