clang 20.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 "llvm/ADT/IntrusiveRefCntPtr.h"
14#include <string>
15#include <type_traits>
16#include <vector>
17
18namespace llvm {
19namespace opt {
20class ArgList;
21} // namespace opt
22} // namespace llvm
23
24namespace clang {
25class DiagnosticsEngine;
26
27/// Specifies which overload candidates to display when overload
28/// resolution fails.
29enum OverloadsShown : unsigned {
30 /// Show all overloads.
32
33 /// Show just the "best" overload candidates.
35};
36
37/// A bitmask representing the diagnostic levels used by
38/// VerifyDiagnosticConsumer.
39enum 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
49 using UT = std::underlying_type_t<DiagnosticLevelMask>;
50 return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M));
51}
52
55 using UT = std::underlying_type_t<DiagnosticLevelMask>;
56 return static_cast<DiagnosticLevelMask>(
57 static_cast<UT>(LHS) | static_cast<UT>(RHS));
58}
59
62 using UT = std::underlying_type_t<DiagnosticLevelMask>;
63 return static_cast<DiagnosticLevelMask>(
64 static_cast<UT>(LHS) & static_cast<UT>(RHS));
65}
66
67raw_ostream& operator<<(raw_ostream& Out, DiagnosticLevelMask M);
68
69/// Options for controlling the compiler diagnostics engine.
70class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{
71 friend bool ParseDiagnosticArgs(DiagnosticOptions &, llvm::opt::ArgList &,
73
74 friend class CompilerInvocation;
76
77public:
79
80 // Default values.
81 enum {
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
97protected:
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
104public:
105 /// The file to log diagnostic output to.
106 std::string DiagnosticLogFile;
107
108 /// The file to serialize diagnostics to (non-appending).
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-headers-in-module=... options used to override
128 /// whether -Wsystem-headers is enabled on a per-module basis.
129 std::vector<std::string> SystemHeaderWarningsModules;
130
131public:
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 Type get##Name() const { return static_cast<Type>(Name); } \
136 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
137#include "clang/Basic/DiagnosticOptions.def"
138
140#define DIAGOPT(Name, Bits, Default) Name = Default;
141#define ENUM_DIAGOPT(Name, Type, Bits, Default) set##Name(Default);
142#include "clang/Basic/DiagnosticOptions.def"
143 }
144};
145
147
148} // namespace clang
149
150#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::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:192
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