//===----------------------------------------------------------------------===//
#include "RenderingSupport.h"
-#include "CoverageViewOptions.h"
#include "CoverageFilters.h"
-#include "SourceCoverageView.h"
-#include "CoverageSummary.h"
#include "CoverageReport.h"
-#include "llvm/ADT/StringRef.h"
+#include "CoverageViewOptions.h"
+#include "SourceCoverageView.h"
#include "llvm/ADT/SmallString.h"
-#include "llvm/ProfileData/InstrProfReader.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ProfileData/CoverageMapping.h"
-#include "llvm/ProfileData/CoverageMappingReader.h"
+#include "llvm/ProfileData/InstrProfReader.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Path.h"
-#include "llvm/Support/Signals.h"
#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Signals.h"
#include <functional>
#include <system_error>
int report(int argc, const char **argv,
CommandLineParserType commandLineParser);
- StringRef ObjectFilename;
+ std::string ObjectFilename;
CoverageViewOptions ViewOpts;
std::string PGOFilename;
CoverageFiltersMatchAll Filters;
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);
for (const auto &File : InputSourceFiles) {
SmallString<128> Path(File);
- if (std::error_code EC = sys::fs::make_absolute(Path)) {
- errs() << "error: " << File << ": " << EC.message();
- return 1;
- }
+ if (!CompareFilenamesOnly)
+ if (std::error_code EC = sys::fs::make_absolute(Path)) {
+ errs() << "error: " << File << ": " << EC.message();
+ return 1;
+ }
SourceFiles.push_back(Path.str());
}
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);
if (!Coverage)
return 1;
- CoverageSummary Summarizer;
- Summarizer.createSummaries(Coverage->getCoveredFunctions());
- CoverageReport Report(ViewOpts, Summarizer);
- if (SourceFiles.empty() && Filters.empty()) {
+ CoverageReport Report(ViewOpts, std::move(Coverage));
+ if (SourceFiles.empty())
Report.renderFileReports(llvm::outs());
- return 0;
- }
-
- Report.renderFunctionReports(llvm::outs());
+ else
+ Report.renderFunctionReports(SourceFiles, llvm::outs());
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);
}