From 1be5bb8bbc8fb9d8e5b8efc668e0c5603c9f40c6 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Sun, 18 Jul 2021 10:01:22 +0200 Subject: [PATCH] Running astyle [ci skip] --- lib/analyzer.h | 3 +- lib/astutils.cpp | 30 +++++++++---------- lib/valueflow.cpp | 63 +++++++++++++++++++++------------------- test/testnullpointer.cpp | 3 +- test/testvalueflow.cpp | 34 ++++++++++++---------- 5 files changed, 69 insertions(+), 64 deletions(-) diff --git a/lib/analyzer.h b/lib/analyzer.h index 515570266..1b7c7478e 100644 --- a/lib/analyzer.h +++ b/lib/analyzer.h @@ -120,8 +120,7 @@ struct Analyzer { Action action; Terminate terminate; - void update(Result rhs) - { + void update(Result rhs) { if (terminate == Terminate::None) terminate = rhs.terminate; action |= rhs.action; diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 4e0d7e844..92c9951ed 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1423,17 +1423,17 @@ bool isConstFunctionCall(const Token* ftok, const Library& library) if (!Function::returnsConst(f)) { std::vector fs = f->getOverloadedFunctions(); if (std::any_of(fs.begin(), fs.end(), [&](const Function* g) { - if (f == g) - return false; - if (f->argumentList.size() != g->argumentList.size()) - return false; - if (functionModifiesArguments(g)) - return false; - if (g->isConst() && Function::returnsConst(g)) - return true; + if (f == g) return false; - })) - return true; + if (f->argumentList.size() != g->argumentList.size()) + return false; + if (functionModifiesArguments(g)) + return false; + if (g->isConst() && Function::returnsConst(g)) + return true; + return false; + })) + return true; } return false; } else if (f->argumentList.empty()) { @@ -1467,11 +1467,11 @@ bool isConstFunctionCall(const Token* ftok, const Library& library) if (memberFunction && args.empty()) return false; return constMember && std::all_of(args.begin(), args.end(), [](const Token* tok) { - const Variable* var = tok->variable(); - if (var) - return var->isConst(); - return false; - }); + const Variable* var = tok->variable(); + if (var) + return var->isConst(); + return false; + }); } return true; } diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 359f145fd..da087f6df 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1679,11 +1679,11 @@ static void valueFlowGlobalStaticVar(TokenList *tokenList, const Settings *setti } static Analyzer::Result valueFlowForward(Token* startToken, - const Token* endToken, - const Token* exprTok, - std::list values, - TokenList* const tokenlist, - const Settings* settings); + const Token* endToken, + const Token* exprTok, + std::list values, + TokenList* const tokenlist, + const Settings* settings); static void valueFlowReverse(TokenList* tokenlist, Token* tok, @@ -1974,7 +1974,9 @@ struct ValueFlowAnalyzer : Analyzer { virtual bool isGlobal() const { return false; } - virtual bool dependsOnThis() const { return false; } + virtual bool dependsOnThis() const { + return false; + } virtual bool invalid() const { return false; @@ -2020,8 +2022,7 @@ struct ValueFlowAnalyzer : Analyzer { return Action::None; } - virtual Action isThisModified(const Token* tok) const - { + virtual Action isThisModified(const Token* tok) const { if (isThisChanged(tok, 0, getSettings(), isCPP())) return Action::Invalid; return Action::None; @@ -2405,8 +2406,7 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer { ExpressionAnalyzer() : SingleValueFlowAnalyzer(), expr(nullptr), local(true), unknown(false), dependOnThis(false) {} ExpressionAnalyzer(const Token* e, const ValueFlow::Value& val, const TokenList* t) - : SingleValueFlowAnalyzer(val, t), expr(e), local(true), unknown(false), dependOnThis(false) - { + : SingleValueFlowAnalyzer(val, t), expr(e), local(true), unknown(false), dependOnThis(false) { dependOnThis = exprDependsOnThis(expr); setupExprVarIds(expr); @@ -2421,8 +2421,7 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer { var->isStatic() || var->isReference() || var->isExtern(); } - void setupExprVarIds(const Token* start, int depth = 0) - { + void setupExprVarIds(const Token* start, int depth = 0) { const int maxDepth = 4; if (depth > maxDepth) return; @@ -2468,9 +2467,13 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer { return ps; } - virtual bool match(const Token* tok) const OVERRIDE { return tok->exprId() == expr->exprId(); } + virtual bool match(const Token* tok) const OVERRIDE { + return tok->exprId() == expr->exprId(); + } - virtual bool dependsOnThis() const OVERRIDE { return dependOnThis; } + virtual bool dependsOnThis() const OVERRIDE { + return dependOnThis; + } virtual bool isGlobal() const OVERRIDE { return !local; @@ -2492,11 +2495,11 @@ struct OppositeExpressionAnalyzer : ExpressionAnalyzer { }; static Analyzer::Result valueFlowForwardExpression(Token* startToken, - const Token* endToken, - const Token* exprTok, - const std::list& values, - const TokenList* const tokenlist, - const Settings* settings) + const Token* endToken, + const Token* exprTok, + const std::list& values, + const TokenList* const tokenlist, + const Settings* settings) { Analyzer::Result result{}; for (const ValueFlow::Value& v : values) { @@ -5043,10 +5046,10 @@ static void valueFlowForLoopSimplify(Token * const bodyStart, const nonneg int v } static void valueFlowForLoopSimplifyAfter(Token* fortok, - nonneg int varid, - const MathLib::bigint num, - TokenList* tokenlist, - const Settings* settings) + nonneg int varid, + const MathLib::bigint num, + TokenList* tokenlist, + const Settings* settings) { const Token *vartok = nullptr; for (const Token *tok = fortok; tok; tok = tok->next()) { @@ -6035,19 +6038,19 @@ struct ContainerExpressionAnalyzer : ExpressionAnalyzer { }; static Analyzer::Result valueFlowContainerForward(Token* startToken, - const Token* endToken, - const Token* exprTok, - const ValueFlow::Value& value, - TokenList* tokenlist) + const Token* endToken, + const Token* exprTok, + const ValueFlow::Value& value, + TokenList* tokenlist) { ContainerExpressionAnalyzer a(exprTok, value, tokenlist); return valueFlowGenericForward(startToken, endToken, a, tokenlist->getSettings()); } static Analyzer::Result valueFlowContainerForward(Token* startToken, - const Token* exprTok, - const ValueFlow::Value& value, - TokenList* tokenlist) + const Token* exprTok, + const ValueFlow::Value& value, + TokenList* tokenlist) { const Token* endToken = nullptr; const Function* f = Scope::nestedInFunction(startToken->scope()); diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 2369fcb19..8d93ad35f 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -2330,8 +2330,7 @@ private: ASSERT_EQUALS("", errout.str()); } - void nullpointer75() - { + void nullpointer75() { check("struct a {\n" " a *b() const;\n" " void c();\n" diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 7e47c0324..34231298f 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -152,13 +152,21 @@ private: return !val.isLifetimeValue(); } - static bool isNotPossible(const ValueFlow::Value& val) { return !val.isPossible(); } + static bool isNotPossible(const ValueFlow::Value& val) { + return !val.isPossible(); + } - static bool isNotKnown(const ValueFlow::Value& val) { return !val.isKnown(); } + static bool isNotKnown(const ValueFlow::Value& val) { + return !val.isKnown(); + } - static bool isNotInconclusive(const ValueFlow::Value& val) { return !val.isInconclusive(); } + static bool isNotInconclusive(const ValueFlow::Value& val) { + return !val.isInconclusive(); + } - static bool isNotImpossible(const ValueFlow::Value& val) { return !val.isImpossible(); } + static bool isNotImpossible(const ValueFlow::Value& val) { + return !val.isImpossible(); + } bool testValueOfXKnown(const char code[], unsigned int linenr, int value) { // Tokenize.. @@ -4662,9 +4670,8 @@ private: } static std::string isPossibleContainerSizeValue(std::list values, - MathLib::bigint i, - bool unique = true) - { + MathLib::bigint i, + bool unique = true) { if (!unique) values.remove_if(&isNotPossible); if (values.size() != 1) @@ -4679,9 +4686,8 @@ private: } static std::string isImpossibleContainerSizeValue(std::list values, - MathLib::bigint i, - bool unique = true) - { + MathLib::bigint i, + bool unique = true) { if (!unique) values.remove_if(&isNotImpossible); if (values.size() != 1) @@ -4696,9 +4702,8 @@ private: } static std::string isInconclusiveContainerSizeValue(std::list values, - MathLib::bigint i, - bool unique = true) - { + MathLib::bigint i, + bool unique = true) { if (!unique) values.remove_if(&isNotInconclusive); if (values.size() != 1) @@ -4712,8 +4717,7 @@ private: return ""; } - static std::string isKnownContainerSizeValue(std::list values, MathLib::bigint i, bool unique = true) - { + static std::string isKnownContainerSizeValue(std::list values, MathLib::bigint i, bool unique = true) { if (!unique) values.remove_if(&isNotKnown); if (values.size() != 1)