[clang] [HLSL] Add matrix constructors using initalizer lists (PR #162743)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 9 17:07:07 PDT 2025


================
@@ -1877,6 +1887,93 @@ void InitListChecker::CheckReferenceType(const InitializedEntity &Entity,
     AggrDeductionCandidateParamTypes->push_back(DeclType);
 }
 
+void InitListChecker::CheckMatrixType(const InitializedEntity &Entity,
----------------
farzonl wrote:

Well three things  First SemaHLSL is validating vectors and yet we still have `CheckVectorType` which even has HLSL copy initalization.

Second removing 
```cpp
} else if (DeclType->isMatrixType()) {
    CheckMatrixType(Entity, IList, DeclType, Index, StructuredList,
                    StructuredIndex);
  }
```
causes us to hit this else case:
https://github.com/llvm/llvm-project/blob/0c2913afc82a683d82f16f09442d49b1fb25ca67/clang/lib/Sema/SemaInit.cpp#L1481-L1486

Third even if we do something like below to avoid the err_illegal_initializer_type diag message
```cpp
} else if (DeclType->isMatrixType()) {
    return;
  }
```
we still error with `excess elements in matrix initializer`. So `CheckMatrixType` is necessary. 

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


More information about the cfe-commits mailing list