astyle formatting

This commit is contained in:
Daniel Marjamäki 2021-05-01 07:35:03 +02:00
parent d3035c246f
commit 07c1f28035
6 changed files with 74 additions and 72 deletions

View File

@ -78,11 +78,10 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
static const Token* skipScopeIdentifiers(const Token* tok) static const Token* skipScopeIdentifiers(const Token* tok)
{ {
if (tok && tok->str() == "::") { if (Token::Match(tok, ":: %name%"))
tok = tok->next(); tok = tok->next();
}
while (Token::Match(tok, "%name% ::") || while (Token::Match(tok, "%name% ::") ||
(Token::Match(tok, "%name% <") && Token::simpleMatch(tok->linkAt(1), "> ::"))) { (Token::Match(tok, "%name% <") && Token::Match(tok->linkAt(1), ">|>> ::"))) {
if (tok->strAt(1) == "::") if (tok->strAt(1) == "::")
tok = tok->tokAt(2); tok = tok->tokAt(2);
else else
@ -2633,10 +2632,7 @@ static bool isUnknownType(const Token* start, const Token* end)
{ {
while (Token::Match(start, "const|volatile")) while (Token::Match(start, "const|volatile"))
start = start->next(); start = start->next();
if (Token::Match(start, ":: %name%")) start = skipScopeIdentifiers(start);
start = start->next();
while (Token::Match(start, "%name% :: %name%"))
start = start->tokAt(2);
if (start->tokAt(1) == end && !start->type() && !start->isStandardType()) if (start->tokAt(1) == end && !start->type() && !start->isStandardType())
return true; return true;
// TODO: Try to deduce the type of the expression // TODO: Try to deduce the type of the expression

View File

@ -10818,23 +10818,27 @@ void Tokenizer::simplifyAttributeList()
Token *attrlist = innerLeftBr->next(); Token *attrlist = innerLeftBr->next();
// scanning between initial (( and )) // scanning between initial (( and ))
while(attrlist != innerRightBr && !newtok) { while (attrlist != innerRightBr && !newtok) {
if (attrlist->str() == ",") { if (attrlist->str() == ",") {
attrlist->insertToken(")"); newInnerRightBr = attrlist->next(); attrlist->insertToken(")");
newInnerRightBr = attrlist->next();
Token::createMutualLinks(innerLeftBr, newInnerRightBr); Token::createMutualLinks(innerLeftBr, newInnerRightBr);
newInnerRightBr->insertToken(")"); newOuterRightBr = newInnerRightBr->next(); newInnerRightBr->insertToken(")");
newOuterRightBr = newInnerRightBr->next();
Token::createMutualLinks(outerLeftBr, newOuterRightBr); Token::createMutualLinks(outerLeftBr, newOuterRightBr);
newOuterRightBr->insertToken(tok->str()); newOuterRightBr->insertToken(tok->str());
newtok = newOuterRightBr->next(); newtok = newOuterRightBr->next();
newtok->insertToken("("); newOuterLeftBr = newtok->next(); newtok->insertToken("(");
newOuterLeftBr = newtok->next();
Token::createMutualLinks(newOuterLeftBr, outerRightBr); Token::createMutualLinks(newOuterLeftBr, outerRightBr);
newOuterLeftBr->insertToken("("); newInnerLeftBr = newOuterLeftBr->next(); newOuterLeftBr->insertToken("(");
newInnerLeftBr = newOuterLeftBr->next();
Token::createMutualLinks(newInnerLeftBr, innerRightBr); Token::createMutualLinks(newInnerLeftBr, innerRightBr);
tok = newtok; tok = newtok;
@ -10853,7 +10857,7 @@ void Tokenizer::simplifyAttributeList()
// passing to next token just after __attribute__ ((...)) // passing to next token just after __attribute__ ((...))
// (there may be another __attribute__ ((...)) ) // (there may be another __attribute__ ((...)) )
if(!newtok) { if (!newtok) {
tok = outerRightBr->next(); tok = outerRightBr->next();
} }
} }

View File

@ -2799,7 +2799,9 @@ static std::vector<LifetimeToken> getLifetimeTokens(const Token* tok,
std::vector<LifetimeToken> getLifetimeTokens(const Token* tok, bool escape, ValueFlow::Value::ErrorPath errorPath) std::vector<LifetimeToken> getLifetimeTokens(const Token* tok, bool escape, ValueFlow::Value::ErrorPath errorPath)
{ {
return getLifetimeTokens(tok, escape, std::move(errorPath), [](const Token*) { return false; }); return getLifetimeTokens(tok, escape, std::move(errorPath), [](const Token*) {
return false;
});
} }
bool hasLifetimeToken(const Token* tok, const Token* lifetime) bool hasLifetimeToken(const Token* tok, const Token* lifetime)