A test-free semantic mistakes localization framework in Neural Code Translation

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Chen, Lei, Zhang, Sai, Xu, Fangzhou, Xing, Zhenchang, Wan, Liang, Zhang, Xiaowang, Feng, Zhiyong
Natura: Preprint
Pubblicazione: 2024
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866914997939994624
author Chen, Lei
Zhang, Sai
Xu, Fangzhou
Xing, Zhenchang
Wan, Liang
Zhang, Xiaowang
Feng, Zhiyong
author_facet Chen, Lei
Zhang, Sai
Xu, Fangzhou
Xing, Zhenchang
Wan, Liang
Zhang, Xiaowang
Feng, Zhiyong
contents In the task of code translation, neural network-based models have been shown to frequently produce semantically erroneous code that deviates from the original logic of the source code. This issue persists even with advanced large models. Although a recent approach proposed using test cases to identify these semantic errors, it relies heavily on the quality of the test cases and is not applicable to code snippets without test cases in real-world scenarios. Therefore, We present EISP, a static analysis framework based on the Large Language Model (LLM).First, the framework generates a semantic mapping between source code and translated code. Next, each sub-code fragment is identified by recursively traversing the abstract syntax tree of the source code, and its corresponding translated code fragment is found through the semantic mapping. Finally, EISP connects each pair of sub-code fragments with fine-grained knowledge hints through an AI chain to assist LLMs in discovering semantic mistakes in the translated code. In our benchmark evaluation, the EISP framework, based on GPT-4o mini, achieved an accuracy of 82.3\%, representing a 20.3\% improvement over baseline methods using the same base model, and a 7.4\% improvement compared to dynamic analysis methods that require test cases and manual intervention. To our knowledge, EISP is the first tool to locate semantic errors in translated code without test cases or compilable code. This innovative tool provides the software engineering community with a new way to deal with code fragments without test cases.
format Preprint
id arxiv_https___arxiv_org_abs_2410_22818
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle A test-free semantic mistakes localization framework in Neural Code Translation
Chen, Lei
Zhang, Sai
Xu, Fangzhou
Xing, Zhenchang
Wan, Liang
Zhang, Xiaowang
Feng, Zhiyong
Software Engineering
In the task of code translation, neural network-based models have been shown to frequently produce semantically erroneous code that deviates from the original logic of the source code. This issue persists even with advanced large models. Although a recent approach proposed using test cases to identify these semantic errors, it relies heavily on the quality of the test cases and is not applicable to code snippets without test cases in real-world scenarios. Therefore, We present EISP, a static analysis framework based on the Large Language Model (LLM).First, the framework generates a semantic mapping between source code and translated code. Next, each sub-code fragment is identified by recursively traversing the abstract syntax tree of the source code, and its corresponding translated code fragment is found through the semantic mapping. Finally, EISP connects each pair of sub-code fragments with fine-grained knowledge hints through an AI chain to assist LLMs in discovering semantic mistakes in the translated code. In our benchmark evaluation, the EISP framework, based on GPT-4o mini, achieved an accuracy of 82.3\%, representing a 20.3\% improvement over baseline methods using the same base model, and a 7.4\% improvement compared to dynamic analysis methods that require test cases and manual intervention. To our knowledge, EISP is the first tool to locate semantic errors in translated code without test cases or compilable code. This innovative tool provides the software engineering community with a new way to deal with code fragments without test cases.
title A test-free semantic mistakes localization framework in Neural Code Translation
topic Software Engineering
url https://arxiv.org/abs/2410.22818