Adding a new cl::HideUnrelatedOptions API to allow clang to migrate off cl::getRegist...
[oota-llvm.git] / lib / Support / CommandLine.cpp
index 40570cab7cc881a34f13e61026f1c573f6a08b35..a774421b26c54a983ab86cc1a397d1c1b579401b 100644 (file)
@@ -1826,12 +1826,22 @@ void cl::AddExtraVersionPrinter(void (*func)()) {
 void cl::getRegisteredOptions(StringMap<Option *> &Map) {
   // Get all the options.
   SmallVector<Option *, 4> PositionalOpts; // NOT USED
-  SmallVector<Option *, 4> SinkOpts; // NOT USED
+  SmallVector<Option *, 4> SinkOpts;       // NOT USED
   assert(Map.size() == 0 && "StringMap must be empty");
   GetOptionInfo(PositionalOpts, SinkOpts, Map);
   return;
 }
 
+void cl::HideUnrelatedOptions(cl::OptionCategory &Category) {
+  StringMap<cl::Option *> Options;
+  cl::getRegisteredOptions(Options);
+  for (auto &I : Options) {
+    if (I.second->Category != &Category && I.first() != "help" &&
+        I.first() != "version")
+      I.second->setHiddenFlag(cl::ReallyHidden);
+  }
+}
+
 void LLVMParseCommandLineOptions(int argc, const char *const *argv,
                                  const char *Overview) {
   llvm::cl::ParseCommandLineOptions(argc, argv, Overview);