Skip to content

Unwrap MIDL-synthesised anonymous enum names into top-level constants - #4273

Merged
Rafael Rivera (riverar) merged 2 commits into
masterfrom
copilot/unwrap-anonymous-enumeration
Apr 23, 2026
Merged

Unwrap MIDL-synthesised anonymous enum names into top-level constants#4273
Rafael Rivera (riverar) merged 2 commits into
masterfrom
copilot/unwrap-anonymous-enumeration

Conversation

Copilot AI commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

MIDL assigns synthetic tag names (e.g. __MIDL___MIDL_itf_dia2_0000_0000_0001) to enumerations that were anonymous in the original IDL. The clang parser was treating these as named enums instead of unwrapping their variants as top-level constants.

  • cx.rs: Added is_midl_anonymous_enum_name() — returns true for names starting with __MIDL_, the prefix MIDL uses for all synthesised anonymous-type names.
  • mod.rs: Extended the anonymous-enum check to also cover MIDL-synthesised names, so their variants are emitted as top-level RDL constants (same path as truly unnamed enum { ... }).
  • roundtrip/midl_enum.{h,rdl}: New roundtrip golden test exercising the fix.

Before:

#[repr(i32)]
enum __MIDL___MIDL_itf_test_0000_0000_0001 {
    E_PDB_OUT_OF_MEMORY = -2140340221,
}

After:

const E_PDB_OUT_OF_MEMORY: i32 = -2140340221;

Copilot AI changed the title [WIP] Fix anonymous enumeration unwrapping for Windows RDL Unwrap MIDL-synthesised anonymous enum names into top-level constants Apr 23, 2026
@riverar
Rafael Rivera (riverar) marked this pull request as ready for review April 23, 2026 21:54
@riverar
Rafael Rivera (riverar) merged commit 66d31e5 into master Apr 23, 2026
28 checks passed
@riverar
Rafael Rivera (riverar) deleted the copilot/unwrap-anonymous-enumeration branch April 23, 2026 21:55
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.

windows-rdl / clang: consider unwrapping midl-wrapped anonymous enumerations

3 participants