一句话:提出 DSFM,通过比较代码 AST 的深度子树交互引入细粒度语义相似性,提升功能代码克隆检测性能。
功能代码克隆检测对软件维护很重要。现有深度学习方法常把代码片段压缩为单一语义向量,过于依赖特征学习,难以显式比较 token 交集、相似流图或相似子树等结构信息。本文提出 DSFM,在典型深度克隆检测器中引入深度子树交互:从两个代码片段的 AST 中提取子树并两两比较,从而获得更细粒度的语义相似度以判定功能克隆。作者在 GCJ、OJClone 和 BigCloneBench 三个数据集上实验,结果表明 DSFM 优于两种传统方法、两种无监督方法和四种有监督深度学习方法等强基线,展示了深度子树交互在代码克隆检测中的潜力。
Functional code clone detection is important for software maintenance. In recent years, deep learning techniques are introduced to improve the performance of functional code clone detectors. By representing each code snippet as a vector containing its program semantics, syntactically dissimilar functional clones are detected. However, existing deep learning-based approaches attach too much importance to code feature learning, hoping to project all recognizable knowledge of a code snippet into a single vector. We argue that these deep learning-based approaches can be enhanced by considering the characteristics of syntactic code clone detection, where we need to compare the contents of the source code (e.g., intersection of tokens, similar flow graphs, and similar subtrees) to obtain code clones. In this paper, we propose a novel deep learning-based approach named DSFM, which incorporates comparisons between code snippets for detecting functional code clones. Specifically, we improve the typical deep clone detectors with deep subtree interactions that compare every two subtrees extracted abstract syntax trees (ASTs) of two code snippets, thereby introducing more fine-grained semantic similarity. By conducting extensive experiments on three widely-used datasets, GCJ, OJClone, and BigCloneBench, we demonstrate the great potential of deep subtree interactions in code clone detection task. The proposed DSFM outperforms the state-of-the-art approaches, including two traditional approaches, two unsupervised and four supervised deep learning-based baselines.
@inproceedings{paperbot11343,
title = {DSFM: Enhancing Functional Code Clone Detection with Deep Subtree Interactions},
author = {Zhiwei Xu and Shaohua Qiang and Dinghong Song and Min Zhou and Hai Wan and Xibin Zhao and Ping Luo and Hongyu Zhang},
booktitle = {ICSE},
year = {2024},
doi = {10.1145/3597503.3639215}
}