LLVM: lib/Support/Program.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

15#include "llvm/Config/llvm-config.h"

17using namespace llvm;

18using namespace sys;

19

20

21

22

23

24

28 ArrayRef<std::optional> Redirects,

29 unsigned MemoryLimit, std::string *ErrMsg,

30 BitVector *AffinityMask, bool DetachProcess);

31

34 ArrayRef<std::optional> Redirects,

35 unsigned SecondsToWait, unsigned MemoryLimit,

36 std::string *ErrMsg, bool *ExecutionFailed,

37 std::optional *ProcStat,

39 assert(Redirects.empty() || Redirects.size() == 3);

41 if (Execute(PI, Program, Args, Env, Redirects, MemoryLimit, ErrMsg,

42 AffinityMask, false)) {

43 if (ExecutionFailed)

44 *ExecutionFailed = false;

46 PI, SecondsToWait == 0 ? std::nullopt : std::optional(SecondsToWait),

47 ErrMsg, ProcStat);

48 return Result.ReturnCode;

49 }

50

51 if (ExecutionFailed)

52 *ExecutionFailed = true;

53

54 return -1;

55}

56

59 ArrayRef<std::optional> Redirects,

60 unsigned MemoryLimit, std::string *ErrMsg,

61 bool *ExecutionFailed, BitVector *AffinityMask,

62 bool DetachProcess) {

63 assert(Redirects.empty() || Redirects.size() == 3);

65 if (ExecutionFailed)

66 *ExecutionFailed = false;

67 if (Execute(PI, Program, Args, Env, Redirects, MemoryLimit, ErrMsg,

68 AffinityMask, DetachProcess))

69 if (ExecutionFailed)

70 *ExecutionFailed = true;

71

72 return PI;

73}

74

78 StringRefArgs.reserve(Args.size());

79 for (const char *A : Args)

82}

83

86

87 if (!Quote && !Escape) {

88 OS << Arg;

89 return;

90 }

91

92

93 OS << '"';

94 for (const auto c : Arg) {

95 if (c == '"' || c == '\\' || c == '$')

96 OS << '\\';

97 OS << c;

98 }

99 OS << '"';

100}

101

102

103#ifdef LLVM_ON_UNIX

105#endif

106#ifdef _WIN32

108#endif

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static bool Execute(ProcessInfo &PI, StringRef Program, ArrayRef< StringRef > Args, std::optional< ArrayRef< StringRef > > Env, ArrayRef< std::optional< StringRef > > Redirects, unsigned MemoryLimit, std::string *ErrMsg, BitVector *AffinityMask, bool DetachProcess)

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

reference emplace_back(ArgTypes &&... Args)

void reserve(size_type N)

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

size_t find_first_of(char C, size_t From=0) const

Find the first character in the string that is C, or npos if not found.

static constexpr size_t npos

This class implements an extremely fast bulk output stream that can only output to a stream.

void printArg(llvm::raw_ostream &OS, StringRef Arg, bool Quote)

Print a command argument, and optionally quote it.

ProcessInfo ExecuteNoWait(StringRef Program, ArrayRef< StringRef > Args, std::optional< ArrayRef< StringRef > > Env, ArrayRef< std::optional< StringRef > > Redirects={}, unsigned MemoryLimit=0, std::string *ErrMsg=nullptr, bool *ExecutionFailed=nullptr, BitVector *AffinityMask=nullptr, bool DetachProcess=false)

Similar to ExecuteAndWait, but returns immediately.

bool commandLineFitsWithinSystemLimits(StringRef Program, ArrayRef< StringRef > Args)

Return true if the given arguments fit within system-specific argument length limits.

int ExecuteAndWait(StringRef Program, ArrayRef< StringRef > Args, std::optional< ArrayRef< StringRef > > Env=std::nullopt, ArrayRef< std::optional< StringRef > > Redirects={}, unsigned SecondsToWait=0, unsigned MemoryLimit=0, std::string *ErrMsg=nullptr, bool *ExecutionFailed=nullptr, std::optional< ProcessStatistics > *ProcStat=nullptr, BitVector *AffinityMask=nullptr)

This function executes the program using the arguments provided.

This is an optimization pass for GlobalISel generic memory operations.

This struct encapsulates information about a process.