Added optional pass-by-reference argument "isExact" to
NumericLiteralParser::GetFloatValue(). Upon method return, this flag has the value
true if the returned APFloat can exactly represent the number in the parsed text,
and false otherwise.

Modified the implementation of GetFloatValue() to parse literals using APFloat's
convertFromString method (which allows us to set the value of isExact).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44339 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Lex/LiteralSupport.cpp b/Lex/LiteralSupport.cpp
index 21ead21..ebc6627 100644
--- a/Lex/LiteralSupport.cpp
+++ b/Lex/LiteralSupport.cpp
@@ -410,17 +410,27 @@
 }
 
 llvm::APFloat NumericLiteralParser::
-GetFloatValue(const llvm::fltSemantics &Format) {
+GetFloatValue(const llvm::fltSemantics &Format, bool* isExact) {
+  using llvm::APFloat;
+  
   char floatChars[256];
   strncpy(floatChars, ThisTokBegin, ThisTokEnd-ThisTokBegin);
   floatChars[ThisTokEnd-ThisTokBegin] = '\0';
-#if 0
-  // This doesn't work yet.
-  return llvm::APFloat(Format, floatChars);
+
+#if 1
+  APFloat V (Format, APFloat::fcZero, false);
+
+  APFloat::opStatus status;
+  status = V.convertFromString(floatChars,APFloat::rmTowardZero);
+  
+  if (isExact)
+    *isExact = status == APFloat::opOK;
+  
+  return V;
 #else
   // FIXME: this is horrible!
-  llvm::APFloat V(strtod(floatChars, 0));
-  V.convert(Format, llvm::APFloat::rmTowardZero);
+  APFloat V(strtod(floatChars, 0));
+  V.convert(Format, APFloat::rmTowardZero);
   return V;
 #endif
 }