Skip to content

Commit ad5764c

Browse files
committed
Remove default arguments from abstract_environmentt::abstract_object_factory
Default arguments on a virtual function aren't safe. Even through this function isn't overriden anywhere now, it's a latent bug waiting for the future.
1 parent db5ea6d commit ad5764c

8 files changed

+15
-15
lines changed

src/analyses/variable-sensitivity/abstract_environment.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ abstract_environmentt::eval(const exprt &expr, const namespacet &ns) const
7474
{
7575
// It is important that this is top as the abstract object may not know
7676
// how to handle the expression
77-
return abstract_object_factory(simplified_expr.type(), ns, true);
77+
return abstract_object_factory(simplified_expr.type(), ns, true, false);
7878
}
7979
}
8080

@@ -389,7 +389,7 @@ abstract_object_pointert abstract_environmentt::eval_expression(
389389
// The value of the temporary abstract object is ignored, its
390390
// purpose is just to dispatch the expression transform call to
391391
// a concrete subtype of abstract_objectt.
392-
auto eval_obj = abstract_object_factory(e.type(), ns, true);
392+
auto eval_obj = abstract_object_factory(e.type(), ns, true, false);
393393
auto operands = eval_operands(e, *this, ns);
394394

395395
return eval_obj->expression_transform(e, operands, *this, ns);

src/analyses/variable-sensitivity/abstract_environment.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ class abstract_environmentt
150150
virtual abstract_object_pointert abstract_object_factory(
151151
const typet &type,
152152
const namespacet &ns,
153-
bool top = true,
154-
bool bottom = false) const;
153+
bool top,
154+
bool bottom) const;
155155

156156
/// For converting constants in the program
157157
///

src/analyses/variable-sensitivity/abstract_object.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ abstract_object_pointert abstract_objectt::expression_transform(
129129

130130
if(const_op.is_nil())
131131
{
132-
return environment.abstract_object_factory(copy.type(), ns, true);
132+
return environment.abstract_object_factory(copy.type(), ns, true, false);
133133
}
134134
}
135135

@@ -144,7 +144,7 @@ abstract_object_pointert abstract_objectt::write(
144144
const abstract_object_pointert &value,
145145
bool merging_write) const
146146
{
147-
return environment.abstract_object_factory(type(), ns, true);
147+
return environment.abstract_object_factory(type(), ns, true, false);
148148
}
149149

150150
bool abstract_objectt::is_top() const

src/analyses/variable-sensitivity/constant_abstract_value.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ constant_abstract_valuet::try_transform_expr_with_all_rounding_modes(
159159
auto current = possible_result->to_constant();
160160
if(current.is_nil() || current != first)
161161
{
162-
return environment.abstract_object_factory(expr.type(), ns);
162+
return environment.abstract_object_factory(expr.type(), ns, true, false);
163163
}
164164
}
165165
return possible_results.front();

src/analyses/variable-sensitivity/full_array_abstract_object.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ abstract_object_pointert full_array_abstract_objectt::read_component(
168168
const namespacet &ns) const
169169
{
170170
if(is_top())
171-
return environment.abstract_object_factory(expr.type(), ns, true);
171+
return environment.abstract_object_factory(expr.type(), ns, true, false);
172172

173173
auto read_element_fn =
174174
[this, &environment, &ns](const index_exprt &index_expr) {

src/analyses/variable-sensitivity/full_struct_abstract_object.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ abstract_object_pointert full_struct_abstract_objectt::read_component(
8383

8484
if(is_top())
8585
{
86-
return environment.abstract_object_factory(expr.type(), ns, true);
86+
return environment.abstract_object_factory(expr.type(), ns, true, false);
8787
}
8888
else
8989
{
@@ -100,7 +100,7 @@ abstract_object_pointert full_struct_abstract_objectt::read_component(
100100
}
101101
else
102102
{
103-
return environment.abstract_object_factory(member_expr.type(), ns, true);
103+
return environment.abstract_object_factory(member_expr.type(), ns, true, false);
104104
}
105105
}
106106
}

src/analyses/variable-sensitivity/interval_abstract_value.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ abstract_object_pointert interval_abstract_valuet::expression_transform(
304304
if(op_as_constant.is_nil())
305305
{
306306
auto top_object =
307-
environment.abstract_object_factory(expr.type(), ns, true);
307+
environment.abstract_object_factory(expr.type(), ns, true, false);
308308
auto top_context_object =
309309
std::dynamic_pointer_cast<const context_abstract_objectt>(
310310
top_object);
@@ -340,7 +340,7 @@ abstract_object_pointert interval_abstract_valuet::expression_transform(
340340
}
341341

342342
if(num_operands == 0)
343-
return environment.abstract_object_factory(expr.type(), ns, true);
343+
return environment.abstract_object_factory(expr.type(), ns, true, false);
344344

345345
if(expr.id() == ID_if)
346346
return evaluate_conditional(expr, interval_operands, environment, ns);

src/analyses/variable-sensitivity/variable_sensitivity_domain.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void variable_sensitivity_domaint::transform(
4646
abstract_object_pointert top_object =
4747
abstract_state
4848
.abstract_object_factory(
49-
to_code_decl(instruction.code).symbol().type(), ns, true)
49+
to_code_decl(instruction.code).symbol().type(), ns, true, false)
5050
->update_location_context(write_location, true);
5151
abstract_state.assign(
5252
to_code_decl(instruction.code).symbol(), top_object, ns);
@@ -318,7 +318,7 @@ void variable_sensitivity_domaint::transform_function_call(
318318
std::stack<exprt>(),
319319
nil_exprt(),
320320
abstract_state.abstract_object_factory(
321-
called_arg.type().subtype(), ns, true),
321+
called_arg.type().subtype(), ns, true, false),
322322
false);
323323
}
324324
}
@@ -331,7 +331,7 @@ void variable_sensitivity_domaint::transform_function_call(
331331
abstract_state.assign(
332332
symbol_exprt(symbol.first, symbol.second.type),
333333
abstract_state.abstract_object_factory(
334-
symbol.second.type, ns, true),
334+
symbol.second.type, ns, true, false),
335335
ns);
336336
}
337337
}

0 commit comments

Comments
 (0)