[cfe-dev] Clang Analysis of several open source projects.
Ted Kremenek
kremenek at apple.com
Fri May 13 12:26:52 PDT 2011
On May 13, 2011, at 10:33 AM, Kaelyn Uhrain wrote:
> Once I added the declaration "void fatal() __attribute__ ((noreturn));", clang's static analyzer no longer complained that x might be uninitialized. I haven't looked into the code, but I suspect that either the analyzer isn't propagating the noreturn function attribute properly (in cases where the only return path in a function hits a call to another function marked as noreturn) or possibly that the attribute is missing in a key spot within a header.
Right now there is no propagation of the noreturn attribute because the analyzer isn't doing any inter-procedural analysis.
I have two thoughts on this:
1) Eventually do this propagation automatically. This will not always be correct, however, because we can only infer this when the implementation of the function is available.
2) Warn when a function that never returns does not have the noreturn attribute. I believe the compiler may already do this.
The benefit of (2) is that it also teaches the compiler that a function doesn't return when called. This allows it to do a variety of optimizations in the caller. Beyond whatever it gets from inlining, the compiler will never do full auto-propagation of the noreturn attribute.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110513/59ff163f/attachment.html>
More information about the cfe-dev
mailing list