diff options
author | Eric Fiselier <eric@efcs.ca> | 2015-06-13 07:11:40 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2015-06-13 07:11:40 +0000 |
commit | 72cdbbce28d3c016d5b88acd3cf439b10d762674 (patch) | |
tree | 7e58dbb4e87bc1f0876f7e78d2d1e1dd0ddd02e9 /include/clang/Basic/DiagnosticOptions.h | |
parent | d9462c2afcdad32f7543d7b6504e39b022abb81f (diff) |
Add `-verify-ignore-unexpected` option to ignore unexpected diagnostics in VerifyDiagnosticsConsumer
Summary:
The goal of this patch is to make `-verify` easier to use when testing libc++. The `notes` attached to compile error diagnostics are numerous and relatively unstable when they reference libc++ header internals. This patch allows libc++ to write stable compilation failure tests by allowing unexpected diagnostic messages to be ignored where they are not relevant.
This patch adds a new CC1 flag called `-verify-ignore-unexpected`. `-verify-ignore-unexpected` tells `VerifyDiagnosticsConsumer` to ignore *all* unexpected diagnostic messages. `-verify-ignore-unexpected=<LevelList>` can be used to only ignore certain diagnostic levels. `<LevelList>` is a comma separated list of diagnostic levels to ignore. The supported levels are `note`, `remark`, `warning` and `error`.
Reviewers: bogner, grosser, EricWF
Reviewed By: EricWF
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D10138
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239665 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/DiagnosticOptions.h')
-rw-r--r-- | include/clang/Basic/DiagnosticOptions.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/clang/Basic/DiagnosticOptions.h b/include/clang/Basic/DiagnosticOptions.h index a16c7747ce..c9b0c5def9 100644 --- a/include/clang/Basic/DiagnosticOptions.h +++ b/include/clang/Basic/DiagnosticOptions.h @@ -13,6 +13,7 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include <string> +#include <type_traits> #include <vector> namespace clang { @@ -24,6 +25,38 @@ enum OverloadsShown : unsigned { Ovl_Best ///< Show just the "best" overload candidates. }; +/// \brief A bitmask representing the diagnostic levels used by +/// VerifyDiagnosticConsumer. +enum class DiagnosticLevelMask : unsigned { + None = 0, + Note = 1 << 0, + Remark = 1 << 1, + Warning = 1 << 2, + Error = 1 << 3, + All = Note | Remark | Warning | Error +}; + +inline DiagnosticLevelMask operator~(DiagnosticLevelMask M) { + using UT = std::underlying_type<DiagnosticLevelMask>::type; + return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M)); +} + +inline DiagnosticLevelMask operator|(DiagnosticLevelMask LHS, + DiagnosticLevelMask RHS) { + using UT = std::underlying_type<DiagnosticLevelMask>::type; + return static_cast<DiagnosticLevelMask>( + static_cast<UT>(LHS) | static_cast<UT>(RHS)); +} + +inline DiagnosticLevelMask operator&(DiagnosticLevelMask LHS, + DiagnosticLevelMask RHS) { + using UT = std::underlying_type<DiagnosticLevelMask>::type; + return static_cast<DiagnosticLevelMask>( + static_cast<UT>(LHS) & static_cast<UT>(RHS)); +} + +raw_ostream& operator<<(raw_ostream& Out, DiagnosticLevelMask M); + /// \brief Options for controlling the compiler diagnostics engine. class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{ public: |