summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/StringRef.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/StringRef.cpp')
-rw-r--r--llvm/lib/Support/StringRef.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index 393504cf01b..4142d130d51 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -12,6 +12,7 @@
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/edit_distance.h"
+#include "llvm/Support/Error.h"
#include <bitset>
using namespace llvm;
@@ -587,8 +588,13 @@ bool StringRef::getAsInteger(unsigned Radix, APInt &Result) const {
bool StringRef::getAsDouble(double &Result, bool AllowInexact) const {
APFloat F(0.0);
- APFloat::opStatus Status =
- F.convertFromString(*this, APFloat::rmNearestTiesToEven);
+ auto ErrOrStatus = F.convertFromString(*this, APFloat::rmNearestTiesToEven);
+ if (!ErrOrStatus) {
+ assert("Invalid floating point representation");
+ return true;
+ }
+
+ APFloat::opStatus Status = *ErrOrStatus;
if (Status != APFloat::opOK) {
if (!AllowInexact || !(Status & APFloat::opInexact))
return true;
OpenPOWER on IntegriCloud