Skip to content

Commit 043f4fa

Browse files
Fix #11693 performance regression (hang) in 2.11dev (#5022)
1 parent b3016f0 commit 043f4fa

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ namespace {
665665
}
666666

667667
for (Token* type = start; Token::Match(type, "%name%|*|&"); type = type->next()) {
668-
if (Token::Match(type, "%name% ;")) {
668+
if (Token::Match(type, "%name% ;") && !type->isStandardType()) {
669669
mRangeType.first = start;
670670
mRangeType.second = type;
671671
mNameToken = type;

test/testsimplifytypedef.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3277,7 +3277,8 @@ class TestSimplifyTypedef : public TestFixture {
32773277
ASSERT_EQUALS("struct X { } ; std :: vector < X > v ;", tok(code));
32783278
}
32793279

3280-
void simplifyTypedef145() { // #11634
3280+
void simplifyTypedef145() {
3281+
// #11634
32813282
const char* code{};
32823283
code = "int typedef i;\n"
32833284
"i main() {}\n";
@@ -3292,6 +3293,11 @@ class TestSimplifyTypedef : public TestFixture {
32923293
code = "struct {} typedef S;\n" // don't crash
32933294
"S();\n";
32943295
ASSERT_EQUALS("struct S { } ; struct S ( ) ;", tok(code));
3296+
3297+
// #11693
3298+
code = "typedef unsigned char unsigned char;\n" // don't hang
3299+
"void f(char);\n";
3300+
ASSERT_EQUALS("void f ( char ) ;", tok(code));
32953301
}
32963302

32973303
void simplifyTypedefFunction1() {

0 commit comments

Comments
 (0)