• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   bool Debug;
27   bool Colors;
28   bool ShowLineNumbers;
29   bool ShowLineStats;
30   bool ShowRegionMarkers;
31   bool ShowExpandedRegions;
32   bool ShowFunctionInstantiations;
33   bool ShowFullFilenames;
34   bool ShowRegionSummary;
35   bool ShowInstantiationSummary;
36   bool ExportSummaryOnly;
37   bool SkipExpansions;
38   bool SkipFunctions;
39   OutputFormat Format;
40   std::string ShowOutputDirectory;
41   std::vector<std::string> DemanglerOpts;
42   uint32_t TabSize;
43   std::string ProjectTitle;
44   std::string CreatedTimeStr;
45   unsigned NumThreads;
46 
47   /// Change the output's stream color if the colors are enabled.
colored_ostreamCoverageViewOptions48   ColoredRawOstream colored_ostream(raw_ostream &OS,
49                                     raw_ostream::Colors Color) const {
50     return llvm::colored_ostream(OS, Color, Colors);
51   }
52 
53   /// Check if an output directory has been specified.
hasOutputDirectoryCoverageViewOptions54   bool hasOutputDirectory() const { return !ShowOutputDirectory.empty(); }
55 
56   /// Check if a demangler has been specified.
hasDemanglerCoverageViewOptions57   bool hasDemangler() const { return !DemanglerOpts.empty(); }
58 
59   /// Check if a project title has been specified.
hasProjectTitleCoverageViewOptions60   bool hasProjectTitle() const { return !ProjectTitle.empty(); }
61 
62   /// Check if the created time of the profile data file is available.
hasCreatedTimeCoverageViewOptions63   bool hasCreatedTime() const { return !CreatedTimeStr.empty(); }
64 
65   /// Get the LLVM version string.
getLLVMVersionStringCoverageViewOptions66   std::string getLLVMVersionString() const {
67     std::string VersionString = "Generated by llvm-cov -- llvm version ";
68     VersionString += LLVM_VERSION_STRING;
69     return VersionString;
70   }
71 };
72 }
73 
74 #endif // LLVM_COV_COVERAGEVIEWOPTIONS_H
75