GCC Code Coverage Report


Directory: ../
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 94.4% 17 / 0 / 18
Functions: 100.0% 2 / 0 / 2
Branches: 80.0% 16 / 0 / 20

src/model/GenericType.cpp
Line Branch Exec Source
1 // Copyright (c) 2021-2026 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 requestedType Qualified qualType to be checked
11 * @param substantiation Concrete substantiation of the generic type
12 * @param ignoreArraySize Ignore the array size for qualType comparison
13 * @param ignoreQualifiers Ignore the type qualifiers for qualType comparison
14 * @return True or false
15 */
16 53735 bool GenericType::checkConditionsOf(const QualType &requestedType, QualType &substantiation, bool ignoreArraySize,
17 bool ignoreQualifiers) const {
18 53735 return checkTypeConditionOf(requestedType, substantiation, ignoreArraySize, ignoreQualifiers);
19 }
20
21 /**
22 * Checks if the given qualType matches all qualType conditions to get a manifestation of the current generic qualType
23 *
24 * @param requestedType Qualified type to be checked
25 * @param substantiation Concrete substantiation of the generic type
26 * @param ignoreArraySize Ignore the array size for qualType comparison
27 * @param ignoreQualifiers Ignore the type qualifiers for qualType comparison
28 * @return True or false
29 */
30 53735 bool GenericType::checkTypeConditionOf(const QualType &requestedType, QualType &substantiation, bool ignoreArraySize,
31 bool ignoreQualifiers) const {
32 53735 substantiation = requestedType;
33 // Succeed if there are no type conditions
34
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 53735 times.
53735 if (typeConditions.empty())
35 ✗ return true;
36 // Succeed if the given qual type is generic and matches the current one
37
6/6
✓ Branch 6 → 7 taken 3038 times.
✓ Branch 6 → 10 taken 50697 times.
✓ Branch 8 → 9 taken 2137 times.
✓ Branch 8 → 10 taken 901 times.
✓ Branch 11 → 12 taken 2137 times.
✓ Branch 11 → 13 taken 51598 times.
53735 if (requestedType.hasAnyGenericParts() && requestedType == *this)
38 2137 return true;
39 // Check type conditions
40
2/2
✓ Branch 34 → 15 taken 72917 times.
✓ Branch 34 → 35 taken 16073 times.
140588 for (const QualType &typeCondition : typeConditions) {
41 // If we have a dyn type condition, the conditions are fulfilled immediately
42
3/4
✓ Branch 17 → 18 taken 72917 times.
✗ Branch 17 → 37 not taken.
✓ Branch 18 → 19 taken 30202 times.
✓ Branch 18 → 20 taken 42715 times.
72917 if (typeCondition.is(TY_DYN))
43 35525 return true;
44 // In situations like this we need to unwrap: requestedType = const int&, typeCondition = int
45 42715 QualType typeConditionCopy = typeCondition;
46 42715 QualType requestedTypeCopy = requestedType;
47
1/2
✓ Branch 20 → 21 taken 42715 times.
✗ Branch 20 → 37 not taken.
42715 unwrapBothWithRefWrappers(typeConditionCopy, requestedTypeCopy);
48
3/4
✓ Branch 21 → 22 taken 42715 times.
✗ Branch 21 → 37 not taken.
✓ Branch 22 → 23 taken 5323 times.
✓ Branch 22 → 24 taken 37392 times.
42715 if (typeConditionCopy.matches(requestedTypeCopy, ignoreArraySize, ignoreQualifiers, ignoreQualifiers)) {
49 5323 substantiation = typeCondition;
50 5323 return true;
51 }
52 }
53 16073 return false;
54 }
55
56 } // namespace spice::compiler
57