AST: better handling when returning list of lambdas
This commit is contained in:
parent
575fa35ce2
commit
f03945a9e2
|
@ -1184,11 +1184,21 @@ static void createAstAtTokenInner(Token * const tok1, const Token *endToken, boo
|
|||
const Token * const endToken2 = tok->link();
|
||||
for (; tok && tok != endToken && tok != endToken2; tok = tok ? tok->next() : nullptr)
|
||||
tok = createAstAtToken(tok, cpp);
|
||||
} else if (Token::simpleMatch(tok->link(), "] (") && Token::simpleMatch(tok->link()->linkAt(1), ") {")) {
|
||||
tok = tok->link()->linkAt(1)->next();
|
||||
const Token * const endToken2 = tok->link();
|
||||
for (; tok && tok != endToken && tok != endToken2; tok = tok ? tok->next() : nullptr)
|
||||
tok = createAstAtToken(tok, cpp);
|
||||
} else if (Token::simpleMatch(tok->link(), "] (") && Token::Match(tok->link()->linkAt(1), ") .|{")) {
|
||||
Token *bodyStart = tok->link()->linkAt(1)->next();
|
||||
if (Token::Match(bodyStart, ". %name%") && bodyStart->originalName() == "->") {
|
||||
bodyStart = bodyStart->next();
|
||||
while (Token::Match(bodyStart, "%name%|::"))
|
||||
bodyStart = bodyStart->next();
|
||||
if (Token::simpleMatch(bodyStart, "<") && Token::simpleMatch(bodyStart->link(), "> {"))
|
||||
bodyStart = bodyStart->link()->next();
|
||||
}
|
||||
if (Token::simpleMatch(bodyStart, "{")) {
|
||||
tok = bodyStart;
|
||||
const Token * const endToken2 = tok->link();
|
||||
for (; tok && tok != endToken && tok != endToken2; tok = tok ? tok->next() : nullptr)
|
||||
tok = createAstAtToken(tok, cpp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7613,6 +7613,12 @@ private:
|
|||
" a = b;\n"
|
||||
" }\n"
|
||||
"};\n"));
|
||||
ASSERT_EQUALS("{return ab={",
|
||||
testAst("return {\n"
|
||||
" [=]() -> int {\n"
|
||||
" a=b;\n"
|
||||
" }\n"
|
||||
"}"));
|
||||
}
|
||||
|
||||
void astcase() {
|
||||
|
|
Loading…
Reference in New Issue