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 | 9b5e5059b2b7751caa2470a33c3ee8ccd3ff013f (patch) | |
tree | 9495a49ed12bacf56d5b8cbfafd279e097e73d17 /lib/Analysis/BugReporter.cpp | |
parent | a97b6666d2e08027e89a01ed718affbf969fad19 (diff) |
When retrieving the location of a Node, for MemberExprs use the location of the
'.' or '->'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65651 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BugReporter.cpp')
-rw-r--r-- | lib/Analysis/BugReporter.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index 50ef3070ab..a8cb6a9107 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/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(); } |