diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-11-17 17:15:08 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-11-17 17:15:08 +0000 |
commit | 30313cbb8078e915712b50c44786c3f119c12a3d (patch) | |
tree | b50de3ac8d2a426000ea835fddbc659b1caf13d7 /clang/tools | |
parent | 8defde09fd565a12e9af40e39c97f963b50a4836 (diff) | |
download | bcm5719-llvm-30313cbb8078e915712b50c44786c3f119c12a3d.tar.gz bcm5719-llvm-30313cbb8078e915712b50c44786c3f119c12a3d.zip |
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.
llvm-svn: 119516
Diffstat (limited to 'clang/tools')
-rw-r--r-- | clang/tools/libclang/CIndex.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index e6c208b2eaa..c69a97c4936 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -1841,7 +1841,17 @@ void EnqueueVisitor::VisitInitListExpr(InitListExpr *IE) { 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) { |