astyle formatting

This commit is contained in:
Daniel Marjamäki 2020-08-23 17:17:33 +02:00
parent ac846b96d1
commit 2bb73840fc
8 changed files with 17 additions and 15 deletions

View File

@ -857,7 +857,7 @@ void CheckStl::invalidContainer()
if (skipVarIds.count(info.tok->varId()) > 0) if (skipVarIds.count(info.tok->varId()) > 0)
return false; return false;
// if (Token::simpleMatch(info.tok->next(), ".")) // if (Token::simpleMatch(info.tok->next(), "."))
// return false; // return false;
if (Token::Match(info.tok->astParent(), "%assign%") && astIsLHS(info.tok)) if (Token::Match(info.tok->astParent(), "%assign%") && astIsLHS(info.tok))
skipVarIds.insert(info.tok->varId()); skipVarIds.insert(info.tok->varId());
if (info.tok->variable()->isReference() && if (info.tok->variable()->isReference() &&
@ -2024,7 +2024,7 @@ void CheckStl::checkDereferenceInvalidIterator2()
} }
// Can iterator point to END or before START? // Can iterator point to END or before START?
for(const ValueFlow::Value& value:tok->values()) { for (const ValueFlow::Value& value:tok->values()) {
if (!printInconclusive && value.isInconclusive()) if (!printInconclusive && value.isInconclusive())
continue; continue;
if (!value.isIteratorValue()) if (!value.isIteratorValue())
@ -2488,7 +2488,7 @@ void CheckStl::knownEmptyContainerLoop()
const Token* contTok = splitTok->astOperand2(); const Token* contTok = splitTok->astOperand2();
if (!contTok) if (!contTok)
continue; continue;
for(const ValueFlow::Value& v:contTok->values()) { for (const ValueFlow::Value& v:contTok->values()) {
if (!v.isKnown()) if (!v.isKnown())
continue; continue;
if (!v.isContainerSizeValue()) if (!v.isContainerSizeValue())

View File

@ -189,7 +189,7 @@ public:
/** @brief Look for loops that can replaced with std algorithms */ /** @brief Look for loops that can replaced with std algorithms */
void useStlAlgorithm(); void useStlAlgorithm();
void knownEmptyContainerLoop(); void knownEmptyContainerLoop();
void checkMutexes(); void checkMutexes();

View File

@ -542,8 +542,7 @@ void execute(const Token *expr,
*result = 0; *result = 0;
else else
*error = true; *error = true;
} } else if (Token::Match(expr->tokAt(-3), "%var% . %name% (")) {
else if (Token::Match(expr->tokAt(-3), "%var% . %name% (")) {
const Token* containerTok = expr->tokAt(-3); const Token* containerTok = expr->tokAt(-3);
if (astIsContainer(containerTok)) { if (astIsContainer(containerTok)) {
Library::Container::Yield yield = containerTok->valueType()->container->getYield(expr->strAt(-1)); Library::Container::Yield yield = containerTok->valueType()->container->getYield(expr->strAt(-1));

View File

@ -1452,10 +1452,10 @@ void SymbolDatabase::createSymbolDatabaseExprIds()
} }
// Apply CSE // Apply CSE
for(const auto& p:exprs) { for (const auto& p:exprs) {
const std::vector<Token*>& tokens = p.second; const std::vector<Token*>& tokens = p.second;
for(Token* tok1:tokens) { for (Token* tok1:tokens) {
for(Token* tok2:tokens) { for (Token* tok2:tokens) {
if (tok1 == tok2) if (tok1 == tok2)
continue; continue;
if (tok1->exprId() == tok2->exprId()) if (tok1->exprId() == tok2->exprId())

View File

@ -484,8 +484,7 @@ static Token * skipDecl(Token *tok)
return tok; return tok;
} else if (Token::Match(vartok, "%var% [:=(]")) { } else if (Token::Match(vartok, "%var% [:=(]")) {
return vartok; return vartok;
} } else if (Token::simpleMatch(vartok, "decltype (")) {
else if (Token::simpleMatch(vartok, "decltype (")) {
return vartok->linkAt(1)->next(); return vartok->linkAt(1)->next();
} }
vartok = vartok->next(); vartok = vartok->next();

View File

@ -5649,8 +5649,10 @@ struct ContainerVariableForwardAnalyzer : VariableForwardAnalyzer {
if (rhs->tokType() == Token::eString) if (rhs->tokType() == Token::eString)
return Action::Read | Action::Write; return Action::Read | Action::Write;
if (rhs->valueType() && rhs->valueType()->container && rhs->valueType()->container->stdStringLike) { if (rhs->valueType() && rhs->valueType()->container && rhs->valueType()->container->stdStringLike) {
if (std::any_of(rhs->values().begin(), rhs->values().end(), [&](const ValueFlow::Value &rhsval) { return rhsval.isKnown() && rhsval.isContainerSizeValue(); })) if (std::any_of(rhs->values().begin(), rhs->values().end(), [&](const ValueFlow::Value &rhsval) {
return Action::Read | Action::Write; return rhsval.isKnown() && rhsval.isContainerSizeValue();
}))
return Action::Read | Action::Write;
} }
} else if (Token::Match(tok, "%name% . %name% (")) { } else if (Token::Match(tok, "%name% . %name% (")) {
Library::Container::Action action = tok->valueType()->container->getAction(tok->strAt(2)); Library::Container::Action action = tok->valueType()->container->getAction(tok->strAt(2));

View File

@ -326,7 +326,9 @@ private:
std::list<ValueFlow::Value> tokenValues(const char code[], const char tokstr[], ValueFlow::Value::ValueType vt, const Settings *s = nullptr) { std::list<ValueFlow::Value> tokenValues(const char code[], const char tokstr[], ValueFlow::Value::ValueType vt, const Settings *s = nullptr) {
std::list<ValueFlow::Value> values = tokenValues(code, tokstr, s); std::list<ValueFlow::Value> values = tokenValues(code, tokstr, s);
values.remove_if([&](const ValueFlow::Value& v) { return v.valueType != vt; }); values.remove_if([&](const ValueFlow::Value& v) {
return v.valueType != vt;
});
return values; return values;
} }

View File

@ -202,7 +202,7 @@ private:
TEST_CASE(setVarIdStructMembers1); TEST_CASE(setVarIdStructMembers1);
TEST_CASE(decltype1); TEST_CASE(decltype1);
TEST_CASE(exprid1); TEST_CASE(exprid1);
} }