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/SemaExprObjC.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'clang/lib/Sema/SemaExprObjC.cpp') diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 4ef502555d6..ffb6b037ec0 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/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); } } } -- cgit v1.2.3