r183149 - UnresolvedMemberExpr should have an expr location of the member (not the base)

David Blaikie dblaikie at gmail.com
Mon Jun 3 12:46:44 PDT 2013


Author: dblaikie
Date: Mon Jun  3 14:46:44 2013
New Revision: 183149

URL: http://llvm.org/viewvc/llvm-project?rev=183149&view=rev
Log:
UnresolvedMemberExpr should have an expr location of the member (not the base)

This matches the behavior of MemberExpr and makes diagnostics such as
"reference to non-static member function must be called" more legible in
the case that the base & member are split over multiple lines (prior to
this change the diagnostic would point to the base, not the member -
making it very unclear in chained multi-line builder-style calls)

Modified:
    cfe/trunk/include/clang/AST/ExprCXX.h
    cfe/trunk/test/SemaCXX/overloaded-operator.cpp

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=183149&r1=183148&r2=183149&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Jun  3 14:46:44 2013
@@ -3387,6 +3387,10 @@ public:
   // expression refers to.
   SourceLocation getMemberLoc() const { return getNameLoc(); }
 
+  // \brief Return the preferred location (the member name) for the arrow when
+  // diagnosing a problem with this expression.
+  SourceLocation getExprLoc() const LLVM_READONLY { return getMemberLoc(); }
+
   SourceLocation getLocStart() const LLVM_READONLY {
     if (!isImplicitAccess())
       return Base->getLocStart();

Modified: cfe/trunk/test/SemaCXX/overloaded-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-operator.cpp?rev=183149&r1=183148&r2=183149&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/overloaded-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/overloaded-operator.cpp Mon Jun  3 14:46:44 2013
@@ -396,7 +396,8 @@ namespace rdar9136502 {
   };
 
   void f(X x, Y y) {
-    y << x.i; // expected-error{{reference to non-static member function must be called}}
+    y << x
+      .i; // expected-error{{reference to non-static member function must be called}}
   }
 }
 





More information about the cfe-commits mailing list