Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:49

0001 //===- DiagnosticOptions.h --------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
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 } // namespace opt
0022 } // namespace llvm
0023 
0024 namespace clang {
0025 class DiagnosticsEngine;
0026 
0027 /// Specifies which overload candidates to display when overload
0028 /// resolution fails.
0029 enum OverloadsShown : unsigned {
0030   /// Show all overloads.
0031   Ovl_All,
0032 
0033   /// Show just the "best" overload candidates.
0034   Ovl_Best
0035 };
0036 
0037 /// A bitmask representing the diagnostic levels used by
0038 /// VerifyDiagnosticConsumer.
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 /// Options for controlling the compiler diagnostics engine.
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   // Default values.
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   // Define simple diagnostic options (with no accessors).
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   // Define diagnostic options of enumeration type. These are private, and will
0099   // have accessors (below).
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   /// The file to log diagnostic output to.
0106   std::string DiagnosticLogFile;
0107 
0108   /// The file to serialize diagnostics to (non-appending).
0109   std::string DiagnosticSerializationFile;
0110 
0111   /// Path for the file that defines diagnostic suppression mappings.
0112   std::string DiagnosticSuppressionMappingsFile;
0113 
0114   /// The list of -W... options used to alter the diagnostic mappings, with the
0115   /// prefixes removed.
0116   std::vector<std::string> Warnings;
0117 
0118   /// The list of prefixes from -Wundef-prefix=... used to generate warnings
0119   /// for undefined macros.
0120   std::vector<std::string> UndefPrefixes;
0121 
0122   /// The list of -R... options used to alter the diagnostic mappings, with the
0123   /// prefixes removed.
0124   std::vector<std::string> Remarks;
0125 
0126   /// The prefixes for comment directives sought by -verify ("expected" by
0127   /// default).
0128   std::vector<std::string> VerifyPrefixes;
0129 
0130   /// The list of -Wsystem-headers-in-module=... options used to override
0131   /// whether -Wsystem-headers is enabled on a per-module basis.
0132   std::vector<std::string> SystemHeaderWarningsModules;
0133 
0134 public:
0135   // Define accessors/mutators for diagnostic options of enumeration type.
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 } // namespace clang
0152 
0153 #endif // LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H