/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Basic/DiagnosticOptions.h
Line | Count | Source |
1 | | //===- DiagnosticOptions.h --------------------------------------*- C++ -*-===// |
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_CLANG_BASIC_DIAGNOSTICOPTIONS_H |
10 | | #define LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H |
11 | | |
12 | | #include "clang/Basic/LLVM.h" |
13 | | #include "llvm/ADT/IntrusiveRefCntPtr.h" |
14 | | #include <string> |
15 | | #include <type_traits> |
16 | | #include <vector> |
17 | | |
18 | | namespace llvm { |
19 | | namespace opt { |
20 | | class ArgList; |
21 | | } // namespace opt |
22 | | } // namespace llvm |
23 | | |
24 | | namespace clang { |
25 | | class DiagnosticsEngine; |
26 | | |
27 | | /// Specifies which overload candidates to display when overload |
28 | | /// resolution fails. |
29 | | enum OverloadsShown : unsigned { |
30 | | /// Show all overloads. |
31 | | Ovl_All, |
32 | | |
33 | | /// Show just the "best" overload candidates. |
34 | | Ovl_Best |
35 | | }; |
36 | | |
37 | | /// A bitmask representing the diagnostic levels used by |
38 | | /// VerifyDiagnosticConsumer. |
39 | | enum class DiagnosticLevelMask : unsigned { |
40 | | None = 0, |
41 | | Note = 1 << 0, |
42 | | Remark = 1 << 1, |
43 | | Warning = 1 << 2, |
44 | | Error = 1 << 3, |
45 | | All = Note | Remark | Warning | Error |
46 | | }; |
47 | | |
48 | 20.5k | inline DiagnosticLevelMask operator~(DiagnosticLevelMask M) { |
49 | 20.5k | using UT = std::underlying_type_t<DiagnosticLevelMask>; |
50 | 20.5k | return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M)); |
51 | 20.5k | } |
52 | | |
53 | | inline DiagnosticLevelMask operator|(DiagnosticLevelMask LHS, |
54 | 100 | DiagnosticLevelMask RHS) { |
55 | 100 | using UT = std::underlying_type_t<DiagnosticLevelMask>; |
56 | 100 | return static_cast<DiagnosticLevelMask>( |
57 | 100 | static_cast<UT>(LHS) | static_cast<UT>(RHS)); |
58 | 100 | } |
59 | | |
60 | | inline DiagnosticLevelMask operator&(DiagnosticLevelMask LHS, |
61 | 164k | DiagnosticLevelMask RHS) { |
62 | 164k | using UT = std::underlying_type_t<DiagnosticLevelMask>; |
63 | 164k | return static_cast<DiagnosticLevelMask>( |
64 | 164k | static_cast<UT>(LHS) & static_cast<UT>(RHS)); |
65 | 164k | } |
66 | | |
67 | | raw_ostream& operator<<(raw_ostream& Out, DiagnosticLevelMask M); |
68 | | |
69 | | /// Options for controlling the compiler diagnostics engine. |
70 | | class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{ |
71 | | friend bool ParseDiagnosticArgs(DiagnosticOptions &, llvm::opt::ArgList &, |
72 | | clang::DiagnosticsEngine *, bool); |
73 | | |
74 | | friend class CompilerInvocation; |
75 | | friend class CompilerInvocationBase; |
76 | | |
77 | | public: |
78 | | enum TextDiagnosticFormat { Clang, MSVC, Vi, SARIF }; |
79 | | |
80 | | // Default values. |
81 | | enum { |
82 | | DefaultTabStop = 8, |
83 | | MaxTabStop = 100, |
84 | | DefaultMacroBacktraceLimit = 6, |
85 | | DefaultTemplateBacktraceLimit = 10, |
86 | | DefaultConstexprBacktraceLimit = 10, |
87 | | DefaultSpellCheckingLimit = 50, |
88 | | DefaultSnippetLineLimit = 16, |
89 | | DefaultShowLineNumbers = 1, |
90 | | }; |
91 | | |
92 | | // Define simple diagnostic options (with no accessors). |
93 | | #define DIAGOPT(Name, Bits, Default) unsigned Name : Bits; |
94 | | #define ENUM_DIAGOPT(Name, Type, Bits, Default) |
95 | | #include "clang/Basic/DiagnosticOptions.def" |
96 | | |
97 | | protected: |
98 | | // Define diagnostic options of enumeration type. These are private, and will |
99 | | // have accessors (below). |
100 | | #define DIAGOPT(Name, Bits, Default) |
101 | | #define ENUM_DIAGOPT(Name, Type, Bits, Default) unsigned Name : Bits; |
102 | | #include "clang/Basic/DiagnosticOptions.def" |
103 | | |
104 | | public: |
105 | | /// The file to log diagnostic output to. |
106 | | std::string DiagnosticLogFile; |
107 | | |
108 | | /// The file to serialize diagnostics to (non-appending). |
109 | | std::string DiagnosticSerializationFile; |
110 | | |
111 | | /// The list of -W... options used to alter the diagnostic mappings, with the |
112 | | /// prefixes removed. |
113 | | std::vector<std::string> Warnings; |
114 | | |
115 | | /// The list of prefixes from -Wundef-prefix=... used to generate warnings |
116 | | /// for undefined macros. |
117 | | std::vector<std::string> UndefPrefixes; |
118 | | |
119 | | /// The list of -R... options used to alter the diagnostic mappings, with the |
120 | | /// prefixes removed. |
121 | | std::vector<std::string> Remarks; |
122 | | |
123 | | /// The prefixes for comment directives sought by -verify ("expected" by |
124 | | /// default). |
125 | | std::vector<std::string> VerifyPrefixes; |
126 | | |
127 | | /// The list of -Wsystem-header-in-module=... options used to override |
128 | | /// whether -Wsystem-headers is enabled on a per-module basis. |
129 | | std::vector<std::string> SystemHeaderWarningsModules; |
130 | | |
131 | | public: |
132 | | // Define accessors/mutators for diagnostic options of enumeration type. |
133 | | #define DIAGOPT(Name, Bits, Default) |
134 | | #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ |
135 | 599k | Type get##Name() const { return static_cast<Type>(Name); } \ clang::DiagnosticOptions::getFormat() const Line | Count | Source | 135 | 225k | Type get##Name() const { return static_cast<Type>(Name); } \ |
clang::DiagnosticOptions::getShowOverloads() const Line | Count | Source | 135 | 168k | Type get##Name() const { return static_cast<Type>(Name); } \ |
clang::DiagnosticOptions::getVerifyIgnoreUnexpected() const Line | Count | Source | 135 | 205k | Type get##Name() const { return static_cast<Type>(Name); } \ |
|
136 | 2.08M | void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } clang::DiagnosticOptions::setFormat(clang::DiagnosticOptions::TextDiagnosticFormat) Line | Count | Source | 136 | 624k | void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } |
clang::DiagnosticOptions::setShowOverloads(clang::OverloadsShown) Line | Count | Source | 136 | 624k | void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } |
clang::DiagnosticOptions::setVerifyIgnoreUnexpected(clang::DiagnosticLevelMask) Line | Count | Source | 136 | 831k | void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } |
|
137 | | #include "clang/Basic/DiagnosticOptions.def" |
138 | | |
139 | 613k | DiagnosticOptions() { |
140 | 19.6M | #define DIAGOPT(Name, Bits, Default) Name = Default; |
141 | 1.84M | #define ENUM_DIAGOPT(Name, Type, Bits, Default) set##Name(Default); |
142 | 613k | #include "clang/Basic/DiagnosticOptions.def" |
143 | 613k | } |
144 | | }; |
145 | | |
146 | | using TextDiagnosticFormat = DiagnosticOptions::TextDiagnosticFormat; |
147 | | |
148 | | } // namespace clang |
149 | | |
150 | | #endif // LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H |