Skip to main content
QUICK REVIEW

[논문 리뷰] Detecting Code Clones with Graph Neural Networkand Flow-Augmented Abstract Syntax Tree

Wenhan Wang, Ge Li|arXiv (Cornell University)|2020. 02. 20.
Software Engineering Research참고 문헌 23인용 수 32
한 줄 요약

이 논문은 FA-AST를 도입하고 GGNN 및 GMN 그래프 신경망을 적용하여 의미적 코드 클론을 탐지하며 GCJ와 BigCloneBench 데이터셋에서 최첨단 성능을 달성한다.

ABSTRACT

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.

연구 동기 및 목표

  • 구문적 유사성을 넘어선 의미적(타입-4) 코드 클론 탐지의 도전을 제시합니다.
  • FA-AST라 불리는 그래프 기반 표현을 제안합니다. 이 표현은 구문, 제어 흐름, 데이터 흐름을 인코딩합니다.
  • 코드 클론 탐지를 위한 두 GNN 모델(GGNN과 GMN)을 개발하고 비교합니다.
  • 두 자바 데이터셋(Google Code Jam과 BigCloneBench)에서 평가하고 AST 기반 기준선보다 향상된 성능을 보임을 보여줍니다.

제안 방법

  • 제어 흐름 엣지(If, While, For)와 데이터 흐름 단서(NextUse, NextToken)를 이용해 AST를 보강하여 FA-AST를 구성합니다.
  • 프로그램을 그래프로 표현하고 GGNN을 적용해 MLP 기반 메시지 및 GRU 기반 업데이트로 그래프 임베딩을 학습합니다.
  • GMN을 적용하여 교차 그래프 주의 메커니즘으로 코드 쌍의 임베딩을 공동으로 학습하고 GGNN과 유사한 읽어웃으로 그래프 수준 벡터를 얻습니다.
  • 유사성 예측에 대한 MSE 손실로 학습하고 그래프 임베딩의 코사인 유사도를 코드 클론 판단에 사용합니다.
  • GCJ와 BigCloneBench에서 기저선(DECKARD, RtvNN, CDLH, ASTNN)과 비교하고 검증 데이터에서 임계값을 튜닝합니다.

실험 결과

연구 질문

  • RQ1FA-AST가 코드 조각의 구문 구조와 의미 흐름 정보를 효과적으로 인코딩할 수 있는가?
  • RQ2그래프 신경망(GGNN 및 GMN)이 코드 클론 탐지에서 AST 기반의 딥러닝 접근법을 능가하는가?
  • RQ3GMN의 교차 그래프 주의가 서로 다른 코드 쌍에서 의미적 클론 탐지에 유익한가?
  • RQ4제안된 방법이 GCJ 및 BigCloneBench에서 타입-4/의미적 클론에 대해 어떤 성능을 보이는가?

주요 결과

  • FA-AST+GMN은 Google Code Jam에서 정밀도 0.99, 재현율 0.97, F1 0.98을 달성하며 ASTNN 및 다른 기저선보다 우수합니다.
  • FA-AST+GGNN은 Google Code Jam에서 정밀도 0.96, 재현율 1.0, F1 0.97를 달성하며 대부분의 기저선보다 좋지만 GMN보다 약간 낮습니다.
  • BigCloneBench에서 FA-AST+GMN은 정밀도 0.96, 재현율 0.94, F1 0.95를 달성하며 ASTNN 및 다른 기저선을 앞섭니다.
  • GMN 모델이 일반적으로 GGNN 모델을 능가하여 교차 그래프 주의가 클론 탐지 성능을 향상시킵니다.
  • FA-AST+GMN은 의미적(WT3/T4) 클론에 대해 강력한 성능을 보이며 이 어려운 케이스에서 ASTNN을 능가합니다.

더 나은 연구,지금 바로 시작하세요

논문 읽기부터 검토까지, 연구 시간을 획기적으로 줄여보세요.

카드 등록 없음 · 무료 플랜 제공

이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.