clang  7.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 /// Specifies which overload candidates to display when overload
22 /// resolution fails.
23 enum OverloadsShown : unsigned {
24  /// Show all overloads.
26 
27  /// Show just the "best" overload candidates.
29 };
30 
31 /// A bitmask representing the diagnostic levels used by
32 /// VerifyDiagnosticConsumer.
33 enum class DiagnosticLevelMask : unsigned {
34  None = 0,
35  Note = 1 << 0,
36  Remark = 1 << 1,
37  Warning = 1 << 2,
38  Error = 1 << 3,
39  All = Note | Remark | Warning | Error
40 };
41 
44  return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M));
45 }
46 
48  DiagnosticLevelMask RHS) {
50  return static_cast<DiagnosticLevelMask>(
51  static_cast<UT>(LHS) | static_cast<UT>(RHS));
52 }
53 
55  DiagnosticLevelMask RHS) {
57  return static_cast<DiagnosticLevelMask>(
58  static_cast<UT>(LHS) & static_cast<UT>(RHS));
59 }
60 
61 raw_ostream& operator<<(raw_ostream& Out, DiagnosticLevelMask M);
62 
63 /// Options for controlling the compiler diagnostics engine.
64 class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{
65 public:
66  enum TextDiagnosticFormat { Clang, MSVC, Vi };
67 
68  // Default values.
69  enum {
70  DefaultTabStop = 8,
71  MaxTabStop = 100,
72  DefaultMacroBacktraceLimit = 6,
73  DefaultTemplateBacktraceLimit = 10,
74  DefaultConstexprBacktraceLimit = 10,
75  DefaultSpellCheckingLimit = 50,
76  DefaultSnippetLineLimit = 1,
77  };
78 
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"
83 
84 protected:
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"
90 
91 public:
92  /// The file to log diagnostic output to.
93  std::string DiagnosticLogFile;
94 
95  /// The file to serialize diagnostics to (non-appending).
97 
98  /// The list of -W... options used to alter the diagnostic mappings, with the
99  /// prefixes removed.
100  std::vector<std::string> Warnings;
101 
102  /// The list of -R... options used to alter the diagnostic mappings, with the
103  /// prefixes removed.
104  std::vector<std::string> Remarks;
105 
106  /// The prefixes for comment directives sought by -verify ("expected" by
107  /// default).
108  std::vector<std::string> VerifyPrefixes;
109 
110 public:
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"
117 
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"
122  }
123 };
124 
126 
127 } // namespace clang
128 
129 #endif // LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
Definition: Attr.h:322
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).
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.