Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Feb 28, 2024
1 parent f912734 commit dcab1cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2844,14 +2844,15 @@ bool Tokenizer::simplifyUsing()
for (Token* tok = list.front(); tok; tok = tok->next()) {
if (!Token::Match(tok, "using ::| %name% ::"))
continue;
Token* end = tok->next();
Token* end = tok->tokAt(3);
while (end && end->str() != ";")
end = end->next();
if (!end)
continue;
if (end->tokAt(-1)->isKeyword() || end->tokAt(-2)->isKeyword() || end->strAt(-1) == "...") // e.g. operator=
if (!end->tokAt(-1)->isNameOnly()) // e.g. operator=
continue;
tok->insertToken(end->strAt(-1))->insertToken("=");
tok = end;
}

const unsigned int maxReplacementTokens = 1000; // limit the number of tokens we replace
Expand Down
5 changes: 2 additions & 3 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2508,9 +2508,8 @@ class TestVarID : public TestFixture {

void varid_using() {
// #3648
const char code[] = "using std::size_t;\n"
"size_t s;";
const char expected[] = "2: unsigned long s@1 ;\n";
const char code[] = "using std::size_t;";
const char expected[] = "1: using unsigned long ;\n";
ASSERT_EQUALS(expected, tokenize(code));
}

Expand Down

0 comments on commit dcab1cd

Please sign in to comment.