[PATCH] D69770: [APFloat] Add recoverable string parsing errors to APFloat

Shoaib Meenai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 8 14:42:04 PST 2020


smeenai added inline comments.
Herald added a subscriber: herhut.


================
Comment at: llvm/lib/MC/MCParser/AsmParser.cpp:3133
       return TokError("invalid floating point literal");
-  } else if (Value.convertFromString(IDVal, APFloat::rmNearestTiesToEven) ==
-             APFloat::opInvalidOp)
+  } else if (!Value.convertFromString(IDVal, APFloat::rmNearestTiesToEven))
     return TokError("invalid floating point literal");
----------------
I'm pretty certain this won't do what you want in an asserts build (technically a build with `LLVM_ENABLE_ABI_BREAKING_CHECKS`). The destructor of an `llvm::Expected` asserts that the Expected was checked, and evaluating an Expected as a boolean only counts as checking it if there wasn't an error, in the error case, you'll hit an assert failure instead of doing the return. You'll need to capture the Expected and then do something like `consumeError(expected.takeError())` to discard the error and avoid the assertion.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69770/new/

https://reviews.llvm.org/D69770





More information about the cfe-commits mailing list