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 { 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). 93 std::string DiagnosticSerializationFile; 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 public: 104 // Define accessors/mutators for diagnostic options of enumeration type. 105 #define DIAGOPT(Name, Bits, Default) 106 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ 107 Type get##Name() const { return static_cast<Type>(Name); } \ 108 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } 109 #include "clang/Basic/DiagnosticOptions.def" 110 111 DiagnosticOptions() { 112 #define DIAGOPT(Name, Bits, Default) Name = Default; 113 #define ENUM_DIAGOPT(Name, Type, Bits, Default) set##Name(Default); 114 #include "clang/Basic/DiagnosticOptions.def" 115 } 116 }; 117 118 typedef DiagnosticOptions::TextDiagnosticFormat TextDiagnosticFormat; 119 120 } // end namespace clang 121 122 #endif 123