[Lldb-commits] [lldb] 1b4b12a - Revert "[NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute." and follow-ups
Nico Weber via lldb-commits
lldb-commits at lists.llvm.org
Sat Jul 23 09:35:56 PDT 2022
Author: Nico Weber
Date: 2022-07-23T12:35:48-04:00
New Revision: 1b4b12a34022b13b35755d9c941f7f13753e5e96
URL: https://github.com/llvm/llvm-project/commit/1b4b12a34022b13b35755d9c941f7f13753e5e96
DIFF: https://github.com/llvm/llvm-project/commit/1b4b12a34022b13b35755d9c941f7f13753e5e96.diff
LOG: Revert "[NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute." and follow-ups
This reverts commit 9429b67b8e300e638d7828bbcb95585f85c4df4d.
It broke the build on Windows, see comments on https://reviews.llvm.org/D130309
It also reverts these follow-ups:
Revert "Fix buildbot breakage after https://reviews.llvm.org/D130309."
This reverts commit f959d815f4637890ebbacca379f1c38ab47e4e14.
Revert "Fix buildbot breakage after https://reviews.llvm.org/D130309."
This reverts commit 0bbce7a4c2d2bff622bdadd4323f93f5d90e6d24.
Revert "Cache the value for absolute path in FileSpec."
This reverts commit dabe877248b85b34878e75d5510339325ee087d0.
Added:
Modified:
lldb/include/lldb/Utility/FileSpec.h
lldb/source/API/SBFileSpec.cpp
lldb/source/API/SBLaunchInfo.cpp
lldb/source/API/SBPlatform.cpp
lldb/source/API/SBReproducer.cpp
lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
lldb/source/Commands/CommandObjectLog.cpp
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Core/Debugger.cpp
lldb/source/Core/IOHandlerCursesGUI.cpp
lldb/source/Expression/FunctionCaller.cpp
lldb/source/Expression/REPL.cpp
lldb/source/Host/common/FileAction.cpp
lldb/source/Host/common/FileSystem.cpp
lldb/source/Host/common/HostInfoBase.cpp
lldb/source/Host/linux/HostInfoLinux.cpp
lldb/source/Host/macosx/objcxx/Host.mm
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
lldb/source/Host/posix/FileSystemPosix.cpp
lldb/source/Host/posix/HostInfoPosix.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Symbol/Symbol.cpp
lldb/source/Symbol/SymbolContext.cpp
lldb/source/Target/Platform.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/TargetList.cpp
lldb/source/Target/Trace.cpp
lldb/source/Utility/FileSpec.cpp
lldb/tools/lldb-server/lldb-platform.cpp
lldb/tools/lldb-test/lldb-test.cpp
lldb/unittests/Target/FindFileTest.cpp
lldb/unittests/Target/ModuleCacheTest.cpp
lldb/unittests/Utility/FileSpecTest.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h
index 8492c93fd58a1..ec473a2afeec7 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -216,38 +216,29 @@ class FileSpec {
Style GetPathStyle() const;
+ /// Directory string get accessor.
+ ///
+ /// \return
+ /// A reference to the directory string object.
+ ConstString &GetDirectory();
+
/// Directory string const get accessor.
///
/// \return
/// A const reference to the directory string object.
- const ConstString &GetDirectory() const { return m_directory; }
+ ConstString GetDirectory() const;
- /// Directory string set accessor.
+ /// Filename string get accessor.
///
- /// \param[in] directory
- /// The value to replace the directory with.
- void SetDirectory(ConstString directory);
- void SetDirectory(llvm::StringRef directory);
-
- /// Clear the directory in this object.
- void ClearDirectory();
-
+ /// \return
+ /// A reference to the filename string object.
+ ConstString &GetFilename();
/// Filename string const get accessor.
///
/// \return
/// A const reference to the filename string object.
- const ConstString &GetFilename() const { return m_filename; }
-
- /// Filename string set accessor.
- ///
- /// \param[in] filename
- /// The const string to replace the directory with.
- void SetFilename(ConstString filename);
- void SetFilename(llvm::StringRef filename);
-
- /// Clear the filename in this object.
- void ClearFilename();
+ ConstString GetFilename() const;
/// Returns true if the filespec represents an implementation source file
/// (files with a ".c", ".cpp", ".m", ".mm" (many more) extension).
@@ -308,13 +299,7 @@ class FileSpec {
/// concatenated.
std::string GetPath(bool denormalize = true) const;
- /// Get the full path as a ConstString.
- ///
- /// This method should only be used when you need a ConstString or the
- /// const char * from a ConstString to ensure permanent lifetime of C string.
- /// Anyone needing the path temporarily should use the GetPath() method that
- /// returns a std:string.
- ConstString GetPathAsConstString(bool denormalize = true) const;
+ const char *GetCString(bool denormalize = true) const;
/// Extract the full path to the file.
///
@@ -416,24 +401,10 @@ class FileSpec {
// Convenience method for setting the file without changing the style.
void SetFile(llvm::StringRef path);
- /// Called anytime m_directory or m_filename is changed to clear any cached
- /// state in this object.
- void PathWasModified() {
- m_is_resolved = false;
- m_absolute = Absolute::Calculate;
- }
-
- enum class Absolute : uint8_t {
- Calculate,
- Yes,
- No
- };
-
// Member variables
ConstString m_directory; ///< The uniqued directory path
ConstString m_filename; ///< The uniqued filename path
mutable bool m_is_resolved = false; ///< True if this path has been resolved.
- mutable Absolute m_absolute = Absolute::Calculate; ///< Cache absoluteness.
Style m_style; ///< The syntax that this path uses (e.g. Windows / Posix)
};
diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp
index a7df9afc4b8eb..2bec9a7a1e770 100644
--- a/lldb/source/API/SBFileSpec.cpp
+++ b/lldb/source/API/SBFileSpec.cpp
@@ -115,26 +115,26 @@ const char *SBFileSpec::GetDirectory() const {
LLDB_INSTRUMENT_VA(this);
FileSpec directory{*m_opaque_up};
- directory.ClearFilename();
- return directory.GetPathAsConstString().GetCString();
+ directory.GetFilename().Clear();
+ return directory.GetCString();
}
void SBFileSpec::SetFilename(const char *filename) {
LLDB_INSTRUMENT_VA(this, filename);
if (filename && filename[0])
- m_opaque_up->SetFilename(filename);
+ m_opaque_up->GetFilename().SetCString(filename);
else
- m_opaque_up->ClearFilename();
+ m_opaque_up->GetFilename().Clear();
}
void SBFileSpec::SetDirectory(const char *directory) {
LLDB_INSTRUMENT_VA(this, directory);
if (directory && directory[0])
- m_opaque_up->SetDirectory(directory);
+ m_opaque_up->GetDirectory().SetCString(directory);
else
- m_opaque_up->ClearDirectory();
+ m_opaque_up->GetDirectory().Clear();
}
uint32_t SBFileSpec::GetPath(char *dst_path, size_t dst_len) const {
diff --git a/lldb/source/API/SBLaunchInfo.cpp b/lldb/source/API/SBLaunchInfo.cpp
index ae191916b49e5..5149feba5e0ba 100644
--- a/lldb/source/API/SBLaunchInfo.cpp
+++ b/lldb/source/API/SBLaunchInfo.cpp
@@ -207,7 +207,7 @@ void SBLaunchInfo::Clear() {
const char *SBLaunchInfo::GetWorkingDirectory() const {
LLDB_INSTRUMENT_VA(this);
- return m_opaque_sp->GetWorkingDirectory().GetPathAsConstString().AsCString();
+ return m_opaque_sp->GetWorkingDirectory().GetCString();
}
void SBLaunchInfo::SetWorkingDirectory(const char *working_dir) {
diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index 2a8e963c15a7c..ba18ba6d187f0 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -354,7 +354,7 @@ const char *SBPlatform::GetWorkingDirectory() {
PlatformSP platform_sp(GetSP());
if (platform_sp)
- return platform_sp->GetWorkingDirectory().GetPathAsConstString().AsCString();
+ return platform_sp->GetWorkingDirectory().GetCString();
return nullptr;
}
@@ -547,15 +547,14 @@ SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) {
if (!command)
return Status("invalid shell command (empty)");
- if (shell_command.GetWorkingDirectory() == nullptr) {
- std::string platform_working_dir =
- platform_sp->GetWorkingDirectory().GetPath();
- if (!platform_working_dir.empty())
- shell_command.SetWorkingDirectory(platform_working_dir.c_str());
+ const char *working_dir = shell_command.GetWorkingDirectory();
+ if (working_dir == nullptr) {
+ working_dir = platform_sp->GetWorkingDirectory().GetCString();
+ if (working_dir)
+ shell_command.SetWorkingDirectory(working_dir);
}
return platform_sp->RunShellCommand(
- shell_command.m_opaque_ptr->m_shell, command,
- FileSpec(shell_command.GetWorkingDirectory()),
+ shell_command.m_opaque_ptr->m_shell, command, FileSpec(working_dir),
&shell_command.m_opaque_ptr->m_status,
&shell_command.m_opaque_ptr->m_signo,
&shell_command.m_opaque_ptr->m_output,
diff --git a/lldb/source/API/SBReproducer.cpp b/lldb/source/API/SBReproducer.cpp
index 4a69e2c0a977d..7431b49d3ea62 100644
--- a/lldb/source/API/SBReproducer.cpp
+++ b/lldb/source/API/SBReproducer.cpp
@@ -136,8 +136,9 @@ bool SBReproducer::SetAutoGenerate(bool b) {
const char *SBReproducer::GetPath() {
LLDB_INSTRUMENT()
ConstString path;
+ auto &r = Reproducer::Instance();
if (FileSpec reproducer_path = Reproducer::Instance().GetReproducerPath())
- path = ConstString(reproducer_path.GetPathAsConstString());
+ path = ConstString(r.GetReproducerPath().GetCString());
return path.GetCString();
}
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
index 449ff124f437b..ff044526799c2 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -236,7 +236,7 @@ Searcher::CallbackReturn BreakpointResolverFileLine::SearchCallback(
FileSpec search_file_spec = m_location_spec.GetFileSpec();
const bool is_relative = search_file_spec.IsRelative();
if (is_relative)
- search_file_spec.ClearDirectory();
+ search_file_spec.GetDirectory().Clear();
SourceLocationSpec search_location_spec(
search_file_spec, m_location_spec.GetLine().value_or(0),
m_location_spec.GetColumn(), m_location_spec.GetCheckInlines(),
diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp
index 1b630e1e0bde1..89bc3e0f1b7d9 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -401,7 +401,7 @@ class CommandObjectLogDump : public CommandObjectParsed {
m_options.log_file, flags, lldb::eFilePermissionsFileDefault, false);
if (!file) {
result.AppendErrorWithFormat("Unable to open log file '%s': %s",
- m_options.log_file.GetPath().c_str(),
+ m_options.log_file.GetCString(),
llvm::toString(file.takeError()).c_str());
return false;
}
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index f72d4c7715c6d..3dcb35557bfe2 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -406,7 +406,7 @@ class CommandObjectTargetCreate : public CommandObjectParsed {
if (core_file) {
FileSpec core_file_dir;
- core_file_dir.SetDirectory(core_file.GetDirectory());
+ core_file_dir.GetDirectory() = core_file.GetDirectory();
target_sp->AppendExecutableSearchPaths(core_file_dir);
ProcessSP process_sp(target_sp->CreateProcess(
@@ -4072,7 +4072,7 @@ class CommandObjectTargetSymbolsAdd : public CommandObjectParsed {
if (!module_spec.GetUUID().IsValid()) {
if (!module_spec.GetFileSpec() && !module_spec.GetPlatformFileSpec())
- module_spec.GetFileSpec().SetFilename(symbol_fspec.GetFilename());
+ module_spec.GetFileSpec().GetFilename() = symbol_fspec.GetFilename();
}
// Now module_spec represents a symbol file for a module that might exist
@@ -4136,7 +4136,7 @@ class CommandObjectTargetSymbolsAdd : public CommandObjectParsed {
break;
// Replace basename with one fewer extension
- module_spec.GetFileSpec().SetFilename(filename_no_extension);
+ module_spec.GetFileSpec().GetFilename() = filename_no_extension;
target->GetImages().FindModules(module_spec, matching_modules);
}
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index f5d13b1f93da2..62857c181af89 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -302,7 +302,7 @@ void Debugger::SetPrompt(llvm::StringRef p) {
llvm::StringRef Debugger::GetReproducerPath() const {
auto &r = repro::Reproducer::Instance();
- return r.GetReproducerPath().GetPathAsConstString().AsCString();
+ return r.GetReproducerPath().GetCString();
}
const FormatEntity::Entry *Debugger::GetThreadFormat() const {
diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 5fe2726b7e6be..0151255631bf8 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -3170,7 +3170,7 @@ class TargetCreateFormDelegate : public FormDelegate {
FileSpec core_file_spec = m_core_file_field->GetResolvedFileSpec();
FileSpec core_file_directory_spec;
- core_file_directory_spec.SetDirectory(core_file_spec.GetDirectory());
+ core_file_directory_spec.GetDirectory() = core_file_spec.GetDirectory();
target_sp->AppendExecutableSearchPaths(core_file_directory_spec);
ProcessSP process_sp(target_sp->CreateProcess(
diff --git a/lldb/source/Expression/FunctionCaller.cpp b/lldb/source/Expression/FunctionCaller.cpp
index 980cb801f55b7..307bed1ee3fd0 100644
--- a/lldb/source/Expression/FunctionCaller.cpp
+++ b/lldb/source/Expression/FunctionCaller.cpp
@@ -98,10 +98,10 @@ bool FunctionCaller::WriteFunctionWrapper(
if (jit_module_sp) {
ConstString const_func_name(FunctionName());
FileSpec jit_file;
- jit_file.SetFilename(const_func_name);
+ jit_file.GetFilename() = const_func_name;
jit_module_sp->SetFileSpecAndObjectName(jit_file, ConstString());
m_jit_module_wp = jit_module_sp;
- process->GetTarget().GetImages().Append(jit_module_sp,
+ process->GetTarget().GetImages().Append(jit_module_sp,
true /* notify */);
}
}
diff --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp
index 36a21de683960..d7582af9b2eab 100644
--- a/lldb/source/Expression/REPL.cpp
+++ b/lldb/source/Expression/REPL.cpp
@@ -58,7 +58,7 @@ std::string REPL::GetSourcePath() {
ConstString file_basename = GetSourceFileBasename();
FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir();
if (tmpdir_file_spec) {
- tmpdir_file_spec.SetFilename(file_basename);
+ tmpdir_file_spec.GetFilename() = file_basename;
m_repl_source_path = tmpdir_file_spec.GetPath();
} else {
tmpdir_file_spec = FileSpec("/tmp");
diff --git a/lldb/source/Host/common/FileAction.cpp b/lldb/source/Host/common/FileAction.cpp
index f980d3224640e..e399c7ec47cd5 100644
--- a/lldb/source/Host/common/FileAction.cpp
+++ b/lldb/source/Host/common/FileAction.cpp
@@ -25,9 +25,7 @@ void FileAction::Clear() {
m_file_spec.Clear();
}
-llvm::StringRef FileAction::GetPath() const {
- return m_file_spec.GetPathAsConstString().AsCString();
-}
+llvm::StringRef FileAction::GetPath() const { return m_file_spec.GetCString(); }
const FileSpec &FileAction::GetFileSpec() const { return m_file_spec; }
@@ -83,7 +81,7 @@ void FileAction::Dump(Stream &stream) const {
break;
case eFileActionOpen:
stream.Printf("open fd %d with '%s', OFLAGS = 0x%x", m_fd,
- m_file_spec.GetPath().c_str(), m_arg);
+ m_file_spec.GetCString(), m_arg);
break;
}
}
diff --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp
index 23cf3c43a40a2..501062f99a539 100644
--- a/lldb/source/Host/common/FileSystem.cpp
+++ b/lldb/source/Host/common/FileSystem.cpp
@@ -267,7 +267,7 @@ void FileSystem::Resolve(FileSpec &file_spec) {
// Update the FileSpec with the resolved path.
if (file_spec.GetFilename().IsEmpty())
- file_spec.SetDirectory(path);
+ file_spec.GetDirectory().SetString(path);
else
file_spec.SetPath(path);
file_spec.SetIsResolved(true);
diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp
index caed8a35de21e..22c0403006e9d 100644
--- a/lldb/source/Host/common/HostInfoBase.cpp
+++ b/lldb/source/Host/common/HostInfoBase.cpp
@@ -242,7 +242,7 @@ bool HostInfoBase::ComputePathRelativeToLibrary(FileSpec &file_spec,
raw_path = (parent_path + dir).str();
LLDB_LOGF(log, "HostInfo::%s() derived the path as: %s", __FUNCTION__,
raw_path.c_str());
- file_spec.SetDirectory(raw_path);
+ file_spec.GetDirectory().SetString(raw_path);
return (bool)file_spec.GetDirectory();
}
@@ -258,7 +258,7 @@ bool HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec) {
g_shlib_dir_helper(lldb_file_spec);
// Remove the filename so that this FileSpec only represents the directory.
- file_spec.SetDirectory(lldb_file_spec.GetDirectory());
+ file_spec.GetDirectory() = lldb_file_spec.GetDirectory();
return (bool)file_spec.GetDirectory();
}
@@ -278,7 +278,7 @@ bool HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec) {
if (llvm::sys::fs::create_directory(temp_file_spec.GetPath()))
return false;
- file_spec.SetDirectory(temp_file_spec.GetPathAsConstString());
+ file_spec.GetDirectory().SetCString(temp_file_spec.GetCString());
return true;
}
@@ -301,7 +301,7 @@ bool HostInfoBase::ComputeGlobalTempFileDirectory(FileSpec &file_spec) {
if (llvm::sys::fs::create_directory(temp_file_spec.GetPath()))
return false;
- file_spec.SetDirectory(temp_file_spec.GetPathAsConstString());
+ file_spec.GetDirectory().SetCString(temp_file_spec.GetCString());
return true;
}
diff --git a/lldb/source/Host/linux/HostInfoLinux.cpp b/lldb/source/Host/linux/HostInfoLinux.cpp
index 0af7a473e1af5..1ed203769bd1b 100644
--- a/lldb/source/Host/linux/HostInfoLinux.cpp
+++ b/lldb/source/Host/linux/HostInfoLinux.cpp
@@ -171,14 +171,14 @@ bool HostInfoLinux::ComputeSupportExeDirectory(FileSpec &file_spec) {
if (HostInfoPosix::ComputeSupportExeDirectory(file_spec) &&
file_spec.IsAbsolute() && FileSystem::Instance().Exists(file_spec))
return true;
- file_spec.SetDirectory(GetProgramFileSpec().GetDirectory());
+ file_spec.GetDirectory() = GetProgramFileSpec().GetDirectory();
return !file_spec.GetDirectory().IsEmpty();
}
bool HostInfoLinux::ComputeSystemPluginsDirectory(FileSpec &file_spec) {
FileSpec temp_file("/usr/lib" LLDB_LIBDIR_SUFFIX "/lldb/plugins");
FileSystem::Instance().Resolve(temp_file);
- file_spec.SetDirectory(temp_file.GetPath());
+ file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str());
return true;
}
@@ -190,9 +190,9 @@ bool HostInfoLinux::ComputeUserPluginsDirectory(FileSpec &file_spec) {
if (xdg_data_home && xdg_data_home[0]) {
std::string user_plugin_dir(xdg_data_home);
user_plugin_dir += "/lldb";
- file_spec.SetDirectory(user_plugin_dir.c_str());
+ file_spec.GetDirectory().SetCString(user_plugin_dir.c_str());
} else
- file_spec.SetDirectory("~/.local/share/lldb");
+ file_spec.GetDirectory().SetCString("~/.local/share/lldb");
return true;
}
diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm
index 5a3098dcab3b2..1c990c8dd16b6 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -211,7 +211,7 @@ repeat with the_window in (get windows)\n\
return error;
}
- darwin_debug_file_spec.SetFilename("darwin-debug");
+ darwin_debug_file_spec.GetFilename().SetCString("darwin-debug");
if (!FileSystem::Instance().Exists(darwin_debug_file_spec)) {
error.SetErrorStringWithFormat(
@@ -236,7 +236,7 @@ repeat with the_window in (get windows)\n\
FileSpec working_dir{launch_info.GetWorkingDirectory()};
if (working_dir)
- command.Printf(R"( --working-dir \"%s\")", working_dir.GetPath().c_str());
+ command.Printf(R"( --working-dir \"%s\")", working_dir.GetCString());
else {
char cwd[PATH_MAX];
if (getcwd(cwd, PATH_MAX))
@@ -1200,14 +1200,13 @@ typedef int (*posix_spawnattr_setarchpref_np_t)(
FileSpec working_dir{launch_info.GetWorkingDirectory()};
if (working_dir) {
// Set the working directory on this thread only
- std::string working_dir_path = working_dir.GetPath();
- if (__pthread_chdir(working_dir_path.c_str()) < 0) {
+ if (__pthread_chdir(working_dir.GetCString()) < 0) {
if (errno == ENOENT) {
error.SetErrorStringWithFormat("No such file or directory: %s",
- working_dir_path.c_str());
+ working_dir.GetCString());
} else if (errno == ENOTDIR) {
error.SetErrorStringWithFormat("Path doesn't name a directory: %s",
- working_dir_path.c_str());
+ working_dir.GetCString());
} else {
error.SetErrorStringWithFormat("An unknown error occurred when "
"changing directory for process "
diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 74a4fb2539436..e038b7abb6d78 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -167,7 +167,8 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
}
}
- file_spec.SetDirectory(raw_path);
+ file_spec.GetDirectory().SetString(
+ llvm::StringRef(raw_path.c_str(), raw_path.size()));
return (bool)file_spec.GetDirectory();
}
@@ -184,7 +185,8 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
raw_path.resize(framework_pos);
raw_path.append("/Headers");
}
- file_spec.SetDirectory(raw_path);
+ file_spec.GetDirectory().SetString(
+ llvm::StringRef(raw_path.c_str(), raw_path.size()));
return true;
}
@@ -202,14 +204,15 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
framework_pos += strlen("LLDB.framework");
raw_path.resize(framework_pos);
raw_path.append("/Resources/PlugIns");
- file_spec.SetDirectory(raw_path);
+ file_spec.GetDirectory().SetString(
+ llvm::StringRef(raw_path.c_str(), raw_path.size()));
return true;
}
bool HostInfoMacOSX::ComputeUserPluginsDirectory(FileSpec &file_spec) {
FileSpec temp_file("~/Library/Application Support/LLDB/PlugIns");
FileSystem::Instance().Resolve(temp_file);
- file_spec.SetDirectory(temp_file.GetPathAsConstString());
+ file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str());
return true;
}
@@ -259,8 +262,8 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
arch_32.SetArchitecture(eArchTypeMachO, cputype & ~(CPU_ARCH_MASK),
cpusubtype32);
- if (cputype == CPU_TYPE_ARM ||
- cputype == CPU_TYPE_ARM64 ||
+ if (cputype == CPU_TYPE_ARM ||
+ cputype == CPU_TYPE_ARM64 ||
cputype == CPU_TYPE_ARM64_32) {
// When running on a watch or tv, report the host os correctly
#if defined(TARGET_OS_TV) && TARGET_OS_TV == 1
diff --git a/lldb/source/Host/posix/FileSystemPosix.cpp b/lldb/source/Host/posix/FileSystemPosix.cpp
index 26a266e86382b..3660f67895a4f 100644
--- a/lldb/source/Host/posix/FileSystemPosix.cpp
+++ b/lldb/source/Host/posix/FileSystemPosix.cpp
@@ -35,7 +35,7 @@ const char *FileSystem::DEV_NULL = "/dev/null";
Status FileSystem::Symlink(const FileSpec &src, const FileSpec &dst) {
Status error;
- if (::symlink(dst.GetPath().c_str(), src.GetPath().c_str()) == -1)
+ if (::symlink(dst.GetCString(), src.GetCString()) == -1)
error.SetErrorToErrno();
return error;
}
@@ -56,8 +56,7 @@ Status FileSystem::Readlink(const FileSpec &src, FileSpec &dst) {
Status FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) {
char resolved_path[PATH_MAX];
if (!src.GetPath(resolved_path, sizeof(resolved_path))) {
- return Status("Couldn't get the canonical path for %s",
- src.GetPath().c_str());
+ return Status("Couldn't get the canonical path for %s", src.GetCString());
}
char real_path[PATH_MAX + 1];
diff --git a/lldb/source/Host/posix/HostInfoPosix.cpp b/lldb/source/Host/posix/HostInfoPosix.cpp
index 8718e90b3241c..63553590dff51 100644
--- a/lldb/source/Host/posix/HostInfoPosix.cpp
+++ b/lldb/source/Host/posix/HostInfoPosix.cpp
@@ -144,7 +144,7 @@ bool HostInfoPosix::ComputeSupportExeDirectory(FileSpec &file_spec) {
bool HostInfoPosix::ComputeHeaderDirectory(FileSpec &file_spec) {
FileSpec temp_file("/opt/local/include/lldb");
- file_spec.SetDirectory(temp_file.GetPath());
+ file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str());
return true;
}
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 3f185fac269ea..0063760e9583d 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -276,7 +276,7 @@ bool DynamicLoaderDarwin::UpdateImageLoadAddress(Module *module,
changed = m_process->GetTarget().SetSectionLoadAddress(
section_sp, new_section_load_addr, warn_multiple);
- }
+ }
}
}
@@ -541,8 +541,8 @@ void DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos(
const size_t image_infos_size = image_infos.size();
for (size_t i = 0; i < image_infos_size; i++) {
if (image_infos[i].header.filetype == llvm::MachO::MH_DYLINKER) {
- // In a "simulator" process we will have two dyld modules --
- // a "dyld" that we want to keep track of, and a "dyld_sim" which
+ // In a "simulator" process we will have two dyld modules --
+ // a "dyld" that we want to keep track of, and a "dyld_sim" which
// we don't need to keep track of here. dyld_sim will have a non-macosx
// OS.
if (target_arch.GetTriple().getEnvironment() == llvm::Triple::Simulator &&
@@ -551,7 +551,7 @@ void DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos(
}
dyld_idx = i;
- }
+ }
if (image_infos[i].header.filetype == llvm::MachO::MH_EXECUTE) {
exe_idx = i;
}
@@ -652,7 +652,7 @@ bool DynamicLoaderDarwin::AddModulesUsingImageInfos(
module_spec.SetObjectOffset(objfile->GetFileOffset() +
commpage_section->GetFileOffset());
module_spec.SetObjectSize(objfile->GetByteSize());
- commpage_image_module_sp = target.GetOrCreateModule(module_spec,
+ commpage_image_module_sp = target.GetOrCreateModule(module_spec,
true /* notify */);
if (!commpage_image_module_sp ||
commpage_image_module_sp->GetObjectFile() == nullptr) {
@@ -1023,7 +1023,8 @@ lldb::ModuleSP DynamicLoaderDarwin::GetPThreadLibraryModule() {
if (!module_sp) {
SymbolContextList sc_list;
ModuleSpec module_spec;
- module_spec.GetFileSpec().SetFilename("libsystem_pthread.dylib");
+ module_spec.GetFileSpec().GetFilename().SetCString(
+ "libsystem_pthread.dylib");
ModuleList module_list;
m_process->GetTarget().GetImages().FindModules(module_spec, module_list);
if (!module_list.IsEmpty()) {
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index fd9ecc90f272b..4869cf0fd9c81 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -119,7 +119,7 @@ void DYLDRendezvous::UpdateExecutablePath() {
if (exe_mod) {
m_exe_file_spec = exe_mod->GetPlatformFileSpec();
LLDB_LOGF(log, "DYLDRendezvous::%s exe module executable path set: '%s'",
- __FUNCTION__, m_exe_file_spec.GetPath().c_str());
+ __FUNCTION__, m_exe_file_spec.GetCString());
} else {
LLDB_LOGF(log,
"DYLDRendezvous::%s cannot cache exe module path: null "
@@ -658,7 +658,7 @@ void DYLDRendezvous::DumpToLog(Log *log) const {
log->PutCString("DYLDRendezvous SOEntries:");
for (int i = 1; I != E; ++I, ++i) {
- LLDB_LOGF(log, "\n SOEntry [%d] %s", i, I->file_spec.GetPath().c_str());
+ LLDB_LOGF(log, "\n SOEntry [%d] %s", i, I->file_spec.GetCString());
LLDB_LOGF(log, " Base : %" PRIx64, I->base_addr);
LLDB_LOGF(log, " Path : %" PRIx64, I->path_addr);
LLDB_LOGF(log, " Dyn : %" PRIx64, I->dyn_addr);
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 4652e1dcec27a..8a708c1f9898e 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -650,7 +650,7 @@ void DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() {
LLDB_LOGF(
log,
"DynamicLoaderPOSIXDYLD::%s failed loading module %s at 0x%" PRIx64,
- __FUNCTION__, I->file_spec.GetPath().c_str(), I->base_addr);
+ __FUNCTION__, I->file_spec.GetCString(), I->base_addr);
}
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index d143686dfab3c..6ba03dad98d1a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -568,7 +568,7 @@ addr_t ClangExpressionDeclMap::GetSymbolAddress(Target &target,
reexport_module_sp =
target.GetImages().FindFirstModule(reexport_module_spec);
if (!reexport_module_sp) {
- reexport_module_spec.GetPlatformFileSpec().ClearDirectory();
+ reexport_module_spec.GetPlatformFileSpec().GetDirectory().Clear();
reexport_module_sp =
target.GetImages().FindFirstModule(reexport_module_spec);
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
index 1b8ea9adfe808..2099cfaaefece 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -72,7 +72,7 @@ static bool DefaultComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
"DefaultComputeClangResourceDir: Setting ClangResourceDir "
"to \"{0}\", verify = {1}",
clang_dir.str(), verify ? "true" : "false");
- file_spec.SetDirectory(clang_dir);
+ file_spec.GetDirectory().SetString(clang_dir);
FileSystem::Instance().Resolve(file_spec);
return true;
}
@@ -119,7 +119,7 @@ bool lldb_private::ComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
"Developer/Toolchains/XcodeDefault.xctoolchain",
swift_clang_resource_dir);
if (!verify || VerifyClangPath(clang_path)) {
- file_spec.SetDirectory(clang_path);
+ file_spec.GetDirectory().SetString(clang_path.c_str());
FileSystem::Instance().Resolve(file_spec);
return true;
}
@@ -134,7 +134,7 @@ bool lldb_private::ComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
raw_path.resize(parent - r_end);
llvm::sys::path::append(clang_path, raw_path, swift_clang_resource_dir);
if (!verify || VerifyClangPath(clang_path)) {
- file_spec.SetDirectory(clang_path);
+ file_spec.GetDirectory().SetString(clang_path.c_str());
FileSystem::Instance().Resolve(file_spec);
return true;
}
@@ -145,7 +145,7 @@ bool lldb_private::ComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
raw_path = lldb_shlib_spec.GetPath();
raw_path.resize(rev_it - r_end);
raw_path.append("LLDB.framework/Resources/Clang");
- file_spec.SetDirectory(raw_path);
+ file_spec.GetDirectory().SetString(raw_path.c_str());
FileSystem::Instance().Resolve(file_spec);
return true;
#endif // __APPLE__
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
index 3399f423f8fc0..7145e7804e685 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -753,7 +753,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
if (jit_module_sp) {
ConstString const_func_name(FunctionName());
FileSpec jit_file;
- jit_file.SetFilename(const_func_name);
+ jit_file.GetFilename() = const_func_name;
jit_module_sp->SetFileSpecAndObjectName(jit_file, ConstString());
m_jit_module_wp = jit_module_sp;
target->GetImages().Append(jit_module_sp);
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
index f9956e120b603..3db3fcea01927 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -144,7 +144,7 @@ bool ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager,
if (jit_module_sp) {
ConstString const_func_name(FunctionName());
FileSpec jit_file;
- jit_file.SetFilename(const_func_name);
+ jit_file.GetFilename() = const_func_name;
jit_module_sp->SetFileSpecAndObjectName(jit_file, ConstString());
m_jit_module_wp = jit_module_sp;
target->GetImages().Append(jit_module_sp);
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index 06cb1b63db9f6..0c032f8a7c88f 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -577,7 +577,7 @@ struct RenderScriptRuntime::Element {
array_size; // Number of items in array, only needed for structs
ConstString type_name; // Name of type, only needed for structs
- static ConstString
+ static ConstString
GetFallbackStructName(); // Print this as the type name of a struct Element
// If we can't resolve the actual struct name
@@ -879,7 +879,7 @@ RSReduceBreakpointResolver::SearchCallback(lldb_private::SearchFilter &filter,
LLDB_LOGF(log, "%s: %s reduction breakpoint on %s in %s",
__FUNCTION__, new_bp ? "new" : "existing",
kernel_name.GetCString(),
- address.GetModule()->GetFileSpec().GetPath().c_str());
+ address.GetModule()->GetFileSpec().GetCString());
}
}
}
@@ -2984,8 +2984,7 @@ bool RSModuleDescriptor::ParseRSInfo() {
const llvm::StringRef raw_rs_info((const char *)buffer->GetBytes());
raw_rs_info.split(info_lines, '\n');
LLDB_LOGF(log, "'.rs.info symbol for '%s':\n%s",
- m_module->GetFileSpec().GetPath().c_str(),
- raw_rs_info.str().c_str());
+ m_module->GetFileSpec().GetCString(), raw_rs_info.str().c_str());
}
enum {
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 5dc71fca36c25..4323f83ea3e6f 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2282,7 +2282,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
// Strip the path if there is @rpath, @executable, etc so we just use
// the basename
if (path[0] == '@')
- file_spec.ClearDirectory();
+ file_spec.GetDirectory().Clear();
if (lc.cmd == LC_REEXPORT_DYLIB) {
m_reexported_dylibs.AppendIfUnique(file_spec);
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 2c1660960250a..800bd9d6e1e39 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -1084,7 +1084,7 @@ uint32_t ObjectFilePECOFF::ParseDependentModules() {
// with the help of the object file's directory.
llvm::SmallString<128> dll_fullpath;
FileSpec dll_specs(dll_name);
- dll_specs.SetDirectory(m_file.GetDirectory());
+ dll_specs.GetDirectory().SetString(m_file.GetDirectory().GetCString());
if (!llvm::sys::fs::real_path(dll_specs.GetPath(), dll_fullpath))
m_deps_filespec->EmplaceBack(dll_fullpath);
diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index 327a6f4d00b0c..c75138f9f892f 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -174,7 +174,7 @@ Status PlatformAndroid::GetFile(const FileSpec &source,
FileSpec source_spec(source.GetPath(false), FileSpec::Style::posix);
if (source_spec.IsRelative())
source_spec = GetRemoteWorkingDirectory().CopyByAppendingPathComponent(
- source_spec.GetPathAsConstString(false).GetStringRef());
+ source_spec.GetCString(false));
Status error;
auto sync_service = GetSyncService(error);
@@ -189,13 +189,13 @@ Status PlatformAndroid::GetFile(const FileSpec &source,
if (mode != 0)
return sync_service->PullFile(source_spec, destination);
- std::string source_file = source_spec.GetPath(false);
+ auto source_file = source_spec.GetCString(false);
Log *log = GetLog(LLDBLog::Platform);
LLDB_LOGF(log, "Got mode == 0 on '%s': try to get file via 'shell cat'",
- source_file.c_str());
+ source_file);
- if (strchr(source_file.c_str(), '\'') != nullptr)
+ if (strchr(source_file, '\'') != nullptr)
return Status("Doesn't support single-quotes in filenames");
// mode == 0 can signify that adbd cannot access the file due security
@@ -203,7 +203,7 @@ Status PlatformAndroid::GetFile(const FileSpec &source,
AdbClient adb(m_device_id);
char cmd[PATH_MAX];
- snprintf(cmd, sizeof(cmd), "cat '%s'", source_file.c_str());
+ snprintf(cmd, sizeof(cmd), "cat '%s'", source_file);
return adb.ShellToFile(cmd, minutes(1), destination);
}
@@ -217,7 +217,7 @@ Status PlatformAndroid::PutFile(const FileSpec &source,
FileSpec destination_spec(destination.GetPath(false), FileSpec::Style::posix);
if (destination_spec.IsRelative())
destination_spec = GetRemoteWorkingDirectory().CopyByAppendingPathComponent(
- destination_spec.GetPath(false));
+ destination_spec.GetCString(false));
// TODO: Set correct uid and gid on remote file.
Status error;
@@ -325,8 +325,8 @@ Status PlatformAndroid::DownloadSymbolFile(const lldb::ModuleSP &module_sp,
// Execute oatdump on the remote device to generate a file with symtab
StreamString command;
command.Printf("oatdump --symbolize=%s --output=%s",
- module_sp->GetPlatformFileSpec().GetPath(false).c_str(),
- symfile_platform_filespec.GetPath(false).c_str());
+ module_sp->GetPlatformFileSpec().GetCString(false),
+ symfile_platform_filespec.GetCString(false));
error = adb.Shell(command.GetData(), minutes(1), nullptr);
if (error.Fail())
return Status("Oatdump failed: %s", error.AsCString());
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 51a15a3647878..af3430115c16b 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -63,7 +63,7 @@ static Status ExceptionMaskValidator(const char *string, void *unused) {
|| candidate == "EXC_ARITHMETIC"
|| candidate == "EXC_RESOURCE"
|| candidate == "EXC_GUARD")) {
- error.SetErrorStringWithFormat("invalid exception type: '%s'",
+ error.SetErrorStringWithFormat("invalid exception type: '%s'",
candidate.str().c_str());
return error;
}
@@ -140,7 +140,7 @@ class PlatformDarwinProperties : public Properties {
assert(option_value);
return option_value->GetCurrentValue();
}
-
+
OptionValueString *GetIgnoredExceptionValue() {
const uint32_t idx = ePropertyIgnoredExceptions;
OptionValueString *option_value =
@@ -172,7 +172,7 @@ void PlatformDarwin::DebuggerInitialize(
Args
PlatformDarwin::GetExtraStartupCommands() {
- std::string ignored_exceptions
+ std::string ignored_exceptions
= GetGlobalProperties().GetIgnoredExceptions();
if (ignored_exceptions.empty())
return {};
@@ -308,7 +308,7 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources(
if (module_spec.GetFilename() == filename_no_extension)
break;
- module_spec.SetFilename(filename_no_extension);
+ module_spec.GetFilename() = filename_no_extension;
}
}
}
@@ -1138,7 +1138,7 @@ lldb_private::FileSpec PlatformDarwin::LocateExecutable(const char *basename) {
xcode_lldb_resources.AppendPathComponent("Resources");
if (FileSystem::Instance().Exists(xcode_lldb_resources)) {
FileSpec dir;
- dir.SetDirectory(xcode_lldb_resources.GetPathAsConstString());
+ dir.GetDirectory().SetCString(xcode_lldb_resources.GetPath().c_str());
g_executable_dirs.push_back(dir);
}
}
@@ -1151,7 +1151,8 @@ lldb_private::FileSpec PlatformDarwin::LocateExecutable(const char *basename) {
cmd_line_lldb_resources.AppendPathComponent("Resources");
if (FileSystem::Instance().Exists(cmd_line_lldb_resources)) {
FileSpec dir;
- dir.SetDirectory(cmd_line_lldb_resources.GetPathAsConstString());
+ dir.GetDirectory().SetCString(
+ cmd_line_lldb_resources.GetPath().c_str());
g_executable_dirs.push_back(dir);
}
}
@@ -1161,8 +1162,8 @@ lldb_private::FileSpec PlatformDarwin::LocateExecutable(const char *basename) {
// are looking for
for (const auto &executable_dir : g_executable_dirs) {
FileSpec executable_file;
- executable_file.SetDirectory(executable_dir.GetDirectory());
- executable_file.SetFilename(basename);
+ executable_file.GetDirectory() = executable_dir.GetDirectory();
+ executable_file.GetFilename().SetCString(basename);
if (FileSystem::Instance().Exists(executable_file))
return executable_file;
}
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
index 337e3bb2f9723..b3eafecedd76e 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -615,7 +615,7 @@ bool PlatformDarwinKernel::KextHasdSYMSibling(
FileSpec dsym_fspec = kext_bundle_filepath;
std::string filename = dsym_fspec.GetFilename().AsCString();
filename += ".dSYM";
- dsym_fspec.SetFilename(filename);
+ dsym_fspec.GetFilename() = ConstString(filename);
if (FileSystem::Instance().IsDirectory(dsym_fspec)) {
return true;
}
@@ -652,7 +652,7 @@ bool PlatformDarwinKernel::KernelHasdSYMSibling(const FileSpec &kernel_binary) {
FileSpec kernel_dsym = kernel_binary;
std::string filename = kernel_binary.GetFilename().AsCString();
filename += ".dSYM";
- kernel_dsym.SetFilename(filename);
+ kernel_dsym.GetFilename() = ConstString(filename);
return FileSystem::Instance().IsDirectory(kernel_dsym);
}
@@ -670,7 +670,8 @@ bool PlatformDarwinKernel::KerneldSYMHasNoSiblingBinary(
FileSpec binary_filespec = kernel_dsym;
// Chop off the '.dSYM' extension on the filename
- binary_filespec.SetFilename(binary_filespec.GetFileNameStrippingExtension());
+ binary_filespec.GetFilename() =
+ binary_filespec.GetFileNameStrippingExtension();
// Is there a binary next to this this? Then return false.
if (FileSystem::Instance().Exists(binary_filespec))
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index aa03583298378..2438661886291 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -177,7 +177,7 @@ FileSpec PlatformRemoteGDBServer::GetRemoteWorkingDirectory() {
if (m_gdb_client_up->GetWorkingDir(working_dir) && log)
LLDB_LOGF(log,
"PlatformRemoteGDBServer::GetRemoteWorkingDirectory() -> '%s'",
- working_dir.GetPath().c_str());
+ working_dir.GetCString());
return working_dir;
} else {
return Platform::GetRemoteWorkingDirectory();
@@ -191,7 +191,7 @@ bool PlatformRemoteGDBServer::SetRemoteWorkingDirectory(
// will for use to re-read it
Log *log = GetLog(LLDBLog::Platform);
LLDB_LOGF(log, "PlatformRemoteGDBServer::SetRemoteWorkingDirectory('%s')",
- working_dir.GetPath().c_str());
+ working_dir.GetCString());
return m_gdb_client_up->SetWorkingDir(working_dir) == 0;
} else
return Platform::SetRemoteWorkingDirectory(working_dir);
@@ -546,8 +546,7 @@ Status PlatformRemoteGDBServer::MakeDirectory(const FileSpec &file_spec,
LLDB_LOGF(log,
"PlatformRemoteGDBServer::MakeDirectory(path='%s', mode=%o) "
"error = %u (%s)",
- file_spec.GetPath().c_str(), mode, error.GetError(),
- error.AsCString());
+ file_spec.GetCString(), mode, error.GetError(), error.AsCString());
return error;
}
@@ -561,7 +560,7 @@ Status PlatformRemoteGDBServer::GetFilePermissions(const FileSpec &file_spec,
LLDB_LOGF(log,
"PlatformRemoteGDBServer::GetFilePermissions(path='%s', "
"file_permissions=%o) error = %u (%s)",
- file_spec.GetPath().c_str(), file_permissions, error.GetError(),
+ file_spec.GetCString(), file_permissions, error.GetError(),
error.AsCString());
return error;
}
@@ -576,7 +575,7 @@ Status PlatformRemoteGDBServer::SetFilePermissions(const FileSpec &file_spec,
LLDB_LOGF(log,
"PlatformRemoteGDBServer::SetFilePermissions(path='%s', "
"file_permissions=%o) error = %u (%s)",
- file_spec.GetPath().c_str(), file_permissions, error.GetError(),
+ file_spec.GetCString(), file_permissions, error.GetError(),
error.AsCString());
return error;
}
@@ -645,7 +644,7 @@ Status PlatformRemoteGDBServer::CreateSymlink(
LLDB_LOGF(log,
"PlatformRemoteGDBServer::CreateSymlink(src='%s', dst='%s') "
"error = %u (%s)",
- src.GetPath().c_str(), dst.GetPath().c_str(), error.GetError(),
+ src.GetCString(), dst.GetCString(), error.GetError(),
error.AsCString());
return error;
}
@@ -656,7 +655,7 @@ Status PlatformRemoteGDBServer::Unlink(const FileSpec &file_spec) {
Status error = m_gdb_client_up->Unlink(file_spec);
Log *log = GetLog(LLDBLog::Platform);
LLDB_LOGF(log, "PlatformRemoteGDBServer::Unlink(path='%s') error = %u (%s)",
- file_spec.GetPath().c_str(), error.GetError(), error.AsCString());
+ file_spec.GetCString(), error.GetError(), error.AsCString());
return error;
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index f750ad98b593e..2a58f20283868 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -1138,8 +1138,7 @@ GDBRemoteCommunicationServerCommon::Handle_qModuleInfo(
response.PutChar(';');
response.PutCString("file_path:");
- response.PutStringAsRawHex8(
- matched_module_spec.GetFileSpec().GetPath().c_str());
+ response.PutStringAsRawHex8(matched_module_spec.GetFileSpec().GetCString());
response.PutChar(';');
response.PutCString("file_offset:");
response.PutHex64(file_offset);
@@ -1214,7 +1213,7 @@ void GDBRemoteCommunicationServerCommon::CreateProcessInfoResponse(
proc_info.GetUserID(), proc_info.GetGroupID(),
proc_info.GetEffectiveUserID(), proc_info.GetEffectiveGroupID());
response.PutCString("name:");
- response.PutStringAsRawHex8(proc_info.GetExecutableFile().GetPath().c_str());
+ response.PutStringAsRawHex8(proc_info.GetExecutableFile().GetCString());
response.PutChar(';');
response.PutCString("args:");
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 20650b5c8820d..5804c13fe7b64 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -1503,7 +1503,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qGetWorkingDir(
FileSpec working_dir{m_process_launch_info.GetWorkingDirectory()};
if (working_dir) {
StreamString response;
- response.PutStringAsRawHex8(working_dir.GetPath().c_str());
+ response.PutStringAsRawHex8(working_dir.GetCString());
return SendPacketNoLock(response.GetString());
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
index bc1119f16bc86..6f137d09fee4f 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -587,8 +587,7 @@ GDBRemoteCommunicationServerPlatform::GetDomainSocketPath(const char *prefix) {
FileSpec socket_path_spec(GetDomainSocketDir());
socket_path_spec.AppendPathComponent(socket_name.c_str());
- llvm::sys::fs::createUniqueFile(socket_path_spec.GetPath().c_str(),
- socket_path);
+ llvm::sys::fs::createUniqueFile(socket_path_spec.GetCString(), socket_path);
return FileSpec(socket_path.c_str());
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 2e3f453c1f86e..5f18706f67e5d 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -745,9 +745,9 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module,
"ProcessGDBRemote::%s provided with STDIO paths via "
"launch_info: stdin=%s, stdout=%s, stderr=%s",
__FUNCTION__,
- stdin_file_spec ? stdin_file_spec.GetPath().c_str() : "<null>",
- stdout_file_spec ? stdout_file_spec.GetPath().c_str() : "<null>",
- stderr_file_spec ? stderr_file_spec.GetPath().c_str() : "<null>");
+ stdin_file_spec ? stdin_file_spec.GetCString() : "<null>",
+ stdout_file_spec ? stdout_file_spec.GetCString() : "<null>",
+ stderr_file_spec ? stderr_file_spec.GetCString() : "<null>");
else
LLDB_LOGF(log,
"ProcessGDBRemote::%s no STDIO paths given via launch_info",
@@ -810,18 +810,18 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module,
"(IsHost() is true) using secondary: stdin=%s, stdout=%s, "
"stderr=%s",
__FUNCTION__,
- stdin_file_spec ? stdin_file_spec.GetPath().c_str() : "<null>",
- stdout_file_spec ? stdout_file_spec.GetPath().c_str() : "<null>",
- stderr_file_spec ? stderr_file_spec.GetPath().c_str() : "<null>");
+ stdin_file_spec ? stdin_file_spec.GetCString() : "<null>",
+ stdout_file_spec ? stdout_file_spec.GetCString() : "<null>",
+ stderr_file_spec ? stderr_file_spec.GetCString() : "<null>");
}
LLDB_LOGF(log,
"ProcessGDBRemote::%s final STDIO paths after all "
"adjustments: stdin=%s, stdout=%s, stderr=%s",
__FUNCTION__,
- stdin_file_spec ? stdin_file_spec.GetPath().c_str() : "<null>",
- stdout_file_spec ? stdout_file_spec.GetPath().c_str() : "<null>",
- stderr_file_spec ? stderr_file_spec.GetPath().c_str() : "<null>");
+ stdin_file_spec ? stdin_file_spec.GetCString() : "<null>",
+ stdout_file_spec ? stdout_file_spec.GetCString() : "<null>",
+ stderr_file_spec ? stderr_file_spec.GetCString() : "<null>");
if (stdin_file_spec)
m_gdb_comm.SetSTDIN(stdin_file_spec);
@@ -962,12 +962,12 @@ Status ProcessGDBRemote::ConnectToDebugserver(llvm::StringRef connect_url) {
entry.c_str(), response);
}
};
-
+
PlatformSP platform_sp = GetTarget().GetPlatform();
if (platform_sp) {
handle_cmds(platform_sp->GetExtraStartupCommands());
}
-
+
// Then dispatch any process commands:
handle_cmds(GetExtraStartupCommands());
diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
index e3bc7d4c97f78..c91c111d8df3a 100644
--- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -567,7 +567,7 @@ void ProcessMinidump::ReadModuleList() {
partial_module_spec.GetUUID().Clear();
module_sp = GetOrCreateModule(uuid, name, partial_module_spec);
if (!module_sp) {
- partial_module_spec.GetFileSpec().ClearDirectory();
+ partial_module_spec.GetFileSpec().GetDirectory().Clear();
module_sp = GetOrCreateModule(uuid, name, partial_module_spec);
}
}
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 6558993470eee..a21adcfbdbd60 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -241,7 +241,7 @@ void ScriptInterpreterPython::ComputePythonDir(
llvm::sys::path::append(path, LLDB_PYTHON_RELATIVE_LIBDIR);
#if defined(_WIN32)
- // This will be injected directly through FileSpec.SetDirectory(),
+ // This will be injected directly through FileSpec.GetDirectory().SetString(),
// so we need to normalize manually.
std::replace(path.begin(), path.end(), '\\', '/');
#endif
@@ -260,7 +260,7 @@ FileSpec ScriptInterpreterPython::GetPythonDir() {
#else
ComputePythonDir(path);
#endif
- spec.SetDirectory(path);
+ spec.GetDirectory().SetString(path);
return spec;
}();
return g_spec;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 9d68cb1e7b1b9..8ee709db9cdb5 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -993,9 +993,10 @@ bool SymbolFileDWARF::ParseSupportFiles(DWARFUnit &dwarf_cu,
dwarf_cu.GetOffset()))
return false;
- std::string comp_dir = dwarf_cu.GetCompilationDirectory().GetPath();
support_files = ParseSupportFilesFromPrologue(
- module, prologue, dwarf_cu.GetPathStyle(), comp_dir);
+ module, prologue, dwarf_cu.GetPathStyle(),
+ dwarf_cu.GetCompilationDirectory().GetCString());
+
return true;
}
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index fbaea3328336b..7e10e315be207 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -120,7 +120,7 @@ loadMatchingPDBFile(std::string exe_path, llvm::BumpPtrAllocator &allocator) {
if (!FileSystem::Instance().Exists(pdb_file)) {
const auto exe_dir = FileSpec(exe_path).CopyByRemovingLastPathComponent();
const auto pdb_name = FileSpec(pdb_file).GetFilename().GetCString();
- pdb_file = exe_dir.CopyByAppendingPathComponent(pdb_name).GetPathAsConstString().GetStringRef();
+ pdb_file = exe_dir.CopyByAppendingPathComponent(pdb_name).GetCString();
}
// If the file is not a PDB or if it doesn't have a matching GUID, fail.
diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp
index 09a5fc936cd0b..668276aa25001 100644
--- a/lldb/source/Symbol/Symbol.cpp
+++ b/lldb/source/Symbol/Symbol.cpp
@@ -425,7 +425,7 @@ Symbol *Symbol::ResolveReExportedSymbolInModuleSpec(
// Next try and find the module by basename in case environment variables
// or other runtime trickery causes shared libraries to be loaded from
// alternate paths
- module_spec.GetFileSpec().ClearDirectory();
+ module_spec.GetFileSpec().GetDirectory().Clear();
module_sp = target.GetImages().FindFirstModule(module_spec);
}
}
diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp
index 2ccc248d839ec..a10db0755d03a 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -812,7 +812,9 @@ const Symbol *SymbolContext::FindBestGlobalDataSymbol(ConstString name,
reexport_module_sp =
target.GetImages().FindFirstModule(reexport_module_spec);
if (!reexport_module_sp) {
- reexport_module_spec.GetPlatformFileSpec().ClearDirectory();
+ reexport_module_spec.GetPlatformFileSpec()
+ .GetDirectory()
+ .Clear();
reexport_module_sp =
target.GetImages().FindFirstModule(reexport_module_spec);
}
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 61c4cba22c236..559f7664c72ef 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -317,7 +317,7 @@ void Platform::GetStatus(Stream &strm) {
strm.Format(" Sysroot: {0}\n", GetSDKRootDirectory());
}
if (GetWorkingDirectory()) {
- strm.Printf("WorkingDir: %s\n", GetWorkingDirectory().GetPath().c_str());
+ strm.Printf("WorkingDir: %s\n", GetWorkingDirectory().GetCString());
}
if (!IsConnected())
return;
@@ -434,13 +434,12 @@ RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
// make the new directory and get in there
FileSpec dst_dir = rc_baton->dst;
if (!dst_dir.GetFilename())
- dst_dir.SetFilename(src.GetLastPathComponent());
+ dst_dir.GetFilename() = src.GetLastPathComponent();
Status error = rc_baton->platform_ptr->MakeDirectory(
dst_dir, lldb::eFilePermissionsDirectoryDefault);
if (error.Fail()) {
rc_baton->error.SetErrorStringWithFormat(
- "unable to setup directory %s on remote end",
- dst_dir.GetPath().c_str());
+ "unable to setup directory %s on remote end", dst_dir.GetCString());
return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail out
}
@@ -450,7 +449,7 @@ RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
// Make a filespec that only fills in the directory of a FileSpec so when
// we enumerate we can quickly fill in the filename for dst copies
FileSpec recurse_dst;
- recurse_dst.SetDirectory(dst_dir.GetPathAsConstString());
+ recurse_dst.GetDirectory().SetCString(dst_dir.GetPath().c_str());
RecurseCopyBaton rc_baton2 = {recurse_dst, rc_baton->platform_ptr,
Status()};
FileSystem::Instance().EnumerateDirectory(src_dir_path, true, true, true,
@@ -466,7 +465,7 @@ RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
// copy the file and keep going
FileSpec dst_file = rc_baton->dst;
if (!dst_file.GetFilename())
- dst_file.SetFilename(src.GetFilename());
+ dst_file.GetFilename() = src.GetFilename();
FileSpec src_resolved;
@@ -488,7 +487,7 @@ RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
// copy the file and keep going
FileSpec dst_file = rc_baton->dst;
if (!dst_file.GetFilename())
- dst_file.SetFilename(src.GetFilename());
+ dst_file.GetFilename() = src.GetFilename();
Status err = rc_baton->platform_ptr->PutFile(src, dst_file);
if (err.Fail()) {
rc_baton->error.SetErrorString(err.AsCString());
@@ -515,7 +514,7 @@ Status Platform::Install(const FileSpec &src, const FileSpec &dst) {
FileSpec fixed_dst(dst);
if (!fixed_dst.GetFilename())
- fixed_dst.SetFilename(src.GetFilename());
+ fixed_dst.GetFilename() = src.GetFilename();
FileSpec working_dir = GetWorkingDirectory();
@@ -523,7 +522,7 @@ Status Platform::Install(const FileSpec &src, const FileSpec &dst) {
if (dst.GetDirectory()) {
const char first_dst_dir_char = dst.GetDirectory().GetCString()[0];
if (first_dst_dir_char == '/' || first_dst_dir_char == '\\') {
- fixed_dst.SetDirectory(dst.GetDirectory());
+ fixed_dst.GetDirectory() = dst.GetDirectory();
}
// If the fixed destination file doesn't have a directory yet, then we
// must have a relative path. We will resolve this relative path against
@@ -534,7 +533,7 @@ Status Platform::Install(const FileSpec &src, const FileSpec &dst) {
if (working_dir) {
relative_spec = working_dir;
relative_spec.AppendPathComponent(dst.GetPath());
- fixed_dst.SetDirectory(relative_spec.GetDirectory());
+ fixed_dst.GetDirectory() = relative_spec.GetDirectory();
} else {
error.SetErrorStringWithFormat(
"platform working directory must be valid for relative path '%s'",
@@ -544,7 +543,7 @@ Status Platform::Install(const FileSpec &src, const FileSpec &dst) {
}
} else {
if (working_dir) {
- fixed_dst.SetDirectory(working_dir.GetPathAsConstString());
+ fixed_dst.GetDirectory().SetCString(working_dir.GetCString());
} else {
error.SetErrorStringWithFormat(
"platform working directory must be valid for relative path '%s'",
@@ -554,7 +553,7 @@ Status Platform::Install(const FileSpec &src, const FileSpec &dst) {
}
} else {
if (working_dir) {
- fixed_dst.SetDirectory(working_dir.GetPathAsConstString());
+ fixed_dst.GetDirectory().SetCString(working_dir.GetCString());
} else {
error.SetErrorStringWithFormat("platform working directory must be valid "
"when destination directory is empty");
@@ -581,7 +580,7 @@ Status Platform::Install(const FileSpec &src, const FileSpec &dst) {
// Make a filespec that only fills in the directory of a FileSpec so
// when we enumerate we can quickly fill in the filename for dst copies
FileSpec recurse_dst;
- recurse_dst.SetDirectory(fixed_dst.GetPathAsConstString());
+ recurse_dst.GetDirectory().SetCString(fixed_dst.GetCString());
std::string src_dir_path(src.GetPath());
RecurseCopyBaton baton = {recurse_dst, this, Status()};
FileSystem::Instance().EnumerateDirectory(
@@ -738,7 +737,7 @@ ConstString Platform::GetFullNameForDylib(ConstString basename) {
bool Platform::SetRemoteWorkingDirectory(const FileSpec &working_dir) {
Log *log = GetLog(LLDBLog::Platform);
LLDB_LOGF(log, "Platform::SetRemoteWorkingDirectory('%s')",
- working_dir.GetPath().c_str());
+ working_dir.GetCString());
m_working_dir = working_dir;
return true;
}
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 6ffe6d3926adf..f16fc6b5da85f 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -107,7 +107,7 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch,
SetEventName(eBroadcastBitModulesUnloaded, "modules-unloaded");
SetEventName(eBroadcastBitWatchpointChanged, "watchpoint-changed");
SetEventName(eBroadcastBitSymbolsLoaded, "symbols-loaded");
-
+
CheckInWithManager();
LLDB_LOG(GetLog(LLDBLog::Object), "{0} Target::Target()",
@@ -2085,12 +2085,11 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
// a suitable image.
if (m_image_search_paths.GetSize()) {
ModuleSpec transformed_spec(module_spec);
- ConstString transformed_dir;
if (m_image_search_paths.RemapPath(
- module_spec.GetFileSpec().GetDirectory(), transformed_dir)) {
- transformed_spec.GetFileSpec().SetDirectory(transformed_dir);
- transformed_spec.GetFileSpec().SetFilename(
- module_spec.GetFileSpec().GetFilename());
+ module_spec.GetFileSpec().GetDirectory(),
+ transformed_spec.GetFileSpec().GetDirectory())) {
+ transformed_spec.GetFileSpec().GetFilename() =
+ module_spec.GetFileSpec().GetFilename();
error = ModuleList::GetSharedModule(transformed_spec, module_sp,
&search_paths, &old_modules,
&did_create_module);
@@ -3220,8 +3219,8 @@ Status Target::Attach(ProcessAttachInfo &attach_info, Stream *stream) {
// the process to attach to by default
if (!attach_info.ProcessInfoSpecified()) {
if (old_exec_module_sp)
- attach_info.GetExecutableFile().SetFilename(
- old_exec_module_sp->GetPlatformFileSpec().GetFilename());
+ attach_info.GetExecutableFile().GetFilename() =
+ old_exec_module_sp->GetPlatformFileSpec().GetFilename();
if (!attach_info.ProcessInfoSpecified()) {
return Status("no process specified, create a target with a file, or "
@@ -3363,7 +3362,7 @@ void Target::FinalizeFileActions(ProcessLaunchInfo &info) {
}
}
-void Target::AddDummySignal(llvm::StringRef name, LazyBool pass, LazyBool notify,
+void Target::AddDummySignal(llvm::StringRef name, LazyBool pass, LazyBool notify,
LazyBool stop) {
if (name.empty())
return;
@@ -3378,38 +3377,38 @@ void Target::AddDummySignal(llvm::StringRef name, LazyBool pass, LazyBool notify
elem.stop = stop;
}
-bool Target::UpdateSignalFromDummy(UnixSignalsSP signals_sp,
+bool Target::UpdateSignalFromDummy(UnixSignalsSP signals_sp,
const DummySignalElement &elem) {
if (!signals_sp)
return false;
- int32_t signo
+ int32_t signo
= signals_sp->GetSignalNumberFromName(elem.first().str().c_str());
if (signo == LLDB_INVALID_SIGNAL_NUMBER)
return false;
-
+
if (elem.second.pass == eLazyBoolYes)
signals_sp->SetShouldSuppress(signo, false);
else if (elem.second.pass == eLazyBoolNo)
signals_sp->SetShouldSuppress(signo, true);
-
+
if (elem.second.notify == eLazyBoolYes)
signals_sp->SetShouldNotify(signo, true);
else if (elem.second.notify == eLazyBoolNo)
signals_sp->SetShouldNotify(signo, false);
-
+
if (elem.second.stop == eLazyBoolYes)
signals_sp->SetShouldStop(signo, true);
else if (elem.second.stop == eLazyBoolNo)
signals_sp->SetShouldStop(signo, false);
- return true;
+ return true;
}
-bool Target::ResetSignalFromDummy(UnixSignalsSP signals_sp,
+bool Target::ResetSignalFromDummy(UnixSignalsSP signals_sp,
const DummySignalElement &elem) {
if (!signals_sp)
return false;
- int32_t signo
+ int32_t signo
= signals_sp->GetSignalNumberFromName(elem.first().str().c_str());
if (signo == LLDB_INVALID_SIGNAL_NUMBER)
return false;
@@ -3420,14 +3419,14 @@ bool Target::ResetSignalFromDummy(UnixSignalsSP signals_sp,
return true;
}
-void Target::UpdateSignalsFromDummy(UnixSignalsSP signals_sp,
+void Target::UpdateSignalsFromDummy(UnixSignalsSP signals_sp,
StreamSP warning_stream_sp) {
if (!signals_sp)
return;
for (const auto &elem : m_dummy_signals) {
if (!UpdateSignalFromDummy(signals_sp, elem))
- warning_stream_sp->Printf("Target signal '%s' not found in process\n",
+ warning_stream_sp->Printf("Target signal '%s' not found in process\n",
elem.first().str().c_str());
}
}
@@ -3460,7 +3459,7 @@ void Target::ClearDummySignals(Args &signal_names) {
void Target::PrintDummySignals(Stream &strm, Args &signal_args) {
strm.Printf("NAME PASS STOP NOTIFY\n");
strm.Printf("=========== ======= ======= =======\n");
-
+
auto str_for_lazy = [] (LazyBool lazy) -> const char * {
switch (lazy) {
case eLazyBoolCalculate: return "not set";
diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp
index 5d60c1eecdcd3..829036976a219 100644
--- a/lldb/source/Target/TargetList.cpp
+++ b/lldb/source/Target/TargetList.cpp
@@ -354,7 +354,7 @@ Status TargetList::CreateTargetInternal(Debugger &debugger,
}
if (file.GetDirectory()) {
FileSpec file_dir;
- file_dir.SetDirectory(file.GetDirectory());
+ file_dir.GetDirectory() = file.GetDirectory();
target_sp->AppendExecutableSearchPaths(file_dir);
}
diff --git a/lldb/source/Target/Trace.cpp b/lldb/source/Target/Trace.cpp
index 68220253c45e6..ac832734b8d01 100644
--- a/lldb/source/Target/Trace.cpp
+++ b/lldb/source/Target/Trace.cpp
@@ -437,7 +437,7 @@ llvm::Error Trace::OnDataFileRead(FileSpec file,
if (std::error_code err = trace_or_error.getError())
return createStringError(
inconvertibleErrorCode(), "Failed fetching trace-related file %s. %s",
- file.GetPath().c_str(), toString(errorCodeToError(err)).c_str());
+ file.GetCString(), toString(errorCodeToError(err)).c_str());
MemoryBuffer &data = **trace_or_error;
ArrayRef<uint8_t> array_ref(
diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp
index 48b922970d87e..c0dbc29bcd1f1 100644
--- a/lldb/source/Utility/FileSpec.cpp
+++ b/lldb/source/Utility/FileSpec.cpp
@@ -170,7 +170,9 @@ void FileSpec::SetFile(llvm::StringRef pathname) { SetFile(pathname, m_style); }
// up into a directory and filename and stored as uniqued string values for
// quick comparison and efficient memory usage.
void FileSpec::SetFile(llvm::StringRef pathname, Style style) {
- Clear();
+ m_filename.Clear();
+ m_directory.Clear();
+ m_is_resolved = false;
m_style = (style == Style::native) ? GetNativeStyle() : style;
if (pathname.empty())
@@ -257,7 +259,6 @@ Stream &lldb_private::operator<<(Stream &s, const FileSpec &f) {
void FileSpec::Clear() {
m_directory.Clear();
m_filename.Clear();
- PathWasModified();
}
// Compare two FileSpec objects. If "full" is true, then both the directory and
@@ -329,35 +330,17 @@ void FileSpec::Dump(llvm::raw_ostream &s) const {
FileSpec::Style FileSpec::GetPathStyle() const { return m_style; }
-void FileSpec::SetDirectory(ConstString directory) {
- m_directory = directory;
- PathWasModified();
-}
+// Directory string get accessor.
+ConstString &FileSpec::GetDirectory() { return m_directory; }
-void FileSpec::SetDirectory(llvm::StringRef directory) {
- m_directory = ConstString(directory);
- PathWasModified();
-}
+// Directory string const get accessor.
+ConstString FileSpec::GetDirectory() const { return m_directory; }
-void FileSpec::SetFilename(ConstString filename) {
- m_filename = filename;
- PathWasModified();
-}
-
-void FileSpec::SetFilename(llvm::StringRef filename) {
- m_filename = ConstString(filename);
- PathWasModified();
-}
-
-void FileSpec::ClearFilename() {
- m_filename.Clear();
- PathWasModified();
-}
+// Filename string get accessor.
+ConstString &FileSpec::GetFilename() { return m_filename; }
-void FileSpec::ClearDirectory() {
- m_directory.Clear();
- PathWasModified();
-}
+// Filename string const get accessor.
+ConstString FileSpec::GetFilename() const { return m_filename; }
// Extract the directory and path into a fixed buffer. This is needed as the
// directory and path are stored in separate string values.
@@ -377,8 +360,8 @@ std::string FileSpec::GetPath(bool denormalize) const {
return static_cast<std::string>(result);
}
-ConstString FileSpec::GetPathAsConstString(bool denormalize) const {
- return ConstString{GetPath(denormalize)};
+const char *FileSpec::GetCString(bool denormalize) const {
+ return ConstString{GetPath(denormalize)}.AsCString(nullptr);
}
void FileSpec::GetPath(llvm::SmallVectorImpl<char> &path,
@@ -493,22 +476,18 @@ bool FileSpec::IsRelative() const {
}
bool FileSpec::IsAbsolute() const {
- // Check if we have cached if this path is absolute to avoid recalculating.
- if (m_absolute != Absolute::Calculate)
- return m_absolute == Absolute::Yes;
-
- m_absolute = Absolute::No;
+ llvm::SmallString<64> current_path;
+ GetPath(current_path, false);
- llvm::SmallString<64> path;
- GetPath(path, false);
+ // Early return if the path is empty.
+ if (current_path.empty())
+ return false;
- if (!path.empty()) {
- // We consider paths starting with ~ to be absolute.
- if (path[0] == '~' || llvm::sys::path::is_absolute(path, m_style))
- m_absolute = Absolute::Yes;
- }
+ // We consider paths starting with ~ to be absolute.
+ if (current_path[0] == '~')
+ return true;
- return m_absolute == Absolute::Yes;
+ return llvm::sys::path::is_absolute(current_path, m_style);
}
void FileSpec::MakeAbsolute(const FileSpec &dir) {
diff --git a/lldb/tools/lldb-server/lldb-platform.cpp b/lldb/tools/lldb-server/lldb-platform.cpp
index 9f8b4c7d67ee3..1a969eec8db85 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -100,7 +100,7 @@ static Status save_socket_id_to_file(const std::string &socket_id,
Status error(llvm::sys::fs::create_directory(temp_file_spec.GetPath()));
if (error.Fail())
return Status("Failed to create directory %s: %s",
- temp_file_spec.GetPath().c_str(), error.AsCString());
+ temp_file_spec.GetCString(), error.AsCString());
llvm::SmallString<64> temp_file_path;
temp_file_spec.AppendPathComponent("port-file.%%%%%%");
diff --git a/lldb/tools/lldb-test/lldb-test.cpp b/lldb/tools/lldb-test/lldb-test.cpp
index 8c52648313a3b..bc3d536cbaac0 100644
--- a/lldb/tools/lldb-test/lldb-test.cpp
+++ b/lldb/tools/lldb-test/lldb-test.cpp
@@ -925,7 +925,7 @@ static int dumpObjectFiles(Debugger &Dbg) {
for (size_t I = 0; I < Files.GetSize(); ++I) {
AutoIndent Indent(Printer, 2);
Printer.formatLine("Name: {0}",
- Files.GetFileSpecAtIndex(I).GetPath());
+ Files.GetFileSpecAtIndex(I).GetCString());
}
Printer.NewLine();
}
diff --git a/lldb/unittests/Target/FindFileTest.cpp b/lldb/unittests/Target/FindFileTest.cpp
index b74d557e61023..9e991605e13c4 100644
--- a/lldb/unittests/Target/FindFileTest.cpp
+++ b/lldb/unittests/Target/FindFileTest.cpp
@@ -47,7 +47,7 @@ static void TestFileFindings(const PathMappingList &map,
llvm::ArrayRef<Matches> matches,
llvm::ArrayRef<FileSpec> fails) {
for (const auto &fail : fails) {
- SCOPED_TRACE(fail.GetPath().c_str());
+ SCOPED_TRACE(fail.GetCString());
EXPECT_FALSE(map.FindFile(fail));
}
diff --git a/lldb/unittests/Target/ModuleCacheTest.cpp b/lldb/unittests/Target/ModuleCacheTest.cpp
index d5a7b8dbf2a93..273338c83695a 100644
--- a/lldb/unittests/Target/ModuleCacheTest.cpp
+++ b/lldb/unittests/Target/ModuleCacheTest.cpp
@@ -72,12 +72,12 @@ void ModuleCacheTest::SetUp() {
static void VerifyDiskState(const FileSpec &cache_dir, const char *hostname) {
FileSpec uuid_view = GetUuidView(cache_dir);
EXPECT_TRUE(FileSystem::Instance().Exists(uuid_view))
- << "uuid_view is: " << uuid_view.GetPath();
+ << "uuid_view is: " << uuid_view.GetCString();
EXPECT_EQ(module_size, FileSystem::Instance().GetByteSize(uuid_view));
FileSpec sysroot_view = GetSysrootView(cache_dir, hostname);
EXPECT_TRUE(FileSystem::Instance().Exists(sysroot_view))
- << "sysroot_view is: " << sysroot_view.GetPath();
+ << "sysroot_view is: " << sysroot_view.GetCString();
EXPECT_EQ(module_size, FileSystem::Instance().GetByteSize(sysroot_view));
}
@@ -97,10 +97,10 @@ void ModuleCacheTest::TryGetAndPut(const FileSpec &cache_dir,
[&download_called, this](const ModuleSpec &module_spec,
const FileSpec &tmp_download_file_spec) {
download_called = true;
- EXPECT_STREQ(GetDummyRemotePath().GetPath().c_str(),
- module_spec.GetFileSpec().GetPath().c_str());
+ EXPECT_STREQ(GetDummyRemotePath().GetCString(),
+ module_spec.GetFileSpec().GetCString());
std::error_code ec = llvm::sys::fs::copy_file(
- s_test_executable, tmp_download_file_spec.GetPath());
+ s_test_executable, tmp_download_file_spec.GetCString());
EXPECT_FALSE(ec);
return Status();
},
@@ -118,8 +118,8 @@ void ModuleCacheTest::TryGetAndPut(const FileSpec &cache_dir,
module_sp->FindFunctionSymbols(ConstString("boom"), eFunctionNameTypeFull,
sc_list);
EXPECT_EQ(1u, sc_list.GetSize());
- EXPECT_STREQ(GetDummyRemotePath().GetPath().c_str(),
- module_sp->GetPlatformFileSpec().GetPath().c_str());
+ EXPECT_STREQ(GetDummyRemotePath().GetCString(),
+ module_sp->GetPlatformFileSpec().GetCString());
EXPECT_STREQ(module_uuid, module_sp->GetUUID().GetAsString().c_str());
}
@@ -140,7 +140,7 @@ TEST_F(ModuleCacheTest, GetAndPutUuidExists) {
std::error_code ec =
llvm::sys::fs::create_directories(uuid_view.GetDirectory().GetCString());
ASSERT_FALSE(ec);
- ec = llvm::sys::fs::copy_file(s_test_executable, uuid_view.GetPath().c_str());
+ ec = llvm::sys::fs::copy_file(s_test_executable, uuid_view.GetCString());
ASSERT_FALSE(ec);
const bool expect_download = false;
diff --git a/lldb/unittests/Utility/FileSpecTest.cpp b/lldb/unittests/Utility/FileSpecTest.cpp
index 0249dd5a98a4d..f92be63892cd9 100644
--- a/lldb/unittests/Utility/FileSpecTest.cpp
+++ b/lldb/unittests/Utility/FileSpecTest.cpp
@@ -22,92 +22,92 @@ static FileSpec WindowsSpec(llvm::StringRef path) {
TEST(FileSpecTest, FileAndDirectoryComponents) {
FileSpec fs_posix("/foo/bar", FileSpec::Style::posix);
- EXPECT_STREQ("/foo/bar", fs_posix.GetPath().c_str());
+ EXPECT_STREQ("/foo/bar", fs_posix.GetCString());
EXPECT_STREQ("/foo", fs_posix.GetDirectory().GetCString());
EXPECT_STREQ("bar", fs_posix.GetFilename().GetCString());
FileSpec fs_windows("F:\\bar", FileSpec::Style::windows);
- EXPECT_STREQ("F:\\bar", fs_windows.GetPath().c_str());
- // EXPECT_STREQ("F:\\", fs_windows.GetDirectory().GetPath().c_str()); // It returns
+ EXPECT_STREQ("F:\\bar", fs_windows.GetCString());
+ // EXPECT_STREQ("F:\\", fs_windows.GetDirectory().GetCString()); // It returns
// "F:/"
EXPECT_STREQ("bar", fs_windows.GetFilename().GetCString());
FileSpec fs_posix_root("/", FileSpec::Style::posix);
- EXPECT_STREQ("/", fs_posix_root.GetPath().c_str());
+ EXPECT_STREQ("/", fs_posix_root.GetCString());
EXPECT_EQ(nullptr, fs_posix_root.GetDirectory().GetCString());
EXPECT_STREQ("/", fs_posix_root.GetFilename().GetCString());
FileSpec fs_net_drive("//net", FileSpec::Style::posix);
- EXPECT_STREQ("//net", fs_net_drive.GetPath().c_str());
+ EXPECT_STREQ("//net", fs_net_drive.GetCString());
EXPECT_EQ(nullptr, fs_net_drive.GetDirectory().GetCString());
EXPECT_STREQ("//net", fs_net_drive.GetFilename().GetCString());
FileSpec fs_net_root("//net/", FileSpec::Style::posix);
- EXPECT_STREQ("//net/", fs_net_root.GetPath().c_str());
+ EXPECT_STREQ("//net/", fs_net_root.GetCString());
EXPECT_STREQ("//net", fs_net_root.GetDirectory().GetCString());
EXPECT_STREQ("/", fs_net_root.GetFilename().GetCString());
FileSpec fs_windows_drive("F:", FileSpec::Style::windows);
- EXPECT_STREQ("F:", fs_windows_drive.GetPath().c_str());
+ EXPECT_STREQ("F:", fs_windows_drive.GetCString());
EXPECT_EQ(nullptr, fs_windows_drive.GetDirectory().GetCString());
EXPECT_STREQ("F:", fs_windows_drive.GetFilename().GetCString());
FileSpec fs_windows_root("F:\\", FileSpec::Style::windows);
- EXPECT_STREQ("F:\\", fs_windows_root.GetPath().c_str());
+ EXPECT_STREQ("F:\\", fs_windows_root.GetCString());
EXPECT_STREQ("F:", fs_windows_root.GetDirectory().GetCString());
// EXPECT_STREQ("\\", fs_windows_root.GetFilename().GetCString()); // It
// returns "/"
FileSpec fs_posix_long("/foo/bar/baz", FileSpec::Style::posix);
- EXPECT_STREQ("/foo/bar/baz", fs_posix_long.GetPath().c_str());
+ EXPECT_STREQ("/foo/bar/baz", fs_posix_long.GetCString());
EXPECT_STREQ("/foo/bar", fs_posix_long.GetDirectory().GetCString());
EXPECT_STREQ("baz", fs_posix_long.GetFilename().GetCString());
FileSpec fs_windows_long("F:\\bar\\baz", FileSpec::Style::windows);
- EXPECT_STREQ("F:\\bar\\baz", fs_windows_long.GetPath().c_str());
+ EXPECT_STREQ("F:\\bar\\baz", fs_windows_long.GetCString());
// EXPECT_STREQ("F:\\bar", fs_windows_long.GetDirectory().GetCString()); // It
// returns "F:/bar"
EXPECT_STREQ("baz", fs_windows_long.GetFilename().GetCString());
FileSpec fs_posix_trailing_slash("/foo/bar/", FileSpec::Style::posix);
- EXPECT_STREQ("/foo/bar", fs_posix_trailing_slash.GetPath().c_str());
+ EXPECT_STREQ("/foo/bar", fs_posix_trailing_slash.GetCString());
EXPECT_STREQ("/foo", fs_posix_trailing_slash.GetDirectory().GetCString());
EXPECT_STREQ("bar", fs_posix_trailing_slash.GetFilename().GetCString());
FileSpec fs_windows_trailing_slash("F:\\bar\\", FileSpec::Style::windows);
- EXPECT_STREQ("F:\\bar", fs_windows_trailing_slash.GetPath().c_str());
+ EXPECT_STREQ("F:\\bar", fs_windows_trailing_slash.GetCString());
EXPECT_STREQ("bar", fs_windows_trailing_slash.GetFilename().GetCString());
}
TEST(FileSpecTest, AppendPathComponent) {
FileSpec fs_posix("/foo", FileSpec::Style::posix);
fs_posix.AppendPathComponent("bar");
- EXPECT_STREQ("/foo/bar", fs_posix.GetPath().c_str());
+ EXPECT_STREQ("/foo/bar", fs_posix.GetCString());
EXPECT_STREQ("/foo", fs_posix.GetDirectory().GetCString());
EXPECT_STREQ("bar", fs_posix.GetFilename().GetCString());
FileSpec fs_posix_2("/foo", FileSpec::Style::posix);
fs_posix_2.AppendPathComponent("//bar/baz");
- EXPECT_STREQ("/foo/bar/baz", fs_posix_2.GetPath().c_str());
+ EXPECT_STREQ("/foo/bar/baz", fs_posix_2.GetCString());
EXPECT_STREQ("/foo/bar", fs_posix_2.GetDirectory().GetCString());
EXPECT_STREQ("baz", fs_posix_2.GetFilename().GetCString());
FileSpec fs_windows("F:\\bar", FileSpec::Style::windows);
fs_windows.AppendPathComponent("baz");
- EXPECT_STREQ("F:\\bar\\baz", fs_windows.GetPath().c_str());
+ EXPECT_STREQ("F:\\bar\\baz", fs_windows.GetCString());
// EXPECT_STREQ("F:\\bar", fs_windows.GetDirectory().GetCString()); // It
// returns "F:/bar"
EXPECT_STREQ("baz", fs_windows.GetFilename().GetCString());
FileSpec fs_posix_root("/", FileSpec::Style::posix);
fs_posix_root.AppendPathComponent("bar");
- EXPECT_STREQ("/bar", fs_posix_root.GetPath().c_str());
+ EXPECT_STREQ("/bar", fs_posix_root.GetCString());
EXPECT_STREQ("/", fs_posix_root.GetDirectory().GetCString());
EXPECT_STREQ("bar", fs_posix_root.GetFilename().GetCString());
FileSpec fs_windows_root("F:\\", FileSpec::Style::windows);
fs_windows_root.AppendPathComponent("bar");
- EXPECT_STREQ("F:\\bar", fs_windows_root.GetPath().c_str());
+ EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString());
// EXPECT_STREQ("F:\\", fs_windows_root.GetDirectory().GetCString()); // It
// returns "F:/"
EXPECT_STREQ("bar", fs_windows_root.GetFilename().GetCString());
@@ -115,7 +115,7 @@ TEST(FileSpecTest, AppendPathComponent) {
TEST(FileSpecTest, CopyByAppendingPathComponent) {
FileSpec fs = PosixSpec("/foo").CopyByAppendingPathComponent("bar");
- EXPECT_STREQ("/foo/bar", fs.GetPath().c_str());
+ EXPECT_STREQ("/foo/bar", fs.GetCString());
EXPECT_STREQ("/foo", fs.GetDirectory().GetCString());
EXPECT_STREQ("bar", fs.GetFilename().GetCString());
}
@@ -123,23 +123,23 @@ TEST(FileSpecTest, CopyByAppendingPathComponent) {
TEST(FileSpecTest, PrependPathComponent) {
FileSpec fs_posix("foo", FileSpec::Style::posix);
fs_posix.PrependPathComponent("/bar");
- EXPECT_STREQ("/bar/foo", fs_posix.GetPath().c_str());
+ EXPECT_STREQ("/bar/foo", fs_posix.GetCString());
FileSpec fs_posix_2("foo/bar", FileSpec::Style::posix);
fs_posix_2.PrependPathComponent("/baz");
- EXPECT_STREQ("/baz/foo/bar", fs_posix_2.GetPath().c_str());
+ EXPECT_STREQ("/baz/foo/bar", fs_posix_2.GetCString());
FileSpec fs_windows("baz", FileSpec::Style::windows);
fs_windows.PrependPathComponent("F:\\bar");
- EXPECT_STREQ("F:\\bar\\baz", fs_windows.GetPath().c_str());
+ EXPECT_STREQ("F:\\bar\\baz", fs_windows.GetCString());
FileSpec fs_posix_root("bar", FileSpec::Style::posix);
fs_posix_root.PrependPathComponent("/");
- EXPECT_STREQ("/bar", fs_posix_root.GetPath().c_str());
+ EXPECT_STREQ("/bar", fs_posix_root.GetCString());
FileSpec fs_windows_root("bar", FileSpec::Style::windows);
fs_windows_root.PrependPathComponent("F:\\");
- EXPECT_STREQ("F:\\bar", fs_windows_root.GetPath().c_str());
+ EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString());
}
TEST(FileSpecTest, EqualSeparator) {
@@ -343,44 +343,44 @@ TEST(FileSpecTest, IsRelative) {
TEST(FileSpecTest, RemoveLastPathComponent) {
FileSpec fs_posix("/foo/bar/baz", FileSpec::Style::posix);
- EXPECT_STREQ("/foo/bar/baz", fs_posix.GetPath().c_str());
+ EXPECT_STREQ("/foo/bar/baz", fs_posix.GetCString());
EXPECT_TRUE(fs_posix.RemoveLastPathComponent());
- EXPECT_STREQ("/foo/bar", fs_posix.GetPath().c_str());
+ EXPECT_STREQ("/foo/bar", fs_posix.GetCString());
EXPECT_TRUE(fs_posix.RemoveLastPathComponent());
- EXPECT_STREQ("/foo", fs_posix.GetPath().c_str());
+ EXPECT_STREQ("/foo", fs_posix.GetCString());
EXPECT_TRUE(fs_posix.RemoveLastPathComponent());
- EXPECT_STREQ("/", fs_posix.GetPath().c_str());
+ EXPECT_STREQ("/", fs_posix.GetCString());
EXPECT_FALSE(fs_posix.RemoveLastPathComponent());
- EXPECT_STREQ("/", fs_posix.GetPath().c_str());
+ EXPECT_STREQ("/", fs_posix.GetCString());
FileSpec fs_posix_relative("./foo/bar/baz", FileSpec::Style::posix);
- EXPECT_STREQ("foo/bar/baz", fs_posix_relative.GetPath().c_str());
+ EXPECT_STREQ("foo/bar/baz", fs_posix_relative.GetCString());
EXPECT_TRUE(fs_posix_relative.RemoveLastPathComponent());
- EXPECT_STREQ("foo/bar", fs_posix_relative.GetPath().c_str());
+ EXPECT_STREQ("foo/bar", fs_posix_relative.GetCString());
EXPECT_TRUE(fs_posix_relative.RemoveLastPathComponent());
- EXPECT_STREQ("foo", fs_posix_relative.GetPath().c_str());
+ EXPECT_STREQ("foo", fs_posix_relative.GetCString());
EXPECT_FALSE(fs_posix_relative.RemoveLastPathComponent());
- EXPECT_STREQ("foo", fs_posix_relative.GetPath().c_str());
+ EXPECT_STREQ("foo", fs_posix_relative.GetCString());
FileSpec fs_posix_relative2("./", FileSpec::Style::posix);
- EXPECT_STREQ(".", fs_posix_relative2.GetPath().c_str());
+ EXPECT_STREQ(".", fs_posix_relative2.GetCString());
EXPECT_FALSE(fs_posix_relative2.RemoveLastPathComponent());
- EXPECT_STREQ(".", fs_posix_relative2.GetPath().c_str());
+ EXPECT_STREQ(".", fs_posix_relative2.GetCString());
EXPECT_FALSE(fs_posix_relative.RemoveLastPathComponent());
- EXPECT_STREQ(".", fs_posix_relative2.GetPath().c_str());
+ EXPECT_STREQ(".", fs_posix_relative2.GetCString());
FileSpec fs_windows("C:\\foo\\bar\\baz", FileSpec::Style::windows);
- EXPECT_STREQ("C:\\foo\\bar\\baz", fs_windows.GetPath().c_str());
+ EXPECT_STREQ("C:\\foo\\bar\\baz", fs_windows.GetCString());
EXPECT_TRUE(fs_windows.RemoveLastPathComponent());
- EXPECT_STREQ("C:\\foo\\bar", fs_windows.GetPath().c_str());
+ EXPECT_STREQ("C:\\foo\\bar", fs_windows.GetCString());
EXPECT_TRUE(fs_windows.RemoveLastPathComponent());
- EXPECT_STREQ("C:\\foo", fs_windows.GetPath().c_str());
+ EXPECT_STREQ("C:\\foo", fs_windows.GetCString());
EXPECT_TRUE(fs_windows.RemoveLastPathComponent());
- EXPECT_STREQ("C:\\", fs_windows.GetPath().c_str());
+ EXPECT_STREQ("C:\\", fs_windows.GetCString());
EXPECT_TRUE(fs_windows.RemoveLastPathComponent());
- EXPECT_STREQ("C:", fs_windows.GetPath().c_str());
+ EXPECT_STREQ("C:", fs_windows.GetCString());
EXPECT_FALSE(fs_windows.RemoveLastPathComponent());
- EXPECT_STREQ("C:", fs_windows.GetPath().c_str());
+ EXPECT_STREQ("C:", fs_windows.GetCString());
}
TEST(FileSpecTest, Equal) {
@@ -450,29 +450,3 @@ TEST(FileSpecTest, OperatorBool) {
EXPECT_FALSE(FileSpec(""));
EXPECT_TRUE(FileSpec("/foo/bar"));
}
-
-
-TEST(FileSpecTest, TestAbsoluteCaching) {
- // Test that if we modify a path that we recalculate if a path is relative
- // or absolute correctly. The test below calls set accessors and functions
- // that change the path and verifies that the FileSpec::IsAbsolute() returns
- // the correct value.
- FileSpec file = PosixSpec("/tmp/a");
- EXPECT_TRUE(file.IsAbsolute());
- file.ClearDirectory();
- EXPECT_FALSE(file.IsAbsolute());
- file.SetDirectory("/tmp");
- EXPECT_TRUE(file.IsAbsolute());
- file.SetDirectory(".");
- EXPECT_FALSE(file.IsAbsolute());
- file.SetPath("/log.txt");
- EXPECT_TRUE(file.IsAbsolute());
- file.RemoveLastPathComponent();
- EXPECT_TRUE(file.IsAbsolute());
- file.ClearFilename();
- EXPECT_FALSE(file.IsAbsolute());
- file.AppendPathComponent("foo.txt");
- EXPECT_FALSE(file.IsAbsolute());
- file.PrependPathComponent("/tmp");
- EXPECT_TRUE(file.IsAbsolute());
-}
More information about the lldb-commits
mailing list