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

llvm-svn: 239419
This commit is contained in:
Chaoren Lin 2015-06-09 17:54:27 +00:00
parent efba7812cc
commit 372e9067a7
8 changed files with 30 additions and 15 deletions

View File

@ -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;

View File

@ -1484,7 +1484,7 @@ FileSpec::IsSourceImplementationFile () const
}
bool
FileSpec::IsRelativeToCurrentWorkingDirectory () const
FileSpec::IsRelative() const
{
const char *dir = m_directory.GetCString();
llvm::StringRef directory(dir ? dir : "");
@ -1519,3 +1519,9 @@ FileSpec::IsRelativeToCurrentWorkingDirectory () const
}
return false;
}
bool
FileSpec::IsAbsolute() const
{
return !FileSpec::IsRelative();
}

View File

@ -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();

View File

@ -215,7 +215,7 @@ PlatformAndroid::GetFile (const FileSpec& source,
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& source,
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);

View File

@ -519,14 +519,14 @@ DWARFDebugLine::ParseSupportFiles (const lldb::ModuleSP &module_sp,
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;

View File

@ -977,7 +977,7 @@ SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx)
{
// 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.

View File

@ -423,7 +423,7 @@ ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell (Error &error,
// 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")

View File

@ -412,7 +412,7 @@ TargetList::CreateTargetInternal (Debugger &debugger,
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] == '/') ||