Skip to content

Commit de65ec6

Browse files
authored
Merge pull request #2541 from tautschnig/vs-string-static
Use std::string(N, ' ') instead of static locals
2 parents 7c4b5aa + 4d8aa45 commit de65ec6

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

src/solvers/refinement/string_refinement.cpp

+24-30
Original file line numberDiff line numberDiff line change
@@ -972,42 +972,41 @@ static exprt get_char_array_and_concretize(
972972
const array_string_exprt &arr)
973973
{
974974
const auto &eom = messaget::eom;
975-
static const std::string indent(" ");
976975
stream << "- " << format(arr) << ":\n";
977-
stream << indent << indent << "- type: " << format(arr.type()) << eom;
976+
stream << std::string(4, ' ') << "- type: " << format(arr.type()) << eom;
978977
const auto arr_model_opt =
979978
get_array(super_get, ns, stream, arr);
980979
if(arr_model_opt)
981980
{
982-
stream << indent << indent << "- char_array: " << format(*arr_model_opt)
981+
stream << std::string(4, ' ') << "- char_array: " << format(*arr_model_opt)
983982
<< '\n';
984-
stream << indent << indent << "- type : " << format(arr_model_opt->type())
983+
stream << std::string(4, ' ') << "- type : " << format(arr_model_opt->type())
985984
<< eom;
986985
const exprt simple = simplify_expr(*arr_model_opt, ns);
987-
stream << indent << indent << "- simplified_char_array: " << format(simple)
986+
stream << std::string(4, ' ') << "- simplified_char_array: " << format(simple)
988987
<< eom;
989988
if(
990989
const auto concretized_array = get_array(
991990
super_get, ns, stream, to_array_string_expr(simple)))
992991
{
993-
stream << indent << indent
992+
stream << std::string(4, ' ')
994993
<< "- concretized_char_array: " << format(*concretized_array)
995994
<< eom;
996995

997996
if(
998997
const auto array_expr =
999998
expr_try_dynamic_cast<array_exprt>(*concretized_array))
1000999
{
1001-
stream << indent << indent << "- as_string: \""
1000+
stream << std::string(4, ' ') << "- as_string: \""
10021001
<< string_of_array(*array_expr) << "\"\n";
10031002
}
10041003
else
1005-
stream << indent << "- warning: not an array" << eom;
1004+
stream << std::string(2, ' ') << "- warning: not an array" << eom;
10061005
return *concretized_array;
10071006
}
10081007
return simple;
10091008
}
1010-
stream << indent << indent << "- incomplete model" << eom;
1009+
stream << std::string(4, ' ') << "- incomplete model" << eom;
10111010
return arr;
10121011
}
10131012

@@ -1021,8 +1020,6 @@ void debug_model(
10211020
const std::vector<symbol_exprt> &boolean_symbols,
10221021
const std::vector<symbol_exprt> &index_symbols)
10231022
{
1024-
static const std::string indent(" ");
1025-
10261023
stream << "debug_model:" << '\n';
10271024
for(const auto &pointer_array : generator.array_pool.get_arrays_of_pointers())
10281025
{
@@ -1031,8 +1028,8 @@ void debug_model(
10311028
super_get, ns, stream, arr);
10321029

10331030
stream << "- " << format(arr) << ":\n"
1034-
<< indent << "- pointer: " << format(pointer_array.first) << "\n"
1035-
<< indent << "- model: " << format(model) << messaget::eom;
1031+
<< " - pointer: " << format(pointer_array.first) << "\n"
1032+
<< " - model: " << format(model) << messaget::eom;
10361033
}
10371034

10381035
for(const auto &symbol : boolean_symbols)
@@ -1232,16 +1229,15 @@ static void debug_check_axioms_step(
12321229
const exprt &negaxiom,
12331230
const exprt &with_concretized_arrays)
12341231
{
1235-
static const std::string indent = " ";
1236-
static const std::string indent2 = " ";
1237-
stream << indent2 << "- axiom:\n" << indent2 << indent;
1232+
stream << std::string(4, ' ') << "- axiom:\n" << std::string(6, ' ');
12381233
stream << to_string(axiom);
1239-
stream << '\n' << indent2 << "- axiom_in_model:\n" << indent2 << indent;
1234+
stream << '\n' << std::string(4, ' ') << "- axiom_in_model:\n"
1235+
<< std::string(6, ' ');
12401236
stream << to_string(axiom_in_model) << '\n'
1241-
<< indent2 << "- negated_axiom:\n"
1242-
<< indent2 << indent << format(negaxiom) << '\n';
1243-
stream << indent2 << "- negated_axiom_with_concretized_arrays:\n"
1244-
<< indent2 << indent << format(with_concretized_arrays) << '\n';
1237+
<< std::string(4, ' ') << "- negated_axiom:\n"
1238+
<< std::string(6, ' ') << format(negaxiom) << '\n';
1239+
stream << std::string(4, ' ') << "- negated_axiom_with_concretized_arrays:\n"
1240+
<< std::string(6, ' ') << format(with_concretized_arrays) << '\n';
12451241
}
12461242

12471243
/// \return true if the current model satisfies all the axioms
@@ -1256,8 +1252,6 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
12561252
const union_find_replacet &symbol_resolve)
12571253
{
12581254
const auto eom=messaget::eom;
1259-
static const std::string indent = " ";
1260-
static const std::string indent2 = " ";
12611255
// clang-format off
12621256
const auto gen_symbol = [&](const irep_idt &id, const typet &type)
12631257
{
@@ -1300,7 +1294,7 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
13001294
exprt negaxiom = axiom_in_model.negation();
13011295
negaxiom = simplify_expr(negaxiom, ns);
13021296

1303-
stream << indent << i << ".\n";
1297+
stream << std::string(2, ' ') << i << ".\n";
13041298
const exprt with_concretized_arrays =
13051299
substitute_array_access(negaxiom, gen_symbol, true);
13061300
debug_check_axioms_step(
@@ -1310,12 +1304,12 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
13101304
const auto &witness =
13111305
find_counter_example(ns, with_concretized_arrays, axiom.univ_var))
13121306
{
1313-
stream << indent2 << "- violated_for: " << format(axiom.univ_var) << "="
1314-
<< format(*witness) << eom;
1307+
stream << std::string(4, ' ') << "- violated_for: "
1308+
<< format(axiom.univ_var) << "=" << format(*witness) << eom;
13151309
violated[i]=*witness;
13161310
}
13171311
else
1318-
stream << indent2 << "- correct" << eom;
1312+
stream << std::string(4, ' ') << "- correct" << eom;
13191313
}
13201314

13211315
// Maps from indexes of violated not_contains axiom to a witness of violation
@@ -1332,16 +1326,16 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
13321326
nc_axiom, univ_var, [&](const exprt &expr) {
13331327
return simplify_expr(get(expr), ns); });
13341328

1335-
stream << indent << i << ".\n";
1329+
stream << std::string(2, ' ') << i << ".\n";
13361330
debug_check_axioms_step(
13371331
stream, nc_axiom, nc_axiom, negated_axiom, negated_axiom);
13381332

13391333
if(
13401334
const auto witness =
13411335
find_counter_example(ns, negated_axiom, univ_var))
13421336
{
1343-
stream << indent2 << "- violated_for: " << univ_var.get_identifier()
1344-
<< "=" << format(*witness) << eom;
1337+
stream << std::string(4, ' ') << "- violated_for: "
1338+
<< univ_var.get_identifier() << "=" << format(*witness) << eom;
13451339
violated_not_contains[i]=*witness;
13461340
}
13471341
}

0 commit comments

Comments
 (0)