Skip to content

Fix static member call instantiation #7377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

simoll
Copy link
Contributor

@simoll simoll commented Apr 24, 2025

The first parameter of the HLSL_INTRINSIC record is actually a dummy entry for the function name.
When builtin member function templates are instantiated, the 'this' ptr is added as the first ParamVarDecl, which has the same index as the first argument in the HLSL_INTRINSIC record.
This shifts the parameter names by one for static member functions, as those do not have a 'this' pointer, as in:

| | | `-CXXMethodDecl {{[^ ]+}} <<invalid sloc>> <invalid sloc> used MakeMiss 'dx::HitObject (unsigned int, unsigned int, RayDesc)' static
| | |   |-TemplateArgument type 'dx::HitObject'
| | |   |-TemplateArgument type 'unsigned int'
| | |   |-TemplateArgument type 'unsigned int'
| | |   |-TemplateArgument type 'RayDesc'
| | |   |-ParmVarDecl {{[^ ]+}} <<invalid sloc>> <invalid sloc> MakeMiss 'unsigned int'
| | |   |-ParmVarDecl {{[^ ]+}} <<invalid sloc>> <invalid sloc> RayFlags 'unsigned int'
| | |   |-ParmVarDecl {{[^ ]+}} <<invalid sloc>> <invalid sloc> MissShaderIndex 'RayDesc'

The fix is the take the first actual parameter name of the HLSL_INTRINSIC if a static member function template is declared.

Closes #7374

The first parameter of the HLSL_INTRINSIC record is actually a dummy
entry for the function name.
When builtin member function templates are instantiated, the 'this' ptr is
added as the first ParamVarDecl, which has the same index as the first
argument in the HLSL_INTRINSIC record.
This shifts the parameter names by one for static member functions, as
those do not have a 'this' pointer, as in:

| | | `-CXXMethodDecl {{[^ ]+}} <<invalid sloc>> <invalid sloc> used MakeMiss 'dx::HitObject (unsigned int, unsigned int, RayDesc)' static
| | |   |-TemplateArgument type 'dx::HitObject'
| | |   |-TemplateArgument type 'unsigned int'
| | |   |-TemplateArgument type 'unsigned int'
| | |   |-TemplateArgument type 'RayDesc'
| | |   |-ParmVarDecl {{[^ ]+}} <<invalid sloc>> <invalid sloc> MakeMiss 'unsigned int'
| | |   |-ParmVarDecl {{[^ ]+}} <<invalid sloc>> <invalid sloc> RayFlags 'unsigned int'
| | |   |-ParmVarDecl {{[^ ]+}} <<invalid sloc>> <invalid sloc> MissShaderIndex 'RayDesc'

The fix is the take the first actual parameter name of the
HLSL_INTRINSIC if a static member function template is declared.

Closes microsoft#7374
Copy link
Contributor

@tex3d tex3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

Parameter types misaligned in static member functions
2 participants