blob: d4e8ee8fdecea00acffa74a310dc429a8e6a6702 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include "klee/Expr/ArrayCache.h"
namespace klee {
ArrayCache::~ArrayCache() {
// Free Allocated Array objects
for (ArrayHashMap::iterator ai = cachedSymbolicArrays.begin(),
e = cachedSymbolicArrays.end();
ai != e; ++ai) {
delete *ai;
}
for (ArrayPtrVec::iterator ai = concreteArrays.begin(),
e = concreteArrays.end();
ai != e; ++ai) {
delete *ai;
}
}
const Array *
ArrayCache::CreateArray(const std::string &_name, uint64_t _size,
const ref<ConstantExpr> *constantValuesBegin,
const ref<ConstantExpr> *constantValuesEnd,
Expr::Width _domain, Expr::Width _range) {
const Array *array = new Array(_name, _size, constantValuesBegin,
constantValuesEnd, _domain, _range);
if (array->isSymbolicArray()) {
std::pair<ArrayHashMap::const_iterator, bool> success =
cachedSymbolicArrays.insert(array);
if (success.second) {
// Cache miss
return array;
}
// Cache hit
delete array;
array = *(success.first);
assert(array->isSymbolicArray() &&
"Cached symbolic array is no longer symbolic");
return array;
} else {
// Treat every constant array as distinct so we never cache them
assert(array->isConstantArray());
concreteArrays.push_back(array); // For deletion later
return array;
}
}
}
|