Skip to content

Commit ab2a26c

Browse files
authored
Merge pull request #7999 from NlightNFotis/cleanup_string_constantt
Refactor `string_constantt::get_value` and `string_constantt::set_value` call sites.
2 parents 032a284 + db61a6a commit ab2a26c

19 files changed

+30
-34
lines changed

src/analyses/custom_bitvector_analysis.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ unsigned custom_bitvector_analysist::get_bit_nr(
184184
else if(string_expr.id()==ID_index)
185185
return get_bit_nr(to_index_expr(string_expr).array());
186186
else if(string_expr.id()==ID_string_constant)
187-
return bits.number(to_string_constant(string_expr).get_value());
187+
return bits.number(to_string_constant(string_expr).value());
188188
else
189189
return bits.number("(unknown)");
190190
}

src/ansi-c/ansi_c_convert_type.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ void ansi_c_convert_typet::read_rec(const typet &type)
4444
!type_with_subtypes.subtypes().empty() &&
4545
type_with_subtypes.subtypes()[0].id() == ID_string_constant)
4646
c_storage_spec.asm_label =
47-
to_string_constant(type_with_subtypes.subtypes()[0]).get_value();
47+
to_string_constant(type_with_subtypes.subtypes()[0]).value();
4848
}
4949
else if(
5050
type.id() == ID_section && type.has_subtype() &&
5151
to_type_with_subtype(type).subtype().id() == ID_string_constant)
5252
{
5353
c_storage_spec.section =
54-
to_string_constant(to_type_with_subtype(type).subtype()).get_value();
54+
to_string_constant(to_type_with_subtype(type).subtype()).value();
5555
}
5656
else if(type.id()==ID_const)
5757
c_qualifiers.is_constant=true;
@@ -227,7 +227,7 @@ void ansi_c_convert_typet::read_rec(const typet &type)
227227
to_type_with_subtype(type).subtype().id() == ID_string_constant)
228228
{
229229
c_storage_spec.alias =
230-
to_string_constant(to_type_with_subtype(type).subtype()).get_value();
230+
to_string_constant(to_type_with_subtype(type).subtype()).value();
231231
}
232232
else if(type.id()==ID_frontend_pointer)
233233
{

src/ansi-c/c_storage_spec.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,19 @@ void c_storage_spect::read(const typet &type)
5252
type.id() == ID_alias && type.has_subtype() &&
5353
to_type_with_subtype(type).subtype().id() == ID_string_constant)
5454
{
55-
alias =
56-
to_string_constant(to_type_with_subtype(type).subtype()).get_value();
55+
alias = to_string_constant(to_type_with_subtype(type).subtype()).value();
5756
}
5857
else if(
5958
type.id() == ID_asm && !to_type_with_subtypes(type).subtypes().empty() &&
6059
to_type_with_subtypes(type).subtypes()[0].id() == ID_string_constant)
6160
{
6261
asm_label =
63-
to_string_constant(to_type_with_subtypes(type).subtypes()[0]).get_value();
62+
to_string_constant(to_type_with_subtypes(type).subtypes()[0]).value();
6463
}
6564
else if(
6665
type.id() == ID_section && type.has_subtype() &&
6766
to_type_with_subtype(type).subtype().id() == ID_string_constant)
6867
{
69-
section =
70-
to_string_constant(to_type_with_subtype(type).subtype()).get_value();
68+
section = to_string_constant(to_type_with_subtype(type).subtype()).value();
7169
}
7270
}

src/ansi-c/c_typecheck_code.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void c_typecheck_baset::typecheck_code(codet &code)
119119
error().source_location = code.find_source_location();
120120
error() << "static assertion failed";
121121
if(code.op1().id() == ID_string_constant)
122-
error() << ": " << to_string_constant(code.op1()).get_value();
122+
error() << ": " << to_string_constant(code.op1()).value();
123123
error() << eom;
124124
throw 0;
125125
}

src/ansi-c/expr2c.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -3960,8 +3960,7 @@ std::string expr2ct::convert_with_precedence(
39603960
}
39613961

