X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FValue.h;h=aece4ce2439682c5e052d7ba3358a7962d619694;hb=2a72820b43b94a4da0d51c1533b22ded37fc5c86;hp=255105f28801ebdc749bc4cc7e4cb9b07182bd46;hpb=ef9c23f2812322ae5c5f3140bfbcf92629d7ff47;p=oota-llvm.git diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 255105f2880..aece4ce2439 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -110,6 +110,8 @@ public: inline use_const_iterator use_begin() const { return Uses.begin(); } inline use_iterator use_end() { return Uses.end(); } inline use_const_iterator use_end() const { return Uses.end(); } + inline User *use_back() { return Uses.back(); } + inline const User *use_back() const { return Uses.back(); } inline void use_push_back(User *I) { Uses.push_back(I); } User *use_remove(use_iterator &I); @@ -186,19 +188,24 @@ template class real_type > { typedef X *Type; }; // if (isa(myVal)) { ... } // template -inline bool isa(Y Val) { return X::classof(Val); } +inline bool isa(Y Val) { + assert(Val && "isa(NULL) invoked!"); + 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)) && + "cast() argument of uncompatible type!"); return (X*)(real_type::Type)Val; }