Some small refactorizations to tokenize.cpp
This commit is contained in:
parent
11be2f79a6
commit
ebae879cf9
|
@ -1914,10 +1914,8 @@ void Tokenizer::combineStrings()
|
||||||
|
|
||||||
tok->str(simplifyString(tok->str()));
|
tok->str(simplifyString(tok->str()));
|
||||||
while (tok->next() && tok->next()->tokType() == Token::eString) {
|
while (tok->next() && tok->next()->tokType() == Token::eString) {
|
||||||
tok->next()->str(simplifyString(tok->next()->str()));
|
|
||||||
|
|
||||||
// Two strings after each other, combine them
|
// Two strings after each other, combine them
|
||||||
tok->concatStr(tok->next()->str());
|
tok->concatStr(simplifyString(tok->next()->str()));
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4334,6 +4332,7 @@ void Tokenizer::removeRedundantSemicolons()
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (tok->str() == "(") {
|
if (tok->str() == "(") {
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (Token::simpleMatch(tok, "; ;")) {
|
if (Token::simpleMatch(tok, "; ;")) {
|
||||||
|
@ -4962,7 +4961,7 @@ void Tokenizer::simplifyCasts()
|
||||||
void Tokenizer::simplifyFunctionParameters()
|
void Tokenizer::simplifyFunctionParameters()
|
||||||
{
|
{
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "{|[|(")) {
|
if (tok->link() && Token::Match(tok, "{|[|(")) {
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5243,7 +5242,7 @@ bool Tokenizer::simplifyFunctionReturn()
|
||||||
else if (Token::Match(tok, "%name% ( ) { return %bool%|%char%|%num%|%str% ; }") && tok->strAt(-1) != "::") {
|
else if (Token::Match(tok, "%name% ( ) { return %bool%|%char%|%num%|%str% ; }") && tok->strAt(-1) != "::") {
|
||||||
const Token* const any = tok->tokAt(5);
|
const Token* const any = tok->tokAt(5);
|
||||||
|
|
||||||
const std::string pattern("(|[|=|%cop% " + tok->str() + " ( ) ;|]|)|%cop%");
|
const std::string pattern("(|[|=|return|%op% " + tok->str() + " ( ) ;|]|)|%cop%");
|
||||||
for (Token *tok2 = list.front(); tok2; tok2 = tok2->next()) {
|
for (Token *tok2 = list.front(); tok2; tok2 = tok2->next()) {
|
||||||
if (Token::Match(tok2, pattern.c_str())) {
|
if (Token::Match(tok2, pattern.c_str())) {
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
|
@ -7828,7 +7827,6 @@ void Tokenizer::simplifyStd()
|
||||||
if (isC())
|
if (isC())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (tok->str() != "std")
|
if (tok->str() != "std")
|
||||||
continue;
|
continue;
|
||||||
|
@ -8795,7 +8793,6 @@ void Tokenizer::simplifyErrNoInWhile()
|
||||||
|
|
||||||
// tok is invalid.. move to endpar
|
// tok is invalid.. move to endpar
|
||||||
tok = endpar;
|
tok = endpar;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue