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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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 =

0 commit comments

Comments
 (0)