Skip to content

rdl writer: propagate SupportedArchitecture to un-nested inner types - #4058

Merged
Kenny Kerr (kennykerr) merged 2 commits into
masterfrom
copilot/add-architecture-attributes-propagation
Mar 20, 2026
Merged

rdl writer: propagate SupportedArchitecture to un-nested inner types#4058
Kenny Kerr (kennykerr) merged 2 commits into
masterfrom
copilot/add-architecture-attributes-propagation

Conversation

Copilot AI commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

When the RDL writer un-nests anonymous inner types from arch-restricted structs/unions, the synthesised helper types (e.g. SLIST_HEADER_0) were emitted without any SupportedArchitecture attribute, incorrectly making them appear available on all architectures.

Changes

  • collect_nested — adds parent_arches: i32 parameter; computes effective_arches = parent_arches | nested.arches() per inner type so unrestricted inner types inherit the parent's constraint. Propagated recursively for deeply-nested cases. Now also emits any other custom attributes on inner types (previously none were written).
  • write_arch_attr — new helper mapping the arch bitmask (bit 0 = X86, bit 1 = X64, bit 2 = Arm64) to #[Windows::Win32::Foundation::Metadata::SupportedArchitecture(...)] tokens; returns empty stream for zero or unrecognised bits.
  • write_struct_items — seeds collect_nested with item.arches() from the outermost type.
  • tests/nested-arches — regression test filtering Windows.Win32.System.Kernel; the committed nested-arches-out.rdl shows SLIST_HEADER_0/SLIST_HEADER_1 each carrying the correct per-arch attribute.
// Before fix — un-nested inner types had no arch attribute:
struct SLIST_HEADER_0 { Alignment: u64, Region: u64, }

// After fix — arch inherited from parent SLIST_HEADER:
#[Windows::Win32::Foundation::Metadata::SupportedArchitecture(Arm64)]
struct SLIST_HEADER_0 { Alignment: u64, Region: u64, }
#[Windows::Win32::Foundation::Metadata::SupportedArchitecture(X64)]
struct SLIST_HEADER_0 { Alignment: u64, Region: u64, }
#[Windows::Win32::Foundation::Metadata::SupportedArchitecture(X86)]
struct SLIST_HEADER_0 { Next: SINGLE_LIST_ENTRY, Depth: u16, CpuId: u16, }

Copilot AI and others added 2 commits March 20, 2026 19:05
@kennykerr
Kenny Kerr (kennykerr) marked this pull request as ready for review March 20, 2026 19:27
@kennykerr
Kenny Kerr (kennykerr) merged commit cd5a2ad into master Mar 20, 2026
39 checks passed
@kennykerr
Kenny Kerr (kennykerr) deleted the copilot/add-architecture-attributes-propagation branch March 20, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants