[clang] [Matrix][Clang][HLSL] Move MaxMatrixDimension to a LangOpt (PR #163307)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 15 08:06:58 PDT 2025


farzonl wrote:

> The behavior change is that in HLSL-mode the `matrix_type` attribute has reduced size limits.
> 
> > We are confirming that the constraint is applied on matrix<int, 5, 5> mat3;
> > https://github.com/llvm/llvm-project/blob/b358af10a7b783e771a1e5ad6ded3e3535648b06/clang/test/SemaHLSL/BuiltIns/matrix-basic_types-errors.hlsl#L10-L12
> 
> This is enforced by the `matrix` template, you're changing the implementation to _also_ enforce this on the `matrix_type` attribute.
> 
> > Since the behavior differences are tested. I’ve just added an explicit compiler invocation test to confirm this number changes When we change the language mode to HLSL. I think that’s all you wanted?
> 
> With this PR, clang should generate an error on this code:
> 
> ```c++
> using float8x8 = __attribute__((matrix_type(8,8))) float;
> ```
> 
> Which would not have been generated without this PR (See [Compiler Explorer](https://godbolt.org/z/Gh53nEGEs))

I think there is a misunderstanding here. this change doesn't impact any constraints on `matrix_type`. we are just moving where the dim variable is stored to a language option. We have a different ticket to change size constraints for the unaliased version of `matrix_type` here: https://github.com/llvm/llvm-project/issues/116710

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


More information about the cfe-commits mailing list