]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Basic/DiagnosticOptions.h
Update DTS files from Linux 4.12
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Basic / DiagnosticOptions.h
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 /// \brief Specifies which overload candidates to display when overload
22 /// resolution fails.
23 enum OverloadsShown : unsigned {
24   Ovl_All,  ///< Show all overloads.
25   Ovl_Best  ///< Show just the "best" overload candidates.
26 };
27
28 /// \brief A bitmask representing the diagnostic levels used by
29 /// VerifyDiagnosticConsumer.
30 enum class DiagnosticLevelMask : unsigned {
31   None    = 0,
32   Note    = 1 << 0,
33   Remark  = 1 << 1,
34   Warning = 1 << 2,
35   Error   = 1 << 3,
36   All     = Note | Remark | Warning | Error
37 };
38
39 inline DiagnosticLevelMask operator~(DiagnosticLevelMask M) {
40   using UT = std::underlying_type<DiagnosticLevelMask>::type;
41   return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M));
42 }
43
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));
49 }
50
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));
56 }
57
58 raw_ostream& operator<<(raw_ostream& Out, DiagnosticLevelMask M);
59
60 /// \brief Options for controlling the compiler diagnostics engine.
61 class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{
62 public:
63   enum TextDiagnosticFormat { Clang, MSVC, Vi };
64
65   // Default values.
66   enum { DefaultTabStop = 8, MaxTabStop = 100,
67     DefaultMacroBacktraceLimit = 6,
68     DefaultTemplateBacktraceLimit = 10,
69     DefaultConstexprBacktraceLimit = 10,
70     DefaultSpellCheckingLimit = 50 };
71
72   // Define simple diagnostic options (with no accessors).
73 #define DIAGOPT(Name, Bits, Default) unsigned Name : Bits;
74 #define ENUM_DIAGOPT(Name, Type, Bits, Default)
75 #include "clang/Basic/DiagnosticOptions.def"
76
77 protected:
78   // Define diagnostic options of enumeration type. These are private, and will
79   // have accessors (below).
80 #define DIAGOPT(Name, Bits, Default)
81 #define ENUM_DIAGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
82 #include "clang/Basic/DiagnosticOptions.def"
83
84 public:
85   /// \brief The file to log diagnostic output to.
86   std::string DiagnosticLogFile;
87   
88   /// \brief The file to serialize diagnostics to (non-appending).
89   std::string DiagnosticSerializationFile;
90
91   /// The list of -W... options used to alter the diagnostic mappings, with the
92   /// prefixes removed.
93   std::vector<std::string> Warnings;
94
95   /// The list of -R... options used to alter the diagnostic mappings, with the
96   /// prefixes removed.
97   std::vector<std::string> Remarks;
98
99 public:
100   // Define accessors/mutators for diagnostic options of enumeration type.
101 #define DIAGOPT(Name, Bits, Default)
102 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
103   Type get##Name() const { return static_cast<Type>(Name); } \
104   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
105 #include "clang/Basic/DiagnosticOptions.def"
106
107   DiagnosticOptions() {
108 #define DIAGOPT(Name, Bits, Default) Name = Default;
109 #define ENUM_DIAGOPT(Name, Type, Bits, Default) set##Name(Default);
110 #include "clang/Basic/DiagnosticOptions.def"
111   }
112 };
113
114 typedef DiagnosticOptions::TextDiagnosticFormat TextDiagnosticFormat;
115
116 }  // end namespace clang
117
118 #endif