1 //===- DiagnosticOptions.h --------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
10 #define LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
12 #include "clang/Basic/LLVM.h"
13 #include "llvm/ADT/IntrusiveRefCntPtr.h"
15 #include <type_traits>
20 /// Specifies which overload candidates to display when overload
22 enum OverloadsShown : unsigned {
23 /// Show all overloads.
26 /// Show just the "best" overload candidates.
30 /// A bitmask representing the diagnostic levels used by
31 /// VerifyDiagnosticConsumer.
32 enum class DiagnosticLevelMask : unsigned {
38 All = Note | Remark | Warning | Error
41 inline DiagnosticLevelMask operator~(DiagnosticLevelMask M) {
42 using UT = std::underlying_type<DiagnosticLevelMask>::type;
43 return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M));
46 inline DiagnosticLevelMask operator|(DiagnosticLevelMask LHS,
47 DiagnosticLevelMask RHS) {
48 using UT = std::underlying_type<DiagnosticLevelMask>::type;
49 return static_cast<DiagnosticLevelMask>(
50 static_cast<UT>(LHS) | static_cast<UT>(RHS));
53 inline DiagnosticLevelMask operator&(DiagnosticLevelMask LHS,
54 DiagnosticLevelMask RHS) {
55 using UT = std::underlying_type<DiagnosticLevelMask>::type;
56 return static_cast<DiagnosticLevelMask>(
57 static_cast<UT>(LHS) & static_cast<UT>(RHS));
60 raw_ostream& operator<<(raw_ostream& Out, DiagnosticLevelMask M);
62 /// Options for controlling the compiler diagnostics engine.
63 class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{
65 enum TextDiagnosticFormat { Clang, MSVC, Vi };
71 DefaultMacroBacktraceLimit = 6,
72 DefaultTemplateBacktraceLimit = 10,
73 DefaultConstexprBacktraceLimit = 10,
74 DefaultSpellCheckingLimit = 50,
75 DefaultSnippetLineLimit = 1,
78 // Define simple diagnostic options (with no accessors).
79 #define DIAGOPT(Name, Bits, Default) unsigned Name : Bits;
80 #define ENUM_DIAGOPT(Name, Type, Bits, Default)
81 #include "clang/Basic/DiagnosticOptions.def"
84 // Define diagnostic options of enumeration type. These are private, and will
85 // have accessors (below).
86 #define DIAGOPT(Name, Bits, Default)
87 #define ENUM_DIAGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
88 #include "clang/Basic/DiagnosticOptions.def"
91 /// The file to log diagnostic output to.
92 std::string DiagnosticLogFile;
94 /// The file to serialize diagnostics to (non-appending).
95 std::string DiagnosticSerializationFile;
97 /// The list of -W... options used to alter the diagnostic mappings, with the
99 std::vector<std::string> Warnings;
101 /// The list of -R... options used to alter the diagnostic mappings, with the
102 /// prefixes removed.
103 std::vector<std::string> Remarks;
105 /// The prefixes for comment directives sought by -verify ("expected" by
107 std::vector<std::string> VerifyPrefixes;
110 // Define accessors/mutators for diagnostic options of enumeration type.
111 #define DIAGOPT(Name, Bits, Default)
112 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
113 Type get##Name() const { return static_cast<Type>(Name); } \
114 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
115 #include "clang/Basic/DiagnosticOptions.def"
117 DiagnosticOptions() {
118 #define DIAGOPT(Name, Bits, Default) Name = Default;
119 #define ENUM_DIAGOPT(Name, Type, Bits, Default) set##Name(Default);
120 #include "clang/Basic/DiagnosticOptions.def"
124 using TextDiagnosticFormat = DiagnosticOptions::TextDiagnosticFormat;
128 #endif // LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H