From: Ted Kremenek Date: Fri, 27 Feb 2009 20:05:10 +0000 (+0000) Subject: When retrieving the location of a Node, for MemberExprs use the location of the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b5e5059b2b7751caa2470a33c3ee8ccd3ff013f;p=clang 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 --- 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(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(S)) + return ME->getMemberLoc(); + return S->getLocStart(); + } return FullSourceLoc(); }