Author: vitalybuka Date: Mon May 15 17:04:03 2017 New Revision: 303121 URL: http://llvm.org/viewvc/llvm-project?rev=303121&view=rev Log: [Sema] Use CK_NoOp instead CK_Invalid in tryGCCVectorConvertAndSplat
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. Modified: cfe/trunk/lib/Sema/SemaExpr.cpp Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=303121&r1=303120&r2=303121&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon May 15 17:04:03 2017 @@ -8204,7 +8204,7 @@ static bool tryGCCVectorConvertAndSplat( // 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( // 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); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits