From c763a4087f1d8fa4dbdfb9c8f30d545cdb66a0aa Mon Sep 17 00:00:00 2001 From: Julian Büning Date: Sat, 10 Oct 2020 15:13:06 +0200 Subject: Ref: implement operator bool() --- lib/Expr/ArrayExprOptimizer.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lib/Expr/ArrayExprOptimizer.cpp') diff --git a/lib/Expr/ArrayExprOptimizer.cpp b/lib/Expr/ArrayExprOptimizer.cpp index 8877efd5..a2367506 100644 --- a/lib/Expr/ArrayExprOptimizer.cpp +++ b/lib/Expr/ArrayExprOptimizer.cpp @@ -147,7 +147,7 @@ ref ExprOptimizer::optimizeExpr(const ref &e, bool valueOnly) { result = ConstantExpr::create(0, Expr::Bool); } // Add new expression to cache - if (result.get()) { + if (result) { klee_warning("OPT_I: successful"); cacheExprOptimized[e] = result; } else { @@ -161,7 +161,7 @@ ref ExprOptimizer::optimizeExpr(const ref &e, bool valueOnly) { } // ----------------------- VALUE-BASED OPTIMIZATION ------------------------- if (OptimizeArray == VALUE || - (OptimizeArray == ALL && (!result.get() || valueOnly))) { + (OptimizeArray == ALL && (!result || valueOnly))) { std::vector reads; std::map, Expr::Width>> readInfo; ArrayReadExprVisitor are(reads, readInfo); @@ -175,7 +175,7 @@ ref ExprOptimizer::optimizeExpr(const ref &e, bool valueOnly) { ref selectOpt = getSelectOptExpr(e, reads, readInfo, are.containsSymbolic()); - if (selectOpt.get()) { + if (selectOpt) { klee_warning("OPT_V: successful"); result = selectOpt; cacheExprOptimized[e] = result; @@ -184,7 +184,7 @@ ref ExprOptimizer::optimizeExpr(const ref &e, bool valueOnly) { cacheExprUnapplicable.insert(e); } } - if (result.isNull()) + if (!result) return e; return result; } @@ -204,12 +204,11 @@ bool ExprOptimizer::computeIndexes(array2idx_ty &arrays, const ref &e, assert((idxt_v.getWidth() % arr->range == 0) && "Read is not aligned"); Expr::Width width = idxt_v.getWidth() / arr->range; - if (idxt_v.getMul().get()) { + if (auto e = idxt_v.getMul()) { // If we have a MulExpr in the index, we can optimize our search by // skipping all those indexes that are not multiple of such value. // In fact, they will be rejected by the MulExpr interpreter since it // will not find any integer solution - auto e = idxt_v.getMul(); auto ce = dyn_cast(e); assert(ce && "Not a constant expression"); uint64_t mulVal = (*ce->getAPValue().getRawData()); @@ -320,7 +319,7 @@ ref ExprOptimizer::getSelectOptExpr( ref opt = buildConstantSelectExpr(index, arrayValues, width, elementsInArray); - if (opt.get()) { + if (opt) { cacheReadExprOptimized[const_cast(read)] = opt; optimized.insert(std::make_pair(info.first, opt)); } @@ -418,7 +417,7 @@ ref ExprOptimizer::getSelectOptExpr( // Build the dynamic select expression ref opt = buildMixedSelectExpr(read, arrayValues, width, elementsInArray); - if (opt.get()) { + if (opt) { cacheReadExprOptimized[const_cast(read)] = opt; optimized.insert(std::make_pair(info.first, opt)); } @@ -428,7 +427,7 @@ ref ExprOptimizer::getSelectOptExpr( toReturn = replacer.visit(e); } - return toReturn.get() ? toReturn : notFound; + return toReturn ? toReturn : notFound; } ref ExprOptimizer::buildConstantSelectExpr( -- cgit 1.4.1