Detection of clone sequences and classes using AST

Li Yajun,Xu Baowen,Zhou Xiaoyu
DOI: https://doi.org/10.3321/j.issn:1001-0505.2008.02.009
2008-01-01
Abstract:In order to reduce code redundancy and improve program structure,a novel approach based on abstract syntax is presented to detect clone code,and several kinds of code clones that occur frequently in programs are outlined.Corresponding refactoring techniques are also presented.Abstract syntax of the analyzed program is represented as binary tree(BAST).Isomorphism of sub-BAST is judged statement by statement.Similar statement sequences are detected as clone sequences.1-tuple clone classes are detected according to isomorphism of sub-BAST. By the join operation of clone classes 2-tuple and other clone classes can be achieved stage by stage.The experiment analyzes several open source projects,and clone sequences and classes are detected.Four kinds of code clones are induced from the detection result which have the following characters respectively: accessing different properties of the same class's objects at the same program point,modifying some variable names,applying the same operation to different types,modifying variables defined outside the clone area.All the four kinds of clone codes are refactored successfully.
What problem does this paper attempt to address?