[llvm-commits] [llvm] r164439 - /llvm/trunk/include/llvm/Support/Casting.h
Jordan Rose
jordan_rose at apple.com
Fri Sep 21 18:24:19 PDT 2012
Author: jrose
Date: Fri Sep 21 20:24:18 2012
New Revision: 164439
URL: http://llvm.org/viewvc/llvm-project?rev=164439&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/Support/Casting.h
Modified: llvm/trunk/include/llvm/Support/Casting.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Casting.h?rev=164439&r1=164438&r2=164439&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Casting.h (original)
+++ llvm/trunk/include/llvm/Support/Casting.h Fri Sep 21 20:24:18 2012
@@ -65,18 +65,21 @@
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);
}
};
More information about the llvm-commits
mailing list