clang  14.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 
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.
32 
33  /// Show just the "best" overload candidates.
35 };
36 
37 /// A bitmask representing the diagnostic levels used by
38 /// VerifyDiagnosticConsumer.
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 
50  return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M));
51 }
52 
54  DiagnosticLevelMask RHS) {
56  return static_cast<DiagnosticLevelMask>(
57  static_cast<UT>(LHS) | static_cast<UT>(RHS));
58 }
59 
61  DiagnosticLevelMask RHS) {
63  return static_cast<DiagnosticLevelMask>(
64  static_cast<UT>(LHS) & static_cast<UT>(RHS));
65 }
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 
76 public:
78 
79  // Default values.
80  enum {
82  MaxTabStop = 100,
88  };
89 
90  // Define simple diagnostic options (with no accessors).
91 #define DIAGOPT(Name, Bits, Default) unsigned Name : Bits;
92 #define ENUM_DIAGOPT(Name, Type, Bits, Default)
93 #include "clang/Basic/DiagnosticOptions.def"
94 
95 protected:
96  // Define diagnostic options of enumeration type. These are private, and will
97  // have accessors (below).
98 #define DIAGOPT(Name, Bits, Default)
99 #define ENUM_DIAGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
100 #include "clang/Basic/DiagnosticOptions.def"
101 
102 public:
103  /// The file to log diagnostic output to.
105 
106  /// The file to serialize diagnostics to (non-appending).
108 
109  /// The list of -W... options used to alter the diagnostic mappings, with the
110  /// prefixes removed.
111  std::vector<std::string> Warnings;
112 
113  /// The list of prefixes from -Wundef-prefix=... used to generate warnings
114  /// for undefined macros.
115  std::vector<std::string> UndefPrefixes;
116 
117  /// The list of -R... options used to alter the diagnostic mappings, with the
118  /// prefixes removed.
119  std::vector<std::string> Remarks;
120 
121  /// The prefixes for comment directives sought by -verify ("expected" by
122  /// default).
123  std::vector<std::string> VerifyPrefixes;
124 
125 public:
126  // Define accessors/mutators for diagnostic options of enumeration type.
127 #define DIAGOPT(Name, Bits, Default)
128 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
129  Type get##Name() const { return static_cast<Type>(Name); } \
130  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
131 #include "clang/Basic/DiagnosticOptions.def"
132 
134 #define DIAGOPT(Name, Bits, Default) Name = Default;
135 #define ENUM_DIAGOPT(Name, Type, Bits, Default) set##Name(Default);
136 #include "clang/Basic/DiagnosticOptions.def"
137  }
138 };
139 
141 
142 } // namespace clang
143 
144 #endif // LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
clang::DiagnosticOptions::DefaultTemplateBacktraceLimit
@ DefaultTemplateBacktraceLimit
Definition: DiagnosticOptions.h:84
llvm
Definition: Dominators.h:30
clang::DiagnosticOptions::DefaultMacroBacktraceLimit
@ DefaultMacroBacktraceLimit
Definition: DiagnosticOptions.h:83
clang::DiagnosticOptions::DefaultSnippetLineLimit
@ DefaultSnippetLineLimit
Definition: DiagnosticOptions.h:87
clang::DiagnosticOptions::DiagnosticSerializationFile
std::string DiagnosticSerializationFile
The file to serialize diagnostics to (non-appending).
Definition: DiagnosticOptions.h:107
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::DiagnosticOptions::MSVC
@ MSVC
Definition: DiagnosticOptions.h:77
clang::DiagnosticLevelMask::Error
@ Error
clang::DiagnosticOptions::DefaultConstexprBacktraceLimit
@ DefaultConstexprBacktraceLimit
Definition: DiagnosticOptions.h:85
clang::DiagnosticsEngine
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:191
clang::ast_matchers::type
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchersInternal.cpp:772
clang::Ovl_Best
@ Ovl_Best
Show just the "best" overload candidates.
Definition: DiagnosticOptions.h:34
llvm::RefCountedBase
Definition: LLVM.h:49
clang::DiagnosticOptions::DiagnosticOptions
DiagnosticOptions()
Definition: DiagnosticOptions.h:133
clang::operator&
DiagnosticLevelMask operator&(DiagnosticLevelMask LHS, DiagnosticLevelMask RHS)
Definition: DiagnosticOptions.h:60
clang::Ovl_All
@ Ovl_All
Show all overloads.
Definition: DiagnosticOptions.h:31
clang::DiagnosticOptions::ParseDiagnosticArgs
friend bool ParseDiagnosticArgs(DiagnosticOptions &, llvm::opt::ArgList &, clang::DiagnosticsEngine *, bool)
Fill out Opts based on the options given in Args.
clang::operator<<
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
Definition: ASTContext.cpp:11777
clang::operator|
DiagnosticLevelMask operator|(DiagnosticLevelMask LHS, DiagnosticLevelMask RHS)
Definition: DiagnosticOptions.h:53
clang::DiagnosticOptions::Vi
@ Vi
Definition: DiagnosticOptions.h:77
clang::operator~
DiagnosticLevelMask operator~(DiagnosticLevelMask M)
Definition: DiagnosticOptions.h:48
clang::DiagnosticOptions::Warnings
std::vector< std::string > Warnings
The list of -W...
Definition: DiagnosticOptions.h:111
clang::DiagnosticOptions::DefaultTabStop
@ DefaultTabStop
Definition: DiagnosticOptions.h:81
clang::DiagnosticOptions::UndefPrefixes
std::vector< std::string > UndefPrefixes
The list of prefixes from -Wundef-prefix=...
Definition: DiagnosticOptions.h:115
LLVM.h
clang::DiagnosticLevelMask
DiagnosticLevelMask
A bitmask representing the diagnostic levels used by VerifyDiagnosticConsumer.
Definition: DiagnosticOptions.h:39
clang::DiagnosticOptions::DiagnosticLogFile
std::string DiagnosticLogFile
The file to log diagnostic output to.
Definition: DiagnosticOptions.h:104
clang::DiagnosticOptions::Remarks
std::vector< std::string > Remarks
The list of -R...
Definition: DiagnosticOptions.h:119
clang::DiagnosticOptions::MaxTabStop
@ MaxTabStop
Definition: DiagnosticOptions.h:82
clang::DiagnosticLevelMask::None
@ None
clang::DiagnosticLevelMask::Remark
@ Remark
clang::DiagnosticLevelMask::All
@ All
clang::DiagnosticLevelMask::Note
@ Note
clang::DiagnosticOptions::TextDiagnosticFormat
TextDiagnosticFormat
Definition: DiagnosticOptions.h:77
clang
Definition: CalledOnceCheck.h:17
clang::DiagnosticOptions::DefaultSpellCheckingLimit
@ DefaultSpellCheckingLimit
Definition: DiagnosticOptions.h:86
clang::CompilerInvocation
Helper class for holding the data necessary to invoke the compiler.
Definition: CompilerInvocation.h:193
unsigned
clang::DiagnosticOptions::Clang
@ Clang
Definition: DiagnosticOptions.h:77
clang::OverloadsShown
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
Definition: DiagnosticOptions.h:29
clang::DiagnosticLevelMask::Warning
@ Warning
clang::DiagnosticOptions
Options for controlling the compiler diagnostics engine.
Definition: DiagnosticOptions.h:70
clang::DiagnosticOptions::VerifyPrefixes
std::vector< std::string > VerifyPrefixes
The prefixes for comment directives sought by -verify ("expected" by default).
Definition: DiagnosticOptions.h:123