Skip to content

Commit 5678ed6

Browse files
authored
Merge pull request #7534 from remi-delmas-3000/read-irep-ensure-named-sub-ordering
Restore named_sub map entries ordering when reading from a goto binary.
2 parents 4ba6285 + c52c0f6 commit 5678ed6

16 files changed

+34
-30
lines changed

src/analyses/variable-sensitivity/value_set_pointer_abstract_object.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "abstract_environment.h"
1919
#include "context_abstract_object.h" // IWYU pragma: keep
2020

21+
#include <algorithm>
2122
#include <numeric>
2223

2324
static abstract_object_sett

src/cprover/generalization.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Author: Daniel Kroening, [email protected]
1616

1717
#include "solver.h"
1818

19+
#include <algorithm>
1920
#include <iostream>
2021
#include <map>
2122

src/cprover/inductiveness.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Author: Daniel Kroening, [email protected]
2323
#include "propagate.h"
2424
#include "solver.h"
2525

26+
#include <algorithm>
2627
#include <iomanip>
2728
#include <iostream>
2829

src/cprover/state_encoding.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Author: Daniel Kroening, [email protected]
2626
#include "state_encoding_targets.h"
2727
#include "variable_encoding.h"
2828

29+
#include <algorithm>
2930
#include <iostream>
3031

3132
class state_encodingt

src/goto-instrument/contracts/instrument_spec_assigns.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Date: January 2022
2121

2222
#include <goto-programs/goto_program.h>
2323

24+
#include <algorithm>
2425
#include <unordered_map>
2526
#include <unordered_set>
2627

src/goto-instrument/unwindset.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected]
2020

2121
#include <goto-programs/abstract_goto_model.h>
2222

23+
#include <algorithm>
2324
#include <fstream>
2425

2526
void unwindsett::parse_unwind(const std::string &unwind)

src/solvers/flattening/boolbv_bitreverse.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ Author: Michael Tautschnig
66
77
\*******************************************************************/
88

9+
#include <util/bitvector_expr.h>
10+
911
#include "boolbv.h"
1012

11-
#include <util/bitvector_expr.h>
13+
#include <algorithm>
1214

