Index: lib/Index/IndexBody.cpp =================================================================== --- lib/Index/IndexBody.cpp +++ 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; @@ -454,6 +455,17 @@ } 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 Index: test/Index/cxx11-lambdas.cpp =================================================================== --- test/Index/cxx11-lambdas.cpp +++ test/Index/cxx11-lambdas.cpp @@ -31,3 +31,10 @@ // CHECK-INDEX: [indexEntityReference]: kind: variable | name: localA | USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localA | lang: C | cursor: DeclRefExpr=localA:6:9 | loc: 8:14 // CHECK-INDEX: [indexEntityReference]: kind: variable | name: localB | USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localB | lang: C | cursor: DeclRefExpr=localB:6:17 | loc: 8:23 // CHECK-INDEX: [indexEntityReference]: kind: variable | name: x | USR: c:cxx11-lambdas.cpp@157@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: DeclRefExpr=x:7:46 | loc: 8:32 +// CHECK-INDEX: [indexDeclaration]: kind: variable | name: x | USR: c:cxx11-lambdas.cpp@157@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: ParmDecl=x:7:46 (Definition) | loc: 7:46 + +void f() { + auto lambda = [](Integer y) {}; +} +// RUN: env CINDEXTEST_INDEXLOCALSYMBOLS=1 c-index-test -index-file -std=c++11 %s | FileCheck -check-prefix=CHECK-INDEX2 %s +// CHECK-INDEX2: indexDeclaration]: kind: variable | name: y | USR: c:cxx11-lambdas.cpp@2548@F@f#@Sa@F@operator()#I#1@y | lang: C | cursor: ParmDecl=y:37:28 (Definition) | loc: 37:28 \ No newline at end of file