Lecture Notes in Computer Science, 2001, Volume 2028/2001, 383-386, DOI: 10.1007/3-540-45309-1_25

Tool Demonstration: Finding Duplicated Code Using Program Dependences

Raghavan Komondoor and Susan Horwitz

View Related Documents

Abstract

The results of several studies [1,7,8] indicate that 7-23% of the source code for large programs is duplicated code. Duplication makes programs harder to maintain because when enhancements or bug fixes are made in one instance of the duplicated code, it is necessary to search for the other instances in order to perform the corresponding modification.
A tool that finds clones (instances of duplicated code) can help to alleviate this problem. When code is modified, the tool can be used to find the other copies that also need modification. Alternatively, the clones identified by the tool can be extracted into a new procedure, and the clones themselves replaced by calls to that procedure. In that case, there is only one copy to maintain (the new procedure), and the fact that the procedure can be reused may cut down on future duplication.
We have designed and implemented a tool for C programs that finds clones and displays them to the programmer. To find clones in a program, we represent each procedure using its program dependence graph (PDG) [6]. In the PDG, nodes represent program statements and predicates, and edges represent data and control dependences. To find a pair of clones we use a variation on backward slicing [11,10].

Fulltext Preview

Image of the first page of the fulltext document