klee
ArrayCache.cpp
Go to the documentation of this file.
2
3namespace klee {
4
6 // Free Allocated Array objects
7 for (ArrayHashMap::iterator ai = cachedSymbolicArrays.begin(),
8 e = cachedSymbolicArrays.end();
9 ai != e; ++ai) {
10 delete *ai;
11 }
12 for (ArrayPtrVec::iterator ai = concreteArrays.begin(),
13 e = concreteArrays.end();
14 ai != e; ++ai) {
15 delete *ai;
16 }
17}
18
19const Array *
20ArrayCache::CreateArray(const std::string &_name, uint64_t _size,
21 const ref<ConstantExpr> *constantValuesBegin,
22 const ref<ConstantExpr> *constantValuesEnd,
23 Expr::Width _domain, Expr::Width _range) {
24
25 const Array *array = new Array(_name, _size, constantValuesBegin,
26 constantValuesEnd, _domain, _range);
27 if (array->isSymbolicArray()) {
28 std::pair<ArrayHashMap::const_iterator, bool> success =
29 cachedSymbolicArrays.insert(array);
30 if (success.second) {
31 // Cache miss
32 return array;
33 }
34 // Cache hit
35 delete array;
36 array = *(success.first);
37 assert(array->isSymbolicArray() &&
38 "Cached symbolic array is no longer symbolic");
39 return array;
40 } else {
41 // Treat every constant array as distinct so we never cache them
42 assert(array->isConstantArray());
43 concreteArrays.push_back(array); // For deletion later
44 return array;
45 }
46}
47}
ArrayHashMap cachedSymbolicArrays
Definition: ArrayCache.h:66
ArrayPtrVec concreteArrays
Definition: ArrayCache.h:68
const Array * CreateArray(const std::string &_name, uint64_t _size, const ref< ConstantExpr > *constantValuesBegin=0, const ref< ConstantExpr > *constantValuesEnd=0, Expr::Width _domain=Expr::Int32, Expr::Width _range=Expr::Int8)
Create an Array object.
Definition: ArrayCache.cpp:20
bool isConstantArray() const
Definition: Expr.h:525
bool isSymbolicArray() const
Definition: Expr.h:524
unsigned Width
The type of an expression is simply its width, in bits.
Definition: Expr.h:97
Definition: Ref.h:82
Definition: main.cpp:291