summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-09-22 01:24:18 +0000
committerJordan Rose <jordan_rose@apple.com>2012-09-22 01:24:18 +0000
commitf5091b476c46333ecfcf095cd2e422e9748e9546 (patch)
tree91433aeae3998d8da764592eb5bdb129aea932c7
parent3bbdddf527c762085802544665d6e77471ea035b (diff)
downloadllvm-f5091b476c46333ecfcf095cd2e422e9748e9546.tar.gz
llvm-f5091b476c46333ecfcf095cd2e422e9748e9546.tar.bz2
llvm-f5091b476c46333ecfcf095cd2e422e9748e9546.tar.xz
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.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h
index 3aab4367f5..d35febbe6d 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);
}
};