Helping LLMs Improve Code Generation Using Feedback from Testing and Static Analysis
Not on the map. Why?
Abstract (arXiv)
Large Language Models (LLMs) are one of the most promising developments in the field of artificial intelligence, and the software engineering community has readily noticed their potential role in the software development life-cycle. Developers routinely ask LLMs to generate code snippets, increasing productivity but also potentially introducing ownership, privacy, correctness, and security issues. Previous work highlighted how code generated by mainstream commercial LLMs is often not safe, containing vulnerabilities, bugs, and code smells. In this paper, we present a framework that leverages testing and static analysis to assess the quality, and guide the self-improvement, of code generated by general-purpose, open-source LLMs. First, we ask LLMs to generate C code to solve a number of programming tasks. Then we employ ground-truth tests to assess the (in)correctness of the generated code, and a static analysis tool to detect potential safety vulnerabilities. Next, we assess the models ability to evaluate the generated code, by asking them to detect errors and vulnerabilities. Finally, we test the models ability to fix the generated code, providing the reports produced during the static analysis and incorrectness evaluation phases as feedback. Our results show that models often produce incorrect code, and that the generated code can include safety issues. Moreover, they perform very poorly at detecting either issue. On the positive side, we observe a substantial ability to fix flawed code when provided with information about failed tests or potential vulnerabilities, indicating a promising avenue for improving the safety of LLM-based code generation tools.
Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). Builds on 26 of its 39 references that are in the map. First posted on arXiv 19 Dec 2024.
Builds on
26 of 39 references.
References · 26
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2023Mistral 7Bcited by 3,065
- 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 1,906
- 2024Mixtral of Expertscited by 1,785
- 2022Large Language Models Are Human-Level Prompt Engineerscited by 1,020
- 2024Gemma: Open Models Based on Gemini Research and Technologycited by 889
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2022Grounded Copilot: How Programmers Interact with Code-Generating Modelscited by 216
- 2023Is Self-Repair a Silver Bullet for Code Generation?cited by 191
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
- 2023Purple Llama CyberSecEval: A Secure Coding Benchmark for Language Modelscited by 130
14 more
- 2023InferFix: End-to-End Program Repair with LLMscited by 113
- 2021Examining Zero-Shot Vulnerability Repair with Large Language Modelscited by 105
- 2024IRIS: LLM-Assisted Static Analysis for Detecting Security Vulnerabilitiescited by 100
- 2023LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarkscited by 94
- 2024Instruction Tuning for Secure Code Generationcited by 63
- 2023A New Era in Software Security: Towards Self-Healing Software via Large Language Models and Formal Verificationcited by 42
- 2023The FormAI Dataset: Generative AI in Software Security Through the Lens of Formal Verificationcited by 32
- 2024CRUXEval-X: A Benchmark for Multilingual Code Reasoning, Understanding and Executioncited by 31
- 2024How secure is AI-generated Code: A Large-Scale Comparison of Large Language Modelscited by 23
- 2024SCALE: Constructing Structured Natural Language Comment Trees for Software Vulnerability Detectioncited by 17
- 2024PromSec: Prompt Optimization for Secure Generation of Functional Source Code with Large Language Models (LLMs)cited by 17
- 2023Can ChatGPT support software verification?cited by 14
- 2023Practices and Challenges of Using GitHub Copilot: An Empirical Studycited by 13
- 2024Enhancing Source Code Security with LLMs: Demystifying The Challenges and Generating Reliable Repairscited by 4
Built on by
Citing papers per year: 2025: 3; 2026: 3.
6 papers.
- 2026Self-Improvements in Modern Agentic Systems: A Surveycited by 17
- 2025Towards Reliable Code-as-Policies: A Neuro-Symbolic Framework for Embodied Task Planningcited by 10
- 2025A Systematic Literature Review on Detecting Software Vulnerabilities with Large Language Modelscited by 8
- 2025Assessing Code Understanding in LLMscited by 2
- 2026Call-Chain-Aware LLM-Based Test Generation for Java Projectscited by 0
- 2026When Passing Tests Hides Vulnerabilities: An Empirical Study of Silent Failures in Agentic Systemscited by 0
- 2026Self-Improvements in Modern Agentic Systems: A Survey14 Jul 2026
- 2026When Passing Tests Hides Vulnerabilities: An Empirical Study of Silent Failures in Agentic Systems25 Jun 2026
- 2026Call-Chain-Aware LLM-Based Test Generation for Java Projects23 Apr 2026
- 2025Towards Reliable Code-as-Policies: A Neuro-Symbolic Framework for Embodied Task Planning24 Oct 2025
- 2025A Systematic Literature Review on Detecting Software Vulnerabilities with Large Language Models30 Jul 2025
- 2025Assessing Code Understanding in LLMs31 Mar 2025