Tokenizer::simplifyGoto: process also derived class/structs.
This commit is contained in:
parent
b0e4dc3ab8
commit
a7029291fd
|
@ -7181,11 +7181,25 @@ void Tokenizer::simplifyGoto()
|
||||||
if (tok->str() == "(" || tok->str() == "[")
|
if (tok->str() == "(" || tok->str() == "[")
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
|
|
||||||
else if (tok->str() == "{") {
|
else if (Token::Match(tok, "class|namespace|struct|union %type% :|{")) {
|
||||||
if (Token::Match(tok->tokAt(-2),"class|namespace|struct|union %var% {") ||
|
tok = tok->tokAt(2);
|
||||||
Token::Match(tok->previous(),"namespace|struct|union {"))
|
while (tok && !Token::Match(tok, "[;{=]"))
|
||||||
|
tok = tok->next();
|
||||||
|
if (tok && tok->str() == "{")
|
||||||
++indentspecial;
|
++indentspecial;
|
||||||
else if ((!beginfunction && !indentlevel) ||
|
else if (!tok)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (Token::Match(tok, "namespace|struct|union {")) {
|
||||||
|
tok = tok->next();
|
||||||
|
++indentspecial;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (tok->str() == "{") {
|
||||||
|
if ((!beginfunction && !indentlevel) ||
|
||||||
(tok->previous() && tok->previous()->str() == "="))
|
(tok->previous() && tok->previous()->str() == "="))
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
else
|
else
|
||||||
|
|
|
@ -3130,6 +3130,54 @@ private:
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(expected, tok(code));
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const char code[] = "class A"
|
||||||
|
"{"
|
||||||
|
" int a; "
|
||||||
|
" double b; "
|
||||||
|
" A() : b(3.22)"
|
||||||
|
" {"
|
||||||
|
" goto source ;"
|
||||||
|
" bleeh;"
|
||||||
|
" source:"
|
||||||
|
" a = 322;"
|
||||||
|
" }"
|
||||||
|
"}"
|
||||||
|
"class A1 : public A"
|
||||||
|
"{"
|
||||||
|
" int a1; "
|
||||||
|
" double b1; "
|
||||||
|
" A1() : b1(3.22)"
|
||||||
|
" {"
|
||||||
|
" goto source1 ;"
|
||||||
|
" bleeh1;"
|
||||||
|
" source1:"
|
||||||
|
" a = 322;"
|
||||||
|
" }"
|
||||||
|
"}";
|
||||||
|
const char expected[] = "class A "
|
||||||
|
"{"
|
||||||
|
" int a ;"
|
||||||
|
" double b ;"
|
||||||
|
" A ( ) : b ( 3.22 )"
|
||||||
|
" {"
|
||||||
|
" a = 322 ;"
|
||||||
|
" return ;"
|
||||||
|
" } "
|
||||||
|
"} "
|
||||||
|
"class A1 : public A "
|
||||||
|
"{"
|
||||||
|
" int a1 ;"
|
||||||
|
" double b1 ;"
|
||||||
|
" A1 ( ) : b1 ( 3.22 )"
|
||||||
|
" {"
|
||||||
|
" a = 322 ;"
|
||||||
|
" return ;"
|
||||||
|
" } "
|
||||||
|
"}";
|
||||||
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void flowControl() {
|
void flowControl() {
|
||||||
|
|
Loading…
Reference in New Issue