[llvm-commits] [llvm] r77127 - /llvm/trunk/lib/Support/CommandLine.cpp
Daniel Dunbar
daniel at zuster.org
Sat Jul 25 22:10:25 PDT 2009
Author: ddunbar
Date: Sun Jul 26 00:09:50 2009
New Revision: 77127
URL: http://llvm.org/viewvc/llvm-project?rev=77127&view=rev
Log:
Sort list of targets in --version.
Modified:
llvm/trunk/lib/Support/CommandLine.cpp
Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=77127&r1=77126&r2=77127&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Sun Jul 26 00:09:50 2009
@@ -1144,19 +1144,22 @@
cout << "\n";
cout << " Registered Targets:\n";
+ std::vector<std::pair<std::string, const Target*> > Targets;
size_t Width = 0;
for (TargetRegistry::iterator it = TargetRegistry::begin(),
- ie = TargetRegistry::end(); it != ie; ++it)
+ ie = TargetRegistry::end(); it != ie; ++it) {
+ Targets.push_back(std::make_pair(it->getName(), &*it));
Width = std::max(Width, ::strlen(it->getName()));
+ }
+ std::sort(Targets.begin(), Targets.end());
- unsigned NumTargets = 0;
- for (TargetRegistry::iterator it = TargetRegistry::begin(),
- ie = TargetRegistry::end(); it != ie; ++it, ++NumTargets) {
- cout << " " << it->getName()
- << std::string(Width - ::strlen(it->getName()), ' ') << " - "
- << it->getShortDescription() << "\n";
+ for (unsigned i = 0, e = Targets.size(); i != e; ++i) {
+ const Target *T = Targets[i].second;
+ cout << " " << T->getName()
+ << std::string(Width - ::strlen(T->getName()), ' ') << " - "
+ << T->getShortDescription() << "\n";
}
- if (!NumTargets)
+ if (Targets.empty())
cout << " (none)\n";
}
void operator=(bool OptionWasSpecified) {
More information about the llvm-commits
mailing list