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 /// \brief Specifies which overload candidates to display when overload
23 enum OverloadsShown : unsigned {
24 Ovl_All, ///< Show all overloads.
25 Ovl_Best ///< Show just the "best" overload candidates.
28 /// \brief A bitmask representing the diagnostic levels used by
29 /// VerifyDiagnosticConsumer.
30 enum class DiagnosticLevelMask : unsigned {
36 All = Note | Remark | Warning | Error
39 inline DiagnosticLevelMask operator~(DiagnosticLevelMask M) {
40 using UT = std::underlying_type<DiagnosticLevelMask>::type;
41 return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M));
44 inline DiagnosticLevelMask operator|(DiagnosticLevelMask LHS,
45 DiagnosticLevelMask RHS) {
46 using UT = std::underlying_type<DiagnosticLevelMask>::type;
47 return static_cast<DiagnosticLevelMask>(
48 static_cast<UT>(LHS) | static_cast<UT>(RHS));
51 inline DiagnosticLevelMask operator&(DiagnosticLevelMask LHS,
52 DiagnosticLevelMask RHS) {
53 using UT = std::underlying_type<DiagnosticLevelMask>::type;
54 return static_cast<DiagnosticLevelMask>(
55 static_cast<UT>(LHS) & static_cast<UT>(RHS));
58 raw_ostream& operator<<(raw_ostream& Out, DiagnosticLevelMask M);
60 /// \brief Options for controlling the compiler diagnostics engine.
61 class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{
63 enum TextDiagnosticFormat { Clang, MSVC, Vi };
69 DefaultMacroBacktraceLimit = 6,
70 DefaultTemplateBacktraceLimit = 10,
71 DefaultConstexprBacktraceLimit = 10,
72 DefaultSpellCheckingLimit = 50,
73 DefaultSnippetLineLimit = 1,
76 // Define simple diagnostic options (with no accessors).
77 #define DIAGOPT(Name, Bits, Default) unsigned Name : Bits;
78 #define ENUM_DIAGOPT(Name, Type, Bits, Default)
79 #include "clang/Basic/DiagnosticOptions.def"
82 // Define diagnostic options of enumeration type. These are private, and will
83 // have accessors (below).
84 #define DIAGOPT(Name, Bits, Default)
85 #define ENUM_DIAGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
86 #include "clang/Basic/DiagnosticOptions.def"
89 /// \brief The file to log diagnostic output to.
90 std::string DiagnosticLogFile;
92 /// \brief The file to serialize diagnostics to (non-appending).
93 std::string DiagnosticSerializationFile;
95 /// The list of -W... options used to alter the diagnostic mappings, with the
97 std::vector<std::string> Warnings;
99 /// The list of -R... options used to alter the diagnostic mappings, with the
100 /// prefixes removed.
101 std::vector<std::string> Remarks;
103 /// The prefixes for comment directives sought by -verify ("expected" by
105 std::vector<std::string> VerifyPrefixes;
108 // Define accessors/mutators for diagnostic options of enumeration type.
109 #define DIAGOPT(Name, Bits, Default)
110 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
111 Type get##Name() const { return static_cast<Type>(Name); } \
112 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
113 #include "clang/Basic/DiagnosticOptions.def"
115 DiagnosticOptions() {
116 #define DIAGOPT(Name, Bits, Default) Name = Default;
117 #define ENUM_DIAGOPT(Name, Type, Bits, Default) set##Name(Default);
118 #include "clang/Basic/DiagnosticOptions.def"
122 typedef DiagnosticOptions::TextDiagnosticFormat TextDiagnosticFormat;
124 } // end namespace clang