This is an archive of the discontinued LLVM Phabricator instance.

[clangd] dexp tool uses llvm::cl to parse its flags.
ClosedPublic

Authored by sammccall on Sep 12 2018, 7:44 AM.

Details

Summary

We can use cl::ResetCommandLineParser() to support different types of
command-lines, as long as we're careful about option lifetimes.
(I tried using subcommands, but the error messages were bad)
I found a mostly-reasonable pattern to isolate the fiddly parts.

Added -scope and -limit flags to the find command to demonstrate.
(Note that scope support seems to be broken in dex?)

Fixed symbol lookup to parse symbol IDs.

Caveats:

  • with command help (e.g. find -help), you also get some spam about required arguments. This is a bug in llvm::cl, which prints these to errs() rather than the designated stream.

Diff Detail

Event Timeline

sammccall created this revision.Sep 12 2018, 7:44 AM

A small drive-by comment.

PS it'd be cool to have an interface to cl that does not rely on global state...

clangd/index/dex/dexp/Dexp.cpp
165

Maybe use a named struct?
C++ is powerful, but looks obscure at times...

kbobyrev accepted this revision.Sep 13 2018, 7:18 AM

PS it'd be cool to have an interface to cl that does not rely on global state...

Yeah, I'm not sure if that's trivial to do, though.

Thanks for the patch, it looks really good, I don't have any concerns.

This revision is now accepted and ready to land.Sep 13 2018, 7:18 AM
This revision was automatically updated to reflect the committed changes.