Skip to content

Commit 79c002a

Browse files
dmcppcheckclaude
andcommitted
Fix clang-tidy, selfcheck and uncrustify findings
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 67076ae commit 79c002a

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎lib/symboldatabase.cpp‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8011,9 +8011,13 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
80118011

80128012
std::unordered_map<const Scope*, ValueType::Type> enumTypes;
80138013
struct EnumTypeCacheGuard {
8014-
explicit EnumTypeCacheGuard(std::unordered_map<const Scope*, ValueType::Type>* cache) : prev(enumTypeCache) { enumTypeCache = cache; }
8015-
~EnumTypeCacheGuard() { enumTypeCache = prev; }
8016-
std::unordered_map<const Scope*, ValueType::Type>* prev;
8014+
explicit EnumTypeCacheGuard(std::unordered_map<const Scope*, ValueType::Type>* cache) {
8015+
enumTypeCache = cache;
8016+
}
8017+
~EnumTypeCacheGuard() {
8018+
enumTypeCache = prev;
8019+
}
8020+
std::unordered_map<const Scope*, ValueType::Type>* prev{enumTypeCache};
80178021
} enumTypeCacheGuard(&enumTypes);
80188022

80198023
for (Token *tok = tokens; tok; tok = tok->next())

‎lib/valueflow.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
#include <limits>
123123
#include <map>
124124
#include <memory>
125+
#include <numeric>
125126
#include <set>
126127
#include <string>
127128
#include <unordered_map>
@@ -7482,8 +7483,10 @@ struct ValueFlowPassRunner {
74827483
continue;
74837484
std::size_t h = 0;
74847485
for (const Token* tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) {
7485-
for (const ValueFlow::Value& v : tok->values())
7486-
h += hashValue(v) * (2 * reinterpret_cast<std::uintptr_t>(tok) + 1);
7486+
const std::size_t k = (2 * reinterpret_cast<std::uintptr_t>(tok)) + 1;
7487+
h = std::accumulate(tok->values().cbegin(), tok->values().cend(), h, [&](std::size_t acc, const ValueFlow::Value& v) {
7488+
return acc + (hashValue(v) * k);
7489+
});
74877490
}
74887491
result[i] = h;
74897492
}

0 commit comments

Comments
 (0)