From: Mehdi Amini Date: Sat, 1 Oct 2016 03:43:20 +0000 (+0000) Subject: Use StringRef in CommandLine Options handling (NFC) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b7d8ee46b4656ec2da22f90a5d152acb5a306aff;p=llvm Use StringRef in CommandLine Options handling (NFC) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283007 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/CodeGen/MachinePassRegistry.h b/include/llvm/CodeGen/MachinePassRegistry.h index 8fb9ebd60f5..db914b1f8bc 100644 --- a/include/llvm/CodeGen/MachinePassRegistry.h +++ b/include/llvm/CodeGen/MachinePassRegistry.h @@ -132,9 +132,9 @@ public: // Add existing passes to option. for (RegistryClass *Node = RegistryClass::getList(); Node; Node = Node->getNext()) { - this->addLiteralOption(Node->getName().data(), + this->addLiteralOption(Node->getName(), (typename RegistryClass::FunctionPassCtor)Node->getCtor(), - Node->getDescription().data()); + Node->getDescription()); } // Make sure we listen for list changes. @@ -144,12 +144,10 @@ public: // Implement the MachinePassRegistryListener callbacks. // void NotifyAdd(StringRef N, MachinePassCtor C, StringRef D) override { - this->addLiteralOption(N.data(), - (typename RegistryClass::FunctionPassCtor)C, - D.data()); + this->addLiteralOption(N, (typename RegistryClass::FunctionPassCtor)C, D); } void NotifyRemove(StringRef N) override { - this->removeLiteralOption(N.data()); + this->removeLiteralOption(N); } }; diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 1c1345516c2..f2e8b281716 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -47,7 +47,7 @@ namespace cl { // ParseCommandLineOptions - Command line option processing entry point. // bool ParseCommandLineOptions(int argc, const char *const *argv, - const char *Overview = nullptr, + StringRef Overview = "", bool IgnoreErrors = false); //===----------------------------------------------------------------------===// @@ -55,7 +55,7 @@ bool ParseCommandLineOptions(int argc, const char *const *argv, // entry point. // void ParseEnvironmentOptions(const char *progName, const char *envvar, - const char *Overview = nullptr); + const char *Overview = ""); ///===---------------------------------------------------------------------===// /// SetVersionPrinter - Override the default (LLVM specific) version printer @@ -89,7 +89,7 @@ class Option; /// /// Literal options are used by some parsers to register special option values. /// This is how the PassNameParser registers pass names for opt. -void AddLiteralOption(Option &O, const char *Name); +void AddLiteralOption(Option &O, StringRef Name); //===----------------------------------------------------------------------===// // Flags permitted to be passed to command line arguments @@ -157,18 +157,18 @@ enum MiscFlags { // Miscellaneous flags to adjust argument // class OptionCategory { private: - const char *const Name; - const char *const Description; + StringRef const Name; + StringRef const Description; void registerCategory(); public: - OptionCategory(const char *const Name, - const char *const Description = nullptr) + OptionCategory(StringRef const Name, + StringRef const Description = "") : Name(Name), Description(Description) { registerCategory(); } - const char *getName() const { return Name; } - const char *getDescription() const { return Description; } + StringRef getName() const { return Name; } + StringRef getDescription() const { return Description; } }; // The general Option Category (used as default category). @@ -179,17 +179,17 @@ extern OptionCategory GeneralCategory; // class SubCommand { private: - const char *const Name = nullptr; - const char *const Description = nullptr; + StringRef Name = ""; + StringRef Description = ""; protected: void registerSubCommand(); void unregisterSubCommand(); public: - SubCommand(const char *const Name, const char *const Description = nullptr) + SubCommand(StringRef Name, StringRef Description = "") : Name(Name), Description(Description) { - registerSubCommand(); + registerSubCommand(); } SubCommand() {} @@ -197,8 +197,8 @@ public: operator bool() const; - const char *getName() const { return Name; } - const char *getDescription() const { return Description; } + StringRef getName() const { return Name; } + StringRef getDescription() const { return Description; } SmallVector