Skip to content

Conversation

llvm-beanz
Copy link
Collaborator

@llvm-beanz llvm-beanz commented Jun 4, 2025

This change adds additional calls to Sema::RequireCompleteType, one when evaluating unary sizeof, which fixes a reported issue with templates.

The second area is in the DXR diagnostics where complete type should be required but not diagnosed because ordering in the compiler is a bit wonky when diagnosing DXR entry points.

The third is when checking the template argument for Load/Store, where again an incomplete type will be diagnosed later, but needs to be handled at this point.

Fixes #7510

This change adds two additional calls to Sema::RequireCompleteType, one
when evaluating unary `sizeof`, which fixes a reported issue with
templates. The second is in the DXR diagnostics where complete type
should be required but not diagnosed because ordering in the compiler is
a bit wonky when diagnosing DXR entry points.

Fixes microsoft#7510

../tools/clang/test/SemaHLSL/raytracing-entry-diags.hlsl
../tools/clang/test/SemaHLSL/sizeof-requires-complete-type.hlsl
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.

Thanks Chris!

@llvm-beanz
Copy link
Collaborator Author

@tex3d's additions look good to me. I can't approve since I'm the original author.

Copy link
Contributor

@pow2clk pow2clk left a comment

Choose a reason for hiding this comment

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

It looks sensible to me. The overall question I have is how do we determine where this is needed? Is it anywhere we check a type in Sema? Is there not somewhere we can insert this once and for all? I added a lot of these as part of the longvector diagnostics

Copy link
Member

@hekota hekota left a comment

Choose a reason for hiding this comment

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

LGTM!

@tex3d
Copy link
Contributor

tex3d commented Jun 5, 2025

It looks sensible to me. The overall question I have is how do we determine where this is needed? Is it anywhere we check a type in Sema? Is there not somewhere we can insert this once and for all? I added a lot of these as part of the longvector diagnostics

Yeah, it's a bit more complicated than that. While it would seem convenient to call RequireCompleteType from IsHLSLCopyableAnnotatableRecord, the code that's calling this may need to handle an incomplete type scenario differently than a failing IsHLSLCopyableAnnotatableRecord call. Plus, some code paths should be able to assume the type is completed already, otherwise something else is wrong. For instance, there's a code path that uses IsHLSLCopyableAnnotatableRecord for a call argument type (payload) during DiagnoseTranslationUnit, where there should definitely not be an incomplete type, and if there was, this is not the right time to complete it, so it will hit the assert instead of blindly trying to complete the type now.

@llvm-beanz llvm-beanz merged commit 77dcbb6 into microsoft:main Jun 5, 2025
12 checks passed
@llvm-beanz llvm-beanz deleted the cbieneman/sizeof-requires-type branch June 5, 2025 18:37
@github-project-automation github-project-automation bot moved this from New to Done in HLSL Roadmap Jun 5, 2025
tex3d added a commit to tex3d/DirectXShaderCompiler that referenced this pull request Jun 6, 2025
This change adds two additional calls to Sema::RequireCompleteType, one
when evaluating unary `sizeof`, which fixes a reported issue with
templates. The second is in the DXR diagnostics where complete type
should be required but not diagnosed because ordering in the compiler is
a bit wonky when diagnosing DXR entry points.

Fixes microsoft#7510

---------

Co-authored-by: Tex Riddell <[email protected]>
(cherry picked from commit 77dcbb6)
tex3d added a commit that referenced this pull request Jun 11, 2025
This change adds two additional calls to Sema::RequireCompleteType, one
when evaluating unary `sizeof`, which fixes a reported issue with
templates. The second is in the DXR diagnostics where complete type
should be required but not diagnosed because ordering in the compiler is
a bit wonky when diagnosing DXR entry points.

Fixes #7510

---------


(cherry picked from commit 77dcbb6)

Co-authored-by: Chris B <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Segfault when calling sizeof() on templated type
4 participants