hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, ioeric.

This fixes clangd couldn't find references for lambda parameters.


Repository:
  rC Clang

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@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
\ No newline at end of file
Index: lib/Index/IndexBody.cpp
===================================================================
--- lib/Index/IndexBody.cpp
+++ lib/Index/IndexBody.cpp
@@ -454,6 +454,11 @@
     }
     return true;
   }
+
+  bool VisitLambdaExpr(const LambdaExpr *E) {
+    IndexCtx.indexTagDecl(E->getLambdaClass());
+    return true;
+  }
 };
 
 } // anonymous namespace


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@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
\ No newline at end of file
Index: lib/Index/IndexBody.cpp
===================================================================
--- lib/Index/IndexBody.cpp
+++ lib/Index/IndexBody.cpp
@@ -454,6 +454,11 @@
     }
     return true;
   }
+
+  bool VisitLambdaExpr(const LambdaExpr *E) {
+    IndexCtx.indexTagDecl(E->getLambdaClass());
+    return true;
+  }
 };
 
 } // anonymous namespace
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to