astyle formatting

[ci skip]
This commit is contained in:
Daniel Marjamäki 2021-01-25 22:51:50 +01:00
parent 0f8f207719
commit 987c8a854e
4 changed files with 19 additions and 23 deletions

View File

@ -22,8 +22,7 @@ struct ForwardTraversal {
bool analyzeTerminate;
Terminate terminate = Terminate::None;
Progress Break(Terminate t = Terminate::None)
{
Progress Break(Terminate t = Terminate::None) {
if ((!analyzeOnly || analyzeTerminate) && t != Terminate::None)
terminate = t;
return Progress::Break;
@ -237,8 +236,7 @@ struct ForwardTraversal {
return ft;
}
std::vector<ForwardTraversal> tryForkScope(Token* endBlock, bool isModified = false)
{
std::vector<ForwardTraversal> tryForkScope(Token* endBlock, bool isModified = false) {
if (analyzer->updateScope(endBlock, isModified)) {
ForwardTraversal ft = forkScope(endBlock);
return {ft};
@ -251,7 +249,7 @@ struct ForwardTraversal {
}
bool hasInnerReturnScope(const Token* start, const Token* end) const {
for(const Token* tok=start;tok != end;tok = tok->previous()) {
for (const Token* tok=start; tok != end; tok = tok->previous()) {
if (Token::simpleMatch(tok, "}")) {
const Token* ftok = nullptr;
bool r = isReturnScope(tok, &settings->library, &ftok);

View File

@ -116,8 +116,7 @@ struct ReverseTraversal {
return nullptr;
}
void traverse(Token* start, const Token* end = nullptr)
{
void traverse(Token* start, const Token* end = nullptr) {
if (start == end)
return;
for (Token* tok = start->previous(); tok != end; tok = tok->previous()) {

View File

@ -3736,7 +3736,7 @@ static ValueFlow::Value makeConditionValue(long long val, const Token* condTok,
v.errorPath.emplace_back(condTok, "Assuming condition '" + condTok->expressionString() + "' is false");
return v;
}
//
//
static void valueFlowConditionExpressions(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
{
for (const Scope * scope : symboldatabase->functionScopes) {
@ -3770,7 +3770,7 @@ static void valueFlowConditionExpressions(TokenList *tokenlist, SymbolDatabase*
std::vector<const Token*> args = astFlatten(condTok, "&&");
conds.insert(conds.end(), args.begin(), args.end());
}
for(const Token* condTok2:conds) {
for (const Token* condTok2:conds) {
ExpressionAnalyzer a1(condTok2, makeConditionValue(1, condTok2, true), tokenlist);
valueFlowGenericForward(startTok, startTok->link(), a1, settings);
@ -3788,7 +3788,7 @@ static void valueFlowConditionExpressions(TokenList *tokenlist, SymbolDatabase*
// Check else block
if (Token::simpleMatch(startTok->link(), "} else {")) {
startTok = startTok->link()->tokAt(2);
for(const Token* condTok2:conds) {
for (const Token* condTok2:conds) {
ExpressionAnalyzer a1(condTok2, makeConditionValue(0, condTok2, false), tokenlist);
valueFlowGenericForward(startTok, startTok->link(), a1, settings);
@ -3799,7 +3799,7 @@ static void valueFlowConditionExpressions(TokenList *tokenlist, SymbolDatabase*
// Check if the block terminates early
if (isEscapeScope(blockTok, tokenlist)) {
for(const Token* condTok2:conds) {
for (const Token* condTok2:conds) {
ExpressionAnalyzer a1(condTok2, makeConditionValue(0, condTok2, false), tokenlist);
valueFlowGenericForward(startTok->link()->next(), scope->bodyEnd, a1, settings);
@ -3827,8 +3827,10 @@ static void valueFlowForwardAssign(Token* const tok,
values.remove_if(std::mem_fn(&ValueFlow::Value::isLifetimeValue));
}
if (std::all_of(
vars.begin(), vars.end(), [&](const Variable* var) { return !var->isPointer() && !var->isSmartPointer(); }))
values.remove_if(std::mem_fn(&ValueFlow::Value::isTokValue));
vars.begin(), vars.end(), [&](const Variable* var) {
return !var->isPointer() && !var->isSmartPointer();
}))
values.remove_if(std::mem_fn(&ValueFlow::Value::isTokValue));
if (tok->astParent()) {
for (ValueFlow::Value& value : values) {
const std::string info = "Assignment '" + tok->astParent()->expressionString() + "', assigned value is " + value.infoString();
@ -4194,9 +4196,9 @@ struct ConditionHandler {
if (isExpressionChanged(cond.vartok, start, end, settings, tokenlist->isCPP())) {
// If its reassigned in loop then analyze from the end
if (!Token::Match(tok, "%assign%|++|--") &&
findExpression(cond.vartok->exprId(), start, end, [&](const Token* tok2) {
return Token::Match(tok2->astParent(), "%assign%") && astIsLHS(tok2);
})) {
findExpression(cond.vartok->exprId(), start, end, [&](const Token* tok2) {
return Token::Match(tok2->astParent(), "%assign%") && astIsLHS(tok2);
})) {
// Start at the end of the loop body
Token* bodyTok = top->link()->next();
reverse(bodyTok->link(), bodyTok, cond.vartok, values, tokenlist, settings);
@ -4458,8 +4460,7 @@ struct SimpleConditionHandler : ConditionHandler {
const Token* exprTok,
const std::list<ValueFlow::Value>& values,
TokenList* tokenlist,
const Settings* settings) const OVERRIDE
{
const Settings* settings) const OVERRIDE {
return valueFlowReverse(start, endToken, exprTok, values, tokenlist, settings);
}
@ -6179,8 +6180,7 @@ struct ContainerConditionHandler : ConditionHandler {
const Token* exprTok,
const std::list<ValueFlow::Value>& values,
TokenList* tokenlist,
const Settings* settings) const OVERRIDE
{
const Settings* settings) const OVERRIDE {
if (values.empty())
return;
if (!exprTok->variable())

View File

@ -2137,8 +2137,7 @@ private:
ASSERT_EQUALS("", errout.str());
}
void nullpointer69()
{
void nullpointer69() {
check("void f(const Scope *scope) {\n"
" if (scope->definedType) {}\n"
" while (scope) {\n"
@ -2212,7 +2211,7 @@ private:
"}\n");
ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:10]: (warning) Either the condition 'first' is redundant or there is possible null pointer dereference: first.\n", errout.str());
}
void nullpointer_addressOf() { // address of
check("void f() {\n"
" struct X *x = 0;\n"