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 "RenderingSupport.h"
13#include "llvm/Config/llvm-config.h"
14#include <vector>
15
16namespace llvm {
17
18/// The options for displaying the code coverage information.
19struct 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 ShowMCDCNonExecutedVectors = false;
35 bool ShowBranchCounts;
36 bool ShowBranchPercents;
37 bool ShowExpandedRegions;
38 bool ShowFunctionInstantiations;
39 bool UnifyFunctionInstantiations;
40 bool ShowFullFilenames;
41 bool ShowBranchSummary;
42 bool ShowMCDCSummary;
43 bool ShowRegionSummary;
44 bool ShowFunctionSummary;
45 bool ShowInstantiationSummary;
46 bool ShowDirectoryCoverage;
47 bool ExportSummaryOnly;
48 bool SkipExpansions;
49 bool SkipFunctions;
50 bool SkipBranches;
51 bool BinaryCounters;
52 OutputFormat Format;
53 BranchOutputType ShowBranches;
54 std::string ShowOutputDirectory;
55 std::vector<std::string> DemanglerOpts;
56 uint32_t TabSize;
57 std::string ProjectTitle;
58 std::string CreatedTimeStr;
59 unsigned NumThreads;
60 std::string CompilationDirectory;
61 float HighCovWatermark;
62 float LowCovWatermark;
63
64 /// Change the output's stream color if the colors are enabled.
65 ColoredRawOstream colored_ostream(raw_ostream &OS,
66 raw_ostream::Colors Color) const {
67 return llvm::colored_ostream(OS, Color, IsColorUsed: Colors);
68 }
69
70 /// Check if an output directory has been specified.
71 bool hasOutputDirectory() const { return !ShowOutputDirectory.empty(); }
72
73 /// Check if a demangler has been specified.
74 bool hasDemangler() const { return !DemanglerOpts.empty(); }
75
76 /// Check if a project title has been specified.
77 bool hasProjectTitle() const { return !ProjectTitle.empty(); }
78
79 /// Check if the created time of the profile data file is available.
80 bool hasCreatedTime() const { return !CreatedTimeStr.empty(); }
81
82 /// Get the LLVM version string.
83 std::string getLLVMVersionString() const {
84 std::string VersionString = "Generated by llvm-cov -- llvm version ";
85 VersionString += LLVM_VERSION_STRING;
86 return VersionString;
87 }
88};
89}
90
91#endif // LLVM_COV_COVERAGEVIEWOPTIONS_H
92