Open JohelEGP opened 1 month ago
The quoted https://github.com/hsutter/cppfront/issues/844#issuecomment-1829023060 also includes a worthwhile suggestion:
operator=
s could also be generated.
One of the things emit_special_member_function
does
is lowering up to 4 Cpp1 declarations from a single Cpp2 operator=
.
Arguably, this makes it hard to refactor, since the other lowering functions are unable to do so.
Instead of determining what an operator=
generates at to_cpp1
time,
we could generate them with a built-in metafunction that runs last.
For starters, that would greatly simplify emit_special_member_function
,
which will then need to emit only one declaration at a time.
operator=
s could also be generated.
This necessitates expanding the reflection API to reflect on function bodies.
Title: refactor(to_cpp1): decentralize lowering of special member functions.
Description:
Since the dawn of Cpp2 user-defined types, there have been bugs in the lowered Cpp1 special member functions. The focus of this issue is Cpp2 code that in any other context lowers correctly.
There are some issues and fixing PRs for (some of) those, some resolved or merged, and others still open. You can navigate those in this quote to reach some of them:
cppfront::emit_special_member_function
, into_cpp1.h
, centralizes the lowering of special member functions. Its duplication of logic is a source of bugs. In order to uproot present and future issues, I think we should decentralize it. We should strive to leave ever more to the lowering functions that already work, and focus ever more on handling only that which makes lowering special member functions unique.