Skip to content

Commit 25e26ff

Browse files
committed
Fix CI failures
1 parent f6f61fb commit 25e26ff

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

‎lib/programmemory.cpp‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ bool ProgramMemory::getContainerEmptyValue(nonneg int exprid, MathLib::bigint& r
273273
const Values* values = getValues(exprid);
274274
if (!values)
275275
return false;
276-
const ValueFlow::Value empty = containerEmptyValue(*values);
277-
if (empty.isUninitValue())
276+
const ValueFlow::Value isEmpty = containerEmptyValue(*values);
277+
if (isEmpty.isUninitValue())
278278
return false;
279-
result = empty.intvalue;
279+
result = isEmpty.intvalue;
280280
return true;
281281
}
282282

@@ -2058,8 +2058,9 @@ namespace {
20582058
const std::vector<const Token*> tokArgs = getArguments(expr);
20592059
std::vector<Values> args;
20602060
args.reserve(tokArgs.size());
2061-
for (const Token* tok : tokArgs)
2062-
args.push_back(execute(tok));
2061+
std::transform(tokArgs.cbegin(), tokArgs.cend(), std::back_inserter(args), [&](const Token* tok) {
2062+
return execute(tok);
2063+
});
20632064
if (f) {
20642065
if (fdepth >= 0 && !f->isImplicitlyVirtual()) {
20652066
ProgramMemory functionState;
@@ -2072,10 +2073,10 @@ namespace {
20722073
Executor ex = *this;
20732074
ex.pm = &functionState;
20742075
ex.fdepth--;
2075-
for (const ValueFlow::Value& v : ex.execute(f->functionScope)) {
2076-
if (!v.isUninitValue())
2077-
result.push_back(v);
2078-
}
2076+
const std::vector<ValueFlow::Value> returned = ex.execute(f->functionScope);
2077+
std::copy_if(returned.cbegin(), returned.cend(), std::back_inserter(result), [](const ValueFlow::Value& v) {
2078+
return !v.isUninitValue();
2079+
});
20792080
// TODO: Track values changed by reference
20802081
}
20812082
} else {

‎test/testprogrammemory.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include <algorithm>
3030
#include <cstddef>
31+
#include <iterator>
3132
#include <stdexcept>
3233
#include <string>
3334
#include <vector>
@@ -322,9 +323,11 @@ class TestProgramMemory : public TestFixture {
322323
SimpleTokenizer tokenizer(settings, *this);
323324
ASSERT(tokenizer.tokenize(code));
324325
clearValues(tokenizer);
326+
const std::vector<const Token*> exprs = assignedExpressions(tokenizer.tokens(), "y");
325327
std::vector<std::string> results;
326-
for (const Token* expr : assignedExpressions(tokenizer.tokens(), "y"))
327-
results.push_back(evaluate(expr));
328+
std::transform(exprs.cbegin(), exprs.cend(), std::back_inserter(results), [&](const Token* expr) {
329+
return evaluate(expr);
330+
});
328331
return results;
329332
}
330333

0 commit comments

Comments
 (0)