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.

llvm-svn: 139488
This commit is contained in:
Greg Clayton 2011-09-12 04:00:42 +00:00
parent 24756648e5
commit 6372d1cda2
2 changed files with 3 additions and 5 deletions

View File

@ -180,8 +180,7 @@ public:
/// A pointer to this object if either the directory or filename
/// is valid, NULL otherwise.
//------------------------------------------------------------------
operator
void* () const;
operator bool() const;
//------------------------------------------------------------------
/// Logical NOT operator.

View File

@ -352,10 +352,9 @@ FileSpec::SetFile (const char *pathname, bool resolve)
// 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;
}
//----------------------------------------------------------------------