Change FileAction::GetPath() to return a StringRef.

llvm-svn: 282306
This commit is contained in:
Zachary Turner 2016-09-23 22:11:51 +00:00
parent 382e5d991f
commit 27a5c2b302
5 changed files with 22 additions and 31 deletions

View File

@ -40,7 +40,7 @@ public:
int GetActionArgument() const { return m_arg; }
const char *GetPath() const;
llvm::StringRef GetPath() const;
const FileSpec &GetFileSpec() const;

View File

@ -137,16 +137,16 @@ public:
uint32_t GetMaximumMemReadSize() const;
FileSpec GetStandardInputPath() const;
void SetStandardInputPath(const char *path);
FileSpec GetStandardErrorPath() const;
FileSpec GetStandardOutputPath() const;
void SetStandardOutputPath(const char *path);
void SetStandardInputPath(llvm::StringRef path);
void SetStandardOutputPath(llvm::StringRef path);
void SetStandardErrorPath(llvm::StringRef path);
FileSpec GetStandardErrorPath() const;
void SetStandardErrorPath(const char *path);
void SetStandardInputPath(const char *path) = delete;
void SetStandardOutputPath(const char *path) = delete;
void SetStandardErrorPath(const char *path) = delete;
bool GetBreakpointsConsultPlatformAvoidList();

View File

@ -124,7 +124,7 @@ ProcessLauncherWindows::GetStdioHandle(const ProcessLaunchInfo &launch_info,
secattr.nLength = sizeof(SECURITY_ATTRIBUTES);
secattr.bInheritHandle = TRUE;
const char *path = action->GetPath();
llvm::StringRef path = action->GetPath();
DWORD access = 0;
DWORD share = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
DWORD create = 0;

View File

@ -29,7 +29,7 @@ void FileAction::Clear() {
m_file_spec.Clear();
}
const char *FileAction::GetPath() const { return m_file_spec.GetCString(); }
llvm::StringRef FileAction::GetPath() const { return m_file_spec.GetCString(); }
const FileSpec &FileAction::GetFileSpec() const { return m_file_spec; }

View File

@ -3817,10 +3817,9 @@ FileSpec TargetProperties::GetStandardInputPath() const {
return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
}
void TargetProperties::SetStandardInputPath(const char *p) {
void TargetProperties::SetStandardInputPath(llvm::StringRef path) {
const uint32_t idx = ePropertyInputPath;
m_collection_sp->SetPropertyAtIndexAsString(
nullptr, idx, llvm::StringRef::withNullAsEmpty(p));
m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, path);
}
FileSpec TargetProperties::GetStandardOutputPath() const {
@ -3828,10 +3827,9 @@ FileSpec TargetProperties::GetStandardOutputPath() const {
return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
}
void TargetProperties::SetStandardOutputPath(const char *p) {
void TargetProperties::SetStandardOutputPath(llvm::StringRef path) {
const uint32_t idx = ePropertyOutputPath;
m_collection_sp->SetPropertyAtIndexAsString(
nullptr, idx, llvm::StringRef::withNullAsEmpty(p));
m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, path);
}
FileSpec TargetProperties::GetStandardErrorPath() const {
@ -3839,6 +3837,11 @@ FileSpec TargetProperties::GetStandardErrorPath() const {
return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
}
void TargetProperties::SetStandardErrorPath(llvm::StringRef path) {
const uint32_t idx = ePropertyErrorPath;
m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, path);
}
LanguageType TargetProperties::GetLanguage() const {
OptionValueLanguage *value =
m_collection_sp->GetPropertyAtIndexAsOptionValueLanguage(
@ -3862,12 +3865,6 @@ const char *TargetProperties::GetExpressionPrefixContentsAsCString() {
return nullptr;
}
void TargetProperties::SetStandardErrorPath(const char *p) {
const uint32_t idx = ePropertyErrorPath;
m_collection_sp->SetPropertyAtIndexAsString(
nullptr, idx, llvm::StringRef::withNullAsEmpty(p));
}
bool TargetProperties::GetBreakpointsConsultPlatformAvoidList() {
const uint32_t idx = ePropertyBreakpointUseAvoidList;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
@ -3963,23 +3960,17 @@ void TargetProperties::SetProcessLaunchInfo(
const FileAction *input_file_action =
launch_info.GetFileActionForFD(STDIN_FILENO);
if (input_file_action) {
const char *input_path = input_file_action->GetPath();
if (input_path)
SetStandardInputPath(input_path);
SetStandardInputPath(input_file_action->GetPath());
}
const FileAction *output_file_action =
launch_info.GetFileActionForFD(STDOUT_FILENO);
if (output_file_action) {
const char *output_path = output_file_action->GetPath();
if (output_path)
SetStandardOutputPath(output_path);
SetStandardOutputPath(output_file_action->GetPath());
}
const FileAction *error_file_action =
launch_info.GetFileActionForFD(STDERR_FILENO);
if (error_file_action) {
const char *error_path = error_file_action->GetPath();
if (error_path)
SetStandardErrorPath(error_path);
SetStandardErrorPath(error_file_action->GetPath());
}
SetDetachOnError(launch_info.GetFlags().Test(lldb::eLaunchFlagDetachOnError));
SetDisableASLR(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableASLR));