[clang] [Sema][HLSL][Matrix] Make matrices initializable by a single vector and vice-versa (PR #177486)

Deric C. via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 17 14:48:36 PST 2026


================
@@ -6938,7 +6938,12 @@ void InitializationSequence::InitializeFrom(Sema &S,
   // For HLSL ext vector types we allow list initialization behavior for C++
   // functional cast expressions which look like constructor syntax. This is
   // accomplished by converting initialization arguments to InitListExpr.
-  if (S.getLangOpts().HLSL && Args.size() > 1 &&
+  bool IsHLSLMatToVecOrVecToMatInit =
+      S.getLangOpts().HLSL && Args.size() == 1 &&
+      ((SourceType->isExtVectorType() && DestType->isConstantMatrixType()) ||
+       (SourceType->isConstantMatrixType() && DestType->isExtVectorType()));
+  if (S.getLangOpts().HLSL &&
+      (IsHLSLMatToVecOrVecToMatInit || Args.size() > 1) &&
       (DestType->isExtVectorType() || DestType->isConstantMatrixType()) &&
       (SourceType.isNull() ||
        !Context.hasSameUnqualifiedType(SourceType, DestType))) {
----------------
Icohedron wrote:

I replaced the condition with a call to a boolean lambda expression with early exits

https://github.com/llvm/llvm-project/pull/177486


More information about the cfe-commits mailing list