[CommandLine] Add missing Callbacks
authorDavid Green <david.green@arm.com>
Mon, 9 Dec 2019 10:33:33 +0000 (10:33 +0000)
committerDavid Green <david.green@arm.com>
Mon, 9 Dec 2019 11:37:34 +0000 (11:37 +0000)
It appears that the cl::bits options are not used anywhere in-tree. In
the recent addition to add Callback's to the options, the Callback was
missing from this one. This fixes it by adding the same code from the
other classes.

It also adds a simple test, of sorts, just to make sure these continue
compiling.

llvm/include/llvm/Support/CommandLine.h
llvm/unittests/Support/CommandLineTest.cpp

index 8c1d35c..8a67546 100644 (file)
@@ -1794,6 +1794,14 @@ public:
     apply(this, Ms...);
     done();
   }
+
+  void setCallback(
+      std::function<void(const typename ParserClass::parser_data_type &)> CB) {
+    Callback = CB;
+  }
+
+  std::function<void(const typename ParserClass::parser_data_type &)> Callback =
+      [](const typename ParserClass::parser_data_type &) {};
 };
 
 //===----------------------------------------------------------------------===//
index 702aa52..a435200 100644 (file)
@@ -1784,4 +1784,12 @@ TEST(CommandLineTest, Callback) {
 
   cl::ResetAllOptionOccurrences();
 }
+
+enum Enum { Val1, Val2 };
+static cl::bits<Enum> ExampleBits(
+    cl::desc("An example cl::bits to ensure it compiles"),
+    cl::values(
+      clEnumValN(Val1, "bits-val1", "The Val1 value"),
+      clEnumValN(Val1, "bits-val2", "The Val2 value")));
+
 } // anonymous namespace