From 46c6371141c050e1599ba86d9d84447be3b4c786 Mon Sep 17 00:00:00 2001 From: "Vikram S. Adve" Date: Sun, 14 Oct 2001 23:21:06 +0000 Subject: [PATCH] Cast NULL when requested. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@803 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Value.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; } -- 2.34.1