그래프 기반 시아먼 네트워크를 활용한 소스 코드 기능적 유사성 모델링
Modeling Functional Similarity in Source Code with Graph-Based Siamese Networks
Modeling Functional Similarity in Source Code with Graph-Based Siamese Networks
@misc{mehrotra2020modeling,
title = {Modeling Functional Similarity in Source Code with Graph-Based Siamese Networks},
author = {Nikita Mehrotra and Navdha Agarwal and Piyush Gupta and Saket Anand and David Lo and Rahul Purandare},
year = {2020},
eprint = {2011.11228},
archivePrefix = {arXiv},
primaryClass = {cs.SE},
url = {https://arxiv.org/abs/2011.11228}
}
Mehrotra, N., Agarwal, N., Gupta, P., Anand, S., Lo, D., & Purandare, R. (2020). Modeling Functional Similarity in Source Code with Graph-Based Siamese Networks [Preprint]. arXiv. https://doi.org/10.48550/arXiv.2011.11228
MEHROTRA N, AGARWAL N, GUPTA P, et al. Modeling Functional Similarity in Source Code with Graph-Based Siamese Networks[EB/OL]. (2020-11-23)[2026-11-29]. https://arxiv.org/abs/2011.11228.
초록
코드 클론은 (거의) 유사한 문법이나 의미를 공유하는 중복 코드 조각으로, 소프트웨어 유지보수, 코드 리팩토링 및 재사용에서 중요한 역할을 한다. 과거에는 클론을 탐지하기 위한 상당한 양의 연구가 수행되었으며, 대부분의 접근법은 클론을 탐지하기 위해 단어론적 및 문법적 정보를 활용한다. 그러나 이러한 방법들 중 대부분은 의미적 클론을 대상으로 하지 않는다. 최근 자연어 처리 및 컴퓨터 비전 등 다른 분야에서 딥러닝 모델의 성공을 계기로, 연구자들은 코드 클론 탐지에 딥러닝 기법을 적용하려는 시도를 하고 있다. 이러한 접근법은 단어론적 정보 (토큰) 와 추상 문법 트리 (AST) 와 같은 문법 구조를 활용하여 코드 클론을 탐지한다. 그러나 이용 가능한 구조적 및 의미적 정보를 충분히 활용하지 못해 그 성능에 한계가 있다. 본 논문은 프로그램 의존성 그래프와 기하학적 신경망을 활용하여 구조화된 문법 및 의미 정보를 기반으로 의미적 코드 클론 탐지 문제를 해결한다. 우리는 제안한 새로운 접근법에 기반한 프로토타입 도구 HOLMES 를 개발하고, 일반적인 코드 클론 벤치마크에서 이를 경험적으로 평가하였다. 우리의 결과는 HOLMES 가 현재 최상위 수준 도구인 TBCCD 보다 현저히 더 좋은 성능을 발휘함을 보여준다. 또한 HOLMES 를 보이지 않는 프로젝트에서 평가하고 교차 데이터셋 실험을 수행하여 HOLMES 의 일반화 능력을 평가하였다. 우리의 결과는 HOLMES 가 TBCCD 를 능가함을 확인하며, HOLMES 가 탐지한 대부분의 쌍이 TBCCD 에서는 탐지되지 않거나 최적화되지 않은 방식으로 보고되었음을 보여준다.
Code clones are duplicate code fragments that share (nearly) similar syntax or semantics. Code clone detection plays an important role in software maintenance, code refactoring, and reuse. A substantial amount of research has been conducted in the past to detect clones. A majority of these approaches use lexical and syntactic information to detect clones. However, only a few of them target semantic clones. Recently, motivated by the success of deep learning models in other fields, including natural language processing and computer vision, researchers have attempted to adopt deep learning techniques to detect code clones. These approaches use lexical information (tokens) and(or) syntactic structures like abstract syntax trees (ASTs) to detect code clones. However, they do not make sufficient use of the available structural and semantic information hence, limiting their capabilities. This paper addresses the problem of semantic code clone detection using program dependency graphs and geometric neural networks, leveraging the structured syntactic and semantic information. We have developed a prototype tool HOLMES, based on our novel approach, and empirically evaluated it on popular code clone benchmarks. Our results show that HOLMES performs considerably better than the other state-of-the-art tool, TBCCD. We also evaluated HOLMES on unseen projects and performed cross dataset experiments to assess the generalizability of HOLMES. Our results affirm that HOLMES outperforms TBCCD since most of the pairs that HOLMES detected were either undetected or suboptimally reported by TBCCD.