-
Notifications
You must be signed in to change notification settings - Fork 259
Default-define out-of-line dtors for types with fwd-declared unique_ptr members #1088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,9 @@ struct primary_expression_node | |
// Cache to work around <https://github.com/llvm/llvm-project/issues/73336>. | ||
bool expression_list_is_fold_expression = false; | ||
|
||
// Out-of-line definition of the dtor is necessary due to the forward-declared | ||
// type(s) used in a std::unique_ptr as a member | ||
~primary_expression_node(); | ||
|
||
// API | ||
// | ||
|
@@ -234,6 +237,10 @@ struct prefix_expression_node | |
std::vector<token const*> ops; | ||
std::unique_ptr<postfix_expression_node> expr; | ||
|
||
// Out-of-line definition of the dtor is necessary due to the forward-declared | ||
// type(s) used in a std::unique_ptr as a member | ||
~prefix_expression_node(); | ||
|
||
// API | ||
// | ||
auto is_fold_expression() const | ||
|
@@ -293,6 +300,10 @@ struct binary_expression_node | |
|
||
binary_expression_node(); | ||
|
||
// Out-of-line definition of the dtor is necessary due to the forward-declared | ||
// type(s) used as Term in a std::unique_ptr as a member | ||
~binary_expression_node(); | ||
|
||
struct term | ||
{ | ||
token const* op; | ||
|
@@ -1087,6 +1098,18 @@ struct template_argument | |
std::unique_ptr<type_id_node> | ||
> arg; | ||
|
||
// The type needs to be movable | ||
// The copy ctor+operator are implicitly deleted due to the std::unique_ptr member | ||
// Because a forward-declared type is used in a std::unique_ptr as a member an out-of-line dtor is necessary | ||
// Because of the OOL dtor together with the fact that the copy ctor+operator are deleted | ||
// the move ctor+operator need to be explicitly defaulted | ||
// As a result the default constructor also needs to be explicitly defaulted | ||
template_argument() = default; | ||
template_argument(template_argument&&) = default; | ||
template_argument& operator=(template_argument&&) = default; | ||
|
||
~template_argument(); | ||
|
||
auto to_string() const | ||
-> std::string; | ||
}; | ||
|
@@ -1800,6 +1823,10 @@ struct iteration_statement_node | |
std::unique_ptr<statement_node> body; // used for "for", else null | ||
bool for_with_in = false;// used for "for," says whether loop variable is 'in' | ||
|
||
// Out-of-line definition of the dtor is necessary due to the forward-declared | ||
// type(s) used in a std::unique_ptr as a member | ||
~iteration_statement_node(); | ||
|
||
auto position() const | ||
-> source_position | ||
{ | ||
|
@@ -1851,6 +1878,10 @@ struct alternative_node | |
source_position equal_sign; | ||
std::unique_ptr<statement_node> statement; | ||
|
||
// Out-of-line definition of the dtor is necessary due to the forward-declared | ||
// type(s) used in a std::unique_ptr as a member | ||
~alternative_node(); | ||
|
||
auto position() const | ||
-> source_position | ||
{ | ||
|
@@ -1874,6 +1905,10 @@ struct inspect_expression_node | |
|
||
std::vector<std::unique_ptr<alternative_node>> alternatives; | ||
|
||
// Out-of-line definition of the dtor is necessary due to the forward-declared | ||
// type(s) used in a std::unique_ptr as a member | ||
~inspect_expression_node(); | ||
|
||
auto position() const | ||
-> source_position | ||
{ | ||
|
@@ -2011,6 +2046,10 @@ struct statement_node | |
|
||
statement_node(compound_statement_node* compound_parent_ = nullptr); | ||
|
||
// Out-of-line definition of the dtor is necessary due to the forward-declared | ||
// type(s) used in a std::unique_ptr as a member | ||
~statement_node(); | ||
|
||
enum active { expression=0, compound, selection, declaration, return_, iteration, using_, contract, inspect, jump }; | ||
std::variant< | ||
std::unique_ptr<expression_statement_node>, | ||
|
@@ -4386,6 +4425,26 @@ struct translation_unit_node | |
} | ||
}; | ||
|
||
// Definitions of out-of-line dtors for nodes with unique_ptr members of forward-declared types | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've decided to add the deferred dtor definitions here, at the point where (to the best of my knowledge) all node types are already defined. |
||
primary_expression_node::~primary_expression_node() = default; | ||
|
||
prefix_expression_node::~prefix_expression_node() = default; | ||
|
||
template< | ||
String Name, | ||
typename Term | ||
> | ||
binary_expression_node<Name, Term>::~binary_expression_node() = default; | ||
|
||
alternative_node::~alternative_node() = default; | ||
|
||
iteration_statement_node::~iteration_statement_node() = default; | ||
|
||
template_argument::~template_argument() = default; | ||
|
||
inspect_expression_node::~inspect_expression_node() = default; | ||
|
||
statement_node::~statement_node() = default; | ||
|
||
//----------------------------------------------------------------------- | ||
// | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting side-effect of the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good old SMF defaults 😁 Thanks!