Skip to content

Commit 26e895d

Browse files
Distinguish strings and char arrays in get
This is done by looking at which arrays were associted to pointers in the generator.
1 parent 4b8a421 commit 26e895d

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

src/solvers/refinement/string_refinement.cpp

+26-10
Original file line numberDiff line numberDiff line change
@@ -733,16 +733,6 @@ static optionalt<exprt> get_array(
733733
ret.move_to_operands(arr_val.operands()[i]);
734734
return ret;
735735
}
736-
else if(arr_val.id() == ID_symbol)
737-
{
738-
stream << "(sr::get_array) warning: symbol "
739-
<< to_symbol_expr(arr_val).get_identifier()
740-
<< " not found by super_get" << eom;
741-
// `super_get` does not know anything about this array so we make one up
742-
for(size_t i = 0; i < n; i++)
743-
ret.copy_to_operands(exprt(ID_unknown, arr_val.type().subtype()));
744-
return ret;
745-
}
746736
else
747737
return {};
748738
}
@@ -1954,6 +1944,32 @@ exprt string_refinementt::get(const exprt &expr) const
19541944
arr_model, generator.max_string_length, ns);
19551945
return concretized_array;
19561946
}
1947+
else
1948+
{
1949+
const auto &arr_of_ptr = generator.get_arrays_of_pointers();
1950+
const auto arr_in_arr_of_ptr = std::find_if(
1951+
arr_of_ptr.begin(),
1952+
arr_of_ptr.end(),
1953+
[arr](std::pair<exprt, array_string_exprt> pair) {
1954+
return pair.second == arr;
1955+
});
1956+
1957+
if(arr_in_arr_of_ptr != arr_of_ptr.end())
1958+
{
1959+
exprt length = super_get(arr.length());
1960+
if(const auto n = expr_cast<std::size_t>(length))
1961+
{
1962+
exprt arr_model =
1963+
array_exprt(array_typet(arr.type().subtype(), length));
1964+
for(size_t i = 0; i < *n; i++)
1965+
arr_model.copy_to_operands(exprt(ID_unknown, arr.type().subtype()));
1966+
const exprt concretized_array = concretize_arrays_in_expression(
1967+
arr_model, generator.max_string_length, ns);
1968+
return concretized_array;
1969+
}
1970+
}
1971+
return arr;
1972+
}
19571973
}
19581974
return supert::get(ecopy);
19591975
}

0 commit comments

Comments
 (0)