开发者

Should I be aiming for no analyzer results when I run Build and Analyze

I have read numerous times that Build and Analyze is not perfect. When I run it, it does turn out some useful information and has definitely improved my code, but it also gives results that are not necessary problems. At the minute I'm changing my code to try and get rid of all the Analyzer results, whether they are a problem or not. Is this best practise, because like warnings it is then easy to check that you have a problem, or should I recognise that the analyzer is not perfec开发者_运维问答t and not change the code unless it has found an genuine problem?


First of all, all compiler warnings are just errors that will only show up in the runtime. They don't prevent compilation but they will eventually cause a serious problem somewhere down the road. You should go into the build settings and check "Treat Warnings as Errors" and fix the resulting errors as you go. Otherwise, you will eventually hit hard to debug problems way down the road.

The analyzer is not perfect but you should closely inspect any problems it finds. Any problems it finds with your code should be fixed. Sometimes it reports errors from the API and there may not be anything to be done about those.

In most cases, ignoring errors from any compiler stage is a "penny wise, pound foolish" time savings. Any time you save upfront will be lost debugging later.


Yes - ideally you want to fix all the issues raised from the Analyse process.

However, while clang is great, it is not perfect. Sometimes it may raise a false positive. If you are certain this is the case, and the diagnostic is in error, then you should try to recreate the smallest possible test case that exhibits the error, and submit it to http://clang-analyzer.llvm.org/filing_bugs.html so they can improve the analysis engine.


An exception to the above answers, I assume, is when you are using Garbage Collection. In this case, the Analyzer, alas, still shows you potential leaks, but naturally they are not applicable when using Garbage Collection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