From 1ec7397c2177c3f61e3a2ddc1c175029b3bd06c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 1 Aug 2021 14:05:30 +0200 Subject: [PATCH] astyle formatting [ci skip] --- lib/programmemory.cpp | 3 +-- lib/valueflow.cpp | 55 ++++++++++++++++++++---------------------- lib/valueflow.h | 4 ++- test/testother.cpp | 4 +-- test/teststl.cpp | 3 +-- test/testvalueflow.cpp | 4 ++- 6 files changed, 36 insertions(+), 37 deletions(-) diff --git a/lib/programmemory.cpp b/lib/programmemory.cpp index 7b6b22678..66f8bd109 100644 --- a/lib/programmemory.cpp +++ b/lib/programmemory.cpp @@ -725,8 +725,7 @@ void execute(const Token* expr, *result = 0; else *error = true; - } - else if (expr->str() == "(" && expr->isCast()) { + } else if (expr->str() == "(" && expr->isCast()) { if (Token::simpleMatch(expr->previous(), ">") && expr->previous()->link()) execute(expr->astOperand2(), programMemory, result, error); else diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index c54289cee..98097625f 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -2590,10 +2590,10 @@ static Analyzer::Result valueFlowForward(Token* startToken, } static Analyzer::Result valueFlowForward(Token* top, - const Token* exprTok, - const std::list& values, - TokenList* const tokenlist, - const Settings* settings) + const Token* exprTok, + const std::list& values, + TokenList* const tokenlist, + const Settings* settings) { Analyzer::Result result{}; for (const ValueFlow::Value& v : values) { @@ -4040,13 +4040,13 @@ static void valueFlowSymbolic(TokenList* tokenlist, SymbolDatabase* symboldataba ValueFlow::Value rhs = makeSymbolic(tok->astOperand2()); rhs.errorPath.emplace_back(tok, tok->astOperand1()->expressionString() + " is assigned '" + - tok->astOperand2()->expressionString() + "' here."); + tok->astOperand2()->expressionString() + "' here."); valueFlowForward(start, end, tok->astOperand1(), {rhs}, tokenlist, tokenlist->getSettings()); ValueFlow::Value lhs = makeSymbolic(tok->astOperand1()); lhs.errorPath.emplace_back(tok, tok->astOperand1()->expressionString() + " is assigned '" + - tok->astOperand2()->expressionString() + "' here."); + tok->astOperand2()->expressionString() + "' here."); valueFlowForward(start, end, tok->astOperand2(), {lhs}, tokenlist, tokenlist->getSettings()); } } @@ -4071,16 +4071,16 @@ static void valueFlowSymbolicInfer(TokenList* tokenlist, SymbolDatabase* symbold MathLib::bigint rhsvalue = 0; const ValueFlow::Value* rhs = - ValueFlow::findValue(tok->astOperand2()->values(), nullptr, [&](const ValueFlow::Value& v) { - return v.isSymbolicValue() && v.tokvalue && v.tokvalue->exprId() == tok->astOperand1()->exprId(); - }); + ValueFlow::findValue(tok->astOperand2()->values(), nullptr, [&](const ValueFlow::Value& v) { + return v.isSymbolicValue() && v.tokvalue && v.tokvalue->exprId() == tok->astOperand1()->exprId(); + }); if (rhs) rhsvalue = rhs->intvalue; MathLib::bigint lhsvalue = 0; const ValueFlow::Value* lhs = - ValueFlow::findValue(tok->astOperand1()->values(), nullptr, [&](const ValueFlow::Value& v) { - return v.isSymbolicValue() && v.tokvalue && v.tokvalue->exprId() == tok->astOperand2()->exprId(); - }); + ValueFlow::findValue(tok->astOperand1()->values(), nullptr, [&](const ValueFlow::Value& v) { + return v.isSymbolicValue() && v.tokvalue && v.tokvalue->exprId() == tok->astOperand2()->exprId(); + }); if (lhs) lhsvalue = lhs->intvalue; if (!lhs && !rhs) @@ -4607,10 +4607,12 @@ struct ConditionHandler { changePossibleToKnown(values); if (astIsFloat(cond.vartok, false) || (!cond.vartok->valueType() && - std::all_of(values.begin(), values.end(), [](const ValueFlow::Value& v) { - return v.isIntValue() || v.isFloatValue(); - }))) - values.remove_if([&](const ValueFlow::Value& v) { return v.isImpossible(); }); + std::all_of(values.begin(), values.end(), [](const ValueFlow::Value& v) { + return v.isIntValue() || v.isFloatValue(); + }))) + values.remove_if([&](const ValueFlow::Value& v) { + return v.isImpossible(); + }); Analyzer::Result r = forward(parent->astOperand2(), cond.vartok, values, tokenlist, settings); if (r.terminate != Analyzer::Terminate::None) return; @@ -4807,8 +4809,7 @@ struct SimpleConditionHandler : ConditionHandler { const Token* exprTok, const std::list& values, TokenList* tokenlist, - const Settings* settings) const OVERRIDE - { + const Settings* settings) const OVERRIDE { return valueFlowForward(top, exprTok, values, tokenlist, settings); } @@ -4821,8 +4822,7 @@ struct SimpleConditionHandler : ConditionHandler { return valueFlowReverse(start, endToken, exprTok, values, tokenlist, settings); } - virtual std::vector parse(const Token* tok, const Settings*) const OVERRIDE - { + virtual std::vector parse(const Token* tok, const Settings*) const OVERRIDE { Condition cond; ValueFlow::Value true_value; ValueFlow::Value false_value; @@ -6172,9 +6172,9 @@ static Analyzer::Result valueFlowContainerForward(Token* startToken, } static Analyzer::Result valueFlowContainerForwardRecursive(Token* top, - const Token* exprTok, - const ValueFlow::Value& value, - TokenList* tokenlist) + const Token* exprTok, + const ValueFlow::Value& value, + TokenList* tokenlist) { ContainerExpressionAnalyzer a(exprTok, value, tokenlist); return valueFlowGenericForward(top, a, tokenlist->getSettings()); @@ -6355,8 +6355,7 @@ static std::list getIteratorValues(std::list } struct IteratorConditionHandler : SimpleConditionHandler { - virtual std::vector parse(const Token* tok, const Settings*) const OVERRIDE - { + virtual std::vector parse(const Token* tok, const Settings*) const OVERRIDE { Condition cond; ValueFlow::Value true_value; @@ -6567,8 +6566,7 @@ struct ContainerConditionHandler : ConditionHandler { const Token* exprTok, const std::list& values, TokenList* tokenlist, - const Settings*) const OVERRIDE - { + const Settings*) const OVERRIDE { Analyzer::Result result{}; for (const ValueFlow::Value& value : values) result.update(valueFlowContainerForwardRecursive(top, exprTok, value, tokenlist)); @@ -6584,8 +6582,7 @@ struct ContainerConditionHandler : ConditionHandler { return valueFlowContainerReverse(start, endTok, exprTok, values, tokenlist, settings); } - virtual std::vector parse(const Token* tok, const Settings*) const OVERRIDE - { + virtual std::vector parse(const Token* tok, const Settings*) const OVERRIDE { Condition cond; ValueFlow::Value true_value; ValueFlow::Value false_value; diff --git a/lib/valueflow.h b/lib/valueflow.h index 485d33cbb..29a47d4ec 100644 --- a/lib/valueflow.h +++ b/lib/valueflow.h @@ -286,7 +286,9 @@ namespace ValueFlow { bool isIteratorEndValue() const { return valueType == ValueType::ITERATOR_END; } - bool isSymbolicValue() const { return valueType == ValueType::SYMBOLIC; } + bool isSymbolicValue() const { + return valueType == ValueType::SYMBOLIC; + } bool isLocalLifetimeValue() const { return valueType == ValueType::LIFETIME && lifetimeScope == LifetimeScope::Local; diff --git a/test/testother.cpp b/test/testother.cpp index 54282c7e0..b11467a48 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -255,7 +255,7 @@ private: TEST_CASE(sameExpressionPointers); TEST_CASE(checkOverlappingWrite); - + TEST_CASE(constVariableArrayMember); // #10371 } @@ -9491,7 +9491,7 @@ private: "}"); ASSERT_EQUALS("[test.cpp:2]: (error) Overlapping read/write in strcpy() is undefined behavior\n", errout.str()); } - + void constVariableArrayMember() { // #10371 check("class Foo {\n" "public:\n" diff --git a/test/teststl.cpp b/test/teststl.cpp index 97b7b8194..2e23cd0dd 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -1419,8 +1419,7 @@ private: ASSERT_EQUALS("", errout.str()); } - void iterator27() - { + void iterator27() { // #10378 check("struct A {\n" " int a;\n" diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 941c34dad..978d08377 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -154,7 +154,9 @@ private: return !val.isLifetimeValue(); } - static bool isNotUninitValue(const ValueFlow::Value& val) { return !val.isUninitValue(); } + static bool isNotUninitValue(const ValueFlow::Value& val) { + return !val.isUninitValue(); + } static bool isNotPossible(const ValueFlow::Value& val) { return !val.isPossible();