Distilling useful clones by contextual differencing

Zhenchang Xing, Yinxing Xue, Stan Jarzabek
2013 2013 20th Working Conference on Reverse Engineering (WCRE)  
Clone detectors find similar code fragments and report large numbers of them for large systems. Textually similar clones may perform different computations, depending on the program context in which clones occur. Understanding these contextual differences is essential to distill useful clones for a specific maintenance task, such as refactoring. Manual analysis of contextual differences is time consuming and error-prone. To mitigate this problem, we present an automated approach to helping
more » ... opers find and analyze contextual differences of clones. Our approach represents context of clones as program dependence graphs, and applies a graph differencing technique to identify required contextual differences of clones. We implemented a tool called CloneDifferentiator that identifies contextual differences of clones and allows developers to formulate queries to distill candidate clones that are useful for a given refactoring task. Two empirical studies show that CloneDifferentiator can reduce the efforts of post-detection analysis of clones for refactorings.
doi:10.1109/wcre.2013.6671285 dblp:conf/wcre/XingXJ13 fatcat:q4v65w5ecreyzoiuhn5rwtr7ey