Skip to content

refactor(to_cpp1): decentralize lowering of special member functions #1295

Closed as not planned
@JohelEGP

Description

@JohelEGP

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:

#478 fixes #422 by generating a default constructor.
to_cpp1.h takes care of lowering a default constructor
that both uses the NSDMIs and #lines to their .cpp2 source.

operator=s could also be generated.
[emit_special_member_function], on top of lowering member initializer lists, simulates the generation during lowering.
That has resulted in bugs because some logic isn't repeated for the member-wise assignments.
For example, #487 didn't work in the member-wise assignments, so #680 had to add a special case for it.
Another example might be #822.

-- #844 (comment).

cppfront::emit_special_member_function, in to_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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions