[PATCH] D55437: [Index] Index declarations in lambda expression.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 17 02:53:06 PST 2018
hokein updated this revision to Diff 178437.
hokein added a comment.
Update the patch, add comments.
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55437/new/
https://reviews.llvm.org/D55437
Files:
lib/Index/IndexBody.cpp
test/Index/cxx11-lambdas.cpp
Index: test/Index/cxx11-lambdas.cpp
===================================================================
--- test/Index/cxx11-lambdas.cpp
+++ test/Index/cxx11-lambdas.cpp
@@ -31,3 +31,4 @@
// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localA | USR: c:cxx11-lambdas.cpp at 100@S at X@F at f#@localA | lang: C | cursor: DeclRefExpr=localA:6:9 | loc: 8:14
// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localB | USR: c:cxx11-lambdas.cpp at 100@S at X@F at f#@localB | lang: C | cursor: DeclRefExpr=localB:6:17 | loc: 8:23
// CHECK-INDEX: [indexEntityReference]: kind: variable | name: x | USR: c:cxx11-lambdas.cpp at 157@S at X@F at f#@Sa at F@operator()#I#1 at x | lang: C | cursor: DeclRefExpr=x:7:46 | loc: 8:32
+// CHECK-INDEX: [indexDeclaration]: kind: variable | name: x | USR: c:cxx11-lambdas.cpp at 157@S at X@F at f#@Sa at F@operator()#I#1 at x | lang: C | cursor: ParmDecl=x:7:46 (Definition) | loc: 7:46
\ No newline at end of file
Index: lib/Index/IndexBody.cpp
===================================================================
--- lib/Index/IndexBody.cpp
+++ lib/Index/IndexBody.cpp
@@ -399,6 +399,19 @@
return true;
}
+ bool TraverseLambdaExpr(LambdaExpr* LE) {
+ // Clang's default behavior is only visiting the visible parts of lambda
+ // expressions, thus the implicitly (and importantly) generated call
+ // operator is not visited, which results in ignoring parameters of
+ // the lambda expressions.
+ bool Result = RecursiveASTVisitor::TraverseLambdaExpr(LE);
+ // Index parameters of the lambda expressions.
+ if (IndexCtx.shouldIndexFunctionLocalSymbols())
+ for (const auto* PI : LE->getCallOperator()->parameters())
+ IndexCtx.handleDecl(PI);
+ return Result;
+ }
+
// RecursiveASTVisitor visits both syntactic and semantic forms, duplicating
// the things that we visit. Make sure to only visit the semantic form.
// Also visit things that are in the syntactic form but not the semantic one,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55437.178437.patch
Type: text/x-patch
Size: 1962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181217/d537783c/attachment-0001.bin>
More information about the cfe-commits
mailing list