本文主要是介绍C++ 代码检查工具,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Cppcheck :
http://cppcheck.sourceforge.net/
Clang Static Analyzer
https://clang-analyzer.llvm.org / sudo apt install clang
cppcheck main.c
输出:
Checking main.c...
[main.c:15]: (error) Common realloc mistake: 'buf' nulled but not freed upon failure
clang static analyzer
clang --analyze main.c
输出:
main.c:17:13: warning: Potential leak of memory pointed to by 'buf'
printf("no memory!\n");
^~~~~~
1 warning generated.
scan-build gcc main.c (模拟编译 )
scan-build: Using '/usr/lib/llvm-3.8/bin/clang' for static analysis
main.c:17:13: warning: Potential leak of memory pointed to by 'buf'
printf("no memory!\n");
这篇关于C++ 代码检查工具的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!