Abstract

It is important for improving program to detect duplicated code (also known as code clone) in the field of software development and maintenance. The existing solutions can not effectively analyze the complex semantics of programs, and so can not effectively detect functionally equivalent code fragments that execute the same operations but with different syntax. This paper proposes a method to detect functionally equivalent code fragments via k-nearest neighbor algorithm. Firstly, the source code is statically analyzed to get the information of control dependency and data flow; then, k-nearest neighbor clustering algorithm is performed to form functionally independent code fragments; next, the input and output variables of the code fragments are identified, and the code fragments are transformed to compliable and executable functions, then the automatic random assignment for the input variables of functions are carried out. At last, the functions are dynamically tested and are classified into different clusters according to the testing outputs. Experimental results show that this method can effectively get functionally equivalent code fragments with a lower time complexity.

Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.