Type-4 clones refer to a pair of code snippets with similar semantics but written in different syntax, which challenges the existing code clone detection techniques. Previous studies, however, highly rely on syntactic structures and textual tokens, which cannot precisely represent the semantic information of code and might introduce non-negligible noise into the detection models. To overcome these limitations, we design a novel semantic graph-based deep detection approach, called SEED. For a pair of code snippets, SEED constructs a semantic graph of each code snippet based on intermediate representation to represent the code semantic more precisely compared to the representations based on lexical and syntactic analysis. To accommodate the characteristics of Type-4 clones, a semantic graph is constructed focusing on the operators and API calls instead of all tokens. Then, SEED generates the feature vectors by using the graph match network and performs clone detection based on the similarity among the vectors. Extensive experiments show that our approach significantly outperforms two baseline approaches over two public datasets and one customized dataset. Especially, SEED outperforms other baseline methods by an average of 25.2% in the form of F1-Score. Our experiments demonstrate that SEED can reach state-of-the-art and be useful for Type-4 clone detection in practice.
翻译:类型-4 克隆是指一对具有类似语义学的代码片段,但以不同的语法写成,对现有的代码克隆探测技术提出了挑战。然而,以往的研究高度依赖合成结构和文本符号,这些符号不能准确地代表代码的语义信息,可能会在检测模型中引入不可忽略的噪音。为了克服这些局限性,我们设计了一个新型的语义图形深度探测方法,称为SEEED。对于一对代码片段,SEID构建了一个每个代码片段的语义图,以中间表达方式为基础,更准确地代表代码语义学,与基于词汇和合成分析的表达方式相比。为了容纳类型-4 克隆的特征,正在构建一个以操作者为主的语义图解图,并可能在所有符号中引入不可忽略的噪音。然后,SEEEDD通过图形匹配网络并根据矢量的相似性进行克隆检测。广泛的实验表明,我们的方法在两个公共数据集和一个定制的数据集中,两个基线方法明显优于两个基准路径,一个定制的数据集,一个是SEEECD-D 平均的S- 25D 样实验中,可以展示其他的基样样的基样方法。