summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/Diagnostic.h17
-rw-r--r--lib/Lex/HeaderSearch.cpp4
-rw-r--r--lib/Lex/Lexer.cpp9
-rw-r--r--lib/Lex/PPDirectives.cpp3
-rw-r--r--lib/Lex/PPLexerChange.cpp10
-rw-r--r--lib/Parse/ParsePragma.cpp5
-rw-r--r--lib/Sema/AnalysisBasedWarnings.cpp52
-rw-r--r--lib/Sema/Sema.cpp8
-rw-r--r--lib/Sema/SemaCast.cpp9
-rw-r--r--lib/Sema/SemaChecking.cpp18
-rw-r--r--lib/Sema/SemaDecl.cpp36
-rw-r--r--lib/Sema/SemaDeclCXX.cpp17
-rw-r--r--lib/Sema/SemaDeclObjC.cpp14
-rw-r--r--lib/Sema/SemaExpr.cpp18
-rw-r--r--lib/Sema/SemaExprMember.cpp4
-rw-r--r--lib/Sema/SemaExprObjC.cpp18
-rw-r--r--lib/Sema/SemaInit.cpp3
-rw-r--r--lib/Sema/SemaPseudoObject.cpp9
-rw-r--r--lib/Sema/SemaStmt.cpp14
-rw-r--r--lib/Sema/SemaTemplate.cpp17
20 files changed, 114 insertions, 171 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 {
diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp
index a283f69d88..c12d7314ee 100644
--- a/lib/Lex/HeaderSearch.cpp
+++ b/lib/Lex/HeaderSearch.cpp
@@ -666,9 +666,7 @@ const FileEntry *HeaderSearch::LookupFile(
// Otherwise, we found the path via MSVC header search rules. If
// -Wmsvc-include is enabled, we have to keep searching to see if we
// would've found this header in -I or -isystem directories.
- if (Diags.getDiagnosticLevel(diag::ext_pp_include_search_ms,
- IncludeLoc) ==
- DiagnosticsEngine::Ignored) {
+ if (Diags.isIgnored(diag::ext_pp_include_search_ms, IncludeLoc)) {
return FE;
} else {
MSFE = FE;
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index 21b51e13cb..6f6b50b246 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -1399,8 +1399,7 @@ static inline CharSourceRange makeCharRange(Lexer &L, const char *Begin,
static void maybeDiagnoseIDCharCompat(DiagnosticsEngine &Diags, uint32_t C,
CharSourceRange Range, bool IsFirst) {
// Check C99 compatibility.
- if (Diags.getDiagnosticLevel(diag::warn_c99_compat_unicode_id,
- Range.getBegin()) > DiagnosticsEngine::Ignored) {
+ if (!Diags.isIgnored(diag::warn_c99_compat_unicode_id, Range.getBegin())) {
enum {
CannotAppearInIdentifier = 0,
CannotStartIdentifier
@@ -1422,8 +1421,7 @@ static void maybeDiagnoseIDCharCompat(DiagnosticsEngine &Diags, uint32_t C,
}
// Check C++98 compatibility.
- if (Diags.getDiagnosticLevel(diag::warn_cxx98_compat_unicode_id,
- Range.getBegin()) > DiagnosticsEngine::Ignored) {
+ if (!Diags.isIgnored(diag::warn_cxx98_compat_unicode_id, Range.getBegin())) {
static const llvm::sys::UnicodeCharSet CXX03AllowedIDChars(
CXX03AllowedIDCharRanges);
if (!CXX03AllowedIDChars.contains(C)) {
@@ -2522,8 +2520,7 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) {
// C++11 [lex.phases] 2.2 p2
// Prefer the C++98 pedantic compatibility warning over the generic,
// non-extension, user-requested "missing newline at EOF" warning.
- if (Diags.getDiagnosticLevel(diag::warn_cxx98_compat_no_newline_eof,
- EndLoc) != DiagnosticsEngine::Ignored) {
+ if (!Diags.isIgnored(diag::warn_cxx98_compat_no_newline_eof, EndLoc)) {
DiagID = diag::warn_cxx98_compat_no_newline_eof;
} else {
DiagID = diag::warn_no_newline_eof;
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index a8dde086ba..a0ec2bf78c 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -2123,8 +2123,7 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok,
// If we need warning for not using the macro, add its location in the
// warn-because-unused-macro set. If it gets used it will be removed from set.
if (getSourceManager().isInMainFile(MI->getDefinitionLoc()) &&
- Diags->getDiagnosticLevel(diag::pp_macro_not_used,
- MI->getDefinitionLoc()) != DiagnosticsEngine::Ignored) {
+ !Diags->isIgnored(diag::pp_macro_not_used, MI->getDefinitionLoc())) {
MI->setIsWarnIfUnused(true);
WarnUnusedMacroLocs.insert(MI->getDefinitionLoc());
}
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp
index 40d15d4bfa..81bb077632 100644
--- a/lib/Lex/PPLexerChange.cpp
+++ b/lib/Lex/PPLexerChange.cpp
@@ -449,9 +449,8 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
SourceLocation StartLoc
= SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
- if (getDiagnostics().getDiagnosticLevel(
- diag::warn_uncovered_module_header,
- StartLoc) != DiagnosticsEngine::Ignored) {
+ if (!getDiagnostics().isIgnored(diag::warn_uncovered_module_header,
+ StartLoc)) {
ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap();
typedef llvm::sys::fs::recursive_directory_iterator
recursive_directory_iterator;
@@ -486,9 +485,8 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
// mentioned at all in the module map. Such headers
SourceLocation StartLoc
= SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
- if (getDiagnostics().getDiagnosticLevel(diag::warn_forgotten_module_header,
- StartLoc)
- != DiagnosticsEngine::Ignored) {
+ if (!getDiagnostics().isIgnored(diag::warn_forgotten_module_header,
+ StartLoc)) {
ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap();
for (unsigned I = 0, N = SourceMgr.local_sloc_entry_size(); I != N; ++I) {
// We only care about file entries.
diff --git a/lib/Parse/ParsePragma.cpp b/lib/Parse/ParsePragma.cpp
index 1bdf5b001d..c7a344f59d 100644
--- a/lib/Parse/ParsePragma.cpp
+++ b/lib/Parse/ParsePragma.cpp
@@ -1211,9 +1211,8 @@ void
PragmaNoOpenMPHandler::HandlePragma(Preprocessor &PP,
PragmaIntroducerKind Introducer,
Token &FirstTok) {
- if (PP.getDiagnostics().getDiagnosticLevel(diag::warn_pragma_omp_ignored,
- FirstTok.getLocation()) !=
- DiagnosticsEngine::Ignored) {
+ if (!PP.getDiagnostics().isIgnored(diag::warn_pragma_omp_ignored,
+ FirstTok.getLocation())) {
PP.Diag(FirstTok, diag::warn_pragma_omp_ignored);
PP.getDiagnostics().setSeverity(diag::warn_pragma_omp_ignored,
diag::Severity::Ignored, SourceLocation());
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index 7f2748ede1..0e522dc415 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -477,14 +477,13 @@ struct CheckFallThroughDiagnostics {
bool HasNoReturn) const {
if (funMode == Function) {
return (ReturnsVoid ||
- D.getDiagnosticLevel(diag::warn_maybe_falloff_nonvoid_function,
- FuncLoc) == DiagnosticsEngine::Ignored)
- && (!HasNoReturn ||
- D.getDiagnosticLevel(diag::warn_noreturn_function_has_return_expr,
- FuncLoc) == DiagnosticsEngine::Ignored)
- && (!ReturnsVoid ||
- D.getDiagnosticLevel(diag::warn_suggest_noreturn_block, FuncLoc)
- == DiagnosticsEngine::Ignored);
+ D.isIgnored(diag::warn_maybe_falloff_nonvoid_function,
+ FuncLoc)) &&
+ (!HasNoReturn ||
+ D.isIgnored(diag::warn_noreturn_function_has_return_expr,
+ FuncLoc)) &&
+ (!ReturnsVoid ||
+ D.isIgnored(diag::warn_suggest_noreturn_block, FuncLoc));
}
// For blocks / lambdas.
@@ -1713,8 +1712,7 @@ clang::sema::AnalysisBasedWarnings::Policy::Policy() {
}
static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag) {
- return (unsigned) D.getDiagnosticLevel(diag, SourceLocation()) !=
- DiagnosticsEngine::Ignored;
+ return (unsigned)!D.isIgnored(diag, SourceLocation());
}
clang::sema::AnalysisBasedWarnings::AnalysisBasedWarnings(Sema &s)
@@ -1819,8 +1817,8 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
// Install the logical handler for -Wtautological-overlap-compare
std::unique_ptr<LogicalErrorHandler> LEH;
- if (Diags.getDiagnosticLevel(diag::warn_tautological_overlap_comparison,
- D->getLocStart())) {
+ if (!Diags.isIgnored(diag::warn_tautological_overlap_comparison,
+ D->getLocStart())) {
LEH.reset(new LogicalErrorHandler(S));
AC.getCFGBuildOptions().Observer = LEH.get();
}
@@ -1895,8 +1893,7 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
SourceLocation FL = AC.getDecl()->getLocation();
SourceLocation FEL = AC.getDecl()->getLocEnd();
thread_safety::ThreadSafetyReporter Reporter(S, FL, FEL);
- if (Diags.getDiagnosticLevel(diag::warn_thread_safety_beta,D->getLocStart())
- != DiagnosticsEngine::Ignored)
+ if (!Diags.isIgnored(diag::warn_thread_safety_beta, D->getLocStart()))
Reporter.setIssueBetaWarnings(true);
thread_safety::runThreadSafetyAnalysis(AC, Reporter);
@@ -1910,12 +1907,9 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
Analyzer.run(AC);
}
- if (Diags.getDiagnosticLevel(diag::warn_uninit_var, D->getLocStart())
- != DiagnosticsEngine::Ignored ||
- Diags.getDiagnosticLevel(diag::warn_sometimes_uninit_var,D->getLocStart())
- != DiagnosticsEngine::Ignored ||
- Diags.getDiagnosticLevel(diag::warn_maybe_uninit_var, D->getLocStart())
- != DiagnosticsEngine::Ignored) {
+ if (!Diags.isIgnored(diag::warn_uninit_var, D->getLocStart()) ||
+ !Diags.isIgnored(diag::warn_sometimes_uninit_var, D->getLocStart()) ||
+ !Diags.isIgnored(diag::warn_maybe_uninit_var, D->getLocStart())) {
if (CFG *cfg = AC.getCFG()) {
UninitValsDiagReporter reporter(S);
UninitVariablesAnalysisStats stats;
@@ -1938,25 +1932,21 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
}
bool FallThroughDiagFull =
- Diags.getDiagnosticLevel(diag::warn_unannotated_fallthrough,
- D->getLocStart()) != DiagnosticsEngine::Ignored;
- bool FallThroughDiagPerFunction =
- Diags.getDiagnosticLevel(diag::warn_unannotated_fallthrough_per_function,
- D->getLocStart()) != DiagnosticsEngine::Ignored;
+ !Diags.isIgnored(diag::warn_unannotated_fallthrough, D->getLocStart());
+ bool FallThroughDiagPerFunction = !Diags.isIgnored(
+ diag::warn_unannotated_fallthrough_per_function, D->getLocStart());
if (FallThroughDiagFull || FallThroughDiagPerFunction) {
DiagnoseSwitchLabelsFallthrough(S, AC, !FallThroughDiagFull);
}
if (S.getLangOpts().ObjCARCWeak &&
- Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak,
- D->getLocStart()) != DiagnosticsEngine::Ignored)
+ !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, D->getLocStart()))
diagnoseRepeatedUseOfWeak(S, fscope, D, AC.getParentMap());
// Check for infinite self-recursion in functions
- if (Diags.getDiagnosticLevel(diag::warn_infinite_recursive_function,
- D->getLocStart())
- != DiagnosticsEngine::Ignored) {
+ if (!Diags.isIgnored(diag::warn_infinite_recursive_function,
+ D->getLocStart())) {
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
checkRecursiveFunction(S, FD, Body, AC);
}
@@ -1964,7 +1954,7 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
// If none of the previous checks caused a CFG build, trigger one here
// for -Wtautological-overlap-compare
- if (Diags.getDiagnosticLevel(diag::warn_tautological_overlap_comparison,
+ if (!Diags.isIgnored(diag::warn_tautological_overlap_comparison,
D->getLocStart())) {
AC.getCFG();
}
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index ce0911e2ff..4d92fb0a83 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -681,9 +681,7 @@ void Sema::ActOnEndOfTranslationUnit() {
}
if (LangOpts.CPlusPlus11 &&
- Diags.getDiagnosticLevel(diag::warn_delegating_ctor_cycle,
- SourceLocation())
- != DiagnosticsEngine::Ignored)
+ !Diags.isIgnored(diag::warn_delegating_ctor_cycle, SourceLocation()))
CheckDelegatingCtorCycles();
if (TUKind == TU_Module) {
@@ -823,9 +821,7 @@ void Sema::ActOnEndOfTranslationUnit() {
checkUndefinedButUsed(*this);
}
- if (Diags.getDiagnosticLevel(diag::warn_unused_private_field,
- SourceLocation())
- != DiagnosticsEngine::Ignored) {
+ if (!Diags.isIgnored(diag::warn_unused_private_field, SourceLocation())) {
RecordCompleteMap RecordsComplete;
RecordCompleteMap MNCComplete;
for (NamedDeclSetType::iterator I = UnusedPrivateFields.begin(),
diff --git a/lib/Sema/SemaCast.cpp b/lib/Sema/SemaCast.cpp
index caaf5e5954..7fa30680f5 100644
--- a/lib/Sema/SemaCast.cpp
+++ b/lib/Sema/SemaCast.cpp
@@ -1606,10 +1606,8 @@ void Sema::CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
diag::warn_pointer_indirection_from_incompatible_type :
diag::warn_undefined_reinterpret_cast;
- if (Diags.getDiagnosticLevel(DiagID, Range.getBegin()) ==
- DiagnosticsEngine::Ignored) {
+ if (Diags.isIgnored(DiagID, Range.getBegin()))
return;
- }
QualType SrcTy, DestTy;
if (IsDereference) {
@@ -2127,9 +2125,8 @@ void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
/// pointer; etc. Cast to 'void' is an exception.
static void DiagnoseBadFunctionCast(Sema &Self, const ExprResult &SrcExpr,
QualType DestType) {
- if (Self.Diags.getDiagnosticLevel(diag::warn_bad_function_cast,
- SrcExpr.get()->getExprLoc())
- == DiagnosticsEngine::Ignored)
+ if (Self.Diags.isIgnored(diag::warn_bad_function_cast,
+ SrcExpr.get()->getExprLoc()))
return;
if (!isa<CallExpr>(SrcExpr.get()))
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 9f7a8bf7b3..d43713f60c 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -4065,8 +4065,8 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
// expression IDs can be expensive, we only do this if the diagnostic is
// enabled.
if (SizeOfArg &&
- Diags.getDiagnosticLevel(diag::warn_sizeof_pointer_expr_memaccess,
- SizeOfArg->getExprLoc())) {
+ !Diags.isIgnored(diag::warn_sizeof_pointer_expr_memaccess,
+ SizeOfArg->getExprLoc())) {
// We only compute IDs for expressions if the warning is enabled, and
// cache the sizeof arg's ID.
if (SizeOfArgID == llvm::FoldingSetNodeID())
@@ -6067,8 +6067,7 @@ void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
if (!Suspicious) return;
// ...but it's currently ignored...
- if (S.Diags.getDiagnosticLevel(diag::warn_impcast_integer_sign_conditional,
- CC))
+ if (!S.Diags.isIgnored(diag::warn_impcast_integer_sign_conditional, CC))
return;
// ...then check whether it would have warned about either of the
@@ -6916,9 +6915,7 @@ bool Sema::CheckParmsForFunctionDef(ParmVarDecl *const *P,
void Sema::CheckCastAlign(Expr *Op, QualType T, SourceRange TRange) {
// This is actually a lot of work to potentially be doing on every
// cast; don't do it if we're ignoring -Wcast_align (as is the default).
- if (getDiagnostics().getDiagnosticLevel(diag::warn_cast_align,
- TRange.getBegin())
- == DiagnosticsEngine::Ignored)
+ if (getDiagnostics().isIgnored(diag::warn_cast_align, TRange.getBegin()))
return;
// Ignore dependent types.
@@ -7527,9 +7524,7 @@ void Sema::checkUnsafeExprAssigns(SourceLocation Loc,
Qualifiers::ObjCLifetime LT = LHSType.getObjCLifetime();
if (LT == Qualifiers::OCL_Weak) {
- DiagnosticsEngine::Level Level =
- Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak, Loc);
- if (Level != DiagnosticsEngine::Ignored)
+ if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
getCurFunction()->markSafeWeakUse(LHS);
}
@@ -7654,8 +7649,7 @@ void Sema::DiagnoseEmptyLoopBody(const Stmt *S,
return;
// Skip expensive checks if diagnostic is disabled.
- if (Diags.getDiagnosticLevel(DiagID, NBody->getSemiLoc()) ==
- DiagnosticsEngine::Ignored)
+ if (Diags.isIgnored(DiagID, NBody->getSemiLoc()))
return;
// Do the usual checks.
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 68fecdb74a..733fdddd16 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/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())
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index ed7908dfc9..3f5321664c 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -2119,9 +2119,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
FieldDecl *FD = cast<FieldDecl>(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<CXXMethodDecl *, 8> OverloadedMethods;
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index fc9fdb1afa..b5205b3e62 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -1770,8 +1770,7 @@ static void CheckProtocolMethodDefs(Sema &S,
if (C || MethodInClass->isPropertyAccessor())
continue;
unsigned DIAG = diag::warn_unimplemented_protocol_method;
- if (S.Diags.getDiagnosticLevel(DIAG, ImpLoc)
- != DiagnosticsEngine::Ignored) {
+ if (!S.Diags.isIgnored(DIAG, ImpLoc)) {
WarnUndefinedMethod(S, ImpLoc, method, IncompleteImpl, DIAG,
PDecl);
}
@@ -1794,8 +1793,7 @@ static void CheckProtocolMethodDefs(Sema &S,
continue;
unsigned DIAG = diag::warn_unimplemented_protocol_method;
- if (S.Diags.getDiagnosticLevel(DIAG, ImpLoc) !=
- DiagnosticsEngine::Ignored) {
+ if (!S.Diags.isIgnored(DIAG, ImpLoc)) {
WarnUndefinedMethod(S, ImpLoc, method, IncompleteImpl, DIAG, PDecl);
}
}
@@ -2349,10 +2347,8 @@ ObjCMethodDecl *Sema::LookupMethodInGlobalPool(Selector Sel, SourceRange R,
// We support a warning which complains about *any* difference in
// method signature.
bool strictSelectorMatch =
- (receiverIdOrClass && warn &&
- (Diags.getDiagnosticLevel(diag::warn_strict_multiple_method_decl,
- R.getBegin())
- != DiagnosticsEngine::Ignored));
+ receiverIdOrClass && warn &&
+ !Diags.isIgnored(diag::warn_strict_multiple_method_decl, R.getBegin());
if (strictSelectorMatch) {
for (unsigned I = 1, N = Methods.size(); I != N; ++I) {
if (!MatchTwoMethodDeclarations(Methods[0], Methods[I], MMS_strict)) {
@@ -3527,7 +3523,7 @@ void Sema::DiagnoseUnusedBackingIvarInAccessor(Scope *S,
for (const auto *CurMethod : ImplD->instance_methods()) {
unsigned DIAG = diag::warn_unused_property_backing_ivar;
SourceLocation Loc = CurMethod->getLocation();
- if (Diags.getDiagnosticLevel(DIAG, Loc) == DiagnosticsEngine::Ignored)
+ if (Diags.isIgnored(DIAG, Loc))
continue;
const ObjCPropertyDecl *PDecl;
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 2ae8b27be9..4c329d925f 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1666,13 +1666,9 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
MarkDeclRefReferenced(E);
if (getLangOpts().ObjCARCWeak && isa<VarDecl>(D) &&
- Ty.getObjCLifetime() == Qualifiers::OCL_Weak) {
- DiagnosticsEngine::Level Level =
- Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak,
- E->getLocStart());
- if (Level != DiagnosticsEngine::Ignored)
+ Ty.getObjCLifetime() == Qualifiers::OCL_Weak &&
+ !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
recordUseOfEvaluatedWeak(E);
- }
// Just in case we're building an illegal pointer-to-member.
FieldDecl *FD = dyn_cast<FieldDecl>(D);
@@ -2352,9 +2348,7 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S,
if (getLangOpts().ObjCAutoRefCount) {
if (IV->getType().getObjCLifetime() == Qualifiers::OCL_Weak) {
- DiagnosticsEngine::Level Level =
- Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak, Loc);
- if (Level != DiagnosticsEngine::Ignored)
+ if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
recordUseOfEvaluatedWeak(Result);
}
if (CurContext->isClosure())
@@ -8664,10 +8658,8 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
// 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.
- DiagnosticsEngine::Level Level =
- Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak,
- RHS.get()->getLocStart());
- if (Level != DiagnosticsEngine::Ignored)
+ if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
+ RHS.get()->getLocStart()))
getCurFunction()->markSafeWeakUse(RHS.get());
} else if (getLangOpts().ObjCAutoRefCount) {
diff --git a/lib/Sema/SemaExprMember.cpp b/lib/Sema/SemaExprMember.cpp
index 133cabcb0a..ef7898208c 100644
--- a/lib/Sema/SemaExprMember.cpp
+++ b/lib/Sema/SemaExprMember.cpp
@@ -1365,9 +1365,7 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R,
if (S.getLangOpts().ObjCAutoRefCount) {
if (IV->getType().getObjCLifetime() == Qualifiers::OCL_Weak) {
- DiagnosticsEngine::Level Level = S.Diags.getDiagnosticLevel(
- diag::warn_arc_repeated_use_of_weak, MemberLoc);
- if (Level != DiagnosticsEngine::Ignored)
+ if (!S.Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, MemberLoc))
S.recordUseOfEvaluatedWeak(Result);
}
}
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 4ef502555d..ffb6b037ec 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -1004,9 +1004,7 @@ static bool HelperToDiagnoseMismatchedMethodsInGlobalPool(Sema &S,
static void DiagnoseMismatchedSelectors(Sema &S, SourceLocation AtLoc,
ObjCMethodDecl *Method) {
- if (S.Diags.getDiagnosticLevel(diag::warning_multiple_selectors,
- SourceLocation())
- == DiagnosticsEngine::Ignored)
+ if (S.Diags.isIgnored(diag::warning_multiple_selectors, SourceLocation()))
return;
bool Warned = false;
for (Sema::GlobalMethodPool::iterator b = S.MethodPool.begin(),
@@ -1989,7 +1987,7 @@ static void applyCocoaAPICheck(Sema &S, const ObjCMessageExpr *Msg,
bool (*refactor)(const ObjCMessageExpr *,
const NSAPI &, edit::Commit &)) {
SourceLocation MsgLoc = Msg->getExprLoc();
- if (S.Diags.getDiagnosticLevel(DiagID, MsgLoc) == DiagnosticsEngine::Ignored)
+ if (S.Diags.isIgnored(DiagID, MsgLoc))
return;
SourceManager &SM = S.SourceMgr;
@@ -2668,15 +2666,9 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak;
if (!IsWeak && Sel.isUnarySelector())
IsWeak = ReturnType.getObjCLifetime() & Qualifiers::OCL_Weak;
-
- if (IsWeak) {
- DiagnosticsEngine::Level Level =
- Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak,
- LBracLoc);
- if (Level != DiagnosticsEngine::Ignored)
- getCurFunction()->recordUseOfWeak(Result, Prop);
-
- }
+ if (IsWeak &&
+ !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, LBracLoc))
+ getCurFunction()->recordUseOfWeak(Result, Prop);
}
}
}
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index e3225da7f7..3dfeb8ecd3 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -5078,8 +5078,7 @@ static void CheckCXX98CompatAccessibleCopy(Sema &S,
return;
SourceLocation Loc = getInitializationLoc(Entity, CurInitExpr);
- if (S.Diags.getDiagnosticLevel(diag::warn_cxx98_compat_temp_copy, Loc)
- == DiagnosticsEngine::Ignored)
+ if (S.Diags.isIgnored(diag::warn_cxx98_compat_temp_copy, Loc))
return;
// Find constructors which would have been considered.
diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp
index c649cbe38d..3c9e83c492 100644
--- a/lib/Sema/SemaPseudoObject.cpp
+++ b/lib/Sema/SemaPseudoObject.cpp
@@ -931,14 +931,11 @@ ObjCPropertyOpBuilder::buildIncDecOperation(Scope *Sc, SourceLocation opcLoc,
}
ExprResult ObjCPropertyOpBuilder::complete(Expr *SyntacticForm) {
- if (S.getLangOpts().ObjCAutoRefCount && isWeakProperty()) {
- DiagnosticsEngine::Level Level =
- S.Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak,
- SyntacticForm->getLocStart());
- if (Level != DiagnosticsEngine::Ignored)
+ if (S.getLangOpts().ObjCAutoRefCount && isWeakProperty() &&
+ !S.Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
+ SyntacticForm->getLocStart()))
S.recordUseOfEvaluatedWeak(SyntacticRefExpr,
SyntacticRefExpr->isMessagingGetter());
- }
return PseudoOpBuilder::complete(SyntacticForm);
}
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index cdcbaeae04..d27e75aefa 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -1157,9 +1157,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
void
Sema::DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
Expr *SrcExpr) {
- if (Diags.getDiagnosticLevel(diag::warn_not_in_enum_assignment,
- SrcExpr->getExprLoc()) ==
- DiagnosticsEngine::Ignored)
+ if (Diags.isIgnored(diag::warn_not_in_enum_assignment, SrcExpr->getExprLoc()))
return;
if (const EnumType *ET = DstType->getAs<EnumType>())
@@ -1406,9 +1404,8 @@ namespace {
// Condition is empty
if (!Second) return;
- if (S.Diags.getDiagnosticLevel(diag::warn_variables_not_in_loop_body,
- Second->getLocStart())
- == DiagnosticsEngine::Ignored)
+ if (S.Diags.isIgnored(diag::warn_variables_not_in_loop_body,
+ Second->getLocStart()))
return;
PartialDiagnostic PDiag = S.PDiag(diag::warn_variables_not_in_loop_body);
@@ -1535,9 +1532,8 @@ namespace {
// Return when there is nothing to check.
if (!Body || !Third) return;
- if (S.Diags.getDiagnosticLevel(diag::warn_redundant_loop_iteration,
- Third->getLocStart())
- == DiagnosticsEngine::Ignored)
+ if (S.Diags.isIgnored(diag::warn_redundant_loop_iteration,
+ Third->getLocStart()))
return;
// Get the last statement from the loop body.
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index d6e2fb6166..84c58d12ea 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -4161,12 +4161,17 @@ bool Sema::CheckTemplateArgument(TemplateTypeParmDecl *Param,
//
// C++11 allows these, and even in C++03 we allow them as an extension with
// a warning.
- if (LangOpts.CPlusPlus11 ?
- Diags.getDiagnosticLevel(diag::warn_cxx98_compat_template_arg_unnamed_type,
- SR.getBegin()) != DiagnosticsEngine::Ignored ||
- Diags.getDiagnosticLevel(diag::warn_cxx98_compat_template_arg_local_type,
- SR.getBegin()) != DiagnosticsEngine::Ignored :
- Arg->hasUnnamedOrLocalType()) {
+ bool NeedsCheck;
+ if (LangOpts.CPlusPlus11)
+ NeedsCheck =
+ !Diags.isIgnored(diag::warn_cxx98_compat_template_arg_unnamed_type,
+ SR.getBegin()) ||
+ !Diags.isIgnored(diag::warn_cxx98_compat_template_arg_local_type,
+ SR.getBegin());
+ else
+ NeedsCheck = Arg->hasUnnamedOrLocalType();
+
+ if (NeedsCheck) {
UnnamedLocalNoLinkageFinder Finder(*this, SR);
(void)Finder.Visit(Context.getCanonicalType(Arg));
}