[PSDK/DDK/XDK]

- Make NT_ASSERT() give the MSVC static analyzer a hint that the condition can now be excpected to be true. This adds __analysis_unreachable(), which uses __assume(0) on _PREFAST_ builds. This is neccessary, since it seems impossible to make MSVC respect __analysis_noreturn / __declspec(noreturn) on an intrinsic prototype like __int2c().

svn path=/trunk/; revision=66642
This commit is contained in:
Timo Kreuzer 2015-03-10 00:10:46 +00:00
parent a3df492617
commit 83779b37e6
2 changed files with 18 additions and 6 deletions

View file

@ -11189,6 +11189,12 @@ RtlCheckBit(
DbgPrint("Assertion failed at %s(%d): %S\n", __FILE__, __LINE__, msg)
#endif
#ifdef _PREFAST_
#define __analysis_unreachable() __assume(0)
#else
#define __analysis_unreachable() ((void)0)
#endif
#define NT_VERIFY(exp) \
((!(exp)) ? \
(__assert_annotationA(#exp), \
@ -11208,17 +11214,17 @@ RtlCheckBit(
#define NT_ASSERT(exp) \
((VOID)((!(exp)) ? \
(__assert_annotationA(#exp), \
DbgRaiseAssertionFailure(), FALSE) : TRUE))
DbgRaiseAssertionFailure(), __analysis_unreachable(), FALSE) : TRUE))
#define NT_ASSERTMSG(msg, exp) \
((VOID)((!(exp)) ? \
(__assert_annotationA(msg), \
DbgRaiseAssertionFailure(), FALSE) : TRUE))
DbgRaiseAssertionFailure(), __analysis_unreachable(), FALSE) : TRUE))
#define NT_ASSERTMSGW(msg, exp) \
((VOID)((!(exp)) ? \
(__assert_annotationW(msg), \
DbgRaiseAssertionFailure(), FALSE) : TRUE))
DbgRaiseAssertionFailure(), __analysis_unreachable(), FALSE) : TRUE))
#else /* !DBG */

View file

@ -3241,6 +3241,12 @@ RtlCheckBit(
DbgPrint("Assertion failed at %s(%d): %S\n", __FILE__, __LINE__, msg)
#endif
#ifdef _PREFAST_
#define __analysis_unreachable() __assume(0)
#else
#define __analysis_unreachable() ((void)0)
#endif
#define NT_VERIFY(exp) \
((!(exp)) ? \
(__assert_annotationA(#exp), \
@ -3260,17 +3266,17 @@ RtlCheckBit(
#define NT_ASSERT(exp) \
((VOID)((!(exp)) ? \
(__assert_annotationA(#exp), \
DbgRaiseAssertionFailure(), FALSE) : TRUE))
DbgRaiseAssertionFailure(), __analysis_unreachable(), FALSE) : TRUE))
#define NT_ASSERTMSG(msg, exp) \
((VOID)((!(exp)) ? \
(__assert_annotationA(msg), \
DbgRaiseAssertionFailure(), FALSE) : TRUE))
DbgRaiseAssertionFailure(), __analysis_unreachable(), FALSE) : TRUE))
#define NT_ASSERTMSGW(msg, exp) \
((VOID)((!(exp)) ? \
(__assert_annotationW(msg), \
DbgRaiseAssertionFailure(), FALSE) : TRUE))
DbgRaiseAssertionFailure(), __analysis_unreachable(), FALSE) : TRUE))
#else /* !DBG */