diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 | 
| commit | 044eb2f6afba375a914ac9d8024f8f5142bb912e (patch) | |
| tree | 1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /include/llvm/Support/Program.h | |
| parent | eb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff) | |
Notes
Diffstat (limited to 'include/llvm/Support/Program.h')
| -rw-r--r-- | include/llvm/Support/Program.h | 51 | 
1 files changed, 27 insertions, 24 deletions
| diff --git a/include/llvm/Support/Program.h b/include/llvm/Support/Program.h index 055f016d8243..06fd35078145 100644 --- a/include/llvm/Support/Program.h +++ b/include/llvm/Support/Program.h @@ -15,12 +15,12 @@  #define LLVM_SUPPORT_PROGRAM_H  #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringRef.h"  #include "llvm/Support/ErrorOr.h"  #include <system_error>  namespace llvm { -class StringRef; -  namespace sys {    /// This is the OS-specific separator for PATH like environment variables: @@ -69,7 +69,7 @@ struct ProcessInfo {    /// \returns The fully qualified path to the first \p Name in \p Paths if it    ///   exists. \p Name if \p Name has slashes in it. Otherwise an error.    ErrorOr<std::string> -  findProgramByName(StringRef Name, ArrayRef<StringRef> Paths = None); +  findProgramByName(StringRef Name, ArrayRef<StringRef> Paths = {});    // These functions change the specified standard stream (stdin or stdout) to    // binary mode. They return errc::success if the specified stream @@ -84,33 +84,33 @@ struct ProcessInfo {    /// This function waits for the program to finish, so should be avoided in    /// library functions that aren't expected to block. Consider using    /// ExecuteNoWait() instead. -  /// @returns an integer result code indicating the status of the program. +  /// \returns an integer result code indicating the status of the program.    /// A zero or positive value indicates the result code of the program.    /// -1 indicates failure to execute    /// -2 indicates a crash during execution or timeout    int ExecuteAndWait(        StringRef Program, ///< Path of the program to be executed. It is        ///< presumed this is the result of the findProgramByName method. -      const char **args, ///< A vector of strings that are passed to the +      const char **Args, ///< A vector of strings that are passed to the        ///< program.  The first element should be the name of the program.        ///< The list *must* be terminated by a null char* entry. -      const char **env = nullptr, ///< An optional vector of strings to use for +      const char **Env = nullptr, ///< An optional vector of strings to use for        ///< the program's environment. If not provided, the current program's        ///< environment will be used. -      const StringRef **redirects = nullptr, ///< An optional array of pointers -      ///< to paths. If the array is null, no redirection is done. The array -      ///< should have a size of at least three. The inferior process's -      ///< stdin(0), stdout(1), and stderr(2) will be redirected to the -      ///< corresponding paths. -      ///< When an empty path is passed in, the corresponding file -      ///< descriptor will be disconnected (ie, /dev/null'd) in a portable -      ///< way. -      unsigned secondsToWait = 0, ///< If non-zero, this specifies the amount +      ArrayRef<Optional<StringRef>> Redirects = {}, ///< +      ///< An array of optional paths. Should have a size of zero or three. +      ///< If the array is empty, no redirections are performed. +      ///< Otherwise, the inferior process's stdin(0), stdout(1), and stderr(2) +      ///< will be redirected to the corresponding paths, if the optional path +      ///< is present (not \c llvm::None). +      ///< When an empty path is passed in, the corresponding file descriptor +      ///< will be disconnected (ie, /dev/null'd) in a portable way. +      unsigned SecondsToWait = 0, ///< If non-zero, this specifies the amount        ///< of time to wait for the child process to exit. If the time        ///< expires, the child is killed and this call returns. If zero,        ///< this function will wait until the child finishes or forever if        ///< it doesn't. -      unsigned memoryLimit = 0, ///< If non-zero, this specifies max. amount +      unsigned MemoryLimit = 0, ///< If non-zero, this specifies max. amount        ///< of memory can be allocated by process. If memory usage will be        ///< higher limit, the child is killed and this call returns. If zero        ///< - no memory limit. @@ -122,17 +122,20 @@ struct ProcessInfo {    /// Similar to ExecuteAndWait, but returns immediately.    /// @returns The \see ProcessInfo of the newly launced process. -  /// \note On Microsoft Windows systems, users will need to either call \see -  /// Wait until the process finished execution or win32 CloseHandle() API on -  /// ProcessInfo.ProcessHandle to avoid memory leaks. -  ProcessInfo -  ExecuteNoWait(StringRef Program, const char **args, const char **env = nullptr, -                const StringRef **redirects = nullptr, unsigned memoryLimit = 0, -                std::string *ErrMsg = nullptr, bool *ExecutionFailed = nullptr); +  /// \note On Microsoft Windows systems, users will need to either call +  /// \see Wait until the process finished execution or win32 CloseHandle() API +  /// on ProcessInfo.ProcessHandle to avoid memory leaks. +  ProcessInfo ExecuteNoWait(StringRef Program, const char **Args, +                            const char **Env = nullptr, +                            ArrayRef<Optional<StringRef>> Redirects = {}, +                            unsigned MemoryLimit = 0, +                            std::string *ErrMsg = nullptr, +                            bool *ExecutionFailed = nullptr);    /// Return true if the given arguments fit within system-specific    /// argument length limits. -  bool commandLineFitsWithinSystemLimits(StringRef Program, ArrayRef<const char*> Args); +  bool commandLineFitsWithinSystemLimits(StringRef Program, +                                         ArrayRef<const char *> Args);    /// File encoding options when writing contents that a non-UTF8 tool will    /// read (on Windows systems). For UNIX, we always use UTF-8. | 
