GCC Code Coverage Report


Directory: ../
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 93.5% 388 / 10 / 425
Functions: 100.0% 16 / 0 / 16
Branches: 52.6% 686 / 32 / 1337

src/typechecker/TypeCheckerExpressions.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 <global/GlobalResourceManager.h>
7 #include <symboltablebuilder/Scope.h>
8 #include <symboltablebuilder/SymbolTableBuilder.h>
9 #include <typechecker/MacroDefs.h>
10
11 namespace spice::compiler {
12
13 19510 std::any TypeChecker::visitAssignExpr(AssignExprNode *node) {
14 // Check if ternary
15
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 10 taken 19510 times.
19510 if (node->ternaryExpr) {
16 auto result = std::any_cast<ExprResult>(visit(node->ternaryExpr));
17 node->setEvaluatedSymbolType(result.type, manIdx);
18 return result;
19 }
20
21 // Check if assignment
22
1/2
✓ Branch 10 → 11 taken 19510 times.
✗ Branch 10 → 142 not taken.
19510 if (node->op != AssignExprNode::AssignOp::OP_NONE) {
23 // Visit the right side first
24
2/4
✓ Branch 11 → 12 taken 19510 times.
✗ Branch 11 → 157 not taken.
✓ Branch 12 → 13 taken 19510 times.
✗ Branch 12 → 155 not taken.
19510 auto rhs = std::any_cast<ExprResult>(visit(node->rhs));
25 19510 auto [rhsType, rhsEntry] = rhs;
26
5/8
✓ Branch 14 → 15 taken 19510 times.
✗ Branch 14 → 201 not taken.
✓ Branch 15 → 16 taken 1 time.
✓ Branch 15 → 20 taken 19509 times.
✓ Branch 16 → 17 taken 1 time.
✗ Branch 16 → 158 not taken.
✓ Branch 17 → 18 taken 1 time.
✗ Branch 17 → 158 not taken.
19511 HANDLE_UNRESOLVED_TYPE_ER(rhsType)
27 // Then visit the left side
28
2/4
✓ Branch 20 → 21 taken 19509 times.
✗ Branch 20 → 161 not taken.
✓ Branch 21 → 22 taken 19509 times.
✗ Branch 21 → 159 not taken.
19509 auto lhs = std::any_cast<ExprResult>(visit(node->lhs));
29 19509 auto [lhsType, lhsVar] = lhs;
30
5/8
✓ Branch 23 → 24 taken 19509 times.
✗ Branch 23 → 201 not taken.
✓ Branch 24 → 25 taken 1 time.
✓ Branch 24 → 29 taken 19508 times.
✓ Branch 25 → 26 taken 1 time.
✗ Branch 25 → 162 not taken.
✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 162 not taken.
19510 HANDLE_UNRESOLVED_TYPE_ER(lhsType)
31
32 // A native lambda stores its captures in the stack frame that created it. Storing a capturing lambda in a
33 // struct field lets it outlive those captures, so the captures would dangle. Reject this and direct the user
34 // to the owning std Lambda wrapper. Non-capturing lambdas (plain function pointers) are safe to store and are
35 // not affected. The std Lambda wrapper itself stores the captures-flagged lambda in its own field, so std
36 // files are exempt.
37
5/6
✓ Branch 30 → 31 taken 17219 times.
✓ Branch 30 → 40 taken 1 time.
✓ Branch 31 → 32 taken 17219 times.
✗ Branch 31 → 163 not taken.
✓ Branch 32 → 33 taken 13888 times.
✓ Branch 32 → 40 taken 3331 times.
17220 if (node->op == AssignExprNode::AssignOp::OP_ASSIGN && lhs.entry != nullptr && lhs.entry->isField() &&
38
12/16
✓ Branch 29 → 30 taken 17220 times.
✓ Branch 29 → 40 taken 2288 times.
✓ Branch 33 → 34 taken 13888 times.
✗ Branch 33 → 163 not taken.
✓ Branch 34 → 35 taken 13888 times.
✗ Branch 34 → 163 not taken.
✓ Branch 35 → 36 taken 141 times.
✓ Branch 35 → 40 taken 13747 times.
✓ Branch 36 → 37 taken 141 times.
✗ Branch 36 → 163 not taken.
✓ Branch 37 → 38 taken 1 time.
✓ Branch 37 → 40 taken 140 times.
✓ Branch 38 → 39 taken 1 time.
✗ Branch 38 → 40 not taken.
✓ Branch 41 → 42 taken 1 time.
✓ Branch 41 → 55 taken 19507 times.
36728 rhsType.getBase().isOneOf({TY_FUNCTION, TY_PROCEDURE}) && rhsType.hasLambdaCaptures() && !sourceFile->isStdFile)
39
8/16
✓ Branch 42 → 43 taken 1 time.
✗ Branch 42 → 171 not taken.
✓ Branch 43 → 44 taken 1 time.
✗ Branch 43 → 171 not taken.
✓ Branch 44 → 45 taken 1 time.
✗ Branch 44 → 171 not taken.
✓ Branch 45 → 46 taken 1 time.
✗ Branch 45 → 169 not taken.
✓ Branch 46 → 47 taken 1 time.
✗ Branch 46 → 167 not taken.
✓ Branch 47 → 48 taken 1 time.
✗ Branch 47 → 165 not taken.
✓ Branch 51 → 52 taken 1 time.
✗ Branch 51 → 176 not taken.
✓ Branch 52 → 53 taken 1 time.
✗ Branch 52 → 176 not taken.
2 SOFT_ERROR_ER(node->rhs, LAMBDA_CAPTURE_ESCAPE,
40 "A capturing lambda cannot be stored in a field, because its captures live in the frame that "
41 "created it and would dangle. Wrap it in 'Lambda<" +
42 rhsType.getBase().getWithLambdaCaptures(false).getName(false) + ">' from std/type/lambda instead.")
43
44 // Take a look at the operator
45
2/2
✓ Branch 55 → 56 taken 17219 times.
✓ Branch 55 → 98 taken 2288 times.
19507 if (node->op == AssignExprNode::AssignOp::OP_ASSIGN) {
46
8/10
✓ Branch 56 → 57 taken 17218 times.
✓ Branch 56 → 63 taken 1 time.
✓ Branch 57 → 58 taken 17218 times.
✗ Branch 57 → 188 not taken.
✓ Branch 58 → 59 taken 13887 times.
✓ Branch 58 → 63 taken 3331 times.
✓ Branch 60 → 61 taken 13887 times.
✗ Branch 60 → 188 not taken.
✓ Branch 61 → 62 taken 5287 times.
✓ Branch 61 → 63 taken 8600 times.
17219 const bool isDecl = lhs.entry != nullptr && lhs.entry->isField() && !lhs.entry->getLifecycle().isInitialized();
47
2/2
✓ Branch 64 → 65 taken 17218 times.
✓ Branch 64 → 188 taken 1 time.
17219 const auto [assignType, copyCtor] = opRuleManager.getAssignResultType(node, lhs, rhs, isDecl);
48 17218 rhsType = assignType;
49 // If the assignment overwrites an already initialized struct by copying a new value into it, the old value
50 // of the lhs must be destructed first. Otherwise its owning members (heap pointers, strings, ...) would leak.
51 // A non-null copy ctor signals that a real copy (not a move/temporary steal or ref assignment) takes place.
52 // 'isInitialized()' is false for declarations, uninitialized fields and moved-from values, so those are skipped.
53 // Unsafe blocks are excluded on purpose: code that manually manages object lifetimes there (e.g. the raw
54 // element shifts in container implementations) relies on assignments not implicitly destructing the lhs.
55
10/12
✓ Branch 67 → 68 taken 139 times.
✓ Branch 67 → 75 taken 17079 times.
✓ Branch 68 → 69 taken 33 times.
✓ Branch 68 → 75 taken 106 times.
✓ Branch 69 → 70 taken 33 times.
✗ Branch 69 → 75 not taken.
✓ Branch 70 → 71 taken 33 times.
✗ Branch 70 → 188 not taken.
✓ Branch 71 → 72 taken 18 times.
✓ Branch 71 → 75 taken 15 times.
✓ Branch 76 → 77 taken 10 times.
✓ Branch 76 → 97 taken 17208 times.
17236 if (copyCtor != nullptr && !isDecl && lhs.entry != nullptr && lhs.entry->isInitialized() &&
56
3/4
✓ Branch 72 → 73 taken 18 times.
✗ Branch 72 → 188 not taken.
✓ Branch 73 → 74 taken 10 times.
✓ Branch 73 → 75 taken 8 times.
18 !currentScope->doesAllowUnsafeOperations()) {
57
2/4
✓ Branch 77 → 78 taken 10 times.
✗ Branch 77 → 177 not taken.
✓ Branch 78 → 79 taken 10 times.
✗ Branch 78 → 177 not taken.
10 const QualType lhsSType = lhs.type.removeReferenceWrapper().toNonConst();
58
5/10
✓ Branch 79 → 80 taken 10 times.
✗ Branch 79 → 187 not taken.
✓ Branch 80 → 81 taken 10 times.
✗ Branch 80 → 84 not taken.
✓ Branch 81 → 82 taken 10 times.
✗ Branch 81 → 187 not taken.
✓ Branch 82 → 83 taken 10 times.
✗ Branch 82 → 84 not taken.
✓ Branch 85 → 86 taken 10 times.
✗ Branch 85 → 96 not taken.
10 if (lhsSType.is(TY_STRUCT) && !lhsSType.isTriviallyDestructible(node))
59
2/4
✓ Branch 89 → 90 taken 10 times.
✗ Branch 89 → 180 not taken.
✓ Branch 90 → 91 taken 10 times.
✗ Branch 90 → 178 not taken.
30 node->lhsDtorFct[manIdx] = implicitlyCallStructMethod(lhsSType, DTOR_FUNCTION_NAME, {}, node);
60 }
61
2/2
✓ Branch 98 → 99 taken 1160 times.
✓ Branch 98 → 101 taken 1128 times.
2288 } else if (node->op == AssignExprNode::AssignOp::OP_PLUS_EQUAL) {
62
1/2
✓ Branch 99 → 100 taken 1160 times.
✗ Branch 99 → 189 not taken.
1160 rhsType = opRuleManager.getPlusEqualResultType(node, lhs, rhs).type;
63
2/2
✓ Branch 101 → 102 taken 80 times.
✓ Branch 101 → 104 taken 1048 times.
1128 } else if (node->op == AssignExprNode::AssignOp::OP_MINUS_EQUAL) {
64
1/2
✓ Branch 102 → 103 taken 80 times.
✗ Branch 102 → 190 not taken.
80 rhsType = opRuleManager.getMinusEqualResultType(node, lhs, rhs).type;
65
2/2
✓ Branch 104 → 105 taken 170 times.
✓ Branch 104 → 107 taken 878 times.
1048 } else if (node->op == AssignExprNode::AssignOp::OP_MUL_EQUAL) {
66
1/2
✓ Branch 105 → 106 taken 170 times.
✗ Branch 105 → 191 not taken.
170 rhsType = opRuleManager.getMulEqualResultType(node, lhs, rhs).type;
67
2/2
✓ Branch 107 → 108 taken 104 times.
✓ Branch 107 → 110 taken 774 times.
878 } else if (node->op == AssignExprNode::AssignOp::OP_DIV_EQUAL) {
68
1/2
✓ Branch 108 → 109 taken 104 times.
✗ Branch 108 → 192 not taken.
104 rhsType = opRuleManager.getDivEqualResultType(node, lhs, rhs).type;
69
2/2
✓ Branch 110 → 111 taken 41 times.
✓ Branch 110 → 113 taken 733 times.
774 } else if (node->op == AssignExprNode::AssignOp::OP_REM_EQUAL) {
70
1/2
✓ Branch 111 → 112 taken 41 times.
✗ Branch 111 → 193 not taken.
41 rhsType = opRuleManager.getRemEqualResultType(node, lhs, rhs);
71
2/2
✓ Branch 113 → 114 taken 12 times.
✓ Branch 113 → 116 taken 721 times.
733 } else if (node->op == AssignExprNode::AssignOp::OP_SHL_EQUAL) {
72
1/2
✓ Branch 114 → 115 taken 12 times.
✗ Branch 114 → 194 not taken.
12 rhsType = opRuleManager.getSHLEqualResultType(node, lhs, rhs);
73
2/2
✓ Branch 116 → 117 taken 13 times.
✓ Branch 116 → 119 taken 708 times.
721 } else if (node->op == AssignExprNode::AssignOp::OP_SHR_EQUAL) {
74
1/2
✓ Branch 117 → 118 taken 13 times.
✗ Branch 117 → 195 not taken.
13 rhsType = opRuleManager.getSHREqualResultType(node, lhs, rhs);
75
2/2
✓ Branch 119 → 120 taken 17 times.
✓ Branch 119 → 122 taken 691 times.
708 } else if (node->op == AssignExprNode::AssignOp::OP_AND_EQUAL) {
76
1/2
✓ Branch 120 → 121 taken 17 times.
✗ Branch 120 → 196 not taken.
17 rhsType = opRuleManager.getAndEqualResultType(node, lhs, rhs);
77
2/2
✓ Branch 122 → 123 taken 13 times.
✓ Branch 122 → 125 taken 678 times.
691 } else if (node->op == AssignExprNode::AssignOp::OP_OR_EQUAL) {
78
1/2
✓ Branch 123 → 124 taken 13 times.
✗ Branch 123 → 197 not taken.
13 rhsType = opRuleManager.getOrEqualResultType(node, lhs, rhs);
79
1/2
✓ Branch 125 → 126 taken 678 times.
✗ Branch 125 → 128 not taken.
678 } else if (node->op == AssignExprNode::AssignOp::OP_XOR_EQUAL) {
80
1/2
✓ Branch 126 → 127 taken 678 times.
✗ Branch 126 → 198 not taken.
678 rhsType = opRuleManager.getXorEqualResultType(node, lhs, rhs);
81 }
82
83
1/2
✓ Branch 128 → 129 taken 19506 times.
✗ Branch 128 → 137 not taken.
19506 if (lhsVar) { // Variable is involved on the left side
84 // Perform type inference
85
3/4
✓ Branch 129 → 130 taken 19506 times.
✗ Branch 129 → 201 not taken.
✓ Branch 130 → 131 taken 1 time.
✓ Branch 130 → 132 taken 19505 times.
19506 if (lhsType.is(TY_DYN))
86
1/2
✓ Branch 131 → 132 taken 1 time.
✗ Branch 131 → 201 not taken.
1 lhsVar->updateType(rhsType, false);
87
88 // In case the lhs variable is captured, notify the capture about the write access
89
3/4
✓ Branch 132 → 133 taken 19506 times.
✗ Branch 132 → 201 not taken.
✓ Branch 133 → 134 taken 3 times.
✓ Branch 133 → 135 taken 19503 times.
19506 if (Capture *lhsCapture = currentScope->symbolTable.lookupCapture(lhsVar->name); lhsCapture)
90
1/2
✓ Branch 134 → 135 taken 3 times.
✗ Branch 134 → 201 not taken.
3 lhsCapture->setAccessType(READ_WRITE);
91
92 // Update the state of the variable
93
1/2
✓ Branch 135 → 136 taken 19506 times.
✗ Branch 135 → 199 not taken.
19506 lhsVar->updateState(INITIALIZED, node);
94 }
95
96
2/4
✓ Branch 137 → 138 taken 19506 times.
✗ Branch 137 → 200 not taken.
✓ Branch 138 → 139 taken 19506 times.
✗ Branch 138 → 200 not taken.
39012 return ExprResult{node->setEvaluatedSymbolType(rhsType, manIdx)};
97 }
98
99 throw CompilerError(UNHANDLED_BRANCH, "AssignExpr fall-through"); // GCOV_EXCL_LINE
100 }
101
102 1213 std::any TypeChecker::visitTernaryExpr(TernaryExprNode *node) {
103 // Check if there is a ternary operator applied
104
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 1213 times.
1213 if (!node->falseExpr)
105 return visit(node->condition);
106
107 // Visit condition
108
2/4
✓ Branch 5 → 6 taken 1213 times.
✗ Branch 5 → 126 not taken.
✓ Branch 6 → 7 taken 1213 times.
✗ Branch 6 → 124 not taken.
1213 const auto condition = std::any_cast<ExprResult>(visit(node->condition));
109
2/8
✓ Branch 8 → 9 taken 1213 times.
✗ Branch 8 → 161 not taken.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 14 taken 1213 times.
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 127 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 127 not taken.
1213 HANDLE_UNRESOLVED_TYPE_ER(condition.type)
110
6/10
✓ Branch 14 → 15 taken 1 time.
✓ Branch 14 → 16 taken 1212 times.
✓ Branch 16 → 17 taken 1212 times.
✗ Branch 16 → 128 not taken.
✓ Branch 17 → 18 taken 1212 times.
✗ Branch 17 → 128 not taken.
✓ Branch 18 → 19 taken 1212 times.
✓ Branch 18 → 20 taken 1 time.
✗ Branch 128 → 129 not taken.
✗ Branch 128 → 130 not taken.
1213 const auto trueExpr = node->isShortened ? condition : std::any_cast<ExprResult>(visit(node->trueExpr));
111 1213 const auto [trueType, trueEntry] = trueExpr;
112
2/8
✓ Branch 20 → 21 taken 1213 times.
✗ Branch 20 → 161 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 21 → 26 taken 1213 times.
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 132 not taken.
✗ Branch 23 → 24 not taken.
✗ Branch 23 → 132 not taken.
1213 HANDLE_UNRESOLVED_TYPE_ER(trueType)
113
2/4
✓ Branch 26 → 27 taken 1213 times.
✗ Branch 26 → 135 not taken.
✓ Branch 27 → 28 taken 1213 times.
✗ Branch 27 → 133 not taken.
1213 const auto falseExpr = std::any_cast<ExprResult>(visit(node->falseExpr));
114 1213 const auto [falseType, falseEntry] = falseExpr;
115
2/8
✓ Branch 29 → 30 taken 1213 times.
✗ Branch 29 → 161 not taken.
✗ Branch 30 → 31 not taken.
✓ Branch 30 → 35 taken 1213 times.
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 136 not taken.
✗ Branch 32 → 33 not taken.
✗ Branch 32 → 136 not taken.
1213 HANDLE_UNRESOLVED_TYPE_ER(falseType)
116
117 // Check if the condition evaluates to bool
118
3/4
✓ Branch 35 → 36 taken 1213 times.
✗ Branch 35 → 161 not taken.
✓ Branch 36 → 37 taken 1 time.
✓ Branch 36 → 47 taken 1212 times.
1213 if (!condition.type.is(TY_BOOL))
119
4/8
✓ Branch 39 → 40 taken 1 time.
✗ Branch 39 → 139 not taken.
✓ Branch 40 → 41 taken 1 time.
✗ Branch 40 → 137 not taken.
✓ Branch 43 → 44 taken 1 time.
✗ Branch 43 → 143 not taken.
✓ Branch 44 → 45 taken 1 time.
✗ Branch 44 → 143 not taken.
4 SOFT_ERROR_ER(node->condition, OPERATOR_WRONG_DATA_TYPE, "Condition operand in ternary must be a bool")
120
121 // Check if trueType and falseType are matching
122
1/2
✓ Branch 47 → 48 taken 1212 times.
✗ Branch 47 → 161 not taken.
1212 const QualType trueTypeModified = trueType.removeReferenceWrapper();
123
1/2
✓ Branch 48 → 49 taken 1212 times.
✗ Branch 48 → 161 not taken.
1212 const QualType falseTypeModified = falseType.removeReferenceWrapper();
124
3/4
✓ Branch 49 → 50 taken 1212 times.
✗ Branch 49 → 161 not taken.
✓ Branch 50 → 51 taken 1 time.
✓ Branch 50 → 66 taken 1211 times.
1212 if (!trueTypeModified.matches(falseTypeModified, false, true, false))
125
8/16
✓ Branch 51 → 52 taken 1 time.
✗ Branch 51 → 157 not taken.
✓ Branch 52 → 53 taken 1 time.
✗ Branch 52 → 152 not taken.
✓ Branch 53 → 54 taken 1 time.
✗ Branch 53 → 150 not taken.
✓ Branch 54 → 55 taken 1 time.
✗ Branch 54 → 148 not taken.
✓ Branch 55 → 56 taken 1 time.
✗ Branch 55 → 146 not taken.
✓ Branch 56 → 57 taken 1 time.
✗ Branch 56 → 144 not taken.
✓ Branch 62 → 63 taken 1 time.
✗ Branch 62 → 159 not taken.
✓ Branch 63 → 64 taken 1 time.
✗ Branch 63 → 159 not taken.
2 SOFT_ERROR_ER(node, OPERATOR_WRONG_DATA_TYPE,
126 "True and false operands in ternary must be of same data type. Got " + trueType.getName(true) + " and " +
127 falseType.getName(true))
128
129 // The result type must be a reference if one of true/false branch is of reference type. Otherwise,
130 // the copy ctor is not called correctly
131
3/4
✓ Branch 66 → 67 taken 1211 times.
✗ Branch 66 → 161 not taken.
✓ Branch 67 → 68 taken 9 times.
✓ Branch 67 → 69 taken 1202 times.
1211 QualType resultType = trueType.isRef() ? trueType : falseType;
132 // Infer the const-ness from the more restrictive operand
133
7/10
✓ Branch 70 → 71 taken 1211 times.
✗ Branch 70 → 161 not taken.
✓ Branch 71 → 72 taken 1181 times.
✓ Branch 71 → 74 taken 30 times.
✓ Branch 72 → 73 taken 1181 times.
✗ Branch 72 → 161 not taken.
✓ Branch 73 → 74 taken 349 times.
✓ Branch 73 → 75 taken 832 times.
✓ Branch 76 → 77 taken 1211 times.
✗ Branch 76 → 161 not taken.
1211 resultType.makeConst(trueType.isConst() || falseType.isConst());
134
135 // If there is an anonymous symbol attached to left or right, remove it,
136 // since the result takes over the ownership of any destructible object.
137 1211 bool removedAnonymousSymbols = false;
138
2/2
✓ Branch 77 → 78 taken 353 times.
✓ Branch 77 → 89 taken 858 times.
1211 if (trueEntry) {
139
2/2
✓ Branch 78 → 79 taken 219 times.
✓ Branch 78 → 81 taken 134 times.
353 if (trueEntry->anonymous) {
140
1/2
✓ Branch 79 → 80 taken 219 times.
✗ Branch 79 → 161 not taken.
219 currentScope->symbolTable.deleteAnonymous(trueEntry->name);
141 219 removedAnonymousSymbols = true;
142
8/10
✓ Branch 81 → 82 taken 134 times.
✗ Branch 81 → 161 not taken.
✓ Branch 82 → 83 taken 126 times.
✓ Branch 82 → 86 taken 8 times.
✓ Branch 83 → 84 taken 126 times.
✗ Branch 83 → 161 not taken.
✓ Branch 84 → 85 taken 9 times.
✓ Branch 84 → 86 taken 117 times.
✓ Branch 87 → 88 taken 9 times.
✓ Branch 87 → 89 taken 125 times.
134 } else if (!trueType.isRef() && !trueType.isTriviallyCopyable(node)) {
143 9 node->trueSideCallsCopyCtor = true;
144 }
145 }
146
2/2
✓ Branch 89 → 90 taken 723 times.
✓ Branch 89 → 101 taken 488 times.
1211 if (falseEntry) {
147
2/2
✓ Branch 90 → 91 taken 209 times.
✓ Branch 90 → 93 taken 514 times.
723 if (falseEntry->anonymous) {
148
1/2
✓ Branch 91 → 92 taken 209 times.
✗ Branch 91 → 161 not taken.
209 currentScope->symbolTable.deleteAnonymous(falseEntry->name);
149 209 removedAnonymousSymbols = true;
150
8/10
✓ Branch 93 → 94 taken 514 times.
✗ Branch 93 → 161 not taken.
✓ Branch 94 → 95 taken 498 times.
✓ Branch 94 → 98 taken 16 times.
✓ Branch 95 → 96 taken 498 times.
✗ Branch 95 → 161 not taken.
✓ Branch 96 → 97 taken 20 times.
✓ Branch 96 → 98 taken 478 times.
✓ Branch 99 → 100 taken 20 times.
✓ Branch 99 → 101 taken 494 times.
514 } else if (!falseType.isRef() && !falseType.isTriviallyCopyable(node)) {
151 20 node->falseSideCallsCopyCtor = true;
152 }
153 }
154
155 // Create a new anonymous symbol for the result if required
156 1211 SymbolTableEntry *anonymousSymbol = nullptr;
157
4/4
✓ Branch 101 → 102 taken 1202 times.
✓ Branch 101 → 103 taken 9 times.
✓ Branch 102 → 103 taken 14 times.
✓ Branch 102 → 104 taken 1188 times.
1211 const bool calledCopyCtor = node->trueSideCallsCopyCtor || node->falseSideCallsCopyCtor;
158
9/10
✓ Branch 105 → 106 taken 990 times.
✓ Branch 105 → 109 taken 221 times.
✓ Branch 106 → 107 taken 975 times.
✓ Branch 106 → 109 taken 15 times.
✓ Branch 107 → 108 taken 975 times.
✗ Branch 107 → 161 not taken.
✓ Branch 108 → 109 taken 16 times.
✓ Branch 108 → 110 taken 959 times.
✓ Branch 111 → 112 taken 252 times.
✓ Branch 111 → 114 taken 959 times.
1211 if (removedAnonymousSymbols || calledCopyCtor || resultType.isRef())
159
1/2
✓ Branch 112 → 113 taken 252 times.
✗ Branch 112 → 161 not taken.
252 anonymousSymbol = currentScope->symbolTable.insertAnonymous(resultType, node);
160
161 // Look up the copy ctor if at least one side needs it
162
4/4
✓ Branch 114 → 115 taken 1202 times.
✓ Branch 114 → 116 taken 9 times.
✓ Branch 115 → 116 taken 14 times.
✓ Branch 115 → 118 taken 1188 times.
1211 if (node->trueSideCallsCopyCtor || node->falseSideCallsCopyCtor)
163
1/2
✓ Branch 116 → 117 taken 23 times.
✗ Branch 116 → 161 not taken.
23 node->calledCopyCtor = matchCopyCtor(trueTypeModified, node);
164
165
2/4
✓ Branch 118 → 119 taken 1211 times.
✗ Branch 118 → 160 not taken.
✓ Branch 119 → 120 taken 1211 times.
✗ Branch 119 → 160 not taken.
2422 return ExprResult{node->setEvaluatedSymbolType(resultType, manIdx), anonymousSymbol};
166 }
167
168 1819 std::any TypeChecker::visitLogicalOrExpr(LogicalOrExprNode *node) {
169 // Check if a logical or operator is applied
170
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 1819 times.
1819 if (node->operands.size() == 1)
171 return visit(node->operands.front());
172
173 // Visit leftmost operand
174
2/4
✓ Branch 8 → 9 taken 1819 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 1819 times.
✗ Branch 9 → 37 not taken.
1819 auto currentOperand = std::any_cast<ExprResult>(visit(node->operands[0]));
175
2/8
✓ Branch 11 → 12 taken 1819 times.
✗ Branch 11 → 46 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 1819 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 40 not taken.
1819 HANDLE_UNRESOLVED_TYPE_ER(currentOperand.type)
176
177 // Loop through all remaining operands
178
2/2
✓ Branch 31 → 18 taken 2413 times.
✓ Branch 31 → 32 taken 1818 times.
4231 for (size_t i = 1; i < node->operands.size(); i++) {
179
2/4
✓ Branch 19 → 20 taken 2413 times.
✗ Branch 19 → 43 not taken.
✓ Branch 20 → 21 taken 2413 times.
✗ Branch 20 → 41 not taken.
2413 auto rhsOperand = std::any_cast<ExprResult>(visit(node->operands[i]));
180
2/8
✓ Branch 22 → 23 taken 2413 times.
✗ Branch 22 → 45 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 2413 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 44 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 44 not taken.
2413 HANDLE_UNRESOLVED_TYPE_ER(rhsOperand.type)
181
2/2
✓ Branch 28 → 29 taken 2412 times.
✓ Branch 28 → 45 taken 1 time.
2413 currentOperand = {OpRuleManager::getLogicalOrResultType(node, currentOperand, rhsOperand)};
182 }
183
184
1/2
✓ Branch 32 → 33 taken 1818 times.
✗ Branch 32 → 46 not taken.
1818 node->setEvaluatedSymbolType(currentOperand.type, manIdx);
185
1/2
✓ Branch 33 → 34 taken 1818 times.
✗ Branch 33 → 46 not taken.
1818 return currentOperand;
186 }
187
188 1091 std::any TypeChecker::visitLogicalAndExpr(LogicalAndExprNode *node) {
189 // Check if a logical and operator is applied
190
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 1091 times.
1091 if (node->operands.size() == 1)
191 return visit(node->operands.front());
192
193 // Visit leftmost operand
194
2/4
✓ Branch 8 → 9 taken 1091 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 1091 times.
✗ Branch 9 → 37 not taken.
1091 auto currentOperand = std::any_cast<ExprResult>(visit(node->operands[0]));
195
2/8
✓ Branch 11 → 12 taken 1091 times.
✗ Branch 11 → 46 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 1091 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 40 not taken.
1091 HANDLE_UNRESOLVED_TYPE_ER(currentOperand.type)
196
197 // Loop through all remaining operands
198
2/2
✓ Branch 31 → 18 taken 1508 times.
✓ Branch 31 → 32 taken 1091 times.
2599 for (size_t i = 1; i < node->operands.size(); i++) {
199
2/4
✓ Branch 19 → 20 taken 1508 times.
✗ Branch 19 → 43 not taken.
✓ Branch 20 → 21 taken 1508 times.
✗ Branch 20 → 41 not taken.
1508 auto rhsOperand = std::any_cast<ExprResult>(visit(node->operands[i]));
200
2/8
✓ Branch 22 → 23 taken 1508 times.
✗ Branch 22 → 45 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 1508 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 44 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 44 not taken.
1508 HANDLE_UNRESOLVED_TYPE_ER(rhsOperand.type)
201
1/2
✓ Branch 28 → 29 taken 1508 times.
✗ Branch 28 → 45 not taken.
1508 currentOperand = {OpRuleManager::getLogicalAndResultType(node, currentOperand, rhsOperand)};
202 }
203
204
1/2
✓ Branch 32 → 33 taken 1091 times.
✗ Branch 32 → 46 not taken.
1091 node->setEvaluatedSymbolType(currentOperand.type, manIdx);
205
1/2
✓ Branch 33 → 34 taken 1091 times.
✗ Branch 33 → 46 not taken.
1091 return currentOperand;
206 }
207
208 277 std::any TypeChecker::visitBitwiseOrExpr(BitwiseOrExprNode *node) {
209 // Check if a bitwise or operator is applied
210
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 277 times.
277 if (node->operands.size() == 1)
211 return visit(node->operands.front());
212
213 // Visit leftmost operand
214
2/4
✓ Branch 8 → 9 taken 277 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 277 times.
✗ Branch 9 → 37 not taken.
277 auto currentOperand = std::any_cast<ExprResult>(visit(node->operands[0]));
215
2/8
✓ Branch 11 → 12 taken 277 times.
✗ Branch 11 → 46 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 277 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 40 not taken.
277 HANDLE_UNRESOLVED_TYPE_ER(currentOperand.type)
216
217 // Loop through all remaining operands
218
2/2
✓ Branch 31 → 18 taken 280 times.
✓ Branch 31 → 32 taken 276 times.
556 for (size_t i = 1; i < node->operands.size(); i++) {
219
2/4
✓ Branch 19 → 20 taken 280 times.
✗ Branch 19 → 43 not taken.
✓ Branch 20 → 21 taken 280 times.
✗ Branch 20 → 41 not taken.
280 auto rhsOperand = std::any_cast<ExprResult>(visit(node->operands[i]));
220
2/8
✓ Branch 22 → 23 taken 280 times.
✗ Branch 22 → 45 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 280 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 44 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 44 not taken.
280 HANDLE_UNRESOLVED_TYPE_ER(rhsOperand.type)
221
2/2
✓ Branch 28 → 29 taken 279 times.
✓ Branch 28 → 45 taken 1 time.
280 currentOperand = opRuleManager.getBitwiseOrResultType(node, currentOperand, rhsOperand, i - 1);
222 }
223
224
1/2
✓ Branch 32 → 33 taken 276 times.
✗ Branch 32 → 46 not taken.
276 node->setEvaluatedSymbolType(currentOperand.type, manIdx);
225
1/2
✓ Branch 33 → 34 taken 276 times.
✗ Branch 33 → 46 not taken.
276 return currentOperand;
226 }
227
228 38 std::any TypeChecker::visitBitwiseXorExpr(BitwiseXorExprNode *node) {
229 // Check if a bitwise xor operator is applied
230
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 38 times.
38 if (node->operands.size() == 1)
231 return visit(node->operands.front());
232
233 // Visit leftmost operand
234
2/4
✓ Branch 8 → 9 taken 38 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 38 times.
✗ Branch 9 → 37 not taken.
38 auto currentOperand = std::any_cast<ExprResult>(visit(node->operands[0]));
235
2/8
✓ Branch 11 → 12 taken 38 times.
✗ Branch 11 → 46 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 38 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 40 not taken.
38 HANDLE_UNRESOLVED_TYPE_ER(currentOperand.type)
236
237 // Loop through all remaining operands
238
2/2
✓ Branch 31 → 18 taken 41 times.
✓ Branch 31 → 32 taken 38 times.
79 for (size_t i = 1; i < node->operands.size(); i++) {
239
2/4
✓ Branch 19 → 20 taken 41 times.
✗ Branch 19 → 43 not taken.
✓ Branch 20 → 21 taken 41 times.
✗ Branch 20 → 41 not taken.
41 auto rhsOperand = std::any_cast<ExprResult>(visit(node->operands[i]));
240
2/8
✓ Branch 22 → 23 taken 41 times.
✗ Branch 22 → 45 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 41 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 44 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 44 not taken.
41 HANDLE_UNRESOLVED_TYPE_ER(rhsOperand.type)
241
1/2
✓ Branch 28 → 29 taken 41 times.
✗ Branch 28 → 45 not taken.
41 currentOperand = opRuleManager.getBitwiseXorResultType(node, currentOperand, rhsOperand, i - 1);
242 }
243
244
1/2
✓ Branch 32 → 33 taken 38 times.
✗ Branch 32 → 46 not taken.
38 node->setEvaluatedSymbolType(currentOperand.type, manIdx);
245
1/2
✓ Branch 33 → 34 taken 38 times.
✗ Branch 33 → 46 not taken.
38 return currentOperand;
246 }
247
248 70 std::any TypeChecker::visitBitwiseAndExpr(BitwiseAndExprNode *node) {
249 // Check if a bitwise and operator is applied
250
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 70 times.
70 if (node->operands.size() == 1)
251 return visit(node->operands.front());
252
253 // Visit leftmost operand
254
2/4
✓ Branch 8 → 9 taken 70 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 70 times.
✗ Branch 9 → 37 not taken.
70 auto currentOperand = std::any_cast<ExprResult>(visit(node->operands[0]));
255
2/8
✓ Branch 11 → 12 taken 70 times.
✗ Branch 11 → 46 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 70 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 40 not taken.
70 HANDLE_UNRESOLVED_TYPE_ER(currentOperand.type)
256
257 // Loop through all remaining operands
258
2/2
✓ Branch 31 → 18 taken 73 times.
✓ Branch 31 → 32 taken 70 times.
143 for (size_t i = 1; i < node->operands.size(); i++) {
259
2/4
✓ Branch 19 → 20 taken 73 times.
✗ Branch 19 → 43 not taken.
✓ Branch 20 → 21 taken 73 times.
✗ Branch 20 → 41 not taken.
73 auto rhsOperand = std::any_cast<ExprResult>(visit(node->operands[i]));
260
2/8
✓ Branch 22 → 23 taken 73 times.
✗ Branch 22 → 45 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 73 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 44 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 44 not taken.
73 HANDLE_UNRESOLVED_TYPE_ER(rhsOperand.type)
261
1/2
✓ Branch 28 → 29 taken 73 times.
✗ Branch 28 → 45 not taken.
73 currentOperand = opRuleManager.getBitwiseAndResultType(node, currentOperand, rhsOperand, i - 1);
262 }
263
264
1/2
✓ Branch 32 → 33 taken 70 times.
✗ Branch 32 → 46 not taken.
70 node->setEvaluatedSymbolType(currentOperand.type, manIdx);
265
1/2
✓ Branch 33 → 34 taken 70 times.
✗ Branch 33 → 46 not taken.
70 return currentOperand;
266 }
267
268 13852 std::any TypeChecker::visitEqualityExpr(EqualityExprNode *node) {
269 // Check if at least one equality operator is applied
270
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 13852 times.
13852 if (node->operands.size() == 1)
271 return visit(node->operands.front());
272
273 // Visit right side first, then left side
274
2/4
✓ Branch 8 → 9 taken 13852 times.
✗ Branch 8 → 58 not taken.
✓ Branch 9 → 10 taken 13852 times.
✗ Branch 9 → 56 not taken.
13852 const auto rhs = std::any_cast<ExprResult>(visit(node->operands[1]));
275
2/8
✓ Branch 11 → 12 taken 13852 times.
✗ Branch 11 → 73 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 13852 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 59 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 59 not taken.
13852 HANDLE_UNRESOLVED_TYPE_ER(rhs.type)
276
2/4
✓ Branch 18 → 19 taken 13852 times.
✗ Branch 18 → 62 not taken.
✓ Branch 19 → 20 taken 13852 times.
✗ Branch 19 → 60 not taken.
13852 const auto lhs = std::any_cast<ExprResult>(visit(node->operands[0]));
277
2/8
✓ Branch 21 → 22 taken 13852 times.
✗ Branch 21 → 73 not taken.
✗ Branch 22 → 23 not taken.
✓ Branch 22 → 27 taken 13852 times.
✗ Branch 23 → 24 not taken.
✗ Branch 23 → 63 not taken.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 63 not taken.
13852 HANDLE_UNRESOLVED_TYPE_ER(lhs.type)
278
279 // Check if we need the string runtime to perform a string comparison
280
10/14
✓ Branch 27 → 28 taken 13852 times.
✗ Branch 27 → 73 not taken.
✓ Branch 28 → 29 taken 340 times.
✓ Branch 28 → 36 taken 13512 times.
✓ Branch 29 → 30 taken 340 times.
✗ Branch 29 → 73 not taken.
✓ Branch 30 → 31 taken 339 times.
✓ Branch 30 → 36 taken 1 time.
✓ Branch 31 → 32 taken 339 times.
✗ Branch 31 → 73 not taken.
✓ Branch 34 → 35 taken 339 times.
✗ Branch 34 → 36 not taken.
✓ Branch 37 → 38 taken 339 times.
✓ Branch 37 → 39 taken 13513 times.
14191 if (lhs.type.is(TY_STRING) && rhs.type.is(TY_STRING) && !sourceFile->isStringRT())
281
1/2
✓ Branch 38 → 39 taken 339 times.
✗ Branch 38 → 73 not taken.
339 sourceFile->requestRuntimeModule(STRING_RT);
282
283 // Check operator
284 13852 ExprResult result;
285
2/2
✓ Branch 39 → 40 taken 10454 times.
✓ Branch 39 → 41 taken 3398 times.
13852 if (node->op == EqualityExprNode::EqualityOp::OP_EQUAL) // Operator was equal
286
2/2
✓ Branch 40 → 51 taken 10453 times.
✓ Branch 40 → 73 taken 1 time.
10454 result = opRuleManager.getEqualResultType(node, lhs, rhs);
287
1/2
✓ Branch 41 → 42 taken 3398 times.
✗ Branch 41 → 43 not taken.
3398 else if (node->op == EqualityExprNode::EqualityOp::OP_NOT_EQUAL) // Operator was not equal
288
1/2
✓ Branch 42 → 51 taken 3398 times.
✗ Branch 42 → 73 not taken.
3398 result = opRuleManager.getNotEqualResultType(node, lhs, rhs);
289 else
290 throw CompilerError(UNHANDLED_BRANCH, "EqualityExpr fall-through"); // GCOV_EXCL_LINE
291
292
1/2
✓ Branch 51 → 52 taken 13851 times.
✗ Branch 51 → 73 not taken.
13851 node->setEvaluatedSymbolType(result.type, manIdx);
293
1/2
✓ Branch 52 → 53 taken 13851 times.
✗ Branch 52 → 73 not taken.
13851 return result;
294 }
295
296 9084 std::any TypeChecker::visitRelationalExpr(RelationalExprNode *node) {
297 // Check if a relational operator is applied
298
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 9084 times.
9084 if (node->operands.size() == 1)
299 return visit(node->operands.front());
300
301 // Visit right side first, then left side
302
2/4
✓ Branch 8 → 9 taken 9084 times.
✗ Branch 8 → 55 not taken.
✓ Branch 9 → 10 taken 9084 times.
✗ Branch 9 → 53 not taken.
9084 const auto rhs = std::any_cast<ExprResult>(visit(node->operands[1]));
303
5/8
✓ Branch 11 → 12 taken 9084 times.
✗ Branch 11 → 75 not taken.
✓ Branch 12 → 13 taken 1 time.
✓ Branch 12 → 17 taken 9083 times.
✓ Branch 13 → 14 taken 1 time.
✗ Branch 13 → 56 not taken.
✓ Branch 14 → 15 taken 1 time.
✗ Branch 14 → 56 not taken.
9085 HANDLE_UNRESOLVED_TYPE_ER(rhs.type)
304
2/4
✓ Branch 18 → 19 taken 9083 times.
✗ Branch 18 → 59 not taken.
✓ Branch 19 → 20 taken 9083 times.
✗ Branch 19 → 57 not taken.
9083 const auto lhs = std::any_cast<ExprResult>(visit(node->operands[0]));
305
2/8
✓ Branch 21 → 22 taken 9083 times.
✗ Branch 21 → 75 not taken.
✗ Branch 22 → 23 not taken.
✓ Branch 22 → 27 taken 9083 times.
✗ Branch 23 → 24 not taken.
✗ Branch 23 → 60 not taken.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 60 not taken.
9083 HANDLE_UNRESOLVED_TYPE_ER(lhs.type)
306
307 // Check operator
308 9083 QualType resultType;
309
2/2
✓ Branch 27 → 28 taken 4203 times.
✓ Branch 27 → 30 taken 4880 times.
9083 if (node->op == RelationalExprNode::RelationalOp::OP_LESS) // Operator was less
310
1/2
✓ Branch 28 → 29 taken 4203 times.
✗ Branch 28 → 61 not taken.
4203 resultType = OpRuleManager::getLessResultType(node, lhs, rhs);
311
2/2
✓ Branch 30 → 31 taken 1685 times.
✓ Branch 30 → 33 taken 3195 times.
4880 else if (node->op == RelationalExprNode::RelationalOp::OP_GREATER) // Operator was greater
312
2/2
✓ Branch 31 → 32 taken 1684 times.
✓ Branch 31 → 62 taken 1 time.
1685 resultType = OpRuleManager::getGreaterResultType(node, lhs, rhs);
313
2/2
✓ Branch 33 → 34 taken 1203 times.
✓ Branch 33 → 36 taken 1992 times.
3195 else if (node->op == RelationalExprNode::RelationalOp::OP_LESS_EQUAL) // Operator was less equal
314
1/2
✓ Branch 34 → 35 taken 1203 times.
✗ Branch 34 → 63 not taken.
1203 resultType = OpRuleManager::getLessEqualResultType(node, lhs, rhs);
315
1/2
✓ Branch 36 → 37 taken 1992 times.
✗ Branch 36 → 39 not taken.
1992 else if (node->op == RelationalExprNode::RelationalOp::OP_GREATER_EQUAL) // Operator was greater equal
316
1/2
✓ Branch 37 → 38 taken 1992 times.
✗ Branch 37 → 64 not taken.
1992 resultType = OpRuleManager::getGreaterEqualResultType(node, lhs, rhs);
317 else
318 throw CompilerError(UNHANDLED_BRANCH, "RelationalExpr fall-through"); // GCOV_EXCL_LINE
319
320
2/4
✓ Branch 47 → 48 taken 9082 times.
✗ Branch 47 → 74 not taken.
✓ Branch 48 → 49 taken 9082 times.
✗ Branch 48 → 74 not taken.
18164 return ExprResult{node->setEvaluatedSymbolType(resultType, manIdx)};
321 }
322
323 1305 std::any TypeChecker::visitShiftExpr(ShiftExprNode *node) {
324 // Check if at least one shift operator is applied
325
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 1305 times.
1305 if (node->operands.size() == 1)
326 return visit(node->operands.front());
327
328 // Visit leftmost operand
329
2/4
✓ Branch 8 → 9 taken 1305 times.
✗ Branch 8 → 53 not taken.
✓ Branch 9 → 10 taken 1305 times.
✗ Branch 9 → 51 not taken.
1305 auto currentResult = std::any_cast<ExprResult>(visit(node->operands[0]));
330
2/8
✓ Branch 11 → 12 taken 1305 times.
✗ Branch 11 → 69 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 1305 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 54 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 54 not taken.
1305 HANDLE_UNRESOLVED_TYPE_ER(currentResult.type)
331
332 // Loop through remaining operands
333
2/2
✓ Branch 45 → 18 taken 1594 times.
✓ Branch 45 → 46 taken 1305 times.
2899 for (size_t i = 0; i < node->opQueue.size(); i++) {
334
2/4
✓ Branch 19 → 20 taken 1594 times.
✗ Branch 19 → 57 not taken.
✓ Branch 20 → 21 taken 1594 times.
✗ Branch 20 → 55 not taken.
1594 auto operandResult = std::any_cast<ExprResult>(visit(node->operands[i + 1]));
335
2/8
✓ Branch 22 → 23 taken 1594 times.
✗ Branch 22 → 68 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 1594 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 58 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 58 not taken.
1594 HANDLE_UNRESOLVED_TYPE_ER(operandResult.type)
336
337 // Check operator
338
1/2
✓ Branch 28 → 29 taken 1594 times.
✗ Branch 28 → 68 not taken.
1594 const ShiftExprNode::ShiftOp &op = node->opQueue.front().first;
339
2/2
✓ Branch 29 → 30 taken 1405 times.
✓ Branch 29 → 31 taken 189 times.
1594 if (op == ShiftExprNode::ShiftOp::OP_SHIFT_LEFT)
340
1/2
✓ Branch 30 → 41 taken 1405 times.
✗ Branch 30 → 68 not taken.
1405 currentResult = opRuleManager.getShiftLeftResultType(node, currentResult, operandResult, i);
341
1/2
✓ Branch 31 → 32 taken 189 times.
✗ Branch 31 → 33 not taken.
189 else if (op == ShiftExprNode::ShiftOp::OP_SHIFT_RIGHT)
342
1/2
✓ Branch 32 → 41 taken 189 times.
✗ Branch 32 → 68 not taken.
189 currentResult = opRuleManager.getShiftRightResultType(node, currentResult, operandResult, i);
343 else
344 throw CompilerError(UNHANDLED_BRANCH, "ShiftExpr fall-through"); // GCOV_EXCL_LINE
345
346 // Push the new item and pop the old one on the other side of the queue
347
1/2
✓ Branch 41 → 42 taken 1594 times.
✗ Branch 41 → 68 not taken.
1594 node->opQueue.emplace(op, currentResult.type);
348
1/2
✓ Branch 42 → 43 taken 1594 times.
✗ Branch 42 → 68 not taken.
1594 node->opQueue.pop();
349 }
350
351
1/2
✓ Branch 46 → 47 taken 1305 times.
✗ Branch 46 → 69 not taken.
1305 node->setEvaluatedSymbolType(currentResult.type, manIdx);
352
1/2
✓ Branch 47 → 48 taken 1305 times.
✗ Branch 47 → 69 not taken.
1305 return currentResult;
353 }
354
355 8968 std::any TypeChecker::visitAdditiveExpr(AdditiveExprNode *node) {
356 // Check if at least one additive operator is applied
357
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 8968 times.
8968 if (node->operands.size() == 1)
358 return visit(node->operands.front());
359
360 // Visit leftmost operand
361
2/4
✓ Branch 8 → 9 taken 8968 times.
✗ Branch 8 → 53 not taken.
✓ Branch 9 → 10 taken 8968 times.
✗ Branch 9 → 51 not taken.
8968 auto currentResult = std::any_cast<ExprResult>(visit(node->operands[0]));
362
2/8
✓ Branch 11 → 12 taken 8968 times.
✗ Branch 11 → 69 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 8968 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 54 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 54 not taken.
8968 HANDLE_UNRESOLVED_TYPE_ER(currentResult.type)
363
364 // Loop through remaining operands
365
2/2
✓ Branch 45 → 18 taken 10200 times.
✓ Branch 45 → 46 taken 8967 times.
19167 for (size_t i = 0; i < node->opQueue.size(); i++) {
366
2/4
✓ Branch 19 → 20 taken 10200 times.
✗ Branch 19 → 57 not taken.
✓ Branch 20 → 21 taken 10200 times.
✗ Branch 20 → 55 not taken.
10200 auto operandResult = std::any_cast<ExprResult>(visit(node->operands[i + 1]));
367
2/8
✓ Branch 22 → 23 taken 10200 times.
✗ Branch 22 → 68 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 10200 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 58 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 58 not taken.
10200 HANDLE_UNRESOLVED_TYPE_ER(operandResult.type)
368
369 // Check operator
370
1/2
✓ Branch 28 → 29 taken 10200 times.
✗ Branch 28 → 68 not taken.
10200 const AdditiveExprNode::AdditiveOp &op = node->opQueue.front().first;
371
2/2
✓ Branch 29 → 30 taken 6430 times.
✓ Branch 29 → 31 taken 3770 times.
10200 if (op == AdditiveExprNode::AdditiveOp::OP_PLUS)
372
2/2
✓ Branch 30 → 41 taken 6429 times.
✓ Branch 30 → 68 taken 1 time.
6430 currentResult = opRuleManager.getPlusResultType(node, currentResult, operandResult, i);
373
1/2
✓ Branch 31 → 32 taken 3770 times.
✗ Branch 31 → 33 not taken.
3770 else if (op == AdditiveExprNode::AdditiveOp::OP_MINUS)
374
1/2
✓ Branch 32 → 41 taken 3770 times.
✗ Branch 32 → 68 not taken.
3770 currentResult = opRuleManager.getMinusResultType(node, currentResult, operandResult, i);
375 else
376 throw CompilerError(UNHANDLED_BRANCH, "AdditiveExpr fall-through"); // GCOV_EXCL_LINE
377
378 // Push the new item and pop the old one on the other side of the queue
379
1/2
✓ Branch 41 → 42 taken 10199 times.
✗ Branch 41 → 68 not taken.
10199 node->opQueue.emplace(op, currentResult.type);
380
1/2
✓ Branch 42 → 43 taken 10199 times.
✗ Branch 42 → 68 not taken.
10199 node->opQueue.pop();
381 }
382
383
1/2
✓ Branch 46 → 47 taken 8967 times.
✗ Branch 46 → 69 not taken.
8967 node->setEvaluatedSymbolType(currentResult.type, manIdx);
384
1/2
✓ Branch 47 → 48 taken 8967 times.
✗ Branch 47 → 69 not taken.
8967 return currentResult;
385 }
386
387 2972 std::any TypeChecker::visitMultiplicativeExpr(MultiplicativeExprNode *node) {
388 // Check if at least one multiplicative operator is applied
389
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 2972 times.
2972 if (node->operands.size() == 1)
390 return visit(node->operands.front());
391
392 // Visit leftmost operand
393
2/4
✓ Branch 8 → 9 taken 2972 times.
✗ Branch 8 → 55 not taken.
✓ Branch 9 → 10 taken 2972 times.
✗ Branch 9 → 53 not taken.
2972 auto currentResult = std::any_cast<ExprResult>(visit(node->operands[0]));
394
2/8
✓ Branch 11 → 12 taken 2972 times.
✗ Branch 11 → 71 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 2972 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 56 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 56 not taken.
2972 HANDLE_UNRESOLVED_TYPE_ER(currentResult.type)
395 // Loop through remaining operands
396
2/2
✓ Branch 47 → 18 taken 3026 times.
✓ Branch 47 → 48 taken 2971 times.
5997 for (size_t i = 0; i < node->opQueue.size(); i++) {
397
2/4
✓ Branch 19 → 20 taken 3026 times.
✗ Branch 19 → 59 not taken.
✓ Branch 20 → 21 taken 3026 times.
✗ Branch 20 → 57 not taken.
3026 auto operandResult = std::any_cast<ExprResult>(visit(node->operands[i + 1]));
398
2/8
✓ Branch 22 → 23 taken 3026 times.
✗ Branch 22 → 70 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 3026 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 60 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 60 not taken.
3026 HANDLE_UNRESOLVED_TYPE_ER(operandResult.type)
399
400 // Check operator
401
1/2
✓ Branch 28 → 29 taken 3026 times.
✗ Branch 28 → 70 not taken.
3026 const MultiplicativeExprNode::MultiplicativeOp &op = node->opQueue.front().first;
402
2/2
✓ Branch 29 → 30 taken 2385 times.
✓ Branch 29 → 31 taken 641 times.
3026 if (op == MultiplicativeExprNode::MultiplicativeOp::OP_MUL)
403
2/2
✓ Branch 30 → 43 taken 2384 times.
✓ Branch 30 → 70 taken 1 time.
2385 currentResult = opRuleManager.getMulResultType(node, currentResult, operandResult, i);
404
2/2
✓ Branch 31 → 32 taken 515 times.
✓ Branch 31 → 33 taken 126 times.
641 else if (op == MultiplicativeExprNode::MultiplicativeOp::OP_DIV)
405
1/2
✓ Branch 32 → 43 taken 515 times.
✗ Branch 32 → 70 not taken.
515 currentResult = opRuleManager.getDivResultType(node, currentResult, operandResult, i);
406
1/2
✓ Branch 33 → 34 taken 126 times.
✗ Branch 33 → 35 not taken.
126 else if (op == MultiplicativeExprNode::MultiplicativeOp::OP_REM)
407
1/2
✓ Branch 34 → 43 taken 126 times.
✗ Branch 34 → 70 not taken.
126 currentResult = OpRuleManager::getRemResultType(node, currentResult, operandResult);
408 else
409 throw CompilerError(UNHANDLED_BRANCH, "Multiplicative fall-through"); // GCOV_EXCL_LINE
410
411 // Push the new item and pop the old one on the other side of the queue
412
1/2
✓ Branch 43 → 44 taken 3025 times.
✗ Branch 43 → 70 not taken.
3025 node->opQueue.emplace(op, currentResult.type);
413
1/2
✓ Branch 44 → 45 taken 3025 times.
✗ Branch 44 → 70 not taken.
3025 node->opQueue.pop();
414 }
415
416
1/2
✓ Branch 48 → 49 taken 2971 times.
✗ Branch 48 → 71 not taken.
2971 node->setEvaluatedSymbolType(currentResult.type, manIdx);
417
1/2
✓ Branch 49 → 50 taken 2971 times.
✗ Branch 49 → 71 not taken.
2971 return currentResult;
418 }
419
420 7950 std::any TypeChecker::visitCastExpr(CastExprNode *node) {
421 // Check if cast is applied
422
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 7950 times.
7950 if (!node->isCast)
423 return visit(node->prefixUnaryExpr);
424
425 // Visit destination type
426
2/4
✓ Branch 5 → 6 taken 7950 times.
✗ Branch 5 → 49 not taken.
✓ Branch 6 → 7 taken 7950 times.
✗ Branch 6 → 47 not taken.
7950 const auto dstType = std::any_cast<QualType>(visit(node->dataType));
427
2/8
✓ Branch 8 → 9 taken 7950 times.
✗ Branch 8 → 65 not taken.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 14 taken 7950 times.
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 50 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 50 not taken.
7950 HANDLE_UNRESOLVED_TYPE_ER(dstType)
428 // Visit source type
429
2/4
✓ Branch 14 → 15 taken 7950 times.
✗ Branch 14 → 53 not taken.
✓ Branch 15 → 16 taken 7950 times.
✗ Branch 15 → 51 not taken.
7950 const auto src = std::any_cast<ExprResult>(visit(node->assignExpr));
430
2/8
✓ Branch 17 → 18 taken 7950 times.
✗ Branch 17 → 65 not taken.
✗ Branch 18 → 19 not taken.
✓ Branch 18 → 23 taken 7950 times.
✗ Branch 19 → 20 not taken.
✗ Branch 19 → 54 not taken.
✗ Branch 20 → 21 not taken.
✗ Branch 20 → 54 not taken.
7950 HANDLE_UNRESOLVED_TYPE_ER(src.type)
431
432 // Check for identity cast
433
3/4
✓ Branch 23 → 24 taken 7950 times.
✗ Branch 23 → 65 not taken.
✓ Branch 24 → 25 taken 877 times.
✓ Branch 24 → 34 taken 7073 times.
7950 if (src.type == dstType) {
434
2/4
✓ Branch 27 → 28 taken 877 times.
✗ Branch 27 → 57 not taken.
✓ Branch 28 → 29 taken 877 times.
✗ Branch 28 → 55 not taken.
1754 const CompilerWarning warning(node->codeLoc, IDENTITY_CAST, "You cast from a type to itself. Thus, this can be simplified.");
435
1/2
✓ Branch 31 → 32 taken 877 times.
✗ Branch 31 → 61 not taken.
877 sourceFile->compilerOutput.warnings.push_back(warning);
436 877 }
437
438 // Get result type
439
1/2
✓ Branch 34 → 35 taken 7950 times.
✗ Branch 34 → 65 not taken.
7950 const QualType resultType = opRuleManager.getCastResultType(node, dstType, src);
440
441
1/2
✓ Branch 35 → 36 taken 7950 times.
✗ Branch 35 → 65 not taken.
7950 const bool typesMatch = dstType.matches(src.type, false, true, true);
442
1/2
✓ Branch 36 → 37 taken 7950 times.
✗ Branch 36 → 65 not taken.
7950 const bool sameContainerType = src.type.isSameContainerTypeAs(dstType);
443
4/4
✓ Branch 37 → 38 taken 7073 times.
✓ Branch 37 → 39 taken 877 times.
✓ Branch 38 → 39 taken 1654 times.
✓ Branch 38 → 40 taken 5419 times.
7950 SymbolTableEntry *entry = typesMatch || sameContainerType ? src.entry : nullptr;
444
2/4
✓ Branch 41 → 42 taken 7950 times.
✗ Branch 41 → 64 not taken.
✓ Branch 42 → 43 taken 7950 times.
✗ Branch 42 → 64 not taken.
15900 return ExprResult{node->setEvaluatedSymbolType(resultType, manIdx), entry};
445 }
446
447 6314 std::any TypeChecker::visitPrefixUnaryExpr(PrefixUnaryExprNode *node) {
448 // If no operator is applied, simply visit the postfix unary expression
449
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 6314 times.
6314 if (node->op == PrefixUnaryExprNode::PrefixUnaryOp::OP_NONE)
450 return visit(node->postfixUnaryExpr);
451
452 // Visit the right side
453 6314 ExprNode *rhsNode = node->prefixUnaryExpr;
454
2/4
✓ Branch 5 → 6 taken 6314 times.
✗ Branch 5 → 58 not taken.
✓ Branch 6 → 7 taken 6314 times.
✗ Branch 6 → 56 not taken.
6314 auto operand = std::any_cast<ExprResult>(visit(rhsNode));
455 6314 auto [operandType, operandEntry] = operand;
456
5/8
✓ Branch 8 → 9 taken 6314 times.
✗ Branch 8 → 79 not taken.
✓ Branch 9 → 10 taken 1 time.
✓ Branch 9 → 14 taken 6313 times.
✓ Branch 10 → 11 taken 1 time.
✗ Branch 10 → 59 not taken.
✓ Branch 11 → 12 taken 1 time.
✗ Branch 11 → 59 not taken.
6315 HANDLE_UNRESOLVED_TYPE_ER(operandType)
457 // Determine action, based on the given operator
458
7/8
✓ Branch 14 → 15 taken 1003 times.
✓ Branch 14 → 17 taken 88 times.
✓ Branch 14 → 25 taken 22 times.
✓ Branch 14 → 33 taken 3456 times.
✓ Branch 14 → 35 taken 12 times.
✓ Branch 14 → 38 taken 903 times.
✓ Branch 14 → 40 taken 829 times.
✗ Branch 14 → 42 not taken.
6313 switch (node->op) {
459 1003 case PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS:
460
1/2
✓ Branch 15 → 16 taken 1003 times.
✗ Branch 15 → 60 not taken.
1003 operandType = OpRuleManager::getPrefixMinusResultType(node, operand);
461 1003 break;
462 88 case PrefixUnaryExprNode::PrefixUnaryOp::OP_PLUS_PLUS:
463
1/2
✓ Branch 17 → 18 taken 88 times.
✗ Branch 17 → 61 not taken.
88 operandType = opRuleManager.getPrefixPlusPlusResultType(node, operand);
464
465
2/2
✓ Branch 18 → 19 taken 85 times.
✓ Branch 18 → 24 taken 3 times.
88 if (operandEntry) {
466 // In case the lhs is captured, notify the capture about the write access
467
2/4
✓ Branch 19 → 20 taken 85 times.
✗ Branch 19 → 79 not taken.
✗ Branch 20 → 21 not taken.
✓ Branch 20 → 22 taken 85 times.
85 if (Capture *lhsCapture = currentScope->symbolTable.lookupCapture(operandEntry->name); lhsCapture)
468 lhsCapture->setAccessType(READ_WRITE);
469
470 // Update the state of the variable
471
1/2
✓ Branch 22 → 23 taken 85 times.
✗ Branch 22 → 62 not taken.
85 operandEntry->updateState(INITIALIZED, node);
472 }
473
474 88 break;
475 22 case PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS_MINUS:
476
2/2
✓ Branch 25 → 26 taken 21 times.
✓ Branch 25 → 63 taken 1 time.
22 operandType = opRuleManager.getPrefixMinusMinusResultType(node, operand);
477
478
2/2
✓ Branch 26 → 27 taken 18 times.
✓ Branch 26 → 32 taken 3 times.
21 if (operandEntry) {
479 // In case the lhs is captured, notify the capture about the write access
480
2/4
✓ Branch 27 → 28 taken 18 times.
✗ Branch 27 → 79 not taken.
✗ Branch 28 → 29 not taken.
✓ Branch 28 → 30 taken 18 times.
18 if (Capture *lhsCapture = currentScope->symbolTable.lookupCapture(operandEntry->name); lhsCapture)
481 lhsCapture->setAccessType(READ_WRITE);
482
483 // Update the state of the variable
484
1/2
✓ Branch 30 → 31 taken 18 times.
✗ Branch 30 → 64 not taken.
18 operandEntry->updateState(INITIALIZED, node);
485 }
486
487 21 break;
488 3456 case PrefixUnaryExprNode::PrefixUnaryOp::OP_NOT:
489
1/2
✓ Branch 33 → 34 taken 3456 times.
✗ Branch 33 → 65 not taken.
3456 operandType = OpRuleManager::getPrefixNotResultType(node, operand);
490 3456 break;
491 12 case PrefixUnaryExprNode::PrefixUnaryOp::OP_BITWISE_NOT: {
492
1/2
✓ Branch 35 → 36 taken 12 times.
✗ Branch 35 → 66 not taken.
12 const ExprResult result = opRuleManager.getPrefixBitwiseNotResultType(node, operand);
493 12 operandType = result.type;
494 12 operandEntry = result.entry;
495 12 break;
496 }
497 903 case PrefixUnaryExprNode::PrefixUnaryOp::OP_DEREFERENCE:
498
2/2
✓ Branch 38 → 39 taken 902 times.
✓ Branch 38 → 67 taken 1 time.
903 operandType = OpRuleManager::getPrefixMulResultType(node, operand);
499 902 break;
500 829 case PrefixUnaryExprNode::PrefixUnaryOp::OP_ADDRESS_OF:
501
1/2
✓ Branch 40 → 41 taken 829 times.
✗ Branch 40 → 68 not taken.
829 operandType = OpRuleManager::getPrefixBitwiseAndResultType(node, operand);
502 829 break;
503 default: // GCOV_EXCL_LINE
504 throw CompilerError(UNHANDLED_BRANCH, "PrefixUnaryExpr fall-through"); // GCOV_EXCL_LINE
505 }
506
507
2/4
✓ Branch 50 → 51 taken 6311 times.
✗ Branch 50 → 78 not taken.
✓ Branch 51 → 52 taken 6311 times.
✗ Branch 51 → 78 not taken.
12622 return ExprResult{node->setEvaluatedSymbolType(operandType, manIdx), operandEntry};
508 }
509
510 62156 std::any TypeChecker::visitPostfixUnaryExpr(PostfixUnaryExprNode *node) {
511 // If no operator is applied, simply visit the atomic expression
512
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 62156 times.
62156 if (node->op == PostfixUnaryExprNode::PostfixUnaryOp::OP_NONE)
513 return visit(node->atomicExpr);
514
515 // Visit left side
516 62156 ExprNode *lhsNode = node->postfixUnaryExpr;
517
2/4
✓ Branch 5 → 6 taken 62156 times.
✗ Branch 5 → 211 not taken.
✓ Branch 6 → 7 taken 62156 times.
✗ Branch 6 → 209 not taken.
62156 auto operand = std::any_cast<ExprResult>(visit(lhsNode));
518 62156 auto [operandType, operandEntry] = operand;
519
5/8
✓ Branch 8 → 9 taken 62156 times.
✗ Branch 8 → 316 not taken.
✓ Branch 9 → 10 taken 6 times.
✓ Branch 9 → 14 taken 62150 times.
✓ Branch 10 → 11 taken 6 times.
✗ Branch 10 → 212 not taken.
✓ Branch 11 → 12 taken 6 times.
✗ Branch 11 → 212 not taken.
62162 HANDLE_UNRESOLVED_TYPE_ER(operandType)
520
521
4/5
✓ Branch 14 → 15 taken 6739 times.
✓ Branch 14 → 101 taken 50416 times.
✓ Branch 14 → 159 taken 4550 times.
✓ Branch 14 → 167 taken 445 times.
✗ Branch 14 → 175 not taken.
62150 switch (node->op) {
522 6739 case PostfixUnaryExprNode::PostfixUnaryOp::OP_SUBSCRIPT: {
523 // Visit index assignment
524 6739 ExprNode *indexAssignExpr = node->subscriptIndexExpr;
525
2/4
✓ Branch 15 → 16 taken 6739 times.
✗ Branch 15 → 215 not taken.
✓ Branch 16 → 17 taken 6739 times.
✗ Branch 16 → 213 not taken.
6739 const auto index = std::any_cast<ExprResult>(visit(indexAssignExpr));
526
2/8
✓ Branch 18 → 19 taken 6739 times.
✗ Branch 18 → 258 not taken.
✗ Branch 19 → 20 not taken.
✓ Branch 19 → 24 taken 6739 times.
✗ Branch 20 → 21 not taken.
✗ Branch 20 → 216 not taken.
✗ Branch 21 → 22 not taken.
✗ Branch 21 → 216 not taken.
6739 HANDLE_UNRESOLVED_TYPE_ER(index.type)
527
528 // Check is there is an overloaded operator function available, if yes accept it
529
1/2
✓ Branch 24 → 25 taken 6739 times.
✗ Branch 24 → 217 not taken.
6739 const auto [type, _] = opRuleManager.isOperatorOverloadingFctAvailable<2>(node, OP_FCT_SUBSCRIPT, {operand, index}, 0);
530
3/4
✓ Branch 25 → 26 taken 6739 times.
✗ Branch 25 → 258 not taken.
✓ Branch 26 → 27 taken 419 times.
✓ Branch 26 → 28 taken 6320 times.
6739 if (!type.is(TY_INVALID)) {
531 419 operandType = type;
532 6737 break;
533 }
534
535
1/2
✓ Branch 28 → 29 taken 6320 times.
✗ Branch 28 → 218 not taken.
6320 operandType = operandType.removeReferenceWrapper();
536
537 // Check if the index is of the right type
538
3/4
✓ Branch 29 → 30 taken 6320 times.
✗ Branch 29 → 219 not taken.
✓ Branch 30 → 31 taken 1 time.
✓ Branch 30 → 41 taken 6319 times.
6320 if (!index.type.isOneOf({TY_INT, TY_LONG}))
539
4/8
✓ Branch 33 → 34 taken 1 time.
✗ Branch 33 → 222 not taken.
✓ Branch 34 → 35 taken 1 time.
✗ Branch 34 → 220 not taken.
✓ Branch 37 → 38 taken 1 time.
✗ Branch 37 → 226 not taken.
✓ Branch 38 → 39 taken 1 time.
✗ Branch 38 → 226 not taken.
4 SOFT_ERROR_ER(node, ARRAY_INDEX_NOT_INT_OR_LONG, "Array index must be of type int or long")
540
541 // Check if we can apply the subscript operator on the lhs type
542
2/4
✓ Branch 41 → 42 taken 6319 times.
✗ Branch 41 → 227 not taken.
✗ Branch 42 → 43 not taken.
✓ Branch 42 → 52 taken 6319 times.
6319 if (!operandType.isOneOf({TY_ARRAY, TY_PTR, TY_STRING}))
543 SOFT_ERROR_ER(node, OPERATOR_WRONG_DATA_TYPE,
544 "Can only apply subscript operator on array type, got " + operandType.getName(true))
545
546 // Check if we have an unsafe operation
547
6/10
✓ Branch 52 → 53 taken 6319 times.
✗ Branch 52 → 258 not taken.
✓ Branch 53 → 54 taken 4739 times.
✓ Branch 53 → 57 taken 1580 times.
✓ Branch 54 → 55 taken 4739 times.
✗ Branch 54 → 258 not taken.
✗ Branch 55 → 56 not taken.
✓ Branch 55 → 57 taken 4739 times.
✗ Branch 58 → 59 not taken.
✓ Branch 58 → 69 taken 6319 times.
6319 if (operandType.isPtr() && !currentScope->doesAllowUnsafeOperations())
548 SOFT_ERROR_ER(
549 node, UNSAFE_OPERATION_IN_SAFE_CONTEXT,
550 "The subscript operator on pointers is an unsafe operation. Use unsafe blocks if you know what you are doing.")
551
552 // In case of compile time index value and known array size, perform a compile time out-of-bounds check
553
8/10
✓ Branch 69 → 70 taken 6319 times.
✗ Branch 69 → 258 not taken.
✓ Branch 70 → 71 taken 254 times.
✓ Branch 70 → 76 taken 6065 times.
✓ Branch 71 → 72 taken 254 times.
✗ Branch 71 → 258 not taken.
✓ Branch 72 → 73 taken 179 times.
✓ Branch 72 → 76 taken 75 times.
✓ Branch 77 → 78 taken 91 times.
✓ Branch 77 → 96 taken 6228 times.
6498 if (operandType.isArray() && operandType.getArraySize() != ARRAY_SIZE_UNKNOWN &&
554
3/4
✓ Branch 73 → 74 taken 179 times.
✗ Branch 73 → 258 not taken.
✓ Branch 74 → 75 taken 91 times.
✓ Branch 74 → 76 taken 88 times.
179 indexAssignExpr->hasCompileTimeValue(manIdx)) {
555
1/2
✓ Branch 78 → 79 taken 91 times.
✗ Branch 78 → 258 not taken.
91 const int32_t constIndex = indexAssignExpr->getCompileTimeValue(manIdx).intValue;
556
1/2
✓ Branch 79 → 80 taken 91 times.
✗ Branch 79 → 258 not taken.
91 const unsigned int constSize = operandType.getArraySize();
557 // Check if we are accessing out-of-bounds memory
558
2/2
✓ Branch 80 → 81 taken 1 time.
✓ Branch 80 → 96 taken 90 times.
91 if (constIndex >= static_cast<int32_t>(constSize)) {
559 1 const std::string idxStr = std::to_string(constIndex);
560 1 const std::string sizeStr = std::to_string(constSize);
561
6/12
✓ Branch 83 → 84 taken 1 time.
✗ Branch 83 → 248 not taken.
✓ Branch 84 → 85 taken 1 time.
✗ Branch 84 → 246 not taken.
✓ Branch 85 → 86 taken 1 time.
✗ Branch 85 → 244 not taken.
✓ Branch 86 → 87 taken 1 time.
✗ Branch 86 → 242 not taken.
✓ Branch 90 → 91 taken 1 time.
✗ Branch 90 → 251 not taken.
✓ Branch 91 → 92 taken 1 time.
✗ Branch 91 → 251 not taken.
1 SOFT_ERROR_ER(node, ARRAY_INDEX_OUT_OF_BOUNDS,
562 "You are trying to access element with index " + idxStr + " of an array with size " + sizeStr)
563 1 }
564 }
565
566 // Get item type
567
1/2
✓ Branch 96 → 97 taken 6318 times.
✗ Branch 96 → 257 not taken.
6318 operandType = operandType.getContained();
568
569 // Remove heap qualifier
570 6318 operandType.getQualifiers().isHeap = false;
571
572 6318 break;
573 }
574 50416 case PostfixUnaryExprNode::PostfixUnaryOp::OP_MEMBER_ACCESS: {
575 50416 const std::string &fieldName = node->identifier;
576
577 // Check if lhs is enum or strobj
578
1/2
✓ Branch 101 → 102 taken 50416 times.
✗ Branch 101 → 286 not taken.
50416 const QualType lhsBaseTy = operandType.autoDeReference();
579
3/4
✓ Branch 102 → 103 taken 50416 times.
✗ Branch 102 → 286 not taken.
✓ Branch 103 → 104 taken 1 time.
✓ Branch 103 → 113 taken 50415 times.
50416 if (!lhsBaseTy.is(TY_STRUCT))
580
5/10
✓ Branch 104 → 105 taken 1 time.
✗ Branch 104 → 263 not taken.
✓ Branch 105 → 106 taken 1 time.
✗ Branch 105 → 261 not taken.
✓ Branch 106 → 107 taken 1 time.
✗ Branch 106 → 259 not taken.
✓ Branch 109 → 110 taken 1 time.
✗ Branch 109 → 265 not taken.
✓ Branch 110 → 111 taken 1 time.
✗ Branch 110 → 265 not taken.
2 SOFT_ERROR_ER(node, INVALID_MEMBER_ACCESS, "Cannot apply member access operator on " + operandType.getName(false))
581
582 // Retrieve registry entry
583
1/2
✓ Branch 113 → 114 taken 50415 times.
✗ Branch 113 → 286 not taken.
50415 const std::string &structName = lhsBaseTy.getSubType();
584
1/2
✓ Branch 114 → 115 taken 50415 times.
✗ Branch 114 → 286 not taken.
50415 Scope *structScope = lhsBaseTy.getBodyScope();
585
586 // If we only have the generic struct scope, lookup the concrete manifestation scope
587
2/2
✓ Branch 115 → 116 taken 280 times.
✓ Branch 115 → 120 taken 50135 times.
50415 if (structScope->isGenericScope) {
588
1/2
✓ Branch 116 → 117 taken 280 times.
✗ Branch 116 → 286 not taken.
280 const Struct *spiceStruct = lhsBaseTy.getStruct(node);
589
1/2
✗ Branch 117 → 118 not taken.
✓ Branch 117 → 119 taken 280 times.
280 assert(spiceStruct != nullptr);
590 280 structScope = spiceStruct->scope;
591 }
592
1/2
✗ Branch 120 → 121 not taken.
✓ Branch 120 → 122 taken 50415 times.
50415 assert(!structScope->isGenericScope); // At this point we always expect a substantiation scope
593
594 // Get accessed field
595 50415 std::vector<size_t> indexPath;
596
1/2
✓ Branch 122 → 123 taken 50415 times.
✗ Branch 122 → 284 not taken.
50415 SymbolTableEntry *memberEntry = structScope->symbolTable.lookupInComposedFields(fieldName, indexPath);
597
2/2
✓ Branch 123 → 124 taken 2 times.
✓ Branch 123 → 135 taken 50413 times.
50415 if (!memberEntry)
598
6/12
✓ Branch 124 → 125 taken 2 times.
✗ Branch 124 → 272 not taken.
✓ Branch 125 → 126 taken 2 times.
✗ Branch 125 → 270 not taken.
✓ Branch 126 → 127 taken 2 times.
✗ Branch 126 → 268 not taken.
✓ Branch 127 → 128 taken 2 times.
✗ Branch 127 → 266 not taken.
✓ Branch 131 → 132 taken 2 times.
✗ Branch 131 → 275 not taken.
✓ Branch 132 → 133 taken 2 times.
✗ Branch 132 → 275 not taken.
4 SOFT_ERROR_ER(node, REFERENCED_UNDEFINED_VARIABLE, "Field '" + node->identifier + "' not found in struct " + structName)
599
1/2
✓ Branch 135 → 136 taken 50413 times.
✗ Branch 135 → 284 not taken.
50413 const QualType memberType = memberEntry->getQualType();
600
601 // Check for insufficient visibility
602
8/14
✓ Branch 136 → 137 taken 50413 times.
✗ Branch 136 → 276 not taken.
✓ Branch 137 → 138 taken 1788 times.
✓ Branch 137 → 143 taken 48625 times.
✓ Branch 138 → 139 taken 1788 times.
✗ Branch 138 → 276 not taken.
✓ Branch 139 → 140 taken 1788 times.
✗ Branch 139 → 276 not taken.
✓ Branch 140 → 141 taken 1788 times.
✗ Branch 140 → 276 not taken.
✗ Branch 141 → 142 not taken.
✓ Branch 141 → 143 taken 1788 times.
✗ Branch 144 → 145 not taken.
✓ Branch 144 → 154 taken 50413 times.
50413 if (structScope->isImportedBy(rootScope) && !memberEntry->getQualType().getBase().isPublic())
603 SOFT_ERROR_ER(node, INSUFFICIENT_VISIBILITY, "Cannot access field '" + fieldName + "' due to its private visibility")
604
605 // Set field to used
606 50413 memberEntry->used = true;
607
608 // Overwrite type and entry of left side with member type and entry
609 50413 operandType = memberType;
610 50413 operandEntry = memberEntry;
611 50413 break;
612
2/2
✓ Branch 156 → 157 taken 2 times.
✓ Branch 156 → 158 taken 50413 times.
50415 }
613 4550 case PostfixUnaryExprNode::PostfixUnaryOp::OP_PLUS_PLUS: {
614
2/2
✓ Branch 159 → 160 taken 4548 times.
✓ Branch 159 → 287 taken 2 times.
4550 operandType = opRuleManager.getPostfixPlusPlusResultType(node, operand).type;
615
616
2/2
✓ Branch 160 → 161 taken 4544 times.
✓ Branch 160 → 166 taken 4 times.
4548 if (operandEntry) {
617 // In case the lhs is captured, notify the capture about the write access
618
3/4
✓ Branch 161 → 162 taken 4544 times.
✗ Branch 161 → 316 not taken.
✓ Branch 162 → 163 taken 4 times.
✓ Branch 162 → 164 taken 4540 times.
4544 if (Capture *lhsCapture = currentScope->symbolTable.lookupCapture(operandEntry->name); lhsCapture)
619
1/2
✓ Branch 163 → 164 taken 4 times.
✗ Branch 163 → 316 not taken.
4 lhsCapture->setAccessType(READ_WRITE);
620
621 // Update the state of the variable
622
1/2
✓ Branch 164 → 165 taken 4544 times.
✗ Branch 164 → 288 not taken.
4544 operandEntry->updateState(INITIALIZED, node);
623 }
624
625 4548 break;
626 }
627 445 case PostfixUnaryExprNode::PostfixUnaryOp::OP_MINUS_MINUS: {
628
1/2
✓ Branch 167 → 168 taken 445 times.
✗ Branch 167 → 289 not taken.
445 operandType = opRuleManager.getPostfixMinusMinusResultType(node, operand).type;
629
630
2/2
✓ Branch 168 → 169 taken 441 times.
✓ Branch 168 → 174 taken 4 times.
445 if (operandEntry) {
631 // In case the lhs is captured, notify the capture about the write access
632
2/4
✓ Branch 169 → 170 taken 441 times.
✗ Branch 169 → 316 not taken.
✗ Branch 170 → 171 not taken.
✓ Branch 170 → 172 taken 441 times.
441 if (Capture *lhsCapture = currentScope->symbolTable.lookupCapture(operandEntry->name); lhsCapture)
633 lhsCapture->setAccessType(READ_WRITE);
634
635 // Update the state of the variable
636
1/2
✓ Branch 172 → 173 taken 441 times.
✗ Branch 172 → 290 not taken.
441 operandEntry->updateState(INITIALIZED, node);
637 }
638
639 445 break;
640 }
641 default: // GCOV_EXCL_LINE
642 throw CompilerError(UNHANDLED_BRANCH, "PostfixUnaryExpr fall-through"); // GCOV_EXCL_LINE
643 }
644
645
2/4
✓ Branch 183 → 184 taken 62143 times.
✗ Branch 183 → 316 not taken.
✗ Branch 184 → 185 not taken.
✓ Branch 184 → 203 taken 62143 times.
62143 if (operandType.is(TY_INVALID)) {
646 const std::string &varName = operandEntry ? operandEntry->name : "";
647 SOFT_ERROR_ER(node, REFERENCED_UNDEFINED_VARIABLE, "Variable '" + varName + "' was referenced before declared")
648 }
649
650
2/4
✓ Branch 203 → 204 taken 62143 times.
✗ Branch 203 → 315 not taken.
✓ Branch 204 → 205 taken 62143 times.
✗ Branch 204 → 315 not taken.
124286 return ExprResult{node->setEvaluatedSymbolType(operandType, manIdx), operandEntry};
651 }
652
653 265202 std::any TypeChecker::visitAtomicExpr(AtomicExprNode *node) {
654 // Check if constant
655
2/2
✓ Branch 2 → 3 taken 49540 times.
✓ Branch 2 → 5 taken 215662 times.
265202 if (node->constant)
656
1/2
✓ Branch 3 → 4 taken 49540 times.
✗ Branch 3 → 218 not taken.
49540 return visit(node->constant);
657
658 // Check if value
659
2/2
✓ Branch 5 → 6 taken 65991 times.
✓ Branch 5 → 8 taken 149671 times.
215662 if (node->value)
660
2/2
✓ Branch 6 → 7 taken 65987 times.
✓ Branch 6 → 218 taken 4 times.
65991 return visit(node->value);
661
662 // Check for assign expression within parentheses
663
2/2
✓ Branch 8 → 9 taken 1174 times.
✓ Branch 8 → 11 taken 148497 times.
149671 if (node->assignExpr)
664
2/2
✓ Branch 9 → 10 taken 1171 times.
✓ Branch 9 → 218 taken 3 times.
1174 return visit(node->assignExpr);
665
666 // Identifier (local or global variable access)
667
1/2
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 148497 times.
148497 assert(!node->fqIdentifier.empty());
668
669
1/2
✓ Branch 14 → 15 taken 148497 times.
✗ Branch 14 → 218 not taken.
148497 auto &[entry, accessScope, capture] = node->data.at(manIdx);
670 148497 accessScope = currentScope;
671
672 // Check if a local or global variable can be found by searching for the name
673
2/2
✓ Branch 16 → 17 taken 144613 times.
✓ Branch 16 → 22 taken 3884 times.
148497 if (node->identifierFragments.size() == 1)
674 289226 entry = accessScope->lookup(node->identifierFragments.back());
675
676 // If no local or global was found, search in the name registry
677
2/2
✓ Branch 22 → 23 taken 4041 times.
✓ Branch 22 → 35 taken 144456 times.
148497 if (!entry) {
678
1/2
✓ Branch 23 → 24 taken 4041 times.
✗ Branch 23 → 218 not taken.
4041 const NameRegistryEntry *registryEntry = sourceFile->getNameRegistryEntry(node->fqIdentifier);
679
2/2
✓ Branch 24 → 25 taken 1 time.
✓ Branch 24 → 34 taken 4040 times.
4041 if (!registryEntry)
680
5/10
✓ Branch 25 → 26 taken 1 time.
✗ Branch 25 → 166 not taken.
✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 164 not taken.
✓ Branch 27 → 28 taken 1 time.
✗ Branch 27 → 162 not taken.
✓ Branch 30 → 31 taken 1 time.
✗ Branch 30 → 168 not taken.
✓ Branch 31 → 32 taken 1 time.
✗ Branch 31 → 168 not taken.
2 SOFT_ERROR_ER(node, REFERENCED_UNDEFINED_VARIABLE, "The variable '" + node->fqIdentifier + "' could not be found")
681 4040 entry = registryEntry->targetEntry;
682 4040 accessScope = registryEntry->targetScope;
683 }
684
1/2
✗ Branch 35 → 36 not taken.
✓ Branch 35 → 37 taken 148496 times.
148496 assert(entry != nullptr);
685 148496 entry->used = true;
686
1/2
✓ Branch 37 → 38 taken 148496 times.
✗ Branch 37 → 218 not taken.
148496 capture = accessScope->symbolTable.lookupCapture(entry->name);
687
688
1/2
✓ Branch 38 → 39 taken 148496 times.
✗ Branch 38 → 218 not taken.
148496 const QualType varType = entry->getQualType();
689
5/8
✓ Branch 39 → 40 taken 148496 times.
✗ Branch 39 → 218 not taken.
✓ Branch 40 → 41 taken 9 times.
✓ Branch 40 → 45 taken 148487 times.
✓ Branch 41 → 42 taken 9 times.
✗ Branch 41 → 169 not taken.
✓ Branch 42 → 43 taken 9 times.
✗ Branch 42 → 169 not taken.
148505 HANDLE_UNRESOLVED_TYPE_ER(varType)
690
3/4
✓ Branch 45 → 46 taken 148487 times.
✗ Branch 45 → 218 not taken.
✓ Branch 46 → 47 taken 2 times.
✓ Branch 46 → 56 taken 148485 times.
148487 if (varType.is(TY_INVALID))
691
5/10
✓ Branch 47 → 48 taken 2 times.
✗ Branch 47 → 174 not taken.
✓ Branch 48 → 49 taken 2 times.
✗ Branch 48 → 172 not taken.
✓ Branch 49 → 50 taken 2 times.
✗ Branch 49 → 170 not taken.
✓ Branch 52 → 53 taken 2 times.
✗ Branch 52 → 176 not taken.
✓ Branch 53 → 54 taken 2 times.
✗ Branch 53 → 176 not taken.
4 SOFT_ERROR_ER(node, USED_BEFORE_DECLARED, "Symbol '" + entry->name + "' was used before declared.")
692
693
7/8
✓ Branch 56 → 57 taken 148485 times.
✗ Branch 56 → 177 not taken.
✓ Branch 57 → 58 taken 121 times.
✓ Branch 57 → 60 taken 148364 times.
✓ Branch 58 → 59 taken 21 times.
✓ Branch 58 → 60 taken 100 times.
✓ Branch 61 → 62 taken 21 times.
✓ Branch 61 → 90 taken 148464 times.
148485 if (varType.isOneOf({TY_FUNCTION, TY_PROCEDURE}) && entry->global) {
694 // Check if overloaded function was referenced
695
1/2
✓ Branch 62 → 63 taken 21 times.
✗ Branch 62 → 218 not taken.
21 const std::vector<Function *> *manifestations = entry->declNode->getFctManifestations(entry->name);
696
2/2
✓ Branch 64 → 65 taken 1 time.
✓ Branch 64 → 75 taken 20 times.
21 if (manifestations->size() > 1)
697
4/8
✓ Branch 67 → 68 taken 1 time.
✗ Branch 67 → 180 not taken.
✓ Branch 68 → 69 taken 1 time.
✗ Branch 68 → 178 not taken.
✓ Branch 71 → 72 taken 1 time.
✗ Branch 71 → 184 not taken.
✓ Branch 72 → 73 taken 1 time.
✗ Branch 72 → 184 not taken.
4 SOFT_ERROR_ER(node, REFERENCED_OVERLOADED_FCT, "Overloaded functions / functions with optional params cannot be referenced")
698
2/2
✓ Branch 77 → 78 taken 1 time.
✓ Branch 77 → 88 taken 19 times.
20 if (!manifestations->front()->templateTypes.empty())
699
4/8
✓ Branch 80 → 81 taken 1 time.
✗ Branch 80 → 187 not taken.
✓ Branch 81 → 82 taken 1 time.
✗ Branch 81 → 185 not taken.
✓ Branch 84 → 85 taken 1 time.
✗ Branch 84 → 191 not taken.
✓ Branch 85 → 86 taken 1 time.
✗ Branch 85 → 191 not taken.
4 SOFT_ERROR_ER(node, REFERENCED_OVERLOADED_FCT, "Generic functions cannot be referenced")
700 // Set referenced function to used
701 19 Function *referencedFunction = manifestations->front();
702 19 referencedFunction->used = true;
703 19 referencedFunction->entry->used = true;
704 }
705
706 // The base type should be an extended primitive
707
1/2
✓ Branch 90 → 91 taken 148483 times.
✗ Branch 90 → 218 not taken.
148483 const QualType baseType = varType.getBase();
708
6/10
✓ Branch 91 → 92 taken 148483 times.
✗ Branch 91 → 218 not taken.
✓ Branch 92 → 93 taken 4 times.
✓ Branch 92 → 96 taken 148479 times.
✓ Branch 93 → 94 taken 4 times.
✗ Branch 93 → 218 not taken.
✗ Branch 94 → 95 not taken.
✓ Branch 94 → 96 taken 4 times.
✗ Branch 97 → 98 not taken.
✓ Branch 97 → 109 taken 148483 times.
148483 if (!baseType.isExtendedPrimitive() && !baseType.is(TY_DYN))
709 SOFT_ERROR_ER(node, INVALID_SYMBOL_ACCESS, "A symbol of type " + varType.getName(false) + " cannot be accessed here")
710
711 // Check if we have seen a 'this.' prefix, because the generator needs that
712
6/8
✓ Branch 109 → 110 taken 1 time.
✓ Branch 109 → 114 taken 148482 times.
✓ Branch 111 → 112 taken 1 time.
✗ Branch 111 → 218 not taken.
✓ Branch 112 → 113 taken 1 time.
✗ Branch 112 → 114 not taken.
✓ Branch 115 → 116 taken 1 time.
✓ Branch 115 → 125 taken 148482 times.
148483 if (entry->scope->type == ScopeType::STRUCT && node->identifierFragments.front() != THIS_VARIABLE_NAME)
713
5/10
✓ Branch 116 → 117 taken 1 time.
✗ Branch 116 → 206 not taken.
✓ Branch 117 → 118 taken 1 time.
✗ Branch 117 → 204 not taken.
✓ Branch 118 → 119 taken 1 time.
✗ Branch 118 → 202 not taken.
✓ Branch 121 → 122 taken 1 time.
✗ Branch 121 → 208 not taken.
✓ Branch 122 → 123 taken 1 time.
✗ Branch 122 → 208 not taken.
2 SOFT_ERROR_ER(node, REFERENCED_UNDEFINED_VARIABLE,
714 "The symbol '" + node->fqIdentifier + "' could not be found. Missing 'this.' prefix?")
715
716 // Ensure that the entry is public, if the symbol is imported.
717 // An exception are enum items. There it is sufficient, that the enum itself is public.
718
7/8
✓ Branch 125 → 126 taken 148482 times.
✗ Branch 125 → 218 not taken.
✓ Branch 126 → 127 taken 3374 times.
✓ Branch 126 → 129 taken 145108 times.
✓ Branch 127 → 128 taken 257 times.
✓ Branch 127 → 129 taken 3117 times.
✓ Branch 130 → 131 taken 257 times.
✓ Branch 130 → 144 taken 148225 times.
148482 if (accessScope->isImportedBy(rootScope) && accessScope->type != ScopeType::ENUM)
719
5/8
✓ Branch 131 → 132 taken 257 times.
✗ Branch 131 → 209 not taken.
✓ Branch 132 → 133 taken 257 times.
✗ Branch 132 → 209 not taken.
✓ Branch 133 → 134 taken 257 times.
✗ Branch 133 → 209 not taken.
✓ Branch 134 → 135 taken 1 time.
✓ Branch 134 → 144 taken 256 times.
257 if (!entry->getQualType().getBase().isPublic())
720
5/10
✓ Branch 135 → 136 taken 1 time.
✗ Branch 135 → 214 not taken.
✓ Branch 136 → 137 taken 1 time.
✗ Branch 136 → 212 not taken.
✓ Branch 137 → 138 taken 1 time.
✗ Branch 137 → 210 not taken.
✓ Branch 140 → 141 taken 1 time.
✗ Branch 140 → 216 not taken.
✓ Branch 141 → 142 taken 1 time.
✗ Branch 141 → 216 not taken.
2 SOFT_ERROR_ER(node, INSUFFICIENT_VISIBILITY, "Cannot access '" + entry->name + "' due to its private visibility")
721
722 // For enum item access, use access scope of the enum
723
2/2
✓ Branch 144 → 145 taken 3879 times.
✓ Branch 144 → 146 taken 144602 times.
148481 if (entry->scope->type == ScopeType::ENUM)
724 3879 accessScope = entry->scope;
725
726 // For struct access, use access scope of the struct
727
3/4
✓ Branch 146 → 147 taken 148481 times.
✗ Branch 146 → 218 not taken.
✓ Branch 147 → 148 taken 62989 times.
✓ Branch 147 → 156 taken 85492 times.
148481 if (baseType.is(TY_STRUCT)) {
728
1/2
✓ Branch 148 → 149 taken 62989 times.
✗ Branch 148 → 218 not taken.
62989 const std::string &structName = baseType.getSubType();
729
1/2
✓ Branch 149 → 150 taken 62989 times.
✗ Branch 149 → 218 not taken.
62989 const NameRegistryEntry *nameRegistryEntry = sourceFile->getNameRegistryEntry(structName);
730 // The struct may only be reachable transitively (i.e. it is not present in this file's name registry under
731 // its unqualified name). In that case, fall back to the struct's body scope, which is exactly what the
732 // registry entry's targetScope would point to (see SymbolTableBuilder struct registration). This keeps
733 // member access working across deep transitive imports instead of crashing.
734
3/4
✓ Branch 150 → 151 taken 62967 times.
✓ Branch 150 → 152 taken 22 times.
✓ Branch 152 → 153 taken 22 times.
✗ Branch 152 → 218 not taken.
62989 accessScope = nameRegistryEntry != nullptr ? nameRegistryEntry->targetScope : baseType.getBodyScope();
735
1/2
✗ Branch 154 → 155 not taken.
✓ Branch 154 → 156 taken 62989 times.
62989 assert(accessScope != nullptr);
736 }
737
738
2/4
✓ Branch 156 → 157 taken 148481 times.
✗ Branch 156 → 217 not taken.
✓ Branch 157 → 158 taken 148481 times.
✗ Branch 157 → 217 not taken.
296962 return ExprResult{node->setEvaluatedSymbolType(varType, manIdx), entry};
739 }
740
741 } // namespace spice::compiler
742