
Instead of taking a fixed set of arguments, use variadics so that we can pass arbitrary arguments to the handler. This is the first step towards using the handler to handle other non-assertion-related failures, like std::unreachable and an exception being thrown in -fno-exceptions mode, which would improve user experience by including additional information in crashes (right now, we call abort() without additional information). Differential Revision: https://reviews.llvm.org/D130507
31 lines
1.1 KiB
C++
31 lines
1.1 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// This test ensures that assertions are still enabled when _LIBCPP_DEBUG=0 is
|
|
// defined, for backwards compatibility with code that might have been using
|
|
// it to enable assertions previously.
|
|
|
|
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
|
|
|
|
// We flag uses of the assertion handler in older dylibs at compile-time to avoid runtime
|
|
// failures when back-deploying.
|
|
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}}
|
|
|
|
#include <cassert>
|
|
|
|
bool handler_called = false;
|
|
void std::__libcpp_assertion_handler(char const*, ...) {
|
|
handler_called = true;
|
|
}
|
|
|
|
int main(int, char**) {
|
|
_LIBCPP_ASSERT(false, "message");
|
|
assert(handler_called);
|
|
return 0;
|
|
}
|