[all-commits] [llvm/llvm-project] f03bcb: [HLSL][RootSignature] Audit `RootSignatureParser` ...

Finn Plummer via All-commits all-commits at lists.llvm.org
Fri Jul 11 19:40:31 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f03bcb7594254b91098f16a339dd6ba4c55a0c8e
      https://github.com/llvm/llvm-project/commit/f03bcb7594254b91098f16a339dd6ba4c55a0c8e
  Author: Finn Plummer <finn.c.plum at gmail.com>
  Date:   2025-07-11 (Fri, 11 Jul 2025)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticParseKinds.td
    M clang/include/clang/Parse/ParseHLSLRootSignature.h
    M clang/lib/Parse/ParseHLSLRootSignature.cpp
    M clang/test/SemaHLSL/RootSignature-err.hlsl
    M clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp

  Log Message:
  -----------
  [HLSL][RootSignature] Audit `RootSignatureParser` diagnostic production (#147800)

This pr audits the diagnostics produced in `RootSignatureParser`
diagnostics.

First, it has been noted more than once that the current
`diag::err_hlsl_unexpected_end_of_params` is not direct and can be
misleading. For instance,
[here](https://github.com/llvm/llvm-project/pull/147350#discussion_r2193717272)
and
[here](https://github.com/llvm/llvm-project/pull/145827#discussion_r2169406679).

This pr address this by removing this diagnostic and replacing it with a
more direct `diag::err_expected_either`. However, doing so removes the
nuance between the case where it is a missing comma and when it was an
invalid parameter.

Hence, we introduce the `diag::err_hlsl_invalid_token` for the latter
case, which does so in a direct way. Further, we can apply the same
diagnostic to the parsing of parameter values.

As part of this, we see that there was a test gap in testing the
diagnostics produced from `diag::err_expected_after` and for the parsing
of enum/flag values. As such, these are also addressed here to provide
sufficient unit/sema test coverage.

- Removes all uses of `diag::err_hlsl_unexpected_end_of_params` in
`RootSigantureParser`
- Introduce `diag::err_hlsl_invalid_token` to provide a direct
diagnostic
- In each of these cases, replace the diagnostic with either a
`diag::err_hlsl_invalid_token` or `diag::err_expected_either`
accordingly
- Update `HLSLRootSignatureParserTest` to account for diagnostic changes
- Increase test coverage of `HLSLRootSignatureParserTest` for enum/flag
diagnostics
- Increase test coverage of `RootSignatures-err` for enum/flag
diagnostics
- Small fix-up of the `diag::err_expected_after` and add test to
demonstrate usage

Resolves: https://github.com/llvm/llvm-project/issues/147799



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list