Add an explicit bool operator to SDValue to make it easier to test for

a non-null node. In particular, this makes it easier to use condition
variables with SDValues, etc.

llvm-svn: 212323
This commit is contained in:
Chandler Carruth 2014-07-04 08:11:38 +00:00
parent 7c163a44aa
commit 872d592326
1 changed files with 3 additions and 0 deletions

View File

@ -142,6 +142,9 @@ public:
bool operator<(const SDValue &O) const { bool operator<(const SDValue &O) const {
return std::tie(Node, ResNo) < std::tie(O.Node, O.ResNo); return std::tie(Node, ResNo) < std::tie(O.Node, O.ResNo);
} }
LLVM_EXPLICIT operator bool() const {
return Node != nullptr;
}
SDValue getValue(unsigned R) const { SDValue getValue(unsigned R) const {
return SDValue(Node, R); return SDValue(Node, R);