39623962
else if(src.id()==ID_string_constant)
3963-
return '"' + MetaString(id2string(to_string_constant(src).get_value())) +
3964-
'"';
3963+
return '"' + MetaString(id2string(to_string_constant(src).value())) + '"';
39653964

39663965
else if(src.id()==ID_struct)
39673966
return convert_struct(src, precedence);

src/assembler/remove_asm.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ void remove_asmt::process_instruction_gcc(
225225
const code_asm_gcct &code,
226226
goto_programt &dest)
227227
{
228-
const irep_idt &i_str = to_string_constant(code.asm_text()).get_value();
228+
const irep_idt &i_str = to_string_constant(code.asm_text()).value();
229229

230230
std::istringstream str(id2string(i_str));
231231
assembler_parser.clear();
@@ -396,7 +396,7 @@ void remove_asmt::process_instruction_msc(
396396
const code_asmt &code,
397397
goto_programt &dest)
398398
{
399-
const irep_idt &i_str = to_string_constant(code.op0()).get_value();
399+
const irep_idt &i_str = to_string_constant(code.op0()).value();
400400

401401
std::istringstream str(id2string(i_str));
402402
assembler_parser.clear();

src/cpp/cpp_typecheck_static_assert.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ void cpp_typecheckt::convert(cpp_static_assertt &cpp_static_assert)
2727
error().source_location=cpp_static_assert.source_location();
2828
error() << "static assertion failed";
2929
if(cpp_static_assert.op1().id()==ID_string_constant)
30-
error() << ": "
31-
<< to_string_constant(cpp_static_assert.op1()).get_value();
30+
error() << ": " << to_string_constant(cpp_static_assert.op1()).value();
3231
error() << eom;
3332
throw 0;
3433
}

src/cprover/axioms.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void axiomst::object_size()
266266
auto pointers_equal = same_object(a_it->address(), *b_it);
267267
auto size_equal = equal_exprt(
268268
*a_it,
269-
from_integer(string_constant.get_value().size() + 1, a_it->type()));
269+
from_integer(string_constant.value().size() + 1, a_it->type()));
270270
auto implication = implies_exprt(pointers_equal, size_equal);
271271
if(verbose)
272272
std::cout << "OBJECT_SIZE2: " << format(implication) << '\n';

src/goto-programs/goto_convert.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ bool goto_convertt::get_string_constant(
18011801

18021802
if(index_op.id()==ID_string_constant)
18031803
{
1804-
value = to_string_constant(index_op).get_value();
1804+
value = to_string_constant(index_op).value();
18051805
return false;
18061806
}
18071807
else if(index_op.id()==ID_array)
@@ -1826,7 +1826,7 @@ bool goto_convertt::get_string_constant(
18261826

18271827
if(expr.id()==ID_string_constant)
18281828
{
1829-
value = to_string_constant(expr).get_value();
1829+
value = to_string_constant(expr).value();
18301830
return false;
18311831
}
18321832

src/goto-programs/string_abstraction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ bool string_abstractiont::build(const exprt &object, exprt &dest, bool write)
803803
if(object.id()==ID_string_constant)
804804
{
805805
const std::string &str_value =
806-
id2string(to_string_constant(object).get_value());
806+
id2string(to_string_constant(object).value());
807807
// make sure we handle the case of a string constant with string-terminating
808808
// \0 in it
809809
const std::size_t str_len =

src/goto-programs/string_instrumentation.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ void string_instrumentationt::do_format_string_read(
378378
format_token_listt token_list = parse_format_string(id2string(
379379
to_string_constant(
380380
to_index_expr(to_address_of_expr(format_arg).object()).array())
381-
.get_value()));
381+
.value()));
382382

383383
std::size_t args=0;
384384

@@ -472,7 +472,7 @@ void string_instrumentationt::do_format_string_write(
472472
format_token_listt token_list = parse_format_string(id2string(
473473
to_string_constant(
474474
to_index_expr(to_address_of_expr(format_arg).object()).array())
475-
.get_value()));
475+
.value()));
476476

477477
std::size_t args=0;
478478

src/goto-symex/shadow_memory.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ void shadow_memoryt::symex_field_static_init_string_constant(
394394

395395
const typet &type = index_expr.array().type();
396396
log.debug() << "Shadow memory: global memory "
397-
<< id2string(to_string_constant(index_expr.array()).get_value())
397+
<< id2string(to_string_constant(index_expr.array()).value())
398398
<< " of type " << from_type(ns, "", type) << messaget::eom;
399399

400400
initialize_shadow_memory(

src/goto-symex/symex_builtin_functions.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ static irep_idt get_string_argument_rec(const exprt &src)
320320
index_expr.index().is_zero())
321321
{
322322
const exprt &fmt_str = index_expr.array();
323-
return to_string_constant(fmt_str).get_value();
323+
return to_string_constant(fmt_str).value();
324324
}
325325
}
326326
else if(object.id() == ID_string_constant)
327327
{
328-
return to_string_constant(object).get_value();
328+
return to_string_constant(object).value();
329329
}
330330
}
331331

