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 | b4e76f6b636aa6aa2474765eb9b1b24ba1caca2c (patch) | |
tree | 3d029e59874f51fa49d3cc9e5c226ded86a7ecf0 /llvm/lib/Option/OptTable.cpp | |
parent | 4e138e1d8c46c873abd9fdda83a3d7b2205e3b88 (diff) | |
download | bcm5719-llvm-b4e76f6b636aa6aa2474765eb9b1b24ba1caca2c.tar.gz bcm5719-llvm-b4e76f6b636aa6aa2474765eb9b1b24ba1caca2c.zip |
[libOption] - Replace std::pair with helper struct. NFC.
Splitted from D35476.
llvm-svn: 308293
Diffstat (limited to 'llvm/lib/Option/OptTable.cpp')
-rw-r--r-- | llvm/lib/Option/OptTable.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp index bcd365236e4..f3b438e829d 100644 --- a/llvm/lib/Option/OptTable.cpp +++ b/llvm/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}); } } |