aboutsummaryrefslogtreecommitdiff
path: root/include/clang
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-10-23 23:11:23 +0000
committerDouglas Gregor <dgregor@apple.com>2012-10-23 23:11:23 +0000
commitdc7b641574a733624489bd87fc7061771edf2113 (patch)
tree9610f52681156222f6b4f2501bbd104f229ca47c /include/clang
parent6a6bb2810cc8478730002c950f9261f6cb5f6143 (diff)
Use a .def file for most of the diagnostic options.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166520 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r--include/clang/ARCMigrate/ARCMT.h1
-rw-r--r--include/clang/Basic/Diagnostic.h8
-rw-r--r--include/clang/Basic/DiagnosticOptions.def61
-rw-r--r--include/clang/Basic/DiagnosticOptions.h75
-rw-r--r--include/clang/Frontend/CompilerInstance.h1
5 files changed, 95 insertions, 51 deletions
diff --git a/include/clang/ARCMigrate/ARCMT.h b/include/clang/ARCMigrate/ARCMT.h
index 0bb91aa7b1..cce8661652 100644
--- a/include/clang/ARCMigrate/ARCMT.h
+++ b/include/clang/ARCMigrate/ARCMT.h
@@ -12,6 +12,7 @@
#include "clang/ARCMigrate/FileRemapper.h"
#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Basic/SourceLocation.h"
namespace clang {
class ASTContext;
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h
index e32da9438e..9990222daa 100644
--- a/include/clang/Basic/Diagnostic.h
+++ b/include/clang/Basic/Diagnostic.h
@@ -16,6 +16,7 @@
#define LLVM_CLANG_DIAGNOSTIC_H
#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
@@ -161,13 +162,6 @@ public:
ak_qualtype_pair ///< pair<QualType, QualType>
};
- /// \brief Specifies which overload candidates to display when overload
- /// resolution fails.
- enum OverloadsShown {
- Ovl_All, ///< Show all overloads.
- Ovl_Best ///< Show just the "best" overload candidates.
- };
-
/// \brief Represents on argument value, which is a union discriminated
/// by ArgumentKind, with a value.
typedef std::pair<ArgumentKind, intptr_t> ArgumentValue;
diff --git a/include/clang/Basic/DiagnosticOptions.def b/include/clang/Basic/DiagnosticOptions.def
new file mode 100644
index 0000000000..600ed0357d
--- /dev/null
+++ b/include/clang/Basic/DiagnosticOptions.def
@@ -0,0 +1,61 @@
+//===--- DiagOptions.def - Diagnostic option database ------------- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the diagnostic options. Users of this file
+// must define the DIAGOPT macro to make use of this information.
+// Optionally, the user may also define ENUM_DIAGOPT (for options
+// that have enumeration type and VALUE_DIAGOPT (for options that
+// describe a value rather than a flag).
+//
+//===----------------------------------------------------------------------===//
+#ifndef DIAGOPT
+# error Define the DIAGOPT macro to handle language options
+#endif
+
+#ifndef VALUE_DIAGOPT
+# define VALUE_DIAGOPT(Name, Bits, Default) \
+DIAGOPT(Name, Bits, Default)
+#endif
+
+#ifndef ENUM_DIAGOPT
+# define ENUM_DIAGOPT(Name, Type, Bits, Default) \
+DIAGOPT(Name, Bits, Default)
+#endif
+
+DIAGOPT(IgnoreWarnings, 1, 0) /// -w
+DIAGOPT(NoRewriteMacros, 1, 0) /// -Wno-rewrite-macros
+DIAGOPT(Pedantic, 1, 0) /// -pedantic
+DIAGOPT(PedanticErrors, 1, 0) /// -pedantic-errors
+DIAGOPT(ShowColumn, 1, 1) /// Show column number on diagnostics.
+DIAGOPT(ShowLocation, 1, 1) /// Show source location information.
+DIAGOPT(ShowCarets, 1, 1) /// Show carets in diagnostics.
+DIAGOPT(ShowFixits, 1, 1) /// Show fixit information.
+DIAGOPT(ShowSourceRanges, 1, 0) /// Show source ranges in numeric form.
+DIAGOPT(ShowParseableFixits, 1, 0) /// Show machine parseable fix-its.
+DIAGOPT(ShowOptionNames, 1, 0) /// Show the option name for mappable
+ /// diagnostics.
+DIAGOPT(ShowNoteIncludeStack, 1, 0) /// Show include stacks for notes.
+VALUE_DIAGOPT(ShowCategories, 2, 0) /// Show categories: 0 -> none, 1 -> Number,
+ /// 2 -> Full Name.
+
+ENUM_DIAGOPT(Format, TextDiagnosticFormat, 2, Clang) /// Format for diagnostics:
+
+DIAGOPT(ShowColors, 1, 0) /// Show diagnostics with ANSI color sequences.
+ENUM_DIAGOPT(ShowOverloads, OverloadsShown, 1,
+ Ovl_All) /// Overload candidates to show.
+DIAGOPT(VerifyDiagnostics, 1, 0) /// Check that diagnostics match the expected
+ /// diagnostics, indicated by markers in the
+ /// input source file.
+
+DIAGOPT(ElideType, 1, 0) /// Elide identical types in template diffing
+DIAGOPT(ShowTemplateTree, 1, 0) /// Print a template tree when diffing
+
+#undef DIAGOPT
+#undef ENUM_DIAGOPT
+#undef VALUE_DIAGOPT
diff --git a/include/clang/Basic/DiagnosticOptions.h b/include/clang/Basic/DiagnosticOptions.h
index 77a8476c49..775d87b502 100644
--- a/include/clang/Basic/DiagnosticOptions.h
+++ b/include/clang/Basic/DiagnosticOptions.h
@@ -10,7 +10,6 @@
#ifndef LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
#define LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
-#include "clang/Basic/Diagnostic.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include <string>
@@ -18,39 +17,32 @@
namespace clang {
+/// \brief Specifies which overload candidates to display when overload
+/// resolution fails.
+enum OverloadsShown {
+ Ovl_All, ///< Show all overloads.
+ Ovl_Best ///< Show just the "best" overload candidates.
+};
+
/// 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
+ // Define simple diagnostic options (with no accessors).
+#define DIAGOPT(Name, Bits, Default) unsigned Name : Bits;
+#define ENUM_DIAGOPT(Name, Type, Bits, Default)
+#include "clang/Basic/DiagnosticOptions.def"
+protected:
+ // Define diagnostic options of enumeration type. These are private, and will
+ // have accessors (below).
+#define DIAGOPT(Name, Bits, Default)
+#define ENUM_DIAGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
+#include "clang/Basic/DiagnosticOptions.def"
+
+public:
unsigned ErrorLimit; /// Limit # errors emitted.
unsigned MacroBacktraceLimit; /// Limit depth of macro expansion backtrace.
unsigned TemplateBacktraceLimit; /// Limit depth of instantiation backtrace.
@@ -81,25 +73,20 @@ public:
std::vector<std::string> Warnings;
public:
+ // Define accessors/mutators for diagnostic options of enumeration type.
+#define DIAGOPT(Name, Bits, Default)
+#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
+ Type get##Name() const { return static_cast<Type>(Name); } \
+ void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
+#include "clang/Basic/DiagnosticOptions.def"
+
DiagnosticOptions() {
- IgnoreWarnings = 0;
- TabStop = DefaultTabStop;
+#define DIAGOPT(Name, Bits, Default) Name = Default;
+#define ENUM_DIAGOPT(Name, Type, Bits, Default) set##Name(Default);
+#include "clang/Basic/DiagnosticOptions.def"
+
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;
+ TabStop = DefaultTabStop;
ErrorLimit = 0;
TemplateBacktraceLimit = DefaultTemplateBacktraceLimit;
MacroBacktraceLimit = DefaultMacroBacktraceLimit;
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h
index 6736d1aadc..548ff86b8b 100644
--- a/include/clang/Frontend/CompilerInstance.h
+++ b/include/clang/Frontend/CompilerInstance.h
@@ -11,6 +11,7 @@
#define LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_
#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/ModuleLoader.h"
#include "llvm/ADT/ArrayRef.h"