[PATCH] D55437: [Index] Index declarations in lambda expression.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 19 05:47:57 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rC349626: [Index] Index paremeters in lambda expressions. (authored by hokein, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D55437?vs=178688&id=178870#toc
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
@@ -7,6 +7,7 @@
auto lambda = [&localA, localB] (Integer x) -> Integer {
return localA + localB + x;
};
+ auto lambda2 = [](Integer y) {};
}
};
@@ -26,8 +27,10 @@
// RUN: env CINDEXTEST_INDEXLOCALSYMBOLS=1 c-index-test -index-file -std=c++11 %s | FileCheck -check-prefix=CHECK-INDEX %s
// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localA | USR: c:cxx11-lambdas.cpp at 100@S at X@F at f#@localA | lang: C | cursor: VariableRef=localA:6:9 | loc: 7:21
// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localB | USR: c:cxx11-lambdas.cpp at 100@S at X@F at f#@localB | lang: C | cursor: VariableRef=localB:6:17 | loc: 7:29
+// 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
// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: c:cxx11-lambdas.cpp at T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 7:52
// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: c:cxx11-lambdas.cpp at T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 7:38
// 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: y | USR: c:cxx11-lambdas.cpp at 244@S at X@F at f#@Sa at F@operator()#I#1 at y | lang: C | cursor: ParmDecl=y:10:31 (Definition) | loc: 10:31
\ No newline at end of file
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,16 @@
}
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55437.178870.patch
Type: text/x-patch
Size: 2801 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181219/eac375ed/attachment.bin>
More information about the cfe-commits
mailing list