diff options
author | Alexander Kornienko <alexfh@google.com> | 2017-09-13 17:03:37 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2017-09-13 17:03:37 +0000 |
commit | 208eecd57fd7f2b2072f70f8fe81f1f5dd68267a (patch) | |
tree | 54617190d336acb1f3cc7764bb91d9b785abfd25 /llvm/lib/Support/Program.cpp | |
parent | f6c74c472d00467e9007dfffb26278ec053957aa (diff) | |
download | bcm5719-llvm-208eecd57fd7f2b2072f70f8fe81f1f5dd68267a.tar.gz bcm5719-llvm-208eecd57fd7f2b2072f70f8fe81f1f5dd68267a.zip |
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
llvm-svn: 313155
Diffstat (limited to 'llvm/lib/Support/Program.cpp')
-rw-r--r-- | llvm/lib/Support/Program.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Support/Program.cpp b/llvm/lib/Support/Program.cpp index f9f64cca7c9..4212323bc0e 100644 --- a/llvm/lib/Support/Program.cpp +++ b/llvm/lib/Support/Program.cpp @@ -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; |