Slicing Demo

Finding Duplicated Code Using Program Dependences

Raghavan Komondoor, Susan Horwitz (University of Wisconsin)

Programs often have a lot of duplicated code, which makes both understanding and maintenance more difficult. This problem can be alleviated by finding duplicated code, extracting it into a separate new procedure, and replacing all the clones (the instances of the duplicated code) by calls to the new procedure. We will demonstrate a tool that finds groups of clones and displays them to the programmer. The novel aspect of our approach is the use of program dependence graphs (PDGs) and program slicing to find isomorphic PDG subgraphs that represent clones.