Skip to content

Commit da0adfe

Browse files
author
Daniel Kroening
committed
bugfix: irep_hash_containert now keeps a copy of the contained ireps
1 parent 45436ce commit da0adfe

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/util/irep_hash_container.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ size_t irep_hash_container_baset::number(const irept &irep)
2121
ptr_hasht::const_iterator it=ptr_hash.find(&irep.read());
2222

2323
if(it!=ptr_hash.end())
24-
return it->second;
24+
return it->second.number;
2525

2626
packedt packed;
2727
pack(irep, packed);
2828
size_t id=numbering.number(packed);
2929

30-
ptr_hash[&irep.read()]=id;
30+
auto &irep_entry = ptr_hash[&irep.read()];
31+
irep_entry.number = id;
32+
irep_entry.irep = irep;
3133

3234
return id;
3335
}

src/util/irep_hash_container.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include <vector>
1616

17+
#include "irep.h"
1718
#include "numbering.h"
1819

19-
class irept;
20-
2120
class irep_hash_container_baset
2221
{
2322
public:
@@ -46,7 +45,13 @@ class irep_hash_container_baset
4645
}
4746
};
4847

49-
typedef std::unordered_map<const void *, std::size_t, pointer_hasht>
48+
struct irep_entryt
49+
{
50+
std::size_t number;
51+
irept irep; // copy to keep addresses stable
52+
};
53+
54+
typedef std::unordered_map<const void *, irep_entryt, pointer_hasht>
5055
ptr_hasht;
5156
ptr_hasht ptr_hash;
5257

0 commit comments

Comments
 (0)