diff options
author | Alp Toker <alp@nuanti.com> | 2014-06-15 23:30:39 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-06-15 23:30:39 +0000 |
commit | d4a3f0e8949647434d8c73e3b563a1cff0b73cfe (patch) | |
tree | 4512b77da6fc9930ad8d71f35259220d1790e214 /clang/lib/Sema/SemaDecl.cpp | |
parent | baabe5091c63748d99bf59a1807c2879881b4af2 (diff) | |
download | bcm5719-llvm-d4a3f0e8949647434d8c73e3b563a1cff0b73cfe.tar.gz bcm5719-llvm-d4a3f0e8949647434d8c73e3b563a1cff0b73cfe.zip |
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
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 68fecdb74ac..733fdddd165 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1571,8 +1571,7 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, << Context.BuiltinInfo.GetName(BID) << R; if (Context.BuiltinInfo.getHeaderName(BID) && - Diags.getDiagnosticLevel(diag::ext_implicit_lib_function_decl, Loc) - != DiagnosticsEngine::Ignored) + !Diags.isIgnored(diag::ext_implicit_lib_function_decl, Loc)) Diag(Loc, diag::note_please_include_header) << Context.BuiltinInfo.getHeaderName(BID) << Context.BuiltinInfo.GetName(BID); @@ -5643,8 +5642,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, /// void Sema::CheckShadow(Scope *S, VarDecl *D, const LookupResult& R) { // Return if warning is ignored. - if (Diags.getDiagnosticLevel(diag::warn_decl_shadow, R.getNameLoc()) == - DiagnosticsEngine::Ignored) + if (Diags.isIgnored(diag::warn_decl_shadow, R.getNameLoc())) return; // Don't diagnose declarations at file scope. @@ -5717,8 +5715,7 @@ void Sema::CheckShadow(Scope *S, VarDecl *D, const LookupResult& R) { /// \brief Check -Wshadow without the advantage of a previous lookup. void Sema::CheckShadow(Scope *S, VarDecl *D) { - if (Diags.getDiagnosticLevel(diag::warn_decl_shadow, D->getLocation()) == - DiagnosticsEngine::Ignored) + if (Diags.isIgnored(diag::warn_decl_shadow, D->getLocation())) return; LookupResult R(*this, D->getDeclName(), D->getLocation(), @@ -8448,13 +8445,10 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, // we do not warn to warn spuriously when 'x' and 'y' are on separate // paths through the function. This should be revisited if // -Wrepeated-use-of-weak is made flow-sensitive. - if (VDecl->getType().getObjCLifetime() == Qualifiers::OCL_Strong) { - DiagnosticsEngine::Level Level = - Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak, - Init->getLocStart()); - if (Level != DiagnosticsEngine::Ignored) + if (VDecl->getType().getObjCLifetime() == Qualifiers::OCL_Strong && + !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, + Init->getLocStart())) getCurFunction()->markSafeWeakUse(Init); - } } // The initialization is usually a full-expression. @@ -8955,9 +8949,8 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) { if (var->isThisDeclarationADefinition() && var->getDeclContext()->getRedeclContext()->isFileContext() && var->isExternallyVisible() && var->hasLinkage() && - getDiagnostics().getDiagnosticLevel( - diag::warn_missing_variable_declarations, - var->getLocation())) { + !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations, + var->getLocation())) { // Find a previous declaration that's not a definition. VarDecl *prev = var->getPreviousDecl(); while (prev && prev->isThisDeclarationADefinition()) @@ -9050,9 +9043,8 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) { if (!var->getDeclContext()->isDependentContext() && Init && !Init->isValueDependent()) { if (IsGlobal && !var->isConstexpr() && - getDiagnostics().getDiagnosticLevel(diag::warn_global_constructor, - var->getLocation()) - != DiagnosticsEngine::Ignored) { + !getDiagnostics().isIgnored(diag::warn_global_constructor, + var->getLocation())) { // Warn about globals which don't have a constant initializer. Don't // warn about globals with a non-trivial destructor because we already // warned about them. @@ -9277,9 +9269,7 @@ void Sema::ActOnDocumentableDecls(ArrayRef<Decl *> Group) { if (Group.empty() || !Group[0]) return; - if (Diags.getDiagnosticLevel(diag::warn_doc_param_not_found, - Group[0]->getLocation()) - == DiagnosticsEngine::Ignored) + if (Diags.isIgnored(diag::warn_doc_param_not_found, Group[0]->getLocation())) return; if (Group.size() >= 2) { @@ -12858,9 +12848,7 @@ struct DenseMapInfoDupKey { static void CheckForDuplicateEnumValues(Sema &S, ArrayRef<Decl *> Elements, EnumDecl *Enum, QualType EnumType) { - if (S.Diags.getDiagnosticLevel(diag::warn_duplicate_enum_values, - Enum->getLocation()) == - DiagnosticsEngine::Ignored) + if (S.Diags.isIgnored(diag::warn_duplicate_enum_values, Enum->getLocation())) return; // Avoid anonymous enums if (!Enum->getIdentifier()) |