GCC Code Coverage Report


Directory: ../
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 146 / 0 / 146
Functions: 100.0% 4 / 0 / 4
Branches: 65.6% 198 / 0 / 302

src/typechecker/TypeCheckerTopLevelDefinitionsCheck.cpp
Line Branch Exec Source
1 // Copyright (c) 2021-2026 ChilliBits. All rights reserved.
2
3 #include "TypeChecker.h"
4
5 #include <SourceFile.h>
6 #include <ast/ASTNodes.h>
7 #include <exception/SemanticError.h>
8 #include <model/Interface.h>
9 #include <symboltablebuilder/Scope.h>
10 #include <symboltablebuilder/SymbolTableBuilder.h>
11 #include <typechecker/FunctionManager.h>
12 #include <typechecker/TypeMatcher.h>
13
14 namespace spice::compiler {
15
16 591 std::any TypeChecker::visitMainFctDefCheck(MainFctDefNode *node) {
17 // Skip if already type-checked
18
2/2
✓ Branch 2 → 3 taken 74 times.
✓ Branch 2 → 6 taken 517 times.
591 if (typeCheckedMainFct)
19
1/2
✓ Branch 3 → 4 taken 74 times.
✗ Branch 3 → 13 not taken.
148 return nullptr;
20
21 517 node->resizeToNumberOfManifestations(1);
22
23 // Change to function body scope
24 517 currentScope = node->bodyScope;
25 // Visit statements in new scope
26
2/2
✓ Branch 7 → 8 taken 487 times.
✓ Branch 7 → 14 taken 30 times.
517 visit(node->body);
27 // Leave main function body scope
28 487 currentScope = rootScope;
29
30 // Set to type-checked
31 487 typeCheckedMainFct = true;
32
1/2
✓ Branch 9 → 10 taken 487 times.
✗ Branch 9 → 15 not taken.
974 return nullptr;
33 }
34
35 45593 std::any TypeChecker::visitFctDefCheck(FctDefNode *node) {
36 45593 node->resizeToNumberOfManifestations(node->manifestations.size());
37 45593 manIdx = 0; // Reset the manifestation index
38
39 // Get all manifestations for this function definition
40
2/2
✓ Branch 79 → 6 taken 64005 times.
✓ Branch 79 → 80 taken 45591 times.
155189 for (Function *manifestation : node->manifestations) {
41 // Skip non-substantiated or already checked functions
42
7/8
✓ Branch 8 → 9 taken 64005 times.
✗ Branch 8 → 101 not taken.
✓ Branch 9 → 10 taken 51397 times.
✓ Branch 9 → 11 taken 12608 times.
✓ Branch 10 → 11 taken 28740 times.
✓ Branch 10 → 12 taken 22657 times.
✓ Branch 13 → 14 taken 41348 times.
✓ Branch 13 → 15 taken 22657 times.
64005 if (!manifestation->isFullySubstantiated() || manifestation->alreadyTypeChecked) {
43 41348 manIdx++; // Increase the manifestation index
44 41348 continue;
45 }
46
47 // Change scope to concrete struct specialization scope
48
2/2
✓ Branch 15 → 16 taken 13348 times.
✓ Branch 15 → 21 taken 9309 times.
22657 if (node->isMethod) {
49
2/4
✓ Branch 16 → 17 taken 13348 times.
✗ Branch 16 → 86 not taken.
✓ Branch 17 → 18 taken 13348 times.
✗ Branch 17 → 86 not taken.
13348 const std::string &scopeName = Struct::getScopeName(node->name->structName, manifestation->thisType.getTemplateTypes());
50
1/2
✓ Branch 18 → 19 taken 13348 times.
✗ Branch 18 → 84 not taken.
13348 changeToScope(scopeName, ScopeType::STRUCT);
51 13348 }
52
53 // Change to function scope
54
1/2
✓ Branch 21 → 22 taken 22657 times.
✗ Branch 21 → 101 not taken.
22657 changeToScope(manifestation->bodyScope, ScopeType::FUNC_PROC_BODY);
55
56 // Mount type mapping for this manifestation
57
1/2
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 25 taken 22657 times.
22657 assert(typeMapping.empty());
58
1/2
✓ Branch 25 → 26 taken 22657 times.
✗ Branch 25 → 101 not taken.
22657 typeMapping = manifestation->typeMapping;
59
60 // Set return type to the result variable
61
1/2
✓ Branch 28 → 29 taken 22657 times.
✗ Branch 28 → 89 not taken.
67971 SymbolTableEntry *resultVarEntry = currentScope->lookupStrict(RETURN_VARIABLE_NAME);
62
1/2
✗ Branch 34 → 35 not taken.
✓ Branch 34 → 36 taken 22657 times.
22657 assert(resultVarEntry != nullptr);
63
1/2
✓ Branch 36 → 37 taken 22657 times.
✗ Branch 36 → 101 not taken.
22657 resultVarEntry->updateType(manifestation->returnType, false);
64 22657 resultVarEntry->used = true;
65
66 // Visit parameters
67 // This happens once in the type checker prepare stage. This second time is only required if we have a generic function
68
2/2
✓ Branch 37 → 38 taken 16000 times.
✓ Branch 37 → 64 taken 6657 times.
22657 if (node->hasParams) {
69
1/2
✓ Branch 38 → 39 taken 16000 times.
✗ Branch 38 → 93 not taken.
16000 visit(node->paramLst);
70 // Annotate function/procedure-typed params with lambda-capture info from the resolved manifestation type.
71 // This must happen in the TypeChecker so that the IRGenerator can treat SymbolTableEntry as immutable.
72
2/2
✓ Branch 63 → 41 taken 23394 times.
✓ Branch 63 → 64 taken 16000 times.
39394 for (size_t i = 0; i < manifestation->paramList.size(); i++) {
73
1/2
✓ Branch 41 → 42 taken 23394 times.
✗ Branch 41 → 99 not taken.
23394 const DeclStmtNode *param = node->paramLst->params.at(i);
74
2/4
✓ Branch 42 → 43 taken 23394 times.
✗ Branch 42 → 96 not taken.
✓ Branch 43 → 44 taken 23394 times.
✗ Branch 43 → 94 not taken.
23394 const QualType paramType = manifestation->getParamTypes().at(i);
75
8/10
✓ Branch 45 → 46 taken 23394 times.
✗ Branch 45 → 97 not taken.
✓ Branch 46 → 47 taken 6 times.
✓ Branch 46 → 50 taken 23388 times.
✓ Branch 47 → 48 taken 6 times.
✗ Branch 47 → 97 not taken.
✓ Branch 48 → 49 taken 2 times.
✓ Branch 48 → 50 taken 4 times.
✓ Branch 51 → 52 taken 2 times.
✓ Branch 51 → 61 taken 23392 times.
23394 if (paramType.isOneOf({TY_FUNCTION, TY_PROCEDURE}) && paramType.hasLambdaCaptures()) {
76
1/2
✓ Branch 52 → 53 taken 2 times.
✗ Branch 52 → 99 not taken.
2 SymbolTableEntry *paramSymbol = currentScope->lookupStrict(param->varName);
77
1/2
✗ Branch 55 → 56 not taken.
✓ Branch 55 → 57 taken 2 times.
2 assert(paramSymbol != nullptr);
78
3/6
✓ Branch 57 → 58 taken 2 times.
✗ Branch 57 → 98 not taken.
✓ Branch 58 → 59 taken 2 times.
✗ Branch 58 → 98 not taken.
✓ Branch 59 → 60 taken 2 times.
✗ Branch 59 → 98 not taken.
2 paramSymbol->updateType(paramSymbol->getQualType().getWithLambdaCaptures(), true);
79 }
80 }
81 }
82
83 // Visit statements in new scope
84
2/2
✓ Branch 64 → 65 taken 22655 times.
✓ Branch 64 → 100 taken 2 times.
22657 visit(node->body);
85
86 // Clear type mapping
87 22655 typeMapping.clear();
88
89 // Change to root scope
90 22655 currentScope = rootScope;
91
1/2
✗ Branch 67 → 68 not taken.
✓ Branch 67 → 69 taken 22655 times.
22655 assert(currentScope->type == ScopeType::GLOBAL);
92
93 // Do not type-check this manifestation again
94 22655 manifestation->alreadyTypeChecked = true;
95
96 22655 manIdx++; // Increase the manifestation index
97 }
98 45591 manIdx = 0; // Reset the manifestation index
99
100
1/2
✓ Branch 80 → 81 taken 45591 times.
✗ Branch 80 → 102 not taken.
91182 return nullptr;
101 }
102
103 26750 std::any TypeChecker::visitProcDefCheck(ProcDefNode *node) {
104 26750 node->resizeToNumberOfManifestations(node->manifestations.size());
105 26750 manIdx = 0; // Reset the manifestation index
106
107 // Get all manifestations for this procedure definition
108
2/2
✓ Branch 72 → 6 taken 41711 times.
✓ Branch 72 → 73 taken 26750 times.
95211 for (Function *manifestation : node->manifestations) {
109 // Skip non-substantiated or already checked procedures
110
7/8
✓ Branch 8 → 9 taken 41711 times.
✗ Branch 8 → 88 not taken.
✓ Branch 9 → 10 taken 27360 times.
✓ Branch 9 → 11 taken 14351 times.
✓ Branch 10 → 11 taken 14626 times.
✓ Branch 10 → 12 taken 12734 times.
✓ Branch 13 → 14 taken 28977 times.
✓ Branch 13 → 15 taken 12734 times.
41711 if (!manifestation->isFullySubstantiated() || manifestation->alreadyTypeChecked) {
111 28977 manIdx++; // Increase the manifestation index
112 28977 continue;
113 }
114
115 // Change scope to concrete struct specialization scope
116
2/2
✓ Branch 15 → 16 taken 10754 times.
✓ Branch 15 → 21 taken 1980 times.
12734 if (node->isMethod) {
117
2/4
✓ Branch 16 → 17 taken 10754 times.
✗ Branch 16 → 79 not taken.
✓ Branch 17 → 18 taken 10754 times.
✗ Branch 17 → 79 not taken.
10754 const std::string &scopeName = Struct::getScopeName(node->name->structName, manifestation->thisType.getTemplateTypes());
118
1/2
✓ Branch 18 → 19 taken 10754 times.
✗ Branch 18 → 77 not taken.
10754 changeToScope(scopeName, ScopeType::STRUCT);
119 10754 }
120
121 // Change to procedure scope
122
1/2
✓ Branch 21 → 22 taken 12734 times.
✗ Branch 21 → 88 not taken.
12734 changeToScope(manifestation->bodyScope, ScopeType::FUNC_PROC_BODY);
123
124 // Mount type mapping for this manifestation
125
1/2
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 25 taken 12734 times.
12734 assert(typeMapping.empty());
126
1/2
✓ Branch 25 → 26 taken 12734 times.
✗ Branch 25 → 88 not taken.
12734 typeMapping = manifestation->typeMapping;
127
128 // Visit parameters
129 // This happens once in the type checker prepare stage. This second time is only required if we have a generic procedure
130
2/2
✓ Branch 26 → 27 taken 9463 times.
✓ Branch 26 → 53 taken 3271 times.
12734 if (node->hasParams) {
131
1/2
✓ Branch 27 → 28 taken 9463 times.
✗ Branch 27 → 80 not taken.
9463 visit(node->paramLst);
132 // Annotate function/procedure-typed params with lambda-capture info from the resolved manifestation type.
133 // This must happen in the TypeChecker so that the IRGenerator can treat SymbolTableEntry as immutable.
134
2/2
✓ Branch 52 → 30 taken 13235 times.
✓ Branch 52 → 53 taken 9463 times.
22698 for (size_t i = 0; i < manifestation->paramList.size(); i++) {
135
1/2
✓ Branch 30 → 31 taken 13235 times.
✗ Branch 30 → 86 not taken.
13235 const DeclStmtNode *param = node->paramLst->params.at(i);
136
2/4
✓ Branch 31 → 32 taken 13235 times.
✗ Branch 31 → 83 not taken.
✓ Branch 32 → 33 taken 13235 times.
✗ Branch 32 → 81 not taken.
13235 const QualType paramType = manifestation->getParamTypes().at(i);
137
8/10
✓ Branch 34 → 35 taken 13235 times.
✗ Branch 34 → 84 not taken.
✓ Branch 35 → 36 taken 59 times.
✓ Branch 35 → 39 taken 13176 times.
✓ Branch 36 → 37 taken 59 times.
✗ Branch 36 → 84 not taken.
✓ Branch 37 → 38 taken 13 times.
✓ Branch 37 → 39 taken 46 times.
✓ Branch 40 → 41 taken 13 times.
✓ Branch 40 → 50 taken 13222 times.
13235 if (paramType.isOneOf({TY_FUNCTION, TY_PROCEDURE}) && paramType.hasLambdaCaptures()) {
138
1/2
✓ Branch 41 → 42 taken 13 times.
✗ Branch 41 → 86 not taken.
13 SymbolTableEntry *paramSymbol = currentScope->lookupStrict(param->varName);
139
1/2
✗ Branch 44 → 45 not taken.
✓ Branch 44 → 46 taken 13 times.
13 assert(paramSymbol != nullptr);
140
3/6
✓ Branch 46 → 47 taken 13 times.
✗ Branch 46 → 85 not taken.
✓ Branch 47 → 48 taken 13 times.
✗ Branch 47 → 85 not taken.
✓ Branch 48 → 49 taken 13 times.
✗ Branch 48 → 85 not taken.
13 paramSymbol->updateType(paramSymbol->getQualType().getWithLambdaCaptures(), true);
141 }
142 }
143 }
144
145 // Prepare generation of special ctor preamble to store VTable, default field values, etc. if required
146
2/2
✓ Branch 53 → 54 taken 5754 times.
✓ Branch 53 → 55 taken 6980 times.
12734 if (node->isCtor)
147
1/2
✓ Branch 54 → 55 taken 5754 times.
✗ Branch 54 → 88 not taken.
5754 createCtorBodyPreamble(node->scope);
148
149 // Visit statements in new scope
150
1/2
✓ Branch 55 → 56 taken 12734 times.
✗ Branch 55 → 87 not taken.
12734 visit(node->body);
151
152 // Clear type mapping
153 12734 typeMapping.clear();
154
155 // Change to root scope
156 12734 currentScope = rootScope;
157
2/4
✓ Branch 58 → 59 taken 12734 times.
✗ Branch 58 → 61 not taken.
✓ Branch 59 → 60 taken 12734 times.
✗ Branch 59 → 61 not taken.
12734 assert(currentScope != nullptr && currentScope->type == ScopeType::GLOBAL);
158
159 // Do not type-check this manifestation again
160 12734 manifestation->alreadyTypeChecked = true;
161
162 12734 manIdx++; // Increase the manifestation index
163 }
164 26750 manIdx = 0; // Reset the manifestation index
165
166
1/2
✓ Branch 73 → 74 taken 26750 times.
✗ Branch 73 → 89 not taken.
53500 return nullptr;
167 }
168
169 6136 std::any TypeChecker::visitStructDefCheck(StructDefNode *node) {
170 6136 node->resizeToNumberOfManifestations(node->structManifestations.size());
171 6136 manIdx = 0; // Reset the manifestation index
172
173 // Get all manifestations for this procedure definition
174
2/2
✓ Branch 214 → 6 taken 11259 times.
✓ Branch 214 → 215 taken 6136 times.
23531 for (const Struct *manifestation : node->structManifestations) {
175 // Skip non-substantiated or already checked procedures
176
3/4
✓ Branch 8 → 9 taken 11259 times.
✗ Branch 8 → 298 not taken.
✓ Branch 9 → 10 taken 1970 times.
✓ Branch 9 → 11 taken 9289 times.
11259 if (!manifestation->isFullySubstantiated()) {
177 1970 manIdx++; // Increase the manifestation index
178 1970 continue;
179 }
180
181 // Change to struct scope
182
1/2
✓ Branch 11 → 12 taken 9289 times.
✗ Branch 11 → 298 not taken.
9289 changeToScope(manifestation->scope, ScopeType::STRUCT);
183
184 // Mount type mapping for this manifestation, so that the body preamble helpers below can substantiate
185 // generic field types (e.g. `heap T*` on `Vector<T>`). Without this, an auto-generated body preamble that
186 // touches a still-generic field would assert in TypeMatcher::substantiateTypeWithTypeMapping.
187
1/2
✗ Branch 13 → 14 not taken.
✓ Branch 13 → 15 taken 9289 times.
9289 assert(typeMapping.empty());
188
1/2
✓ Branch 15 → 16 taken 9289 times.
✗ Branch 15 → 298 not taken.
9289 typeMapping = manifestation->typeMapping;
189
190 // Re-visit all default values. This is required, since the type of the default value might vary for different manifestations
191
2/2
✓ Branch 39 → 18 taken 19480 times.
✓ Branch 39 → 40 taken 9289 times.
38058 for (const FieldNode *field : node->fields) {
192
2/2
✓ Branch 20 → 21 taken 8900 times.
✓ Branch 20 → 30 taken 10580 times.
19480 if (field->defaultValue != nullptr) {
193
1/2
✓ Branch 21 → 22 taken 8900 times.
✗ Branch 21 → 219 not taken.
8900 visit(field->defaultValue);
194
1/2
✓ Branch 23 → 24 taken 8900 times.
✗ Branch 23 → 221 not taken.
8900 SymbolTableEntry *fieldEntry = manifestation->scope->lookupStrict(field->fieldName);
195
1/2
✗ Branch 26 → 27 not taken.
✓ Branch 26 → 28 taken 8900 times.
8900 assert(fieldEntry != nullptr);
196
1/2
✓ Branch 28 → 29 taken 8900 times.
✗ Branch 28 → 220 not taken.
8900 fieldEntry->updateState(INITIALIZED, field);
197 }
198 }
199
200 // Build struct type
201
1/2
✓ Branch 40 → 41 taken 9289 times.
✗ Branch 40 → 298 not taken.
9289 const QualType structType = manifestation->entry->getQualType();
202
203 // Check if the struct implements all methods of all attached interfaces
204 9289 size_t vtableIndex = 0;
205
2/2
✓ Branch 145 → 43 taken 3236 times.
✓ Branch 145 → 146 taken 9289 times.
21814 for (const QualType &interfaceType : manifestation->interfaceTypes) {
206
1/2
✓ Branch 45 → 46 taken 3236 times.
✗ Branch 45 → 265 not taken.
3236 const Interface *interface = interfaceType.getInterface(node);
207
1/2
✗ Branch 46 → 47 not taken.
✓ Branch 46 → 48 taken 3236 times.
3236 assert(interface != nullptr);
208
209 // Check for all methods, that it is implemented by the struct
210
2/2
✓ Branch 135 → 50 taken 9138 times.
✓ Branch 135 → 136 taken 3236 times.
15610 for (const Function *expMethod : interface->methods) {
211
1/2
✓ Branch 52 → 53 taken 9138 times.
✗ Branch 52 → 263 not taken.
9138 const std::string methodName = expMethod->name;
212
1/2
✓ Branch 53 → 54 taken 9138 times.
✗ Branch 53 → 261 not taken.
9138 QualTypeList params = expMethod->getParamTypes();
213 9138 QualType returnType = expMethod->returnType;
214
215 // Substantiate param and return types
216
1/2
✓ Branch 54 → 55 taken 9138 times.
✗ Branch 54 → 259 not taken.
9138 TypeMatcher::substantiateTypesWithTypeMapping(params, interface->typeMapping, node);
217
3/4
✓ Branch 55 → 56 taken 9138 times.
✗ Branch 55 → 259 not taken.
✓ Branch 56 → 57 taken 4678 times.
✓ Branch 56 → 58 taken 4460 times.
9138 if (returnType.hasAnyGenericParts())
218
1/2
✓ Branch 57 → 58 taken 4678 times.
✗ Branch 57 → 259 not taken.
4678 TypeMatcher::substantiateTypeWithTypeMapping(returnType, interface->typeMapping, node);
219
220 // Build args list
221 9138 ArgList args;
222
1/2
✓ Branch 59 → 60 taken 9138 times.
✗ Branch 59 → 257 not taken.
9138 args.reserve(params.size());
223
2/2
✓ Branch 74 → 62 taken 1080 times.
✓ Branch 74 → 75 taken 9138 times.
19356 for (const QualType &param : params)
224
1/2
✓ Branch 64 → 65 taken 1080 times.
✗ Branch 64 → 222 not taken.
1080 args.emplace_back(param, nullptr);
225
226 // Search for method that has the required signature
227
1/2
✓ Branch 76 → 77 taken 9138 times.
✗ Branch 76 → 224 not taken.
9138 Function *spiceFunction = FunctionManager::match(currentScope, methodName, structType, args, {}, true, node);
228
2/2
✓ Branch 78 → 79 taken 4 times.
✓ Branch 78 → 91 taken 9134 times.
9138 if (spiceFunction == nullptr) {
229
1/2
✓ Branch 84 → 85 taken 4 times.
✗ Branch 84 → 227 not taken.
4 softError(node, INTERFACE_METHOD_NOT_IMPLEMENTED,
230
5/10
✓ Branch 79 → 80 taken 4 times.
✗ Branch 79 → 239 not taken.
✓ Branch 80 → 81 taken 4 times.
✗ Branch 80 → 235 not taken.
✓ Branch 81 → 82 taken 4 times.
✗ Branch 81 → 233 not taken.
✓ Branch 82 → 83 taken 4 times.
✗ Branch 82 → 231 not taken.
✓ Branch 83 → 84 taken 4 times.
✗ Branch 83 → 229 not taken.
8 "The struct '" + node->structName + "' does not implement method '" + expMethod->getSignature() + "'.");
231 4 continue;
232 }
233
234 // Check return type
235
5/6
✓ Branch 91 → 92 taken 9134 times.
✗ Branch 91 → 257 not taken.
✓ Branch 92 → 93 taken 1540 times.
✓ Branch 92 → 96 taken 7594 times.
✓ Branch 97 → 98 taken 2 times.
✓ Branch 97 → 110 taken 9132 times.
10674 if (spiceFunction->returnType != returnType &&
236
3/4
✓ Branch 93 → 94 taken 1540 times.
✗ Branch 93 → 257 not taken.
✓ Branch 94 → 95 taken 2 times.
✓ Branch 94 → 96 taken 1538 times.
1540 !returnType.matchesInterfaceImplementedByStruct(spiceFunction->returnType)) {
237
1/2
✓ Branch 103 → 104 taken 2 times.
✗ Branch 103 → 242 not taken.
2 softError(node, INTERFACE_METHOD_NOT_IMPLEMENTED,
238
4/8
✓ Branch 98 → 99 taken 2 times.
✗ Branch 98 → 254 not taken.
✓ Branch 99 → 100 taken 2 times.
✗ Branch 99 → 250 not taken.
✓ Branch 100 → 101 taken 2 times.
✗ Branch 100 → 248 not taken.
✓ Branch 101 → 102 taken 2 times.
✗ Branch 101 → 246 not taken.
4 "The struct '" + node->structName + "' does not implement method '" + expMethod->getSignature() +
239
1/2
✓ Branch 102 → 103 taken 2 times.
✗ Branch 102 → 244 not taken.
2 "'. The return type does not match.");
240 2 continue;
241 }
242 // Set to virtual, since it overrides the interface method
243 9132 spiceFunction->isVirtual = true;
244 9132 spiceFunction->vtableIndex = vtableIndex++;
245
6/6
✓ Branch 112 → 113 taken 9132 times.
✓ Branch 112 → 114 taken 6 times.
✓ Branch 117 → 118 taken 9132 times.
✓ Branch 117 → 119 taken 6 times.
✓ Branch 122 → 123 taken 9132 times.
✓ Branch 122 → 125 taken 6 times.
27414 }
246 }
247
248 // Check default ctor body if required
249
2/4
✓ Branch 149 → 150 taken 9289 times.
✗ Branch 149 → 268 not taken.
✓ Branch 150 → 151 taken 9289 times.
✗ Branch 150 → 266 not taken.
27867 const Function *ctorFunc = FunctionManager::lookup(currentScope, CTOR_FUNCTION_NAME, structType, {}, true);
250
4/4
✓ Branch 154 → 155 taken 2296 times.
✓ Branch 154 → 160 taken 6993 times.
✓ Branch 155 → 156 taken 238 times.
✓ Branch 155 → 160 taken 2058 times.
9289 if (ctorFunc != nullptr && ctorFunc->implicitDefault) {
251
1/2
✓ Branch 156 → 157 taken 238 times.
✗ Branch 156 → 298 not taken.
238 createCtorBodyPreamble(ctorFunc->bodyScope);
252
2/4
✓ Branch 157 → 158 taken 238 times.
✗ Branch 157 → 298 not taken.
✗ Branch 158 → 159 not taken.
✓ Branch 158 → 160 taken 238 times.
238 assert(manifestation->areAllFieldsInitialized() == nullptr);
253 }
254
255 // Check default copy ctor body if required
256
2/4
✓ Branch 160 → 161 taken 9289 times.
✗ Branch 160 → 279 not taken.
✓ Branch 164 → 165 taken 9289 times.
✗ Branch 164 → 275 not taken.
27867 const ArgList args = {{structType.toConstRef(node), false /* always non-temporary */}};
257
2/4
✓ Branch 168 → 169 taken 9289 times.
✗ Branch 168 → 283 not taken.
✓ Branch 169 → 170 taken 9289 times.
✗ Branch 169 → 281 not taken.
9289 const Function *copyCtorFunc = FunctionManager::lookup(currentScope, CTOR_FUNCTION_NAME, structType, args, true);
258
4/4
✓ Branch 172 → 173 taken 4427 times.
✓ Branch 172 → 178 taken 4862 times.
✓ Branch 173 → 174 taken 3165 times.
✓ Branch 173 → 178 taken 1262 times.
9289 if (copyCtorFunc != nullptr && copyCtorFunc->implicitDefault) {
259
1/2
✓ Branch 174 → 175 taken 3165 times.
✗ Branch 174 → 296 not taken.
3165 createCopyCtorBodyPreamble(copyCtorFunc->bodyScope);
260
2/4
✓ Branch 175 → 176 taken 3165 times.
✗ Branch 175 → 296 not taken.
✗ Branch 176 → 177 not taken.
✓ Branch 176 → 178 taken 3165 times.
3165 assert(manifestation->areAllFieldsInitialized() == nullptr);
261 }
262
263 // Check default move ctor body if required. findMoveCtor scans the manifestations directly to avoid the
264 // constify-based false-positive that FunctionManager::lookup with a non-const ref arg can produce.
265
5/6
✓ Branch 178 → 179 taken 9289 times.
✗ Branch 178 → 296 not taken.
✓ Branch 179 → 180 taken 430 times.
✓ Branch 179 → 185 taken 8859 times.
✓ Branch 180 → 181 taken 17 times.
✓ Branch 180 → 185 taken 413 times.
9289 if (const Function *moveCtorFunc = FunctionManager::findMoveCtor(currentScope); moveCtorFunc && moveCtorFunc->implicitDefault) {
266
1/2
✓ Branch 181 → 182 taken 17 times.
✗ Branch 181 → 296 not taken.
17 createMoveCtorBodyPreamble(moveCtorFunc->bodyScope);
267
2/4
✓ Branch 182 → 183 taken 17 times.
✗ Branch 182 → 296 not taken.
✗ Branch 183 → 184 not taken.
✓ Branch 183 → 185 taken 17 times.
17 assert(manifestation->areAllFieldsInitialized() == nullptr);
268 }
269
270 // Check default dtor body if required
271
2/4
✓ Branch 188 → 189 taken 9289 times.
✗ Branch 188 → 289 not taken.
✓ Branch 189 → 190 taken 9289 times.
✗ Branch 189 → 287 not taken.
27867 const Function *dtorFunc = FunctionManager::lookup(currentScope, DTOR_FUNCTION_NAME, structType, {}, true);
272
4/4
✓ Branch 193 → 194 taken 5050 times.
✓ Branch 193 → 196 taken 4239 times.
✓ Branch 194 → 195 taken 3321 times.
✓ Branch 194 → 196 taken 1729 times.
9289 if (dtorFunc != nullptr && dtorFunc->implicitDefault)
273
1/2
✓ Branch 195 → 196 taken 3321 times.
✗ Branch 195 → 296 not taken.
3321 createDtorBodyPreamble(dtorFunc->bodyScope);
274
275 // Reset field symbols to declared state for the next manifestation
276
1/2
✓ Branch 196 → 197 taken 9289 times.
✗ Branch 196 → 296 not taken.
9289 manifestation->resetFieldSymbolsToDeclared(node);
277
278 // Clear type mapping
279 9289 typeMapping.clear();
280
281 // Return to the root scope
282 9289 currentScope = rootScope;
283
2/4
✓ Branch 198 → 199 taken 9289 times.
✗ Branch 198 → 201 not taken.
✓ Branch 199 → 200 taken 9289 times.
✗ Branch 199 → 201 not taken.
9289 assert(currentScope != nullptr && currentScope->type == ScopeType::GLOBAL);
284
285 9289 manIdx++; // Increase the manifestation index
286 9289 }
287 6136 manIdx = 0; // Reset the manifestation index
288
289
1/2
✓ Branch 215 → 216 taken 6136 times.
✗ Branch 215 → 300 not taken.
12272 return nullptr;
290 }
291
292 } // namespace spice::compiler
293