transpile: Various fixes to type handling for builtins#1860
Conversation
6ac8aad to
7a907b6
Compare
6ec15cf to
d7fcb1c
Compare
d7fcb1c to
aaabe91
Compare
fw-immunant
left a comment
There was a problem hiding this comment.
LGTM overall, but would appreciate a comment where mentioned inline.
aaabe91 to
04f75f7
Compare
fw-immunant
left a comment
There was a problem hiding this comment.
NAK on the comment change - now the name of bubble_expr_types and its comment disagree on its primary purpose. It exists to homogeneize types between Clang versions by bubbling up types from child AST nodes to parent ones (and these types are not necessarily ones in PULLBACK_KINDS, e.g. in the case of bit shifts), and the other things it does are unrelated to this function. They should really be done separately, so we can remove the function when we no longer support Clang <16. Translating arbitrary C operations producing one type to Rust ones that producing a different type (based on the operation's identity rather than its children) seems best done in expr translation rather than by altering types here.
We don't necessarily need to change where this logic happens in this PR, but I meant to ask for a comment that documents the tech debt here rather than making it sound like the current confusing arrangement is by design.
Iterating through the whole AST is somewhat expensive, so I figure it's more efficient to fit it all together like this.
Perhaps, but the difficulty here is that the "bubbling" is done bottom-up while translation operates top-down. For example, if you have an expression like |
CTypeKind::Boolis always present)size_tfor__builtin_object_sizecast tounsigned long, causing Rust type mismatch #1707