src/util/CustomHashFunctions.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright (c) 2021-2026 ChilliBits. All rights reserved. | ||
| 2 | |||
| 3 | #pragma once | ||
| 4 | |||
| 5 | #include <cstdint> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | namespace spice::compiler { | ||
| 9 | |||
| 10 | // Forward declarations | ||
| 11 | struct TypeChainElement; | ||
| 12 | class Type; | ||
| 13 | class TypeQualifiers; | ||
| 14 | class QualType; | ||
| 15 | |||
| 16 | uint64_t hashMix(uint64_t hash) noexcept; | ||
| 17 | |||
| 18 | void hashCombine64(uint64_t &hash, uint64_t value) noexcept; | ||
| 19 | |||
| 20 | 8563049 | template <typename T> uint64_t hashValue(const T &value) noexcept { return static_cast<uint64_t>(std::hash<T>{}(value)); } | |
| 21 | |||
| 22 | 888758 | template <typename T> uint64_t hashPointer(const T *value) noexcept { return reinterpret_cast<uint64_t>(value) >> 3; } | |
| 23 | |||
| 24 | 23838684 | template <typename T> uint64_t hashVector(const std::vector<T> &vec) noexcept { | |
| 25 | 23838684 | uint64_t hash = 0; | |
| 26 |
4/4unsigned long spice::compiler::hashVector<spice::compiler::TypeChainElement>(std::vector<spice::compiler::TypeChainElement, std::allocator<spice::compiler::TypeChainElement> > const&):
✓ Branch 9 → 4 taken 7962563 times.
✓ Branch 9 → 10 taken 7791686 times.
unsigned long spice::compiler::hashVector<spice::compiler::QualType>(std::vector<spice::compiler::QualType, std::allocator<spice::compiler::QualType> > const&):
✓ Branch 9 → 4 taken 600486 times.
✓ Branch 9 → 10 taken 16046998 times.
|
32401733 | for (const T &item : vec) |
| 27 | 8563049 | hashCombine64(hash, hashValue(item)); | |
| 28 | 23838684 | return hash; | |
| 29 | } | ||
| 30 | |||
| 31 | } // namespace spice::compiler | ||
| 32 | |||
| 33 | namespace std { | ||
| 34 | |||
| 35 | // Implement hash functionality for the TypeChainElement struct | ||
| 36 | template <> struct hash<spice::compiler::TypeChainElement> { | ||
| 37 | size_t operator()(const spice::compiler::TypeChainElement &tce) const noexcept; | ||
| 38 | }; | ||
| 39 | |||
| 40 | // Implement hash functionality for the Type class | ||
| 41 | template <> struct hash<spice::compiler::Type> { | ||
| 42 | size_t operator()(const spice::compiler::Type &t) const noexcept; | ||
| 43 | }; | ||
| 44 | |||
| 45 | // Implement hash functionality for the TypeQualifiers class | ||
| 46 | template <> struct hash<spice::compiler::TypeQualifiers> { | ||
| 47 | size_t operator()(const spice::compiler::TypeQualifiers &qualifiers) const noexcept; | ||
| 48 | }; | ||
| 49 | |||
| 50 | // Implement hash functionality for the QualType class | ||
| 51 | template <> struct hash<spice::compiler::QualType> { | ||
| 52 | size_t operator()(const spice::compiler::QualType &qualType) const noexcept; | ||
| 53 | }; | ||
| 54 | |||
| 55 | } // namespace std | ||
| 56 |