GCC Code Coverage Report


Directory: ../
File: src/model/Struct.cpp
Date: 2025-12-19 06:54:40
Coverage Exec Excl Total
Lines: 100.0% 8 0 8
Functions: 100.0% 4 0 4
Branches: 57.1% 8 0 14

Line Branch Exec Source
1 // Copyright (c) 2021-2025 ChilliBits. All rights reserved.
2
3 #include "Struct.h"
4
5 #include <ast/ASTNodes.h>
6
7 namespace spice::compiler {
8
9 static constexpr auto STRUCT_SCOPE_PREFIX = "struct:";
10
11 /**
12 * Retrieve the name of the scope, where members and methods are placed. This is used to navigate to the scope of the struct
13 * from the parent scope.
14 *
15 * @return Name of the struct scope
16 */
17 932 std::string Struct::getScopeName() const {
18
5/8
✓ Branch 2 → 3 taken 932 times.
✗ Branch 2 → 13 not taken.
✓ Branch 3 → 4 taken 466 times.
✓ Branch 3 → 5 taken 466 times.
✓ Branch 4 → 6 taken 466 times.
✗ Branch 4 → 13 not taken.
✓ Branch 5 → 6 taken 466 times.
✗ Branch 5 → 13 not taken.
932 const std::string &appendix = isGenericSubstantiation() ? getSignature() : name;
19
1/2
✓ Branch 6 → 7 taken 932 times.
✗ Branch 6 → 11 not taken.
1864 return STRUCT_SCOPE_PREFIX + appendix;
20 932 }
21
22 /**
23 * Retrieve the name of the scope, where members and methods are placed. This is used to navigate to the scope of the struct
24 * from the parent scope.
25 *
26 * @return Name of the struct scope
27 */
28 19957 std::string Struct::getScopeName(const std::string &name, const QualTypeList &concreteTemplateTypes) {
29
2/4
✓ Branch 2 → 3 taken 19957 times.
✗ Branch 2 → 10 not taken.
✓ Branch 3 → 4 taken 19957 times.
✗ Branch 3 → 8 not taken.
19957 return STRUCT_SCOPE_PREFIX + getSignature(name, concreteTemplateTypes);
30 }
31
32 /**
33 * Checks at least one field is a reference.
34 * This is used to prohibit constant instantiations.
35 *
36 * @return Has reference as field type or not
37 */
38 281 bool Struct::hasReferenceFields() const {
39 715 return std::ranges::any_of(fieldTypes, [](const QualType &fieldType) { return fieldType.isRef(); });
40 }
41
42 } // namespace spice::compiler
43