Skip to content

Commit b495b17

Browse files
author
git apple-llvm automerger
committed
Merge commit '2ca279eb4652' from swift/release/5.9 into stable/20221013
2 parents 2d63ce4 + 2ca279e commit b495b17

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

lldb/docs/resources/contributing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ rules of thumb:
6666

6767
* Soft assertions. LLDB provides ``lldb_assert()`` as a soft
6868
alternative to cover the middle ground of situations that indicate a
69-
recoverable bug in LLDB. In a Debug configuration ``lldb_assert()``
70-
behaves like ``assert()``. In a Release configuration it will print a
69+
recoverable bug in LLDB. When asserts are enabled ``lldbassert()``
70+
behaves like ``assert()``. When asserts are disabled, it will print a
7171
warning and encourage the user to file a bug report, similar to
7272
LLVM's crash handler, and then return execution. Use these sparingly
7373
and only if error handling is not otherwise feasible. Specifically,

lldb/include/lldb/Utility/LLDBAssert.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@
99
#ifndef LLDB_UTILITY_LLDBASSERT_H
1010
#define LLDB_UTILITY_LLDBASSERT_H
1111

12-
#ifdef LLDB_CONFIGURATION_DEBUG
12+
#ifndef NDEBUG
1313
#define lldbassert(x) assert(x)
1414
#else
15+
#if defined(__clang__)
16+
// __FILE_NAME__ is a Clang-specific extension that functions similar to
17+
// __FILE__ but only renders the last path component (the filename) instead of
18+
// an invocation dependent full path to that file.
19+
#define lldbassert(x) \
20+
lldb_private::lldb_assert(static_cast<bool>(x), #x, __FUNCTION__, \
21+
__FILE_NAME__, __LINE__)
22+
#else
1523
#define lldbassert(x) \
1624
lldb_private::lldb_assert(static_cast<bool>(x), #x, __FUNCTION__, __FILE__, \
1725
__LINE__)
1826
#endif
27+
#endif
1928

2029
namespace lldb_private {
2130
void lldb_assert(bool expression, const char *expr_text, const char *func,

lldb/source/Utility/LLDBAssert.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ void lldb_private::lldb_assert(bool expression, const char *expr_text,
2525
if (LLVM_LIKELY(expression))
2626
return;
2727

28-
// If asserts are enabled abort here.
29-
assert(false && "lldb_assert failed");
30-
3128
#if LLVM_SUPPORT_XCODE_SIGNPOSTS
3229
if (__builtin_available(macos 10.12, iOS 10, tvOS 10, watchOS 3, *)) {
3330
os_log_fault(OS_LOG_DEFAULT,
@@ -36,9 +33,8 @@ void lldb_private::lldb_assert(bool expression, const char *expr_text,
3633
}
3734
#endif
3835

39-
// In a release configuration it will print a warning and encourage the user
40-
// to file a bug report, similar to LLVM’s crash handler, and then return
41-
// execution.
36+
// Print a warning and encourage the user to file a bug report, similar to
37+
// LLVM’s crash handler, and then return execution.
4238
errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
4339
expr_text, func, file, line);
4440
errs() << "backtrace leading to the failure:\n";

0 commit comments

Comments
 (0)