Clang Static Analyzer找不到最基本的问题 [英] Clang Static Analyzer doesn't find the most basic problems

查看:227
本文介绍了Clang Static Analyzer找不到最基本的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试一下clang静态分析器.我在Windows上,并使用Visual Studio构建了clang.它似乎可行,但同时似乎也毫无用处.

I wanted to try out the clang static analyzer. I'm on Windows and built clang with Visual Studio. It seems to work, but at the same time it seems to be extremely useless.

我制作了一个示例文件

示例.c

int main(void) 
{
    int h = 0;
    return 1/h;
}

呼叫scan-build gcc -c example.c没有发现错误.

示例.c

int main(void) 
{
    int h;
    return 1/h;
}

呼叫scan-build gcc -c example.c没有发现错误.

示例.c

int main(void) 
{
    return 1/0;
}

呼叫scan-build gcc -c example.c没有发现错误.

如果找不到这些最基本的错误(并且可以通过clang本身找到),那么静态分析器有什么用?

If these most basic errors can't be found (and they can be found by clang itself), how can the static analyzer be of any use?

如果重要的话,我的gcc是MinGW.我也尝试替换clang,但是什么也没发生.

My gcc is MinGW if that matters. I also tried substituting clang but there's just nothing happening.

我在这里做错什么了吗?

Am I doing something wrong here?

推荐答案

请确保使用build-scan -v(详细)来查看是否实际运行了clang检查器. 我遵循了本教程 http://web.cs.ucla.edu/~tianyi.zhang/tutorial.html 当我尝试C ++示例时,它没有在错误代码中显示任何错误. -v向我显示提供的Makefile已损坏-在我修复了clang仍未检测到bug的问题之后,但g ++显示了该bug.

be sure to use build-scan -v (verbose) to see if actually running clang checker. I followed this tutorial http://web.cs.ucla.edu/~tianyi.zhang/tutorial.html When I tried the C++ example it did not show any errors in the buggy code. The -v showed me that the provided Makefile was broken - after I fixed that clang still did not detect the bugs but g++ shows the bug.

也许他们关闭了该特定的检查. Clang静态分析器3.8版 本教程使用版本3.2

Maybe they turned that particular check off. Clang Static Analyzer version 3.8 The tutorial uses version 3.2

这篇关于Clang Static Analyzer找不到最基本的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