[cfe-commits] r65651 - /cfe/trunk/lib/Analysis/BugReporter.cpp

Ted Kremenek kremenek at apple.com
Fri Feb 27 12:05:10 PST 2009


Author: kremenek
Date: Fri Feb 27 14:05:10 2009
New Revision: 65651

URL: http://llvm.org/viewvc/llvm-project?rev=65651&view=rev
Log:
When retrieving the location of a Node, for MemberExprs use the location of the
'.' or '->'.

Modified:
    cfe/trunk/lib/Analysis/BugReporter.cpp

Modified: cfe/trunk/lib/Analysis/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BugReporter.cpp?rev=65651&r1=65650&r2=65651&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Fri Feb 27 14:05:10 2009
@@ -151,6 +151,7 @@
   
   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 @@
 
 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();
 }





More information about the cfe-commits mailing list