C++: Fix (Find)LocalSymbols for lambda parameters

Change-Id: I5cb69749b4f15e4f70dea410aa6f943c4189c502
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-06-26 15:07:31 -04:00
parent 995d1f777f
commit 8ff225d9d6
4 changed files with 29 additions and 0 deletions

View File

@@ -175,6 +175,19 @@ protected:
_scopeStack.removeLast();
}
virtual bool visit(LambdaExpressionAST *ast)
{
if (ast->lambda_declarator && ast->lambda_declarator->symbol)
enterScope(ast->lambda_declarator->symbol);
return true;
}
virtual void endVisit(LambdaExpressionAST *ast)
{
if (ast->lambda_declarator && ast->lambda_declarator->symbol)
_scopeStack.removeLast();
}
virtual bool visit(CompoundStatementAST *ast)
{
if (ast->symbol)

View File

@@ -157,6 +157,18 @@ void CppToolsPlugin::test_cpplocalsymbols_data()
<< Result(_("local"), 3, 8, 5)
<< Result(_("local"), 4, 12, 5)
<< Result(_("arg"), 4, 20, 3));
QTest::newRow("lambda")
<< _("void f()\n"
"{\n"
" auto func = [](int arg) { return arg; };\n"
" func(1);\n"
"}\n")
<< (QList<Result>()
<< Result(_("func"), 2, 10, 4)
<< Result(_("arg"), 2, 24, 3)
<< Result(_("arg"), 2, 38, 3)
<< Result(_("func"), 3, 5, 4));
}
void CppToolsPlugin::test_cpplocalsymbols()