Skip to content

transpile: Add convert_decl_ref and convert_enum_constant_decl_ref - #1889

Merged
ahomescu merged 3 commits into
immunant:masterfrom
Rua:split-decl-ref
Jul 31, 2026
Merged

transpile: Add convert_decl_ref and convert_enum_constant_decl_ref#1889
ahomescu merged 3 commits into
immunant:masterfrom
Rua:split-decl-ref

Conversation

@Rua

@Rua Rua commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Some of the refactorings needed for #1620, split off so that they can be merged earlier.

}
}

if let CDeclKind::EnumConstant { .. } = decl {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're moving this before the reorganize_definitions check below, is this correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In principle yes, because convert_enum_constant_decl_ref calls enum_constant_expr, which does the importing itself. What puzzles me more is why the import is gated behind reorganize_definitions in the first place? Should enum_constant_expr be doing the same? I don't understand the original logic behind it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In reorganize_definitions mode we emit the code coming in from #included headers in separate sub-modules. In that case, each use of a header declaration needs to import it from its sub-module, so the transpiler calls add_import. There is one interesting thing going on there: that method calls add_use_item which checks if the imported item lives in the same module as the use, and it skips the import in that case. I think that makes the if self.tcfg.reorganize_definitions check redundant before self.add_import.

It's weird to me because both checks were introduced in the same commit 7154048c138, but they still feel redundant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a new commit to remove the check.

@Rua
Rua force-pushed the split-decl-ref branch 4 times, most recently from ec95ebf to 05c294f Compare July 30, 2026 07:56
@Rua
Rua force-pushed the split-decl-ref branch from 05c294f to 79eceb6 Compare July 31, 2026 07:23
@ahomescu
ahomescu merged commit 54205b7 into immunant:master Jul 31, 2026
11 checks passed
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