Check for NULL before traversing the isa<> type hierarchy checking with a
authorScott Michel <scottm@aero.org>
Sat, 22 Nov 2008 23:49:26 +0000 (23:49 +0000)
committerScott Michel <scottm@aero.org>
Sat, 22 Nov 2008 23:49:26 +0000 (23:49 +0000)
NULL-based reference.

Note: Encountered this a few times on Tiger + gcc 4.0.1. Might just be a
platform-specific compiler issue, but it's good defensive programming in any
case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59890 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/Casting.h

index 48988f8a6bb8354c71326e634364acbb2895b4b2..c441626216f16b92dccb57dcee66f7802a01ad2c 100644 (file)
@@ -98,7 +98,7 @@ template<class FromCl>
 struct isa_impl_cl<FromCl*> {
   template<class ToCl>
   static bool isa(FromCl *Val) {
-    return isa_impl_cl<FromCl>::template isa<ToCl>(*Val);
+    return (Val != 0 && isa_impl_cl<FromCl>::template isa<ToCl>(*Val));
   }
 };