Skip to content

[HLSL] Template parameter elision creates confusing Diagnostics for mismatched vector (matrix) templates #112410

@pow2clk

Description

@pow2clk

Because HLSL vector types (and soon matrices) are defined as templates, some of the diagnostics will treat them as user-defined templates that don't match in all the particulars instead of printing them as types in their diagnostic messages.

These take the form of eliding the template elements that match, which makes it unclear what HLSL types they refer to or even that they refer to HLSL types. Two examples:

cannot initialize a variable of type 'vector<[...], 4>' with an lvalue of type 'vector<[...], 3>'
assigning to 'matrix<float, [2 * ...]>' from incompatible type 'matrix<int, [2 * ...]>

This can be seen in this test and will manifest in several of the new matrix tests.

The elision could be removed, but that would change behavior elsewhere. Perhaps a preferrable solution would be to direct these diagnostic prints to places where the types get printed instead of the more generic template outputs. These don't involve TypePrinter at all, rather the output comes from the TemplateDiff class in ASTDiagnostics.c

void PrintElideArgs(unsigned NumElideArgs, unsigned Indent) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    HLSLHLSL Language Supportclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions