From d4a3f0e8949647434d8c73e3b563a1cff0b73cfe Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Sun, 15 Jun 2014 23:30:39 +0000 Subject: 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. llvm-svn: 211005 --- clang/lib/Sema/SemaDeclCXX.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'clang/lib/Sema/SemaDeclCXX.cpp') diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index ed7908dfc92..3f5321664ca 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2119,9 +2119,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, FieldDecl *FD = cast(Member); FieldCollector->Add(FD); - if (Diags.getDiagnosticLevel(diag::warn_unused_private_field, - FD->getLocation()) - != DiagnosticsEngine::Ignored) { + if (!Diags.isIgnored(diag::warn_unused_private_field, FD->getLocation())) { // Remember all explicit private FieldDecls that have a name, no side // effects and are not part of a dependent type declaration. if (!FD->isImplicit() && FD->getDeclName() && @@ -2309,9 +2307,8 @@ namespace { static void DiagnoseUninitializedFields( Sema &SemaRef, const CXXConstructorDecl *Constructor) { - if (SemaRef.getDiagnostics().getDiagnosticLevel(diag::warn_field_is_uninit, - Constructor->getLocation()) - == DiagnosticsEngine::Ignored) { + if (SemaRef.getDiagnostics().isIgnored(diag::warn_field_is_uninit, + Constructor->getLocation())) { return; } @@ -3734,9 +3731,8 @@ static void DiagnoseBaseOrMemInitializerOrder( bool ShouldCheckOrder = false; for (unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) { CXXCtorInitializer *Init = Inits[InitIndex]; - if (SemaRef.Diags.getDiagnosticLevel(diag::warn_initializer_out_of_order, - Init->getSourceLocation()) - != DiagnosticsEngine::Ignored) { + if (!SemaRef.Diags.isIgnored(diag::warn_initializer_out_of_order, + Init->getSourceLocation())) { ShouldCheckOrder = true; break; } @@ -5971,8 +5967,7 @@ void Sema::DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD) { if (MD->isInvalidDecl()) return; - if (Diags.getDiagnosticLevel(diag::warn_overloaded_virtual, - MD->getLocation()) == DiagnosticsEngine::Ignored) + if (Diags.isIgnored(diag::warn_overloaded_virtual, MD->getLocation())) return; SmallVector OverloadedMethods; -- cgit v1.2.3