]> granicus.if.org Git - clang/commitdiff
Fix for failing test from sanitizer-x86_64-linux-fast where there was a
authorLeonard Chan <leonardchan@google.com>
Mon, 6 Aug 2018 17:55:38 +0000 (17:55 +0000)
committerLeonard Chan <leonardchan@google.com>
Mon, 6 Aug 2018 17:55:38 +0000 (17:55 +0000)
left shift on a negative value.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339037 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/Basic/FixedPointTest.cpp

index 6d608f1faff28155c7a43f58dc2d5aa6a75a79ae..74b676bb21ff5363276ddf564ec9191231ae7274 100644 (file)
@@ -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);