1 //===- DiagnosticOptions.h --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
11 #define LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
13 #include "clang/Basic/LLVM.h"
14 #include "llvm/ADT/IntrusiveRefCntPtr.h"
16 #include <type_traits>
21 /// Specifies which overload candidates to display when overload
23 enum OverloadsShown : unsigned {
24 /// Show all overloads.
27 /// Show just the "best" overload candidates.
31 /// A bitmask representing the diagnostic levels used by
32 /// VerifyDiagnosticConsumer.
33 enum class DiagnosticLevelMask : unsigned {
39 All = Note | Remark | Warning | Error
42 inline DiagnosticLevelMask operator~(DiagnosticLevelMask M) {
43 using UT = std::underlying_type<DiagnosticLevelMask>::type;
44 return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M));
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));
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));
61 raw_ostream& operator<<(raw_ostream& Out, DiagnosticLevelMask M);
63 /// Options for controlling the compiler diagnostics engine.
64 class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{
66 enum TextDiagnosticFormat { Clang, MSVC, Vi };
72 DefaultMacroBacktraceLimit = 6,
73 DefaultTemplateBacktraceLimit = 10,
74 DefaultConstexprBacktraceLimit = 10,
75 DefaultSpellCheckingLimit = 50,
76 DefaultSnippetLineLimit = 1,
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"
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"
92 /// The file to log diagnostic output to.
93 std::string DiagnosticLogFile;
95 /// The file to serialize diagnostics to (non-appending).
96 std::string DiagnosticSerializationFile;
98 /// The list of -W... options used to alter the diagnostic mappings, with the
100 std::vector<std::string> Warnings;
102 /// The list of -R... options used to alter the diagnostic mappings, with the
103 /// prefixes removed.
104 std::vector<std::string> Remarks;
106 /// The prefixes for comment directives sought by -verify ("expected" by
108 std::vector<std::string> VerifyPrefixes;
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"
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"
125 using TextDiagnosticFormat = DiagnosticOptions::TextDiagnosticFormat;
129 #endif // LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H