diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-09-22 01:24:18 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-09-22 01:24:18 +0000 |
commit | f5091b476c46333ecfcf095cd2e422e9748e9546 (patch) | |
tree | 91433aeae3998d8da764592eb5bdb129aea932c7 | |
parent | 3bbdddf527c762085802544665d6e77471ea035b (diff) | |
download | external_llvm-f5091b476c46333ecfcf095cd2e422e9748e9546.zip external_llvm-f5091b476c46333ecfcf095cd2e422e9748e9546.tar.gz external_llvm-f5091b476c46333ecfcf095cd2e422e9748e9546.tar.bz2 |
Casting: assert that pointer arguments to isa<> are non-null.
This silences several analyzer warnings within LLVM, and provides a slightly
nicer crash experience when someone calls isa<>, cast<>, or dyn_cast<> with
a null pointer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164439 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Support/Casting.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h index 3aab436..d35febb 100644 --- a/include/llvm/Support/Casting.h +++ b/include/llvm/Support/Casting.h @@ -65,18 +65,21 @@ template <typename To, typename From> struct isa_impl_cl<To, const From> { template <typename To, typename From> struct isa_impl_cl<To, From*> { static inline bool doit(const From *Val) { + assert(Val && "isa<> used on a null pointer"); return isa_impl<To, From>::doit(*Val); } }; template <typename To, typename From> struct isa_impl_cl<To, const From*> { static inline bool doit(const From *Val) { + assert(Val && "isa<> used on a null pointer"); return isa_impl<To, From>::doit(*Val); } }; template <typename To, typename From> struct isa_impl_cl<To, const From*const> { static inline bool doit(const From *Val) { + assert(Val && "isa<> used on a null pointer"); return isa_impl<To, From>::doit(*Val); } }; |