Skip to content

Commit 33c34a0

Browse files
authored
Merge pull request #3590 from tautschnig/string-constantt
Use string_constantt's API
2 parents 70287a1 + 72a025a commit 33c34a0

19 files changed

+59
-44
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Author: Daniel Kroening, [email protected]
3232
#include <util/simplify_expr.h>
3333
#include <util/std_expr.h>
3434
#include <util/string2int.h>
35-
#include <util/string_constant.h>
3635
#include <util/threeval.h>
3736

3837
#include <goto-programs/cfg.h>

src/analyses/custom_bitvector_analysis.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <util/expr_util.h>
1515
#include <util/simplify_expr.h>
16+
#include <util/string_constant.h>
1617
#include <util/xml_expr.h>
1718

1819
#include <langapi/language_util.h>
@@ -182,10 +183,7 @@ unsigned custom_bitvector_analysist::get_bit_nr(
182183
else if(string_expr.id()==ID_index)
183184
return get_bit_nr(to_index_expr(string_expr).array());
184185
else if(string_expr.id()==ID_string_constant)
185-
{
186-
irep_idt value=string_expr.get(ID_value);
187-
return bits.number(value);
188-
}
186+
return bits.number(to_string_constant(string_expr).get_value());
189187
else
190188
return bits.number("(unknown)");
191189
}

src/ansi-c/ansi_c_convert_type.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <cassert>
1515

16+
#include <util/arith_tools.h>
1617
#include <util/c_types.h>
1718
#include <util/config.h>
1819
#include <util/namespace.h>
1920
#include <util/simplify_expr.h>
20-
#include <util/arith_tools.h>
2121
#include <util/std_types.h>
22+
#include <util/string_constant.h>
2223

2324
#include "gcc_types.h"
2425

@@ -50,13 +51,13 @@ void ansi_c_convert_typet::read_rec(const typet &type)
5051
{
5152
if(type.has_subtype() &&
5253
type.subtype().id()==ID_string_constant)
53-
c_storage_spec.asm_label=type.subtype().get(ID_value);
54+
c_storage_spec.asm_label = to_string_constant(type.subtype()).get_value();
5455
}
5556
else if(type.id()==ID_section &&
5657
type.has_subtype() &&
5758
type.subtype().id()==ID_string_constant)
5859
{
59-
c_storage_spec.section=type.subtype().get(ID_value);
60+
c_storage_spec.section = to_string_constant(type.subtype()).get_value();
6061
}
6162
else if(type.id()==ID_const)
6263
c_qualifiers.is_constant=true;
@@ -230,7 +231,7 @@ void ansi_c_convert_typet::read_rec(const typet &type)
230231
type.has_subtype() &&
231232
type.subtype().id()==ID_string_constant)
232233
{
233-
c_storage_spec.alias=type.subtype().get(ID_value);
234+
c_storage_spec.alias = to_string_constant(type.subtype()).get_value();
234235
}
235236
else if(type.id()==ID_frontend_pointer)
236237
{

src/ansi-c/c_storage_spec.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Author: Daniel Kroening, [email protected]
99
#include "c_storage_spec.h"
1010

1111
#include <util/expr.h>
12+
#include <util/string_constant.h>
1213

1314
void c_storage_spect::read(const typet &type)
1415
{
@@ -50,18 +51,18 @@ void c_storage_spect::read(const typet &type)
5051
type.has_subtype() &&
5152
type.subtype().id()==ID_string_constant)
5253
{
53-
alias=type.subtype().get(ID_value);
54+
alias = to_string_constant(type.subtype()).get_value();
5455
}
5556
else if(type.id()==ID_asm &&
5657
type.has_subtype() &&
5758
type.subtype().id()==ID_string_constant)
5859
{
59-
asm_label=type.subtype().get(ID_value);
60+
asm_label = to_string_constant(type.subtype()).get_value();
6061
}
6162
else if(type.id()==ID_section &&
6263
type.has_subtype() &&
6364
type.subtype().id()==ID_string_constant)
6465
{
65-
section=type.subtype().get(ID_value);
66+
section = to_string_constant(type.subtype()).get_value();
6667
}
6768
}

src/ansi-c/expr2c.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Author: Daniel Kroening, [email protected]
2424
#include <util/lispirep.h>
2525
#include <util/namespace.h>
2626
#include <util/pointer_offset_size.h>
27+
#include <util/string_constant.h>
2728
#include <util/suffix.h>
2829
#include <util/symbol.h>
2930

