summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-04-07 08:42:53 +0000
committerChris Lattner <sabre@nondot.org>2002-04-07 08:42:53 +0000
commit34208394d0f803ecc896de7e9ab54774068e172e (patch)
tree1da2a85f63b16212bcbb11f3cb157cc8808e9ded /llvm/lib
parent9a11be849102e3a106cc9a3b4eed41b45efbc9cb (diff)
downloadbcm5719-llvm-34208394d0f803ecc896de7e9ab54774068e172e.tar.gz
bcm5719-llvm-34208394d0f803ecc896de7e9ab54774068e172e.zip
Fix Bug: test/Regression/Other/2002-04-07-InfConstant.ll
llvm-svn: 2142
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Constants.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index 410276683d1..acec62b4f1a 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/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!
OpenPOWER on IntegriCloud