From 5ce4d154f5fea5193cf031bd2ca69d694bc1be10 Mon Sep 17 00:00:00 2001 From: David Green Date: Mon, 9 Dec 2019 10:33:33 +0000 Subject: [PATCH] [CommandLine] Add missing Callbacks 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. --- include/llvm/Support/CommandLine.h | 8 ++++++++ unittests/Support/CommandLineTest.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 8c1d35c3cbc..8a67546c747 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -1794,6 +1794,14 @@ public: apply(this, Ms...); done(); } + + void setCallback( + std::function CB) { + Callback = CB; + } + + std::function Callback = + [](const typename ParserClass::parser_data_type &) {}; }; //===----------------------------------------------------------------------===// diff --git a/unittests/Support/CommandLineTest.cpp b/unittests/Support/CommandLineTest.cpp index 702aa526fda..a435200bb31 100644 --- a/unittests/Support/CommandLineTest.cpp +++ b/unittests/Support/CommandLineTest.cpp @@ -1784,4 +1784,12 @@ TEST(CommandLineTest, Callback) { cl::ResetAllOptionOccurrences(); } + +enum Enum { Val1, Val2 }; +static cl::bits 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