一句话:提出 CCGraph,通过归一化 PDG、两级过滤与基于改进 WL 图核的近似图匹配来高效检测代码克隆。
代码克隆检测对软件维护、缺陷检测等具有重要意义,而基于程序依赖图(PDG)的方法虽能同时刻画语法与结构信息,却大多依赖子图同构进行精确图匹配,因而耗时严重且漏检较多。本文提出新的 PDG 克隆检测器 CCGraph:首先对 PDG 结构做归一化,并通过度量代码的特征向量设计两级过滤策略以快速剪除无关候选;随后采用基于改进 Weisfeiler-Lehman(WL)图核的近似图匹配算法完成克隆检测。实验结果表明,CCGraph 在保持较高准确率的同时,召回率与 F1 值均有更优表现,能够检出比其他两个相关最新工具更多的语义克隆,并且效率显著优于现有基于 PDG 的工具。
Software clone detection is an active research area, which is very important for software maintenance, bug detection, etc. The two pieces of cloned code reflect some similarities or equivalents in the syntax or structure of the code representations. There are many representations of code like AST, token, PDG, etc. The PDG (Program Dependency Graph) of source code can contain both syntactic and structural information. However, most existing PDG-based tools are quite time-consuming and miss many clones because they detect code clones with exact graph matching by using subgraph isomorphism. In this paper, we propose a novel PDG-based code clone detector, CCGraph, that uses graph kernels. Firstly, we normalize the structure of PDGs and design a two-stage filtering strategy by measuring the characteristic vectors of codes. Then we detect the code clones by using an approximate graph matching algorithm based on the reforming WL (Weisfeiler-Lehman) graph kernel. Experiment results show that CCGraph retains a high accuracy, has both better recall and F1-score values, and detects more semantic clones than other two related state-of-the-art tools. Besides, CCGraph is much more efficient than the existing PDG-based tools.
DOI 原文 ·
@inproceedings{paperbot5962,
title = {CCGraph},
author = {Yue Zou and Bihuan Ban and Yinxing Xue and Yun Xu},
booktitle = {ASE},
year = {2020},
doi = {10.1145/3324884.3416541}
}