r339037 - Fix for failing test from sanitizer-x86_64-linux-fast where there was a

Leonard Chan via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 6 10:55:38 PDT 2018


Author: leonardchan
Date: Mon Aug  6 10:55:38 2018
New Revision: 339037

URL: http://llvm.org/viewvc/llvm-project?rev=339037&view=rev
Log:
Fix for failing test from sanitizer-x86_64-linux-fast where there was a
left shift on a negative value.

Modified:
    cfe/trunk/unittests/Basic/FixedPointTest.cpp

Modified: cfe/trunk/unittests/Basic/FixedPointTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FixedPointTest.cpp?rev=339037&r1=339036&r2=339037&view=diff
==============================================================================
--- cfe/trunk/unittests/Basic/FixedPointTest.cpp (original)
+++ cfe/trunk/unittests/Basic/FixedPointTest.cpp Mon Aug  6 10:55:38 2018
@@ -364,12 +364,19 @@ TEST(FixedPoint, compare) {
 void CheckUnsaturatedConversion(FixedPointSemantics Src,
                                 FixedPointSemantics Dst, int64_t TestVal) {
   int64_t ScaledVal = TestVal;
+  bool IsNegative = ScaledVal < 0;
+  if (IsNegative)
+    ScaledVal = -ScaledVal;
+
   if (Dst.getScale() > Src.getScale()) {
     ScaledVal <<= (Dst.getScale() - Src.getScale());
   } else {
     ScaledVal >>= (Src.getScale() - Dst.getScale());
   }
 
+  if (IsNegative)
+    ScaledVal = -ScaledVal;
+
   APFixedPoint Fixed(TestVal, Src);
   APFixedPoint Expected(ScaledVal, Dst);
   ASSERT_EQ(Fixed.convert(Dst), Expected);




More information about the cfe-commits mailing list