Automated Program Repair (APR) aspires to automatically generate patches for an input buggy program. Traditional APR tools typically focus on specific bug types and fixes through the use of templates, heuristics, and formal specifications. However, these techniques are limited in terms of the bug types and patch variety they can produce. As such, researchers have designed various learning-based APR tools with recent work focused on directly using Large Language Models (LLMs) for APR. While LLM-based APR tools are able to achieve state-of-the-art performance on many repair datasets, the LLMs used for direct repair are not fully aware of the project-specific information such as unique variable or method names. The plastic surgery hypothesis is a well-known insight for APR, which states that the code ingredients to fix the bug usually already exist within the same project. Traditional APR tools have largely leveraged the plastic surgery hypothesis by designing manual or heuristic-based approaches to exploit such existing code ingredients. However, as recent APR research starts focusing on LLM-based approaches, the plastic surgery hypothesis has been largely ignored. In this paper, we ask the following question: How useful is the plastic surgery hypothesis in the era of LLMs? Interestingly, LLM-based APR presents a unique opportunity to fully automate the plastic surgery hypothesis via fine-tuning and prompting. To this end, we propose FitRepair, which combines the direct usage of LLMs with two domain-specific fine-tuning strategies and one prompting strategy for more powerful APR. Our experiments on the widely studied Defects4j 1.2 and 2.0 datasets show that FitRepair fixes 89 and 44 bugs (substantially outperforming the best-performing baseline by 15 and 8), respectively, demonstrating a promising future of the plastic surgery hypothesis in the era of LLMs.
翻译:自动程序修复旨在为输入的错误程序自动生成补丁。传统APR工具通常通过模板、启发式规则和形式化规范聚焦于特定缺陷类型和修复方法。然而,这些技术在可处理的缺陷类型和补丁多样性方面存在局限。为此,研究者设计了多种基于学习的APR工具,近期工作更直接利用大语言模型进行程序修复。尽管基于LLM的APR工具能在许多修复数据集上取得最先进性能,但直接用于修复的LLM并未充分感知项目特有信息(如独特的变量或方法名)。塑性手术假说是APR领域的经典洞见,指出修复缺陷所需的代码成分通常已存在于同一项目中。传统APR工具主要通过设计人工或启发式方法来利用此类现有代码成分。然而,随着近期APR研究转向基于LLM的方法,塑性手术假说在很大程度上被忽视。本文提出以下问题:在LLM时代,塑性手术假说具有多大价值?有趣的是,基于LLM的APR通过微调和提示工程为完全自动化实现塑性手术假说提供了独特机遇。为此,我们提出FitRepair方法,该方法将LLM的直接使用与两种领域特定微调策略及一种提示策略相结合,以实现更强大的APR。在广泛研究的Defects4j 1.2和2.0数据集上的实验表明,FitRepair分别修复了89个和44个缺陷(分别大幅超越最优基线15个和8个),展示了LLM时代塑性手术假说的光明前景。