From bda35257b64545870c6de5fe8aba573ef82945d9 Mon Sep 17 00:00:00 2001 From: Julian Büning Date: Sat, 10 Oct 2020 15:13:40 +0200 Subject: Casting.h: isa_and_nonnull<> --- include/klee/ADT/Ref.h | 7 +------ include/klee/Support/Casting.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 include/klee/Support/Casting.h (limited to 'include') 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 #include // 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 +inline bool isa_and_nonnull(const Y &value) { + return value && isa(value); +} +#endif + +} // namespace klee + +#endif /* KLEE_CASTING_H */ \ No newline at end of file -- cgit 1.4.1