[Lldb-commits] [lldb] r124231 - /lldb/trunk/source/Core/FileSpec.cpp

Greg Clayton gclayton at apple.com
Tue Jan 25 13:32:01 PST 2011


Author: gclayton
Date: Tue Jan 25 15:32:01 2011
New Revision: 124231

URL: http://llvm.org/viewvc/llvm-project?rev=124231&view=rev
Log:
http://llvm.org/bugs/show_bug.cgi?id=9053

Fixed bug reported by Ken Ryall.


Modified:
    lldb/trunk/source/Core/FileSpec.cpp

Modified: lldb/trunk/source/Core/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=124231&r1=124230&r2=124231&view=diff
==============================================================================
--- lldb/trunk/source/Core/FileSpec.cpp (original)
+++ lldb/trunk/source/Core/FileSpec.cpp Tue Jan 25 15:32:01 2011
@@ -497,29 +497,33 @@
 {
     if (!m_directory)
     {
-        const std::string file_str (m_filename.AsCString());
-        llvm::sys::Path path = llvm::sys::Program::FindProgramByName (file_str);
-        const std::string &path_str = path.str();
-        llvm::StringRef dir_ref = llvm::sys::path::parent_path(path_str);
-        //llvm::StringRef dir_ref = path.getDirname();
-        if (! dir_ref.empty())
+        const char *file_cstr = m_filename.GetCString();
+        if (file_cstr)
         {
-            // FindProgramByName returns "." if it can't find the file.
-            if (strcmp (".", dir_ref.data()) == 0)
-                return false;
-
-            m_directory.SetCString (dir_ref.data());
-            if (Exists())
-                return true;
-            else
+            const std::string file_str (file_cstr);
+            llvm::sys::Path path = llvm::sys::Program::FindProgramByName (file_str);
+            const std::string &path_str = path.str();
+            llvm::StringRef dir_ref = llvm::sys::path::parent_path(path_str);
+            //llvm::StringRef dir_ref = path.getDirname();
+            if (! dir_ref.empty())
             {
-                // If FindProgramByName found the file, it returns the directory + filename in its return results.
-                // We need to separate them.
-                FileSpec tmp_file (dir_ref.data(), false);
-                if (tmp_file.Exists())
-                {
-                    m_directory = tmp_file.m_directory;
+                // FindProgramByName returns "." if it can't find the file.
+                if (strcmp (".", dir_ref.data()) == 0)
+                    return false;
+
+                m_directory.SetCString (dir_ref.data());
+                if (Exists())
                     return true;
+                else
+                {
+                    // If FindProgramByName found the file, it returns the directory + filename in its return results.
+                    // We need to separate them.
+                    FileSpec tmp_file (dir_ref.data(), false);
+                    if (tmp_file.Exists())
+                    {
+                        m_directory = tmp_file.m_directory;
+                        return true;
+                    }
                 }
             }
         }





More information about the lldb-commits mailing list