mlsanityData to 7 Oct 2026

Helping LLMs Improve Code Generation Using Feedback from Testing and Static Analysis

arXiv 2412.14841 ↗First posted 19 Dec 2024cs.SE cs.AIcited by 6

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

  1. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
  2. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  3. 2023Mistral 7Bcited by 3,065
  4. 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 1,906
  5. 2024Mixtral of Expertscited by 1,785
  6. 2022Large Language Models Are Human-Level Prompt Engineerscited by 1,020
  7. 2024Gemma: Open Models Based on Gemini Research and Technologycited by 889
  8. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
  9. 2022Grounded Copilot: How Programmers Interact with Code-Generating Modelscited by 216
  10. 2023Is Self-Repair a Silver Bullet for Code Generation?cited by 191
  11. 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
  12. 2023Purple Llama CyberSecEval: A Secure Coding Benchmark for Language Modelscited by 130
14 more
  1. 2023InferFix: End-to-End Program Repair with LLMscited by 113
  2. 2021Examining Zero-Shot Vulnerability Repair with Large Language Modelscited by 105
  3. 2024IRIS: LLM-Assisted Static Analysis for Detecting Security Vulnerabilitiescited by 100
  4. 2023LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarkscited by 94
  5. 2024Instruction Tuning for Secure Code Generationcited by 63
  6. 2023A New Era in Software Security: Towards Self-Healing Software via Large Language Models and Formal Verificationcited by 42
  7. 2023The FormAI Dataset: Generative AI in Software Security Through the Lens of Formal Verificationcited by 32
  8. 2024CRUXEval-X: A Benchmark for Multilingual Code Reasoning, Understanding and Executioncited by 31
  9. 2024How secure is AI-generated Code: A Large-Scale Comparison of Large Language Modelscited by 23
  10. 2024SCALE: Constructing Structured Natural Language Comment Trees for Software Vulnerability Detectioncited by 17
  11. 2024PromSec: Prompt Optimization for Secure Generation of Functional Source Code with Large Language Models (LLMs)cited by 17
  12. 2023Can ChatGPT support software verification?cited by 14
  13. 2023Practices and Challenges of Using GitHub Copilot: An Empirical Studycited by 13
  14. 2024Enhancing Source Code Security with LLMs: Demystifying The Challenges and Generating Reliable Repairscited by 4

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 3; 2026: 3.

6 papers.