From 6ebba1fb81db92765ce640929b76cda8afac0a20 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 16 Feb 2026 10:55:42 +0100 Subject: [PATCH 1/7] Update tokenlist.cpp --- lib/tokenlist.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 1138b410ddd..5592d8aae6a 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1787,11 +1787,11 @@ static Token * createAstAtToken(Token *tok) } } - if (Token::Match(tok, "%type% %name%|*|&|&&|::") && !Token::Match(tok, "return|new|delete")) { + if (Token::Match(tok, "%type%| %name%|*|&|&&|::") && !Token::Match(tok, "return|new|delete")) { int typecount = 0; Token *typetok = tok; while (Token::Match(typetok, "%type%|::|*|&|&&|<")) { - if (typetok->isName() && !Token::simpleMatch(typetok->previous(), "::")) + if (typetok->isName() && (!Token::simpleMatch(typetok->previous(), "::") || tok->str() == "::")) typecount++; if (typetok->str() == "<") { if (Token* closing = typetok->findClosingBracket()) { @@ -1811,7 +1811,7 @@ static Token * createAstAtToken(Token *tok) !Token::Match(tok, "return|throw") && Token::Match(typetok->previous(), "%name% ( !!*") && typetok->previous()->varId() == 0 && - !typetok->previous()->isKeyword() && + (!typetok->previous()->isKeyword() || typetok->previous()->isOperatorKeyword()) && (skipMethodDeclEnding(typetok->link()) || Token::Match(typetok->link(), ") ;|{"))) return typetok; } From 65c631720ed3ff8a6706faa52e0b112f45c13919 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 16 Feb 2026 10:58:19 +0100 Subject: [PATCH 2/7] Update testtokenize.cpp --- test/testtokenize.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index eff4a8d44f2..ccf4177edb6 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6400,8 +6400,13 @@ class TestTokenizer : public TestFixture { Z3 }; + enum class ListSimplification : std::uint8_t { + Partial, + Full + }; + template - std::string testAst(const char (&data)[size], AstStyle style = AstStyle::Simple) { + std::string testAst(const char (&data)[size], AstStyle style = AstStyle::Simple, ListSimplification ls = ListSimplification::Partial) { // tokenize given code.. TokenList tokenlist{settings0, Standards::Language::CPP}; tokenlist.appendFileIfNew("test.cpp"); @@ -6409,13 +6414,18 @@ class TestTokenizer : public TestFixture { return "ERROR"; TokenizerTest tokenizer(std::move(tokenlist), *this); - tokenizer.combineStringAndCharLiterals(); - tokenizer.combineOperators(); - tokenizer.simplifySpaceshipOperator(); - tokenizer.createLinks(); - tokenizer.createLinks2(); - tokenizer.simplifyCAlternativeTokens(); - tokenizer.list.front()->assignIndexes(); + if (ls == ListSimplification::Partial) { + tokenizer.combineStringAndCharLiterals(); + tokenizer.combineOperators(); + tokenizer.simplifySpaceshipOperator(); + tokenizer.createLinks(); + tokenizer.createLinks2(); + tokenizer.simplifyCAlternativeTokens(); + tokenizer.simplifyOperatorName(); + tokenizer.list.front()->assignIndexes(); + } else { // Full + tokenizer.simplifyTokens1(""); + } // set varid.. for (Token *tok = tokenizer.list.front(); tok; tok = tok->next()) { @@ -7408,6 +7418,11 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("A0U=", testAst("enum myclass : unsigned char { A = 0U, };")); } + void astfuncdecl() { + ASSERT_EQUALS("", testAst("bool operator==(const S& a, const S& b);", AstStyle::Simple, ListSimplification::Full)); + ASSERT_EQUALS("", testAst("::int32_t f() {}")); + } + #define isStartOfExecutableScope(offset, code) isStartOfExecutableScope_(offset, code, __FILE__, __LINE__) template bool isStartOfExecutableScope_(int offset, const char (&code)[size], const char* file, int line) { From 01f44aba7eb2e5964fc53571723f5c3bb506c25a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 16 Feb 2026 11:03:13 +0100 Subject: [PATCH 3/7] Update testtokenize.cpp --- test/testtokenize.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index ccf4177edb6..fbe0ca1e675 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6421,7 +6421,6 @@ class TestTokenizer : public TestFixture { tokenizer.createLinks(); tokenizer.createLinks2(); tokenizer.simplifyCAlternativeTokens(); - tokenizer.simplifyOperatorName(); tokenizer.list.front()->assignIndexes(); } else { // Full tokenizer.simplifyTokens1(""); From 75f8dfd3cc1b03bb4954968fd0868fd34dc8fe4d Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Mon, 16 Feb 2026 19:44:55 +0100 Subject: [PATCH 4/7] Fix --- lib/symboldatabase.cpp | 2 +- lib/tokenlist.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index f5ffa4e1604..7a00f5fb2e4 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -714,7 +714,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes() } // function prototype? else if (declEnd && declEnd->str() == ";") { - if (tok->astParent() && tok->astParent()->str() == "::" && + if ((Token::simpleMatch(tok->tokAt(-1), "::") || (tok->tokAt(-2) && Token::simpleMatch(tok->tokAt(-2), ":: ~"))) && Token::Match(declEnd->previous(), "default|delete")) { addClassFunction(scope, tok, argStart); continue; diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 5592d8aae6a..60af44ec98e 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1787,7 +1787,7 @@ static Token * createAstAtToken(Token *tok) } } - if (Token::Match(tok, "%type%| %name%|*|&|&&|::") && !Token::Match(tok, "return|new|delete")) { + if (Token::Match(tok, "%type% %name%|*|&|&&|::") && !Token::Match(tok, "return|new|delete")) { int typecount = 0; Token *typetok = tok; while (Token::Match(typetok, "%type%|::|*|&|&&|<")) { From 07cc7c3626fd56984d6012918b5b4aae9d0de357 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Mon, 16 Feb 2026 21:20:09 +0100 Subject: [PATCH 5/7] Fix --- lib/tokenlist.cpp | 7 ++++--- test/testtokenize.cpp | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 60af44ec98e..775c4554770 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1787,11 +1787,12 @@ static Token * createAstAtToken(Token *tok) } } - if (Token::Match(tok, "%type% %name%|*|&|&&|::") && !Token::Match(tok, "return|new|delete")) { - int typecount = 0; + if ((Token::Match(tok, "%type% %name%|*|&|&&|::") && !Token::Match(tok, "return|new|delete")) || + (Token::Match(tok, ":: %tyoe%") && !tok->next()->isKeyword())) { + int typecount = tok->str() == "::" ? 1 : 0; Token *typetok = tok; while (Token::Match(typetok, "%type%|::|*|&|&&|<")) { - if (typetok->isName() && (!Token::simpleMatch(typetok->previous(), "::") || tok->str() == "::")) + if (typetok->isName() && !Token::simpleMatch(typetok->previous(), "::")) typecount++; if (typetok->str() == "<") { if (Token* closing = typetok->findClosingBracket()) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index fbe0ca1e675..5cd508c5359 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -425,6 +425,7 @@ class TestTokenizer : public TestFixture { TEST_CASE(astrvaluedecl); TEST_CASE(astorkeyword); TEST_CASE(astenumdecl); + TEST_CASE(astfuncdecl); TEST_CASE(startOfExecutableScope); @@ -7419,7 +7420,7 @@ class TestTokenizer : public TestFixture { void astfuncdecl() { ASSERT_EQUALS("", testAst("bool operator==(const S& a, const S& b);", AstStyle::Simple, ListSimplification::Full)); - ASSERT_EQUALS("", testAst("::int32_t f() {}")); + ASSERT_EQUALS("", testAst("::int32_t f();")); } #define isStartOfExecutableScope(offset, code) isStartOfExecutableScope_(offset, code, __FILE__, __LINE__) From f3195517da7eef2e9d03529a3008bf006e9d14b5 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Mon, 16 Feb 2026 21:36:34 +0100 Subject: [PATCH 6/7] Fix --- lib/tokenlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 775c4554770..aca098a99ae 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1788,7 +1788,7 @@ static Token * createAstAtToken(Token *tok) } if ((Token::Match(tok, "%type% %name%|*|&|&&|::") && !Token::Match(tok, "return|new|delete")) || - (Token::Match(tok, ":: %tyoe%") && !tok->next()->isKeyword())) { + (Token::Match(tok, ":: %type%") && !tok->next()->isKeyword())) { int typecount = tok->str() == "::" ? 1 : 0; Token *typetok = tok; while (Token::Match(typetok, "%type%|::|*|&|&&|<")) { From 51e223cb11edac560553fb18f93dfbfc7ab5584f Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Mon, 16 Feb 2026 22:27:56 +0100 Subject: [PATCH 7/7] Fix --- lib/symboldatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 7a00f5fb2e4..340b8e246e0 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -714,7 +714,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes() } // function prototype? else if (declEnd && declEnd->str() == ";") { - if ((Token::simpleMatch(tok->tokAt(-1), "::") || (tok->tokAt(-2) && Token::simpleMatch(tok->tokAt(-2), ":: ~"))) && + if ((Token::simpleMatch(tok->tokAt(-1), "::") || (tok->tokAt(-1) && Token::simpleMatch(tok->tokAt(-2), ":: ~"))) && Token::Match(declEnd->previous(), "default|delete")) { addClassFunction(scope, tok, argStart); continue;