Evaluation of code clone detection using large language models
Xinyi Wang · IET conference proceedings. · 2025
Code clone detection has extensive and critical applications in software metrics, plagiarism detection, aspect mining, code compression, and software supply chain vulnerability detection. Traditional token-based and tree-based clone detection methods are effective for syntactically similar clones. However, they often struggle to detect semantic clones—code segments that are semantically and functionally equivalent but syntactically distinct—since functionality similarity is not immediately apparent from syntax alone. This study explores the potential of large language models (LLMs) for code clone detection. By inputting code pairs into LLMs alongside prompt engineering techniques, we evaluated the capacity of LLMs to identify different types of code clones. Through comparative analyses of accuracy and recall rates between LLM-based methods and traditional token-based and tree-based approaches across various code clone types, we aimed to assess the advantages, limitations, and unique capabilities of LLMs in handling complex code similarity tasks. Experimental results demonstrate that LLMs outperform traditional methods in detecting semantic clones, achieving an accuracy of up to 100% and a recall rate of up to 92%, underscoring their value in modern software engineering practices. However, LLMs still face limitations, particularly in detecting semantic clones with significant structural differences, necessitating further improvements in future research.