From f5091b476c46333ecfcf095cd2e422e9748e9546 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Sat, 22 Sep 2012 01:24:18 +0000 Subject: [PATCH] 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 --- include/llvm/Support/Casting.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h index 3aab4367f5b..d35febbe6d8 100644 --- a/include/llvm/Support/Casting.h +++ b/include/llvm/Support/Casting.h @@ -65,18 +65,21 @@ template struct isa_impl_cl { template struct isa_impl_cl { static inline bool doit(const From *Val) { + assert(Val && "isa<> used on a null pointer"); return isa_impl::doit(*Val); } }; template struct isa_impl_cl { static inline bool doit(const From *Val) { + assert(Val && "isa<> used on a null pointer"); return isa_impl::doit(*Val); } }; template struct isa_impl_cl { static inline bool doit(const From *Val) { + assert(Val && "isa<> used on a null pointer"); return isa_impl::doit(*Val); } }; -- 2.34.1