Another fix for handling of final/override specifiers in Tokenizer::simplifyKeyword() including a testcase. Ran astyle
This commit is contained in:
parent
355890375c
commit
7416d6add9
|
@ -9308,7 +9308,7 @@ void Tokenizer::simplifyKeyword()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_settings->standards.cpp >= Standards::CPP11) {
|
if (isCPP() && _settings->standards.cpp >= Standards::CPP11) {
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
while (tok->str() == "constexpr") {
|
while (tok->str() == "constexpr") {
|
||||||
tok->deleteThis();
|
tok->deleteThis();
|
||||||
|
@ -9327,16 +9327,21 @@ void Tokenizer::simplifyKeyword()
|
||||||
//if (Token::Match(tok, ") override [{;]"))
|
//if (Token::Match(tok, ") override [{;]"))
|
||||||
if (Token::Match(tok, ") const|override|final")) {
|
if (Token::Match(tok, ") const|override|final")) {
|
||||||
Token* specifier = tok->tokAt(2);
|
Token* specifier = tok->tokAt(2);
|
||||||
while (specifier && Token::Match(specifier, "const|override|final"))
|
while (specifier && Token::Match(specifier, "const|override|final")) {
|
||||||
specifier=specifier->next();
|
specifier=specifier->next();
|
||||||
|
}
|
||||||
if (specifier && Token::Match(specifier, "[{;]")) {
|
if (specifier && Token::Match(specifier, "[{;]")) {
|
||||||
specifier=tok->next();
|
specifier = tok->next();
|
||||||
while (specifier->str()=="override" || specifier->str()=="final")
|
while (!Token::Match(specifier, "[{;]")) {
|
||||||
|
if (specifier->str()=="const")
|
||||||
|
specifier=specifier->next();
|
||||||
|
else
|
||||||
specifier->deleteThis();
|
specifier->deleteThis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tokenizer::simplifyAssignmentInFunctionCall()
|
void Tokenizer::simplifyAssignmentInFunctionCall()
|
||||||
|
|
|
@ -4485,6 +4485,24 @@ private:
|
||||||
const char in4 [] = "struct B final : A { void foo(); };";
|
const char in4 [] = "struct B final : A { void foo(); };";
|
||||||
const char out4 [] = "struct B : A { void foo ( ) ; } ;";
|
const char out4 [] = "struct B : A { void foo ( ) ; } ;";
|
||||||
ASSERT_EQUALS(out4, tokenizeAndStringify(in4));
|
ASSERT_EQUALS(out4, tokenizeAndStringify(in4));
|
||||||
|
|
||||||
|
const char in5 [] = "struct ArrayItemsValidator final {\n"
|
||||||
|
" SchemaError validate() const override {\n"
|
||||||
|
" for (; pos < value.size(); ++pos) {\n"
|
||||||
|
" }\n"
|
||||||
|
" return none;\n"
|
||||||
|
" }\n"
|
||||||
|
"};\n";
|
||||||
|
const char out5 [] =
|
||||||
|
"struct ArrayItemsValidator {\n"
|
||||||
|
"SchemaError validate ( ) const {\n"
|
||||||
|
"for ( ; pos < value . size ( ) ; ++ pos ) {\n"
|
||||||
|
"}\n"
|
||||||
|
"return none ;\n"
|
||||||
|
"}\n"
|
||||||
|
"} ;";
|
||||||
|
|
||||||
|
ASSERT_EQUALS(out5, tokenizeAndStringify(in5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue