llvm-cov: Don't manually parse an option for no reason

We're using cl::opt here, but for some reason we're reading out one
particular option by hand instead. This makes -help and the like
behave rather poorly, so let's not do it this way.

llvm-svn: 220928
This commit is contained in:
Justin Bogner 2014-10-30 20:51:24 +00:00
parent 10c046a373
commit a65f2cf59b

View File

@ -81,7 +81,7 @@ public:
int report(int argc, const char **argv,
CommandLineParserType commandLineParser);
StringRef ObjectFilename;
std::string ObjectFilename;
CoverageViewOptions ViewOpts;
std::string PGOFilename;
CoverageFiltersMatchAll Filters;
@ -233,6 +233,10 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
PrettyStackTraceProgram X(argc, argv);
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
cl::opt<std::string, true> ObjectFilename(
cl::Positional, cl::Required, cl::location(this->ObjectFilename),
cl::desc("Covered executable or object file."));
cl::list<std::string> InputSourceFiles(
cl::Positional, cl::desc("<Source files>"), cl::ZeroOrMore);
@ -332,23 +336,6 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
return 0;
};
// Parse the object filename
if (argc > 1) {
StringRef Arg(argv[1]);
if (Arg.equals_lower("-help") || Arg.equals_lower("-version")) {
cl::ParseCommandLineOptions(2, argv, "LLVM code coverage tool\n");
return 0;
}
ObjectFilename = Arg;
argv[1] = argv[0];
--argc;
++argv;
} else {
errs() << sys::path::filename(argv[0]) << ": No executable file given!\n";
return 1;
}
switch (Cmd) {
case Show:
return show(argc, argv, commandLineParser);