[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

Reid Spencer reid at x10sys.com
Thu Dec 22 13:07:41 PST 2005



Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.139 -> 1.140
---
Log message:

Fix PR409: http://llvm.cs.uiuc.edu/PR409 :
Implement the suggested check to ensure that out-of-range float constants
don't get accepted by LLVM accidentally. Adjust the supporting test cases
as well.


---
Diffs of the changes:  (+3 -0)

 Constants.cpp |    3 +++
 1 files changed, 3 insertions(+)


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.139 llvm/lib/VMCore/Constants.cpp:1.140
--- llvm/lib/VMCore/Constants.cpp:1.139	Fri Oct  7 00:23:36 2005
+++ llvm/lib/VMCore/Constants.cpp	Thu Dec 22 15:07:29 2005
@@ -482,6 +482,9 @@
 
     // TODO: Figure out how to test if a double can be cast to a float!
   case Type::FloatTyID:
+    float FV = float(Val);
+    double DV = double(FV);
+    return  IsNAN(Val) || Val == DV;
   case Type::DoubleTyID:
     return true;          // This is the largest type...
   }






More information about the llvm-commits mailing list