mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
[libOption] - Replace std::pair with helper struct. NFC.
Splitted from D35476. llvm-svn: 308293
This commit is contained in:
parent
374e6b7624
commit
89cb57e606
@ -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});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user