混合图结构对代码克隆检测效果复杂,纯AST反而有时更优。
AST-Enhanced or AST-Overloaded? The Surprising Impact of Hybrid Graph Representations on Code Clone Detection
- 用多种图结构融合AST,测试不同GNN模型表现
- CFG+DFG增强能提升GCN/GAT准确率,但FA-AST常拖后腿
- GMN模型仅用原始AST就领先,适合追求高效检测的团队
代码克隆是软件工程中危害严重的代码异味,显著增加维护成本并加剧漏洞风险,其检测至关重要。抽象语法树(AST)因精确表达语法结构,成为深度学习代码克隆检测的主流,但缺乏语义信息。近期研究通过引入控制流图(CFG)和数据流图(DFG)等语义图来增强AST表示。然而,不同混合表示的效果及其与各类图神经网络(GNN)的适配性仍不明确。本文开展系统性实证研究,评估多种基于AST的混合图表示在GNN框架下的性能。我们在多个GNN架构上对比了不同组合(如AST+CFG+DFG、FA-AST)。结果表明:混合表示对卷积型与注意力型模型(如GCN、GAT)有正向作用,而FA-AST因结构复杂度上升常导致性能下降。值得注意的是,即使仅使用标准AST,GMN模型仍表现最佳,展现出更强的跨代码相似性识别能力,减少了对复杂结构的依赖。
原文摘要 · Abstract (English)
As one of the most detrimental code smells, code clones significantly increase software maintenance costs and heighten vulnerability risks, making their detection a critical challenge in software engineering. Abstract Syntax Trees (ASTs) dominate deep learning-based code clone detection due to their precise syntactic structure representation, but they inherently lack semantic depth. Recent studies address this by enriching AST-based representations with semantic graphs, such as Control Flow Graphs (CFGs) and Data Flow Graphs (DFGs). However, the effectiveness of various enriched AST-based representations and their compatibility with different graph-based machine learning techniques remains an open question, warranting further investigation to unlock their full potential in addressing the complexities of code clone detection. In this paper, we present a comprehensive empirical study to rigorously evaluate the effectiveness of AST-based hybrid graph representations in Graph Neural Network (GNN)-based code clone detection. We systematically compare various hybrid representations ((CFG, DFG, Flow-Augmented ASTs (FA-AST)) across multiple GNN architectures. Our experiments reveal that hybrid representations impact GNNs differently: while AST+CFG+DFG consistently enhances accuracy for convolution- and attention-based models (Graph Convolutional Networks (GCN), Graph Attention Networks (GAT)), FA-AST frequently introduces structural complexity that harms performance. Notably, GMN outperforms others even with standard AST representations, highlighting its superior cross-code similarity detection and reducing the need for enriched structures.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。