[llvm-commits] [llvm] r59890 - /llvm/trunk/include/llvm/Support/Casting.h

Scott Michel scottm at aero.org
Sat Nov 22 15:49:27 PST 2008


Author: pingbak
Date: Sat Nov 22 17:49:26 2008
New Revision: 59890

URL: http://llvm.org/viewvc/llvm-project?rev=59890&view=rev
Log:
Check for NULL before traversing the isa<> type hierarchy checking with a
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.

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=59890&r1=59889&r2=59890&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/Casting.h (original)
+++ llvm/trunk/include/llvm/Support/Casting.h Sat Nov 22 17:49:26 2008
@@ -98,7 +98,7 @@
 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));
   }
 };
 





More information about the llvm-commits mailing list