File indexing completed on 2026-05-10 08:36:49
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
0010 #define LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
0011
0012 #include "clang/Basic/LLVM.h"
0013 #include "llvm/ADT/IntrusiveRefCntPtr.h"
0014 #include <string>
0015 #include <type_traits>
0016 #include <vector>
0017
0018 namespace llvm {
0019 namespace opt {
0020 class ArgList;
0021 }
0022 }
0023
0024 namespace clang {
0025 class DiagnosticsEngine;
0026
0027
0028
0029 enum OverloadsShown : unsigned {
0030
0031 Ovl_All,
0032
0033
0034 Ovl_Best
0035 };
0036
0037
0038
0039 enum class DiagnosticLevelMask : unsigned {
0040 None = 0,
0041 Note = 1 << 0,
0042 Remark = 1 << 1,
0043 Warning = 1 << 2,
0044 Error = 1 << 3,
0045 All = Note | Remark | Warning | Error
0046 };
0047
0048 inline DiagnosticLevelMask operator~(DiagnosticLevelMask M) {
0049 using UT = std::underlying_type_t<DiagnosticLevelMask>;
0050 return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M));
0051 }
0052
0053 inline DiagnosticLevelMask operator|(DiagnosticLevelMask LHS,
0054 DiagnosticLevelMask RHS) {
0055 using UT = std::underlying_type_t<DiagnosticLevelMask>;
0056 return static_cast<DiagnosticLevelMask>(
0057 static_cast<UT>(LHS) | static_cast<UT>(RHS));
0058 }
0059
0060 inline DiagnosticLevelMask operator&(DiagnosticLevelMask LHS,
0061 DiagnosticLevelMask RHS) {
0062 using UT = std::underlying_type_t<DiagnosticLevelMask>;
0063 return static_cast<DiagnosticLevelMask>(
0064 static_cast<UT>(LHS) & static_cast<UT>(RHS));
0065 }
0066
0067 raw_ostream& operator<<(raw_ostream& Out, DiagnosticLevelMask M);
0068
0069
0070 class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{
0071 friend bool ParseDiagnosticArgs(DiagnosticOptions &, llvm::opt::ArgList &,
0072 clang::DiagnosticsEngine *, bool);
0073
0074 friend class CompilerInvocation;
0075 friend class CompilerInvocationBase;
0076
0077 public:
0078 enum TextDiagnosticFormat { Clang, MSVC, Vi, SARIF };
0079
0080
0081 enum {
0082 DefaultTabStop = 8,
0083 MaxTabStop = 100,
0084 DefaultMacroBacktraceLimit = 6,
0085 DefaultTemplateBacktraceLimit = 10,
0086 DefaultConstexprBacktraceLimit = 10,
0087 DefaultSpellCheckingLimit = 50,
0088 DefaultSnippetLineLimit = 16,
0089 DefaultShowLineNumbers = 1,
0090 };
0091
0092
0093 #define DIAGOPT(Name, Bits, Default) unsigned Name : Bits;
0094 #define ENUM_DIAGOPT(Name, Type, Bits, Default)
0095 #include "clang/Basic/DiagnosticOptions.def"
0096
0097 protected:
0098
0099
0100 #define DIAGOPT(Name, Bits, Default)
0101 #define ENUM_DIAGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
0102 #include "clang/Basic/DiagnosticOptions.def"
0103
0104 public:
0105
0106 std::string DiagnosticLogFile;
0107
0108
0109 std::string DiagnosticSerializationFile;
0110
0111
0112 std::string DiagnosticSuppressionMappingsFile;
0113
0114
0115
0116 std::vector<std::string> Warnings;
0117
0118
0119
0120 std::vector<std::string> UndefPrefixes;
0121
0122
0123
0124 std::vector<std::string> Remarks;
0125
0126
0127
0128 std::vector<std::string> VerifyPrefixes;
0129
0130
0131
0132 std::vector<std::string> SystemHeaderWarningsModules;
0133
0134 public:
0135
0136 #define DIAGOPT(Name, Bits, Default)
0137 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
0138 Type get##Name() const { return static_cast<Type>(Name); } \
0139 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
0140 #include "clang/Basic/DiagnosticOptions.def"
0141
0142 DiagnosticOptions() {
0143 #define DIAGOPT(Name, Bits, Default) Name = Default;
0144 #define ENUM_DIAGOPT(Name, Type, Bits, Default) set##Name(Default);
0145 #include "clang/Basic/DiagnosticOptions.def"
0146 }
0147 };
0148
0149 using TextDiagnosticFormat = DiagnosticOptions::TextDiagnosticFormat;
0150
0151 }
0152
0153 #endif