LLVM: include/llvm/Support/Program.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_SUPPORT_PROGRAM_H

14#define LLVM_SUPPORT_PROGRAM_H

15

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

22#include

23#include

24#include <system_error>

25

26namespace llvm {

28namespace sys {

29

30

31

32#if defined(LLVM_ON_UNIX)

34#elif defined(_WIN32)

36#endif

37

38#if defined(_WIN32)

39typedef unsigned long procid_t;

40typedef void *process_t;

41#else

44#endif

45

46

58

59

65

66

67

68

69

70

71

72

73

74

75

76

77

78

81

82

83

84

87

88

89

90

93

94

95

96

97

98

99

100

101

102

103

104

106 StringRef Program,

107

108 ArrayRef Args,

109

110

112 std::nullopt,

113

114

115

116 ArrayRef<std::optional> Redirects = {},

117

118

119

120

121

122

123

124 unsigned SecondsToWait = 0,

125

126

127

128

129 unsigned MemoryLimit = 0,

130

131

132

133 std::string *ErrMsg = nullptr,

134

135

136

137 bool *ExecutionFailed = nullptr,

138 std::optional *ProcStat = nullptr,

139

140

141 BitVector *AffinityMask = nullptr

142

143);

144

145

146

147

148

149

153 ArrayRef<std::optional> Redirects = {}, unsigned MemoryLimit = 0,

154 std::string *ErrMsg = nullptr, bool *ExecutionFailed = nullptr,

155 BitVector *AffinityMask = nullptr,

156

157

158

159 bool DetachProcess = false);

160

161

162

165

166

167

170

171

172

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

204

205

206

207

208

209

210

211

213 const ProcessInfo &PI,

214 std::optional SecondsToWait,

215

216

217

218

219

220

221

222

223 std::string *ErrMsg = nullptr,

224

225

226

227 std::optional *ProcStat =

228 nullptr,

229

230

231

232 bool Polling = false

233);

234

235

237

238#if defined(_WIN32)

239

240

241

242

245#endif

246}

247}

248

249#endif

Provides ErrorOr smart pointer.

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

Represents either an error or a value T.

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

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

LLVM_ABI std::error_code ChangeStdoutMode(fs::OpenFlags Flags)

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

Print a command argument, and optionally quote it.

LLVM_ABI std::error_code ChangeStdinMode(fs::OpenFlags Flags)

::pid_t procid_t

Definition Program.h:42

LLVM_ABI std::error_code ChangeStdinToBinary()

procid_t process_t

Definition Program.h:43

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

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

LLVM_ABI 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.

const char EnvPathSeparator

This is the OS-specific separator for PATH like environment variables:

Definition Program.h:33

LLVM_ABI std::error_code writeFileWithEncoding(StringRef FileName, StringRef Contents, WindowsEncodingMethod Encoding=WEM_UTF8)

Saves the UTF8-encoded contents string into the file FileName using a specific encoding.

LLVM_ABI ErrorOr< std::string > findProgramByName(StringRef Name, ArrayRef< StringRef > Paths={})

Find the first executable file Name in Paths.

WindowsEncodingMethod

File encoding options when writing contents that a non-UTF8 tool will read (on Windows systems).

Definition Program.h:173

@ WEM_CurrentCodePage

Definition Program.h:177

@ WEM_UTF16

Definition Program.h:178

@ WEM_UTF8

UTF-8 is the LLVM native encoding, being the same as "do not performencoding conversion".

Definition Program.h:176

LLVM_ABI 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.

LLVM_ABI std::error_code ChangeStdoutToBinary()

This is an optimization pass for GlobalISel generic memory operations.

This struct encapsulates information about a process.

Definition Program.h:47

process_t Process

The process identifier.

Definition Program.h:51

int ReturnCode

Platform-dependent process object.

Definition Program.h:54

procid_t Pid

Definition Program.h:50

static constexpr procid_t InvalidPid

Definition Program.h:48

This struct encapsulates information about a process execution.

Definition Program.h:60

uint64_t PeakMemory

Maximum resident set size in KiB.

Definition Program.h:63

std::chrono::microseconds TotalTime

Definition Program.h:61

std::chrono::microseconds UserTime

Definition Program.h:62