Skip to content

Commit c60290f

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

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
@@ -7988,9 +7988,13 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
79887988

79897989
std::unordered_map<const Scope*, ValueType::Type> enumTypes;
79907990
struct EnumTypeCacheGuard {
7991-
explicit EnumTypeCacheGuard(std::unordered_map<const Scope*, ValueType::Type>* cache) : prev(enumTypeCache) { enumTypeCache = cache; }
7992-
~EnumTypeCacheGuard() { enumTypeCache = prev; }
7993-
std::unordered_map<const Scope*, ValueType::Type>* prev;
7991+
explicit EnumTypeCacheGuard(std::unordered_map<const Scope*, ValueType::Type>* cache) {
7992+
enumTypeCache = cache;
7993+
}
7994+
~EnumTypeCacheGuard() {
7995+
enumTypeCache = prev;
7996+
}
7997+
std::unordered_map<const Scope*, ValueType::Type>* prev{enumTypeCache};
79947998
} enumTypeCacheGuard(&enumTypes);
79957999

79968000
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>
@@ -7402,8 +7403,10 @@ struct ValueFlowPassRunner {
74027403
continue;
74037404
std::size_t h = 0;
74047405
for (const Token* tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) {
7405-
for (const ValueFlow::Value& v : tok->values())
7406-
h += hashValue(v) * (2 * reinterpret_cast<std::uintptr_t>(tok) + 1);
7406+
const std::size_t k = (2 * reinterpret_cast<std::uintptr_t>(tok)) + 1;
7407+
h = std::accumulate(tok->values().cbegin(), tok->values().cend(), h, [&](std::size_t acc, const ValueFlow::Value& v) {
7408+
return acc + (hashValue(v) * k);
7409+
});
74077410
}
74087411
result[i] = h;
74097412
}

0 commit comments

Comments
 (0)