1 //===- CoverageViewOptions.h - Code coverage display options -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_COV_COVERAGEVIEWOPTIONS_H
10 #define LLVM_COV_COVERAGEVIEWOPTIONS_H
11 
12 #include "llvm/Config/llvm-config.h"
13 #include "RenderingSupport.h"
14 #include <vector>
15 
16 namespace llvm {
17 
18 /// The options for displaying the code coverage information.
19 struct CoverageViewOptions {
20   enum class OutputFormat {
21     Text,
22     HTML,
23     Lcov
24   };
25 
26   enum class BranchOutputType { Count, Percent, Off };
27 
28   bool Debug;
29   bool Colors;
30   bool ShowLineNumbers;
31   bool ShowLineStats;
32   bool ShowRegionMarkers;
33   bool ShowMCDC;
34   bool ShowBranchCounts;
35   bool ShowBranchPercents;
36   bool ShowExpandedRegions;
37   bool ShowFunctionInstantiations;
38   bool ShowFullFilenames;
39   bool ShowBranchSummary;
40   bool ShowMCDCSummary;
41   bool ShowRegionSummary;
42   bool ShowInstantiationSummary;
43   bool ShowDirectoryCoverage;
44   bool ExportSummaryOnly;
45   bool SkipExpansions;
46   bool SkipFunctions;
47   bool SkipBranches;
48   OutputFormat Format;
49   BranchOutputType ShowBranches;
50   std::string ShowOutputDirectory;
51   std::vector<std::string> DemanglerOpts;
52   uint32_t TabSize;
53   std::string ProjectTitle;
54   std::string CreatedTimeStr;
55   unsigned NumThreads;
56   std::string CompilationDirectory;
57   float HighCovWatermark;
58   float LowCovWatermark;
59 
60   /// Change the output's stream color if the colors are enabled.
colored_ostreamCoverageViewOptions61   ColoredRawOstream colored_ostream(raw_ostream &OS,
62                                     raw_ostream::Colors Color) const {
63     return llvm::colored_ostream(OS, Color, Colors);
64   }
65 
66   /// Check if an output directory has been specified.
hasOutputDirectoryCoverageViewOptions67   bool hasOutputDirectory() const { return !ShowOutputDirectory.empty(); }
68 
69   /// Check if a demangler has been specified.
hasDemanglerCoverageViewOptions70   bool hasDemangler() const { return !DemanglerOpts.empty(); }
71 
72   /// Check if a project title has been specified.
hasProjectTitleCoverageViewOptions73   bool hasProjectTitle() const { return !ProjectTitle.empty(); }
74 
75   /// Check if the created time of the profile data file is available.
hasCreatedTimeCoverageViewOptions76   bool hasCreatedTime() const { return !CreatedTimeStr.empty(); }
77 
78   /// Get the LLVM version string.
getLLVMVersionStringCoverageViewOptions79   std::string getLLVMVersionString() const {
80     std::string VersionString = "Generated by llvm-cov -- llvm version ";
81     VersionString += LLVM_VERSION_STRING;
82     return VersionString;
83   }
84 };
85 }
86 
87 #endif // LLVM_COV_COVERAGEVIEWOPTIONS_H
88