clang 22.0.0git
DiagnosticOptions.h
Go to the documentation of this file.
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 <string>
14#include <type_traits>
15#include <vector>
16
17namespace llvm {
18namespace opt {
19class ArgList;
20} // namespace opt
21} // namespace llvm
22
23namespace clang {
24class DiagnosticsEngine;
25
26/// Specifies which overload candidates to display when overload
27/// resolution fails.
28enum OverloadsShown : unsigned {
29 /// Show all overloads.
31
32 /// Show just the "best" overload candidates.
34};
35
36/// A bitmask representing the diagnostic levels used by
37/// VerifyDiagnosticConsumer.
38enum class DiagnosticLevelMask : unsigned {
39 None = 0,
40 Note = 1 << 0,
41 Remark = 1 << 1,
42 Warning = 1 << 2,
43 Error = 1 << 3,
44 All = Note | Remark | Warning | Error
45};
46
48 using UT = std::underlying_type_t<DiagnosticLevelMask>;
49 return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M));
50}
51
54 using UT = std::underlying_type_t<DiagnosticLevelMask>;
55 return static_cast<DiagnosticLevelMask>(
56 static_cast<UT>(LHS) | static_cast<UT>(RHS));
57}
58
61 using UT = std::underlying_type_t<DiagnosticLevelMask>;
62 return static_cast<DiagnosticLevelMask>(
63 static_cast<UT>(LHS) & static_cast<UT>(RHS));
64}
65
66raw_ostream& operator<<(raw_ostream& Out, DiagnosticLevelMask M);
67
68/// Options for controlling the compiler diagnostics engine.
70 friend bool ParseDiagnosticArgs(DiagnosticOptions &, llvm::opt::ArgList &,
72
73 friend class CompilerInvocation;
75
76public:
78
79 // Default values.
80 enum {
89 };
90
91 // Define simple diagnostic options (with no accessors).
92#define DIAGOPT(Name, Bits, Default) unsigned Name : Bits;
93#define ENUM_DIAGOPT(Name, Type, Bits, Default)
94#include "clang/Basic/DiagnosticOptions.def"
95
96protected:
97 // Define diagnostic options of enumeration type. These are private, and will
98 // have accessors (below).
99#define DIAGOPT(Name, Bits, Default)
100#define ENUM_DIAGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
101#include "clang/Basic/DiagnosticOptions.def"
102
103public:
104 /// The file to log diagnostic output to.
105 std::string DiagnosticLogFile;
106
107 /// The file to serialize diagnostics to (non-appending).
109
110 /// Path for the file that defines diagnostic suppression mappings.
112
113 /// The list of -W... options used to alter the diagnostic mappings, with the
114 /// prefixes removed.
115 std::vector<std::string> Warnings;
116
117 /// The list of prefixes from -Wundef-prefix=... used to generate warnings
118 /// for undefined macros.
119 std::vector<std::string> UndefPrefixes;
120
121 /// The list of -R... options used to alter the diagnostic mappings, with the
122 /// prefixes removed.
123 std::vector<std::string> Remarks;
124
125 /// The prefixes for comment directives sought by -verify ("expected" by
126 /// default).
127 std::vector<std::string> VerifyPrefixes;
128
129 /// The list of -Wsystem-headers-in-module=... options used to override
130 /// whether -Wsystem-headers is enabled on a per-module basis.
131 std::vector<std::string> SystemHeaderWarningsModules;
132
133public:
134 // Define accessors/mutators for diagnostic options of enumeration type.
135#define DIAGOPT(Name, Bits, Default)
136#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
137 Type get##Name() const { return static_cast<Type>(Name); } \
138 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
139#include "clang/Basic/DiagnosticOptions.def"
140
142#define DIAGOPT(Name, Bits, Default) Name = Default;
143#define ENUM_DIAGOPT(Name, Type, Bits, Default) set##Name(Default);
144#include "clang/Basic/DiagnosticOptions.def"
145 }
146};
147
149
150} // namespace clang
151
152#endif // LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
The base class of CompilerInvocation.
Helper class for holding the data necessary to invoke the compiler.
Options for controlling the compiler diagnostics engine.
std::string DiagnosticSuppressionMappingsFile
Path for the file that defines diagnostic suppression mappings.
std::vector< std::string > Remarks
The list of -R... options used to alter the diagnostic mappings, with the prefixes removed.
std::vector< std::string > Warnings
The list of -W... options used to alter the diagnostic mappings, with the prefixes removed.
std::string DiagnosticLogFile
The file to log diagnostic output to.
std::vector< std::string > VerifyPrefixes
The prefixes for comment directives sought by -verify ("expected" by default).
std::vector< std::string > UndefPrefixes
The list of prefixes from -Wundef-prefix=... used to generate warnings for undefined macros.
std::vector< std::string > SystemHeaderWarningsModules
The list of -Wsystem-headers-in-module=... options used to override whether -Wsystem-headers is enabl...
std::string DiagnosticSerializationFile
The file to serialize diagnostics to (non-appending).
friend bool ParseDiagnosticArgs(DiagnosticOptions &, llvm::opt::ArgList &, clang::DiagnosticsEngine *, bool)
Fill out Opts based on the options given in Args.
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:231
The JSON file list parser is used to communicate input to InstallAPI.
DiagnosticLevelMask
A bitmask representing the diagnostic levels used by VerifyDiagnosticConsumer.
DiagnosticLevelMask operator&(DiagnosticLevelMask LHS, DiagnosticLevelMask RHS)
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
@ Ovl_All
Show all overloads.
@ Ovl_Best
Show just the "best" overload candidates.
DiagnosticLevelMask operator~(DiagnosticLevelMask M)
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
DiagnosticLevelMask operator|(DiagnosticLevelMask LHS, DiagnosticLevelMask RHS)
@ None
The alignment was not explicit in code.
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30