]> granicus.if.org Git - clang/commitdiff
[Sema] Use CK_NoOp instead CK_Invalid in tryGCCVectorConvertAndSplat
authorVitaly Buka <vitalybuka@google.com>
Mon, 15 May 2017 22:04:03 +0000 (22:04 +0000)
committerVitaly Buka <vitalybuka@google.com>
Mon, 15 May 2017 22:04:03 +0000 (22:04 +0000)
This fix UBSAN bots after r302935. Storing non-defined values in enum is
undefined behavior.

Other places, where "if (ScalarCast != CK_Invalid)" is used, never get to the
"if" with CK_Invalid. tryGCCVectorConvertAndSplat can get to the "if" with
CK_Invalid and it looks like expected case. So we have to use something other
than CK_Invalid, e.g. CK_NoOp.

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

lib/Sema/SemaExpr.cpp

index fa64c4523fb244feb3480a769caee77dbe504595..14efc9672061ad882fa21a59055c59d99de3ffcc 100644 (file)
@@ -8204,7 +8204,7 @@ static bool tryGCCVectorConvertAndSplat(Sema &S, ExprResult *Scalar,
 
   // The conversion to apply to the scalar before splatting it,
   // if necessary.
-  CastKind ScalarCast = CK_Invalid;
+  CastKind ScalarCast = CK_NoOp;
 
   // Accept cases where the vector elements are integers and the scalar is
   // an integer.
@@ -8254,7 +8254,7 @@ static bool tryGCCVectorConvertAndSplat(Sema &S, ExprResult *Scalar,
 
   // Adjust scalar if desired.
   if (Scalar) {
-    if (ScalarCast != CK_Invalid)
+    if (ScalarCast != CK_NoOp)
       *Scalar = S.ImpCastExprToType(Scalar->get(), VectorEltTy, ScalarCast);
     *Scalar = S.ImpCastExprToType(Scalar->get(), VectorTy, CK_VectorSplat);
   }