arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.09304cs.SEcs.HC
收藏

从自然语言问题生成复杂代码分析器

Generating Complex Code Analyzers from Natural Language Questions

University of Southern California(南加州大学)

Amirmohammad Nazari, Sadra Sabouri, Wang Bill Zhu, Robin Jia, Souti Chattopadhyay, Mukund Raghothaman

AI总结:

本文提出Merlin系统,通过整合LLM与CodeQL,解决复杂代码分析问题,提升代码问题解答的准确性和效率。

摘要:

许多软件开发任务,如实现功能和修复bug,始于开发者对代码库的问题提问。然而,回答涉及数百万行代码和数千文件的代码库问题极具挑战性。标准工具如grep无法回答需要语义或跨过程推理的问题,而大语言模型(LLMs)因资源和上下文限制难以处理大规模代码库。本文提出Merlin,一种新的系统,用于回答需要代码分析推理的自由形式问题。Merlin整合了LLM与CodeQL,一种支持对大规模代码库进行表达性查询的程序分析框架。我们面临两个主要挑战:首先,程序分析查询多样且语义复杂;因此,即使语法正确,查询也常产生退化或空结果。此外,CodeQL查询相对较少,限制了LLM作为CodeQL查询生成器的即开即用效果。我们通过开发基于RAG的迭代查询生成方法和新的自测技术来解决这些挑战。我们的查询调试技术基于辅助查询的概念,生成具体的见证者,以暴露和解释候选查询中的语义缺陷。通过实验和用户研究评估Merlin。在一组从常见bug查找任务中衍生的自然语言问题上,Merlin不仅发现了其他方法报告的大多数软件问题,还发现了其他方法无法发现的问题。通过一项内组用户研究,我们发现访问Merlin使任务准确性平均提高了3.8倍,同时减少了程序员完成所有任务的时间31%。

英文摘要:

Many software development tasks, such as implementing features and fixing bugs, begin with developers posing questions about a codebase. However, answering questions about codebases that span millions of lines of code across thousands of files is non-trivial. Standard tools like grep cannot answer questions requiring semantic or inter-procedural reasoning, and large language models (LLMs) struggle with large codebases due to resource and context constraints. In this paper, we present Merlin, a new system for answering free-form questions that require analytical reasoning about code. Merlin integrates an LLM with CodeQL, a program analysis framework that supports expressive queries over large codebases. We face two principal challenges in the design of such systems: First, program analysis queries are diverse and semantically complex; as a result, even syntactically well-formed queries frequently produce degenerate/empty results. Furthermore, relatively few CodeQL queries are available online, limiting the out-of-the-box effectiveness of LLMs as CodeQL query generators. We address these challenges by developing a RAG-based iterative query-generation approach and a novel self-test technique. Our query debugging technique builds on the idea of assistive queries, which generate concrete witnesses that expose and explain semantic flaws in candidate queries. We evaluate Merlin through both experimental and user studies. Over a set of natural language questions derived from common bug-finding tasks, Merlin discovered not only the majority of software issues reported by other approaches, but also issues that would have otherwise remained undetected. Through a within-subject user study, we found that access to Merlin increased task accuracy by an average of 3.8* and simultaneously reduced the time for programmers to complete all tasks by 31%.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