diff options
-rw-r--r-- | include/klee/ADT/Ref.h | 7 | ||||
-rw-r--r-- | include/klee/Support/Casting.h | 35 | ||||
-rw-r--r-- | lib/Core/ExecutionState.cpp | 3 | ||||
-rw-r--r-- | lib/Core/Executor.cpp | 11 | ||||
-rw-r--r-- | lib/Core/SpecialFunctionHandler.cpp | 5 | ||||
-rw-r--r-- | lib/Expr/ArrayExprOptimizer.cpp | 4 | ||||
-rw-r--r-- | lib/Expr/ArrayExprRewriter.cpp | 2 | ||||
-rw-r--r-- | lib/Expr/AssignmentGenerator.cpp | 2 | ||||
-rw-r--r-- | lib/Expr/ExprSMTLIBPrinter.cpp | 2 | ||||
-rw-r--r-- | lib/Module/FunctionAlias.cpp | 10 |
10 files changed, 56 insertions, 25 deletions
diff --git a/include/klee/ADT/Ref.h b/include/klee/ADT/Ref.h index 7267f894..a40ed238 100644 --- a/include/klee/ADT/Ref.h +++ b/include/klee/ADT/Ref.h @@ -29,12 +29,7 @@ #ifndef KLEE_REF_H #define KLEE_REF_H -#include "llvm/Support/Casting.h" -using llvm::isa; -using llvm::cast; -using llvm::cast_or_null; -using llvm::dyn_cast; -using llvm::dyn_cast_or_null; +#include "klee/Support/Casting.h" #include <cassert> #include <iosfwd> // FIXME: Remove this when LLVM 4.0 support is removed!!! diff --git a/include/klee/Support/Casting.h b/include/klee/Support/Casting.h new file mode 100644 index 00000000..865218a0 --- /dev/null +++ b/include/klee/Support/Casting.h @@ -0,0 +1,35 @@ +//===-- Casting.h -----------------------------------------------*- C++ -*-===// +// +// The KLEE Symbolic Virtual Machine +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef KLEE_CASTING_H +#define KLEE_CASTING_H + +#include "klee/Config/Version.h" + +#include "llvm/Support/Casting.h" + +namespace klee { + +using llvm::cast; +using llvm::cast_or_null; +using llvm::dyn_cast; +using llvm::dyn_cast_or_null; +using llvm::isa; +#if LLVM_VERSION_CODE >= LLVM_VERSION(9, 0) +using llvm::isa_and_nonnull; +#else +template <typename... X, typename Y> +inline bool isa_and_nonnull(const Y &value) { + return value && isa<X...>(value); +} +#endif + +} // namespace klee + +#endif /* KLEE_CASTING_H */ \ No newline at end of file diff --git a/lib/Core/ExecutionState.cpp b/lib/Core/ExecutionState.cpp index 97f97a8b..47a3b3c6 100644 --- a/lib/Core/ExecutionState.cpp +++ b/lib/Core/ExecutionState.cpp @@ -16,6 +16,7 @@ #include "klee/Module/InstructionInfoTable.h" #include "klee/Module/KInstruction.h" #include "klee/Module/KModule.h" +#include "klee/Support/Casting.h" #include "klee/Support/OptionCategories.h" #include "llvm/IR/Function.h" @@ -342,7 +343,7 @@ void ExecutionState::dumpStack(llvm::raw_ostream &out) const { out << ai->getName().str(); // XXX should go through function ref<Expr> value = sf.locals[sf.kf->getArgRegister(index++)].value; - if (value.get() && isa<ConstantExpr>(value)) + if (isa_and_nonnull<ConstantExpr>(value)) out << "=" << value; } out << ")"; diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 13c25076..a0df89f0 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -25,6 +25,7 @@ #include "TimingSolver.h" #include "UserSearcher.h" +#include "klee/ADT/KTest.h" #include "klee/ADT/RNG.h" #include "klee/Config/Version.h" #include "klee/Core/Interpreter.h" @@ -34,20 +35,20 @@ #include "klee/Expr/ExprPPrinter.h" #include "klee/Expr/ExprSMTLIBPrinter.h" #include "klee/Expr/ExprUtil.h" -#include "klee/Solver/Common.h" -#include "klee/ADT/KTest.h" -#include "klee/Support/OptionCategories.h" -#include "klee/Statistics/TimerStatIncrementer.h" #include "klee/Module/Cell.h" #include "klee/Module/InstructionInfoTable.h" #include "klee/Module/KInstruction.h" #include "klee/Module/KModule.h" +#include "klee/Solver/Common.h" #include "klee/Solver/SolverCmdLine.h" #include "klee/Solver/SolverStats.h" +#include "klee/Statistics/TimerStatIncrementer.h" +#include "klee/Support/Casting.h" #include "klee/Support/ErrorHandling.h" #include "klee/Support/FileHandling.h" #include "klee/Support/FloatEvaluation.h" #include "klee/Support/ModuleUtil.h" +#include "klee/Support/OptionCategories.h" #include "klee/System/MemoryUsage.h" #include "klee/System/Time.h" @@ -1651,7 +1652,7 @@ ref<klee::ConstantExpr> Executor::getEhTypeidFor(ref<Expr> type_info) { void Executor::executeCall(ExecutionState &state, KInstruction *ki, Function *f, std::vector<ref<Expr>> &arguments) { Instruction *i = ki->inst; - if (i && isa<DbgInfoIntrinsic>(i)) + if (isa_and_nonnull<DbgInfoIntrinsic>(i)) return; if (f && f->isDeclaration()) { switch (f->getIntrinsicID()) { diff --git a/lib/Core/SpecialFunctionHandler.cpp b/lib/Core/SpecialFunctionHandler.cpp index 153619d3..f101a085 100644 --- a/lib/Core/SpecialFunctionHandler.cpp +++ b/lib/Core/SpecialFunctionHandler.cpp @@ -21,6 +21,7 @@ #include "klee/Module/KInstruction.h" #include "klee/Module/KModule.h" #include "klee/Solver/SolverCmdLine.h" +#include "klee/Support/Casting.h" #include "klee/Support/Debug.h" #include "klee/Support/ErrorHandling.h" #include "klee/Support/OptionCategories.h" @@ -471,8 +472,8 @@ void SpecialFunctionHandler::handleEhUnwindRaiseExceptionImpl( return; } - if (state.unwindingInformation && - isa<SearchPhaseUnwindingInformation>(state.unwindingInformation.get())) { + if (isa_and_nonnull<SearchPhaseUnwindingInformation>( + state.unwindingInformation.get())) { executor.terminateStateOnExecError( state, "Internal error: Unwinding restarted during an ongoing search phase"); diff --git a/lib/Expr/ArrayExprOptimizer.cpp b/lib/Expr/ArrayExprOptimizer.cpp index a2367506..b329b1ec 100644 --- a/lib/Expr/ArrayExprOptimizer.cpp +++ b/lib/Expr/ArrayExprOptimizer.cpp @@ -16,11 +16,11 @@ #include "klee/Expr/Assignment.h" #include "klee/Expr/AssignmentGenerator.h" #include "klee/Expr/ExprBuilder.h" -#include "klee/Support/OptionCategories.h" +#include "klee/Support/Casting.h" #include "klee/Support/ErrorHandling.h" +#include "klee/Support/OptionCategories.h" #include <llvm/ADT/APInt.h> -#include <llvm/Support/Casting.h> #include <llvm/Support/CommandLine.h> #include <algorithm> diff --git a/lib/Expr/ArrayExprRewriter.cpp b/lib/Expr/ArrayExprRewriter.cpp index 2732cdc4..780301c7 100644 --- a/lib/Expr/ArrayExprRewriter.cpp +++ b/lib/Expr/ArrayExprRewriter.cpp @@ -11,9 +11,9 @@ #include "klee/ADT/BitArray.h" #include "klee/Expr/ArrayExprVisitor.h" +#include "klee/Support/Casting.h" #include <llvm/ADT/APInt.h> -#include <llvm/Support/Casting.h> #include <cassert> #include <cstdint> diff --git a/lib/Expr/AssignmentGenerator.cpp b/lib/Expr/AssignmentGenerator.cpp index e7d2eb61..be77765e 100644 --- a/lib/Expr/AssignmentGenerator.cpp +++ b/lib/Expr/AssignmentGenerator.cpp @@ -10,11 +10,11 @@ #include "klee/Expr/AssignmentGenerator.h" #include "klee/Expr/Assignment.h" +#include "klee/Support/Casting.h" #include "klee/Support/ErrorHandling.h" #include "klee/klee.h" #include <llvm/ADT/APInt.h> -#include <llvm/Support/Casting.h> #include <llvm/Support/raw_ostream.h> #include <cassert> diff --git a/lib/Expr/ExprSMTLIBPrinter.cpp b/lib/Expr/ExprSMTLIBPrinter.cpp index 8b651b04..57af2a85 100644 --- a/lib/Expr/ExprSMTLIBPrinter.cpp +++ b/lib/Expr/ExprSMTLIBPrinter.cpp @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// #include "klee/Expr/ExprSMTLIBPrinter.h" +#include "klee/Support/Casting.h" -#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" diff --git a/lib/Module/FunctionAlias.cpp b/lib/Module/FunctionAlias.cpp index 2ab8cfd4..3fb0ec9a 100644 --- a/lib/Module/FunctionAlias.cpp +++ b/lib/Module/FunctionAlias.cpp @@ -9,8 +9,9 @@ #include "Passes.h" -#include "klee/Support/OptionCategories.h" +#include "klee/Support/Casting.h" #include "klee/Support/ErrorHandling.h" +#include "klee/Support/OptionCategories.h" #include "llvm/IR/GlobalAlias.h" #include "llvm/Support/CommandLine.h" @@ -221,13 +222,10 @@ bool FunctionAliasPass::tryToReplace(GlobalValue *match, } bool FunctionAliasPass::isFunctionOrGlobalFunctionAlias(const GlobalValue *gv) { - if (gv == nullptr) - return false; - - if (isa<Function>(gv)) + if (isa_and_nonnull<Function>(gv)) return true; - if (const auto *ga = dyn_cast<GlobalAlias>(gv)) { + if (const auto *ga = dyn_cast_or_null<GlobalAlias>(gv)) { const auto *aliasee = dyn_cast<GlobalValue>(ga->getAliasee()); if (!aliasee) { // check if GlobalAlias is alias bitcast |