From 78e2cd1d934e7299f2025230d74a07b3619f7612 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Mon, 8 Oct 2018 23:57:44 +0200
Subject: [PATCH] Add __attribut__ to help scan-build static analyzer

---
 src/utils/PastisAssert.hpp | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/utils/PastisAssert.hpp b/src/utils/PastisAssert.hpp
index 9f5a171ac..d260ce25f 100644
--- a/src/utils/PastisAssert.hpp
+++ b/src/utils/PastisAssert.hpp
@@ -45,19 +45,29 @@ class AssertError
   ~AssertError() = default;
 };
 
+#pragma GCC diagnostic ignored "-Wattributes"
+inline bool
+__attribute__((analyzer_noreturn))
+_pastis_assert(const bool& assert)
+{
+  return assert;
+}
+#pragma GCC diagnostic pop
+
 #ifdef NDEBUG
 
 // Useless test is there to check syntax even in optimized mode. Costs nothing.
-#define Assert(assertion) if (not (assertion)) {}
+#define Assert(assertion)                       \
+  if (not _pastis_assert(assertion)) {}
 
 #else // NDEBUG
 
-#define Assert(assertion)                                               \
-  if (not (assertion)) {                                                \
-    throw AssertError(__FILE__,                                         \
-                      __LINE__,                                         \
-                      __PRETTY_FUNCTION__,                              \
-                      (#assertion));                                    \
+#define Assert(assertion)                       \
+  if (not _pastis_assert(assertion)) {          \
+    throw AssertError(__FILE__,                 \
+                      __LINE__,                 \
+                      __PRETTY_FUNCTION__,      \
+                      (#assertion));            \
   }
 
 #endif // NDEBUG
-- 
GitLab