Skip to content

Fix stale ODR-use state before lexed inline methods - #8324

Closed
Arkadiusz Lachowicz (AnastaZIuk) wants to merge 1 commit into
microsoft:mainfrom
Devsh-Graphics-Programming:fix_ex40_assert_2026_04_01
Closed

Arkadiusz Lachowicz (AnastaZIuk) wants to merge 1 commit into
microsoft:mainfrom
Devsh-Graphics-Programming:fix_ex40_assert_2026_04_01

Conversation

@AnastaZIuk

Copy link
Copy Markdown
Contributor

Summary

This clears stale delayed ODR-use bookkeeping before starting a lexed inline method body.

It also adds a small SPIR-V regression test for the same parser path.

Root cause

The missing cleanup is in ParseLexedMethodDef, which was introduced in 6ee4074a4.

That path enters ActOnStartOfFunctionDef(...) without first calling CleanupVarDeclMarking().

HLSL constant-expression references inside declarations such as [[vk::binding(Bindings::Mask, SessionDSIndex)]] can leave entries in MaybeODRUseExprs.

When the next lexed inline method is parsed, ActOnFinishFunctionBody(...) trips the debug invariant:

Leftover expressions for odr-use checking

Impact

This crashes assert-enabled DXC builds on valid HLSL.

Public release-like builds usually compile the same source because assertions are off, so the bug is masked rather than absent.

Repros

Both CE links use the public dxc_trunk build, so they compile there because that build does not expose the local debug assert path.

@llvm-beanz

Copy link
Copy Markdown
Collaborator

The test case provided in the PR does not fail with DXC without this patch. The Linked godbolt contains loads of invalid HLSL and errors as a result of the invalid code.

The LLM-spew in the description does not give me any indication why this change is warranted or correct, and modern Clang does not have this change, so it doesn't seem to be correct for C++.

For all of those reasons I'm going to close this PR. If you believe there is something we should actually fix here, please provide an updated patch with a concrete test case and a human-written explanation of why it is necessary and correct.

@AnastaZIuk

Copy link
Copy Markdown
Contributor Author

Chris B (@llvm-beanz)

modern Clang does not have this change, so it doesn't seem to be correct for C++.

That conclusion is false and Clang does the cleanup earlier, see #9072.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spirv Work related to SPIR-V

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants