xref: /freebsd/contrib/llvm-project/llvm/tools/llvm-cov/CoverageViewOptions.h (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
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 ShowBranchCounts;
34   bool ShowBranchPercents;
35   bool ShowExpandedRegions;
36   bool ShowFunctionInstantiations;
37   bool ShowFullFilenames;
38   bool ShowBranchSummary;
39   bool ShowRegionSummary;
40   bool ShowInstantiationSummary;
41   bool ExportSummaryOnly;
42   bool SkipExpansions;
43   bool SkipFunctions;
44   bool SkipBranches;
45   OutputFormat Format;
46   BranchOutputType ShowBranches;
47   std::string ShowOutputDirectory;
48   std::vector<std::string> DemanglerOpts;
49   uint32_t TabSize;
50   std::string ProjectTitle;
51   std::string CreatedTimeStr;
52   unsigned NumThreads;
53   std::string CompilationDirectory;
54   float HighCovWatermark;
55   float LowCovWatermark;
56 
57   /// Change the output's stream color if the colors are enabled.
58   ColoredRawOstream colored_ostream(raw_ostream &OS,
59                                     raw_ostream::Colors Color) const {
60     return llvm::colored_ostream(OS, Color, Colors);
61   }
62 
63   /// Check if an output directory has been specified.
64   bool hasOutputDirectory() const { return !ShowOutputDirectory.empty(); }
65 
66   /// Check if a demangler has been specified.
67   bool hasDemangler() const { return !DemanglerOpts.empty(); }
68 
69   /// Check if a project title has been specified.
70   bool hasProjectTitle() const { return !ProjectTitle.empty(); }
71 
72   /// Check if the created time of the profile data file is available.
73   bool hasCreatedTime() const { return !CreatedTimeStr.empty(); }
74 
75   /// Get the LLVM version string.
76   std::string getLLVMVersionString() const {
77     std::string VersionString = "Generated by llvm-cov -- llvm version ";
78     VersionString += LLVM_VERSION_STRING;
79     return VersionString;
80   }
81 };
82 }
83 
84 #endif // LLVM_COV_COVERAGEVIEWOPTIONS_H
85