Use early continue

This commit is contained in:
Daniel Marjamäki 2018-09-09 20:58:30 +02:00
parent 404eb6c746
commit 1bb1c4cc8e
1 changed files with 42 additions and 42 deletions

View File

@ -9766,56 +9766,56 @@ void Tokenizer::simplifyOperatorName()
return; return;
for (Token *tok = list.front(); tok; tok = tok->next()) { for (Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->str() == "operator") { if (tok->str() != "operator")
// operator op continue;
std::string op; // operator op
Token *par = tok->next(); std::string op;
bool done = false; Token *par = tok->next();
while (!done && par) { bool done = false;
done = true; while (!done && par) {
if (par->isName()) { done = true;
if (par->isName()) {
op += par->str();
par = par->next();
// merge namespaces eg. 'operator std :: string () const {'
if (Token::Match(par, ":: %name%|%op%|.")) {
op += par->str(); op += par->str();
par = par->next(); par = par->next();
// merge namespaces eg. 'operator std :: string () const {'
if (Token::Match(par, ":: %name%|%op%|.")) {
op += par->str();
par = par->next();
}
done = false;
} }
if (Token::Match(par, ".|%op%|,")) { done = false;
}
if (Token::Match(par, ".|%op%|,")) {
op += par->str();
par = par->next();
done = false;
}
if (Token::simpleMatch(par, "[ ]")) {
op += "[]";
par = par->tokAt(2);
done = false;
}
if (Token::Match(par, "( *| )")) {
// break out and simplify..
if (operatorEnd(par->next()))
break;
while (par->str() != ")") {
op += par->str(); op += par->str();
par = par->next(); par = par->next();
done = false;
}
if (Token::simpleMatch(par, "[ ]")) {
op += "[]";
par = par->tokAt(2);
done = false;
}
if (Token::Match(par, "( *| )")) {
// break out and simplify..
if (operatorEnd(par->next()))
break;
while (par->str() != ")") {
op += par->str();
par = par->next();
}
op += ")";
par = par->next();
done = false;
} }
op += ")";
par = par->next();
done = false;
} }
if (par && operatorEnd(par->link())) {
tok->str("operator" + op);
Token::eraseTokens(tok, par);
}
if (!op.empty())
tok->isOperatorKeyword(true);
} }
if (par && operatorEnd(par->link())) {
tok->str("operator" + op);
Token::eraseTokens(tok, par);
}
if (!op.empty())
tok->isOperatorKeyword(true);
} }
if (mSettings->debugwarnings) { if (mSettings->debugwarnings) {