summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authortstellar <tstellar@91177308-0d34-0410-b5e6-96231b3b80d8>2012-09-24 15:52:06 +0000
committertstellar <tstellar@91177308-0d34-0410-b5e6-96231b3b80d8>2012-09-24 15:52:06 +0000
commit85ed560b4b38c7d1178dbc84e37f9b6c3d611b6e (patch)
treeaf95ce0f88e2f86cadb6f0a0fb4186fdeb6f6dce /include
parentbf33081abc6a2c9a5d2570257f3a8a6513dbd595 (diff)
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/branches/R600/@164515 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-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);
}
};