First pass of semantic analysis for init-captures: check the initializer, build
a FieldDecl from it, and propagate both into the closure type and the
LambdaExpr.
You can't do much useful with them yet -- you can't use them within the body
of the lambda, because we don't have a representation for "the this of the
lambda, not the this of the enclosing context". We also don't have support or a
representation for a nested capture of an init-capture yet, which was intended
to work despite not being allowed by the current standard wording.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181985 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 71827f8..db7faab 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -2366,9 +2366,10 @@
for (LambdaExpr::capture_iterator C = E->explicit_capture_begin(),
CEnd = E->explicit_capture_end();
C != CEnd; ++C) {
- if (C->capturesThis())
+ // FIXME: Lambda init-captures.
+ if (!C->capturesVariable())
continue;
-
+
if (Visit(MakeCursorVariableRef(C->getCapturedVar(),
C->getLocation(),
TU)))
diff --git a/tools/libclang/IndexBody.cpp b/tools/libclang/IndexBody.cpp
index 02ab885..e08a346 100644
--- a/tools/libclang/IndexBody.cpp
+++ b/tools/libclang/IndexBody.cpp
@@ -153,9 +153,11 @@
if (C.capturesThis())
return true;
- if (IndexCtx.shouldIndexFunctionLocalSymbols())
+ if (C.capturesVariable() && IndexCtx.shouldIndexFunctionLocalSymbols())
IndexCtx.handleReference(C.getCapturedVar(), C.getLocation(),
Parent, ParentDC);
+
+ // FIXME: Lambda init-captures.
return true;
}