1315
bvt boolbvt::convert_bitreverse(const bitreverse_exprt &expr)
1416
{

src/solvers/flattening/boolbv_get.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Author: Daniel Kroening, [email protected]
1616
#include "boolbv.h"
1717
#include "boolbv_type.h"
1818

19+
#include <algorithm>
20+
1921
exprt boolbvt::get(const exprt &expr) const
2022
{
2123
if(expr.id()==ID_symbol ||

src/solvers/smt2_incremental/ast/smt_commands.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include <util/range.h>
66

7+
#include <algorithm>
8+
79
// Define the irep_idts for commands.
810
#define COMMAND_ID(the_id) \
911
const irep_idt ID_smt_##the_id##_command{"smt_" #the_id "_command"};

src/solvers/smt2_incremental/convert_expr_to_smt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Author: Diffblue Ltd.
2-
32
#include <util/arith_tools.h>
43
#include <util/bitvector_expr.h>
54
#include <util/byte_operators.h>
@@ -22,6 +21,7 @@
2221
#include <solvers/smt2_incremental/theories/smt_bit_vector_theory.h>
2322
#include <solvers/smt2_incremental/theories/smt_core_theory.h>
2423

24+
#include <algorithm>
2525
#include <functional>
2626
#include <numeric>
2727

src/util/forward_list_as_map.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class forward_list_as_mapt : public std::forward_list<std::pair<keyt, mappedt>>
3434
{
3535
}
3636

37-
void remove(const keyt &name)
37+
void erase(const keyt &name)
3838
{
3939
const_iterator it = this->lower_bound(name);
4040

@@ -94,6 +94,23 @@ class forward_list_as_mapt : public std::forward_list<std::pair<keyt, mappedt>>
9494
return it->second;
9595
}
9696

97+
mappedt &emplace(const keyt &name, const mappedt &irep)
98+
{
99+
iterator it = mutable_lower_bound(name);
100+
101+
if(it == this->end() || it->first != name)
102+
{
103+
iterator before = this->before_begin();
104+
while(std::next(before) != it)
105+
++before;
106+
it = this->emplace_after(before, name, irep);
107+
}
108+
else
109+
it->second = irep;
110+
111+
return it->second;
112+
}
113+
97114
std::size_t size() const
98115
{
99116
return narrow<std::size_t>(std::distance(this->begin(), this->end()));

src/util/irep.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,8 @@ void irept::set_size_t(const irep_idt &name, const std::size_t value)
9494

9595
void irept::remove(const irep_idt &name)
9696
{
97-
#if NAMED_SUB_IS_FORWARD_LIST
98-
return get_named_sub().remove(name);
99-
#else
10097
named_subt &s = get_named_sub();
10198
s.erase(name);
102-
#endif
10399
}
104100

105101
const irept &irept::find(const irep_idt &name) const

src/util/irep_hash_container.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,7 @@ void irep_hash_container_baset::pack(
5555
{
5656
// we pack: the irep id, the sub size, the subs, the named-sub size, and
5757
// each of the named subs with their ids
58-
#if NAMED_SUB_IS_FORWARD_LIST
59-
const std::size_t named_sub_size =
60-
std::distance(named_sub.begin(), named_sub.end());
61-
#else
6258
const std::size_t named_sub_size = named_sub.size();
63-
#endif
6459
packed.reserve(1 + 1 + sub.size() + 1 + named_sub_size * 2);
6560

6661
packed.push_back(irep_id_hash()(irep.id()));

src/util/irep_serialization.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,31 +75,18 @@ irept irep_serializationt::read_irep(std::istream &in)
7575
sub.push_back(reference_convert(in));
7676
}
7777

78-
#if NAMED_SUB_IS_FORWARD_LIST
79-
irept::named_subt::iterator before = named_sub.before_begin();
80-
#endif
8178
while(in.peek()=='N')
8279
{
8380
in.get();
8481
irep_idt id = read_string_ref(in);
85-
#if NAMED_SUB_IS_FORWARD_LIST
86-
named_sub.emplace_after(before, id, reference_convert(in));
87-
++before;
88-
#else
8982
named_sub.emplace(id, reference_convert(in));
90-
#endif
9183
}
9284

9385
while(in.peek()=='C')
9486
{
9587
in.get();
9688
irep_idt id = read_string_ref(in);
97-
#if NAMED_SUB_IS_FORWARD_LIST
98-
named_sub.emplace_after(before, id, reference_convert(in));
99-
++before;
100-
#else
10189
named_sub.emplace(id, reference_convert(in));
102-
#endif
10390
}
10491

10592
if(in.get()!=0)

src/util/lispirep.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,7 @@ void irep2lisp(const irept &src, lispexprt &dest)
4646
dest.value.clear();
4747
dest.type=lispexprt::List;
4848

49-
#if NAMED_SUB_IS_FORWARD_LIST
50-
const std::size_t named_sub_size =
51-
std::distance(src.get_named_sub().begin(), src.get_named_sub().end());
52-
#else
5349
const std::size_t named_sub_size = src.get_named_sub().size();
54-
#endif
5550
dest.reserve(2 + 2 * src.get_sub().size() + 2 * named_sub_size);
5651

5752
lispexprt id;

src/util/simplify_expr_int.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Author: Daniel Kroening, [email protected]
2525
#include "simplify_utils.h"
2626
#include "std_expr.h"
2727

28+
#include <algorithm>
29+
2830
simplify_exprt::resultt<>
2931
simplify_exprt::simplify_bswap(const bswap_exprt &expr)
3032
{

0 commit comments

Comments
 (0)