Tokenizer::simplifyConst : handle also '%type% const' when the 'type' token is the first one in the list.
This commit is contained in:
parent
a363749a17
commit
2fc067e6ab
|
@ -8921,11 +8921,12 @@ void Tokenizer::simplifyComparisonOrder()
|
||||||
void Tokenizer::simplifyConst()
|
void Tokenizer::simplifyConst()
|
||||||
{
|
{
|
||||||
for (Token *tok = _tokens; tok; tok = tok->next()) {
|
for (Token *tok = _tokens; tok; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "[;{}(,] %type% const") &&
|
if (Token::Match(tok, "%type% const") &&
|
||||||
tok->next()->str().find(":") == std::string::npos &&
|
(!tok->previous() || Token::Match(tok->previous(), "[;{}(,]")) &&
|
||||||
tok->next()->str() != "operator") {
|
tok->str().find(":") == std::string::npos &&
|
||||||
tok->tokAt(2)->str(tok->next()->str());
|
tok->str() != "operator") {
|
||||||
tok->next()->str("const");
|
tok->next()->str(tok->str());
|
||||||
|
tok->str("const");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4196,7 +4196,7 @@ private:
|
||||||
"a = SZ;\n"
|
"a = SZ;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"static const char str [ 5 ] = \"abcd\" ;\n\nvoid f ( ) {\na = 5 ;\n}";
|
"const static char str [ 5 ] = \"abcd\" ;\n\nvoid f ( ) {\na = 5 ;\n}";
|
||||||
ASSERT_EQUALS(expected, tokenizeAndStringify(code,true));
|
ASSERT_EQUALS(expected, tokenizeAndStringify(code,true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4890,6 +4890,7 @@ private:
|
||||||
ASSERT_EQUALS("void foo ( ) { int * const x ; }",
|
ASSERT_EQUALS("void foo ( ) { int * const x ; }",
|
||||||
tokenizeAndStringify("void foo(){ int * const x;}"));
|
tokenizeAndStringify("void foo(){ int * const x;}"));
|
||||||
|
|
||||||
|
ASSERT_EQUALS("const int foo ( ) ;", tokenizeAndStringify("int const foo ();"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchCase() {
|
void switchCase() {
|
||||||
|
|
Loading…
Reference in New Issue