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].
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
References
B. Baker. On finding duplication and near-duplication in large software systems. In Proc. IEEE Working Conf. on Reverse Eng., pages 86–95, July 1995.
B. Baker. Parameterized duplication in strings: Algorithms and an application to software maint. SIAM Jrnl. of Computing, 26(5):1343–1362, Oct. 1997.
I. Baxter, A. Yahin, L. Moura, M. Sant’Anna, and L. Bier. Clone detection using abstract syntax trees. In Int. Conf. on Software Maint., pages 368–378, 1998.
N. Davey, P. Barson, S. Field, R. Frank, and D. Tansley. The development of a software clone detector. Int. Jrnl. of Applied Software Tech., 1(3-4):219–36, 1995.
S. Debray, W. Evans, R. Muth, and B. D. Sutter. Compiler techniques for code compaction. ACM Trans. on Prog. Lang. and Sys., 22(2):378–415, Mar. 2000.
J. Ferrante, K. Ottenstein, and J. Warren. The program dependence graph and its use in optimization. ACM Trans. on Prog. Lang. and Sys., 9(3):319–349, July 1987.
K. Kontogiannis, R. Demori, E. Merlo, M. Galler, and M. Bernstein. Pattern matching for clone and concept detection. Automated Software Eng., 3(1-2):77–108, 1996.
B. Lague, D. Proulx, J. Mayrand, E. Merlo, and J. Hudepohl. Assessing the benefits of incorporating function clone detection in a development process. In Int. Conf. on Software Maint., pages 314–321, 1997.
J. Mayrand, C. Leblanc, and E. Merlo. Experiment on the automatic detection of function clones in a software system using metrics. In Proc. of the Int. Conf. on Software Maint., pages 244–254, 1996.
K. Ottenstein and L. Ottenstein. The program dependence graph in a software development environment. In Proc. ACM SIGSOFT/SIGPLAN Software Eng. Symp. on Practical Software Development Environments, pages 177–184, 1984.
M. Weiser. Program slicing. IEEE Trans. on Software Eng., SE-10(4):352–357, July 1984.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2001 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Komondoor, R., Horwitz, S. (2001). Tool Demonstration: Finding Duplicated Code Using Program Dependences. In: Sands, D. (eds) Programming Languages and Systems. ESOP 2001. Lecture Notes in Computer Science, vol 2028. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-45309-1_25
Download citation
DOI: https://doi.org/10.1007/3-540-45309-1_25
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-41862-7
Online ISBN: 978-3-540-45309-3
eBook Packages: Springer Book Archive