Fixed #7119 (Cppcheck hangs with 100% CPU load in Tokenizer::copyTokens (invalidcode))
This commit is contained in:
parent
4eaf585dd2
commit
8a9e068129
|
@ -1237,6 +1237,8 @@ void Tokenizer::simplifyTypedef()
|
||||||
bool inOperator = false;
|
bool inOperator = false;
|
||||||
bool inSizeof = false;
|
bool inSizeof = false;
|
||||||
|
|
||||||
|
const bool sameStartEnd = (typeStart == typeEnd);
|
||||||
|
|
||||||
// check for derived class: class A : some_typedef {
|
// check for derived class: class A : some_typedef {
|
||||||
const bool isDerived = Token::Match(tok2->previous(), "public|protected|private %type% {|,");
|
const bool isDerived = Token::Match(tok2->previous(), "public|protected|private %type% {|,");
|
||||||
|
|
||||||
|
@ -1274,6 +1276,9 @@ void Tokenizer::simplifyTypedef()
|
||||||
if (typeStart->str() == "struct" && Token::Match(tok2, "%name% ::"))
|
if (typeStart->str() == "struct" && Token::Match(tok2, "%name% ::"))
|
||||||
typeStart = typeStart->next();
|
typeStart = typeStart->next();
|
||||||
|
|
||||||
|
if (sameStartEnd)
|
||||||
|
typeEnd = typeStart;
|
||||||
|
|
||||||
// start substituting at the typedef name by replacing it with the type
|
// start substituting at the typedef name by replacing it with the type
|
||||||
tok2->str(typeStart->str());
|
tok2->str(typeStart->str());
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,7 @@ private:
|
||||||
TEST_CASE(garbageCode156); // #7120
|
TEST_CASE(garbageCode156); // #7120
|
||||||
TEST_CASE(garbageCode157); // #7131
|
TEST_CASE(garbageCode157); // #7131
|
||||||
TEST_CASE(garbageCode158); // #3238
|
TEST_CASE(garbageCode158); // #3238
|
||||||
|
TEST_CASE(garbageCode159); // #7119
|
||||||
|
|
||||||
TEST_CASE(garbageValueFlow);
|
TEST_CASE(garbageValueFlow);
|
||||||
TEST_CASE(garbageSymbolDatabase);
|
TEST_CASE(garbageSymbolDatabase);
|
||||||
|
@ -1246,6 +1247,10 @@ private:
|
||||||
checkCode("__FBSDID(\"...\");\n");
|
checkCode("__FBSDID(\"...\");\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void garbageCode159() { // #7119
|
||||||
|
checkCode("({}typedef typename x;typename x!){({{}()})}"); // dont hang
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void garbageValueFlow() {
|
void garbageValueFlow() {
|
||||||
// #6089
|
// #6089
|
||||||
|
|
Loading…
Reference in New Issue