llvm.org GIT mirror llvm / 0347ce7
[llvm-cov] Add a format option for the 'show' sub-command (mostly NFC) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273968 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 3 years ago
5 changed file(s) with 23 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
235235
236236 Show code coverage only for functions that match the given regular expression.
237237
238 .. option:: -format=
239
240 Use the specified output format. The supported formats are: "text".
241
238242 .. option:: -line-coverage-gt=
239243
240244 Show code coverage only for functions with line coverage greater than the
33 // NAN-NOT: 0{{[ \t]+}}nan%{{[ \t]+}}0{{[ \t]+}}nan%
44
55 // RUN: llvm-profdata merge %S/Inputs/prevent_false_instantiations.proftext -o %t.profdata
6 // RUN: llvm-cov show %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s -check-prefix=INSTANTIATION
6 // RUN: llvm-cov show -format text %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s -check-prefix=INSTANTIATION
77 // RUN: llvm-cov report %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %t.profdata | FileCheck %s -check-prefix=NAN
88
99 #define DO_SOMETHING() \
398398 cl::desc("Show function instantiations"),
399399 cl::cat(ViewCategory));
400400
401 cl::opt ShowFormat(
402 "format", cl::desc("Output format for line-based coverage reports"),
403 cl::values(clEnumValN(CoverageViewOptions::OutputFormat::Text, "text",
404 "Text output"),
405 clEnumValEnd),
406 cl::init(CoverageViewOptions::OutputFormat::Text));
407
401408 auto Err = commandLineParser(argc, argv);
402409 if (Err)
403410 return Err;
409416 ViewOpts.ShowLineStatsOrRegionMarkers = ShowBestLineRegionsCounts;
410417 ViewOpts.ShowExpandedRegions = ShowExpansions;
411418 ViewOpts.ShowFunctionInstantiations = ShowInstantiations;
419 ViewOpts.ShowFormat = ShowFormat;
412420
413421 auto Coverage = load();
414422 if (!Coverage)
1515
1616 /// \brief The options for displaying the code coverage information.
1717 struct CoverageViewOptions {
18 enum class OutputFormat {
19 Text
20 };
21
1822 bool Debug;
1923 bool Colors;
2024 bool ShowLineNumbers;
2428 bool ShowExpandedRegions;
2529 bool ShowFunctionInstantiations;
2630 bool ShowFullFilenames;
31 OutputFormat ShowFormat;
2732
2833 /// \brief Change the output's stream color if the colors are enabled.
2934 ColoredRawOstream colored_ostream(raw_ostream &OS,
4949 SourceCoverageView::create(StringRef SourceName, const MemoryBuffer &File,
5050 const CoverageViewOptions &Options,
5151 coverage::CoverageData &&CoverageInfo) {
52 return llvm::make_unique(SourceName, File, Options,
53 std::move(CoverageInfo));
52 switch (Options.ShowFormat) {
53 case CoverageViewOptions::OutputFormat::Text:
54 return llvm::make_unique(SourceName, File, Options,
55 std::move(CoverageInfo));
56 }
5457 }
5558
5659 void SourceCoverageView::print(raw_ostream &OS, bool WholeFile,