[PATCH] D61574: [CommandLine] Allow Options to specify multiple OptionCategory's.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 5 20:20:32 PDT 2019


MaskRay added a comment.

May I ask you to share some dumps of `some-command -help` (a demo how you'll make use of the multiple categories)😁



================
Comment at: llvm/lib/Support/CommandLine.cpp:429
+void Option::addCategory(OptionCategory &C) {
+  assert(!Categories.empty() && "Categories cannot be empty.");
+  // Maintain backward compatibility by replacing the default GeneralCategory
----------------
Can you explain why Categories cannot be empty? Is it because an option has one category when it is registered? (Sorry as I'm not very familiar with the code)


================
Comment at: llvm/unittests/Support/CommandLineTest.cpp:99
+  ASSERT_NE(Retrieved->Categories.end(),
+            std::find_if(Retrieved->Categories.begin(),
+                         Retrieved->Categories.end(),
----------------
Since the file includes `STLExtras.h` you may use the range-style `llvm::find_if` to simplify begin/end.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61574





More information about the llvm-commits mailing list