mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
Add an extension point to the CommandLine library where clients can
register extra version information to be printed. This is designed to allow those tools which link in various targets to also print those registered targets under --version. Currently this printing logic is embedded into the Support library directly; a huge layering violation. This is the first step to hoisting it out into the tools without adding lots of duplicated code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135755 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
12b2772578
commit
6d51d26a24
@ -59,6 +59,15 @@ void ParseEnvironmentOptions(const char *progName, const char *envvar,
|
||||
/// CommandLine utilities to print their own version string.
|
||||
void SetVersionPrinter(void (*func)());
|
||||
|
||||
///===---------------------------------------------------------------------===//
|
||||
/// AddExtraVersionPrinter - Add an extra printer to use in addition to the
|
||||
/// default one. This can be called multiple times,
|
||||
/// and each time it adds a new function to the list
|
||||
/// which will be called after the basic LLVM version
|
||||
/// printing is complete. Each can then add additional
|
||||
/// information specific to the tool.
|
||||
void AddExtraVersionPrinter(void (*func)());
|
||||
|
||||
|
||||
// PrintOptionValues - Print option values.
|
||||
// With -print-options print the difference between option values and defaults.
|
||||
|
@ -1330,6 +1330,8 @@ void cl::PrintOptionValues() {
|
||||
|
||||
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);
|
||||
@ -1387,11 +1389,21 @@ public:
|
||||
void operator=(bool OptionWasSpecified) {
|
||||
if (!OptionWasSpecified) return;
|
||||
|
||||
if (OverrideVersionPrinter == 0) {
|
||||
print();
|
||||
if (OverrideVersionPrinter != 0) {
|
||||
(*OverrideVersionPrinter)();
|
||||
exit(1);
|
||||
}
|
||||
(*OverrideVersionPrinter)();
|
||||
print();
|
||||
|
||||
// Iterate over any registered extra printers and call them to add further
|
||||
// information.
|
||||
if (ExtraVersionPrinters != 0) {
|
||||
for (std::vector<void (*)()>::iterator I = ExtraVersionPrinters->begin(),
|
||||
E = ExtraVersionPrinters->end();
|
||||
I != E; ++I)
|
||||
(*I)();
|
||||
}
|
||||
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
@ -1424,3 +1436,10 @@ void cl::PrintVersionMessage() {
|
||||
void cl::SetVersionPrinter(void (*func)()) {
|
||||
OverrideVersionPrinter = func;
|
||||
}
|
||||
|
||||
void cl::AddExtraVersionPrinter(void (*func)()) {
|
||||
if (ExtraVersionPrinters == 0)
|
||||
ExtraVersionPrinters = new std::vector<void (*)()>;
|
||||
|
||||
ExtraVersionPrinters->push_back(func);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user