17 const exprt &return_code,
18 const std::vector<exprt> &fun_args,
22 PRECONDITION(fun_args.size() >= 4 && fun_args.size() <= 6);
23 const auto arg1 = expr_checked_cast<struct_exprt>(fun_args[2]);
25 const auto arg2 = expr_checked_cast<struct_exprt>(fun_args[3]);
28 args.insert(
args.end(), fun_args.begin() + 4, fun_args.end());
52 std::pair<exprt, string_constraintst>
57 const exprt &start_index,
58 const exprt &end_index)
61 const typet &index_type = start_index.
type();
120 if_exprt(overflow, max_int, res_length));
159 std::pair<exprt, string_constraintst>
174 std::pair<exprt, string_constraintst>
183 const typet &index_type =
s1.length_type();
192 const std::vector<mp_integer> &input1_value,
193 const std::vector<mp_integer> &input2_value,
194 const std::vector<mp_integer> &args_value)
const
196 const auto start_index =
197 args_value.size() > 0 && args_value[0] > 0 ? args_value[0] :
mp_integer(0);
198 const mp_integer input2_size(input2_value.size());
199 const auto end_index =
200 args_value.size() > 1
201 ? std::max(std::min(args_value[1], input2_size), start_index)
204 std::vector<mp_integer> eval_result(input1_value);
207 input2_value.begin() + numeric_cast_v<std::size_t>(start_index),
208 input2_value.begin() + numeric_cast_v<std::size_t>(end_index));
217 auto pair = [&]() -> std::pair<exprt, string_constraintst> {
array_string_exprt get_string_expr(array_poolt &array_pool, const exprt &expr)
Fetch the string_exprt corresponding to the given refined_string_exprt.
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
bitvector_typet char_type()
Correspondance between arrays and pointers string representations.
exprt get_or_create_length(const array_string_exprt &s)
Get the length of an array_string_exprt from the array_pool.
array_string_exprt fresh_string(const typet &index_type, const typet &char_type)
Construct a string expression whose length and content are new variables.
array_string_exprt find(const exprt &pointer, const exprt &length)
Creates a new array if the pointer is not pointing to an array.
const typet & length_type() const
Base class for all expressions.
typet & type()
Return the type of the expression.
Application of (mathematical) function.
The trinary if-then-else operator.
constant_exprt largest_expr() const
Return an expression representing the largest value of this type.
const irep_idt & id() const
The plus expression Associativity is not specified.
string_constraintst constraints(string_constraint_generatort &generator, message_handlert &message_handler) const override
Add constraints ensuring that the value of result expression of the builtin function corresponds to t...
string_concatenation_builtin_functiont(const exprt &return_code, const std::vector< exprt > &fun_args, array_poolt &array_pool)
Constructor from arguments of a function application.
std::vector< mp_integer > eval(const std::vector< mp_integer > &input1_value, const std::vector< mp_integer > &input2_value, const std::vector< mp_integer > &args_value) const override
Evaluate the result from a concrete valuation of the arguments.
exprt length_constraint() const override
Constraint ensuring that the length of the strings are coherent with the function call.
std::pair< exprt, string_constraintst > add_axioms_for_concat(const array_string_exprt &res, const array_string_exprt &s1, const array_string_exprt &s2)
Add axioms enforcing that res is equal to the concatenation of s1 and s2.
std::pair< exprt, string_constraintst > add_axioms_for_concat_substr(const array_string_exprt &res, const array_string_exprt &s1, const array_string_exprt &s2, const exprt &start_index, const exprt &end_index)
Add axioms enforcing that res is the concatenation of s1 with the substring of s2 starting at index ‘...
message_handlert & message_handler
std::pair< exprt, string_constraintst > add_axioms_for_code_point(const array_string_exprt &res, const exprt &code_point)
add axioms for the conversion of an integer representing a java code point to a utf-16 string
symbol_generatort fresh_symbol
std::pair< exprt, string_constraintst > add_axioms_for_concat_code_point(const function_application_exprt &f)
Add axioms corresponding to the StringBuilder.appendCodePoint(I) function.
std::pair< exprt, string_constraintst > combine_results(std::pair< exprt, string_constraintst > result1, std::pair< exprt, string_constraintst > result2)
Combine the results of two add_axioms function by taking the maximum of the return codes and merging ...
String inserting a string into another one.
array_string_exprt input1
array_string_exprt result
array_string_exprt input2
std::vector< exprt > args
Expression to hold a symbol (variable)
const typet & subtype() const
The type of an expression, extends irept.
#define UNREACHABLE
This should be used to mark dead code.
#define PRECONDITION(CONDITION)
exprt length_constraint_for_concat(const array_string_exprt &res, const array_string_exprt &s1, const array_string_exprt &s2, array_poolt &array_pool)
Add axioms enforcing that the length of res is that of the concatenation of s1 with s2
exprt length_constraint_for_concat_char(const array_string_exprt &res, const array_string_exprt &s1, array_poolt &array_pool)
Add axioms enforcing that the length of res is that of the concatenation of s1 with.
exprt length_constraint_for_concat_substr(const array_string_exprt &res, const array_string_exprt &s1, const array_string_exprt &s2, const exprt &start, const exprt &end, array_poolt &array_pool)
Add axioms enforcing that the length of res is that of the concatenation of s1 with the substring of ...
Builtin functions for string concatenations.
exprt sum_overflows(const plus_exprt &sum)
exprt maximum(const exprt &a, const exprt &b)
exprt minimum(const exprt &a, const exprt &b)
exprt zero_if_negative(const exprt &expr)
Returns a non-negative version of the argument.
signedbv_typet get_return_code_type()
Collection of constraints of different types: existential formulas, universal formulas,...
std::vector< exprt > existential
std::vector< string_constraintt > universal
const type_with_subtypet & to_type_with_subtype(const typet &type)