forked from qt-creator/qt-creator
C++: Store lambda captures in the code model.
Done-with: Erik Verbruggen Task-number: QTCREATORBUG-7968 Task-number: QTCREATORBUG-7949 Change-Id: I0cf727052d0a3536ed96ee894b18768c9538c213 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
43
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
43
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -6294,43 +6294,56 @@ bool Parser::parseLambdaCapture(LambdaCaptureAST *&node)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Parser::parseCapture(CaptureAST *&)
|
||||
bool Parser::parseCapture(CaptureAST *&node)
|
||||
{
|
||||
// See QTCREATORBUG-7968
|
||||
|
||||
DEBUG_THIS_RULE();
|
||||
|
||||
if (LA() == T_THIS) {
|
||||
consumeToken();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (LA() == T_AMPER)
|
||||
consumeToken();
|
||||
|
||||
if (LA() == T_IDENTIFIER) {
|
||||
consumeToken();
|
||||
return true;
|
||||
SimpleNameAST *ast = new (_pool) SimpleNameAST;
|
||||
ast->identifier_token = consumeToken();
|
||||
|
||||
} else if (LA() == T_AMPER && LA(2) == T_IDENTIFIER) {
|
||||
consumeToken();
|
||||
consumeToken();
|
||||
return true;
|
||||
|
||||
} else if (LA() == T_THIS) {
|
||||
consumeToken();
|
||||
node = new (_pool) CaptureAST;
|
||||
node->identifier = ast;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Parser::parseCaptureList(CaptureListAST *&)
|
||||
bool Parser::parseCaptureList(CaptureListAST *&node)
|
||||
{
|
||||
DEBUG_THIS_RULE();
|
||||
|
||||
CaptureAST *capture = 0;
|
||||
|
||||
if (parseCapture(capture)) {
|
||||
node = new (_pool) CaptureListAST;
|
||||
node->value = capture;
|
||||
|
||||
CaptureListAST **l = &node->next;
|
||||
while (LA() == T_COMMA) {
|
||||
consumeToken(); // consume `,'
|
||||
|
||||
CaptureAST *capture = 0;
|
||||
parseCapture(capture);
|
||||
if (capture) {
|
||||
*l = new (_pool) CaptureListAST;
|
||||
(*l)->value = capture;
|
||||
l = &(*l)->next;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Parser::parseLambdaDeclarator(LambdaDeclaratorAST *&node)
|
||||
|
||||
Reference in New Issue
Block a user