mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-21 03:05:26 -04:00
Convenience/safety fix for llvm::sys::Execute(And|No)Wait
Summary: Change the type of the Redirects parameter of llvm::sys::ExecuteAndWait, ExecuteNoWait and other APIs that wrap them from `const StringRef **` to `ArrayRef<Optional<StringRef>>`, which is safer and simplifies the use of these APIs (no more local StringRef variables just to get a pointer to). Corresponding clang changes will be posted as a separate patch. Reviewers: bkramer Reviewed By: bkramer Subscribers: vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D37563 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313155 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -24,13 +24,14 @@ using namespace sys;
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
static bool Execute(ProcessInfo &PI, StringRef Program, const char **Args,
|
||||
const char **Env, const StringRef **Redirects,
|
||||
const char **Env, ArrayRef<Optional<StringRef>> Redirects,
|
||||
unsigned MemoryLimit, std::string *ErrMsg);
|
||||
|
||||
int sys::ExecuteAndWait(StringRef Program, const char **Args, const char **Envp,
|
||||
const StringRef **Redirects, unsigned SecondsToWait,
|
||||
unsigned MemoryLimit, std::string *ErrMsg,
|
||||
bool *ExecutionFailed) {
|
||||
ArrayRef<Optional<StringRef>> Redirects,
|
||||
unsigned SecondsToWait, unsigned MemoryLimit,
|
||||
std::string *ErrMsg, bool *ExecutionFailed) {
|
||||
assert(Redirects.empty() || Redirects.size() == 3);
|
||||
ProcessInfo PI;
|
||||
if (Execute(PI, Program, Args, Envp, Redirects, MemoryLimit, ErrMsg)) {
|
||||
if (ExecutionFailed)
|
||||
@@ -47,9 +48,11 @@ int sys::ExecuteAndWait(StringRef Program, const char **Args, const char **Envp,
|
||||
}
|
||||
|
||||
ProcessInfo sys::ExecuteNoWait(StringRef Program, const char **Args,
|
||||
const char **Envp, const StringRef **Redirects,
|
||||
const char **Envp,
|
||||
ArrayRef<Optional<StringRef>> Redirects,
|
||||
unsigned MemoryLimit, std::string *ErrMsg,
|
||||
bool *ExecutionFailed) {
|
||||
assert(Redirects.empty() || Redirects.size() == 3);
|
||||
ProcessInfo PI;
|
||||
if (ExecutionFailed)
|
||||
*ExecutionFailed = false;
|
||||
|
||||
Reference in New Issue
Block a user