[llvm] r186543 - Add an explicit operator bool conversion to DIDescriptor to make

Eric Christopher echristo at gmail.com
Wed Jul 17 15:53:05 PDT 2013


Author: echristo
Date: Wed Jul 17 17:53:05 2013
New Revision: 186543

URL: http://llvm.org/viewvc/llvm-project?rev=186543&view=rev
Log:
Add an explicit operator bool conversion to DIDescriptor to make
it clear what we want to do. Unfortunately the conversion to
pointer operator fires now instead and chasing down all of the
conversions and making them explicit and handled is a large task
so add a FIXME with it.

Modified:
    llvm/trunk/include/llvm/DebugInfo.h

Modified: llvm/trunk/include/llvm/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo.h?rev=186543&r1=186542&r2=186543&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/DebugInfo.h Wed Jul 17 17:53:05 2013
@@ -102,6 +102,13 @@ namespace llvm {
     operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
     MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
 
+    // An explicit operator bool so that we can do testing of DI values
+    // easily.
+    // FIXME: This operator bool isn't actually protecting anything at the
+    // moment due to the conversion operator above making DIDescriptor nodes
+    // implicitly convertable to pointer.
+    LLVM_EXPLICIT operator bool() const { return DbgNode != 0; }
+
     unsigned getTag() const {
       return getUnsignedField(0) & ~LLVMDebugVersionMask;
     }





More information about the llvm-commits mailing list