Skip to content

Commit b8276a5

Browse files
committed
Update interface of destructor_treet::add to add a declaration
Because this will be needed later for entering a scope via a C front end goto statement. The declaration is optional because it is only needed for named front end declarations. It is not needed for anonymous symbols which cannot be referenced by user code.
1 parent 42225bc commit b8276a5

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

src/goto-programs/destructor_tree.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
#include "destructor_tree.h"
1010

11-
void destructor_treet::add(const codet &destructor)
11+
void destructor_treet::add(
12+
const codet &destructor,
13+
std::optional<goto_programt::targett> declaration)
1214
{
1315
auto previous_node = get_current_node();
1416
auto new_node = destruction_graph.add_node(destructor);

src/goto-programs/destructor_tree.h

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <util/graph.h>
1313
#include <util/std_code_base.h>
1414

15+
#include <goto-programs/goto_program.h>
16+
1517
typedef std::size_t node_indext;
1618

1719
/// Result of an attempt to find ancestor information about two nodes. Holds
@@ -94,9 +96,13 @@ class destructor_treet
9496
this->destruction_graph.add_node();
9597
}
9698

97-
/// Adds a destructor to the current stack, attaching itself to the
98-
/// current node.
99-
void add(const codet &destructor);
99+
/// Adds a destructor/declaration pair to the current stack, attaching it to
100+
/// the current node.
101+
/// \param destructor Code which is called when the current scope is left.
102+
/// \param declaration Instruction which causes the scope to be entered.
103+
void add(
104+
const codet &destructor,
105+
std::optional<goto_programt::targett> declaration);
100106

101107
/// Fetches the destructor value for the passed-in node index.
102108
optionalt<codet> &get_destructor(node_indext index);

src/goto-programs/goto_clean_expr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ symbol_exprt goto_convertt::make_compound_literal(
5353
if(!new_symbol.is_static_lifetime)
5454
{
5555
code_deadt code_dead(result);
56-
targets.destructor_stack.add(std::move(code_dead));
56+
targets.destructor_stack.add(std::move(code_dead), {});
5757
}
5858

5959
return result;

src/goto-programs/goto_convert.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ void goto_convertt::convert_frontend_decl(
653653

654654
{
655655
code_deadt code_dead(symbol_expr);
656-
targets.destructor_stack.add(code_dead);
656+
targets.destructor_stack.add(code_dead, {});
657657
}
658658

659659
// do destructor
@@ -665,7 +665,7 @@ void goto_convertt::convert_frontend_decl(
665665
address_of_exprt this_expr(symbol_expr, pointer_type(symbol.type));
666666
destructor.arguments().push_back(this_expr);
667667

668-
targets.destructor_stack.add(destructor);
668+
targets.destructor_stack.add(destructor, {});
669669
}
670670
}
671671

src/goto-programs/goto_convert_exceptions.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void goto_convertt::convert_msc_try_finally(
3434

3535
// first put 'finally' code onto destructor stack
3636
node_indext old_stack_top = targets.destructor_stack.get_current_node();
37-
targets.destructor_stack.add(to_code(code.op1()));
37+
targets.destructor_stack.add(to_code(code.op1()), {});
3838

3939
// do 'try' code
4040
convert(to_code(code.op0()), dest, mode);
@@ -166,7 +166,7 @@ void goto_convertt::convert_CPROVER_try_catch(
166166

167167
// Store the point before the temp catch code.
168168
node_indext old_stack_top = targets.destructor_stack.get_current_node();
169-
targets.destructor_stack.add(catch_code);
169+
targets.destructor_stack.add(catch_code, {});
170170

171171
// now convert 'try' code
172172
convert(to_code(code.op0()), dest, mode);
@@ -221,7 +221,7 @@ void goto_convertt::convert_CPROVER_try_finally(
221221

222222
// first put 'finally' code onto destructor stack
223223
node_indext old_stack_top = targets.destructor_stack.get_current_node();
224-
targets.destructor_stack.add(to_code(code.op1()));
224+
targets.destructor_stack.add(to_code(code.op1()), {});
225225

226226
// do 'try' code
227227
convert(to_code(code.op0()), dest, mode);

0 commit comments

Comments
 (0)