Fix #11693 performance regression (hang) in 2.11dev (#5022)

This commit is contained in:
chrchr-github 2023-04-29 15:17:55 +02:00 committed by GitHub
parent b3016f01a1
commit 043f4fa621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -665,7 +665,7 @@ namespace {
}
for (Token* type = start; Token::Match(type, "%name%|*|&"); type = type->next()) {
if (Token::Match(type, "%name% ;")) {
if (Token::Match(type, "%name% ;") && !type->isStandardType()) {
mRangeType.first = start;
mRangeType.second = type;
mNameToken = type;

View File

@ -3277,7 +3277,8 @@ private:
ASSERT_EQUALS("struct X { } ; std :: vector < X > v ;", tok(code));
}
void simplifyTypedef145() { // #11634
void simplifyTypedef145() {
// #11634
const char* code{};
code = "int typedef i;\n"
"i main() {}\n";
@ -3292,6 +3293,11 @@ private:
code = "struct {} typedef S;\n" // don't crash
"S();\n";
ASSERT_EQUALS("struct S { } ; struct S ( ) ;", tok(code));
// #11693
code = "typedef unsigned char unsigned char;\n" // don't hang
"void f(char);\n";
ASSERT_EQUALS("void f ( char ) ;", tok(code));
}
void simplifyTypedefFunction1() {