diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-10-23 22:26:28 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-10-23 22:26:28 +0000 |
commit | 02c23ebf41ae2f70da0ba7337e05c51fbfe35f7f (patch) | |
tree | c44af66edb700be2df3d1ad41420df5c7174d5f1 /include/clang/Basic | |
parent | 340d0d30018dd3ed77fb17f33e785acd745bf97d (diff) |
Make DiagnosticOptions intrusively reference-counted, and make sure
the various stakeholders bump up the reference count. In particular,
the diagnostics engine now keeps the DiagnosticOptions object alive.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166508 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic')
-rw-r--r-- | include/clang/Basic/Diagnostic.h | 6 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticOptions.h | 112 |
2 files changed, 118 insertions, 0 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index ef9c3cb4e5..e32da9438e 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -29,6 +29,7 @@ namespace clang { class DiagnosticConsumer; class DiagnosticBuilder; + class DiagnosticOptions; class IdentifierInfo; class DeclContext; class LangOptions; @@ -190,6 +191,7 @@ private: // backtrace stack, 0 -> no limit. ExtensionHandling ExtBehavior; // Map extensions onto warnings or errors? IntrusiveRefCntPtr<DiagnosticIDs> Diags; + IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts; DiagnosticConsumer *Client; bool OwnsDiagClient; SourceManager *SourceMgr; @@ -341,6 +343,7 @@ private: public: explicit DiagnosticsEngine( const IntrusiveRefCntPtr<DiagnosticIDs> &Diags, + DiagnosticOptions *DiagOpts, DiagnosticConsumer *client = 0, bool ShouldOwnClient = true); ~DiagnosticsEngine(); @@ -349,6 +352,9 @@ public: return Diags; } + /// \brief Retrieve the diagnostic options. + DiagnosticOptions &getDiagnosticOptions() const { return *DiagOpts; } + DiagnosticConsumer *getClient() { return Client; } const DiagnosticConsumer *getClient() const { return Client; } diff --git a/include/clang/Basic/DiagnosticOptions.h b/include/clang/Basic/DiagnosticOptions.h new file mode 100644 index 0000000000..77a8476c49 --- /dev/null +++ b/include/clang/Basic/DiagnosticOptions.h @@ -0,0 +1,112 @@ +//===--- DiagnosticOptions.h ------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H +#define LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H + +#include "clang/Basic/Diagnostic.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" + +#include <string> +#include <vector> + +namespace clang { + +/// DiagnosticOptions - Options for controlling the compiler diagnostics +/// engine. +class DiagnosticOptions : public llvm::RefCountedBase<DiagnosticOptions>{ +public: + unsigned IgnoreWarnings : 1; /// -w + unsigned NoRewriteMacros : 1; /// -Wno-rewrite-macros + unsigned Pedantic : 1; /// -pedantic + unsigned PedanticErrors : 1; /// -pedantic-errors + unsigned ShowColumn : 1; /// Show column number on diagnostics. + unsigned ShowLocation : 1; /// Show source location information. + unsigned ShowCarets : 1; /// Show carets in diagnostics. + unsigned ShowFixits : 1; /// Show fixit information. + unsigned ShowSourceRanges : 1; /// Show source ranges in numeric form. + unsigned ShowParseableFixits : 1; /// Show machine parseable fix-its. + unsigned ShowOptionNames : 1; /// Show the option name for mappable + /// diagnostics. + unsigned ShowNoteIncludeStack : 1; /// Show include stacks for notes. + unsigned ShowCategories : 2; /// Show categories: 0 -> none, 1 -> Number, + /// 2 -> Full Name. + + unsigned Format : 2; /// Format for diagnostics: + enum TextDiagnosticFormat { Clang, Msvc, Vi }; + + unsigned ShowColors : 1; /// Show diagnostics with ANSI color sequences. + unsigned ShowOverloads : 1; /// Overload candidates to show. Values from + /// DiagnosticsEngine::OverloadsShown + unsigned VerifyDiagnostics: 1; /// Check that diagnostics match the expected + /// diagnostics, indicated by markers in the + /// input source file. + + unsigned ElideType: 1; /// Elide identical types in template diffing + unsigned ShowTemplateTree: 1; /// Print a template tree when diffing + + unsigned ErrorLimit; /// Limit # errors emitted. + unsigned MacroBacktraceLimit; /// Limit depth of macro expansion backtrace. + unsigned TemplateBacktraceLimit; /// Limit depth of instantiation backtrace. + unsigned ConstexprBacktraceLimit; /// Limit depth of constexpr backtrace. + + /// The distance between tab stops. + unsigned TabStop; + enum { DefaultTabStop = 8, MaxTabStop = 100, + DefaultMacroBacktraceLimit = 6, + DefaultTemplateBacktraceLimit = 10, + DefaultConstexprBacktraceLimit = 10 }; + + /// Column limit for formatting message diagnostics, or 0 if unused. + unsigned MessageLength; + + /// If non-empty, a file to log extended build information to, for development + /// testing and analysis. + std::string DumpBuildInformation; + + /// The file to log diagnostic output to. + std::string DiagnosticLogFile; + + /// The file to serialize diagnostics to (non-appending). + std::string DiagnosticSerializationFile; + + /// The list of -W... options used to alter the diagnostic mappings, with the + /// prefixes removed. + std::vector<std::string> Warnings; + +public: + DiagnosticOptions() { + IgnoreWarnings = 0; + TabStop = DefaultTabStop; + MessageLength = 0; + NoRewriteMacros = 0; + Pedantic = 0; + PedanticErrors = 0; + ShowCarets = 1; + ShowColors = 0; + ShowOverloads = DiagnosticsEngine::Ovl_All; + ShowColumn = 1; + ShowFixits = 1; + ShowLocation = 1; + ShowOptionNames = 0; + ShowCategories = 0; + Format = Clang; + ShowSourceRanges = 0; + ShowParseableFixits = 0; + VerifyDiagnostics = 0; + ErrorLimit = 0; + TemplateBacktraceLimit = DefaultTemplateBacktraceLimit; + MacroBacktraceLimit = DefaultMacroBacktraceLimit; + ConstexprBacktraceLimit = DefaultConstexprBacktraceLimit; + } +}; + +} // end namespace clang + +#endif |