diff options
author | Dan Liew <delcypher@gmail.com> | 2015-12-18 12:48:18 +0000 |
---|---|---|
committer | Dan Liew <delcypher@gmail.com> | 2015-12-18 12:48:18 +0000 |
commit | 535be01be5ab33a0e7106e2d5511bba2797d1ed0 (patch) | |
tree | 026a4f1b16c1996755954f7824e0d10f8ed0ef8e /unittests/Solver/SolverTest.cpp | |
parent | 7e75fa79b2e76251c2cd417a7eae8a7620b014ae (diff) | |
parent | 53ff7a002a8213a5d5e778bef2a895998d9890e1 (diff) | |
download | klee-535be01be5ab33a0e7106e2d5511bba2797d1ed0.tar.gz |
Merge pull request #315 from delcypher/array_leak
Try to fix leaking Array objects detected by ASan.
Diffstat (limited to 'unittests/Solver/SolverTest.cpp')
-rw-r--r-- | unittests/Solver/SolverTest.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/unittests/Solver/SolverTest.cpp b/unittests/Solver/SolverTest.cpp index d9aa9b56..16bd3ce4 100644 --- a/unittests/Solver/SolverTest.cpp +++ b/unittests/Solver/SolverTest.cpp @@ -13,6 +13,7 @@ #include "klee/Constraints.h" #include "klee/Expr.h" #include "klee/Solver.h" +#include "klee/util/ArrayCache.h" #include "llvm/ADT/StringExtras.h" using namespace klee; @@ -32,6 +33,10 @@ ref<Expr> getConstant(int value, Expr::Width width) { return ConstantExpr::create(trunc, width); } +// We have to have the cache globally scopped (and not in ``testOperation``) +// because the Solver (i.e. in STP's case the STPBuilder) holds on to pointers +// to allocated Arrays. +ArrayCache ac; template<class T> void testOperation(Solver &solver, @@ -46,7 +51,7 @@ void testOperation(Solver &solver, unsigned size = Expr::getMinBytesForWidth(operandWidth); static uint64_t id = 0; - const Array *array = Array::CreateArray("arr" + llvm::utostr(++id), size); + const Array *array = ac.CreateArray("arr" + llvm::utostr(++id), size); symbolicArgs.push_back(Expr::CreateArg(Expr::createTempRead(array, operandWidth))); } |