Skip to content

Commit 67b36f0

Browse files
authored
Merge pull request #5737 from diffblue/mathematical_function_applicationt
helper for getting the function type used in function_application_exprt
2 parents 5cac14f + 25ed1d7 commit 67b36f0

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

src/goto-symex/goto_symex.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ void goto_symext::constant_propagate_empty_string(
382382
symex_assignt &symex_assign,
383383
const function_application_exprt &f_l1)
384384
{
385-
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
385+
const auto &f_type = f_l1.function_type();
386386
const auto &length_type = f_type.domain().at(0);
387387
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();
388388

@@ -410,7 +410,7 @@ bool goto_symext::constant_propagate_string_concat(
410410
symex_assignt &symex_assign,
411411
const function_application_exprt &f_l1)
412412
{
413-
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
413+
const auto &f_type = f_l1.function_type();
414414
const auto &length_type = f_type.domain().at(0);
415415
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();
416416

@@ -465,7 +465,7 @@ bool goto_symext::constant_propagate_string_substring(
465465
PRECONDITION(num_operands >= 4);
466466
PRECONDITION(num_operands <= 5);
467467

468-
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
468+
const auto &f_type = f_l1.function_type();
469469
const auto &length_type = f_type.domain().at(0);
470470
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();
471471

@@ -557,7 +557,7 @@ bool goto_symext::constant_propagate_integer_to_string(
557557
PRECONDITION(num_operands >= 3);
558558
PRECONDITION(num_operands <= 4);
559559

560-
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
560+
const auto &f_type = f_l1.function_type();
561561
const auto &length_type = f_type.domain().at(0);
562562
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();
563563

@@ -633,7 +633,7 @@ bool goto_symext::constant_propagate_delete_char_at(
633633
// - index of char to delete
634634
PRECONDITION(f_l1.arguments().size() == 4);
635635

636-
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
636+
const auto &f_type = f_l1.function_type();
637637
const auto &length_type = f_type.domain().at(0);
638638
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();
639639

@@ -707,7 +707,7 @@ bool goto_symext::constant_propagate_delete(
707707
// - index of end of substring to delete (exclusive)
708708
PRECONDITION(f_l1.arguments().size() == 5);
709709

710-
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
710+
const auto &f_type = f_l1.function_type();
711711
const auto &length_type = f_type.domain().at(0);
712712
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();
713713

@@ -800,7 +800,7 @@ bool goto_symext::constant_propagate_set_length(
800800
// - new length of the string
801801
PRECONDITION(f_l1.arguments().size() == 4);
802802

803-
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
803+
const auto &f_type = f_l1.function_type();
804804
const auto &length_type = f_type.domain().at(0);
805805
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();
806806

@@ -882,7 +882,7 @@ bool goto_symext::constant_propagate_set_char_at(
882882
// - new char
883883
PRECONDITION(f_l1.arguments().size() == 5);
884884

885-
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
885+
const auto &f_type = f_l1.function_type();
886886
const auto &length_type = f_type.domain().at(0);
887887
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();
888888

@@ -945,7 +945,7 @@ bool goto_symext::constant_propagate_case_change(
945945
const function_application_exprt &f_l1,
946946
bool to_upper)
947947
{
948-
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
948+
const auto &f_type = f_l1.function_type();
949949
const auto &length_type = f_type.domain().at(0);
950950
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();
951951

@@ -1006,7 +1006,7 @@ bool goto_symext::constant_propagate_replace(
10061006
symex_assignt &symex_assign,
10071007
const function_application_exprt &f_l1)
10081008
{
1009-
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
1009+
const auto &f_type = f_l1.function_type();
10101010
const auto &length_type = f_type.domain().at(0);
10111011
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();
10121012

@@ -1114,7 +1114,7 @@ bool goto_symext::constant_propagate_trim(
11141114
symex_assignt &symex_assign,
11151115
const function_application_exprt &f_l1)
11161116
{
1117-
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
1117+
const auto &f_type = f_l1.function_type();
11181118
const auto &length_type = f_type.domain().at(0);
11191119
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();
11201120

src/util/mathematical_expr.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ function_application_exprt::function_application_exprt(
1818
tuple_exprt(std::move(_arguments)),
1919
to_mathematical_function_type(_function.type()).codomain())
2020
{
21-
const auto &domain = to_mathematical_function_type(_function.type()).domain();
21+
const auto &domain = function_type().domain();
2222
PRECONDITION(domain.size() == arguments().size());
2323
}
24+
25+
const mathematical_function_typet &
26+
function_application_exprt::function_type() const
27+
{
28+
return to_mathematical_function_type(function().type());
29+
}

src/util/mathematical_expr.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,16 @@ class tuple_exprt : public multi_ary_exprt
186186
}
187187
};
188188

189+
class mathematical_function_typet;
190+
189191
/// \brief Application of (mathematical) function
190192
class function_application_exprt : public binary_exprt
191193
{
192194
public:
193195
using argumentst = exprt::operandst;
194196

197+
/// \param _function must be known to have \ref mathematical_function_typet type.
198+
/// \param _arguments must match function_type().domain()
195199
function_application_exprt(const exprt &_function, argumentst _arguments);
196200

197201
exprt &function()
@@ -204,6 +208,9 @@ class function_application_exprt : public binary_exprt
204208
return op0();
205209
}
206210

211+
/// This helper method provides the type of the expression returned by \ref function.
212+
const mathematical_function_typet &function_type() const;
213+
207214
argumentst &arguments()
208215
{
209216
return op1().operands();

0 commit comments

Comments
 (0)