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% 687 / 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 20376 std::any TypeChecker::visitAssignExpr(AssignExprNode *node) {
14 // Check if ternary
15
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 10 taken 20376 times.
20376 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 20376 times.
✗ Branch 10 → 142 not taken.
20376 if (node->op != AssignExprNode::AssignOp::OP_NONE) {
23 // Visit the right side first
24
2/4
✓ Branch 11 → 12 taken 20376 times.
✗ Branch 11 → 157 not taken.
✓ Branch 12 → 13 taken 20376 times.
✗ Branch 12 → 155 not taken.
20376 auto rhs = std::any_cast<ExprResult>(visit(node->rhs));
25 20376 auto [rhsType, rhsEntry] = rhs;
26
5/8
✓ Branch 14 → 15 taken 20376 times.
✗ Branch 14 → 201 not taken.
✓ Branch 15 → 16 taken 1 time.
✓ Branch 15 → 20 taken 20375 times.
✓ Branch 16 → 17 taken 1 time.
✗ Branch 16 → 158 not taken.
✓ Branch 17 → 18 taken 1 time.
✗ Branch 17 → 158 not taken.
20377 HANDLE_UNRESOLVED_TYPE_ER(rhsType)
27 // Then visit the left side
28
2/4
✓ Branch 20 → 21 taken 20375 times.
✗ Branch 20 → 161 not taken.
✓ Branch 21 → 22 taken 20375 times.
✗ Branch 21 → 159 not taken.
20375 auto lhs = std::any_cast<ExprResult>(visit(node->lhs));
29 20375 auto [lhsType, lhsVar] = lhs;
30
5/8
✓ Branch 23 → 24 taken 20375 times.
✗ Branch 23 → 201 not taken.
✓ Branch 24 → 25 taken 1 time.
✓ Branch 24 → 29 taken 20374 times.
✓ Branch 25 → 26 taken 1 time.
✗ Branch 25 → 162 not taken.
✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 162 not taken.
20376 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 18070 times.
✓ Branch 30 → 40 taken 1 time.
✓ Branch 31 → 32 taken 18070 times.
✗ Branch 31 → 163 not taken.
✓ Branch 32 → 33 taken 14672 times.
✓ Branch 32 → 40 taken 3398 times.
18071 if (node->op == AssignExprNode::AssignOp::OP_ASSIGN && lhs.entry != nullptr && lhs.entry->isField() &&
38
13/16
✓ Branch 29 → 30 taken 18071 times.
✓ Branch 29 → 40 taken 2303 times.
✓ Branch 33 → 34 taken 14672 times.
✗ Branch 33 → 163 not taken.
✓ Branch 34 → 35 taken 14672 times.
✗ Branch 34 → 163 not taken.
✓ Branch 35 → 36 taken 143 times.
✓ Branch 35 → 40 taken 14529 times.
✓ Branch 36 → 37 taken 143 times.
✗ Branch 36 → 163 not taken.
✓ Branch 37 → 38 taken 7 times.
✓ Branch 37 → 40 taken 136 times.
✓ Branch 38 → 39 taken 1 time.
✓ Branch 38 → 40 taken 6 times.
✓ Branch 41 → 42 taken 1 time.
✓ Branch 41 → 55 taken 20373 times.
38445 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 18070 times.
✓ Branch 55 → 98 taken 2303 times.
20373 if (node->op == AssignExprNode::AssignOp::OP_ASSIGN) {
46
8/10
✓ Branch 56 → 57 taken 18069 times.
✓ Branch 56 → 63 taken 1 time.
✓ Branch 57 → 58 taken 18069 times.
✗ Branch 57 → 188 not taken.
✓ Branch 58 → 59 taken 14671 times.
✓ Branch 58 → 63 taken 3398 times.
✓ Branch 60 → 61 taken 14671 times.
✗ Branch 60 → 188 not taken.
✓ Branch 61 → 62 taken 5442 times.
✓ Branch 61 → 63 taken 9229 times.
18070 const bool isDecl = lhs.entry != nullptr && lhs.entry->isField() && !lhs.entry->getLifecycle().isInitialized();
47
2/2
✓ Branch 64 → 65 taken 18069 times.
✓ Branch 64 → 188 taken 1 time.
18070 const auto [assignType, copyCtor] = opRuleManager.getAssignResultType(node, lhs, rhs, isDecl);
48 18069 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 142 times.
✓ Branch 67 → 75 taken 17927 times.
✓ Branch 68 → 69 taken 34 times.
✓ Branch 68 → 75 taken 108 times.
✓ Branch 69 → 70 taken 34 times.
✗ Branch 69 → 75 not taken.
✓ Branch 70 → 71 taken 34 times.
✗ Branch 70 → 188 not taken.
✓ Branch 71 → 72 taken 19 times.
✓ Branch 71 → 75 taken 15 times.
✓ Branch 76 → 77 taken 11 times.
✓ Branch 76 → 97 taken 18058 times.
18088 if (copyCtor != nullptr && !isDecl && lhs.entry != nullptr && lhs.entry->isInitialized() &&
56
3/4
✓ Branch 72 → 73 taken 19 times.
✗ Branch 72 → 188 not taken.
✓ Branch 73 → 74 taken 11 times.
✓ Branch 73 → 75 taken 8 times.
19 !currentScope->doesAllowUnsafeOperations()) {
57
2/4
✓ Branch 77 → 78 taken 11 times.
✗ Branch 77 → 177 not taken.
✓ Branch 78 → 79 taken 11 times.
✗ Branch 78 → 177 not taken.
11 const QualType lhsSType = lhs.type.removeReferenceWrapper().toNonConst();
58
5/10
✓ Branch 79 → 80 taken 11 times.
✗ Branch 79 → 187 not taken.
✓ Branch 80 → 81 taken 11 times.
✗ Branch 80 → 84 not taken.
✓ Branch 81 → 82 taken 11 times.
✗ Branch 81 → 187 not taken.
✓ Branch 82 → 83 taken 11 times.
✗ Branch 82 → 84 not taken.
✓ Branch 85 → 86 taken 11 times.
✗ Branch 85 → 96 not taken.
11 if (lhsSType.is(TY_STRUCT) && !lhsSType.isTriviallyDestructible(node))
59
2/4
✓ Branch 89 → 90 taken 11 times.
✗ Branch 89 → 180 not taken.
✓ Branch 90 → 91 taken 11 times.
✗ Branch 90 → 178 not taken.
33 node->lhsDtorFct[manIdx] = implicitlyCallStructMethod(lhsSType, DTOR_FUNCTION_NAME, {}, node);
60 }
61
2/2
✓ Branch 98 → 99 taken 1165 times.
✓ Branch 98 → 101 taken 1138 times.
2303 } else if (node->op == AssignExprNode::AssignOp::OP_PLUS_EQUAL) {
62
1/2
✓ Branch 99 → 100 taken 1165 times.
✗ Branch 99 → 189 not taken.
1165 rhsType = opRuleManager.getPlusEqualResultType(node, lhs, rhs).type;
63
2/2
✓ Branch 101 → 102 taken 81 times.
✓ Branch 101 → 104 taken 1057 times.
1138 } else if (node->op == AssignExprNode::AssignOp::OP_MINUS_EQUAL) {
64
1/2
✓ Branch 102 → 103 taken 81 times.
✗ Branch 102 → 190 not taken.
81 rhsType = opRuleManager.getMinusEqualResultType(node, lhs, rhs).type;
65
2/2
✓ Branch 104 → 105 taken 170 times.
✓ Branch 104 → 107 taken 887 times.
1057 } 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 783 times.
887 } 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 742 times.
783 } 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 730 times.
742 } 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 717 times.
730 } 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 700 times.
717 } 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 687 times.
700 } 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 687 times.
✗ Branch 125 → 128 not taken.
687 } else if (node->op == AssignExprNode::AssignOp::OP_XOR_EQUAL) {
80
1/2
✓ Branch 126 → 127 taken 687 times.
✗ Branch 126 → 198 not taken.
687 rhsType = opRuleManager.getXorEqualResultType(node, lhs, rhs);
81 }
82
83
1/2
✓ Branch 128 → 129 taken 20372 times.
✗ Branch 128 → 137 not taken.
20372 if (lhsVar) { // Variable is involved on the left side
84 // Perform type inference
85
3/4
✓ Branch 129 → 130 taken 20372 times.
✗ Branch 129 → 201 not taken.
✓ Branch 130 → 131 taken 1 time.
✓ Branch 130 → 132 taken 20371 times.
20372 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 20372 times.
✗ Branch 132 → 201 not taken.
✓ Branch 133 → 134 taken 3 times.
✓ Branch 133 → 135 taken 20369 times.
20372 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 20372 times.
✗ Branch 135 → 199 not taken.
20372 lhsVar->updateState(INITIALIZED, node);
94 }
95
96
2/4
✓ Branch 137 → 138 taken 20372 times.
✗ Branch 137 → 200 not taken.
✓ Branch 138 → 139 taken 20372 times.
✗ Branch 138 → 200 not taken.
40744 return ExprResult{node->setEvaluatedSymbolType(rhsType, manIdx)};
97 }
98
99 throw CompilerError(UNHANDLED_BRANCH, "AssignExpr fall-through"); // GCOV_EXCL_LINE
100 }
101
102 2035 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 2035 times.
2035 if (!node->falseExpr)
105 return visit(node->condition);
106
107 // Visit condition
108
2/4
✓ Branch 5 → 6 taken 2035 times.
✗ Branch 5 → 126 not taken.
✓ Branch 6 → 7 taken 2035 times.
✗ Branch 6 → 124 not taken.
2035 const auto condition = std::any_cast<ExprResult>(visit(node->condition));
109
2/8
✓ Branch 8 → 9 taken 2035 times.
✗ Branch 8 → 161 not taken.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 14 taken 2035 times.
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 127 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 127 not taken.
2035 HANDLE_UNRESOLVED_TYPE_ER(condition.type)
110
6/10
✓ Branch 14 → 15 taken 1 time.
✓ Branch 14 → 16 taken 2034 times.
✓ Branch 16 → 17 taken 2034 times.
✗ Branch 16 → 128 not taken.
✓ Branch 17 → 18 taken 2034 times.
✗ Branch 17 → 128 not taken.
✓ Branch 18 → 19 taken 2034 times.
✓ Branch 18 → 20 taken 1 time.
✗ Branch 128 → 129 not taken.
✗ Branch 128 → 130 not taken.
2035 const auto trueExpr = node->isShortened ? condition : std::any_cast<ExprResult>(visit(node->trueExpr));
111 2035 const auto [trueType, trueEntry] = trueExpr;
112
2/8
✓ Branch 20 → 21 taken 2035 times.
✗ Branch 20 → 161 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 21 → 26 taken 2035 times.
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 132 not taken.
✗ Branch 23 → 24 not taken.
✗ Branch 23 → 132 not taken.
2035 HANDLE_UNRESOLVED_TYPE_ER(trueType)
113
2/4
✓ Branch 26 → 27 taken 2035 times.
✗ Branch 26 → 135 not taken.
✓ Branch 27 → 28 taken 2035 times.
✗ Branch 27 → 133 not taken.
2035 const auto falseExpr = std::any_cast<ExprResult>(visit(node->falseExpr));
114 2035 const auto [falseType, falseEntry] = falseExpr;
115
2/8
✓ Branch 29 → 30 taken 2035 times.
✗ Branch 29 → 161 not taken.
✗ Branch 30 → 31 not taken.
✓ Branch 30 → 35 taken 2035 times.
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 136 not taken.
✗ Branch 32 → 33 not taken.
✗ Branch 32 → 136 not taken.
2035 HANDLE_UNRESOLVED_TYPE_ER(falseType)
116
117 // Check if the condition evaluates to bool
118
3/4
✓ Branch 35 → 36 taken 2035 times.
✗ Branch 35 → 161 not taken.
✓ Branch 36 → 37 taken 1 time.
✓ Branch 36 → 47 taken 2034 times.
2035 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 2034 times.
✗ Branch 47 → 161 not taken.
2034 const QualType trueTypeModified = trueType.removeReferenceWrapper();
123
1/2
✓ Branch 48 → 49 taken 2034 times.
✗ Branch 48 → 161 not taken.
2034 const QualType falseTypeModified = falseType.removeReferenceWrapper();
124
3/4
✓ Branch 49 → 50 taken 2034 times.
✗ Branch 49 → 161 not taken.
✓ Branch 50 → 51 taken 1 time.
✓ Branch 50 → 66 taken 2033 times.
2034 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 2033 times.
✗ Branch 66 → 161 not taken.
✓ Branch 67 → 68 taken 9 times.
✓ Branch 67 → 69 taken 2024 times.
2033 QualType resultType = trueType.isRef() ? trueType : falseType;
132 // Infer the const-ness from the more restrictive operand
133
7/10
✓ Branch 70 → 71 taken 2033 times.
✗ Branch 70 → 161 not taken.
✓ Branch 71 → 72 taken 1178 times.
✓ Branch 71 → 74 taken 855 times.
✓ Branch 72 → 73 taken 1178 times.
✗ Branch 72 → 161 not taken.
✓ Branch 73 → 74 taken 355 times.
✓ Branch 73 → 75 taken 823 times.
✓ Branch 76 → 77 taken 2033 times.
✗ Branch 76 → 161 not taken.
2033 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 2033 bool removedAnonymousSymbols = false;
138
2/2
✓ Branch 77 → 78 taken 1180 times.
✓ Branch 77 → 89 taken 853 times.
2033 if (trueEntry) {
139
2/2
✓ Branch 78 → 79 taken 221 times.
✓ Branch 78 → 81 taken 959 times.
1180 if (trueEntry->anonymous) {
140
1/2
✓ Branch 79 → 80 taken 221 times.
✗ Branch 79 → 161 not taken.
221 currentScope->symbolTable.deleteAnonymous(trueEntry->name);
141 221 removedAnonymousSymbols = true;
142
8/10
✓ Branch 81 → 82 taken 959 times.
✗ Branch 81 → 161 not taken.
✓ Branch 82 → 83 taken 951 times.
✓ Branch 82 → 86 taken 8 times.
✓ Branch 83 → 84 taken 951 times.
✗ Branch 83 → 161 not taken.
✓ Branch 84 → 85 taken 9 times.
✓ Branch 84 → 86 taken 942 times.
✓ Branch 87 → 88 taken 9 times.
✓ Branch 87 → 89 taken 950 times.
959 } else if (!trueType.isRef() && !trueType.isTriviallyCopyable(node)) {
143 9 node->trueSideCallsCopyCtor = true;
144 }
145 }
146
2/2
✓ Branch 89 → 90 taken 725 times.
✓ Branch 89 → 101 taken 1308 times.
2033 if (falseEntry) {
147
2/2
✓ Branch 90 → 91 taken 211 times.
✓ Branch 90 → 93 taken 514 times.
725 if (falseEntry->anonymous) {
148
1/2
✓ Branch 91 → 92 taken 211 times.
✗ Branch 91 → 161 not taken.
211 currentScope->symbolTable.deleteAnonymous(falseEntry->name);
149 211 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 2033 SymbolTableEntry *anonymousSymbol = nullptr;
157
4/4
✓ Branch 101 → 102 taken 2024 times.
✓ Branch 101 → 103 taken 9 times.
✓ Branch 102 → 103 taken 14 times.
✓ Branch 102 → 104 taken 2010 times.
2033 const bool calledCopyCtor = node->trueSideCallsCopyCtor || node->falseSideCallsCopyCtor;
158
9/10
✓ Branch 105 → 106 taken 1810 times.
✓ Branch 105 → 109 taken 223 times.
✓ Branch 106 → 107 taken 1795 times.
✓ Branch 106 → 109 taken 15 times.
✓ Branch 107 → 108 taken 1795 times.
✗ Branch 107 → 161 not taken.
✓ Branch 108 → 109 taken 10 times.
✓ Branch 108 → 110 taken 1785 times.
✓ Branch 111 → 112 taken 248 times.
✓ Branch 111 → 114 taken 1785 times.
2033 if (removedAnonymousSymbols || calledCopyCtor || resultType.isRef())
159
1/2
✓ Branch 112 → 113 taken 248 times.
✗ Branch 112 → 161 not taken.
248 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 2024 times.
✓ Branch 114 → 116 taken 9 times.
✓ Branch 115 → 116 taken 14 times.
✓ Branch 115 → 118 taken 2010 times.
2033 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 2033 times.
✗ Branch 118 → 160 not taken.
✓ Branch 119 → 120 taken 2033 times.
✗ Branch 119 → 160 not taken.
4066 return ExprResult{node->setEvaluatedSymbolType(resultType, manIdx), anonymousSymbol};
166 }
167
168 1844 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 1844 times.
1844 if (node->operands.size() == 1)
171 return visit(node->operands.front());
172
173 // Visit leftmost operand
174
2/4
✓ Branch 8 → 9 taken 1844 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 1844 times.
✗ Branch 9 → 37 not taken.
1844 auto currentOperand = std::any_cast<ExprResult>(visit(node->operands[0]));
175
2/8
✓ Branch 11 → 12 taken 1844 times.
✗ Branch 11 → 46 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 1844 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 40 not taken.
1844 HANDLE_UNRESOLVED_TYPE_ER(currentOperand.type)
176
177 // Loop through all remaining operands
178
2/2
✓ Branch 31 → 18 taken 2447 times.
✓ Branch 31 → 32 taken 1843 times.
4290 for (size_t i = 1; i < node->operands.size(); i++) {
179
2/4
✓ Branch 19 → 20 taken 2447 times.
✗ Branch 19 → 43 not taken.
✓ Branch 20 → 21 taken 2447 times.
✗ Branch 20 → 41 not taken.
2447 auto rhsOperand = std::any_cast<ExprResult>(visit(node->operands[i]));
180
2/8
✓ Branch 22 → 23 taken 2447 times.
✗ Branch 22 → 45 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 2447 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 44 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 44 not taken.
2447 HANDLE_UNRESOLVED_TYPE_ER(rhsOperand.type)
181
2/2
✓ Branch 28 → 29 taken 2446 times.
✓ Branch 28 → 45 taken 1 time.
2447 currentOperand = {OpRuleManager::getLogicalOrResultType(node, currentOperand, rhsOperand)};
182 }
183
184
1/2
✓ Branch 32 → 33 taken 1843 times.
✗ Branch 32 → 46 not taken.
1843 node->setEvaluatedSymbolType(currentOperand.type, manIdx);
185
1/2
✓ Branch 33 → 34 taken 1843 times.
✗ Branch 33 → 46 not taken.
1843 return currentOperand;
186 }
187
188 1110 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 1110 times.
1110 if (node->operands.size() == 1)
191 return visit(node->operands.front());
192
193 // Visit leftmost operand
194
2/4
✓ Branch 8 → 9 taken 1110 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 1110 times.
✗ Branch 9 → 37 not taken.
1110 auto currentOperand = std::any_cast<ExprResult>(visit(node->operands[0]));
195
2/8
✓ Branch 11 → 12 taken 1110 times.
✗ Branch 11 → 46 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 1110 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 40 not taken.
1110 HANDLE_UNRESOLVED_TYPE_ER(currentOperand.type)
196
197 // Loop through all remaining operands
198
2/2
✓ Branch 31 → 18 taken 1531 times.
✓ Branch 31 → 32 taken 1110 times.
2641 for (size_t i = 1; i < node->operands.size(); i++) {
199
2/4
✓ Branch 19 → 20 taken 1531 times.
✗ Branch 19 → 43 not taken.
✓ Branch 20 → 21 taken 1531 times.
✗ Branch 20 → 41 not taken.
1531 auto rhsOperand = std::any_cast<ExprResult>(visit(node->operands[i]));
200
2/8
✓ Branch 22 → 23 taken 1531 times.
✗ Branch 22 → 45 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 1531 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 44 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 44 not taken.
1531 HANDLE_UNRESOLVED_TYPE_ER(rhsOperand.type)
201
1/2
✓ Branch 28 → 29 taken 1531 times.
✗ Branch 28 → 45 not taken.
1531 currentOperand = {OpRuleManager::getLogicalAndResultType(node, currentOperand, rhsOperand)};
202 }
203
204
1/2
✓ Branch 32 → 33 taken 1110 times.
✗ Branch 32 → 46 not taken.
1110 node->setEvaluatedSymbolType(currentOperand.type, manIdx);
205
1/2
✓ Branch 33 → 34 taken 1110 times.
✗ Branch 33 → 46 not taken.
1110 return currentOperand;
206 }
207
208 279 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 279 times.
279 if (node->operands.size() == 1)
211 return visit(node->operands.front());
212
213 // Visit leftmost operand
214
2/4
✓ Branch 8 → 9 taken 279 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 279 times.
✗ Branch 9 → 37 not taken.
279 auto currentOperand = std::any_cast<ExprResult>(visit(node->operands[0]));
215
2/8
✓ Branch 11 → 12 taken 279 times.
✗ Branch 11 → 46 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 279 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 40 not taken.
279 HANDLE_UNRESOLVED_TYPE_ER(currentOperand.type)
216
217 // Loop through all remaining operands
218
2/2
✓ Branch 31 → 18 taken 282 times.
✓ Branch 31 → 32 taken 278 times.
560 for (size_t i = 1; i < node->operands.size(); i++) {
219
2/4
✓ Branch 19 → 20 taken 282 times.
✗ Branch 19 → 43 not taken.
✓ Branch 20 → 21 taken 282 times.
✗ Branch 20 → 41 not taken.
282 auto rhsOperand = std::any_cast<ExprResult>(visit(node->operands[i]));
220
2/8
✓ Branch 22 → 23 taken 282 times.
✗ Branch 22 → 45 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 282 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 44 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 44 not taken.
282 HANDLE_UNRESOLVED_TYPE_ER(rhsOperand.type)
221
2/2
✓ Branch 28 → 29 taken 281 times.
✓ Branch 28 → 45 taken 1 time.
282 currentOperand = opRuleManager.getBitwiseOrResultType(node, currentOperand, rhsOperand, i - 1);
222 }
223
224
1/2
✓ Branch 32 → 33 taken 278 times.
✗ Branch 32 → 46 not taken.
278 node->setEvaluatedSymbolType(currentOperand.type, manIdx);
225
1/2
✓ Branch 33 → 34 taken 278 times.
✗ Branch 33 → 46 not taken.
278 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 17178 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 17178 times.
17178 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 17178 times.
✗ Branch 8 → 58 not taken.
✓ Branch 9 → 10 taken 17178 times.
✗ Branch 9 → 56 not taken.
17178 const auto rhs = std::any_cast<ExprResult>(visit(node->operands[1]));
275
2/8
✓ Branch 11 → 12 taken 17178 times.
✗ Branch 11 → 73 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 17178 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 59 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 59 not taken.
17178 HANDLE_UNRESOLVED_TYPE_ER(rhs.type)
276
2/4
✓ Branch 18 → 19 taken 17178 times.
✗ Branch 18 → 62 not taken.
✓ Branch 19 → 20 taken 17178 times.
✗ Branch 19 → 60 not taken.
17178 const auto lhs = std::any_cast<ExprResult>(visit(node->operands[0]));
277
2/8
✓ Branch 21 → 22 taken 17178 times.
✗ Branch 21 → 73 not taken.
✗ Branch 22 → 23 not taken.
✓ Branch 22 → 27 taken 17178 times.
✗ Branch 23 → 24 not taken.
✗ Branch 23 → 63 not taken.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 63 not taken.
17178 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 17178 times.
✗ Branch 27 → 73 not taken.
✓ Branch 28 → 29 taken 345 times.
✓ Branch 28 → 36 taken 16833 times.
✓ Branch 29 → 30 taken 345 times.
✗ Branch 29 → 73 not taken.
✓ Branch 30 → 31 taken 344 times.
✓ Branch 30 → 36 taken 1 time.
✓ Branch 31 → 32 taken 344 times.
✗ Branch 31 → 73 not taken.
✓ Branch 34 → 35 taken 344 times.
✗ Branch 34 → 36 not taken.
✓ Branch 37 → 38 taken 344 times.
✓ Branch 37 → 39 taken 16834 times.
17522 if (lhs.type.is(TY_STRING) && rhs.type.is(TY_STRING) && !sourceFile->isStringRT())
281
1/2
✓ Branch 38 → 39 taken 344 times.
✗ Branch 38 → 73 not taken.
344 sourceFile->requestRuntimeModule(STRING_RT);
282
283 // Check operator
284 17178 ExprResult result;
285
2/2
✓ Branch 39 → 40 taken 13535 times.
✓ Branch 39 → 41 taken 3643 times.
17178 if (node->op == EqualityExprNode::EqualityOp::OP_EQUAL) // Operator was equal
286
2/2
✓ Branch 40 → 51 taken 13534 times.
✓ Branch 40 → 73 taken 1 time.
13535 result = opRuleManager.getEqualResultType(node, lhs, rhs);
287
1/2
✓ Branch 41 → 42 taken 3643 times.
✗ Branch 41 → 43 not taken.
3643 else if (node->op == EqualityExprNode::EqualityOp::OP_NOT_EQUAL) // Operator was not equal
288
1/2
✓ Branch 42 → 51 taken 3643 times.
✗ Branch 42 → 73 not taken.
3643 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 17177 times.
✗ Branch 51 → 73 not taken.
17177 node->setEvaluatedSymbolType(result.type, manIdx);
293
1/2
✓ Branch 52 → 53 taken 17177 times.
✗ Branch 52 → 73 not taken.
17177 return result;
294 }
295
296 9243 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 9243 times.
9243 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 9243 times.
✗ Branch 8 → 55 not taken.
✓ Branch 9 → 10 taken 9243 times.
✗ Branch 9 → 53 not taken.
9243 const auto rhs = std::any_cast<ExprResult>(visit(node->operands[1]));
303
5/8
✓ Branch 11 → 12 taken 9243 times.
✗ Branch 11 → 75 not taken.
✓ Branch 12 → 13 taken 1 time.
✓ Branch 12 → 17 taken 9242 times.
✓ Branch 13 → 14 taken 1 time.
✗ Branch 13 → 56 not taken.
✓ Branch 14 → 15 taken 1 time.
✗ Branch 14 → 56 not taken.
9244 HANDLE_UNRESOLVED_TYPE_ER(rhs.type)
304
2/4
✓ Branch 18 → 19 taken 9242 times.
✗ Branch 18 → 59 not taken.
✓ Branch 19 → 20 taken 9242 times.
✗ Branch 19 → 57 not taken.
9242 const auto lhs = std::any_cast<ExprResult>(visit(node->operands[0]));
305
2/8
✓ Branch 21 → 22 taken 9242 times.
✗ Branch 21 → 75 not taken.
✗ Branch 22 → 23 not taken.
✓ Branch 22 → 27 taken 9242 times.
✗ Branch 23 → 24 not taken.
✗ Branch 23 → 60 not taken.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 60 not taken.
9242 HANDLE_UNRESOLVED_TYPE_ER(lhs.type)
306
307 // Check operator
308 9242 QualType resultType;
309
2/2
✓ Branch 27 → 28 taken 4293 times.
✓ Branch 27 → 30 taken 4949 times.
9242 if (node->op == RelationalExprNode::RelationalOp::OP_LESS) // Operator was less
310
1/2
✓ Branch 28 → 29 taken 4293 times.
✗ Branch 28 → 61 not taken.
4293 resultType = OpRuleManager::getLessResultType(node, lhs, rhs);
311
2/2
✓ Branch 30 → 31 taken 1715 times.
✓ Branch 30 → 33 taken 3234 times.
4949 else if (node->op == RelationalExprNode::RelationalOp::OP_GREATER) // Operator was greater
312
2/2
✓ Branch 31 → 32 taken 1714 times.
✓ Branch 31 → 62 taken 1 time.
1715 resultType = OpRuleManager::getGreaterResultType(node, lhs, rhs);
313
2/2
✓ Branch 33 → 34 taken 1222 times.
✓ Branch 33 → 36 taken 2012 times.
3234 else if (node->op == RelationalExprNode::RelationalOp::OP_LESS_EQUAL) // Operator was less equal
314
1/2
✓ Branch 34 → 35 taken 1222 times.
✗ Branch 34 → 63 not taken.
1222 resultType = OpRuleManager::getLessEqualResultType(node, lhs, rhs);
315
1/2
✓ Branch 36 → 37 taken 2012 times.
✗ Branch 36 → 39 not taken.
2012 else if (node->op == RelationalExprNode::RelationalOp::OP_GREATER_EQUAL) // Operator was greater equal
316
1/2
✓ Branch 37 → 38 taken 2012 times.
✗ Branch 37 → 64 not taken.
2012 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 9241 times.
✗ Branch 47 → 74 not taken.
✓ Branch 48 → 49 taken 9241 times.
✗ Branch 48 → 74 not taken.
18482 return ExprResult{node->setEvaluatedSymbolType(resultType, manIdx)};
321 }
322
323 1459 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 1459 times.
1459 if (node->operands.size() == 1)
326 return visit(node->operands.front());
327
328 // Visit leftmost operand
329
2/4
✓ Branch 8 → 9 taken 1459 times.
✗ Branch 8 → 53 not taken.
✓ Branch 9 → 10 taken 1459 times.
✗ Branch 9 → 51 not taken.
1459 auto currentResult = std::any_cast<ExprResult>(visit(node->operands[0]));
330
2/8
✓ Branch 11 → 12 taken 1459 times.
✗ Branch 11 → 69 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 1459 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 54 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 54 not taken.
1459 HANDLE_UNRESOLVED_TYPE_ER(currentResult.type)
331
332 // Loop through remaining operands
333
2/2
✓ Branch 45 → 18 taken 2287 times.
✓ Branch 45 → 46 taken 1459 times.
3746 for (size_t i = 0; i < node->opQueue.size(); i++) {
334
2/4
✓ Branch 19 → 20 taken 2287 times.
✗ Branch 19 → 57 not taken.
✓ Branch 20 → 21 taken 2287 times.
✗ Branch 20 → 55 not taken.
2287 auto operandResult = std::any_cast<ExprResult>(visit(node->operands[i + 1]));
335
2/8
✓ Branch 22 → 23 taken 2287 times.
✗ Branch 22 → 68 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 2287 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 58 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 58 not taken.
2287 HANDLE_UNRESOLVED_TYPE_ER(operandResult.type)
336
337 // Check operator
338
1/2
✓ Branch 28 → 29 taken 2287 times.
✗ Branch 28 → 68 not taken.
2287 const ShiftExprNode::ShiftOp &op = node->opQueue.front().first;
339
2/2
✓ Branch 29 → 30 taken 2098 times.
✓ Branch 29 → 31 taken 189 times.
2287 if (op == ShiftExprNode::ShiftOp::OP_SHIFT_LEFT)
340
1/2
✓ Branch 30 → 41 taken 2098 times.
✗ Branch 30 → 68 not taken.
2098 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 2287 times.
✗ Branch 41 → 68 not taken.
2287 node->opQueue.emplace(op, currentResult.type);
348
1/2
✓ Branch 42 → 43 taken 2287 times.
✗ Branch 42 → 68 not taken.
2287 node->opQueue.pop();
349 }
350
351
1/2
✓ Branch 46 → 47 taken 1459 times.
✗ Branch 46 → 69 not taken.
1459 node->setEvaluatedSymbolType(currentResult.type, manIdx);
352
1/2
✓ Branch 47 → 48 taken 1459 times.
✗ Branch 47 → 69 not taken.
1459 return currentResult;
353 }
354
355 9258 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 9258 times.
9258 if (node->operands.size() == 1)
358 return visit(node->operands.front());
359
360 // Visit leftmost operand
361
2/4
✓ Branch 8 → 9 taken 9258 times.
✗ Branch 8 → 53 not taken.
✓ Branch 9 → 10 taken 9258 times.
✗ Branch 9 → 51 not taken.
9258 auto currentResult = std::any_cast<ExprResult>(visit(node->operands[0]));
362
2/8
✓ Branch 11 → 12 taken 9258 times.
✗ Branch 11 → 69 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 9258 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 54 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 54 not taken.
9258 HANDLE_UNRESOLVED_TYPE_ER(currentResult.type)
363
364 // Loop through remaining operands
365
2/2
✓ Branch 45 → 18 taken 10598 times.
✓ Branch 45 → 46 taken 9257 times.
19855 for (size_t i = 0; i < node->opQueue.size(); i++) {
366
2/4
✓ Branch 19 → 20 taken 10598 times.
✗ Branch 19 → 57 not taken.
✓ Branch 20 → 21 taken 10598 times.
✗ Branch 20 → 55 not taken.
10598 auto operandResult = std::any_cast<ExprResult>(visit(node->operands[i + 1]));
367
2/8
✓ Branch 22 → 23 taken 10598 times.
✗ Branch 22 → 68 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 10598 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 58 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 58 not taken.
10598 HANDLE_UNRESOLVED_TYPE_ER(operandResult.type)
368
369 // Check operator
370
1/2
✓ Branch 28 → 29 taken 10598 times.
✗ Branch 28 → 68 not taken.
10598 const AdditiveExprNode::AdditiveOp &op = node->opQueue.front().first;
371
2/2
✓ Branch 29 → 30 taken 6770 times.
✓ Branch 29 → 31 taken 3828 times.
10598 if (op == AdditiveExprNode::AdditiveOp::OP_PLUS)
372
2/2
✓ Branch 30 → 41 taken 6769 times.
✓ Branch 30 → 68 taken 1 time.
6770 currentResult = opRuleManager.getPlusResultType(node, currentResult, operandResult, i);
373
1/2
✓ Branch 31 → 32 taken 3828 times.
✗ Branch 31 → 33 not taken.
3828 else if (op == AdditiveExprNode::AdditiveOp::OP_MINUS)
374
1/2
✓ Branch 32 → 41 taken 3828 times.
✗ Branch 32 → 68 not taken.
3828 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 10597 times.
✗ Branch 41 → 68 not taken.
10597 node->opQueue.emplace(op, currentResult.type);
380
1/2
✓ Branch 42 → 43 taken 10597 times.
✗ Branch 42 → 68 not taken.
10597 node->opQueue.pop();
381 }
382
383
1/2
✓ Branch 46 → 47 taken 9257 times.
✗ Branch 46 → 69 not taken.
9257 node->setEvaluatedSymbolType(currentResult.type, manIdx);
384
1/2
✓ Branch 47 → 48 taken 9257 times.
✗ Branch 47 → 69 not taken.
9257 return currentResult;
385 }
386
387 2935 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 2935 times.
2935 if (node->operands.size() == 1)
390 return visit(node->operands.front());
391
392 // Visit leftmost operand
393
2/4
✓ Branch 8 → 9 taken 2935 times.
✗ Branch 8 → 55 not taken.
✓ Branch 9 → 10 taken 2935 times.
✗ Branch 9 → 53 not taken.
2935 auto currentResult = std::any_cast<ExprResult>(visit(node->operands[0]));
394
2/8
✓ Branch 11 → 12 taken 2935 times.
✗ Branch 11 → 71 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 2935 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 56 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 56 not taken.
2935 HANDLE_UNRESOLVED_TYPE_ER(currentResult.type)
395 // Loop through remaining operands
396
2/2
✓ Branch 47 → 18 taken 2989 times.
✓ Branch 47 → 48 taken 2934 times.
5923 for (size_t i = 0; i < node->opQueue.size(); i++) {
397
2/4
✓ Branch 19 → 20 taken 2989 times.
✗ Branch 19 → 59 not taken.
✓ Branch 20 → 21 taken 2989 times.
✗ Branch 20 → 57 not taken.
2989 auto operandResult = std::any_cast<ExprResult>(visit(node->operands[i + 1]));
398
2/8
✓ Branch 22 → 23 taken 2989 times.
✗ Branch 22 → 70 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 2989 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 60 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 60 not taken.
2989 HANDLE_UNRESOLVED_TYPE_ER(operandResult.type)
399
400 // Check operator
401
1/2
✓ Branch 28 → 29 taken 2989 times.
✗ Branch 28 → 70 not taken.
2989 const MultiplicativeExprNode::MultiplicativeOp &op = node->opQueue.front().first;
402
2/2
✓ Branch 29 → 30 taken 2343 times.
✓ Branch 29 → 31 taken 646 times.
2989 if (op == MultiplicativeExprNode::MultiplicativeOp::OP_MUL)
403
2/2
✓ Branch 30 → 43 taken 2342 times.
✓ Branch 30 → 70 taken 1 time.
2343 currentResult = opRuleManager.getMulResultType(node, currentResult, operandResult, i);
404
2/2
✓ Branch 31 → 32 taken 518 times.
✓ Branch 31 → 33 taken 128 times.
646 else if (op == MultiplicativeExprNode::MultiplicativeOp::OP_DIV)
405
1/2
✓ Branch 32 → 43 taken 518 times.
✗ Branch 32 → 70 not taken.
518 currentResult = opRuleManager.getDivResultType(node, currentResult, operandResult, i);
406
1/2
✓ Branch 33 → 34 taken 128 times.
✗ Branch 33 → 35 not taken.
128 else if (op == MultiplicativeExprNode::MultiplicativeOp::OP_REM)
407
1/2
✓ Branch 34 → 43 taken 128 times.
✗ Branch 34 → 70 not taken.
128 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 2988 times.
✗ Branch 43 → 70 not taken.
2988 node->opQueue.emplace(op, currentResult.type);
413
1/2
✓ Branch 44 → 45 taken 2988 times.
✗ Branch 44 → 70 not taken.
2988 node->opQueue.pop();
414 }
415
416
1/2
✓ Branch 48 → 49 taken 2934 times.
✗ Branch 48 → 71 not taken.
2934 node->setEvaluatedSymbolType(currentResult.type, manIdx);
417
1/2
✓ Branch 49 → 50 taken 2934 times.
✗ Branch 49 → 71 not taken.
2934 return currentResult;
418 }
419
420 8334 std::any TypeChecker::visitCastExpr(CastExprNode *node) {
421 // Check if cast is applied
422
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 8334 times.
8334 if (!node->isCast)
423 return visit(node->prefixUnaryExpr);
424
425 // Visit destination type
426
2/4
✓ Branch 5 → 6 taken 8334 times.
✗ Branch 5 → 49 not taken.
✓ Branch 6 → 7 taken 8334 times.
✗ Branch 6 → 47 not taken.
8334 const auto dstType = std::any_cast<QualType>(visit(node->dataType));
427
2/8
✓ Branch 8 → 9 taken 8334 times.
✗ Branch 8 → 65 not taken.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 14 taken 8334 times.
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 50 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 50 not taken.
8334 HANDLE_UNRESOLVED_TYPE_ER(dstType)
428 // Visit source type
429
2/4
✓ Branch 14 → 15 taken 8334 times.
✗ Branch 14 → 53 not taken.
✓ Branch 15 → 16 taken 8334 times.
✗ Branch 15 → 51 not taken.
8334 const auto src = std::any_cast<ExprResult>(visit(node->assignExpr));
430
2/8
✓ Branch 17 → 18 taken 8334 times.
✗ Branch 17 → 65 not taken.
✗ Branch 18 → 19 not taken.
✓ Branch 18 → 23 taken 8334 times.
✗ Branch 19 → 20 not taken.
✗ Branch 19 → 54 not taken.
✗ Branch 20 → 21 not taken.
✗ Branch 20 → 54 not taken.
8334 HANDLE_UNRESOLVED_TYPE_ER(src.type)
431
432 // Check for identity cast
433
3/4
✓ Branch 23 → 24 taken 8334 times.
✗ Branch 23 → 65 not taken.
✓ Branch 24 → 25 taken 882 times.
✓ Branch 24 → 34 taken 7452 times.
8334 if (src.type == dstType) {
434
2/4
✓ Branch 27 → 28 taken 882 times.
✗ Branch 27 → 57 not taken.
✓ Branch 28 → 29 taken 882 times.
✗ Branch 28 → 55 not taken.
1764 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 882 times.
✗ Branch 31 → 61 not taken.
882 sourceFile->compilerOutput.warnings.push_back(warning);
436 882 }
437
438 // Get result type
439
1/2
✓ Branch 34 → 35 taken 8334 times.
✗ Branch 34 → 65 not taken.
8334 const QualType resultType = opRuleManager.getCastResultType(node, dstType, src);
440
441
1/2
✓ Branch 35 → 36 taken 8334 times.
✗ Branch 35 → 65 not taken.
8334 const bool typesMatch = dstType.matches(src.type, false, true, true);
442
1/2
✓ Branch 36 → 37 taken 8334 times.
✗ Branch 36 → 65 not taken.
8334 const bool sameContainerType = src.type.isSameContainerTypeAs(dstType);
443
4/4
✓ Branch 37 → 38 taken 7452 times.
✓ Branch 37 → 39 taken 882 times.
✓ Branch 38 → 39 taken 1835 times.
✓ Branch 38 → 40 taken 5617 times.
8334 SymbolTableEntry *entry = typesMatch || sameContainerType ? src.entry : nullptr;
444
2/4
✓ Branch 41 → 42 taken 8334 times.
✗ Branch 41 → 64 not taken.
✓ Branch 42 → 43 taken 8334 times.
✗ Branch 42 → 64 not taken.
16668 return ExprResult{node->setEvaluatedSymbolType(resultType, manIdx), entry};
445 }
446
447 6397 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 6397 times.
6397 if (node->op == PrefixUnaryExprNode::PrefixUnaryOp::OP_NONE)
450 return visit(node->postfixUnaryExpr);
451
452 // Visit the right side
453 6397 ExprNode *rhsNode = node->prefixUnaryExpr;
454
2/4
✓ Branch 5 → 6 taken 6397 times.
✗ Branch 5 → 58 not taken.
✓ Branch 6 → 7 taken 6397 times.
✗ Branch 6 → 56 not taken.
6397 auto operand = std::any_cast<ExprResult>(visit(rhsNode));
455 6397 auto [operandType, operandEntry] = operand;
456
5/8
✓ Branch 8 → 9 taken 6397 times.
✗ Branch 8 → 79 not taken.
✓ Branch 9 → 10 taken 1 time.
✓ Branch 9 → 14 taken 6396 times.
✓ Branch 10 → 11 taken 1 time.
✗ Branch 10 → 59 not taken.
✓ Branch 11 → 12 taken 1 time.
✗ Branch 11 → 59 not taken.
6398 HANDLE_UNRESOLVED_TYPE_ER(operandType)
457 // Determine action, based on the given operator
458
7/8
✓ Branch 14 → 15 taken 1004 times.
✓ Branch 14 → 17 taken 88 times.
✓ Branch 14 → 25 taken 16 times.
✓ Branch 14 → 33 taken 3586 times.
✓ Branch 14 → 35 taken 12 times.
✓ Branch 14 → 38 taken 920 times.
✓ Branch 14 → 40 taken 770 times.
✗ Branch 14 → 42 not taken.
6396 switch (node->op) {
459 1004 case PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS:
460
1/2
✓ Branch 15 → 16 taken 1004 times.
✗ Branch 15 → 60 not taken.
1004 operandType = OpRuleManager::getPrefixMinusResultType(node, operand);
461 1004 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 16 case PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS_MINUS:
476
2/2
✓ Branch 25 → 26 taken 15 times.
✓ Branch 25 → 63 taken 1 time.
16 operandType = opRuleManager.getPrefixMinusMinusResultType(node, operand);
477
478
2/2
✓ Branch 26 → 27 taken 12 times.
✓ Branch 26 → 32 taken 3 times.
15 if (operandEntry) {
479 // In case the lhs is captured, notify the capture about the write access
480
2/4
✓ Branch 27 → 28 taken 12 times.
✗ Branch 27 → 79 not taken.
✗ Branch 28 → 29 not taken.
✓ Branch 28 → 30 taken 12 times.
12 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 12 times.
✗ Branch 30 → 64 not taken.
12 operandEntry->updateState(INITIALIZED, node);
485 }
486
487 15 break;
488 3586 case PrefixUnaryExprNode::PrefixUnaryOp::OP_NOT:
489
1/2
✓ Branch 33 → 34 taken 3586 times.
✗ Branch 33 → 65 not taken.
3586 operandType = OpRuleManager::getPrefixNotResultType(node, operand);
490 3586 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 920 case PrefixUnaryExprNode::PrefixUnaryOp::OP_DEREFERENCE:
498
2/2
✓ Branch 38 → 39 taken 919 times.
✓ Branch 38 → 67 taken 1 time.
920 operandType = OpRuleManager::getPrefixMulResultType(node, operand);
499 919 break;
500 770 case PrefixUnaryExprNode::PrefixUnaryOp::OP_ADDRESS_OF:
501
1/2
✓ Branch 40 → 41 taken 770 times.
✗ Branch 40 → 68 not taken.
770 operandType = OpRuleManager::getPrefixBitwiseAndResultType(node, operand);
502 770 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 6394 times.
✗ Branch 50 → 78 not taken.
✓ Branch 51 → 52 taken 6394 times.
✗ Branch 51 → 78 not taken.
12788 return ExprResult{node->setEvaluatedSymbolType(operandType, manIdx), operandEntry};
508 }
509
510 66126 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 66126 times.
66126 if (node->op == PostfixUnaryExprNode::PostfixUnaryOp::OP_NONE)
513 return visit(node->atomicExpr);
514
515 // Visit left side
516 66126 ExprNode *lhsNode = node->postfixUnaryExpr;
517
2/4
✓ Branch 5 → 6 taken 66126 times.
✗ Branch 5 → 211 not taken.
✓ Branch 6 → 7 taken 66126 times.
✗ Branch 6 → 209 not taken.
66126 auto operand = std::any_cast<ExprResult>(visit(lhsNode));
518 66126 auto [operandType, operandEntry] = operand;
519
5/8
✓ Branch 8 → 9 taken 66126 times.
✗ Branch 8 → 316 not taken.
✓ Branch 9 → 10 taken 6 times.
✓ Branch 9 → 14 taken 66120 times.
✓ Branch 10 → 11 taken 6 times.
✗ Branch 10 → 212 not taken.
✓ Branch 11 → 12 taken 6 times.
✗ Branch 11 → 212 not taken.
66132 HANDLE_UNRESOLVED_TYPE_ER(operandType)
520
521
4/5
✓ Branch 14 → 15 taken 6833 times.
✓ Branch 14 → 101 taken 54197 times.
✓ Branch 14 → 159 taken 4639 times.
✓ Branch 14 → 167 taken 451 times.
✗ Branch 14 → 175 not taken.
66120 switch (node->op) {
522 6833 case PostfixUnaryExprNode::PostfixUnaryOp::OP_SUBSCRIPT: {
523 // Visit index assignment
524 6833 ExprNode *indexAssignExpr = node->subscriptIndexExpr;
525
2/4
✓ Branch 15 → 16 taken 6833 times.
✗ Branch 15 → 215 not taken.
✓ Branch 16 → 17 taken 6833 times.
✗ Branch 16 → 213 not taken.
6833 const auto index = std::any_cast<ExprResult>(visit(indexAssignExpr));
526
2/8
✓ Branch 18 → 19 taken 6833 times.
✗ Branch 18 → 258 not taken.
✗ Branch 19 → 20 not taken.
✓ Branch 19 → 24 taken 6833 times.
✗ Branch 20 → 21 not taken.
✗ Branch 20 → 216 not taken.
✗ Branch 21 → 22 not taken.
✗ Branch 21 → 216 not taken.
6833 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 6833 times.
✗ Branch 24 → 217 not taken.
6833 const auto [type, _] = opRuleManager.isOperatorOverloadingFctAvailable<2>(node, OP_FCT_SUBSCRIPT, {operand, index}, 0);
530
3/4
✓ Branch 25 → 26 taken 6833 times.
✗ Branch 25 → 258 not taken.
✓ Branch 26 → 27 taken 412 times.
✓ Branch 26 → 28 taken 6421 times.
6833 if (!type.is(TY_INVALID)) {
531 412 operandType = type;
532 6831 break;
533 }
534
535
1/2
✓ Branch 28 → 29 taken 6421 times.
✗ Branch 28 → 218 not taken.
6421 operandType = operandType.removeReferenceWrapper();
536
537 // Check if the index is of the right type
538
3/4
✓ Branch 29 → 30 taken 6421 times.
✗ Branch 29 → 219 not taken.
✓ Branch 30 → 31 taken 1 time.
✓ Branch 30 → 41 taken 6420 times.
6421 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 6420 times.
✗ Branch 41 → 227 not taken.
✗ Branch 42 → 43 not taken.
✓ Branch 42 → 52 taken 6420 times.
6420 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 6420 times.
✗ Branch 52 → 258 not taken.
✓ Branch 53 → 54 taken 4805 times.
✓ Branch 53 → 57 taken 1615 times.
✓ Branch 54 → 55 taken 4805 times.
✗ Branch 54 → 258 not taken.
✗ Branch 55 → 56 not taken.
✓ Branch 55 → 57 taken 4805 times.
✗ Branch 58 → 59 not taken.
✓ Branch 58 → 69 taken 6420 times.
6420 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 6420 times.
✗ Branch 69 → 258 not taken.
✓ Branch 70 → 71 taken 265 times.
✓ Branch 70 → 76 taken 6155 times.
✓ Branch 71 → 72 taken 265 times.
✗ Branch 71 → 258 not taken.
✓ Branch 72 → 73 taken 190 times.
✓ Branch 72 → 76 taken 75 times.
✓ Branch 77 → 78 taken 102 times.
✓ Branch 77 → 96 taken 6318 times.
6610 if (operandType.isArray() && operandType.getArraySize() != ARRAY_SIZE_UNKNOWN &&
554
3/4
✓ Branch 73 → 74 taken 190 times.
✗ Branch 73 → 258 not taken.
✓ Branch 74 → 75 taken 102 times.
✓ Branch 74 → 76 taken 88 times.
190 indexAssignExpr->hasCompileTimeValue(manIdx)) {
555
1/2
✓ Branch 78 → 79 taken 102 times.
✗ Branch 78 → 258 not taken.
102 const int32_t constIndex = indexAssignExpr->getCompileTimeValue(manIdx).intValue;
556
1/2
✓ Branch 79 → 80 taken 102 times.
✗ Branch 79 → 258 not taken.
102 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 101 times.
102 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 6419 times.
✗ Branch 96 → 257 not taken.
6419 operandType = operandType.getContained();
568
569 // Remove heap qualifier
570 6419 operandType.getQualifiers().isHeap = false;
571
572 6419 break;
573 }
574 54197 case PostfixUnaryExprNode::PostfixUnaryOp::OP_MEMBER_ACCESS: {
575 54197 const std::string &fieldName = node->identifier;
576
577 // Check if lhs is enum or strobj
578
1/2
✓ Branch 101 → 102 taken 54197 times.
✗ Branch 101 → 286 not taken.
54197 const QualType lhsBaseTy = operandType.autoDeReference();
579
3/4
✓ Branch 102 → 103 taken 54197 times.
✗ Branch 102 → 286 not taken.
✓ Branch 103 → 104 taken 1 time.
✓ Branch 103 → 113 taken 54196 times.
54197 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 54196 times.
✗ Branch 113 → 286 not taken.
54196 const std::string &structName = lhsBaseTy.getSubType();
584
1/2
✓ Branch 114 → 115 taken 54196 times.
✗ Branch 114 → 286 not taken.
54196 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 284 times.
✓ Branch 115 → 120 taken 53912 times.
54196 if (structScope->isGenericScope) {
588
1/2
✓ Branch 116 → 117 taken 284 times.
✗ Branch 116 → 286 not taken.
284 const Struct *spiceStruct = lhsBaseTy.getStruct(node);
589
1/2
✗ Branch 117 → 118 not taken.
✓ Branch 117 → 119 taken 284 times.
284 assert(spiceStruct != nullptr);
590 284 structScope = spiceStruct->scope;
591 }
592
1/2
✗ Branch 120 → 121 not taken.
✓ Branch 120 → 122 taken 54196 times.
54196 assert(!structScope->isGenericScope); // At this point we always expect a substantiation scope
593
594 // Get accessed field
595 54196 std::vector<size_t> indexPath;
596
1/2
✓ Branch 122 → 123 taken 54196 times.
✗ Branch 122 → 284 not taken.
54196 SymbolTableEntry *memberEntry = structScope->symbolTable.lookupInComposedFields(fieldName, indexPath);
597
2/2
✓ Branch 123 → 124 taken 2 times.
✓ Branch 123 → 135 taken 54194 times.
54196 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 54194 times.
✗ Branch 135 → 284 not taken.
54194 const QualType memberType = memberEntry->getQualType();
600
601 // Check for insufficient visibility
602
8/14
✓ Branch 136 → 137 taken 54194 times.
✗ Branch 136 → 276 not taken.
✓ Branch 137 → 138 taken 1694 times.
✓ Branch 137 → 143 taken 52500 times.
✓ Branch 138 → 139 taken 1694 times.
✗ Branch 138 → 276 not taken.
✓ Branch 139 → 140 taken 1694 times.
✗ Branch 139 → 276 not taken.
✓ Branch 140 → 141 taken 1694 times.
✗ Branch 140 → 276 not taken.
✗ Branch 141 → 142 not taken.
✓ Branch 141 → 143 taken 1694 times.
✗ Branch 144 → 145 not taken.
✓ Branch 144 → 154 taken 54194 times.
54194 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 54194 memberEntry->used = true;
607
608 // Overwrite type and entry of left side with member type and entry
609 54194 operandType = memberType;
610 54194 operandEntry = memberEntry;
611 54194 break;
612
2/2
✓ Branch 156 → 157 taken 2 times.
✓ Branch 156 → 158 taken 54194 times.
54196 }
613 4639 case PostfixUnaryExprNode::PostfixUnaryOp::OP_PLUS_PLUS: {
614
2/2
✓ Branch 159 → 160 taken 4637 times.
✓ Branch 159 → 287 taken 2 times.
4639 operandType = opRuleManager.getPostfixPlusPlusResultType(node, operand).type;
615
616
2/2
✓ Branch 160 → 161 taken 4633 times.
✓ Branch 160 → 166 taken 4 times.
4637 if (operandEntry) {
617 // In case the lhs is captured, notify the capture about the write access
618
3/4
✓ Branch 161 → 162 taken 4633 times.
✗ Branch 161 → 316 not taken.
✓ Branch 162 → 163 taken 4 times.
✓ Branch 162 → 164 taken 4629 times.
4633 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 4633 times.
✗ Branch 164 → 288 not taken.
4633 operandEntry->updateState(INITIALIZED, node);
623 }
624
625 4637 break;
626 }
627 451 case PostfixUnaryExprNode::PostfixUnaryOp::OP_MINUS_MINUS: {
628
1/2
✓ Branch 167 → 168 taken 451 times.
✗ Branch 167 → 289 not taken.
451 operandType = opRuleManager.getPostfixMinusMinusResultType(node, operand).type;
629
630
2/2
✓ Branch 168 → 169 taken 447 times.
✓ Branch 168 → 174 taken 4 times.
451 if (operandEntry) {
631 // In case the lhs is captured, notify the capture about the write access
632
2/4
✓ Branch 169 → 170 taken 447 times.
✗ Branch 169 → 316 not taken.
✗ Branch 170 → 171 not taken.
✓ Branch 170 → 172 taken 447 times.
447 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 447 times.
✗ Branch 172 → 290 not taken.
447 operandEntry->updateState(INITIALIZED, node);
637 }
638
639 451 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 66113 times.
✗ Branch 183 → 316 not taken.
✗ Branch 184 → 185 not taken.
✓ Branch 184 → 203 taken 66113 times.
66113 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 66113 times.
✗ Branch 203 → 315 not taken.
✓ Branch 204 → 205 taken 66113 times.
✗ Branch 204 → 315 not taken.
132226 return ExprResult{node->setEvaluatedSymbolType(operandType, manIdx), operandEntry};
651 }
652
653 285468 std::any TypeChecker::visitAtomicExpr(AtomicExprNode *node) {
654 // Check if constant
655
2/2
✓ Branch 2 → 3 taken 56322 times.
✓ Branch 2 → 5 taken 229146 times.
285468 if (node->constant)
656
1/2
✓ Branch 3 → 4 taken 56322 times.
✗ Branch 3 → 218 not taken.
56322 return visit(node->constant);
657
658 // Check if value
659
2/2
✓ Branch 5 → 6 taken 70368 times.
✓ Branch 5 → 8 taken 158778 times.
229146 if (node->value)
660
2/2
✓ Branch 6 → 7 taken 70364 times.
✓ Branch 6 → 218 taken 4 times.
70368 return visit(node->value);
661
662 // Check for assign expression within parentheses
663
2/2
✓ Branch 8 → 9 taken 1178 times.
✓ Branch 8 → 11 taken 157600 times.
158778 if (node->assignExpr)
664
2/2
✓ Branch 9 → 10 taken 1175 times.
✓ Branch 9 → 218 taken 3 times.
1178 return visit(node->assignExpr);
665
666 // Identifier (local or global variable access)
667
1/2
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 157600 times.
157600 assert(!node->fqIdentifier.empty());
668
669
1/2
✓ Branch 14 → 15 taken 157600 times.
✗ Branch 14 → 218 not taken.
157600 auto &[entry, accessScope, capture] = node->data.at(manIdx);
670 157600 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 153726 times.
✓ Branch 16 → 22 taken 3874 times.
157600 if (node->identifierFragments.size() == 1)
674 307452 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 4027 times.
✓ Branch 22 → 35 taken 153573 times.
157600 if (!entry) {
678
1/2
✓ Branch 23 → 24 taken 4027 times.
✗ Branch 23 → 218 not taken.
4027 const NameRegistryEntry *registryEntry = sourceFile->getNameRegistryEntry(node->fqIdentifier);
679
2/2
✓ Branch 24 → 25 taken 1 time.
✓ Branch 24 → 34 taken 4026 times.
4027 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 4026 entry = registryEntry->targetEntry;
682 4026 accessScope = registryEntry->targetScope;
683 }
684
1/2
✗ Branch 35 → 36 not taken.
✓ Branch 35 → 37 taken 157599 times.
157599 assert(entry != nullptr);
685 157599 entry->used = true;
686
1/2
✓ Branch 37 → 38 taken 157599 times.
✗ Branch 37 → 218 not taken.
157599 capture = accessScope->symbolTable.lookupCapture(entry->name);
687
688
1/2
✓ Branch 38 → 39 taken 157599 times.
✗ Branch 38 → 218 not taken.
157599 const QualType varType = entry->getQualType();
689
5/8
✓ Branch 39 → 40 taken 157599 times.
✗ Branch 39 → 218 not taken.
✓ Branch 40 → 41 taken 9 times.
✓ Branch 40 → 45 taken 157590 times.
✓ Branch 41 → 42 taken 9 times.
✗ Branch 41 → 169 not taken.
✓ Branch 42 → 43 taken 9 times.
✗ Branch 42 → 169 not taken.
157608 HANDLE_UNRESOLVED_TYPE_ER(varType)
690
3/4
✓ Branch 45 → 46 taken 157590 times.
✗ Branch 45 → 218 not taken.
✓ Branch 46 → 47 taken 2 times.
✓ Branch 46 → 56 taken 157588 times.
157590 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 157588 times.
✗ Branch 56 → 177 not taken.
✓ Branch 57 → 58 taken 127 times.
✓ Branch 57 → 60 taken 157461 times.
✓ Branch 58 → 59 taken 21 times.
✓ Branch 58 → 60 taken 106 times.
✓ Branch 61 → 62 taken 21 times.
✓ Branch 61 → 90 taken 157567 times.
157588 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 157586 times.
✗ Branch 90 → 218 not taken.
157586 const QualType baseType = varType.getBase();
708
6/10
✓ Branch 91 → 92 taken 157586 times.
✗ Branch 91 → 218 not taken.
✓ Branch 92 → 93 taken 4 times.
✓ Branch 92 → 96 taken 157582 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 157586 times.
157586 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 157585 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 157585 times.
157586 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 157585 times.
✗ Branch 125 → 218 not taken.
✓ Branch 126 → 127 taken 3350 times.
✓ Branch 126 → 129 taken 154235 times.
✓ Branch 127 → 128 taken 257 times.
✓ Branch 127 → 129 taken 3093 times.
✓ Branch 130 → 131 taken 257 times.
✓ Branch 130 → 144 taken 157328 times.
157585 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 3869 times.
✓ Branch 144 → 146 taken 153715 times.
157584 if (entry->scope->type == ScopeType::ENUM)
724 3869 accessScope = entry->scope;
725
726 // For struct access, use access scope of the struct
727
3/4
✓ Branch 146 → 147 taken 157584 times.
✗ Branch 146 → 218 not taken.
✓ Branch 147 → 148 taken 68893 times.
✓ Branch 147 → 156 taken 88691 times.
157584 if (baseType.is(TY_STRUCT)) {
728
1/2
✓ Branch 148 → 149 taken 68893 times.
✗ Branch 148 → 218 not taken.
68893 const std::string &structName = baseType.getSubType();
729
1/2
✓ Branch 149 → 150 taken 68893 times.
✗ Branch 149 → 218 not taken.
68893 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 68876 times.
✓ Branch 150 → 152 taken 17 times.
✓ Branch 152 → 153 taken 17 times.
✗ Branch 152 → 218 not taken.
68893 accessScope = nameRegistryEntry != nullptr ? nameRegistryEntry->targetScope : baseType.getBodyScope();
735
1/2
✗ Branch 154 → 155 not taken.
✓ Branch 154 → 156 taken 68893 times.
68893 assert(accessScope != nullptr);
736 }
737
738
2/4
✓ Branch 156 → 157 taken 157584 times.
✗ Branch 156 → 217 not taken.
✓ Branch 157 → 158 taken 157584 times.
✗ Branch 157 → 217 not taken.
315168 return ExprResult{node->setEvaluatedSymbolType(varType, manIdx), entry};
739 }
740
741 } // namespace spice::compiler
742