@@ -3867,7 +3868,8 @@ std::string expr2ct::convert_with_precedence(
38673868
return convert_constant(to_constant_expr(src), precedence);
38683869

38693870
else if(src.id()==ID_string_constant)
3870-
return '"'+MetaString(src.get_string(ID_value))+'"';
3871+
return '"' + MetaString(id2string(to_string_constant(src).get_value())) +
3872+
'"';
38713873

38723874
else if(src.id()==ID_struct)
38733875
return convert_struct(src, precedence);

src/ansi-c/literals/convert_string_literal.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ exprt convert_string_literal(const std::string &src)
153153
char_value[i]=value[i];
154154
}
155155

156-
string_constantt result;
157-
result.set_value(char_value);
158-
159-
return std::move(result);
156+
return string_constantt(char_value);
160157
}
161158
}

src/cpp/cpp_typecheck_resolve.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,8 +1388,7 @@ exprt cpp_typecheck_resolvet::resolve(
13881388
{
13891389
// __func__ is an ANSI-C standard compliant hack to get the function name
13901390
// __FUNCTION__ and __PRETTY_FUNCTION__ are GCC-specific
1391-
string_constantt s;
1392-
s.set_value(source_location.get_function());
1391+
string_constantt s(source_location.get_function());
13931392
s.add_source_location()=source_location;
13941393
return std::move(s);
13951394
}

src/cpp/cpp_typecheck_static_assert.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Author: Daniel Kroening, [email protected]
1212
#include "cpp_typecheck.h"
1313

1414
#include <util/std_types.h>
15+
#include <util/string_constant.h>
1516

1617
void cpp_typecheckt::convert(cpp_static_assertt &cpp_static_assert)
1718
{
@@ -31,7 +32,8 @@ void cpp_typecheckt::convert(cpp_static_assertt &cpp_static_assert)
3132
error().source_location=cpp_static_assert.source_location();
3233
error() << "static assertion failed";
3334
if(cpp_static_assert.op1().id()==ID_string_constant)
34-
error() << ": " << cpp_static_assert.op1().get(ID_value);
35+
error() << ": "
36+
<< to_string_constant(cpp_static_assert.op1()).get_value();
3537
error() << eom;
3638
throw 0;
3739
}

src/goto-programs/goto_convert.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected]
2020
#include <util/prefix.h>
2121
#include <util/simplify_expr.h>
2222
#include <util/std_expr.h>
23+
#include <util/string_constant.h>
2324
#include <util/symbol_table.h>
2425
#include <util/symbol_table_builder.h>
2526

@@ -1819,7 +1820,10 @@ bool goto_convertt::get_string_constant(
18191820
simplify(index_op, ns);
18201821

18211822
if(index_op.id()==ID_string_constant)
1822-
return value=index_op.get(ID_value), false;
1823+
{
1824+
value = to_string_constant(index_op).get_value();
1825+
return false;
1826+
}
18231827
else if(index_op.id()==ID_array)
18241828
{
18251829
std::string result;
@@ -1839,7 +1843,10 @@ bool goto_convertt::get_string_constant(
18391843
}
18401844

18411845
if(expr.id()==ID_string_constant)
1842-
return value=expr.get(ID_value), false;
1846+
{
1847+
value = to_string_constant(expr).get_value();
1848+
return false;
1849+
}
18431850

18441851
return true;
18451852
}

src/goto-programs/string_abstraction.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Author: Daniel Kroening, [email protected]
1818
#include <util/exception_utils.h>
1919
#include <util/expr_util.h>
2020
#include <util/pointer_predicates.h>
21+
#include <util/string_constant.h>
2122
#include <util/type_eq.h>
2223

2324
#include "pointer_arithmetic.h"
@@ -763,7 +764,8 @@ bool string_abstractiont::build(const exprt &object, exprt &dest, bool write)
763764

764765
if(object.id()==ID_string_constant)
765766
{
766-
const std::string &str_value = id2string(object.get(ID_value));
767+
const std::string &str_value =
768+
id2string(to_string_constant(object).get_value());
767769
// make sure we handle the case of a string constant with string-terminating
768770
// \0 in it
769771
const std::size_t str_len =

0 commit comments

Comments
 (0)