From 24b326cc610dfdccdd50bc78505ec228d96c8e7a Mon Sep 17 00:00:00 2001 From: Ehud Katz Date: Thu, 9 Jan 2020 09:42:32 +0200 Subject: [APFloat] Fix checked error assert failures `APFLoat::convertFromString` returns `Expected` result, which must be "checked" if the LLVM_ENABLE_ABI_BREAKING_CHECKS preprocessor flag is set. To mark an `Expected` result as "checked" we must consume the `Error` within. In many cases, we are only interested in knowing if an error occured, without the need to examine the error info. This is achieved, easily, with the `errorToBool()` API. --- llvm/lib/Support/APFloat.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Support/APFloat.cpp') diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index f8a217d3535..050c37baefb 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -4518,9 +4518,8 @@ hash_code hash_value(const APFloat &Arg) { APFloat::APFloat(const fltSemantics &Semantics, StringRef S) : APFloat(Semantics) { auto StatusOrErr = convertFromString(S, rmNearestTiesToEven); - if (!StatusOrErr) { - assert(false && "Invalid floating point representation"); - } + assert(StatusOrErr && "Invalid floating point representation"); + consumeError(StatusOrErr.takeError()); } APFloat::opStatus APFloat::convert(const fltSemantics &ToSemantics, -- cgit v1.2.3