From 28d94b1df214a04f479a65000eb37e56ef5c8c39 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 5 Mar 2015 23:06:09 +0000 Subject: [PATCH] Patch to fix the AST for vector splat from any arithmetic type to a vector so that the arithmatic type matches the vector element type. Without which it crashes in Code Gen. rdar://20000762 llvm-svn: 231419 --- clang/lib/Sema/SemaExprCXX.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'clang/lib/Sema/SemaExprCXX.cpp') diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 6ad0b24275a..29e5150073d 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -3000,8 +3000,18 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, break; case ICK_Vector_Splat: - From = ImpCastExprToType(From, ToType, CK_VectorSplat, - VK_RValue, /*BasePath=*/nullptr, CCK).get(); + // Vector splat from any arithmetic type to a vector. + // Cast to the element type. + { + QualType elType = ToType->getAs()->getElementType(); + if (elType != From->getType()) { + ExprResult E = From; + From = ImpCastExprToType(From, elType, + PrepareScalarCast(E, elType)).get(); + } + From = ImpCastExprToType(From, ToType, CK_VectorSplat, + VK_RValue, /*BasePath=*/nullptr, CCK).get(); + } break; case ICK_Complex_Real: -- cgit v1.2.3