• DocumentCode
    596547
  • Title

    Detect functionally equivalent code fragments via k-nearest neighbor algorithm

  • Author

    Dandan Kong ; Xiaohong Su ; Shitang Wu ; Tiantian Wang ; Peijun Ma

  • Author_Institution
    Sch. of Comput. Sci. & Technol., Harbin Inst. of Technol., Harbin, China
  • fYear
    2012
  • fDate
    18-20 Oct. 2012
  • Firstpage
    94
  • Lastpage
    98
  • 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 compilable 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.
  • Keywords
    learning (artificial intelligence); pattern clustering; program diagnostics; software maintenance; code clone; code fragment detection; control dependency information; data flow information; duplicated code detection; k-nearest neighbor clustering algorithm; program semantics; software development; software maintenance; source code analysis; time complexity; Algorithm design and analysis; Cloning; Clustering algorithms; Heuristic algorithms; Input variables; Sorting; Testing;
  • fLanguage
    English
  • Publisher
    ieee
  • Conference_Titel
    Advanced Computational Intelligence (ICACI), 2012 IEEE Fifth International Conference on
  • Conference_Location
    Nanjing
  • Print_ISBN
    978-1-4673-1743-6
  • Type

    conf

  • DOI
    10.1109/ICACI.2012.6463128
  • Filename
    6463128