[PATCH] D31410: llvm-lto2: Move the LTO::run() action behind a subcommand.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 09:41:58 PDT 2017


zturner added a comment.

So if I understand correctly, these are existing options that are defined in some library somewhere, and you want to be able to use them in a subcommand of your own creation?  Yea unfortunately I never considered that use case.

I think one thing you could do to make this work with the least amount of effort possible is to make a new option type instead of `cl::opt` and `cl::list` called `cl::redefine`.  It takes an `opt` or `list` to its constructor, and a list of modifiers.  This way you could do something like:

  extern cl::opt<bool> LtoUseNewPmOpt;
  
  cl::SubCommand RunSubcommand("run");
  
  cl::redefine<cl::opt<bool>> LtoUseNewPm2(LtoUseNewPmOpt, cl::sub(RunSubcommand));

There's probably some details to work out, but it seems like it should work in theory.  Anyway, hacking it up like this is probably ok as a stopgap.


https://reviews.llvm.org/D31410





More information about the llvm-commits mailing list