@@ -2683,6 +2683,18 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
26832683 (Token::simpleMatch (first, " ( void )" ) && Token::simpleMatch (second, " ( )" )))
26842684 return true ;
26852685
2686+ auto skipTopLevelConst = [](const Token* start) -> const Token* {
2687+ const Token* tok = start->next ();
2688+ if (Token::simpleMatch (tok, " const" )) {
2689+ tok = tok->next ();
2690+ while (Token::Match (tok, " %name%|%type%|::" ))
2691+ tok = tok->next ();
2692+ if (Token::Match (tok, " ,|)|=" ))
2693+ return start->next ();
2694+ }
2695+ return start;
2696+ };
2697+
26862698 while (first->str () == second->str () &&
26872699 first->isLong () == second->isLong () &&
26882700 first->isUnsigned () == second->isUnsigned ()) {
@@ -2704,15 +2716,12 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
27042716 second = second->next ();
27052717
27062718 // skip const on type passed by value
2707- if (Token::Match (first->next (), " const %type% %name%|,|)" ) &&
2708- !Token::Match (first->next (), " const %type% %name%| [" ))
2709- first = first->next ();
2710- if (Token::Match (second->next (), " const %type% %name%|,|)" ) &&
2711- !Token::Match (second->next (), " const %type% %name%| [" ))
2712- second = second->next ();
2719+ const Token* const oldSecond = second;
2720+ first = skipTopLevelConst (first);
2721+ second = skipTopLevelConst (second);
27132722
27142723 // skip default value assignment
2715- else if (first->next ()->str () == " =" ) {
2724+ if (oldSecond == second && first->next ()->str () == " =" ) {
27162725 first = first->nextArgument ();
27172726 if (first)
27182727 first = first->tokAt (-2 );
@@ -2726,7 +2735,7 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
27262735 } else if (!first) { // End of argument list (first)
27272736 return !second->nextArgument (); // End of argument list (second)
27282737 }
2729- } else if (second->next ()->str () == " =" ) {
2738+ } else if (oldSecond == second && second->next ()->str () == " =" ) {
27302739 second = second->nextArgument ();
27312740 if (second)
27322741 second = second->tokAt (-2 );
0 commit comments