clang  6.0.0svn
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 /// \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 
41  return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M));
42 }
43 
45  DiagnosticLevelMask RHS) {
47  return static_cast<DiagnosticLevelMask>(
48  static_cast<UT>(LHS) | static_cast<UT>(RHS));
49 }
50 
52  DiagnosticLevelMask RHS) {
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 {
67  DefaultTabStop = 8,
68  MaxTabStop = 100,
69  DefaultMacroBacktraceLimit = 6,
70  DefaultTemplateBacktraceLimit = 10,
71  DefaultConstexprBacktraceLimit = 10,
72  DefaultSpellCheckingLimit = 50,
73  DefaultSnippetLineLimit = 1,
74  };
75 
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"
80 
81 protected:
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"
87 
88 public:
89  /// \brief The file to log diagnostic output to.
90  std::string DiagnosticLogFile;
91 
92  /// \brief The file to serialize diagnostics to (non-appending).
94 
95  /// The list of -W... options used to alter the diagnostic mappings, with the
96  /// prefixes removed.
97  std::vector<std::string> Warnings;
98 
99  /// The list of -R... options used to alter the diagnostic mappings, with the
100  /// prefixes removed.
101  std::vector<std::string> Remarks;
102 
103  /// The prefixes for comment directives sought by -verify ("expected" by
104  /// default).
105  std::vector<std::string> VerifyPrefixes;
106 
107 public:
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"
114 
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"
119  }
120 };
121 
123 
124 } // end namespace clang
125 
126 #endif
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
Definition: Attr.h:195
Show all overloads.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
std::vector< std::string > Warnings
The list of -W...
DiagnosticLevelMask operator|(DiagnosticLevelMask LHS, DiagnosticLevelMask RHS)
DiagnosticLevelMask operator &(DiagnosticLevelMask LHS, DiagnosticLevelMask RHS)
Show just the "best" overload candidates.
Options for controlling the compiler diagnostics engine.
std::string DiagnosticSerializationFile
The file to serialize diagnostics to (non-appending).
DiagnosticOptions::TextDiagnosticFormat TextDiagnosticFormat
std::vector< std::string > Remarks
The list of -R...
Dataflow Directional Tag Classes.
std::vector< std::string > VerifyPrefixes
The prefixes for comment directives sought by -verify ("expected" by default).
DiagnosticLevelMask operator~(DiagnosticLevelMask M)
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
DiagnosticLevelMask
A bitmask representing the diagnostic levels used by VerifyDiagnosticConsumer.
std::string DiagnosticLogFile
The file to log diagnostic output to.