17 std::optional<StringRef> ProgramName) {
18 std::vector<std::unique_ptr<char[]>> ArgVStorage;
19 std::vector<char *> ArgV;
21 ArgVStorage.reserve(Args.size() + (ProgramName ? 1 : 0));
22 ArgV.reserve(Args.size() + 1 + (ProgramName ? 1 : 0));
25 ArgVStorage.push_back(std::make_unique<
char[]>(ProgramName->size() + 1));
26 llvm::copy(*ProgramName, &ArgVStorage.back()[0]);
27 ArgVStorage.back()[ProgramName->size()] =
'\0';
28 ArgV.push_back(ArgVStorage.back().get());
31 for (
const auto &Arg : Args) {
32 ArgVStorage.push_back(std::make_unique<
char[]>(Arg.size() + 1));
34 ArgVStorage.back()[Arg.size()] =
'\0';
35 ArgV.push_back(ArgVStorage.back().get());
37 ArgV.push_back(
nullptr);
39 return Main(Args.size() + !!ProgramName, ArgV.data());
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
int runAsVoidFunction(int(*Func)(void))
int runAsIntFunction(int(*Func)(int), int Arg)
int runAsMain(int(*Main)(int, char *[]), ArrayRef< std::string > Args, std::optional< StringRef > ProgramName=std::nullopt)
Run a main function, returning the result.
This is an optimization pass for GlobalISel generic memory operations.
OutputIt copy(R &&Range, OutputIt Out)