Make sure that the go bindings call LLVMInitializeMCJITCompilerOptions
[oota-llvm.git] / tools / llvm-cov / CodeCoverage.cpp
index 9e2f154c233f63b564acc291b42062194d2c37c1..093525eb3dd866ba91fe494259717c6a2b0f7ba3 100644 (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);
@@ -475,7 +462,7 @@ int CodeCoverageTool::report(int argc, const char **argv,
     return 1;
 
   CoverageSummary Summarizer;
-  Summarizer.createSummaries(Coverage->getCoveredFunctions());
+  Summarizer.createSummaries(*Coverage);
   CoverageReport Report(ViewOpts, Summarizer);
   if (SourceFiles.empty() && Filters.empty()) {
     Report.renderFileReports(llvm::outs());
@@ -486,12 +473,12 @@ int CodeCoverageTool::report(int argc, const char **argv,
   return 0;
 }
 
-int show_main(int argc, const char **argv) {
+int showMain(int argc, const char *argv[]) {
   CodeCoverageTool Tool;
   return Tool.run(CodeCoverageTool::Show, argc, argv);
 }
 
-int report_main(int argc, const char **argv) {
+int reportMain(int argc, const char *argv[]) {
   CodeCoverageTool Tool;
   return Tool.run(CodeCoverageTool::Report, argc, argv);
 }