Code Clone Detection Based on Program Dependence Graph and Graph Attention Networks

  • DU Siyu ,
  • XU Xin
Expand
  • 1. School of Computer Science, Hangzhou Dianzi University Hangzhou 310018, China;
    2. School of Communication Engineering, Hangzhou University of Electronic Science and Technology, Hangzhou 310018, China

Received date: 2023-06-08

  Online published: 2024-10-18

Abstract

With the escalating prevalence of software plagiarism and code cloning incidents, the efficient detection of similar code segments has become increasingly vital, particularly in the context of semantic similarity-based code clone detection, which holds significant implications for advancing research and safeguarding intellectual property rights. Semantic similarity clones, characterized by their shared functionality and semantic underpinnings, pose a greater challenge to detection than syntactic similarities. To address this issue, this paper proposes an innovative detection approach that employs Program Dependency Graph(PDG) instead of Abstract Syntax Tree, thereby offering a more effective means of representing code's semantic information. By integrating Graph Attention Networks (GAT)into our method, it can extract salient semantic features from PDG and subsequently calculate the functional similarity between two pieces of codes. Experimental results demonstrate that the proposed method based on PDG and GAT significantly outperforms existing methods in detecting semantic similarity clones.

Cite this article

DU Siyu , XU Xin . Code Clone Detection Based on Program Dependence Graph and Graph Attention Networks[J]. Journal of Hangzhou Dianzi University, 2024 , 44(4) : 27 -36 . DOI: 10.13954/j.cnki.hdu.2024.04.004

References

[1] KIM M, BERGMAN L, LAU T, et al. An ethnographic study of copy and paste programming practices in OOPL[C]//Proceedings. 2004 International Symposium on Empirical Software Engineering, 2004. ISESE'04. IEEE, 2004:83-92.
[2] BURD E, BAILEY J. Evaluating clone detection tools for use during preventative maintenance[C]//Proceedings. Second IEEE International Workshop on Source Code Analysis and Manipulation. IEEE, 2002:36-43.
[3] SVAJLENKO J, ISLAM J F, KEIVANLOO I, et al. Towards a big data curated benchmark of inter-project code clones[C]//2014 IEEE International Conference on Software Maintenance and Evolution. IEEE, 2014:476-480.
[4] BELLON S, KOSCHKE R, ANTONIOL G, et al. Comparison and evaluation of clone detection tools[J]. IEEE Transactions on Software Engineering, 2007,33(9):577-591.
[5] SAINI V, FARNAHINIFARAHANI F, LU Y, et al. Oreo: Detection of clones in the twilight zone[C]//Proceedings of the 2018 26th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering. 2018:354-365.
[6] WHITE M, TUFANO M, VENDOME C, et al. Deep learning code fragments for code clone detection[C]//Proceedings of the 31st IEEE/ACM International Conference on Automated Software Engineering. Singapore,ACM,2016:87-98.
[7] ZHANG J, WANG X, ZHANG H, et al. A novel neural source code representation based on abstract syntax tree[C]//2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE). IEEE, 2019:783-794.
[8] JIANG L, MISHERGHI G, SU Z, et al. Deckard: Scalable and accurate tree-based detection of code clones[C]//29th International Conference on Software Engineering (ICSE'07). IEEE, 2007:96-105.
[9] WEI H, LI M. Supervised deep features for software functional clone detection by exploiting lexical and syntactical information in source code[C]//Proceedings of the Twenty-Sixth International Joint Conference on Artificial Intelligence. Melbourne, Australia. California: International Joint Conferences on Artificial Intelligence Organization, 2017:3034-3040.
[10] WANG W, LI G, MA B, et al. Detecting code clones with graph neural network and flow-augmented abstract syntax tree[C]//2020 IEEE 27th International Conference on Software Analysis, Evolution and Reengineering (SANER). IEEE, 2020:261-271.
[11] ALLAMANIS M, BROCKSCHMIDT M, KHADEMI M. Learning to represent programs with graphs[J].[EB/OL].(2018-05-04)[2023-06-08].http://arxiv.org/abs/1711.00740.
[12] SIOW J K, LIU S, XIE X, et al. Learning program semantics with code representations: An empirical study[C]//2022 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER). IEEE, 2022:554-565.
[13] KAUR M, RATTAN D. A systematic literature review on the use of machine learning in code clone research[J]. Computer Science Review, 2023,47:100528.
[14] ZHANG W, GUO S, ZHANG H, et al. Challenging machine learning-based clone detectors via semantic-preserving code transformations[J]. IEEE Transactions on Software Engineering, 2023,49(5):3052-3070.
[15] VELIČKOVIĆ P, CUCURULL G, Casanova A, et al. Graph attention networks[EB/OL]. (2018-02-04)[2023-06-08].http://arxiv.org/abs/1710.10903.
[16] XU K, LIU Y. SCCD-GAN: an enhanced semantic code clone detection model using GAN[C]//2021 IEEE 4th International Conference on Electronics and Communication Engineering (ICECE). IEEE, 2021:16-22.
[17] WANG M, WANG P, XU Y. CCSharp: An efficient three-phase code clone detector using modified PDGs[C]//2017 24th Asia-Pacific Software Engineering Conference (APSEC). IEEE, 2017:100-109.
[18] HORWITZ S, PRINS J, REPS T. On the adequacy of program dependence graphs for representing programs[C]//Proceedings of the 15th ACM SIGPLAN-SIGACT symposium on Principles of programming languages. San Diego, California, USA. ACM, 1988:146-157.
Outlines

/

〈 〉