Detecting Code Clones with Graph Neural Network and Flow-Augmented Abstract Syntax Tree
By Wenhan Wang, Ge Li, Bo Ma, Xin Xia, Zhi Jin. 2020
325 citations recorded by the source corpus.
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.
Subfields: Computer Networks and Communications, Information Systems, Graph Learning, Program Analysis & Verification, Signal Processing
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Computer Networks and Communications
- Marie-Anne Lachaux
- Ge Li
- M. Zhou
- Neel Sundaresan
- Shao Kun Deng
- Guillaume Lample
- Shengyu Fu
- Kai-Wei Chang
In Information Systems
- Nan Duan
- Daya Guo
- Baptiste Rozière
- Neel Sundaresan
- Alexey Svyatkovskiy
- Jian Yin
- Marc Szafraniec
- Guillaume Lample
In Graph Learning
In Program Analysis & Verification
- Marie-Anne Lachaux
- Ge Li
- Jian Yin
- Neel Sundaresan
- Guillaume Lample
- Daya Guo
- Marc Szafraniec
- Baishakhi Ray
In Signal Processing
- Baishakhi Ray
- Saikat Chakraborty
- Baptiste Rozière
- Guillaume Lample
- Marie-Anne Lachaux
- Wasi Uddin Ahmad
- Long Zhou
- Ge Li
Citations in the corpus
- Unified Pre-training for Program Understanding and Generation (2021, background): “, 2019) Clone Detection Java 100,000 10,000 415,416 (Wang et al., 2020)”
- CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generation (2021, methodology): “• code-code (clone detection [65, 84, 46, 80, 9, 89, 86], defect detection [91, 55, 51, 42, 78, 79], cloze test [15], code completion [57, 1, 56, 66, 67, 8, 27, 7], code repair [69, 4, 23, 26, 71, 73], and code-to-code translation [48, 37, 10, 41]) • text-code (natural language code search [32, 20, ”
- DOBF: A Deobfuscation Pre-Training Objective for Programming Languages (2021, methodology): “Machine learning is frequently used on tasks involving programming languages, including code completion [28, 33, 35, 42], bug detection and code repair [15, 38, 46], code summarization [8, 25], clone detection [2, 47, 48], code search [13, 23] and code translation [14, 41].”
- GraphCodeBERT: Pre-training Code Representations with Data Flow (2020, methodology): “FA-AST-GMN (Wang et al., 2020) uses GNNs over a flow-augmented AST to leverages explicit control and data flow information for code clone detection.”
- HELoC: Hierarchical Contrastive Learning of Source Code Representation (2022, methodology): “FA-AST [5] constructs a flow-augmented AST by adding explicit control and data flow edges, thus enabling the method to make full use of the semantic information for code representations.”
- Software Testing With Large Language Models: Survey, Landscape, and Vision (2023, unknown): “Besides, researches also utilize the abstract syntax tree and control flow [103], [104] for code representation and achieve good performance.”