[cfe-users] Making analyzer understand VC assert

Anders Montonen Anders.Montonen at iki.fi
Mon Nov 11 03:01:52 PST 2013


I'm trying to use Clang's static analyzer with a Visual Studio project, 
but I'm running into the problem that in Microsoft's headers the _wassert 
function is not declared as noreturn, which leads to lots of false 
positives. The assert declaration looks like so:

#undef  assert

#define assert(_Expression) (void)( (!!(_Expression)) || 
(_wassert(_CRT_WIDE(#_Expression), _CRT_WIDE(__FILE__), __LINE__), 0) )

_CRTIMP void __cdecl _wassert(_In_z_ const wchar_t * _Message, _In_z_ 
const wchar_t *_File, _In_ unsigned _Line);

Looking through the source code there seems to be an "--assert=" flag, but 
it also seems not to be used.

Any advice how to handle this? Since the mingw headers (where the function 
is properly annotated) differ enough from Microsoft's that it would 
require modifications in the source code, I would prefer to not have to 
include them in the mix.

I noticed that there's a number of hardcoded function names in the static 
analyzer's NoReturnFunctionChecker, should _wassert be added to this list?


More information about the cfe-users mailing list