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()
|
||||
{
|
||||
for (Token *tok = _tokens; tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "[;{}(,] %type% const") &&
|
||||
tok->next()->str().find(":") == std::string::npos &&
|
||||
tok->next()->str() != "operator") {
|
||||
tok->tokAt(2)->str(tok->next()->str());
|
||||
tok->next()->str("const");
|
||||
if (Token::Match(tok, "%type% const") &&
|
||||
(!tok->previous() || Token::Match(tok->previous(), "[;{}(,]")) &&
|
||||
tok->str().find(":") == std::string::npos &&
|
||||
tok->str() != "operator") {
|
||||
tok->next()->str(tok->str());
|
||||
tok->str("const");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4196,7 +4196,7 @@ private:
|
|||
"a = SZ;\n"
|
||||
"}\n";
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -4890,6 +4890,7 @@ private:
|
|||
ASSERT_EQUALS("void foo ( ) { int * const x ; }",
|
||||
tokenizeAndStringify("void foo(){ int * const x;}"));
|
||||
|
||||
ASSERT_EQUALS("const int foo ( ) ;", tokenizeAndStringify("int const foo ();"));
|
||||
}
|
||||
|
||||
void switchCase() {
|
||||
|
|
Loading…
Reference in New Issue