[Lldb-commits] [lldb] r239419 - Rename `FileSpec::IsRelativeToCurrentWorkingDirectory` to `IsRelative`.

Chaoren Lin chaorenl at google.com
Tue Jun 9 10:54:27 PDT 2015


Author: chaoren
Date: Tue Jun  9 12:54:27 2015
New Revision: 239419

URL: http://llvm.org/viewvc/llvm-project?rev=239419&view=rev
Log:
Rename `FileSpec::IsRelativeToCurrentWorkingDirectory` to `IsRelative`.

Summary:
`IsRelativeToCurrentWorkingDirectory` was misleading, because relative paths
are sometimes appended to other directories, not just the cwd. Plus, the new
name is shorter. Also added `IsAbsolute` for completeness.

Reviewers: clayborg, ovyalov

Reviewed By: ovyalov

Subscribers: tberghammer, lldb-commits

Differential Revision: http://reviews.llvm.org/D10262

Modified:
    lldb/trunk/include/lldb/Host/FileSpec.h
    lldb/trunk/source/Host/common/FileSpec.cpp
    lldb/trunk/source/Host/linux/HostInfoLinux.cpp
    lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Target/ProcessLaunchInfo.cpp
    lldb/trunk/source/Target/TargetList.cpp

Modified: lldb/trunk/include/lldb/Host/FileSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSpec.h?rev=239419&r1=239418&r2=239419&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/FileSpec.h (original)
+++ lldb/trunk/include/lldb/Host/FileSpec.h Tue Jun  9 12:54:27 2015
@@ -365,16 +365,25 @@ public:
     IsSourceImplementationFile () const;
 
     //------------------------------------------------------------------
-    /// Returns true if the filespec represents path that is relative
-    /// path to the current working directory.
+    /// Returns true if the filespec represents a relative path.
     ///
     /// @return
-    ///     \b true if the filespec represents a current working
-    ///     directory relative path, \b false otherwise.
+    ///     \b true if the filespec represents a relative path,
+    ///     \b false otherwise.
     //------------------------------------------------------------------
     bool
-    IsRelativeToCurrentWorkingDirectory () const;
-    
+    IsRelative() const;
+
+    //------------------------------------------------------------------
+    /// Returns true if the filespec represents an absolute path.
+    ///
+    /// @return
+    ///     \b true if the filespec represents an absolute path,
+    ///     \b false otherwise.
+    //------------------------------------------------------------------
+    bool
+    IsAbsolute() const;
+
     TimeValue
     GetModificationTime () const;
 

Modified: lldb/trunk/source/Host/common/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=239419&r1=239418&r2=239419&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSpec.cpp (original)
+++ lldb/trunk/source/Host/common/FileSpec.cpp Tue Jun  9 12:54:27 2015
@@ -1484,7 +1484,7 @@ FileSpec::IsSourceImplementationFile ()
 }
 
 bool
-FileSpec::IsRelativeToCurrentWorkingDirectory () const
+FileSpec::IsRelative() const
 {
     const char *dir = m_directory.GetCString();
     llvm::StringRef directory(dir ? dir : "");
@@ -1519,3 +1519,9 @@ FileSpec::IsRelativeToCurrentWorkingDire
     }
     return false;
 }
+
+bool
+FileSpec::IsAbsolute() const
+{
+    return !FileSpec::IsRelative();
+}

