1 //===- CoverageViewOptions.h - Code coverage display options -------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_COV_COVERAGEVIEWOPTIONS_H
11 #define LLVM_COV_COVERAGEVIEWOPTIONS_H
12 
13 #include "llvm/Config/llvm-config.h"
14 #include "RenderingSupport.h"
15 #include <vector>
16 
17 namespace llvm {
18 
19 /// The options for displaying the code coverage information.
20 struct CoverageViewOptions {
21   enum class OutputFormat {
22     Text,
23     HTML,
24     Lcov
25   };
26 
27   bool Debug;
28   bool Colors;
29   bool ShowLineNumbers;
30   bool ShowLineStats;
31   bool ShowRegionMarkers;
32   bool ShowExpandedRegions;
33   bool ShowFunctionInstantiations;
34   bool ShowFullFilenames;
35   bool ShowRegionSummary;
36   bool ShowInstantiationSummary;
37   bool ExportSummaryOnly;
38   OutputFormat Format;
39   std::string ShowOutputDirectory;
40   std::vector<std::string> DemanglerOpts;
41   uint32_t TabSize;
42   std::string ProjectTitle;
43   std::string CreatedTimeStr;
44   unsigned NumThreads;
45 
46   /// Change the output's stream color if the colors are enabled.
colored_ostreamCoverageViewOptions47   ColoredRawOstream colored_ostream(raw_ostream &OS,
48                                     raw_ostream::Colors Color) const {
49     return llvm::colored_ostream(OS, Color, Colors);
50   }
51 
52   /// Check if an output directory has been specified.
hasOutputDirectoryCoverageViewOptions53   bool hasOutputDirectory() const { return !ShowOutputDirectory.empty(); }
54 
55   /// Check if a demangler has been specified.
hasDemanglerCoverageViewOptions56   bool hasDemangler() const { return !DemanglerOpts.empty(); }
57 
58   /// Check if a project title has been specified.
hasProjectTitleCoverageViewOptions59   bool hasProjectTitle() const { return !ProjectTitle.empty(); }
60 
61   /// Check if the created time of the profile data file is available.
hasCreatedTimeCoverageViewOptions62   bool hasCreatedTime() const { return !CreatedTimeStr.empty(); }
63 
64   /// Get the LLVM version string.
getLLVMVersionStringCoverageViewOptions65   std::string getLLVMVersionString() const {
66     std::string VersionString = "Generated by llvm-cov -- llvm version ";
67     VersionString += LLVM_VERSION_STRING;
68     return VersionString;
69   }
70 };
71 }
72 
73 #endif // LLVM_COV_COVERAGEVIEWOPTIONS_H
74