transpile: Add convert_decl_ref and convert_enum_constant_decl_ref - #1889
Conversation
| } | ||
| } | ||
|
|
||
| if let CDeclKind::EnumConstant { .. } = decl { |
There was a problem hiding this comment.
You're moving this before the reorganize_definitions check below, is this correct?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I've added a new commit to remove the check.
ec95ebf to
05c294f
Compare
Some of the refactorings needed for #1620, split off so that they can be merged earlier.