When libclang is walking a member access expression, don't walk into
an implicit "this"; it causes clang_getCursor() to find the implicit
"this" expression (which isn't written in the source!) rather than the
actual member.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119516 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index e6c208b..c69a97c 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -1841,7 +1841,17 @@
   EnqueueChildren(IE);
 }
 void EnqueueVisitor::VisitMemberExpr(MemberExpr *M) {
-  WL.push_back(MemberExprParts(M, Parent));  
+  WL.push_back(MemberExprParts(M, Parent));
+  
+  // If the base of the member access expression is an implicit 'this', don't
+  // visit it.
+  // FIXME: If we ever want to show these implicit accesses, this will be
+  // unfortunate. However, clang_getCursor() relies on this behavior.
+  if (CXXThisExpr *This
+            = llvm::dyn_cast<CXXThisExpr>(M->getBase()->IgnoreParenImpCasts()))
+    if (This->isImplicit())
+      return;
+  
   AddStmt(M->getBase());
 }
 void EnqueueVisitor::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {