Skip to content

Commit 4bfa240

Browse files
committed
Add OOL dtor defs to fix unique_ptr issues
1 parent 130f149 commit 4bfa240

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

source/parse.h

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ struct primary_expression_node
145145
// Cache to work around <https://github.com/llvm/llvm-project/issues/73336>.
146146
bool expression_list_is_fold_expression = false;
147147

148+
// Out-of-line definition of the dtor is necessary due to the forward-declared
149+
// type(s) used in a std::unique_ptr as a member
150+
~primary_expression_node();
148151

149152
// API
150153
//
@@ -238,6 +241,10 @@ struct prefix_expression_node
238241
std::vector<token const*> ops;
239242
std::unique_ptr<postfix_expression_node> expr;
240243

244+
// Out-of-line definition of the dtor is necessary due to the forward-declared
245+
// type(s) used in a std::unique_ptr as a member
246+
~prefix_expression_node();
247+
241248
// API
242249
//
243250
auto is_fold_expression() const
@@ -297,6 +304,10 @@ struct binary_expression_node
297304

298305
binary_expression_node();
299306

307+
// Out-of-line definition of the dtor is necessary due to the forward-declared
308+
// type(s) used as Term in a std::unique_ptr as a member
309+
~binary_expression_node();
310+
300311
struct term
301312
{
302313
token const* op;
@@ -1090,6 +1101,18 @@ struct template_argument
10901101
std::unique_ptr<type_id_node>
10911102
> arg;
10921103

1104+
// The type needs to be movable
1105+
// The copy ctor+operator are implicitly deleted due to the std::unique_ptr member
1106+
// Because a forward-declared type is used in a std::unique_ptr as a member an out-of-line dtor is necessary
1107+
// Because of the OOL dtor together with the fact that the copy ctor+operator are deleted
1108+
// the move ctor+operator need to be explicitly defaulted
1109+
// As a result the default constructor also needs to be explicitly defaulted
1110+
template_argument() = default;
1111+
template_argument(template_argument&&) = default;
1112+
template_argument& operator=(template_argument&&) = default;
1113+
1114+
~template_argument();
1115+
10931116
auto to_string() const
10941117
-> std::string;
10951118
};
@@ -1803,6 +1826,10 @@ struct iteration_statement_node
18031826
std::unique_ptr<statement_node> body; // used for "for", else null
18041827
bool for_with_in = false;// used for "for," says whether loop variable is 'in'
18051828

1829+
// Out-of-line definition of the dtor is necessary due to the forward-declared
1830+
// type(s) used in a std::unique_ptr as a member
1831+
~iteration_statement_node();
1832+
18061833
auto position() const
18071834
-> source_position
18081835
{
@@ -1854,6 +1881,10 @@ struct alternative_node
18541881
source_position equal_sign;
18551882
std::unique_ptr<statement_node> statement;
18561883

1884+
// Out-of-line definition of the dtor is necessary due to the forward-declared
1885+
// type(s) used in a std::unique_ptr as a member
1886+
~alternative_node();
1887+
18571888
auto position() const
18581889
-> source_position
18591890
{
@@ -1877,6 +1908,10 @@ struct inspect_expression_node
18771908

18781909
std::vector<std::unique_ptr<alternative_node>> alternatives;
18791910

1911+
// Out-of-line definition of the dtor is necessary due to the forward-declared
1912+
// type(s) used in a std::unique_ptr as a member
1913+
~inspect_expression_node();
1914+
18801915
auto position() const
18811916
-> source_position
18821917
{
@@ -2014,6 +2049,10 @@ struct statement_node
20142049

20152050
statement_node(compound_statement_node* compound_parent_ = nullptr);
20162051

2052+
// Out-of-line definition of the dtor is necessary due to the forward-declared
2053+
// type(s) used in a std::unique_ptr as a member
2054+
~statement_node();
2055+
20172056
enum active { expression=0, compound, selection, declaration, return_, iteration, using_, contract, inspect, jump };
20182057
std::variant<
20192058
std::unique_ptr<expression_statement_node>,
@@ -4389,6 +4428,26 @@ struct translation_unit_node
43894428
}
43904429
};
43914430

4431+
// Definitions of out-of-line dtors for nodes with unique_ptr members of forward-declared types
4432+
primary_expression_node::~primary_expression_node() = default;
4433+
4434+
prefix_expression_node::~prefix_expression_node() = default;
4435+
4436+
template<
4437+
String Name,
4438+
typename Term
4439+
>
4440+
binary_expression_node<Name, Term>::~binary_expression_node() = default;
4441+
4442+
alternative_node::~alternative_node() = default;
4443+
4444+
iteration_statement_node::~iteration_statement_node() = default;
4445+
4446+
template_argument::~template_argument() = default;
4447+
4448+
inspect_expression_node::~inspect_expression_node() = default;
4449+
4450+
statement_node::~statement_node() = default;
43924451

43934452
//-----------------------------------------------------------------------
43944453
//

0 commit comments

Comments
 (0)