一句话:复现12种算法比较代码表示对克隆检测的影响,并组合 token 与树表示实现 TACC。
代码克隆会增加维护成本并带来漏洞传播风险。已有克隆检测技术可按代码表示分为文本、token、树、图等,但不同表示的有效性及组合方式尚不明确。本文复现12种克隆检测算法并按表示分组开展实证比较,发现 token 和树表示在简单克隆上优于图表示,而代码对复杂度升高时图表示更有效。作者进一步人工分析开源项目,观察到多数克隆对属于简单克隆,因此舍弃重量级图方法,探索 token 与树表示的组合,实现工具 TACC,并与当前最优检测器评估。结果表明 TACC 性能更优且具备大规模克隆检测能力。
As one of bad smells in code, code clones may increase the cost of software maintenance and the risk of vulnerability propagation. In the past two decades, numerous clone detection technologies have been proposed. They can be divided into text-based, token-based, tree-based, and graph-based approaches according to their code representations. Different code representations abstract the code details from different perspectives. However, it is unclear which code representation is more effective in detecting code clones and how to combine different code representations to achieve ideal performance. In this paper, we present an empirical study to compare the clone detection ability of different code representations. Specifically, we reproduce 12 clone detection algorithms and divide them into different groups according to their code representations. After analyzing the empirical results, we find that token and tree representations can perform better than graph representation when detecting simple code clones. However, when the code complexity of a code pair increases, graph representation becomes more effective. To make our findings more practical, we perform manual analysis on open-source projects to seek a possible distribution of different clone types in the open-source community. Through the results, we observe that most clone pairs belong to simple code clones. Based on this observation, we discard heavyweight graph-based clone detection algorithms and conduct combination experiments to find out a suitable combination of token-based and tree-based approaches for achieving scalable and effective code clone detection. We develop the suitable combination into a tool called TACC and evaluate it with other state-of-the-art code clone detectors. Experimental results indicate that TACC performs better and has the ability to detect large-scale code clones.
@inproceedings{WangYWZXL23,
title = {Comparison and Evaluation of Clone Detection Techniques with Different Code Representations},
author = {Yuekun Wang and Yuhang Ye and Yueming Wu and Weiwei Zhang and Yinxing Xue and Yang Liu},
booktitle = {ICSE},
year = {2023},
doi = {10.1109/icse48619.2023.00039}
}