summaryrefslogtreecommitdiffstats
path: root/llvm/unittests
diff options
context:
space:
mode:
authorEhud Katz <ehudkatz@gmail.com>2020-01-09 09:42:32 +0200
committerEhud Katz <ehudkatz@gmail.com>2020-01-09 09:42:32 +0200
commit24b326cc610dfdccdd50bc78505ec228d96c8e7a (patch)
treec3ff8db5608329acfb536b64f40467440145bff0 /llvm/unittests
parent4ebb589629b0d3de0827cab179338836ebb3a8b6 (diff)
downloadbcm5719-llvm-24b326cc610dfdccdd50bc78505ec228d96c8e7a.tar.gz
bcm5719-llvm-24b326cc610dfdccdd50bc78505ec228d96c8e7a.zip
[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.
Diffstat (limited to 'llvm/unittests')
-rw-r--r--llvm/unittests/ADT/APFloatTest.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/unittests/ADT/APFloatTest.cpp b/llvm/unittests/ADT/APFloatTest.cpp
index adbf1b3b8c6..65b831c96e8 100644
--- a/llvm/unittests/ADT/APFloatTest.cpp
+++ b/llvm/unittests/ADT/APFloatTest.cpp
@@ -22,15 +22,18 @@ using namespace llvm;
static std::string convertToErrorFromString(StringRef Str) {
llvm::APFloat F(0.0);
- auto ErrOrStatus =
+ auto StatusOrErr =
F.convertFromString(Str, llvm::APFloat::rmNearestTiesToEven);
- EXPECT_TRUE(!ErrOrStatus);
- return toString(ErrOrStatus.takeError());
+ EXPECT_TRUE(!StatusOrErr);
+ return toString(StatusOrErr.takeError());
}
static double convertToDoubleFromString(StringRef Str) {
llvm::APFloat F(0.0);
- EXPECT_FALSE(!F.convertFromString(Str, llvm::APFloat::rmNearestTiesToEven));
+ auto StatusOrErr =
+ F.convertFromString(Str, llvm::APFloat::rmNearestTiesToEven);
+ EXPECT_FALSE(!StatusOrErr);
+ consumeError(StatusOrErr.takeError());
return F.convertToDouble();
}
OpenPOWER on IntegriCloud