[llvm-dev] How to pass arbitrary arguments to runFunctionAsMain?
Alberto Barbaro via llvm-dev
llvm-dev at lists.llvm.org
Fri Jan 25 23:44:23 PST 2019
Hi,
I'm trying to call the function main passing arbitrary parameters. My code
is something like:
Please note that MyInterpreter extends Interpreter
StringRef filename = argv[1];
std::unique_ptr<Module> m(parseIRFile(filename, error, context));
MyInterpreter * v = new MyInterpreter(std::move(m));
v->finalizeObject();
errs() << "Done\n";
Function *main = v->FindFunctionNamed("main");
errs() << " Function " << main->getName().str() << "\n";
std::vector<std::string> parameters;
parameters.insert(parameters.begin(), "argv");
const char* const* envp;
for (int i=1; i<argc;i++)
parameters.push_back(argv[i]);
v->runFunctionAsMain(main, parameters, envp);
Is it correct or should I construct parameters in another way?
Thanks a lot
Alberto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190126/045eaff0/attachment.html>
More information about the llvm-dev
mailing list