Detecting Code Clones with Graph Neural Networkand Flow-Augmented Abstract Syntax Tree

02/20/2020
by   Wenhan Wang, et al.
0

Code clones are semantically similar code fragments pairs that are syntactically similar or different. Detection of code clones can help to reduce the cost of software maintenance and prevent bugs. Numerous approaches of detecting code clones have been proposed previously, but most of them focus on detecting syntactic clones and do not work well on semantic clones with different syntactic features. To detect semantic clones, researchers have tried to adopt deep learning for code clone detection to automatically learn latent semantic features from data. Especially, to leverage grammar information, several approaches used abstract syntax trees (AST) as input and achieved significant progress on code clone benchmarks in various programming languages. However, these AST-based approaches still can not fully leverage the structural information of code fragments, especially semantic information such as control flow and data flow. To leverage control and data flow information, in this paper, we build a graph representation of programs called flow-augmented abstract syntax tree (FA-AST). We construct FA-AST by augmenting original ASTs with explicit control and data flow edges. Then we apply two different types of graph neural networks (GNN) on FA-AST to measure the similarity of code pairs. As far as we have concerned, we are the first to apply graph neural networks on the domain of code clone detection. We apply our FA-AST and graph neural networks on two Java datasets: Google Code Jam and BigCloneBench. Our approach outperforms the state-of-the-art approaches on both Google Code Jam and BigCloneBench tasks.

READ FULL TEXT
research
11/23/2020

Modeling Functional Similarity in Source Code with Graph-Based Siamese Networks

Code clones are duplicate code fragments that share (nearly) similar syn...
research
05/31/2022

Learning to Represent Programs with Code Hierarchies

Graph neural networks have been shown to produce impressive results for ...
research
06/27/2023

Automated Static Warning Identification via Path-based Semantic Representation

Despite their ability to aid developers in detecting potential defects e...
research
05/07/2023

Heterogeneous Directed Hypergraph Neural Network over abstract syntax tree (AST) for Code Classification

Code classification is a difficult issue in program understanding and au...
research
06/14/2022

Exploring Representation of Horn Clauses using GNNs (technique report)

Learning program semantics from raw source code is challenging due to th...
research
07/27/2023

CodeLens: An Interactive Tool for Visualizing Code Representations

Representing source code in a generic input format is crucial to automat...
research
05/09/2023

Learning to Parallelize with OpenMP by Augmented Heterogeneous AST Representation

Detecting parallelizable code regions is a challenging task, even for ex...

Please sign up or login with your details

Forgot password? Click here to reset