From 31ff79f84b2e0b9eda3d89c710bf5338c5d3ea45 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 2 Dec 2023 17:38:12 -0600 Subject: [PATCH] Format --- lib/programmemory.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/programmemory.cpp b/lib/programmemory.cpp index f2182827e7e..14b49521d4e 100644 --- a/lib/programmemory.cpp +++ b/lib/programmemory.cpp @@ -1259,7 +1259,8 @@ namespace { explicit Executor(ProgramMemory* pm = nullptr, const Settings* settings = nullptr) : pm(pm), settings(settings) {} - std::unordered_map executeAll(const std::vector& toks, bool* b = nullptr) const + std::unordered_map executeAll(const std::vector& toks, + bool* b = nullptr) const { std::unordered_map result; auto state = *this; @@ -1269,7 +1270,7 @@ namespace { continue; result.insert(std::make_pair(tok->exprId(), r)); // Short-circuit evaluation - if(b && isTrueOrFalse(r, *b)) + if (b && isTrueOrFalse(r, *b)) break; } return result; @@ -1298,7 +1299,8 @@ namespace { } // Evaluate recursively if there are no exprids - if((expr->astOperand1() && expr->astOperand1()->exprId() == 0) || (expr->astOperand2() && expr->astOperand2()->exprId() == 0)) { + if ((expr->astOperand1() && expr->astOperand1()->exprId() == 0) || + (expr->astOperand2() && expr->astOperand2()->exprId() == 0)) { ValueFlow::Value lhs = execute(expr->astOperand1()); if (isTrueOrFalse(lhs, b)) return lhs; @@ -1314,7 +1316,7 @@ namespace { if (n > 50) return unknown; std::vector conditions1 = flattenConditions(expr); - if(conditions1.empty()) + if (conditions1.empty()) return unknown; std::unordered_map condValues = executeAll(conditions1, &b); bool allNegated = true; @@ -1323,15 +1325,16 @@ namespace { const ValueFlow::Value& v = p.second; if (isTrueOrFalse(v, b)) return v; - allNegated &= isTrueOrFalse(v, !b);; - if(allNegated && negatedValue.isUninitValue()) + allNegated &= isTrueOrFalse(v, !b); + ; + if (allNegated && negatedValue.isUninitValue()) negatedValue = v; } if (condValues.size() == conditions1.size() && allNegated) return negatedValue; if (n > 4) return unknown; - if(!sortConditions(conditions1)) + if (!sortConditions(conditions1)) return unknown; for (const auto& p : *pm) { @@ -1343,7 +1346,7 @@ namespace { if (n != astCount(tok, expr->str().c_str())) continue; std::vector conditions2 = flattenConditions(tok); - if(!sortConditions(conditions2)) + if (!sortConditions(conditions2)) return unknown; if (conditions1.size() == conditions2.size() && std::equal(conditions1.begin(), conditions1.end(), conditions2.begin(), &TokenExprIdEqual))