summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-06-15 23:30:39 +0000
committerAlp Toker <alp@nuanti.com>2014-06-15 23:30:39 +0000
commit7225802bf998624a54e48d81e2d6241cfc8c2b2b (patch)
treeb918afa8ea25c87835b43f03cde4dda107d575d2 /include
parentaf3883a24440561c8d82cf26ca6f7bffe2eb4c4d (diff)
downloadclang-7225802bf998624a54e48d81e2d6241cfc8c2b2b.tar.gz
clang-7225802bf998624a54e48d81e2d6241cfc8c2b2b.tar.bz2
clang-7225802bf998624a54e48d81e2d6241cfc8c2b2b.tar.xz
Hide the concept of diagnostic levels from lex, parse and sema
The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211005 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/Basic/Diagnostic.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h
index f16c0d391f..b0f52165bb 100644
--- a/include/clang/Basic/Diagnostic.h
+++ b/include/clang/Basic/Diagnostic.h
@@ -642,10 +642,27 @@ public:
// DiagnosticsEngine classification and reporting interfaces.
//
+ /// \brief Determine whether the diagnostic is known to be ignored.
+ ///
+ /// This can be used to opportunistically avoid expensive checks when it's
+ /// known for certain that the diagnostic has been suppressed at the
+ /// specified location \p Loc.
+ ///
+ /// \param Loc The source location we are interested in finding out the
+ /// diagnostic state. Can be null in order to query the latest state.
+ bool isIgnored(unsigned DiagID, SourceLocation Loc) const {
+ return Diags->getDiagnosticLevel(DiagID, Loc, *this) ==
+ DiagnosticIDs::Ignored;
+ }
+
/// \brief Based on the way the client configured the DiagnosticsEngine
/// object, classify the specified diagnostic ID into a Level, consumable by
/// the DiagnosticConsumer.
///
+ /// To preserve invariant assumptions, this function should not be used to
+ /// influence parse or semantic analysis actions. Instead consider using
+ /// \c isIgnored().
+ ///
/// \param Loc The source location we are interested in finding out the
/// diagnostic state. Can be null in order to query the latest state.
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const {