At the moment, when we report diagnostics from SemaHLSL we only provide the source location of the root signature attr. This allows for significantly less helpful diagnostics (for eg. reporting resource range overlaps).
This issue tracks implementing a way to retain the source location of a root element when it is parsed, so that we can output the SourceLocation of each root element that causes the overlap in the diagnostics during semantic analysis.
Right now, the RootElement data struct is defined in llvm::hlsl::rootsig, and so it can't retain any clang specific diagnostic information (such as SourceLocation). This issue proposes define a wrapper struct clang::hlsl::RootSignatureElement in SemaHLSL that will contain the underlying RootElement and can hold any additional diagnostic information. This struct will be what is used in HLSLRootSignatureParser and in SemaHLSL. Then the diagnostic information will be stripped and the underlying element will be stored in the RootSignatureDecl.
For the reporting of diagnostics, we can use the now retained SourceLocation of each RootElement when reporting the range overlap, and we can add a note diagnostic to highlight the other root element as well.
With this abstraction, we are able to move the current resource range analysis that is contained in SemaHLSL to the RootSignatueValidations library to be re-used in the backend as well. Please see the sub-issue for a description.
AC:
At the moment, when we report diagnostics from
SemaHLSLwe only provide the source location of the root signature attr. This allows for significantly less helpful diagnostics (for eg. reporting resource range overlaps).This issue tracks implementing a way to retain the source location of a root element when it is parsed, so that we can output the
SourceLocationof each root element that causes the overlap in the diagnostics during semantic analysis.Right now, the
RootElementdata struct is defined inllvm::hlsl::rootsig, and so it can't retain any clang specific diagnostic information (such asSourceLocation). This issue proposes define a wrapper structclang::hlsl::RootSignatureElementinSemaHLSLthat will contain the underlyingRootElementand can hold any additional diagnostic information. This struct will be what is used inHLSLRootSignatureParserand inSemaHLSL. Then the diagnostic information will be stripped and the underlying element will be stored in theRootSignatureDecl.For the reporting of diagnostics, we can use the now retained
SourceLocationof eachRootElementwhen reporting the range overlap, and we can add anotediagnostic to highlight the other root element as well.With this abstraction, we are able to move the current resource range analysis that is contained in
SemaHLSLto theRootSignatueValidationslibrary to be re-used in the backend as well. Please see the sub-issue for a description.AC:
RootSignatureElementin thehlslnamespace inSemaHLSL(defined inSemaHLSLbecauseParsehas a dependency onSema)RootSignatureElements and retain the source loction inParseHLSLRootSignatureSemaHLSLwhen it constructs theRootSignatureDeclto take the newRootSignatureElementand store the underlyingRootElementnotediagnostic is produced and that theSourceLocationis seen