clang 8.0.0

DiagnosticOptions.h
Go to the documentation of this file.
1 //===- DiagnosticOptions.h --------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
11 #define LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
12
13 #include "clang/Basic/LLVM.h"
14 #include "llvm/ADT/IntrusiveRefCntPtr.h"
15 #include <string>
16 #include <type_traits>
17 #include <vector>
18
19 namespace clang {
20
21 /// Specifies which overload candidates to display when overload
22 /// resolution fails.
23 enum OverloadsShown : unsigned {
24 /// Show all overloads.
25 Ovl_All,
26
27 /// Show just the "best" overload candidates.
28 Ovl_Best
29 };
30
31 /// A bitmask representing the diagnostic levels used by
32 /// VerifyDiagnosticConsumer.
33 enum class DiagnosticLevelMask : unsigned {
34 None = 0,
35 Note = 1 << 0,
36 Remark = 1 << 1,
37 Warning = 1 << 2,
38 Error = 1 << 3,
39 All = Note | Remark | Warning | Error
40 };
41
42 inline DiagnosticLevelMask operator~(DiagnosticLevelMask M) {
43 using UT = std::underlying_type<DiagnosticLevelMask>::type;
44 return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M));
45 }
46
47 inline DiagnosticLevelMask operator|(DiagnosticLevelMask LHS,
48 DiagnosticLevelMask RHS) {
49 using UT = std::underlying_type<DiagnosticLevelMask>::type;
50 return static_cast<DiagnosticLevelMask>(
51 static_cast<UT>(LHS) | static_cast<UT>(RHS));
52 }
53
54 inline DiagnosticLevelMask operator&(DiagnosticLevelMask LHS,
55 DiagnosticLevelMask RHS) {
56 using UT = std::underlying_type<DiagnosticLevelMask>::type;
57 return static_cast<DiagnosticLevelMask>(
58 static_cast<UT>(LHS) & static_cast<UT>(RHS));
59 }
60
61 raw_ostream& operator<<(raw_ostream& Out, DiagnosticLevelMask M);
62
63 /// Options for controlling the compiler diagnostics engine.
64 class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{
65 public:
66 enum TextDiagnosticFormat { Clang, MSVC, Vi };
67
68 // Default values.
69 enum {
70 DefaultTabStop = 8,
71 MaxTabStop = 100,
72 DefaultMacroBacktraceLimit = 6,
73 DefaultTemplateBacktraceLimit = 10,
74 DefaultConstexprBacktraceLimit = 10,
75 DefaultSpellCheckingLimit = 50,
76 DefaultSnippetLineLimit = 1,
77 };
78
79 // Define simple diagnostic options (with no accessors).
80 #define DIAGOPT(Name, Bits, Default) unsigned Name : Bits;
81 #define ENUM_DIAGOPT(Name, Type, Bits, Default)
82 #include "clang/Basic/DiagnosticOptions.def"
83
84 protected:
85 // Define diagnostic options of enumeration type. These are private, and will
86 // have accessors (below).
87 #define DIAGOPT(Name, Bits, Default)
88 #define ENUM_DIAGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
89 #include "clang/Basic/DiagnosticOptions.def"
90
91 public:
92 /// The file to log diagnostic output to.
93 std::string DiagnosticLogFile;
94
95 /// The file to serialize diagnostics to (non-appending).
96 std::string DiagnosticSerializationFile;
97
98 /// The list of -W... options used to alter the diagnostic mappings, with the
99 /// prefixes removed.
100 std::vector<std::string> Warnings;
101
102 /// The list of -R... options used to alter the diagnostic mappings, with the
103 /// prefixes removed.
104 std::vector<std::string> Remarks;
105
106 /// The prefixes for comment directives sought by -verify ("expected" by
107 /// default).
108 std::vector<std::string> VerifyPrefixes;
109
110 public:
111 // Define accessors/mutators for diagnostic options of enumeration type.
112 #define DIAGOPT(Name, Bits, Default)
113 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
114 Type get##Name() const { return static_cast<Type>(Name); } \
115 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
116 #include "clang/Basic/DiagnosticOptions.def"
117
118 DiagnosticOptions() {
119 #define DIAGOPT(Name, Bits, Default) Name = Default;
120 #define ENUM_DIAGOPT(Name, Type, Bits, Default) set##Name(Default);
121 #include "clang/Basic/DiagnosticOptions.def"
122 }
123 };
124
125 using TextDiagnosticFormat = DiagnosticOptions::TextDiagnosticFormat;
126
127 } // namespace clang
128
129 #endif // LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
clang::ast_matchers::type
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchersInternal.cpp:592
clang::operator<<
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
Definition: Attr.h:336
clang::Ovl_All
Show all overloads.
Definition: DiagnosticOptions.h:25
clang::DiagnosticLevelMask::Remark
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
llvm::RefCountedBase
Definition: LLVM.h:47
clang::DiagnosticOptions::Warnings
std::vector< std::string > Warnings
The list of -W...
Definition: DiagnosticOptions.h:100
clang::DiagnosticOptions::TextDiagnosticFormat
TextDiagnosticFormat
Definition: DiagnosticOptions.h:66
clang::DiagnosticLevelMask::Warning
clang::operator|
DiagnosticLevelMask operator|(DiagnosticLevelMask LHS, DiagnosticLevelMask RHS)
Definition: DiagnosticOptions.h:47
clang::operator &
DiagnosticLevelMask operator &(DiagnosticLevelMask LHS, DiagnosticLevelMask RHS)
Definition: DiagnosticOptions.h:54
clang::Ovl_Best
Show just the "best" overload candidates.
Definition: DiagnosticOptions.h:28
clang::DiagnosticOptions::DiagnosticOptions
DiagnosticOptions()
Definition: DiagnosticOptions.h:118
clang::DiagnosticLevelMask::Error
clang::DiagnosticLevelMask::None
clang::DiagnosticLevelMask::Note
clang::DiagnosticOptions
Options for controlling the compiler diagnostics engine.
Definition: DiagnosticOptions.h:64
clang::DiagnosticOptions::DiagnosticSerializationFile
std::string DiagnosticSerializationFile
The file to serialize diagnostics to (non-appending).
Definition: DiagnosticOptions.h:96
clang::DiagnosticOptions::Remarks
std::vector< std::string > Remarks
The list of -R...
Definition: DiagnosticOptions.h:104
clang::DiagnosticLevelMask::All
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::DiagnosticOptions::VerifyPrefixes
std::vector< std::string > VerifyPrefixes
The prefixes for comment directives sought by -verify ("expected" by default).
Definition: DiagnosticOptions.h:108
clang::operator~
DiagnosticLevelMask operator~(DiagnosticLevelMask M)
Definition: DiagnosticOptions.h:42
clang::OverloadsShown
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
Definition: DiagnosticOptions.h:23
clang::DiagnosticLevelMask
DiagnosticLevelMask
A bitmask representing the diagnostic levels used by VerifyDiagnosticConsumer.
Definition: DiagnosticOptions.h:33
clang::DiagnosticOptions::DiagnosticLogFile
std::string DiagnosticLogFile
The file to log diagnostic output to.
Definition: DiagnosticOptions.h:93