@@ -3211,6 +3211,8 @@ bool Tokenizer::simplifyUsing()
32113211 }
32123212
32133213 Token * arrayStart = nullptr ;
3214+ Token * fpArgList = nullptr ;
3215+ Token * fpQual = nullptr ;
32143216
32153217 // parse the type
32163218 Token *type = start;
@@ -3310,6 +3312,18 @@ bool Tokenizer::simplifyUsing()
33103312 } while (type && type->str () == " [" );
33113313 }
33123314
3315+ // check for function pointer
3316+ if (type && type->str () == " (" ) {
3317+ if (Token::simpleMatch (type->link (), " ) (" )) {
3318+ fpArgList = type->link ()->next ();
3319+ fpQual = type;
3320+ type = type->link ()->linkAt (1 )->next ();
3321+ } else if (type->link ()->next () == usingEnd) {
3322+ fpArgList = type;
3323+ type = usingEnd;
3324+ }
3325+ }
3326+
33133327 // make sure we are in a good state
33143328 if (!tok1 || !tok1->next ())
33153329 break ; // bail
@@ -3325,6 +3339,24 @@ bool Tokenizer::simplifyUsing()
33253339 tok1->deleteThis ();
33263340 substitute = true ;
33273341 }
3342+ } else if (fpArgList && fpQual && Token::Match (tok1->next (), " %name%" )) {
3343+ // function pointer
3344+ TokenList::copyTokens (tok1->next (), fpArgList, usingEnd->previous ());
3345+ Token* const copyEnd = TokenList::copyTokens (tok1, start, fpQual->link ()->previous ());
3346+ tok1->deleteThis ();
3347+ Token* const rightPar = copyEnd->next ()->insertToken (" )" );
3348+ Token::createMutualLinks (tok1->next (), rightPar);
3349+ substitute = true ;
3350+ } else if (fpArgList && !fpQual && Token::Match (tok1->next (), " * const| %name%" )) {
3351+ // function pointer
3352+ Token* const dest = tok1->tokAt (tok1->strAt (2 ) == " const" ? 3 : 2 );
3353+ Token* const copyEndArgs = TokenList::copyTokens (dest, fpArgList, usingEnd->previous ());
3354+ Token* const copyEndRet = TokenList::copyTokens (tok1, start, fpArgList->previous ());
3355+ Token* const leftPar = copyEndRet->insertToken (" (" );
3356+ Token* const rightPar = copyEndArgs->link ()->tokAt (-1 )->insertToken (" )" );
3357+ Token::createMutualLinks (leftPar, rightPar);
3358+ tok1->deleteThis ();
3359+ substitute = true ;
33283360 } else {
33293361 // add some qualification back if needed
33303362 std::string removed1 = std::move (removed);
@@ -6931,8 +6963,7 @@ void Tokenizer::simplifyFunctionParameters()
69316963 }
69326964
69336965 // Find the function e.g. foo( x ) or foo( x, y )
6934- else if (Token::Match (tok, " %name% ( %name% [,)]" ) &&
6935- !(tok->strAt (-1 ) == " :" || tok->strAt (-1 ) == " ," || tok->strAt (-1 ) == " ::" )) {
6966+ else if (Token::Match (tok, " %name% ( %name% [,)]" ) && !Token::Match (tok->tokAt (-1 ), " :|,|::|=" )) {
69366967 // We have found old style function, now we need to change it
69376968
69386969 // First step: Get list of argument names in parentheses
0 commit comments