From c86e159802a985c60cacb131a5930b5a58c2c1ea Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 17 Nov 2023 19:25:54 -0600 Subject: [PATCH] Format --- lib/programmemory.cpp | 24 ++++++++++++++++-------- test/testvalueflow.cpp | 24 ++++++++++++------------ 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/lib/programmemory.cpp b/lib/programmemory.cpp index d64305acf1d..f1fc037bf00 100644 --- a/lib/programmemory.cpp +++ b/lib/programmemory.cpp @@ -1219,7 +1219,10 @@ static std::vector setDifference(const std::vector& return result; } -static bool evalSameCondition(const ProgramMemory& state, const Token* storedValue, const Token* cond, const Settings* settings) +static bool evalSameCondition(const ProgramMemory& state, + const Token* storedValue, + const Token* cond, + const Settings* settings) { assert(!conditionIsTrue(cond, state, settings)); ProgramMemory pm = state; @@ -1229,9 +1232,13 @@ static bool evalSameCondition(const ProgramMemory& state, const Token* storedVal return conditionIsTrue(cond, pm, settings); } -static void pruneConditions(std::vector& conds, bool b, const std::unordered_map& state) +static void pruneConditions(std::vector& conds, + bool b, + const std::unordered_map& state) { - conds.erase(std::remove_if(conds.begin(), conds.end(), [&](const Token* cond) { + conds.erase(std::remove_if(conds.begin(), + conds.end(), + [&](const Token* cond) { if (cond->exprId() == 0) return false; auto it = state.find(cond->exprId()); @@ -1239,7 +1246,8 @@ static void pruneConditions(std::vector& conds, bool b, const std: return false; const ValueFlow::Value& v = it->second; return isTrueOrFalse(v, !b); - }), conds.end()); + }), + conds.end()); } namespace { @@ -1256,9 +1264,9 @@ namespace { { std::unordered_map result; auto state = *this; - for(const Token* tok:toks) { + for (const Token* tok : toks) { ValueFlow::Value r = state.execute(tok); - if(r.isUninitValue()) + if (r.isUninitValue()) continue; result.insert(std::make_pair(tok->exprId(), r)); } @@ -1294,7 +1302,7 @@ namespace { return unknown; std::vector conditions1 = flattenConditionsSorted(expr); std::unordered_map condValues = executeAll(conditions1); - for(const auto& p:condValues) { + for (const auto& p : condValues) { const ValueFlow::Value& v = p.second; if (isTrueOrFalse(v, b)) return v; @@ -1599,7 +1607,7 @@ namespace { ValueFlow::Value execute(const Token* expr) { depth--; - if(depth < 0) + if (depth < 0) return unknown; ValueFlow::Value v = executeImpl(expr); if (!v.isUninitValue()) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 07f9bf2554c..9ed37e2388b 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -7246,21 +7246,21 @@ class TestValueFlow : public TestFixture { valueOfTok(code, "&"); code = "bool a(int *);\n" - "void fn2(int b) {\n" - " if (b) {\n" - " bool c, d, e;\n" - " if (c && d)\n" - " return;\n" - " if (e && a(&b)) {\n" - " }\n" - " }\n" - "}\n"; + "void fn2(int b) {\n" + " if (b) {\n" + " bool c, d, e;\n" + " if (c && d)\n" + " return;\n" + " if (e && a(&b)) {\n" + " }\n" + " }\n" + "}\n"; valueOfTok(code, "e"); code = "void f(int a, int b, int c) {\n" - " if (c && (a || a && b))\n" - " if (a && b) {}\n" - "}\n"; + " if (c && (a || a && b))\n" + " if (a && b) {}\n" + "}\n"; valueOfTok(code, "a"); }