一句话:提出 GENPAT,利用大代码统计与代码上下文,从单个程序变更示例推断通用程序变换,并验证于系统化编辑与修复。
从具体程序变更推断程序变换可用于系统化编辑、重构和自动修复,但现有方法多依赖大量变更示例。本文研究仅凭单个示例推断变换,核心洞察是 Big Code 可指导泛化:频繁出现的代码元素更通用,不应被抽象。方法用超图表示程序以支持细粒度泛化,并设计 GENPAT,结合代码上下文和大代码统计推断变换。评估覆盖系统化编辑与程序修复:系统化编辑中正确变换案例比 SYDIT 最多提升 5.5 倍;在 Defects4J 上通过已有补丁推断的变换修复 19 个真实 bug,其中 4 个此前无技术可修。结果表明该方法有效且具广泛适用潜力。
Inferring program transformations from concrete program changes has many potential uses, such as applying systematic program edits, refactoring, and automated program repair. Existing work for inferring program transformations usually rely on statistical information over a potentially large set of program-change examples. However, in many practical scenarios we do not have such a large set of program-change examples. In this paper, we address the challenge of inferring a program transformation from one single example. Our core insight is that "big code" can provide effective guide for the generalization of a concrete change into a program transformation, i.e., code elements appearing in many files are general and should not be abstracted away. We first propose a framework for transformation inference, where programs are represented as hypergraphs to enable fine-grained generalization of transformations. We then design a transformation inference approach, GENPAT, that infers a program transformation based on code context and statistics from a big code corpus. We have evaluated GENPAT under two distinct application scenarios, systematic editing and program repair. The evaluation on systematic editing shows that GENPAT significantly outperforms a state-of-the-art approach, SYDIT, with up to 5.5x correctly transformed cases. The evaluation on program repair suggests that GENPAT has the potential to be integrated in advanced program repair tools-GENPAT successfully repaired 19 real-world bugs in the Defects4J benchmark by simply applying transformations inferred from existing patches, where 4 bugs have never been repaired by any existing technique. Overall, the evaluation results suggest that GENPAT is effective for transformation inference and can potentially be adopted for many different applications.
DOI 原文 ·
@inproceedings{paperbot5226,
title = {Inferring Program Transformations From Singular Examples via Big Code},
author = {Jiajun Jiang and Luyao Ren and Yingfei Xiong and Lingming Zhang},
booktitle = {ASE},
year = {2019},
doi = {10.1109/ase.2019.00033}
}