diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 8245f8fb350..ea17c3ef2ec 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -193,14 +193,15 @@ inline bool isa(Y Val) { return X::classof(Val); } // cast - Return the argument parameter cast to the specified type. This // casting operator asserts that the type is correct, so it does not return null -// on failure. Used Like this: +// on failure. But it will correctly return NULL when the input is NULL. +// Used Like this: // // cast< Instruction>(myVal)->getParent() // cast(myVal)->getParent() // template inline X *cast(Y Val) { - assert(isa(Val) && "Invalid cast argument type!"); + assert((Val == 0 || isa(Val)) && "Invalid cast argument type!"); return (X*)(real_type::Type)Val; }