Move the registered target printing in version strings completely out of
authorChandler Carruth <chandlerc@gmail.com>
Fri, 22 Jul 2011 07:50:48 +0000 (07:50 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 22 Jul 2011 07:50:48 +0000 (07:50 +0000)
the Support library. Now its part of the TargetRegistry, and the three
commands that care about this explicitly register this extra bit of
version information.

The set of commands which care was computed by intersecting those which
use the Support library's version string printing and those that
initialize all the registered targets in a way that produces
a meaningful list. The only odd ball out is that 'clang -cc1as -version'
no longer prints the registered targets. I don't think anyone is really
interested in that (especially as the fact that llvm-mc does so is under
a FIXME), but if someone really does want this back I'll happily apply
the same patch there.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135757 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/CommandLine.cpp
tools/llc/llc.cpp
tools/llvm-mc/llvm-mc.cpp
tools/llvm-objdump/llvm-objdump.cpp

index 631d0871afbdd20807f5cc8cb03c4a99090f0c25..839ec799d8090346ae9b4fc3656b0bc8e5dc2229 100644 (file)
@@ -23,7 +23,6 @@
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/system_error.h"
-#include "llvm/Target/TargetRegistry.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/ADT/OwningPtr.h"
@@ -1358,12 +1357,7 @@ public:
        << "  Built " << __DATE__ << " (" << __TIME__ << ").\n"
 #endif
        << "  Host: " << sys::getHostTriple() << '\n'
-       << "  Host CPU: " << CPU << '\n'
-       << '\n';
-
-    // FIXME: This needs to be moved into each commandline tool to remove the
-    // layer violation.
-    TargetRegistry::printRegisteredTargetsForVersion();
+       << "  Host CPU: " << CPU << '\n';
   }
   void operator=(bool OptionWasSpecified) {
     if (!OptionWasSpecified) return;
@@ -1377,6 +1371,7 @@ public:
     // Iterate over any registered extra printers and call them to add further
     // information.
     if (ExtraVersionPrinters != 0) {
+      outs() << '\n';
       for (std::vector<void (*)()>::iterator I = ExtraVersionPrinters->begin(),
                                              E = ExtraVersionPrinters->end();
            I != E; ++I)
index f2c4c27f7d6b057da02ecba40ec8957ee003b5c5..9fe113f186e5051fdd91cc1d4eff40b9ef54671e 100644 (file)
@@ -238,6 +238,9 @@ int main(int argc, char **argv) {
   InitializeAllAsmPrinters();
   InitializeAllAsmParsers();
 
+  // Register the target printer for --version.
+  cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
+
   cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");
 
   // Load the module to be compiled...
index f365972561db3621dd436e85b9a1fe486e1a141b..5d4f015547a638d3598fc9cae77adabd9ea3f5ba 100644 (file)
@@ -463,6 +463,10 @@ int main(int argc, char **argv) {
   llvm::InitializeAllAsmParsers();
   llvm::InitializeAllDisassemblers();
 
+  // Register the target printer for --version.
+  // FIXME: Remove when we stop initializing the Target(Machine)s above.
+  cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
+
   cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n");
   TripleName = Triple::normalize(TripleName);
 
index 21df7ccd9dbedb18efa416d74d970d681097ca62..2efdc0de0361496b56291dd839944facd0f76f94 100644 (file)
@@ -313,6 +313,10 @@ int main(int argc, char **argv) {
   llvm::InitializeAllAsmParsers();
   llvm::InitializeAllDisassemblers();
 
+  // Register the target printer for --version.
+  // FIXME: Remove when we stop initializing the Target(Machine)s above.
+  cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
+
   cl::ParseCommandLineOptions(argc, argv, "llvm object file dumper\n");
   TripleName = Triple::normalize(TripleName);