]> granicus.if.org Git - clang/commitdiff
When retrieving the location of a Node, for MemberExprs use the location of the
authorTed Kremenek <kremenek@apple.com>
Fri, 27 Feb 2009 20:05:10 +0000 (20:05 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 27 Feb 2009 20:05:10 +0000 (20:05 +0000)
'.' or '->'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65651 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/BugReporter.cpp

index 50ef3070ab0b55cab70c85818a51020dbbd28545..a8cb6a9107aac32ebe89948067e1f16d83982989 100644 (file)
@@ -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();
 }