[Lldb-commits] [lldb] r139488 - in /lldb/trunk: include/lldb/Host/FileSpec.h source/Host/common/FileSpec.cpp

Greg Clayton gclayton at apple.com
Sun Sep 11 21:00:42 PDT 2011


Author: gclayton
Date: Sun Sep 11 23:00:42 2011
New Revision: 139488

URL: http://llvm.org/viewvc/llvm-project?rev=139488&view=rev
Log:
Changed to using an "operator bool" instead of an "operator void*"
and avoid returning a pointer to the current object. In the new 
"operator bool" implementation, check the filename object first 
since many times we have FileSpec objects with a filename, yet no
directory.


Modified:
    lldb/trunk/include/lldb/Host/FileSpec.h
    lldb/trunk/source/Host/common/FileSpec.cpp

Modified: lldb/trunk/include/lldb/Host/FileSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSpec.h?rev=139488&r1=139487&r2=139488&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/FileSpec.h (original)
+++ lldb/trunk/include/lldb/Host/FileSpec.h Sun Sep 11 23:00:42 2011
@@ -180,8 +180,7 @@
     ///     A pointer to this object if either the directory or filename
     ///     is valid, NULL otherwise.
     //------------------------------------------------------------------
-    operator
-    void* () const;
+    operator bool() const;
 
     //------------------------------------------------------------------
     /// Logical NOT operator.

Modified: lldb/trunk/source/Host/common/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=139488&r1=139487&r2=139488&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSpec.cpp (original)
+++ lldb/trunk/source/Host/common/FileSpec.cpp Sun Sep 11 23:00:42 2011
@@ -352,10 +352,9 @@
 //  if (file_spec)
 //  {}
 //----------------------------------------------------------------------
-FileSpec::operator
-void*() const
+FileSpec::operator bool() const
 {
-    return (m_directory || m_filename) ? const_cast<FileSpec*>(this) : NULL;
+    return m_filename || m_directory;
 }
 
 //----------------------------------------------------------------------





More information about the lldb-commits mailing list