Skip to content

Commit 6e46c6b

Browse files
Fix #14790 Performance regression (hang) in 2.21dev (#8587)
1 parent 594b442 commit 6e46c6b

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

lib/tokenlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ static bool iscpp11init_impl(const Token * const tok)
609609
if (Token::Match(nameToken, "]|*")) {
610610
const Token* tok2 = nameToken;
611611
if (tok2->link()) {
612-
while (tok2 && tok2->link())
612+
while (tok2 && precedes(tok2->link(), nameToken))
613613
tok2 = tok2->link()->previous();
614614
}
615615
else

test/testtokenize.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8712,6 +8712,10 @@ class TestTokenizer : public TestFixture {
87128712
"{ 1",
87138713
Token::Cpp11init::CPP11INIT);
87148714

8715+
testIsCpp11init("void f() { g([] { if (int x = 1; x) {} }); }", // #14790
8716+
"{ int",
8717+
Token::Cpp11init::NOINIT); // don't hang
8718+
87158719
ASSERT_NO_THROW(tokenizeAndStringify("template<typename U> struct X {};\n" // don't crash
87168720
"template<typename T> auto f(T t) -> X<decltype(t + 1)> {}\n"));
87178721
ASSERT_EQUALS("[test.cpp:2:22]: (debug) auto token with no type. [autoNoType]\n", errout_str());

0 commit comments

Comments
 (0)