[SPIR-V] NonSemantic DebugTypeMember omits static data members
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The SPIR-V NSDI handler does not represent static data members of a struct, class, or union.
`SPIRVNonSemanticDebugHandler::emitDebugTypeComposite` emits a `DebugTypeMember` only for elements tagged `DW_TAG_member` (#211638). Two things are missing for static members:
1. Under DWARF 5, Clang tags a static data member `DW_TAG_variable`, not `DW_TAG_member`. This means that a DWARF-5 static member is skipped entirely and never appears in the composite.
2. `DebugTypeMember` has an optional trailing `Value` operand for the compile-time initializer of a `const static` member. It is never emitted, even for a pre-DWARF-5 `DW_TAG_member` static member. The initializer is available in the metadata as `DIDerivedType::getConstant()`.
We could fix this as follows:
1. In the member loop, also accept a `DIDerivedType` tagged `DW_TAG_variable` when it is a static member (`DIType::isStaticMember()`).
2. In `emitDebugTypeMember`, when the member is static and `getConstant()` returns a constant, emit it as the `Value` operand.
Contributor guide
Assessment
This issue has not been assessed yet.