diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-07-22 07:50:44 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-07-22 07:50:44 +0000 |
commit | 077c40871780136f7016a496703b20ebea9c0978 (patch) | |
tree | 8e55f065c60cd866404e35344827b50211fa5796 /lib/Support/CommandLine.cpp | |
parent | 6d51d26a2479069f85a7676f664d6f998fc49a16 (diff) | |
download | llvm-077c40871780136f7016a496703b20ebea9c0978.tar.gz llvm-077c40871780136f7016a496703b20ebea9c0978.tar.bz2 llvm-077c40871780136f7016a496703b20ebea9c0978.tar.xz |
Move the logic for printing the registered targets into a static
function on the TargetRegistry. Also clean it up and use the modern LLVM
utility libraries available instead of rolling a few things manually.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135756 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/CommandLine.cpp')
-rw-r--r-- | lib/Support/CommandLine.cpp | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 368cef91cf..631d0871af 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -1332,11 +1332,6 @@ static void (*OverrideVersionPrinter)() = 0; static std::vector<void (*)()>* ExtraVersionPrinters = 0; -static int TargetArraySortFn(const void *LHS, const void *RHS) { - typedef std::pair<const char *, const Target*> pair_ty; - return strcmp(((const pair_ty*)LHS)->first, ((const pair_ty*)RHS)->first); -} - namespace { class VersionPrinter { public: @@ -1364,27 +1359,11 @@ public: #endif << " Host: " << sys::getHostTriple() << '\n' << " Host CPU: " << CPU << '\n' - << '\n' - << " Registered Targets:\n"; - - std::vector<std::pair<const char *, const Target*> > Targets; - size_t Width = 0; - for (TargetRegistry::iterator it = TargetRegistry::begin(), - ie = TargetRegistry::end(); it != ie; ++it) { - Targets.push_back(std::make_pair(it->getName(), &*it)); - Width = std::max(Width, strlen(Targets.back().first)); - } - if (!Targets.empty()) - qsort(&Targets[0], Targets.size(), sizeof(Targets[0]), - TargetArraySortFn); - - for (unsigned i = 0, e = Targets.size(); i != e; ++i) { - OS << " " << Targets[i].first; - OS.indent(Width - strlen(Targets[i].first)) << " - " - << Targets[i].second->getShortDescription() << '\n'; - } - if (Targets.empty()) - OS << " (none)\n"; + << '\n'; + + // FIXME: This needs to be moved into each commandline tool to remove the + // layer violation. + TargetRegistry::printRegisteredTargetsForVersion(); } void operator=(bool OptionWasSpecified) { if (!OptionWasSpecified) return; |