RUS  ENG
Full version
JOURNALS // Zapiski Nauchnykh Seminarov POMI // Archive

Zap. Nauchn. Sem. POMI, 2024 Volume 540, Pages 233–251 (Mi znsl7553)

Ensuring trustworthy code: leveraging a static analyzer to identify and mitigate defects in generated code

D. Shaikhelislamovabc, M. Drobyshevskiydbc, A. Belevanceveb

a HSE University, Moscow, Russia
b Ivannikov Institute for System Programming of the Russian Academy of Sciences, Moscow, Russia
c Moscow Institute of Physics and Technology (National Research University), Moscow, Russia
d ISP RAS Research Center for Trusted Artificial Intelligence, Moscow, Russia
e Moscow State University, Moscow, Russia

Abstract: The rise of large language models (LLMs) has greatly advanced code generation capabilities. A recent StackOverflow survey found that 70% of developers are using or planning to use AI coding tools this year. However, most current methods focus on supervised fine-tuning objectives derived from text generation, often overlooking the distinct sequence-level properties of code, such as compilability, and syntactic and functional correctness. To address this gap, we introduce a novel approach that combines pre-trained LLMs with software analysis tools commonly used to detect vulnerabilities and validate code. Our method leverages detailed feedback from code compilation and analysis, incorporating this specialized knowledge into the prompt chaining process. We present CodePatchLLM, an extension of LLMs that uses Svace feedback for improved code generation. CodePatchLLM is a model-agnostic framework that supports multiple programming languages. Extensive experiments on the LeetCode dataset show that our approach outperforms the baseline CodeLlama model, achieving significant improvements in compilation success rates and functional correctness across Java, Python, and Kotlin. The CodePatchLLM framework is available at https://github.com/dsshay/CodePatchLLM.

Key words and phrases: large language models, static analyzer, code quality.

Received: 15.11.2024

Language: English



© Steklov Math. Inst. of RAS, 2025