mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 11:02:04 +08:00
[lldb][NFCI] Remove FileAction::GetPath (#170764)
This method puts strings into the ConstString pool and vends them as llvm::StringRefs. Most of the uses only require a `std::string` or a `const char *`. This can be achieved without wasting memory.
This commit is contained in:
@@ -39,8 +39,6 @@ public:
|
||||
|
||||
int GetActionArgument() const { return m_arg; }
|
||||
|
||||
llvm::StringRef GetPath() const;
|
||||
|
||||
const FileSpec &GetFileSpec() const;
|
||||
|
||||
void Dump(Stream &stream) const;
|
||||
|
||||
@@ -25,10 +25,6 @@ void FileAction::Clear() {
|
||||
m_file_spec.Clear();
|
||||
}
|
||||
|
||||
llvm::StringRef FileAction::GetPath() const {
|
||||
return m_file_spec.GetPathAsConstString().AsCString();
|
||||
}
|
||||
|
||||
const FileSpec &FileAction::GetFileSpec() const { return m_file_spec; }
|
||||
|
||||
bool FileAction::Open(int fd, const FileSpec &file_spec, bool read,
|
||||
|
||||
@@ -1013,20 +1013,29 @@ static Status LaunchProcessXPC(const char *exe_path,
|
||||
xpc_dictionary_set_int64(message, LauncherXPCServicePosixspawnFlagsKey,
|
||||
GetPosixspawnFlags(launch_info));
|
||||
const FileAction *file_action = launch_info.GetFileActionForFD(STDIN_FILENO);
|
||||
if (file_action && !file_action->GetPath().empty()) {
|
||||
std::string file_action_path;
|
||||
if (file_action)
|
||||
file_action_path = file_action->GetFileSpec().GetPath();
|
||||
|
||||
if (!file_action_path.empty())
|
||||
xpc_dictionary_set_string(message, LauncherXPCServiceStdInPathKeyKey,
|
||||
file_action->GetPath().str().c_str());
|
||||
}
|
||||
file_action_path.c_str());
|
||||
|
||||
file_action = launch_info.GetFileActionForFD(STDOUT_FILENO);
|
||||
if (file_action && !file_action->GetPath().empty()) {
|
||||
if (file_action)
|
||||
file_action_path = file_action->GetFileSpec().GetPath();
|
||||
|
||||
if (!file_action_path.empty())
|
||||
xpc_dictionary_set_string(message, LauncherXPCServiceStdOutPathKeyKey,
|
||||
file_action->GetPath().str().c_str());
|
||||
}
|
||||
file_action_path.c_str());
|
||||
|
||||
file_action = launch_info.GetFileActionForFD(STDERR_FILENO);
|
||||
if (file_action && !file_action->GetPath().empty()) {
|
||||
if (file_action)
|
||||
file_action_path = file_action->GetFileSpec().GetPath();
|
||||
|
||||
if (!file_action_path.empty())
|
||||
xpc_dictionary_set_string(message, LauncherXPCServiceStdErrPathKeyKey,
|
||||
file_action->GetPath().str().c_str());
|
||||
}
|
||||
file_action_path.c_str());
|
||||
|
||||
xpc_object_t reply =
|
||||
xpc_connection_send_message_with_reply_sync(conn, message);
|
||||
@@ -1135,16 +1144,16 @@ static bool AddPosixSpawnFileAction(void *_file_actions, const FileAction *info,
|
||||
if (oflag & O_CREAT)
|
||||
mode = 0640;
|
||||
|
||||
error = Status(::posix_spawn_file_actions_addopen(
|
||||
file_actions, info->GetFD(),
|
||||
info->GetPath().str().c_str(), oflag, mode),
|
||||
eErrorTypePOSIX);
|
||||
const std::string file_path(info->GetFileSpec().GetPath());
|
||||
error = Status(
|
||||
::posix_spawn_file_actions_addopen(file_actions, info->GetFD(),
|
||||
file_path.c_str(), oflag, mode),
|
||||
eErrorTypePOSIX);
|
||||
if (error.Fail())
|
||||
LLDB_LOG(log,
|
||||
"error: {0}, posix_spawn_file_actions_addopen (action={1}, "
|
||||
"fd={2}, path='{3}', oflag={4}, mode={5})",
|
||||
error, file_actions, info->GetFD(), info->GetPath(), oflag,
|
||||
mode);
|
||||
error, file_actions, info->GetFD(), file_path, oflag, mode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -229,8 +229,8 @@ struct ForkLaunchInfo {
|
||||
// End of code running in the child process.
|
||||
|
||||
ForkFileAction::ForkFileAction(const FileAction &act)
|
||||
: action(act.GetAction()), fd(act.GetFD()), path(act.GetPath().str()),
|
||||
arg(act.GetActionArgument()) {}
|
||||
: action(act.GetAction()), fd(act.GetFD()),
|
||||
path(act.GetFileSpec().GetPath()), arg(act.GetActionArgument()) {}
|
||||
|
||||
static std::vector<ForkFileAction>
|
||||
MakeForkActions(const ProcessLaunchInfo &info) {
|
||||
|
||||
@@ -5145,17 +5145,17 @@ void TargetProperties::SetProcessLaunchInfo(
|
||||
const FileAction *input_file_action =
|
||||
launch_info.GetFileActionForFD(STDIN_FILENO);
|
||||
if (input_file_action) {
|
||||
SetStandardInputPath(input_file_action->GetPath());
|
||||
SetStandardInputPath(input_file_action->GetFileSpec().GetPath());
|
||||
}
|
||||
const FileAction *output_file_action =
|
||||
launch_info.GetFileActionForFD(STDOUT_FILENO);
|
||||
if (output_file_action) {
|
||||
SetStandardOutputPath(output_file_action->GetPath());
|
||||
SetStandardOutputPath(output_file_action->GetFileSpec().GetPath());
|
||||
}
|
||||
const FileAction *error_file_action =
|
||||
launch_info.GetFileActionForFD(STDERR_FILENO);
|
||||
if (error_file_action) {
|
||||
SetStandardErrorPath(error_file_action->GetPath());
|
||||
SetStandardErrorPath(error_file_action->GetFileSpec().GetPath());
|
||||
}
|
||||
SetDetachOnError(launch_info.GetFlags().Test(lldb::eLaunchFlagDetachOnError));
|
||||
SetDisableASLR(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableASLR));
|
||||
|
||||
Reference in New Issue
Block a user