一句话:提出 DiffFix,利用节点上下文与类型约束迭代增量修复不完美的 AST 差异映射,显著提升完美 diff 率。
AST 差异(ASTDiff)通过比较程序的一对抽象语法树来刻画语法层面的代码变更,广泛用于代码评审、克隆检测与回归测试等任务。其核心难点在于两棵 AST 节点之间的准确映射,而现有方法受多样代码变更与不健全节点匹配启发式的影响,往往无法生成完美 diff。作者深入调查发现,多数不准确映射源于忽略上下文与类型层面的约束。为此,论文提出 DiffFix:同时利用节点的上下文约束与类型约束,对不完美 diff 进行迭代、增量式修复。作者开展全面实验,将 DiffFix 用于修复五种先进 ASTDiff 技术生成的 diff。结果表明,DiffFix 将基线技术的完美 diff 率提升 5.25% 至 51.12%,且时间开销可忽略不计。
The abstract syntax tree differencing (ASTDiff) technique aims to capture syntactic code changes through comparing the differences between a pair of ASTs of a program, which has been widely used in various program analysis or testing tasks, such as code review, clone detection, and regression testing. A key issue for ASTDiff lies in the accurate mappings between nodes of two ASTs. However, most existing approaches often fail to generate such perfect diffs due to the gap between diverse code changes and unsound node matching heuristics. Our in-depth investigation reveals that most inaccurate mappings are caused by the ignorance of context- and/or type-specific constraints. Accordingly, we propose an AST diff fixing approach DiffFix that leverages both the node’s context and type constraints to iteratively and incrementally fix imperfect diffs. Comprehensive experiments have been conducted to evaluate the effectiveness of DiffFix through its application to fix diffs generated by five state-of-the-art ASTDiff techniques. The experimental results demonstrate that DiffFix can improve the perfect diff rate of these baseline techniques by 5.25% to 51.12% with negligible time overhead.
DOI 原文 ·
@inproceedings{paperbot9509,
title = {DiffFix: Incrementally Fixing AST Diffs via Context and Type Information},
author = {Guofeng Zeng and Chang-Ai Sun and Kai Gao and Huai Liu},
booktitle = {ASE},
year = {2025},
doi = {10.1109/ase63991.2025.00237}
}