diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-10-14 23:21:06 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-10-14 23:21:06 +0000 |
commit | 46c6371141c050e1599ba86d9d84447be3b4c786 (patch) | |
tree | c6d7fd808e591195a274b8397c207fda217c3553 /include/llvm/Value.h | |
parent | c649458d184f07e00d009d7b15939ed1e494e1b1 (diff) | |
download | external_llvm-46c6371141c050e1599ba86d9d84447be3b4c786.zip external_llvm-46c6371141c050e1599ba86d9d84447be3b4c786.tar.gz external_llvm-46c6371141c050e1599ba86d9d84447be3b4c786.tar.bz2 |
Cast NULL when requested.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@803 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Value.h')
-rw-r--r-- | include/llvm/Value.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 8245f8f..ea17c3e 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<X> - 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<const Instruction>(myVal)->getParent() // template <class X, class Y> inline X *cast(Y Val) { - assert(isa<X>(Val) && "Invalid cast argument type!"); + assert((Val == 0 || isa<X>(Val)) && "Invalid cast argument type!"); return (X*)(real_type<Y>::Type)Val; } |