[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Reid Spencer
reid at x10sys.com
Mon Dec 6 14:18:48 PST 2004
Changes in directory llvm/lib/VMCore:
Constants.cpp updated: 1.112 -> 1.113
---
Log message:
For PR409: http://llvm.cs.uiuc.edu/PR409 : \
Test the range of float constants to ensure we are not attempting to create a \
float constant using a double value that is out of range for a float
---
Diffs of the changes: (+11 -0)
Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.112 llvm/lib/VMCore/Constants.cpp:1.113
--- llvm/lib/VMCore/Constants.cpp:1.112 Fri Nov 19 10:39:44 2004
+++ llvm/lib/VMCore/Constants.cpp Mon Dec 6 16:18:37 2004
@@ -21,6 +21,7 @@
#include "llvm/ADT/StringExtras.h"
#include <algorithm>
#include <iostream>
+#include <limits>
using namespace llvm;
ConstantBool *ConstantBool::True = new ConstantBool(true);
@@ -442,6 +443,16 @@
// TODO: Figure out how to test if a double can be cast to a float!
case Type::FloatTyID:
+ return
+ (std::numeric_limits<double>::has_infinity &&
+ std::numeric_limits<float>::has_infinity &&
+ Val == std::numeric_limits<double>::infinity()) ||
+ (std::numeric_limits<double>::has_quiet_NaN &&
+ std::numeric_limits<float>::has_quiet_NaN &&
+ Val == std::numeric_limits<double>::quiet_NaN()) ||
+ (Val >= -std::numeric_limits<float>::max() &&
+ Val <= std::numeric_limits<float>::max());
+
case Type::DoubleTyID:
return true; // This is the largest type...
}
More information about the llvm-commits
mailing list