Modified: lldb/trunk/source/Host/linux/HostInfoLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/HostInfoLinux.cpp?rev=239419&r1=239418&r2=239419&view=diff
==============================================================================
--- lldb/trunk/source/Host/linux/HostInfoLinux.cpp (original)
+++ lldb/trunk/source/Host/linux/HostInfoLinux.cpp Tue Jun  9 12:54:27 2015
@@ -225,7 +225,7 @@ bool
 HostInfoLinux::ComputeSupportExeDirectory(FileSpec &file_spec)
 {
     if (HostInfoPosix::ComputeSupportExeDirectory(file_spec) &&
-            !file_spec.IsRelativeToCurrentWorkingDirectory() &&
+            file_spec.IsAbsolute() &&
             file_spec.Exists())
         return true;
     file_spec.GetDirectory() = GetProgramFileSpec().GetDirectory();

Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp?rev=239419&r1=239418&r2=239419&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp Tue Jun  9 12:54:27 2015
@@ -215,7 +215,7 @@ PlatformAndroid::GetFile (const FileSpec
         return PlatformLinux::GetFile(source, destination);
 
     FileSpec source_spec (source.GetPath (false), false, FileSpec::ePathSyntaxPosix);
-    if (source_spec.IsRelativeToCurrentWorkingDirectory ())
+    if (source_spec.IsRelative())
         source_spec = GetRemoteWorkingDirectory ().CopyByAppendingPathComponent (source_spec.GetCString (false));
 
     AdbClient adb (m_device_id);
@@ -232,7 +232,7 @@ PlatformAndroid::PutFile (const FileSpec
         return PlatformLinux::PutFile (source, destination, uid, gid);
 
     FileSpec destination_spec (destination.GetPath (false), false, FileSpec::ePathSyntaxPosix);
-    if (destination_spec.IsRelativeToCurrentWorkingDirectory ())
+    if (destination_spec.IsRelative())
         destination_spec = GetRemoteWorkingDirectory ().CopyByAppendingPathComponent (destination_spec.GetCString (false));
 
     AdbClient adb (m_device_id);

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp?rev=239419&r1=239418&r2=239419&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp Tue Jun  9 12:54:27 2015
@@ -519,14 +519,14 @@ DWARFDebugLine::ParseSupportFiles (const
             debug_line_data.Skip_LEB128(&offset); // Skip mod_time
             debug_line_data.Skip_LEB128(&offset); // Skip length
 
-            if (file_spec.IsRelativeToCurrentWorkingDirectory())
+            if (file_spec.IsRelative())
             {
                 if (0 < dir_idx && dir_idx < include_directories.size())
                 {
                     const FileSpec &dir = include_directories[dir_idx];
                     file_spec.PrependPathComponent(dir);
                 }
-                if (file_spec.IsRelativeToCurrentWorkingDirectory())
+                if (file_spec.IsRelative())
                     file_spec.PrependPathComponent(cu_comp_dir);
             }
             std::string remapped_file;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=239419&r1=239418&r2=239419&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Jun  9 12:54:27 2015
@@ -977,7 +977,7 @@ SymbolFileDWARF::ParseCompileUnit (DWARF
                         {
                             // If we have a full path to the compile unit, we don't need to resolve
                             // the file.  This can be expensive e.g. when the source files are NFS mounted.
-                            if (cu_file_spec.IsRelativeToCurrentWorkingDirectory())
+                            if (cu_file_spec.IsRelative())
                             {
                                 // DWARF2/3 suggests the form hostname:pathname for compilation directory.
                                 // Remove the host part if present.

Modified: lldb/trunk/source/Target/ProcessLaunchInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ProcessLaunchInfo.cpp?rev=239419&r1=239418&r2=239419&view=diff
==============================================================================
--- lldb/trunk/source/Target/ProcessLaunchInfo.cpp (original)
+++ lldb/trunk/source/Target/ProcessLaunchInfo.cpp Tue Jun  9 12:54:27 2015
@@ -423,7 +423,7 @@ ProcessLaunchInfo::ConvertArgumentsForLa
                 // is a relative path.
                 const char *argv0 = argv[0];
                 FileSpec arg_spec(argv0, false);
-                if (arg_spec.IsRelativeToCurrentWorkingDirectory())
+                if (arg_spec.IsRelative())
                 {
                     // We have a relative path to our executable which may not work if
                     // we just try to run "a.out" (without it being converted to "./a.out")

Modified: lldb/trunk/source/Target/TargetList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=239419&r1=239418&r2=239419&view=diff
==============================================================================
--- lldb/trunk/source/Target/TargetList.cpp (original)
+++ lldb/trunk/source/Target/TargetList.cpp Tue Jun  9 12:54:27 2015
@@ -412,7 +412,7 @@ TargetList::CreateTargetInternal (Debugg
         if (file.GetFileType() == FileSpec::eFileTypeDirectory)
             user_exe_path_is_bundle = true;
 
-        if (file.IsRelativeToCurrentWorkingDirectory() && user_exe_path)
+        if (file.IsRelative() && user_exe_path)
         {
             // Ignore paths that start with "./" and "../"
             if (!((user_exe_path[0] == '.' && user_exe_path[1] == '/') ||





More information about the lldb-commits mailing list