Neural Detection of Semantic Code Clones Via Tree-Based Convolution
By Hao Yu, Wing Lam, Long Chen, Ge Li, Tao Xie, Qianxiang Wang. 2019
132 citations recorded by the source corpus.
Code clones are similar code fragments that share the same semantics but may differ syntactically to various degrees. Detecting code clones helps reduce the cost of software maintenance and prevent faults. Various approaches of detecting code clones have been proposed over the last two decades, but few of them can detect semantic clones, i.e., code clones with dissimilar syntax. Recent research has attempted to adopt deep learning for detecting code clones, such as using tree-based LSTM over Abstract Syntax Tree (AST). However, it does not fully leverage the structural information of code fragments, thereby limiting its clone-detection capability. To fully unleash the power of deep learning for detecting code clones, we propose a new approach that uses tree-based convolution to detect semantic clones, by capturing both the structural information of a code fragment from its AST and lexical information from code tokens. Additionally, our approach addresses the limitation that source code has an unlimited vocabulary of tokens and models, and thus exploiting lexical information from code tokens is often ineffective when dealing with unseen tokens. Particularly, we propose a new embedding technique called position-aware character embedding (PACE), which essentially treats any token as a position-weighted combination of character one-hot embeddings. Our experimental results show that our approach substantially outperforms an existing state-of-the-art approach with an increase of 0.42 and 0.15 in F1-score on two popular code-clone benchmarks (OJClone and BigCloneBench), respectively, while being more computationally efficient. Our experimental results also show that PACE enables our approach to be substantially more effective when code clones contain unseen tokens.
Subfields: Information Systems, Software, Code Generation & Program Synthesis, 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 Information Systems
- Daya Guo
- Nan Duan
- Neel Sundaresan
- Alexey Svyatkovskiy
- Colin B. Clement
- Baishakhi Ray
- Saikat Chakraborty
- Shao Kun Deng
In Software
- Neel Sundaresan
- Alexey Svyatkovskiy
- Daya Guo
- Nan Duan
- Colin B. Clement
- Shao Kun Deng
- Dawn Drain
- Baishakhi Ray
In Code Generation & Program Synthesis
- Wasi Uddin Ahmad
- Baishakhi Ray
- Saikat Chakraborty
- Kai-Wei Chang
- Ge Li
- Nan Duan
- Daya Guo
- Neel Sundaresan
In Program Analysis & Verification
- Ge Li
- Neel Sundaresan
- Daya Guo
- Baishakhi Ray
- Michele Tufano
- Nan Duan
- Alexey Svyatkovskiy
- Saikat Chakraborty
In Signal Processing
- Baishakhi Ray
- Saikat Chakraborty
- Wasi Uddin Ahmad
- Long Zhou
- Ge Li
- Neel Sundaresan
- Shujie Liu
- Daya Guo
Citations in the corpus
- Unified Pre-training for Program Understanding and Generation (2021, background): “, 2020), Clone Detection (Zhang et al., 2019; Yu et al., 2019; Wang et al., 2020), Code completion (Li et al.”
- CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generation (2021, methodology): “TBCCD [96] proposes a position-aware character embedding and uses treebased convolution to capture both the structural information of a code fragment from its AST and lexical information from code tokens.”