MdePkg/DebugLib: Flag post-_ASSERT() as unreachable for analyzers.

When a variable is compared to NULL as part of an ASSERT() call, the
code implies that the variable may be NULL. Certain Static Analyzers,
such as the Clang Static Analyzer, then issue false warnings for any
untested access of that pointer, even though that defeats the
intention behind ASSERT(). This patch flags the position after
_ASSERT() as unreachable for Static Analyzers to indicate that if the
variable is NULL, execution cannot pass.
As the ANALYZER-prefixed version is used, the executables will not
have any code stripped during compilation.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Marvin H?user 2016-06-19 09:29:39 +08:00 committed by Liming Gao
parent 001f28caef
commit 90eda6fc27
1 changed files with 1 additions and 0 deletions

View File

@ -291,6 +291,7 @@ DebugPrintLevelEnabled (
if (DebugAssertEnabled ()) { \
if (!(Expression)) { \
_ASSERT (Expression); \
ANALYZER_UNREACHABLE (); \
} \
} \
} while (FALSE)