Programmatically setting command line options?

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

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 :slight_smile:

-Eli

Eli Friedman 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 :slight_smile:
  
Err, yes, I can see from the sheer number of options defined there :slight_smile:

Regards,
Paul