Skip to content

Commit 4d8aa45

Browse files
committed
Use std::string(N, ' ') instead of static locals
Visual Studio complains about them not being thread-safe. The complaint is pointless here, but also there is no need for those static locals.
1 parent 8187bdd commit 4d8aa45

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
@@ -987,42 +987,41 @@ static exprt get_char_array_and_concretize(
987987
const array_string_exprt &arr)
988988
{
989989
const auto &eom = messaget::eom;
990-
static const std::string indent(" ");
991990
stream << "- " << format(arr) << ":\n";
992-
stream << indent << indent << "- type: " << format(arr.type()) << eom;
991+
stream << std::string(4, ' ') << "- type: " << format(arr.type()) << eom;
993992
const auto arr_model_opt =
994993
get_array(super_get, ns, max_string_length, stream, arr);
995994
if(arr_model_opt)
996995
{
997-
stream << indent << indent << "- char_array: " << format(*arr_model_opt)
996+
stream << std::string(4, ' ') << "- char_array: " << format(*arr_model_opt)
998997
<< '\n';
999-
stream << indent << indent << "- type : " << format(arr_model_opt->type())
998+
stream << std::string(4, ' ') << "- type : " << format(arr_model_opt->type())
1000999
<< eom;
10011000
const exprt simple = simplify_expr(*arr_model_opt, ns);
1002-
stream << indent << indent << "- simplified_char_array: " << format(simple)
1001+
stream << std::string(4, ' ') << "- simplified_char_array: " << format(simple)
10031002
<< eom;
10041003
if(
10051004
const auto concretized_array = get_array(
10061005
super_get, ns, max_string_length, stream, to_array_string_expr(simple)))
10071006
{
1008-
stream << indent << indent
1007+
stream << std::string(4, ' ')
10091008
<< "- concretized_char_array: " << format(*concretized_array)
10101009
<< eom;
10111010

10121011
if(
10131012
const auto array_expr =
10141013
expr_try_dynamic_cast<array_exprt>(*concretized_array))
10151014
{
1016-
stream << indent << indent << "- as_string: \""
1015+
stream << std::string(4, ' ') << "- as_string: \""
10171016
<< string_of_array(*array_expr) << "\"\n";
10181017
}
10191018
else
1020-
stream << indent << "- warning: not an array" << eom;
1019+
stream << std::string(2, ' ') << "- warning: not an array" << eom;
10211020
return *concretized_array;
10221021
}
10231022
return simple;
10241023
}
1025-
stream << indent << indent << "- incomplete model" << eom;
1024+
stream << std::string(4, ' ') << "- incomplete model" << eom;
10261025
return arr;
10271026
}
10281027

@@ -1037,8 +1036,6 @@ void debug_model(
10371036
const std::vector<symbol_exprt> &boolean_symbols,
10381037
const std::vector<symbol_exprt> &index_symbols)
10391038
{
1040-
static const std::string indent(" ");
1041-
10421039
stream << "debug_model:" << '\n';
10431040
for(const auto &pointer_array : generator.array_pool.get_arrays_of_pointers())
10441041
{
@@ -1047,8 +1044,8 @@ void debug_model(
10471044
super_get, ns, max_string_length, stream, arr);
10481045

10491046
stream << "- " << format(arr) << ":\n"
1050-
<< indent << "- pointer: " << format(pointer_array.first) << "\n"
1051-
<< indent << "- model: " << format(model) << messaget::eom;
1047+
<< " - pointer: " << format(pointer_array.first) << "\n"
1048+
<< " - model: " << format(model) << messaget::eom;
10521049
}
10531050

10541051
for(const auto &symbol : boolean_symbols)
@@ -1249,16 +1246,15 @@ static void debug_check_axioms_step(
12491246
const exprt &negaxiom,
12501247
const exprt &with_concretized_arrays)
12511248
{
1252-
static const std::string indent = " ";
1253-
static const std::string indent2 = " ";
1254-
stream << indent2 << "- axiom:\n" << indent2 << indent;
1249+
stream << std::string(4, ' ') << "- axiom:\n" << std::string(6, ' ');
12551250
stream << to_string(axiom);
1256-
stream << '\n' << indent2 << "- axiom_in_model:\n" << indent2 << indent;
1251+
stream << '\n' << std::string(4, ' ') << "- axiom_in_model:\n"
1252+
<< std::string(6, ' ');
12571253
stream << to_string(axiom_in_model) << '\n'
1258-
<< indent2 << "- negated_axiom:\n"
1259-
<< indent2 << indent << format(negaxiom) << '\n';
1260-
stream << indent2 << "- negated_axiom_with_concretized_arrays:\n"
1261-
<< indent2 << indent << format(with_concretized_arrays) << '\n';
1254+
<< std::string(4, ' ') << "- negated_axiom:\n"
1255+
<< std::string(6, ' ') << format(negaxiom) << '\n';
1256+
stream << std::string(4, ' ') << "- negated_axiom_with_concretized_arrays:\n"
1257+
<< std::string(6, ' ') << format(with_concretized_arrays) << '\n';
12621258
}
12631259

12641260
/// \return true if the current model satisfies all the axioms
@@ -1275,8 +1271,6 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
12751271
const union_find_replacet &symbol_resolve)
12761272
{
12771273
const auto eom=messaget::eom;
1278-
static const std::string indent = " ";
1279-
static const std::string indent2 = " ";
12801274
// clang-format off
12811275
const auto gen_symbol = [&](const irep_idt &id, const typet &type)
12821276
{
@@ -1320,7 +1314,7 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
13201314
exprt negaxiom = axiom_in_model.negation();
13211315
negaxiom = simplify_expr(negaxiom, ns);
13221316

1323-
stream << indent << i << ".\n";
1317+
stream << std::string(2, ' ') << i << ".\n";
13241318
const exprt with_concretized_arrays =
13251319
substitute_array_access(negaxiom, gen_symbol, true);
13261320
debug_check_axioms_step(
@@ -1330,12 +1324,12 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
13301324
const auto &witness =
13311325
find_counter_example(ns, ui, with_concretized_arrays, axiom.univ_var))
13321326
{
1333-
stream << indent2 << "- violated_for: " << format(axiom.univ_var) << "="
1334-
<< format(*witness) << eom;
1327+
stream << std::string(4, ' ') << "- violated_for: "
1328+
<< format(axiom.univ_var) << "=" << format(*witness) << eom;
13351329
violated[i]=*witness;
13361330
}
13371331
else
1338-
stream << indent2 << "- correct" << eom;
1332+
stream << std::string(4, ' ') << "- correct" << eom;
13391333
}
13401334

13411335
// Maps from indexes of violated not_contains axiom to a witness of violation
@@ -1352,16 +1346,16 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
13521346
nc_axiom, univ_var, [&](const exprt &expr) {
13531347
return simplify_expr(get(expr), ns); });
13541348

1355-
stream << indent << i << ".\n";
1349+
stream << std::string(2, ' ') << i << ".\n";
13561350
debug_check_axioms_step(
13571351
stream, ns, nc_axiom, nc_axiom, negated_axiom, negated_axiom);
13581352

13591353
if(
13601354
const auto witness =
13611355
find_counter_example(ns, ui, negated_axiom, univ_var))
13621356
{
1363-
stream << indent2 << "- violated_for: " << univ_var.get_identifier()
1364-
<< "=" << format(*witness) << eom;
1357+
stream << std::string(4, ' ') << "- violated_for: "
1358+
<< univ_var.get_identifier() << "=" << format(*witness) << eom;
13651359
violated_not_contains[i]=*witness;
13661360
}
13671361
}

0 commit comments

Comments
 (0)