diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2023-05-15 22:47:12 -0700 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2023-05-16 09:27:09 -0700 |
commit | 10a50762caa6ac17dd063b28863a2ec60576c6f7 (patch) | |
tree | 83099cec25705788995dc9974fc8c2fcad22044e /lldb/include | |
parent | 9e37a7bd1f38fed4e00704d561b3897fe8915c4c (diff) | |
download | llvm-10a50762caa6ac17dd063b28863a2ec60576c6f7.tar.gz |
[lldb] Define lldbassert based on NDEBUG instead of LLDB_CONFIGURATION_DEBUG
Whether assertions are enabled or not is orthogonal to the build type
which could lead to surprising behavior for lldbassert. Previously, when
doing a debug build with assertions disabled, lldbassert would become a
NOOP, rather than printing an error like it does in a release build. By
definining lldbassert in terms of NDEBUG, it behaves like a regular
assert when assertions are enabled, and like a soft assert.
Differential revision: https://reviews.llvm.org/D150639
Diffstat (limited to 'lldb/include')
-rw-r--r-- | lldb/include/lldb/Utility/LLDBAssert.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lldb/include/lldb/Utility/LLDBAssert.h b/lldb/include/lldb/Utility/LLDBAssert.h index 471a2f7e824f..524f56fd77c8 100644 --- a/lldb/include/lldb/Utility/LLDBAssert.h +++ b/lldb/include/lldb/Utility/LLDBAssert.h @@ -9,13 +9,22 @@ #ifndef LLDB_UTILITY_LLDBASSERT_H #define LLDB_UTILITY_LLDBASSERT_H -#ifdef LLDB_CONFIGURATION_DEBUG +#ifndef NDEBUG #define lldbassert(x) assert(x) #else +#if defined(__clang__) +// __FILE_NAME__ is a Clang-specific extension that functions similar to +// __FILE__ but only renders the last path component (the filename) instead of +// an invocation dependent full path to that file. +#define lldbassert(x) \ + lldb_private::lldb_assert(static_cast<bool>(x), #x, __FUNCTION__, \ + __FILE_NAME__, __LINE__) +#else #define lldbassert(x) \ lldb_private::lldb_assert(static_cast<bool>(x), #x, __FUNCTION__, __FILE__, \ __LINE__) #endif +#endif namespace lldb_private { void lldb_assert(bool expression, const char *expr_text, const char *func, |