Automated Program Repair (APR) improves software reliability by generating patches for a buggy program automatically. Recent APR techniques leverage deep learning (DL) to build models to learn to generate patches from existing patches and code corpora. While promising, DL-based APR techniques suffer from the abundant syntactically or semantically incorrect patches in the patch space. These patches often disobey the syntactic and semantic domain knowledge of source code and thus cannot be the correct patches to fix a bug. We propose a DL-based APR approach KNOD, which incorporates domain knowledge to guide patch generation in a direct and comprehensive way. KNOD has two major novelties, including (1) a novel three-stage tree decoder, which directly generates Abstract Syntax Trees of patched code according to the inherent tree structure, and (2) a novel domain-rule distillation, which leverages syntactic and semantic rules and teacher-student distributions to explicitly inject the domain knowledge into the decoding procedure during both the training and inference phases. We evaluate KNOD on three widely-used benchmarks. KNOD fixes 72 bugs on the Defects4J v1.2, 25 bugs on the QuixBugs, and 50 bugs on the additional Defects4J v2.0 benchmarks, outperforming all existing APR tools.
翻译:自动程序维修( APR) 通过自动生成错误程序补丁来提高软件的可靠性。 最近的 APR 技术利用了深层次的学习( DL) 来建立模型, 以学习从现有的补丁和代码库生成补丁。 虽然很有希望, DL 以 PR 为基础的技术在补丁空间里会遇到大量的合成或语义不正确的补丁。 这些补丁往往不符合源代码的合成和语义域知识, 因而不能成为纠正错误的正确补丁。 我们提议了基于 DL 的 APR 方法 KONOD, 其中包括直接和全面地指导补丁生成的域知识。 KNOD 有两大新颖之处, 包括:(1) 一个新的三阶段树分解码, 直接生成与固有树结构相符的补丁代码摘要;(2) 新的域规则蒸馏, 利用合成和语义规则以及师资研究的分布, 将域知识明确输入培训和推断阶段的解码程序。 我们评估了KNOD 25- Dfiral 4 在三个广泛使用的基准上, 25- baltial Q- bal 4 Q- balviews 。