diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-02-27 20:05:10 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-02-27 20:05:10 +0000 |
commit | cbcc5e83cafd4486efbbdd82f4bf125a7e07ffa9 (patch) | |
tree | 481a7153e66b525df598af1cc3bb0f4c11476d63 | |
parent | e879e15ed9edb4187a7a50eac05e1f3fc48b5143 (diff) | |
download | bcm5719-llvm-cbcc5e83cafd4486efbbdd82f4bf125a7e07ffa9.tar.gz bcm5719-llvm-cbcc5e83cafd4486efbbdd82f4bf125a7e07ffa9.zip |
When retrieving the location of a Node, for MemberExprs use the location of the
'.' or '->'.
llvm-svn: 65651
-rw-r--r-- | clang/lib/Analysis/BugReporter.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp index 50ef3070ab0..a8cb6a9107a 100644 --- a/clang/lib/Analysis/BugReporter.cpp +++ b/clang/lib/Analysis/BugReporter.cpp @@ -151,6 +151,7 @@ void BugReport::getRanges(BugReporter& BR, const SourceRange*& beg, if (Expr* E = dyn_cast_or_null<Expr>(getStmt(BR))) { R = E->getSourceRange(); + assert(R.isValid()); beg = &R; end = beg+1; } @@ -160,8 +161,13 @@ void BugReport::getRanges(BugReporter& BR, const SourceRange*& beg, SourceLocation BugReport::getLocation() const { if (EndNode) - if (Stmt* S = GetCurrentOrPreviousStmt(EndNode)) + if (Stmt* S = GetCurrentOrPreviousStmt(EndNode)) { + // For member expressions, return the location of the '.' or '->'. + if (MemberExpr* ME = dyn_cast<MemberExpr>(S)) + return ME->getMemberLoc(); + return S->getLocStart(); + } return FullSourceLoc(); } |