Skip to content

Commit 90beed4

Browse files
author
Daniel Kroening
authored
Merge pull request #1845 from tautschnig/fix-1837
Fix building without USE_DSTRING
2 parents 5cdfa94 + 590fc2d commit 90beed4

17 files changed

+37
-18
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ jobs:
142142
- CCACHE_CPP2=yes
143143
- EXTRA_CXXFLAGS="-DNDEBUG"
144144

145-
# Ubuntu Linux with glibc using clang++-3.7, debug mode
145+
# Ubuntu Linux with glibc using clang++-3.7, debug mode, disable USE_DSTRING
146146
- stage: Test different OS/CXX/Flags
147147
os: linux
148148
sudo: false
@@ -165,7 +165,7 @@ jobs:
165165
env:
166166
- COMPILER="ccache clang++-3.7 -Qunused-arguments -fcolor-diagnostics"
167167
- CCACHE_CPP2=yes
168-
- EXTRA_CXXFLAGS="-DDEBUG"
168+
- EXTRA_CXXFLAGS="-DDEBUG -DUSE_STD_STRING"
169169
script: echo "Not running any tests for a debug build."
170170

171171
# cmake build using g++-5

doc/architectural/cbmc-guide.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -597,5 +597,5 @@ they are in the code.
597597
[^2]: Or references, if reference counted data sharing is enabled. It is
598598
enabled by default; see the `SHARING` macro.
599599

600-
[^3]: When `USE_DSTRING` is enabled (it is by default), this is actually
600+
[^3]: Unless `USE_STD_STRING` is set, this is actually
601601
a `dstring` and thus an integer which is a reference into a string table

src/ansi-c/ansi_c_scope.h

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Author: Daniel Kroening, [email protected]
1212

1313
#include <util/irep.h>
1414

15+
#include <unordered_map>
16+
1517
enum class ansi_c_id_classt
1618
{
1719
ANSI_C_UNKNOWN,

src/goto-programs/class_hierarchy.h

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Date: April 2016
1616

1717
#include <iosfwd>
1818
#include <map>
19+
#include <unordered_map>
1920

2021
#include <util/graph.h>
2122
#include <util/namespace.h>

src/goto-programs/interpreter.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected]
2020

