From db4d7a5f47d13bf346260ac35eaafd2c92e5606e Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Sat, 14 Jan 2012 02:05:51 +0000 Subject: [PATCH] [libclang] If CXIndexOpt_IndexFunctionLocalSymbols is enabled, also index parameters. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148169 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/libclang/IndexDecl.cpp | 16 ++++++++++++++-- tools/libclang/IndexingContext.cpp | 6 +++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/tools/libclang/IndexDecl.cpp b/tools/libclang/IndexDecl.cpp index 9ff65b30f4..fb4194c8cd 100644 --- a/tools/libclang/IndexDecl.cpp +++ b/tools/libclang/IndexDecl.cpp @@ -25,8 +25,20 @@ public: void handleDeclarator(DeclaratorDecl *D, const NamedDecl *Parent = 0) { if (!Parent) Parent = D; - IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), Parent); - IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent); + + if (!IndexCtx.indexFunctionLocalSymbols()) { + IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), Parent); + IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent); + } else { + if (ParmVarDecl *Parm = dyn_cast(D)) { + IndexCtx.handleVar(Parm); + } else if (FunctionDecl *FD = dyn_cast(D)) { + for (FunctionDecl::param_iterator + PI = FD->param_begin(), PE = FD->param_end(); PI != PE; ++PI) { + IndexCtx.handleVar(*PI); + } + } + } } bool VisitFunctionDecl(FunctionDecl *D) { diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp index f731580e66..299d1c93d8 100644 --- a/tools/libclang/IndexingContext.cpp +++ b/tools/libclang/IndexingContext.cpp @@ -261,7 +261,8 @@ bool IndexingContext::handleDecl(const NamedDecl *D, ScratchAlloc SA(*this); getEntityInfo(D, DInfo.EntInfo, SA); - if (!DInfo.EntInfo.USR || Loc.isInvalid()) + if ((!indexFunctionLocalSymbols() && !DInfo.EntInfo.USR) + || Loc.isInvalid()) return false; if (suppressRefs()) @@ -829,6 +830,9 @@ void IndexingContext::getEntityInfo(const NamedDecl *D, case Decl::Function: EntityInfo.kind = CXIdxEntity_Function; break; + case Decl::ParmVar: + EntityInfo.kind = CXIdxEntity_Variable; + break; case Decl::Var: EntityInfo.kind = CXIdxEntity_Variable; if (isa(D->getDeclContext())) { -- 2.40.0