Skip to content

Commit f6f61fb

Browse files
committed
Fix CI issues
1 parent 8d4f066 commit f6f61fb

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

‎lib/programmemory.cpp‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,18 @@ void ProgramMemory::replace(ProgramMemory pm, bool skipUnknown)
369369

370370
copyOnWrite();
371371

372+
// The values can be moved out of the given memory only when no other memory shares them
373+
const bool owned = pm.mValues.use_count() == 1;
372374
for (auto&& p : (*pm.mValues)) {
373375
if (skipUnknown) {
374376
auto it = mValues->find(p.first);
375377
if (it != mValues->end() && isUnknown(it->second))
376378
continue;
377379
}
378-
(*mValues)[p.first] = std::move(p.second);
380+
if (owned)
381+
(*mValues)[p.first] = std::move(p.second);
382+
else
383+
(*mValues)[p.first] = p.second;
379384
}
380385
}
381386

@@ -2052,6 +2057,7 @@ namespace {
20522057
if (expr->str() == "(") {
20532058
const std::vector<const Token*> tokArgs = getArguments(expr);
20542059
std::vector<Values> args;
2060+
args.reserve(tokArgs.size());
20552061
for (const Token* tok : tokArgs)
20562062
args.push_back(execute(tok));
20572063
if (f) {
@@ -2076,6 +2082,7 @@ namespace {
20762082
if (BuiltinLibraryFunction lf = getBuiltinLibraryFunction(ftok->str())) {
20772083
// The builtin functions compute with values, not with constraints
20782084
std::vector<ValueFlow::Value> argValues;
2085+
argValues.reserve(args.size());
20792086
for (const Values& a : args) {
20802087
const ValueFlow::Value* v = getSingleValue(a);
20812088
if (!v)

‎lib/programmemory.h‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ struct CPPCHECKLIB ProgramMemory {
190190
std::shared_ptr<Map> mValues;
191191
};
192192

193-
struct ProgramMemoryState {
193+
struct CPPCHECKLIB ProgramMemoryState {
194194
struct ChangedKeyHash {
195195
std::size_t operator()(const std::tuple<const Token*, const Token*, const Token*>& t) const
196196
{
@@ -230,12 +230,12 @@ struct ProgramMemoryState {
230230

231231
std::vector<ValueFlow::Value> execute(const Scope* scope, ProgramMemory& pm, const Settings& settings);
232232

233-
void execute(const Token* expr,
234-
ProgramMemory& programMemory,
235-
MathLib::bigint* result,
236-
bool* error,
237-
const Settings& settings,
238-
const ProgramMemory::Map& vars = {});
233+
CPPCHECKLIB void execute(const Token* expr,
234+
ProgramMemory& programMemory,
235+
MathLib::bigint* result,
236+
bool* error,
237+
const Settings& settings,
238+
const ProgramMemory::Map& vars = {});
239239

240240
/**
241241
* Is condition always false when variable has given value?

0 commit comments

Comments
 (0)