From b70369cae98590c03cad0cd0d6c8f94c4e0e55c4 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 23 Feb 2011 01:51:40 +0000 Subject: [PATCH] Change -Warray-bounds logic to use DiagRuntimeBehavior in preparation for using basic dataflow to suppress warnings on unreachable array bounds checks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126285 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaChecking.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index bb5ef7f9b3..436031b7a5 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -3135,12 +3135,15 @@ void Sema::CheckArrayAccess(const clang::ArraySubscriptExpr *E) { if (index.slt(size)) return; - Diag(E->getBase()->getLocStart(), diag::warn_array_index_exceeds_bounds) - << index.toString(10, true) << size.toString(10, true) - << IndexExpr->getSourceRange(); + DiagRuntimeBehavior(E->getBase()->getLocStart(), + PDiag(diag::warn_array_index_exceeds_bounds) + << index.toString(10, true) << size.toString(10, true) + << IndexExpr->getSourceRange()); } else { - Diag(E->getBase()->getLocStart(), diag::warn_array_index_precedes_bounds) - << index.toString(10, true) << IndexExpr->getSourceRange(); + DiagRuntimeBehavior(E->getBase()->getLocStart(), + PDiag(diag::warn_array_index_precedes_bounds) + << index.toString(10, true) + << IndexExpr->getSourceRange()); } const NamedDecl *ND = NULL; @@ -3149,7 +3152,8 @@ void Sema::CheckArrayAccess(const clang::ArraySubscriptExpr *E) { if (const MemberExpr *ME = dyn_cast(BaseExpr)) ND = dyn_cast(ME->getMemberDecl()); if (ND) - Diag(ND->getLocStart(), diag::note_array_index_out_of_bounds) - << ND->getDeclName(); + DiagRuntimeBehavior(ND->getLocStart(), + PDiag(diag::note_array_index_out_of_bounds) + << ND->getDeclName()); } -- 2.40.0