summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
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/lib/Target
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/lib/Target')
-rw-r--r--llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp4
-rw-r--r--llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp2
2 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index bd48e5d846a..70c9db13f13 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -1223,7 +1223,7 @@ public:
APFloat RealVal(APFloat::IEEEdouble());
auto StatusOrErr =
RealVal.convertFromString(Desc->Repr, APFloat::rmTowardZero);
- if (!StatusOrErr || *StatusOrErr != APFloat::opOK)
+ if (errorToBool(StatusOrErr.takeError()) || *StatusOrErr != APFloat::opOK)
llvm_unreachable("FP immediate is not exact");
if (getFPImm().bitwiseIsEqual(RealVal))
@@ -2580,7 +2580,7 @@ AArch64AsmParser::tryParseFPImm(OperandVector &Operands) {
APFloat RealVal(APFloat::IEEEdouble());
auto StatusOrErr =
RealVal.convertFromString(Tok.getString(), APFloat::rmTowardZero);
- if (!StatusOrErr) {
+ if (errorToBool(StatusOrErr.takeError())) {
TokError("invalid floating point representation");
return MatchOperand_ParseFail;
}
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 326df6bc8fb..d5834826fcd 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -2363,7 +2363,7 @@ AMDGPUAsmParser::parseImm(OperandVector &Operands, bool HasSP3AbsModifier) {
APFloat RealVal(APFloat::IEEEdouble());
auto roundMode = APFloat::rmNearestTiesToEven;
- if (!RealVal.convertFromString(Num, roundMode)) {
+ if (errorToBool(RealVal.convertFromString(Num, roundMode).takeError())) {
return MatchOperand_ParseFail;
}
if (Negate)
OpenPOWER on IntegriCloud