[clang] [Matrix][Clang][HLSL] Move MaxMatrixDimension to a LangOpt (PR #163307)
Farzon Lotfi via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 14 10:29:15 PDT 2025
farzonl wrote:
> This change isn't NFC. You're not just moving a set value out of a header, you're also changing how it applies to the underlying `matrix_type` attribute. That warrants tests.
We already have the test that confirm behavior differences that confirm the impact on the underlying `matrix_type` but there are no explicit tests on
Language option values. From looking how others have done this via
git grep -n "Invocation.getLangOpts()" -- clang/unittests/
It is all just looking at the getter() value. No one is changing a LangOpts and check if it impacts sema or ast generation.
There are tests like that in `ASTImporterTest.cpp`
```bash
clang/unittests/AST/ASTImporterTest.cpp:670: testImport("typedef int __attribute__((matrix_type(5, 5))) declToImport;",
clang/unittests/AST/ASTImporterTest.cpp:681: using declToImport = T __attribute__((matrix_type(Rows, Cols)));
```
but all of those aren't testing impact on `matrix_type` but rather its visibility with use of the `-fenable-matrix` flag.
If you are looking for sema tests maybe this should be a `Options.td` and not a LangOpt? then it would be easier to change the value per runline and show changing matrix dimmension constraints.
Anyways to recap these are the tests that exist:
clang/test/Sema/matrix-type-builtins.c
clang/test/SemaCXX/matrix-type-builtins.cpp
// expected-error at -1 {{row dimension is outside the allowed range [1, 1048575}}
// expected-error at -1 {{column dimension is outside the allowed range [1, 1048575}}
On the `__builtin_matrix_column_major_load` clang builtin
And in
clang/test/SemaHLSL/BuiltIns/matrix-basic_types-errors.hlsl
We are confirming that the constraint is applied on matrix<int, 5, 5> mat3;
// expected-error at -1 {{constraints not satisfied for alias template 'matrix' [with element = int, rows_count = 5, cols_count = 5]}}
// expected-note@* {{because '5 <= 4' (5 <= 4) evaluated to false}}
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?
https://github.com/llvm/llvm-project/pull/163307
More information about the cfe-commits
mailing list