Software development often involves systematic edits, similar but nonidentical changes to many code locations, that are error-prone and laborious for developers. Mining and learning such systematic edit patterns (SEPs) from past code changes enable us to detect and repair overlooked buggy code that requires systematic edits. A recent study presented a promising SEP mining technique that is based on program dependence graphs (PDGs), while traditional approaches leverage syntax-based representations. PDG-based SEPs are highly expressive and can capture more meaningful changes than syntax-based ones. The next challenge to tackle is to apply the same code changes as in PDG-based SEPs to other code locations; detection and repair of overlooked locations that require systematic edits. Existing program transformation techniques cannot well address this challenge because (1) they expect many structural code similarities that are not guaranteed in PDG-based SEPs or (2) they work on the basis of PDGs but are limited to specific domains (e.g., API migrations). We present in this paper a general-purpose program transformation algorithm for applying PDG-based SEPs. Our algorithm identifies a small transplantable structural subtree for each PDG node, thereby adapting code changes from PDG-based SEPs to other locations. We construct a program repair pipeline Sirius that incorporates the algorithm and automates the processes of mining SEPs, detecting overlooked code locations (bugs) that require systematic edits, and repairing them by applying SEPs. We evaluated the repair performance of Sirius with a corpus of open source software consisting of over 80 repositories. Sirius achieved a precision of 0.710, recall of 0.565, and F1-score of 0.630, while those of the state-of-the-art technique were 0.470, 0.141, and 0.216, respectively.
翻译:软件开发往往涉及对许多代码位置进行系统编辑、类似但非同质的修改,这些修改对开发者来说容易出错和费力。采矿和从过去的代码修改中学习这种系统化编辑模式(SEP),使我们能够发现和修复需要系统编辑的被忽视的错误代码。最近的一项研究展示了一种有希望的SEP采矿技术,这种技术以程序依赖图为基础,而传统方法则利用基于语法的表示方式。基于PDG的SEP是高度直观的,可以捕捉比基于语法的更有意义的变化。下一步要应对的挑战是将基于PDG的SEP的标准化规则(SEP)的数值修改到其他代码(例如,API的直径迁移)。我们用基于语法的通用程序转换到基于SEP的SEP的精度;探测和需要系统化的忽略地点。我们的算法分别由SIDO的小规模结构变换S,而SL的S-D的S-D的S-Siral 程序则由S-D的Siral IM的S-D的精细化流程进行。