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

Chris Lattner clattner at apple.com
Sat Nov 22 16:07:31 PST 2008


On Nov 22, 2008, at 3:49 PM, Scott Michel wrote:
> 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.

Scott, this should not be needed and is actively bad.  isa should only  
be called on non-null pointers.  When did you encounter this?

-Chris

>
>
> 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));
>   }
> };
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list