}
// Test that unchecked succes values cause an abort.
-#ifndef NDEBUG
+#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
TEST(Error, UncheckedSuccess) {
EXPECT_DEATH({ Error E = Error::success(); },
"Program aborted due to an unhandled Error:")
}
// Test that ErrorAsOutParameter clears the checked flag on destruction.
-#ifndef NDEBUG
+#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
TEST(Error, ErrorAsOutParameterUnchecked) {
EXPECT_DEATH({ Error E = Error::success(); errAsOutParamHelper(E); },
"Program aborted due to an unhandled Error:")
// Check that we abort on unhandled failure cases. (Force conversion to bool
// to make sure that we don't accidentally treat checked errors as handled).
// Test runs in debug mode only.
-#ifndef NDEBUG
+#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
TEST(Error, UncheckedError) {
auto DropUnhandledError = []() {
Error E = make_error<CustomError>(42);
// Test that handleAllUnhandledErrors crashes if an error is not caught.
// Test runs in debug mode only.
-#ifndef NDEBUG
+#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
TEST(Error, FailureToHandle) {
auto FailToHandle = []() {
handleAllErrors(make_error<CustomError>(7), [&](const CustomSubError &SE) {
// Test that handleAllUnhandledErrors crashes if an error is returned from a
// handler.
// Test runs in debug mode only.
-#ifndef NDEBUG
+#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
TEST(Error, FailureFromHandler) {
auto ReturnErrorFromHandler = []() {
handleAllErrors(make_error<CustomError>(7),
// Test Unchecked Expected<T> in success mode.
// We expect this to blow up the same way Error would.
// Test runs in debug mode only.
-#ifndef NDEBUG
+#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
TEST(Error, UncheckedExpectedInSuccessModeDestruction) {
EXPECT_DEATH({ Expected<int> A = 7; },
"Expected<T> must be checked before access or destruction.")
// Test Unchecked Expected<T> in success mode.
// We expect this to blow up the same way Error would.
// Test runs in debug mode only.
-#ifndef NDEBUG
+#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
TEST(Error, UncheckedExpectedInSuccessModeAccess) {
EXPECT_DEATH({ Expected<int> A = 7; *A; },
"Expected<T> must be checked before access or destruction.")
// Test Unchecked Expected<T> in success mode.
// We expect this to blow up the same way Error would.
// Test runs in debug mode only.
-#ifndef NDEBUG
+#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
TEST(Error, UncheckedExpectedInSuccessModeAssignment) {
EXPECT_DEATH({ Expected<int> A = 7; A = 7; },
"Expected<T> must be checked before access or destruction.")
// Check that an Expected instance with an error value doesn't allow access to
// operator*.
// Test runs in debug mode only.
-#ifndef NDEBUG
+#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
TEST(Error, AccessExpectedInFailureMode) {
Expected<int> A = make_error<CustomError>(42);
EXPECT_DEATH(*A, "Expected<T> must be checked before access or destruction.")
// Check that an Expected instance with an error triggers an abort if
// unhandled.
// Test runs in debug mode only.
-#ifndef NDEBUG
+#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
TEST(Error, UnhandledExpectedInFailureMode) {
EXPECT_DEATH({ Expected<int> A = make_error<CustomError>(42); },
"Expected<T> must be checked before access or destruction.")