diff options
author | Justin Bogner <mail@justinbogner.com> | 2014-07-14 20:53:57 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2014-07-14 20:53:57 +0000 |
commit | 759645ea89e1185868034637172a255ca9cf799c (patch) | |
tree | 5c37b33c5cb8df8b829b0773fd2b7be9e2397bd1 /llvm/include/llvm/Support/CommandLine.h | |
parent | b8f435ca7035b4ac1113457ef47354d69431306d (diff) | |
download | bcm5719-llvm-759645ea89e1185868034637172a255ca9cf799c.tar.gz bcm5719-llvm-759645ea89e1185868034637172a255ca9cf799c.zip |
Support: Fix option handling when using cl::Required with aliasopt
Until now, attempting to create an alias of a required option would
complain if the user supplied the alias, because the required option
didn't have a value. Similarly, if you said the alias was required,
then using the base option would complain that the alias wasn't
supplied. Lastly, if you put required on both, *neither* option would
work.
By changning alias to overload addOccurrence and setting cl::Required
on the original option, we can get this to behave in a more useful
way. I've also added a test and updated a user that was getting this
wrong.
llvm-svn: 212986
Diffstat (limited to 'llvm/include/llvm/Support/CommandLine.h')
-rw-r--r-- | llvm/include/llvm/Support/CommandLine.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h index 5cb55013973..fdd901200fe 100644 --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -270,8 +270,8 @@ public: // addOccurrence - Wrapper around handleOccurrence that enforces Flags. // - bool addOccurrence(unsigned pos, StringRef ArgName, - StringRef Value, bool MultiArg = false); + virtual bool addOccurrence(unsigned pos, StringRef ArgName, + StringRef Value, bool MultiArg = false); // Prints option name followed by message. Always returns true. bool error(const Twine &Message, StringRef ArgName = StringRef()); @@ -1649,6 +1649,10 @@ class alias : public Option { StringRef Arg) override { return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg); } + bool addOccurrence(unsigned pos, StringRef /*ArgName*/, + StringRef Value, bool MultiArg = false) override { + return AliasFor->addOccurrence(pos, AliasFor->ArgStr, Value, MultiArg); + } // Handle printing stuff... size_t getOptionWidth() const override; void printOptionInfo(size_t GlobalWidth) const override; |