diff options
Diffstat (limited to 'lib/Index/IndexBody.cpp')
-rw-r--r-- | lib/Index/IndexBody.cpp | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/lib/Index/IndexBody.cpp b/lib/Index/IndexBody.cpp index 786563a44a4d..54a6df2496a9 100644 --- a/lib/Index/IndexBody.cpp +++ b/lib/Index/IndexBody.cpp @@ -9,6 +9,7 @@ #include "IndexingContext.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/ASTLambda.h" using namespace clang; using namespace clang::index; @@ -143,7 +144,7 @@ public: bool VisitMemberExpr(MemberExpr *E) { SourceLocation Loc = E->getMemberLoc(); if (Loc.isInvalid()) - Loc = E->getLocStart(); + Loc = E->getBeginLoc(); SmallVector<SymbolRelation, 4> Relations; SymbolRoleSet Roles = getRolesForRef(E, Relations); return IndexCtx.handleReference(E->getMemberDecl(), Loc, @@ -175,7 +176,7 @@ public: return true; SourceLocation Loc = NameInfo.getLoc(); if (Loc.isInvalid()) - Loc = E->getLocStart(); + Loc = E->getBeginLoc(); SmallVector<SymbolRelation, 4> Relations; SymbolRoleSet Roles = getRolesForRef(E, Relations); return IndexCtx.handleReference(Symbols[0], Loc, Parent, ParentDC, Roles, @@ -259,8 +260,24 @@ public: if (isDynamic(E)) { Roles |= (unsigned)SymbolRole::Dynamic; - if (auto *RecD = E->getReceiverInterface()) - Relations.emplace_back((unsigned)SymbolRole::RelationReceivedBy, RecD); + + auto addReceivers = [&](const ObjCObjectType *Ty) { + if (!Ty) + return; + if (const auto *clsD = Ty->getInterface()) { + Relations.emplace_back((unsigned)SymbolRole::RelationReceivedBy, + clsD); + } + for (const auto *protD : Ty->quals()) { + Relations.emplace_back((unsigned)SymbolRole::RelationReceivedBy, + protD); + } + }; + QualType recT = E->getReceiverType(); + if (const auto *Ptr = recT->getAs<ObjCObjectPointerType>()) + addReceivers(Ptr->getObjectType()); + else + addReceivers(recT->getAs<ObjCObjectType>()); } return IndexCtx.handleReference(MD, E->getSelectorStartLoc(), @@ -312,8 +329,8 @@ public: SmallVector<SymbolRelation, 2> Relations; addCallRole(Roles, Relations); Roles |= (unsigned)SymbolRole::Implicit; - return IndexCtx.handleReference(MD, E->getLocStart(), - Parent, ParentDC, Roles, Relations, E); + return IndexCtx.handleReference(MD, E->getBeginLoc(), Parent, ParentDC, + Roles, Relations, E); } bool VisitObjCBoxedExpr(ObjCBoxedExpr *E) { @@ -432,12 +449,22 @@ public: for (unsigned I = 0, E = S->getNumComponents(); I != E; ++I) { const OffsetOfNode &Component = S->getComponent(I); if (Component.getKind() == OffsetOfNode::Field) - IndexCtx.handleReference(Component.getField(), Component.getLocEnd(), + IndexCtx.handleReference(Component.getField(), Component.getEndLoc(), Parent, ParentDC, SymbolRoleSet(), {}); // FIXME: Try to resolve dependent field references. } return true; } + + bool VisitParmVarDecl(ParmVarDecl* D) { + // Index the parameters of lambda expression. + if (IndexCtx.shouldIndexFunctionLocalSymbols()) { + const auto *DC = D->getDeclContext(); + if (DC && isLambdaCallOperator(DC)) + IndexCtx.handleDecl(D); + } + return true; + } }; } // anonymous namespace |