<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Sep 14, 2016 at 3:13 AM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Mon, Sep 12, 2016 at 6:57 PM Dean Michael Berris <<a href="mailto:dberris@google.com" class="gmail_msg" target="_blank">dberris@google.com</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">dberris created this revision.<br class="gmail_msg">
dberris added reviewers: zturner, dblaikie, echristo.<br class="gmail_msg">
dberris added a subscriber: llvm-commits.<br class="gmail_msg">
Herald added a subscriber: mehdi_amini.<br class="gmail_msg">
<br class="gmail_msg">
This should allow users of the library to get a range to iterate through<br class="gmail_msg">
all the subcommands that are registered to the global parser. This<br class="gmail_msg">
allows users to define subcommands in libraries that self-register to<br class="gmail_msg">
have dispatch done at a different stage (like main). It allows for<br class="gmail_msg">
writing code like the following:<br class="gmail_msg">
<br class="gmail_msg">
    for (auto *S : cl::getRegisteredSubcommands()) {<br class="gmail_msg">
      if (*S) {<br class="gmail_msg">
        // Dispatch on S->getName().<br class="gmail_msg">
      }<br class="gmail_msg">
    }<br class="gmail_msg"></blockquote></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg"><br class="gmail_msg">FWIW: I wasn't expecting/suggesting we should have to compare by strings (stringly typed isn't ideal, of course) - I was hoping/figuring we could declaer the subcommand in the header (along with the single entry point function) and then define it over in the file that defines the single entry point along with the subcommand's flags.<br class="gmail_msg"></div></div></div></blockquote><div><br></div><div>Unfortunately that doesn't remove the dispatch, which would be manual, as opposed to doing this which would be automatic -- i.e. all the implementations can register a function to invoke to a global map, which is used to dispatch, makes extending easier/simpler than having to manually add if statements.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg"><br class="gmail_msg">Did this not work for some reason?<br class="gmail_msg"> </div></div></div></blockquote><div><br></div><div>I could make it work, but that's mutually exclusive to this functionality. :)</div></div></div>