[PATCH] D105330: [llvm-nm] Switch command line parsing from llvm::cl to OptTable

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 2 11:35:47 PDT 2021


MaskRay added inline comments.


================
Comment at: llvm/tools/llvm-nm/llvm-nm.cpp:2128
   InitLLVM X(argc, argv);
-  cl::HideUnrelatedOptions(NMCat);
-  cl::AddExtraVersionPrinter(printExtraVersionInfo);
-  cl::ParseCommandLineOptions(argc, argv, "llvm symbol table dumper\n");
-
-  if (Version) {
+  BumpPtrAllocator A;
+  StringSaver Saver(A);
----------------
aganea wrote:
> It looks like `L2128-L2151` are the same as D104889, `llvm/tools/llvm-strings/llvm-strings.cpp, L131-L151`. Is it worth putting this boilerplate in a small utility function in `llvm/Support/`, since we'll probably write the same thing for other bintools?
`BumpPtrAllocator` and `StringSaver` are the same.

`OPT_help` can be different (specially the `" [options] <input object files>"`, `"llvm string table dumper"` lines).
It is hard for code sharing because OPT_help is not special in OptTable. The user code knows this is an help option but OptTable doesn't.

`OPT_version` can be different (some utilities need GNU libtool workaround like: `outs() << "llvm-nm, compatible with GNU nm" << '\n';`).

Overall I think code sharing.is difficult for the boilerplate.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105330/new/

https://reviews.llvm.org/D105330



More information about the llvm-commits mailing list