GCC Code Coverage Report


Directory: ../
File: src/util/GlobalDefinitions.h
Date: 2024-12-24 01:17:15
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 0 0 -%
Branches: 14 28 50.0%

Line Branch Exec Source
1 // Copyright (c) 2021-2024 ChilliBits. All rights reserved.
2
3 #pragma once
4
5 #include <cassert>
6
7 #ifdef __GNUC__
8 #pragma GCC diagnostic push
9 #pragma GCC diagnostic ignored "-Wattributes"
10 #endif
11
12 // Add this to the function signature to force inlining the function
13 #define ALWAYS_INLINE __attribute__((always_inline))
14
15 // Casts a pointer to another pointer type and asserts that the cast was successful in debug mode
16 template <typename T> ALWAYS_INLINE static T spice_pointer_cast(auto source) {
17 static_assert(std::is_pointer_v<decltype(source)>, "Source is not a pointer type");
18
14/28
✓ Branch 0 taken 14247 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14247 times.
✓ Branch 5 taken 9044 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 9044 times.
✓ Branch 10 taken 1554 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1554 times.
✓ Branch 15 taken 5955 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 5955 times.
✓ Branch 20 taken 23107 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 23107 times.
✓ Branch 25 taken 539 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 539 times.
✓ Branch 30 taken 23 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 23 times.
54469 assert(dynamic_cast<T>(source) != nullptr);
19 54469 return static_cast<T>(source);
20 }
21
22 // Fail with an assertion error message
23 #define assert_fail(msg) assert(false && (msg))
24
25 #ifdef __GNUC__
26 #pragma GCC diagnostic pop
27 #endif
28