MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / isLambdaCaptureList

Function isLambdaCaptureList

lib/tokenlist.cpp:1479–1498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1477}
1478
1479const Token* isLambdaCaptureList(const Token * tok)
1480{
1481 // a lambda expression '[x](y){}' is compiled as:
1482 // [
1483 // `-( <<-- optional
1484 // `-{
1485 // see compilePrecedence2
1486 if (!Token::simpleMatch(tok, "["))
1487 return nullptr;
1488 if (!Token::Match(tok->link(), "] (|{"))
1489 return nullptr;
1490 if (Token::simpleMatch(tok->astOperand1(), "{") && tok->astOperand1() == tok->link()->next())
1491 return tok->astOperand1();
1492 if (!tok->astOperand1() || tok->astOperand1()->str() != "(")
1493 return nullptr;
1494 const Token * params = tok->astOperand1();
1495 if (!Token::simpleMatch(params->astOperand1(), "{"))
1496 return nullptr;
1497 return params->astOperand1();
1498}
1499
1500const Token* findLambdaEndTokenWithoutAST(const Token* tok) {
1501 if (!(Token::simpleMatch(tok, "[") && tok->link()))

Callers 6

createAstAtTokenInnerFunction · 0.85
setParentExprIdFunction · 0.85
functionCallMethod · 0.85
checkReturnPtrThisMethod · 0.85

Calls 4

astOperand1Method · 0.80
nextMethod · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected