diff options
author | Matt Beaumont-Gay <matthewbg@google.com> | 2011-11-29 19:27:11 +0000 |
---|---|---|
committer | Matt Beaumont-Gay <matthewbg@google.com> | 2011-11-29 19:27:11 +0000 |
commit | cfbc5b5660f49fae63acc1f5ef05df87070a2a3c (patch) | |
tree | 313a307634e02f8e582077baf00f7c8f497ea50c /lib/Sema/SemaChecking.cpp | |
parent | 2cbe84dd36664b54bf056e4c69fe8d0fecd7346c (diff) |
Merge branch 'yo-dawg-i-herd-u-like-arrays'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145421 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index c66b8da6fb..9dd03133b9 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -4297,6 +4297,17 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, << IndexExpr->getSourceRange()); } + if (!ND) { + // Try harder to find a NamedDecl to point at in the note. + while (const ArraySubscriptExpr *ASE = + dyn_cast<ArraySubscriptExpr>(BaseExpr)) + BaseExpr = ASE->getBase()->IgnoreParenCasts(); + if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BaseExpr)) + ND = dyn_cast<NamedDecl>(DRE->getDecl()); + if (const MemberExpr *ME = dyn_cast<MemberExpr>(BaseExpr)) + ND = dyn_cast<NamedDecl>(ME->getMemberDecl()); + } + if (ND) DiagRuntimeBehavior(ND->getLocStart(), BaseExpr, PDiag(diag::note_array_index_out_of_bounds) |