File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3389,12 +3389,17 @@ bool Tokenizer::simplifyUsing()
33893389 } else if (fpArgList && fpQual && Token::Match (tok1->next (), " %name%" )) {
33903390 // function pointer
33913391 const bool isFuncDecl = Token::simpleMatch (tok1->tokAt (2 ), " (" );
3392- TokenList::copyTokens (tok1->next (), fpArgList, usingEnd->previous ());
3392+ Token *dest = tok1->next ();
3393+ while (Token::Match (dest, " %name% :: %name%" ))
3394+ dest = dest->tokAt (2 );
3395+ TokenList::copyTokens (dest, fpArgList, usingEnd->previous ());
33933396 Token* const copyEnd = TokenList::copyTokens (tok1, start, fpQual->link ()->previous ());
33943397 Token* leftPar = copyEnd->previous ();
33953398 while (leftPar->str () != " (" )
33963399 leftPar = leftPar->previous ();
3397- Token* const insertTok = isFuncDecl ? copyEnd->linkAt (2 ) : copyEnd->next ();
3400+ Token *insertTok = isFuncDecl ? copyEnd->linkAt (2 ) : copyEnd->next ();
3401+ while (Token::Match (insertTok, " %name% :: %name%" ))
3402+ insertTok = insertTok->tokAt (2 );
33983403 Token* const rightPar = insertTok->insertToken (" )" );
33993404 Token::createMutualLinks (leftPar, rightPar);
34003405 tok1->deleteThis ();
Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ class TestSimplifyUsing : public TestFixture {
7878 TEST_CASE (simplifyUsing38);
7979 TEST_CASE (simplifyUsing39);
8080 TEST_CASE (simplifyUsing40);
81+ TEST_CASE (simplifyUsing41);
8182
8283 TEST_CASE (simplifyUsing8970);
8384 TEST_CASE (simplifyUsing8971);
@@ -948,6 +949,13 @@ class TestSimplifyUsing : public TestFixture {
948949 ASSERT_EQUALS (expected, tok (code));
949950 }
950951
952+ void simplifyUsing41 () {
953+ const char code[] = " using FpHandler = void(*)(const SourceLocation&);\n "
954+ " inline FpHandler AssertImpl::m_fpHandler = nullptr;\n " ;
955+ const char expected[] = " void ( * AssertImpl :: m_fpHandler ) ( const SourceLocation & ) ; m_fpHandler = nullptr ;" ;
956+ ASSERT_EQUALS (expected, tok (code));
957+ }
958+
951959 void simplifyUsing8970 () {
952960 const char code[] = " using V = std::vector<int>;\n "
953961 " struct A {\n "
You can’t perform that action at this time.
0 commit comments