diff options
author | Chris Lattner <sabre@nondot.org> | 2002-04-07 08:42:53 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-04-07 08:42:53 +0000 |
commit | f862b6d3745a342d4cc162645779817cae1c1be9 (patch) | |
tree | 4bdac338405d786c11211375b3e193d28844de6c | |
parent | ace9103ebefcece3e26c69735dd0087bb973579c (diff) |
Fix Bug: test/Regression/Other/2002-04-07-InfConstant.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2142 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Constants.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 410276683d..acec62b4f1 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -165,9 +165,18 @@ std::string ConstantUInt::getStrValue() const { // std::string ConstantFP::getStrValue() const { std::string StrVal = ftostr(Val); - double TestVal = atof(StrVal.c_str()); // Reparse stringized version! - if (TestVal == Val) - return StrVal; + + // Check to make sure that the stringized number is not some string like "Inf" + // or NaN, that atof will accept, but the lexer will not. Check that the + // string matches the "[-+]?[0-9]" regex. + // + if ((StrVal[0] >= '0' && StrVal[0] <= '9') || + ((StrVal[0] == '-' || StrVal[0] == '+') && + (StrVal[0] >= '0' && StrVal[0] <= '9'))) { + double TestVal = atof(StrVal.c_str()); // Reparse stringized version! + if (TestVal == Val) + return StrVal; + } // Otherwise we could not reparse it to exactly the same value, so we must // output the string in hexadecimal format! |