Last active
February 16, 2019 20:39
-
-
Save Shauren/75eab0b609b26a11f21b1f826d168791 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/common/Debugging/Errors.h b/src/common/Debugging/Errors.h | |
index d263be3efe..f45c586c0c 100644 | |
--- a/src/common/Debugging/Errors.h | |
+++ b/src/common/Debugging/Errors.h | |
@@ -20,6 +20,8 @@ | |
#define TRINITYCORE_ERRORS_H | |
#include "Define.h" | |
+#include <boost/preprocessor/facilities/overload.hpp> | |
+#include <boost/preprocessor/facilities/empty.hpp> | |
#include <string> | |
namespace Trinity | |
@@ -70,13 +72,18 @@ TC_COMMON_API std::string GetDebugInfo(); | |
#define ABORT WPAbort | |
-template <typename T> | |
-inline T* ASSERT_NOTNULL_IMPL(T* pointer, char const* expr) | |
+template <typename T, typename DebugInfoSource> | |
+inline T* ASSERT_NOTNULL_IMPL(T* pointer, char const* expr, char const* file, int line, char const* function, DebugInfoSource&& debugInfoSource) | |
{ | |
- ASSERT(pointer, "%s", expr); | |
+ if (!pointer) | |
+ Trinity::Assert(file, line, function, debugInfoSource(), expr); | |
return pointer; | |
} | |
-#define ASSERT_NOTNULL(pointer) ASSERT_NOTNULL_IMPL(pointer, #pointer) | |
+#define ASSERT_NOTNULL_1(pointer) ASSERT_NOTNULL_IMPL(pointer, #pointer, __FILE__, __LINE__, __FUNCTION__, [&](){ return GetDebugInfo(); }) | |
+#define ASSERT_NOTNULL_2(pointer, context) ASSERT_NOTNULL_IMPL(pointer, #pointer, __FILE__, __LINE__, __FUNCTION__, [&](){ return context->GetDebugInfo(); }) | |
+ | |
+#define ASSERT_NOTNULL(...) BOOST_PP_CAT(BOOST_PP_OVERLOAD(ASSERT_NOTNULL_,__VA_ARGS__)(__VA_ARGS__), BOOST_PP_EMPTY()) | |
+#define ASSERT_NOTNULL_NODEBUGINFO(pointer) ASSERT_NOTNULL_IMPL(pointer, #pointer, __FILE__, __LINE__, __FUNCTION__, [&](){ return ::GetDebugInfo(); }) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment