Nuanced Code Clone Detection Through LLM-Based Code Revision and AST Graph Modeling

Detecting semantically equivalent but syntactically diverse code clones (Type-4) remains challenging for traditional AST- or token-based approaches. We propose a clone detection framework that couples <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">LLM-based code revision</i> with <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">AST graph modeling</i> and <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">Graph Attention Networks</i> (GAT), trained via a joint objective that includes a contrastive loss to align embeddings of semantically equivalent fragments. Concretely, we use an LLM to generate syntactically altered but functionally identical variants, thereby augmenting training data with <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">nuanced code clones</i>—subtle edits such as identifier renaming, control-flow restructuring, or statement reordering that preserve program behavior while confusing purely syntactic matchers. On Google Code Jam (GCJ), the proposed method attains Precision 0.99, Recall 0.98, and F1 0.985, outperforming the strongest baseline (F1 = 0.97) by +1.5 percentage points (relative ≈ +1.6%). On BigCloneBench, it achieves Precision 0.97, Recall 0.96, and F1 0.97, improving over the best baseline (F1 = 0.93) by +4.0 pp (relative ≈ +4.3%). For the hardest WT3/T4 category, the framework reaches F1 97.4 versus 93.6 for a strong GNN baseline (+3.8 pp). Ablations indicate that (i) LLM-based augmentation and (ii) GAT-based AST encoding are both critical to performance. In addition to accuracy, we discuss computational considerations (augmentation/training cost), portability beyond Java, and potential extensions toward dynamic clone detection. The results suggest that marrying LLM-generated <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">nuanced</i> variants with graph-based program representations yields robust Type-4 clone detection while remaining scalable to practical codebases.

Authors

Institutions

Publication Details

Journal
IEEE Access
Published
2025-01-01
DOI
https://doi.org/10.1109/access.2025.3628856
Citations
1
Primary Topic
Software Engineering Research
Type
article
Field-Weighted Citation Impact
3.25
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Nuanced Code Clone Detection Through LLM-Based Code Revision and AST Graph Modeling

Jessada Konpang, Chunguang Li, Shilong Wang, Adisorn Sirikham
1 citations
IEEE Access
Software Engineering Research
3.25
article

Nuanced Code Clone Detection Through LLM-Based Code Revision and AST Graph Modeling

Jessada Konpang, Chunguang Li, Shilong Wang, Adisorn Sirikham
article en
1 citations

Abstract

Detecting semantically equivalent but syntactically diverse code clones (Type-4) remains challenging for traditional AST- or token-based approaches. We propose a clone detection framework that couples <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">LLM-based code revision</i> with <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">AST graph modeling</i> and <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">Graph Attention Networks</i> (GAT), trained via a joint objective that includes a contrastive loss to align embeddings of semantically equivalent fragments. Concretely, we use an LLM to generate syntactically altered but functionally identical variants, thereby augmenting training data with <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">nuanced code clones</i>—subtle edits such as identifier renaming, control-flow restructuring, or statement reordering that preserve program behavior while confusing purely syntactic matchers. On Google Code Jam (GCJ), the proposed method attains Precision 0.99, Recall 0.98, and F1 0.985, outperforming the strongest baseline (F1 = 0.97) by +1.5 percentage points (relative ≈ +1.6%). On BigCloneBench, it achieves Precision 0.97, Recall 0.96, and F1 0.97, improving over the best baseline (F1 = 0.93) by +4.0 pp (relative ≈ +4.3%). For the hardest WT3/T4 category, the framework reaches F1 97.4 versus 93.6 for a strong GNN baseline (+3.8 pp). Ablations indicate that (i) LLM-based augmentation and (ii) GAT-based AST encoding are both critical to performance. In addition to accuracy, we discuss computational considerations (augmentation/training cost), portability beyond Java, and potential extensions toward dynamic clone detection. The results suggest that marrying LLM-generated <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">nuanced</i> variants with graph-based program representations yields robust Type-4 clone detection while remaining scalable to practical codebases.

IEEE AccessVol. 13
Rajamangala University of Technology Krungthep (TH), College of Accounting (SI)
Openalex Percentile: Top 6%
Software Engineering Research
3.25
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.