[cfe-dev] Clang Analysis of several open source projects.

Ted Kremenek kremenek at apple.com
Fri May 13 12:30:00 PDT 2011


Sorry, I didn't see David's response before writing my own.

David's right on.  "Hints" like these allow both the compiler and analyzer to scale better to analyzing your code.  It also documents your assumptions at the function interface level.  For example, marking "fatal" explicitly as noreturn has meaningful documentation value.

On May 13, 2011, at 11:03 AM, David Chisnall wrote:

> On 13 May 2011, at 18:33, 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.
> 
> The analyser won't propagate it (because it doesn't do [much] interprocedural analysis yet), but it would probably make a good candidate for a hint - if a function has no return paths, suggest marking it as not returning - this will help the optimiser.  Suggesting adding const, no-capture attributes, and so on to function arguments would also be a nice idea.
> 
> David
> 
> --
> This email complies with ISO 3103
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list