mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-17 05:31:32 +00:00
the switch from std::map -> StringMap caused --help output to be in
non-sorted order, restore the sort. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82368 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d0062c6e7c
commit
0fd48b1f1c
@ -1010,6 +1010,12 @@ void generic_parser_base::printOptionInfo(const Option &O,
|
|||||||
// --help and --help-hidden option implementation
|
// --help and --help-hidden option implementation
|
||||||
//
|
//
|
||||||
|
|
||||||
|
static int OptNameCompare(const void *LHS, const void *RHS) {
|
||||||
|
typedef std::pair<const char *, Option*> pair_ty;
|
||||||
|
|
||||||
|
return strcmp(((pair_ty*)LHS)->first, ((pair_ty*)RHS)->first);
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HelpPrinter {
|
class HelpPrinter {
|
||||||
@ -1032,7 +1038,7 @@ public:
|
|||||||
GetOptionInfo(PositionalOpts, SinkOpts, OptMap);
|
GetOptionInfo(PositionalOpts, SinkOpts, OptMap);
|
||||||
|
|
||||||
// Copy Options into a vector so we can sort them as we like.
|
// Copy Options into a vector so we can sort them as we like.
|
||||||
std::vector<Option*> Opts;
|
SmallVector<std::pair<const char *, Option*>, 128> Opts;
|
||||||
SmallPtrSet<Option*, 128> OptionSet; // Duplicate option detection.
|
SmallPtrSet<Option*, 128> OptionSet; // Duplicate option detection.
|
||||||
|
|
||||||
for (StringMap<Option*>::iterator I = OptMap.begin(), E = OptMap.end();
|
for (StringMap<Option*>::iterator I = OptMap.begin(), E = OptMap.end();
|
||||||
@ -1046,11 +1052,15 @@ public:
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If we've already seen this option, don't add it to the list again.
|
// If we've already seen this option, don't add it to the list again.
|
||||||
if (OptionSet.insert(I->second))
|
if (!OptionSet.insert(I->second))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Opts.push_back(I->second);
|
Opts.push_back(std::pair<const char *, Option*>(I->getKey().data(),
|
||||||
|
I->second));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort the options list alphabetically.
|
||||||
|
qsort(Opts.data(), Opts.size(), sizeof(Opts[0]), OptNameCompare);
|
||||||
|
|
||||||
if (ProgramOverview)
|
if (ProgramOverview)
|
||||||
outs() << "OVERVIEW: " << ProgramOverview << "\n";
|
outs() << "OVERVIEW: " << ProgramOverview << "\n";
|
||||||
@ -1077,11 +1087,11 @@ public:
|
|||||||
// Compute the maximum argument length...
|
// Compute the maximum argument length...
|
||||||
MaxArgLen = 0;
|
MaxArgLen = 0;
|
||||||
for (size_t i = 0, e = Opts.size(); i != e; ++i)
|
for (size_t i = 0, e = Opts.size(); i != e; ++i)
|
||||||
MaxArgLen = std::max(MaxArgLen, Opts[i]->getOptionWidth());
|
MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth());
|
||||||
|
|
||||||
outs() << "OPTIONS:\n";
|
outs() << "OPTIONS:\n";
|
||||||
for (size_t i = 0, e = Opts.size(); i != e; ++i)
|
for (size_t i = 0, e = Opts.size(); i != e; ++i)
|
||||||
Opts[i]->printOptionInfo(MaxArgLen);
|
Opts[i].second->printOptionInfo(MaxArgLen);
|
||||||
|
|
||||||
// Print any extra help the user has declared.
|
// Print any extra help the user has declared.
|
||||||
for (std::vector<const char *>::iterator I = MoreHelp->begin(),
|
for (std::vector<const char *>::iterator I = MoreHelp->begin(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user