2121
#include <util/invariant.h>
2222
#include <util/std_types.h>
23+
#include <util/string_container.h>
2324
#include <util/symbol_table.h>
2425
#include <util/ieee_float.h>
2526
#include <util/fixedbv.h>
@@ -642,7 +643,7 @@ exprt interpretert::get_value(
642643
{
643644
// Strings are currently encoded by their irep_idt ID.
644645
return constant_exprt(
645-
irep_idt::make_from_table_index(rhs[integer2size_t(offset)].to_long()),
646+
get_string_container().get_string(rhs[integer2size_t(offset)].to_long()),
646647
type);
647648
}
648649

src/goto-programs/interpreter_evaluate.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Author: Daniel Kroening, [email protected]
1919
#include <util/invariant.h>
2020
#include <util/fixedbv.h>
2121
#include <util/std_expr.h>
22+
#include <util/string_container.h>
2223
#include <util/pointer_offset_size.h>
2324

2425
#include <langapi/language_util.h>
@@ -394,7 +395,7 @@ void interpretert::evaluate(
394395
if(show)
395396
warning() << "string decoding not fully implemented "
396397
<< length << eom;
397-
mp_integer tmp=value.get_no();
398+
mp_integer tmp = get_string_container()[id2string(value)];
398399
dest.push_back(tmp);
399400
return;
400401
}

src/java_bytecode/character_refine_preprocess.h

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Date: March 2017
2424
#include <util/std_code.h>
2525
#include <util/mp_arith.h>
2626

27+
#include <unordered_map>
28+
2729
class character_refine_preprocesst:public messaget
2830
{
2931
public:

src/java_bytecode/java_bytecode_convert_class.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ static void find_and_replace_parameter(
687687
{
688688
// get the name of the parameter, e.g., `T` from `java::Class::T`
689689
const std::string &parameter_full_name =
690-
as_string(parameter.type_variable_ref().get_identifier());
690+
id2string(parameter.type_variable_ref().get_identifier());
691691
const std::string &parameter_name =
692692
parameter_full_name.substr(parameter_full_name.rfind("::") + 2);
693693

@@ -698,7 +698,7 @@ static void find_and_replace_parameter(
698698
[&parameter_name](const java_generic_parametert &replacement_param)
699699
{
700700
const std::string &replacement_parameter_full_name =
701-
as_string(replacement_param.type_variable().get_identifier());
701+
id2string(replacement_param.type_variable().get_identifier());
702702
return parameter_name.compare(
703703
replacement_parameter_full_name.substr(
704704
replacement_parameter_full_name.rfind("::") + 2)) == 0;
@@ -708,7 +708,7 @@ static void find_and_replace_parameter(
708708
if(replacement_parameter_p != replacement_parameters.end())
709709
{
710710
const std::string &replacement_parameter_full_name =
711-
as_string(replacement_parameter_p->type_variable().get_identifier());
711+
id2string(replacement_parameter_p->type_variable().get_identifier());
712712

713713
// the replacement parameter is a viable one, i.e., it comes from an outer
714714
// class

src/java_bytecode/java_bytecode_convert_method.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ code_blockt &java_bytecode_convert_methodt::get_or_create_block_for_pcrange(
798798
// any block-internal edges to target the inner header block.
799799

800800
const irep_idt child_label_name=child_label.get_label();
801-
std::string new_label_str=as_string(child_label_name);
801+
std::string new_label_str = id2string(child_label_name);
802802
new_label_str+='$';
803803
irep_idt new_label_irep(new_label_str);
804804

@@ -1281,8 +1281,9 @@ codet java_bytecode_convert_methodt::convert_instructions(
12811281
// constructors.
12821282
if(statement=="invokespecial")
12831283
{
1284-
if(as_string(arg0.get(ID_identifier))
1285-
.find("<init>")!=std::string::npos)
1284+
if(
1285+
id2string(arg0.get(ID_identifier)).find("<init>") !=
1286+
std::string::npos)
12861287
{
12871288
if(needed_lazy_methods)
12881289
needed_lazy_methods->add_needed_class(classname);

src/java_bytecode/java_object_factory.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ void java_object_factoryt::gen_nondet_struct_init(
10341034
if(skip_classid)
10351035
continue;
10361036

1037-
irep_idt qualified_clsid="java::"+as_string(class_identifier);
1037+
irep_idt qualified_clsid = "java::" + id2string(class_identifier);
10381038
constant_exprt ci(qualified_clsid, string_typet());
10391039
code_assignt code(me, ci);
10401040
code.add_source_location()=loc;
@@ -1329,13 +1329,13 @@ void java_object_factoryt::gen_nondet_array_init(
13291329
exprt java_zero=from_integer(0, java_int_type());
13301330
assignments.copy_to_operands(code_assignt(counter_expr, java_zero));
13311331

1332-
std::string head_name=as_string(counter.base_name)+"_header";
1332+
std::string head_name = id2string(counter.base_name) + "_header";
13331333
code_labelt init_head_label(head_name, code_skipt());
13341334
code_gotot goto_head(head_name);
13351335

13361336
assignments.move_to_operands(init_head_label);
13371337

1338-
std::string done_name=as_string(counter.base_name)+"_done";
1338+
std::string done_name = id2string(counter.base_name) + "_done";
13391339
code_labelt init_done_label(done_name, code_skipt());
13401340
code_gotot goto_done(done_name);
13411341

src/solvers/prop/bdd_expr.h

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Author: Michael Tautschnig, [email protected]
2323

2424
#include <solvers/miniBDD/miniBDD.h>
2525

26+
#include <unordered_map>
27+
2628
class namespacet;
2729

2830
/*! \brief TO_BE_DOCUMENTED

src/util/expr.h

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Author: Daniel Kroening, [email protected]
1515
#include <functional>
1616
#include "type.h"
1717

18+
#include <list>
19+
1820
#define forall_operands(it, expr) \
1921
if((expr).has_operands()) /* NOLINT(readability/braces) */ \
2022
for(exprt::operandst::const_iterator it=(expr).operands().begin(), \

src/util/irep_ids.h

+4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ Author: Reuben Thomas, [email protected]
1212
#ifndef CPROVER_UTIL_IREP_IDS_H
1313
#define CPROVER_UTIL_IREP_IDS_H
1414

15+
#ifndef USE_STD_STRING
1516
#define USE_DSTRING
17+
#endif
1618

1719
#ifdef USE_DSTRING
1820
#include "dstring.h"
21+
#else
22+
#include <string>
1923
#endif
2024

2125
/// \file The irep_ids are generated using a technique called

src/util/replace_expr.h

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Author: Daniel Kroening, [email protected]
1717

1818
#include "expr.h"
1919

20+
#include <unordered_map>
21+
2022
typedef std::unordered_map<exprt, exprt, irep_hash> replace_mapt;
2123

2224
bool replace_expr(const exprt &what, const exprt &by, exprt &dest);

src/util/replace_symbol.h

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Author: Daniel Kroening, [email protected]
1717

1818
#include "expr.h"
1919

20+
#include <unordered_map>
21+
2022
class replace_symbolt
2123
{
2224
public:

src/util/std_types.h

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Author: Daniel Kroening, [email protected]
2121
#include "invariant.h"
2222
#include "expr_cast.h"
2323

24+
#include <unordered_map>
25+
2426
class constant_exprt;
2527

2628
/*! \defgroup gr_std_types Conversion to specific types

src/util/symbol_table_base.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ void symbol_table_baset::show(std::ostream &out) const
3838
std::sort(
3939
sorted_names.begin(),
4040
sorted_names.end(),
41-
[](const irep_idt &a, const irep_idt &b)
42-
{
43-
return as_string(a) < as_string(b);
44-
});
41+
[](const irep_idt &a, const irep_idt &b) { return a.compare(b); });
4542
out << "\n"
4643
<< "Symbols:"
4744
<< "\n";

0 commit comments

Comments
 (0)