[llvm-branch-commits] [llvm-branch] r309286 - Revert r304835: It's not clear printing all targets with --version is the right thing to do (see discussion on D33900)

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jul 27 09:21:47 PDT 2017


Author: hans
Date: Thu Jul 27 09:21:47 2017
New Revision: 309286

URL: http://llvm.org/viewvc/llvm-project?rev=309286&view=rev
Log:
Revert r304835: It's not clear printing all targets with --version is the right thing to do (see discussion on D33900)

Modified:
    llvm/branches/release_50/include/llvm/Support/CommandLine.h
    llvm/branches/release_50/include/llvm/Support/TargetRegistry.h
    llvm/branches/release_50/lib/Support/CommandLine.cpp
    llvm/branches/release_50/lib/Support/TargetRegistry.cpp

Modified: llvm/branches/release_50/include/llvm/Support/CommandLine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/include/llvm/Support/CommandLine.h?rev=309286&r1=309285&r2=309286&view=diff
==============================================================================
--- llvm/branches/release_50/include/llvm/Support/CommandLine.h (original)
+++ llvm/branches/release_50/include/llvm/Support/CommandLine.h Thu Jul 27 09:21:47 2017
@@ -66,15 +66,12 @@ bool ParseCommandLineOptions(int argc, c
 void ParseEnvironmentOptions(const char *progName, const char *envvar,
                              const char *Overview = "");
 
-// Function pointer type for printing version information.
-using VersionPrinterTy = std::function<void(raw_ostream &)>;
-
 ///===---------------------------------------------------------------------===//
 /// SetVersionPrinter - Override the default (LLVM specific) version printer
 ///                     used to print out the version when --version is given
 ///                     on the command line. This allows other systems using the
 ///                     CommandLine utilities to print their own version string.
-void SetVersionPrinter(VersionPrinterTy func);
+void SetVersionPrinter(void (*func)());
 
 ///===---------------------------------------------------------------------===//
 /// AddExtraVersionPrinter - Add an extra printer to use in addition to the
@@ -83,7 +80,7 @@ void SetVersionPrinter(VersionPrinterTy
 ///                          which will be called after the basic LLVM version
 ///                          printing is complete. Each can then add additional
 ///                          information specific to the tool.
-void AddExtraVersionPrinter(VersionPrinterTy func);
+void AddExtraVersionPrinter(void (*func)());
 
 // PrintOptionValues - Print option values.
 // With -print-options print the difference between option values and defaults.

Modified: llvm/branches/release_50/include/llvm/Support/TargetRegistry.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/include/llvm/Support/TargetRegistry.h?rev=309286&r1=309285&r2=309286&view=diff
==============================================================================
--- llvm/branches/release_50/include/llvm/Support/TargetRegistry.h (original)
+++ llvm/branches/release_50/include/llvm/Support/TargetRegistry.h Thu Jul 27 09:21:47 2017
@@ -599,7 +599,7 @@ struct TargetRegistry {
 
   /// printRegisteredTargetsForVersion - Print the registered targets
   /// appropriately for inclusion in a tool's version output.
-  static void printRegisteredTargetsForVersion(raw_ostream &OS);
+  static void printRegisteredTargetsForVersion();
 
   /// @name Registry Access
   /// @{

Modified: llvm/branches/release_50/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/lib/Support/CommandLine.cpp?rev=309286&r1=309285&r2=309286&view=diff
==============================================================================
--- llvm/branches/release_50/lib/Support/CommandLine.cpp (original)
+++ llvm/branches/release_50/lib/Support/CommandLine.cpp Thu Jul 27 09:21:47 2017
@@ -2039,9 +2039,9 @@ void CommandLineParser::printOptionValue
     Opts[i].second->printOptionValue(MaxArgLen, PrintAllOptions);
 }
 
-static VersionPrinterTy OverrideVersionPrinter = nullptr;
+static void (*OverrideVersionPrinter)() = nullptr;
 
-static std::vector<VersionPrinterTy> *ExtraVersionPrinters = nullptr;
+static std::vector<void (*)()> *ExtraVersionPrinters = nullptr;
 
 namespace {
 class VersionPrinter {
@@ -2081,7 +2081,7 @@ public:
       return;
 
     if (OverrideVersionPrinter != nullptr) {
-      OverrideVersionPrinter(outs());
+      (*OverrideVersionPrinter)();
       exit(0);
     }
     print();
@@ -2090,8 +2090,10 @@ public:
     // information.
     if (ExtraVersionPrinters != nullptr) {
       outs() << '\n';
-      for (auto I : *ExtraVersionPrinters)
-        I(outs());
+      for (std::vector<void (*)()>::iterator I = ExtraVersionPrinters->begin(),
+                                             E = ExtraVersionPrinters->end();
+           I != E; ++I)
+        (*I)();
     }
 
     exit(0);
@@ -2129,11 +2131,11 @@ void cl::PrintHelpMessage(bool Hidden, b
 /// Utility function for printing version number.
 void cl::PrintVersionMessage() { VersionPrinterInstance.print(); }
 
-void cl::SetVersionPrinter(VersionPrinterTy func) { OverrideVersionPrinter = func; }
+void cl::SetVersionPrinter(void (*func)()) { OverrideVersionPrinter = func; }
 
-void cl::AddExtraVersionPrinter(VersionPrinterTy func) {
+void cl::AddExtraVersionPrinter(void (*func)()) {
   if (!ExtraVersionPrinters)
-    ExtraVersionPrinters = new std::vector<VersionPrinterTy>;
+    ExtraVersionPrinters = new std::vector<void (*)()>;
 
   ExtraVersionPrinters->push_back(func);
 }

Modified: llvm/branches/release_50/lib/Support/TargetRegistry.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/lib/Support/TargetRegistry.cpp?rev=309286&r1=309285&r2=309286&view=diff
==============================================================================
--- llvm/branches/release_50/lib/Support/TargetRegistry.cpp (original)
+++ llvm/branches/release_50/lib/Support/TargetRegistry.cpp Thu Jul 27 09:21:47 2017
@@ -114,7 +114,7 @@ static int TargetArraySortFn(const std::
   return LHS->first.compare(RHS->first);
 }
 
-void TargetRegistry::printRegisteredTargetsForVersion(raw_ostream &OS) {
+void TargetRegistry::printRegisteredTargetsForVersion() {
   std::vector<std::pair<StringRef, const Target*> > Targets;
   size_t Width = 0;
   for (const auto &T : TargetRegistry::targets()) {
@@ -123,6 +123,7 @@ void TargetRegistry::printRegisteredTarg
   }
   array_pod_sort(Targets.begin(), Targets.end(), TargetArraySortFn);
 
+  raw_ostream &OS = outs();
   OS << "  Registered Targets:\n";
   for (unsigned i = 0, e = Targets.size(); i != e; ++i) {
     OS << "    " << Targets[i].first;




More information about the llvm-branch-commits mailing list