OSDN Git Service

[ASMParser] Parse FP constants in non-C locales
authorMeador Inge <meadori@codesourcery.com>
Thu, 2 Jun 2016 20:04:44 +0000 (20:04 +0000)
committerMeador Inge <meadori@codesourcery.com>
Thu, 2 Jun 2016 20:04:44 +0000 (20:04 +0000)
This patch fixes PR25788, which allows for the parsing of
floating-point constants in non-C locales.

Patch by Antoine Pitrou!

Differential Revision: http://reviews.llvm.org/D15375

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271574 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/LLLexer.cpp

index fd0081f..bf457a9 100644 (file)
@@ -958,7 +958,8 @@ lltok::Kind LLLexer::LexDigitOrNegative() {
     }
   }
 
-  APFloatVal = APFloat(std::atof(TokStart));
+  APFloatVal = APFloat(APFloat::IEEEdouble,
+                       StringRef(TokStart, CurPtr - TokStart));
   return lltok::APFloat;
 }
 
@@ -994,6 +995,7 @@ lltok::Kind LLLexer::LexPositive() {
     }
   }
 
-  APFloatVal = APFloat(std::atof(TokStart));
+  APFloatVal = APFloat(APFloat::IEEEdouble,
+                       StringRef(TokStart, CurPtr - TokStart));
   return lltok::APFloat;
 }