[llvm] r212323 - Add an explicit bool operator to SDValue to make it easier to test for

Chandler Carruth chandlerc at gmail.com
Fri Jul 4 01:11:38 PDT 2014


Author: chandlerc
Date: Fri Jul  4 03:11:38 2014
New Revision: 212323

URL: http://llvm.org/viewvc/llvm-project?rev=212323&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h

Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=212323&r1=212322&r2=212323&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Fri Jul  4 03:11:38 2014
@@ -142,6 +142,9 @@ public:
   bool operator<(const SDValue &O) const {
     return std::tie(Node, ResNo) < std::tie(O.Node, O.ResNo);
   }
+  LLVM_EXPLICIT operator bool() const {
+    return Node != nullptr;
+  }
 
   SDValue getValue(unsigned R) const {
     return SDValue(Node, R);





More information about the llvm-commits mailing list