src/jsil/parser.y

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ proc_ident_expr: proc_ident
178178
| TOK_STRING
179179
{
180180
symbol_exprt s = symbol_exprt::typeless(
181-
to_string_constant(parser_stack($$)).get_value());
181+
to_string_constant(parser_stack($$)).value());
182182
parser_stack($$).swap(s);
183183
}
184184
;
@@ -429,7 +429,7 @@ literal: TOK_IDENTIFIER
429429
| TOK_STRING
430430
{
431431
constant_exprt c(to_string_constant(parser_stack($$))
432-
.get_value(), string_typet());
432+
.value(), string_typet());
433433
parser_stack($$).swap(c);
434434
}
435435
| TOK_BUILTIN_LOC

src/solvers/strings/string_constraint_generator_main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ string_constraint_generatort::add_axioms_for_char_literal(
365365
{
366366
const string_constantt &s = to_string_constant(
367367
to_binary_expr(to_unary_expr(to_unary_expr(arg).op()).op()).op0());
368-
const std::string &sval = id2string(s.get_value());
368+
const std::string &sval = id2string(s.value());
369369
CHECK_RETURN(sval.size() == 1);
370370
return {from_integer(unsigned(sval[0]), arg.type()), {}};
371371
}

src/statement-list/statement_list_parser.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static std::string find_version(const exprt &root)
6262
if(op.get(ID_statement_list_type) == ID_statement_list_version)
6363
{
6464
const string_constantt &constant{to_string_constant(op)};
65-
return id2string(constant.get_value());
65+
return id2string(constant.value());
6666
}
6767
}
6868
UNREACHABLE; // Root expression should always have a version
@@ -274,10 +274,10 @@ static void find_instructions(
274274
code_token.add_to_operands(*op_it);
275275
}
276276

277-
if(label.get_value() == ID_nil)
277+
if(label.value() == ID_nil)
278278
instruction.add_token(code_token);
279279
else
280-
instruction.add_token(code_labelt{label.get_value(), code_token});
280+
instruction.add_token(code_labelt{label.value(), code_token});
281281

282282
network.add_instruction(instruction);
283283
}

src/util/format_constant.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ std::string format_constantt::operator()(const exprt &expr)
4040
}
4141
}
4242
else if(expr.id()==ID_string_constant)
43-
return id2string(to_string_constant(expr).get_value());
43+
return id2string(to_string_constant(expr).value());
4444

4545
return "(format-constant failed: "+expr.id_string()+")";
4646
}

src/util/simplify_expr_array.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ simplify_exprt::simplify_index(const index_exprt &expr)
128128
{
129129
const auto i = numeric_cast<mp_integer>(index);
130130

131-
const std::string &value = id2string(to_string_constant(array).get_value());
131+
const std::string &value = id2string(to_string_constant(array).value());
132132

133133
if(!i.has_value())
134134
{

src/util/simplify_expr_pointer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ simplify_exprt::simplify_object_size(const object_size_exprt &expr)
689689
{
690690
typet type=expr.type();
691691
return from_integer(
692-
to_string_constant(op_object).get_value().size() + 1, type);
692+
to_string_constant(op_object).value().size() + 1, type);
693693
}
694694
}
695695

0 commit comments

Comments
 (0)