GCC Code Coverage Report


Directory: ../
File: src/model/GenericType.cpp
Date: 2025-02-05 01:09:36
Exec Total Coverage
Lines: 10 10 100.0%
Functions: 3 3 100.0%
Branches: 12 12 100.0%

Line Branch Exec Source
1 // Copyright (c) 2021-2025 ChilliBits. All rights reserved.
2
3 #include "GenericType.h"
4
5 namespace spice::compiler {
6
7 /**
8 * Checks if the given symbol qualType matches all conditions to get a manifestation of the current generic qualType
9 *
10 * @param qualType Qualified qualType to be checked
11 * @param ignoreArraySize Ignore the array size for qualType comparison
12 * @param igoreQualifiers Ignore the type qualifiers for qualType comparison
13 * @return True or false
14 */
15 6737 bool GenericType::checkConditionsOf(const QualType &qualType, bool ignoreArraySize, bool igoreQualifiers) const {
16 6737 return checkTypeConditionOf(qualType, ignoreArraySize, igoreQualifiers);
17 }
18
19 /**
20 * Checks if the given qualType matches all qualType conditions to get a manifestation of the current generic qualType
21 *
22 * @param qualType Qualified type to be checked
23 * @param ignoreArraySize Ignore the array size for qualType comparison
24 * @param ignoreQualifiers Ignore the type qualifiers for qualType comparison
25 * @return True or false
26 */
27 6737 bool GenericType::checkTypeConditionOf(const QualType &qualType, bool ignoreArraySize, bool ignoreQualifiers) const {
28 // Succeed if no qualType conditions are set
29
2/2
✓ Branch 0 (3→4) taken 1317 times.
✓ Branch 1 (3→5) taken 5420 times.
6737 if (typeConditions.empty())
30 1317 return true;
31 // Succeed if the given qual type is generic and matches the current one
32
6/6
✓ Branch 0 (6→7) taken 344 times.
✓ Branch 1 (6→10) taken 5076 times.
✓ Branch 2 (8→9) taken 317 times.
✓ Branch 3 (8→10) taken 27 times.
✓ Branch 4 (11→12) taken 317 times.
✓ Branch 5 (11→13) taken 5103 times.
5420 if (qualType.hasAnyGenericParts() && qualType == *this)
33 317 return true;
34 // Check type conditions
35 5103 return std::ranges::any_of(typeConditions, [&](const QualType &typeCondition) {
36
4/4
✓ Branch 0 (3→4) taken 7198 times.
✓ Branch 1 (3→6) taken 1514 times.
✓ Branch 2 (5→6) taken 987 times.
✓ Branch 3 (5→7) taken 6211 times.
8712 return typeCondition.is(TY_DYN) || typeCondition.matches(qualType, ignoreArraySize, ignoreQualifiers, ignoreQualifiers);
37 5103 });
38 }
39
40 } // namespace spice::compiler
41