Abstract
Code cloning is a common phenomenon in software development, which reduces developers' programming efforts but also poses risks of defect inheritance. Clone detection locates exact or similar pieces of code within or between software systems. With the amount of source code increasing steadily, efficient and large-scale clone detection has become a necessity. Moreover, code clones may occur at various levels of code granularity, e.g., file, function, and block level, which pose more challenges for efficient clone detection. Although numerous methods have been proposed to detect code clones at different granularities, they often suffer from low detection efficiency, false positive results and are typically limited to identifying clones at a specific granularity. In this paper, we introduce an efficient clone detection, named MGCD, to detect code clones among large-scale codebases. Specifically, we embed function-level code into vectors using a pre-trained model and perform clustering search with the IVF_Flat algorithm to identify clone candidates. These candidates are then filtered through an entropy-based method to enhance accuracy and avoid false positive results. Moreover, we leverage the information from function-level clone detection results to further conduct file and block level clone detection. We evaluate our approach on the BigCloneBench benchmark. Experimental results show that our approach only takes 0.23 ms to search clone results among 800,000 functions and achieves high precision and recall.
| Original language | English |
|---|---|
| Pages (from-to) | 546-561 |
| Number of pages | 16 |
| Journal | IEEE Transactions on Software Engineering |
| Volume | 52 |
| Issue number | 2 |
| DOIs | |
| State | Published - 2026 |
Keywords
- Code clone detection
- large language model
- multi-granularity
Fingerprint
Dive into the research topics of 'Scalable Large-Scale Multi-Granularity Code Clone Detection via Clustering Search and Pre-Trained Models'. Together they form a unique fingerprint.Cite this
- APA
- Author
- BIBTEX
- Harvard
- Standard
- RIS
- Vancouver