GCC Code Coverage Report


Directory: ../
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 14 / 0 / 14
Functions: 100.0% 5 / 0 / 5
Branches: 100.0% 4 / 0 / 4

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