From ecb310b3a7cf60d2bc28aaf8caf8fd29b9f11ec9 Mon Sep 17 00:00:00 2001 From: Don Hinton Date: Thu, 17 Oct 2019 21:54:15 +0000 Subject: [Error] Make llvm::cantFail include the original error messages Summary: The current implementation eats the current errors and just outputs the message parameter passed to llvm::cantFail. This change appends the original error message(s), so the user can see exactly why cantFail failed. New logic is conditional on NDEBUG. Reviewed By: lhames Tags: #llvm Differential Revision: https://reviews.llvm.org/D69057 llvm-svn: 375176 --- llvm/unittests/Support/ErrorTest.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'llvm/unittests/Support/ErrorTest.cpp') diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp index c4a9f3e..2cac94d 100644 --- a/llvm/unittests/Support/ErrorTest.cpp +++ b/llvm/unittests/Support/ErrorTest.cpp @@ -390,7 +390,8 @@ TEST(Error, FailureToHandle) { }; EXPECT_DEATH(FailToHandle(), - "Failure value returned from cantFail wrapped call") + "Failure value returned from cantFail wrapped call\n" + "CustomError \\{7\\}") << "Unhandled Error in handleAllErrors call did not cause an " "abort()"; } @@ -409,7 +410,8 @@ TEST(Error, FailureFromHandler) { }; EXPECT_DEATH(ReturnErrorFromHandler(), - "Failure value returned from cantFail wrapped call") + "Failure value returned from cantFail wrapped call\n" + "CustomError \\{7\\}") << " Error returned from handler in handleAllErrors call did not " "cause abort()"; } @@ -510,11 +512,12 @@ TEST(Error, CantFailSuccess) { // Test that cantFail results in a crash if you pass it a failure value. #if LLVM_ENABLE_ABI_BREAKING_CHECKS && !defined(NDEBUG) TEST(Error, CantFailDeath) { - EXPECT_DEATH( - cantFail(make_error("foo", inconvertibleErrorCode()), - "Cantfail call failed"), - "Cantfail call failed") - << "cantFail(Error) did not cause an abort for failure value"; + EXPECT_DEATH(cantFail(make_error("Original error message", + inconvertibleErrorCode()), + "Cantfail call failed"), + "Cantfail call failed\n" + "Original error message") + << "cantFail(Error) did not cause an abort for failure value"; EXPECT_DEATH( { -- cgit v1.1