[clangd][HLSL] Code Completion Inside register(...)
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
## Expected behavior
Typing `register(` should suggest the correct slot prefix for the declared resource type (e.g. `u0` for `RWStructuredBuffer`, `t0` for `Texture2D`). Typing `register(t0`, should suggest `space0`). It should also be Tab-navigable snippets.
## Observed behavior
Completion inside `register(|)` or `register(t0, |)` showed generic top-level results.
## Reprodution
```hlsl
StructuredBuffer inputData : register(...
```
## Root cause
`ParseHLSLAnnotations` had no `tok::code_completion` hooks inside the `AT_HLSLResourceBinding` case. The token fell through to the error branch, which called `SkipUntil` and returned, leaving the parser at top-level context. The `Declarator*` was also not threaded through, making type-aware slot filtering impossible.
## Proposed fix
Two `ConsumeCodeCompletionToken()` hooks inside `AT_HLSLResourceBinding`. `CodeCompleteHLSLResourceSlot(D)` receives the `Declarator*` and resolves the resource class by matching the `CXXRecordDecl` name.
Contributor guide
Research direction
Start in ParseHLSLAnnotations at the AT_HLSLResourceBinding case and trace the existing ConsumeCodeCompletionToken flow. Check how CodeCompleteHLSLResourceSlot can use the threaded Declarator* and CXXRecordDecl resource name for slot filtering. Done means register(...) suggests the type-appropriate slot prefix, register(t0, ...) suggests space0, and both support Tab-navigable snippets without falling back to top-level completion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100