summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorMatt Beaumont-Gay <matthewbg@google.com>2011-11-29 19:27:11 +0000
committerMatt Beaumont-Gay <matthewbg@google.com>2011-11-29 19:27:11 +0000
commitb2339826e6890bfe4a5e491b5585332767abbd70 (patch)
treed532aa9e97cf600aad3e919434fdb6cf398bedff /clang/lib/Sema/SemaChecking.cpp
parent539d0a8a09794f4a0ef575ebbfe6a666466cd421 (diff)
downloadbcm5719-llvm-b2339826e6890bfe4a5e491b5585332767abbd70.tar.gz
bcm5719-llvm-b2339826e6890bfe4a5e491b5585332767abbd70.zip
Merge branch 'yo-dawg-i-herd-u-like-arrays'
llvm-svn: 145421
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index c66b8da6fbc..9dd03133b99 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/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)
OpenPOWER on IntegriCloud