Home | History | Annotate | Download | only in Frontend
      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_FRONTEND_DIAGNOSTICOPTIONS_H
     11 #define LLVM_CLANG_FRONTEND_DIAGNOSTICOPTIONS_H
     12 
     13 #include "clang/Basic/Diagnostic.h"
     14 
     15 #include <string>
     16 #include <vector>
     17 
     18 namespace clang {
     19 
     20 /// DiagnosticOptions - Options for controlling the compiler diagnostics
     21 /// engine.
     22 class DiagnosticOptions {
     23 public:
     24   unsigned IgnoreWarnings : 1;   /// -w
     25   unsigned NoRewriteMacros : 1;  /// -Wno-rewrite-macros
     26   unsigned Pedantic : 1;         /// -pedantic
     27   unsigned PedanticErrors : 1;   /// -pedantic-errors
     28   unsigned ShowColumn : 1;       /// Show column number on diagnostics.
     29   unsigned ShowLocation : 1;     /// Show source location information.
     30   unsigned ShowCarets : 1;       /// Show carets in diagnostics.
     31   unsigned ShowFixits : 1;       /// Show fixit information.
     32   unsigned ShowSourceRanges : 1; /// Show source ranges in numeric form.
     33   unsigned ShowParseableFixits : 1; /// Show machine parseable fix-its.
     34   unsigned ShowOptionNames : 1;  /// Show the option name for mappable
     35                                  /// diagnostics.
     36   unsigned ShowNoteIncludeStack : 1; /// Show include stacks for notes.
     37   unsigned ShowCategories : 2;   /// Show categories: 0 -> none, 1 -> Number,
     38                                  /// 2 -> Full Name.
     39 
     40   unsigned Format : 2;           /// Format for diagnostics:
     41   enum TextDiagnosticFormat { Clang, Msvc, Vi };
     42 
     43   unsigned ShowColors : 1;       /// Show diagnostics with ANSI color sequences.
     44   unsigned ShowOverloads : 1;    /// Overload candidates to show.  Values from
     45                                  /// DiagnosticsEngine::OverloadsShown
     46   unsigned VerifyDiagnostics: 1; /// Check that diagnostics match the expected
     47                                  /// diagnostics, indicated by markers in the
     48                                  /// input source file.
     49 
     50   unsigned ErrorLimit;           /// Limit # errors emitted.
     51   unsigned MacroBacktraceLimit;  /// Limit depth of macro expansion backtrace.
     52   unsigned TemplateBacktraceLimit; /// Limit depth of instantiation backtrace.
     53   unsigned ConstexprBacktraceLimit; /// Limit depth of constexpr backtrace.
     54 
     55   /// The distance between tab stops.
     56   unsigned TabStop;
     57   enum { DefaultTabStop = 8, MaxTabStop = 100,
     58          DefaultMacroBacktraceLimit = 6,
     59          DefaultTemplateBacktraceLimit = 10,
     60          DefaultConstexprBacktraceLimit = 10 };
     61 
     62   /// Column limit for formatting message diagnostics, or 0 if unused.
     63   unsigned MessageLength;
     64 
     65   /// If non-empty, a file to log extended build information to, for development
     66   /// testing and analysis.
     67   std::string DumpBuildInformation;
     68 
     69   /// The file to log diagnostic output to.
     70   std::string DiagnosticLogFile;
     71 
     72   /// The file to serialize diagnostics to (non-appending).
     73   std::string DiagnosticSerializationFile;
     74 
     75   /// The list of -W... options used to alter the diagnostic mappings, with the
     76   /// prefixes removed.
     77   std::vector<std::string> Warnings;
     78 
     79 public:
     80   DiagnosticOptions() {
     81     IgnoreWarnings = 0;
     82     TabStop = DefaultTabStop;
     83     MessageLength = 0;
     84     NoRewriteMacros = 0;
     85     Pedantic = 0;
     86     PedanticErrors = 0;
     87     ShowCarets = 1;
     88     ShowColors = 0;
     89     ShowOverloads = DiagnosticsEngine::Ovl_All;
     90     ShowColumn = 1;
     91     ShowFixits = 1;
     92     ShowLocation = 1;
     93     ShowOptionNames = 0;
     94     ShowCategories = 0;
     95     Format = Clang;
     96     ShowSourceRanges = 0;
     97     ShowParseableFixits = 0;
     98     VerifyDiagnostics = 0;
     99     ErrorLimit = 0;
    100     TemplateBacktraceLimit = DefaultTemplateBacktraceLimit;
    101     MacroBacktraceLimit = DefaultMacroBacktraceLimit;
    102     ConstexprBacktraceLimit = DefaultConstexprBacktraceLimit;
    103   }
    104 };
    105 
    106 }  // end namespace clang
    107 
    108 #endif
    109