From 90eda6fc279744c3ab200c149e4b75ed0c5dabf0 Mon Sep 17 00:00:00 2001 From: Marvin H?user Date: Sun, 19 Jun 2016 09:29:39 +0800 Subject: [PATCH] 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 Reviewed-by: Michael Kinney Reviewed-by: Liming Gao --- MdePkg/Include/Library/DebugLib.h | 1 + 1 file changed, 1 insertion(+) diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h index 93b6f8df34..803872cf3b 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -291,6 +291,7 @@ DebugPrintLevelEnabled ( if (DebugAssertEnabled ()) { \ if (!(Expression)) { \ _ASSERT (Expression); \ + ANALYZER_UNREACHABLE (); \ } \ } \ } while (FALSE)