diff options
author | Julian Büning <julian.buening@rwth-aachen.de> | 2020-10-10 15:13:06 +0200 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2020-11-12 10:13:54 +0000 |
commit | c763a4087f1d8fa4dbdfb9c8f30d545cdb66a0aa (patch) | |
tree | 5d40c27ecfb16230aa3e714a3e7690b44b322860 /include/klee/ADT | |
parent | acdb9a692d9eee8dd102befa4e101bfa5f028b0e (diff) | |
download | klee-c763a4087f1d8fa4dbdfb9c8f30d545cdb66a0aa.tar.gz |
Ref: implement operator bool()
Diffstat (limited to 'include/klee/ADT')
-rw-r--r-- | include/klee/ADT/Ref.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/include/klee/ADT/Ref.h b/include/klee/ADT/Ref.h index 92fd1740..7267f894 100644 --- a/include/klee/ADT/Ref.h +++ b/include/klee/ADT/Ref.h @@ -217,6 +217,7 @@ public: } bool isNull() const { return ptr == nullptr; } + explicit operator bool() const noexcept { return !isNull(); } // assumes non-null arguments int compare(const ref &rhs) const { @@ -245,12 +246,12 @@ inline std::stringstream &operator<<(std::stringstream &os, const ref<T> &e) { } // end namespace klee namespace llvm { - // simplify_type implementation for ref<>, which allows dyn_cast from on a - // ref<> to apply to the wrapper type. Conceptually the result of such a - // dyn_cast should probably be a ref of the casted type, but that breaks the - // idiom of initializing a variable to the result of a dyn_cast inside an if - // condition, or we would have to implement operator(bool) for ref<> with - // isNull semantics, which doesn't seem like a good idea. +// simplify_type implementation for ref<>, which allows dyn_cast on a +// ref<> to apply to the wrapper type. Conceptually the result of such a +// dyn_cast should probably be a ref of the casted type, which historically +// was breaking the idiom of initializing a variable to the result of a dyn_cast +// inside an if condition, as ref<> did not have an operator bool() with isNull +// semantics. template<typename T> struct simplify_type<const ::klee::ref<T> > { using SimpleType = T *; |