Learning Graph-based Code Representations for Source-level Functional Similarity Detection
Jiahao Liu, Jun Zeng, Xiang Wang et al. · IEEE/ACM International Conference on Software Engineering (ICSE) · 2023
Detecting code functional similarity forms the basis of various software engineering tasks. However, the detection is challenging as functionally similar code fragments can be implemented differently, e.g., with irrelevant syntax. Recent studies incorporate program dependencies as semantics to identify syntactically different yet semantically similar programs, but they often focus only on local neighborhoods (e.g., one-hop dependencies), limiting the expressiveness of program semantics in modeling functionalities. In this paper, we present Tailor that explicitly exploits deep graph-structured code features for functional similarity detection. Given source-level programs, Tailor first represents them into code property graphs (CPGs) - which combine abstract syntax trees, control flow graphs, and data flow graphs - to collectively reason about program syntax and semantics. Then, Tailor learns representations of CPGs by applying a CPG-based neural network (CPGNN) to iteratively propagate information on them. It improves over prior work on code representation learning through a new graph neural network (GNN) tailored to CPG structures instead of the off-the-shelf GNNs used previously. We systematically evaluate Tailor on C and Java programs using two public benchmarks. Experimental results show that Tailor outperforms the state-of-the-art approaches, achieving 99.8% and 99.9% F-scores in code clone detection and 98.3% accuracy in source code classification.
Cited by 30 works. doi:10.1109/icse48619.2023.00040
Authors
References
- Adam: A Method for Stochastic Optimization
- Efficient Estimation of Word Representations in Vector Space
- Visualizing Data using t-SNE
- Understanding the difficulty of training deep feedforward neural networks
- TensorFlow: A system for large-scale machine learning
- Detecting Functionality-Specific Vulnerabilities via Retrieving Individual Functionality-Equivalent APIs in Open-Source Repositories
- On the Properties of Neural Machine Translation: Encoder–Decoder Approaches
- The Graph Neural Network Model
- Graph Attention Networks
- Targeted Branching for the Maximum Independent Set Problem Using Graph Neural Networks