aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/CommandLine.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-11-16 06:11:52 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-11-16 06:11:52 +0000
commit9bbba091396922093687d11a181e5886c42c5dfd (patch)
treed7c9f33e6fe941c0d335160a75ed88187a7661cb /lib/Support/CommandLine.cpp
parenteea9b134fcd97aa6c11277864fecf2d30640d27f (diff)
Per code review:
*Implement/Document the cl::extrahelp feature instead of the MoreHelp ptr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17871 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/CommandLine.cpp')
-rw-r--r--lib/Support/CommandLine.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index ad82c84947..15fd19591a 100644
--- a/lib/Support/CommandLine.cpp
+++ b/lib/Support/CommandLine.cpp
@@ -838,7 +838,15 @@ void generic_parser_base::printOptionInfo(const Option &O,
// If this variable is set, it is a pointer to a function that the user wants
// us to call after we print out the help info. Basically a hook to allow
// additional help to be printed.
-void (*cl::MoreHelp)() = 0;
+static std::vector<const char*>* MoreHelp = 0;
+
+extrahelp::extrahelp(const char* Help)
+ : morehelp(Help) {
+ if (!MoreHelp) {
+ MoreHelp = new std::vector<const char*>;
+ }
+ MoreHelp->push_back(Help);
+}
namespace {
@@ -913,11 +921,16 @@ public:
for (unsigned i = 0, e = Options.size(); i != e; ++i)
Options[i].second->printOptionInfo(MaxArgLen);
- // Call the user's hook so help output can be extended.
- if (MoreHelp != 0)
- (*MoreHelp)();
+ // Print any extra help the user has declared. If MoreHelp is not null,
+ // then the user used at least one cl::extrahelp instance to provide
+ // additional help. We just print it out now.
+ if (MoreHelp != 0) {
+ for (std::vector<const char *>::iterator I = MoreHelp->begin(),
+ E = MoreHelp->end(); I != E; ++I)
+ std::cerr << *I;
+ }
- // Halt the program if help information is printed
+ // Halt the program since help information was printed
exit(1);
}
};
@@ -954,4 +967,10 @@ cl::opt<VersionPrinter, true, parser<bool> >
VersOp("version", cl::desc("display the version"),
cl::location(VersionPrinterInstance), cl::ValueDisallowed);
+
} // End anonymous namespace
+
+// Utility function for printing the help message.
+void cl::PrintHelpMessage() {
+ NormalPrinter = true;
+}