@@ -2447,7 +2447,7 @@ Function::Function(const Tokenizer *mTokenizer,
24472447 const Token *tok1 = setFlags (tok, scope);
24482448
24492449 // find the return type
2450- if (!isConstructor () && !isDestructor () && ! isLambda () ) {
2450+ if (!isConstructor () && !isDestructor ()) {
24512451 // @todo auto type deduction should be checked
24522452 // @todo attributes and exception specification can also precede trailing return type
24532453 if (Token::Match (argDef->link ()->next (), " const|volatile| &|&&| ." )) { // Trailing return type
@@ -2458,7 +2458,7 @@ Function::Function(const Tokenizer *mTokenizer,
24582458 retDef = argDef->link ()->tokAt (3 );
24592459 else if (argDef->link ()->strAt (3 ) == " ." )
24602460 retDef = argDef->link ()->tokAt (4 );
2461- } else {
2461+ } else if (! isLambda ()) {
24622462 if (tok1->str () == " >" )
24632463 tok1 = tok1->next ();
24642464 while (Token::Match (tok1, " extern|virtual|static|friend|struct|union|enum" ))
@@ -6895,6 +6895,23 @@ static const Function *getOperatorFunction(const Token * const tok)
68956895 return nullptr ;
68966896}
68976897
6898+ static const Function* getFunction (const Token* tok) {
6899+ if (!tok)
6900+ return nullptr ;
6901+ if (tok->function () && tok->function ()->retDef )
6902+ return tok->function ();
6903+ if (const Variable* lvar = tok->variable ()) { // lambda
6904+ const Function* lambda{};
6905+ if (Token::Match (lvar->nameToken ()->next (), " ; %varid% = [" , lvar->declarationId ()))
6906+ lambda = lvar->nameToken ()->tokAt (4 )->function ();
6907+ else if (Token::simpleMatch (lvar->nameToken ()->next (), " { [" ))
6908+ lambda = lvar->nameToken ()->tokAt (2 )->function ();
6909+ if (lambda && lambda->retDef )
6910+ return lambda;
6911+ }
6912+ return nullptr ;
6913+ }
6914+
68986915void SymbolDatabase::setValueTypeInTokenList (bool reportDebugWarnings, Token *tokens)
68996916{
69006917 if (!tokens)
@@ -7012,10 +7029,10 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
70127029
70137030 }
70147031
7015- // function
7016- else if (tok-> previous () && tok-> previous ()-> function () && tok->previous ()-> function ()-> retDef ) {
7032+ // function or lambda
7033+ else if (const Function* f = getFunction ( tok->previous ()) ) {
70177034 ValueType valuetype;
7018- if (parsedecl (tok-> previous ()-> function () ->retDef , &valuetype, mDefaultSignedness , mSettings , mIsCpp ))
7035+ if (parsedecl (f ->retDef , &valuetype, mDefaultSignedness , mSettings , mIsCpp ))
70197036 setValueType (tok, valuetype);
70207037 }
70217038
0 commit comments