Hello, Is there currently a way to set options, like -time-passes or -regalloc from C++? I looked at the code in lib/Support/CommandLine.cpp, but the stuff that comes closest to providing such functionality (mostly GetOptionInfo()) is marked static. Thanks, Paul
Eli Friedman
2009-Jun-07 09:11 UTC
[LLVMdev] Programmatically setting command line options?
On Sun, Jun 7, 2009 at 1:48 AM, Paul Melis<llvm at assumetheposition.nl> wrote:> Hello, > > Is there currently a way to set options, like -time-passes or -regalloc > from C++? I looked at the code in lib/Support/CommandLine.cpp, but the > stuff that comes closest to providing such functionality (mostly > GetOptionInfo()) is marked static.You can manipulate the command-line you pass to llvm::cl::ParseCommandLineOptions; other than that, there isn't any easy way to do it. Patches to expose functionality using an option into the C++ API are generally welcome if they are clean. In an ideal world, I guess we wouldn't have any command-line options in lib/, but adding options that way is really convenient :) -Eli
Eli Friedman wrote:> On Sun, Jun 7, 2009 at 1:48 AM, Paul Melis<llvm at assumetheposition.nl> wrote: > >> Hello, >> >> Is there currently a way to set options, like -time-passes or -regalloc >> from C++? I looked at the code in lib/Support/CommandLine.cpp, but the >> stuff that comes closest to providing such functionality (mostly >> GetOptionInfo()) is marked static. >> > > You can manipulate the command-line you pass to > llvm::cl::ParseCommandLineOptions; other than that, there isn't any > easy way to do it. Patches to expose functionality using an option > into the C++ API are generally welcome if they are clean. >Thanks! Using ParseCommandLineOptions will do for now, I guess.> In an ideal world, I guess we wouldn't have any command-line options > in lib/, but adding options that way is really convenient :) >Err, yes, I can see from the sheer number of options defined there :) Regards, Paul