RFC: Macro for 'analyzer_noreturn' attribute

Jordan Rose jordan_rose at apple.com
Wed Mar 27 13:16:42 PDT 2013


Hi, all. As you might know, my primary project is the Clang static analyzer. Recent improvements to the analyzer's understanding of C++ have made it a much more useful tool for running over the LLVM codebase; however, the analyzer is not anywhere close to perfect and still needs a little help to understand some code. One such way is to use the 'analyzer_noreturn' attribute, which instructs the analyzer to stop analyzing after a call to the annotated function.

A large handful of false positives in LLVM are due to MCAsmParser's conventions of returning 'true' when an error occurs. The analyzer doesn't understand this, and so sometimes gets confused about whether or not a certain variable could be used uninitialized. I'd like to try to cut down on the noise by marking the MCAsmParser::Error and MCAsmParser::TokError methods as 'analyzer_noreturn'.

This, of course, suggests a new macro in Compiler.h: LLVM_ATTRIBUTE_ANALYZER_NORETURN. This will be guarded by the __clang_analyzer__ macro and expand to nothing when __clang_analyzer__ is not defined.

Any objections, or ideas for other APIs that could use this annotation?
Thanks,
Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130327/992885d8/attachment.html>


More information about the llvm-commits mailing list