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/Core/ExecutionState.cpp | 2 +- lib/Core/Executor.cpp | 6 +++--- lib/Core/Memory.cpp | 6 +++--- lib/Core/SpecialFunctionHandler.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/Core') diff --git a/lib/Core/ExecutionState.cpp b/lib/Core/ExecutionState.cpp index 62376db6..97f97a8b 100644 --- a/lib/Core/ExecutionState.cpp +++ b/lib/Core/ExecutionState.cpp @@ -283,7 +283,7 @@ bool ExecutionState::merge(const ExecutionState &b) { for (unsigned i=0; inumRegisters; i++) { ref &av = af.locals[i].value; const ref &bv = bf.locals[i].value; - if (av.isNull() || bv.isNull()) { + if (!av || !bv) { // if one is null then by implication (we are at same pc) // we cannot reuse this local, so just ignore } else { diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index e3e33aa2..13c25076 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -3048,11 +3048,11 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { r = ExtractExpr::create(agg, rOffset, agg->getWidth() - rOffset); ref result; - if (!l.isNull() && !r.isNull()) + if (l && r) result = ConcatExpr::create(r, ConcatExpr::create(val, l)); - else if (!l.isNull()) + else if (l) result = ConcatExpr::create(val, l); - else if (!r.isNull()) + else if (r) result = ConcatExpr::create(r, val); else result = val; diff --git a/lib/Core/Memory.cpp b/lib/Core/Memory.cpp index bf00ee4b..86b06701 100644 --- a/lib/Core/Memory.cpp +++ b/lib/Core/Memory.cpp @@ -135,7 +135,7 @@ ObjectState::~ObjectState() { } ArrayCache *ObjectState::getArrayCache() const { - assert(!object.isNull() && "object was NULL"); + assert(object && "object was NULL"); return object->parent->getArrayCache(); } @@ -149,7 +149,7 @@ const UpdateList &ObjectState::getUpdates() const { // FIXME: We should be able to do this more efficiently, we just need to be // careful to get the interaction with the cache right. In particular we // should avoid creating UpdateNode instances we never use. - unsigned NumWrites = updates.head.isNull() ? 0 : updates.head->getSize(); + unsigned NumWrites = updates.head ? updates.head->getSize() : 0; std::vector< std::pair< ref, ref > > Writes(NumWrites); const auto *un = updates.head.get(); for (unsigned i = NumWrites; i != 0; un = un->next.get()) { @@ -219,7 +219,7 @@ void ObjectState::makeConcrete() { } void ObjectState::makeSymbolic() { - assert(updates.head.isNull() && + assert(!updates.head && "XXX makeSymbolic of objects with symbolic values is unsupported"); // XXX simplify this, can just delete various arrays I guess diff --git a/lib/Core/SpecialFunctionHandler.cpp b/lib/Core/SpecialFunctionHandler.cpp index 6d54eb22..153619d3 100644 --- a/lib/Core/SpecialFunctionHandler.cpp +++ b/lib/Core/SpecialFunctionHandler.cpp @@ -464,7 +464,7 @@ void SpecialFunctionHandler::handleEhUnwindRaiseExceptionImpl( "invalid number of arguments to _klee_eh_Unwind_RaiseException_impl"); ref exceptionObject = dyn_cast(arguments[0]); - if (!exceptionObject.get()) { + if (!exceptionObject) { executor.terminateStateOnError(state, "Internal error: Symbolic exception pointer", Executor::Unhandled); -- cgit 1.4.1