kbobyrev added inline comments.
================ Comment at: clang-tools-extra/clangd/dexplorer/Dexplorer.cpp:39 + +// FIXME(kbobyrev): Make this an actual REPL: probably use LLVM Command Line +// library for parsing flags and arguments. ---------------- ilya-biryukov wrote: > kbobyrev wrote: > > ilya-biryukov wrote: > > > Maybe we could expose `CommandLineParser` from > > > `llvm/lib/Support/CommandLine.cpp` as a public API and use it here? > > > Not sure if there are any obstacles to doing so or how much work is it, > > > though. > > > E.g. `cl::opt` seem to rely on being registered in the global parser and > > > I'm not sure if there's an easy way out of it. > > Yes, that might be tricky. I have thought about a few options, e.g. > > consuming the first token from the input string as the command and > > dispatching arguments parsed via `CommandLineParser` manually (discarding > > those which are not accepted by provided command, etc). There are still few > > complications: help wouldn't be separate and easily accessible (unless > > hardcoded, which is suboptimal). > > > > Another approach I could think of would be simplifying the interface of > > each command so that it would be easily parsed: > > > > * `> fuzzy-find request.json`: this would require `FuzzyFindRequest` JSON > > (de)serialization implementation, but that would be useful for the > > benchmark tool, too > > * `> lookup-id symbolid` > > * `> load symbol.yaml`/`swap symbol.yaml` > > * `> density-hist` > > * `> tokens-distribution` > > * `> dense-tokens` > > * `> sparse-tokens` > > > > And also a generic `> help` for the short reference of each command. Out of > > all these commands, only Fuzzy Find request would benefit a lot from a > > proper parsing of arguments, having JSON file representation might not be > > ideal, but it looks OK for the first iteration for me. Fuzzy Find request > > would presumably be one of the most used commands, though, but then again, > > we could iterate if that is not really convinient. > The single-argument and no-arg commands certainly look nice. However, > creating a separate file for each fuzzy-find request feels like a pain. > > Have you tried prototyping parsing with `CommandLineParser `? What are the > complications to exposing it from LLVM? I didn't, but I looked closely at `clang-query` which decided not to do that IIUC due to the complications with the `CommandLineParser` and also the specifics of the tool and `clang-refactor` which utilizes `CommandLineRefactoringOptionVisitor` and `RefactoringActionSubcommand` internal implementations, but overall I don't think it looks very simple. We had a discussion with Eric and Sam, the consensus was that we should start with something very simple and iterate on that if we decide that more complicated interface is necessary. https://reviews.llvm.org/D51628 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits