Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit c92d174

Browse files
committed
Revert r304835: It's not clear printing all targets with --version is the right thing to do (see discussion on D33900)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_50@309286 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 9a5c333 commit c92d174

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

include/llvm/Support/CommandLine.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,12 @@ bool ParseCommandLineOptions(int argc, const char *const *argv,
6666
void ParseEnvironmentOptions(const char *progName, const char *envvar,
6767
const char *Overview = "");
6868

69-
// Function pointer type for printing version information.
70-
using VersionPrinterTy = std::function<void(raw_ostream &)>;
71-
7269
///===---------------------------------------------------------------------===//
7370
/// SetVersionPrinter - Override the default (LLVM specific) version printer
7471
/// used to print out the version when --version is given
7572
/// on the command line. This allows other systems using the
7673
/// CommandLine utilities to print their own version string.
77-
void SetVersionPrinter(VersionPrinterTy func);
74+
void SetVersionPrinter(void (*func)());
7875

7976
///===---------------------------------------------------------------------===//
8077
/// AddExtraVersionPrinter - Add an extra printer to use in addition to the
@@ -83,7 +80,7 @@ void SetVersionPrinter(VersionPrinterTy func);
8380
/// which will be called after the basic LLVM version
8481
/// printing is complete. Each can then add additional
8582
/// information specific to the tool.
86-
void AddExtraVersionPrinter(VersionPrinterTy func);
83+
void AddExtraVersionPrinter(void (*func)());
8784

8885
// PrintOptionValues - Print option values.
8986
// With -print-options print the difference between option values and defaults.

include/llvm/Support/TargetRegistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ struct TargetRegistry {
599599

600600
/// printRegisteredTargetsForVersion - Print the registered targets
601601
/// appropriately for inclusion in a tool's version output.
602-
static void printRegisteredTargetsForVersion(raw_ostream &OS);
602+
static void printRegisteredTargetsForVersion();
603603

604604
/// @name Registry Access
605605
/// @{

lib/Support/CommandLine.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,9 +2039,9 @@ void CommandLineParser::printOptionValues() {
20392039
Opts[i].second->printOptionValue(MaxArgLen, PrintAllOptions);
20402040
}
20412041

2042-
static VersionPrinterTy OverrideVersionPrinter = nullptr;
2042+
static void (*OverrideVersionPrinter)() = nullptr;
20432043

2044-
static std::vector<VersionPrinterTy> *ExtraVersionPrinters = nullptr;
2044+
static std::vector<void (*)()> *ExtraVersionPrinters = nullptr;
20452045

20462046
namespace {
20472047
class VersionPrinter {
@@ -2081,7 +2081,7 @@ class VersionPrinter {
20812081
return;
20822082

20832083
if (OverrideVersionPrinter != nullptr) {
2084-
OverrideVersionPrinter(outs());
2084+
(*OverrideVersionPrinter)();
20852085
exit(0);
20862086
}
20872087
print();
@@ -2090,8 +2090,10 @@ class VersionPrinter {
20902090
// information.
20912091
if (ExtraVersionPrinters != nullptr) {
20922092
outs() << '\n';
2093-
for (auto I : *ExtraVersionPrinters)
2094-
I(outs());
2093+
for (std::vector<void (*)()>::iterator I = ExtraVersionPrinters->begin(),
2094+
E = ExtraVersionPrinters->end();
2095+
I != E; ++I)
2096+
(*I)();
20952097
}
20962098

20972099
exit(0);
@@ -2129,11 +2131,11 @@ void cl::PrintHelpMessage(bool Hidden, bool Categorized) {
21292131
/// Utility function for printing version number.
21302132
void cl::PrintVersionMessage() { VersionPrinterInstance.print(); }
21312133

2132-
void cl::SetVersionPrinter(VersionPrinterTy func) { OverrideVersionPrinter = func; }
2134+
void cl::SetVersionPrinter(void (*func)()) { OverrideVersionPrinter = func; }
21332135

2134-
void cl::AddExtraVersionPrinter(VersionPrinterTy func) {
2136+
void cl::AddExtraVersionPrinter(void (*func)()) {
21352137
if (!ExtraVersionPrinters)
2136-
ExtraVersionPrinters = new std::vector<VersionPrinterTy>;
2138+
ExtraVersionPrinters = new std::vector<void (*)()>;
21372139

21382140
ExtraVersionPrinters->push_back(func);
21392141
}

lib/Support/TargetRegistry.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static int TargetArraySortFn(const std::pair<StringRef, const Target *> *LHS,
114114
return LHS->first.compare(RHS->first);
115115
}
116116

117-
void TargetRegistry::printRegisteredTargetsForVersion(raw_ostream &OS) {
117+
void TargetRegistry::printRegisteredTargetsForVersion() {
118118
std::vector<std::pair<StringRef, const Target*> > Targets;
119119
size_t Width = 0;
120120
for (const auto &T : TargetRegistry::targets()) {
@@ -123,6 +123,7 @@ void TargetRegistry::printRegisteredTargetsForVersion(raw_ostream &OS) {
123123
}
124124
array_pod_sort(Targets.begin(), Targets.end(), TargetArraySortFn);
125125

126+
raw_ostream &OS = outs();
126127
OS << " Registered Targets:\n";
127128
for (unsigned i = 0, e = Targets.size(); i != e; ++i) {
128129
OS << " " << Targets[i].first;

0 commit comments

Comments
 (0)