From: David Green Date: Mon, 9 Dec 2019 10:33:33 +0000 (+0000) Subject: [CommandLine] Add missing Callbacks X-Git-Tag: llvmorg-11-init~2653 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4a6e13ad88ddcc0ab92ace49d4c761921e7f7070;p=platform%2Fupstream%2Fllvm.git [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. --- diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h index 8c1d35c..8a67546 100644 --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/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/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp index 702aa52..a435200 100644 --- a/llvm/unittests/Support/CommandLineTest.cpp +++ b/llvm/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