diff options
author | George Rimar <grimar@accesssoftek.com> | 2017-07-18 10:59:30 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2017-07-18 10:59:30 +0000 |
commit | cd31858e65bf71c50b2db93bf521cc3a85f7b3a6 (patch) | |
tree | a3d5b514bfd6e046751573dea9d8ac5e0aaefdc3 /lib/Option | |
parent | 937f85f25c67b5210104795463f73ad4546e7a7d (diff) |
[libOption] - Replace std::pair with helper struct. NFC.
Splitted from D35476.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308293 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Option')
-rw-r--r-- | lib/Option/OptTable.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/Option/OptTable.cpp b/lib/Option/OptTable.cpp index bcd365236e4..f3b438e829d 100644 --- a/lib/Option/OptTable.cpp +++ b/lib/Option/OptTable.cpp @@ -390,27 +390,29 @@ static std::string getOptionHelpName(const OptTable &Opts, OptSpecifier Id) { return Name; } +namespace { +struct OptionInfo { + std::string Name; + StringRef HelpText; +}; +} // namespace + static void PrintHelpOptionList(raw_ostream &OS, StringRef Title, - std::vector<std::pair<std::string, - const char*>> &OptionHelp) { + std::vector<OptionInfo> &OptionHelp) { OS << Title << ":\n"; // Find the maximum option length. unsigned OptionFieldWidth = 0; for (unsigned i = 0, e = OptionHelp.size(); i != e; ++i) { - // Skip titles. - if (!OptionHelp[i].second) - continue; - // Limit the amount of padding we are willing to give up for alignment. - unsigned Length = OptionHelp[i].first.size(); + unsigned Length = OptionHelp[i].Name.size(); if (Length <= 23) OptionFieldWidth = std::max(OptionFieldWidth, Length); } const unsigned InitialPad = 2; for (unsigned i = 0, e = OptionHelp.size(); i != e; ++i) { - const std::string &Option = OptionHelp[i].first; + const std::string &Option = OptionHelp[i].Name; int Pad = OptionFieldWidth - int(Option.size()); OS.indent(InitialPad) << Option; @@ -419,7 +421,7 @@ static void PrintHelpOptionList(raw_ostream &OS, StringRef Title, OS << "\n"; Pad = OptionFieldWidth + InitialPad; } - OS.indent(Pad + 1) << OptionHelp[i].second << '\n'; + OS.indent(Pad + 1) << OptionHelp[i].HelpText << '\n'; } } @@ -458,8 +460,7 @@ void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title, // Render help text into a map of group-name to a list of (option, help) // pairs. - using helpmap_ty = - std::map<std::string, std::vector<std::pair<std::string, const char*>>>; + using helpmap_ty = std::map<std::string, std::vector<OptionInfo>>; helpmap_ty GroupedOptionHelp; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { @@ -478,7 +479,7 @@ void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title, if (const char *Text = getOptionHelpText(Id)) { const char *HelpGroup = getOptionHelpGroup(*this, Id); const std::string &OptName = getOptionHelpName(*this, Id); - GroupedOptionHelp[HelpGroup].push_back(std::make_pair(OptName, Text)); + GroupedOptionHelp[HelpGroup].push_back({OptName, Text}); } } |