使用LLVM和CodeChecker实现与执行静态分析
Implementing and Executing Static Analysis Using LLVM and CodeChecker
AI总结:
本教程通过LLVM和CodeChecker,以C++中冗余指针消除和std::string悬空指针检测两个问题为例,逐步讲解基于抽象语法树和符号执行的静态分析检查器实现方法。
摘要:
静态分析是一种在不执行源代码的情况下分析源代码的方法。它被广泛用于发现工业软件中的缺陷和代码异味。除其他方法外,最重要的技术是基于抽象语法树的技术和执行符号执行的技术。这两种方法在现代软件开发中都找到了自己的角色,因为它们具有不同的优势和局限性。在本教程中,我们提出C++编程语言中的两个问题:冗余指针的消除,以及因不正确使用std::string类而产生的悬空指针的报告。这两个问题具有不同的理论背景,发现它们需要不同的实现技术。我们将提供一个逐步指南来实现检查器(用于识别上述问题的软件)——一个基于抽象语法分析方法,另一个探索符号执行的可能性。这些方法将以非常详细的方式解释,并辅以代码示例。本教程的目标受众既包括静态分析工具的架构师,也包括希望理解不同方法的优势和约束的开发者。
英文摘要:
Static analysis is a method of analyzing source code without executing it. It is widely used to find bugs and code smells in industrial software. Besides other methods, the most important techniques are those based on the abstract syntax tree and those performing symbolic execution. Both of these methods found their role in modern software development as they have different advantages and limitations. In this tutorial, we present two problems from the C++ programming language: the elimination of redundant pointers, and the reporting of dangling pointers originating from incorrect use of the std::string class. These two issues have different theoretical backgrounds and finding them requires different implementation techniques. We will provide a step-by-step guide to implement the checkers (software to identify the aforementioned problems) - one based on the abstract syntax analysis method, the other exploring the possibilities of symbolic execution. The methods are explained in great detail and supported by code examples. The intended audience for this tutorial are both architects of static analysis tools and developers who want to understand the advantages and constraints of the different methods.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。