| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright (c) 2021-2025 ChilliBits. All rights reserved. | ||
| 2 | |||
| 3 | #include "OpRuleManager.h" | ||
| 4 | |||
| 5 | #include <SourceFile.h> | ||
| 6 | #include <ast/ASTNodes.h> | ||
| 7 | #include <global/GlobalResourceManager.h> | ||
| 8 | #include <global/RuntimeModuleManager.h> | ||
| 9 | #include <typechecker/MacroDefs.h> | ||
| 10 | #include <typechecker/TypeChecker.h> | ||
| 11 | |||
| 12 | namespace spice::compiler { | ||
| 13 | |||
| 14 | 3564 | OpRuleManager::OpRuleManager(TypeChecker *typeChecker) | |
| 15 | 3564 | : typeChecker(typeChecker), resourceManager(typeChecker->resourceManager) {} | |
| 16 | |||
| 17 | 26536 | std::pair<QualType, Function *> OpRuleManager::getAssignResultType(const ASTNode *node, const ExprResult &lhs, | |
| 18 | const ExprResult &rhs, bool isDecl, bool isReturn, | ||
| 19 | const char *errMsgPrefix) const { | ||
| 20 | // Retrieve types | ||
| 21 | 26536 | const QualType lhsType = lhs.type; | |
| 22 | 26536 | const QualType rhsType = rhs.type; | |
| 23 | |||
| 24 | // Check if lhs is a temporary | ||
| 25 |
2/2✓ Branch 3 → 4 taken 1 time.
✓ Branch 3 → 12 taken 26535 times.
|
26536 | if (lhs.isTemporary()) |
| 26 |
2/4✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 111 not taken.
✓ Branch 8 → 9 taken 1 time.
✗ Branch 8 → 108 not taken.
|
3 | throw SemanticError(node, OPERATOR_WRONG_DATA_TYPE, "Cannot assign to a temporary value"); |
| 27 | |||
| 28 | // Skip type compatibility check if the lhs is of type dyn -> perform type inference | ||
| 29 |
3/4✓ Branch 12 → 13 taken 26535 times.
✗ Branch 12 → 125 not taken.
✓ Branch 13 → 14 taken 77 times.
✓ Branch 13 → 16 taken 26458 times.
|
26535 | if (lhsType.is(TY_DYN)) |
| 30 | 77 | return {rhsType, nullptr}; | |
| 31 | |||
| 32 | // Check if we try to assign a constant value | ||
| 33 |
1/2✓ Branch 16 → 17 taken 26458 times.
✗ Branch 16 → 125 not taken.
|
26458 | ensureNoConstAssign(node, lhsType, isDecl, isReturn); |
| 34 | |||
| 35 | // Allow pointers and references of the same type straight away | ||
| 36 |
8/10✓ Branch 17 → 18 taken 26458 times.
✗ Branch 17 → 117 not taken.
✓ Branch 18 → 19 taken 3577 times.
✓ Branch 18 → 22 taken 22881 times.
✓ Branch 19 → 20 taken 3577 times.
✗ Branch 19 → 117 not taken.
✓ Branch 20 → 21 taken 2945 times.
✓ Branch 20 → 22 taken 632 times.
✓ Branch 23 → 24 taken 2945 times.
✓ Branch 23 → 41 taken 23513 times.
|
26458 | if (lhsType.isOneOf({TY_PTR, TY_REF}) && lhsType.matches(rhsType, false, false, true)) { |
| 37 | // If we perform a heap x* = heap x* assignment, we need set the right hand side to MOVED | ||
| 38 |
15/22✓ Branch 24 → 25 taken 982 times.
✓ Branch 24 → 35 taken 1963 times.
✓ Branch 25 → 26 taken 982 times.
✗ Branch 25 → 118 not taken.
✓ Branch 26 → 27 taken 669 times.
✓ Branch 26 → 35 taken 313 times.
✓ Branch 27 → 28 taken 669 times.
✗ Branch 27 → 118 not taken.
✓ Branch 28 → 29 taken 546 times.
✓ Branch 28 → 35 taken 123 times.
✓ Branch 29 → 30 taken 546 times.
✗ Branch 29 → 118 not taken.
✓ Branch 30 → 31 taken 546 times.
✗ Branch 30 → 118 not taken.
✓ Branch 31 → 32 taken 546 times.
✗ Branch 31 → 35 not taken.
✓ Branch 32 → 33 taken 546 times.
✗ Branch 32 → 118 not taken.
✓ Branch 33 → 34 taken 546 times.
✗ Branch 33 → 35 not taken.
✓ Branch 36 → 37 taken 546 times.
✓ Branch 36 → 39 taken 2399 times.
|
2945 | if (rhs.entry && lhsType.isPtr() && lhsType.isHeap() && rhsType.removeReferenceWrapper().isPtr() && rhsType.isHeap()) |
| 39 |
1/2✓ Branch 37 → 38 taken 546 times.
✗ Branch 37 → 119 not taken.
|
546 | rhs.entry->updateState(MOVED, node); |
| 40 | 2945 | return {rhsType, nullptr}; | |
| 41 | } | ||
| 42 | // Allow ref type to type of the same contained type straight away | ||
| 43 |
3/4✓ Branch 41 → 42 taken 23513 times.
✗ Branch 41 → 125 not taken.
✓ Branch 42 → 43 taken 368 times.
✓ Branch 42 → 63 taken 23145 times.
|
23513 | if (rhsType.isRef()) { |
| 44 | // If this is const ref, remove both: the reference and the constness | ||
| 45 |
2/4✓ Branch 43 → 44 taken 368 times.
✗ Branch 43 → 120 not taken.
✓ Branch 44 → 45 taken 368 times.
✗ Branch 44 → 120 not taken.
|
368 | const QualType rhsModified = rhsType.getContained().toNonConst(); |
| 46 |
3/4✓ Branch 45 → 46 taken 368 times.
✗ Branch 45 → 122 not taken.
✓ Branch 46 → 47 taken 366 times.
✓ Branch 46 → 62 taken 2 times.
|
368 | if (lhsType.matches(rhsModified, false, false, true)) { |
| 47 | // Check if we support nrvo. If yes, skip the implicit copy ctor call | ||
| 48 |
4/4✓ Branch 47 → 48 taken 13 times.
✓ Branch 47 → 51 taken 353 times.
✓ Branch 49 → 50 taken 2 times.
✓ Branch 49 → 51 taken 11 times.
|
366 | const bool supportsNRVO = isReturn && !rhs.isTemporary(); |
| 49 | 366 | Function *copyCtor = nullptr; | |
| 50 |
7/8✓ Branch 52 → 53 taken 366 times.
✗ Branch 52 → 121 not taken.
✓ Branch 53 → 54 taken 242 times.
✓ Branch 53 → 56 taken 124 times.
✓ Branch 54 → 55 taken 240 times.
✓ Branch 54 → 56 taken 2 times.
✓ Branch 57 → 58 taken 240 times.
✓ Branch 57 → 60 taken 126 times.
|
366 | if (rhsModified.is(TY_STRUCT) && !supportsNRVO) |
| 51 |
1/2✓ Branch 58 → 59 taken 240 times.
✗ Branch 58 → 121 not taken.
|
240 | copyCtor = typeChecker->implicitlyCallStructCopyCtor(rhsModified, node); |
| 52 | 366 | return {lhsType, copyCtor}; | |
| 53 | } | ||
| 54 | } | ||
| 55 | // Allow arrays, structs, interfaces, functions, procedures of the same type straight away | ||
| 56 |
8/10✓ Branch 63 → 64 taken 23147 times.
✗ Branch 63 → 123 not taken.
✓ Branch 64 → 65 taken 85 times.
✓ Branch 64 → 68 taken 23062 times.
✓ Branch 65 → 66 taken 85 times.
✗ Branch 65 → 123 not taken.
✓ Branch 66 → 67 taken 80 times.
✓ Branch 66 → 68 taken 5 times.
✓ Branch 69 → 70 taken 80 times.
✓ Branch 69 → 72 taken 23067 times.
|
23147 | if (lhsType.isOneOf({TY_ARRAY, TY_INTERFACE, TY_FUNCTION, TY_PROCEDURE}) && lhsType.matches(rhsType, false, true, true)) |
| 57 | 80 | return {rhsType, nullptr}; | |
| 58 | // Allow struct of the same type straight away | ||
| 59 |
8/10✓ Branch 72 → 73 taken 23067 times.
✗ Branch 72 → 125 not taken.
✓ Branch 73 → 74 taken 2710 times.
✓ Branch 73 → 77 taken 20357 times.
✓ Branch 74 → 75 taken 2710 times.
✗ Branch 74 → 125 not taken.
✓ Branch 75 → 76 taken 2709 times.
✓ Branch 75 → 77 taken 1 time.
✓ Branch 78 → 79 taken 2709 times.
✓ Branch 78 → 96 taken 20358 times.
|
23067 | if (lhsType.is(TY_STRUCT) && lhsType.matches(rhsType, false, true, true)) { |
| 60 | // Check if we support nrvo. If yes, skip the implicit copy ctor call | ||
| 61 |
4/4✓ Branch 79 → 80 taken 1488 times.
✓ Branch 79 → 83 taken 1221 times.
✓ Branch 81 → 82 taken 113 times.
✓ Branch 81 → 83 taken 1375 times.
|
2709 | const bool supportsNRVO = isReturn && !rhs.isTemporary(); |
| 62 | 2709 | Function *copyCtor = nullptr; | |
| 63 |
10/10✓ Branch 84 → 85 taken 2023 times.
✓ Branch 84 → 90 taken 686 times.
✓ Branch 85 → 86 taken 1910 times.
✓ Branch 85 → 90 taken 113 times.
✓ Branch 86 → 87 taken 1053 times.
✓ Branch 86 → 90 taken 857 times.
✓ Branch 88 → 89 taken 12 times.
✓ Branch 88 → 90 taken 1041 times.
✓ Branch 91 → 92 taken 12 times.
✓ Branch 91 → 94 taken 2697 times.
|
2709 | if (rhs.entry != nullptr && !supportsNRVO && !isReturn && !rhs.isTemporary()) |
| 64 |
1/2✓ Branch 92 → 93 taken 12 times.
✗ Branch 92 → 124 not taken.
|
12 | copyCtor = typeChecker->implicitlyCallStructCopyCtor(rhsType, rhs.entry->declNode); |
| 65 | 2709 | return {rhsType, copyCtor}; | |
| 66 | } | ||
| 67 | |||
| 68 | // Check common type combinations | ||
| 69 |
2/2✓ Branch 96 → 97 taken 20356 times.
✓ Branch 96 → 125 taken 2 times.
|
20358 | const QualType resultType = getAssignResultTypeCommon(node, lhs, rhs, isDecl, isReturn); |
| 70 |
3/4✓ Branch 97 → 98 taken 20356 times.
✗ Branch 97 → 125 not taken.
✓ Branch 98 → 99 taken 580 times.
✓ Branch 98 → 101 taken 19776 times.
|
20356 | if (!resultType.is(TY_INVALID)) |
| 71 | 580 | return {resultType, nullptr}; | |
| 72 | |||
| 73 | // Check primitive type combinations | ||
| 74 | const QualType binOpType = | ||
| 75 |
2/2✓ Branch 103 → 104 taken 19764 times.
✓ Branch 103 → 125 taken 12 times.
|
19776 | validateBinaryOperation(node, ASSIGN_OP_RULES, std::size(ASSIGN_OP_RULES), "=", lhsType, rhsType, true, errMsgPrefix); |
| 76 | 19764 | return {binOpType, nullptr}; | |
| 77 | } | ||
| 78 | |||
| 79 | 413 | QualType OpRuleManager::getFieldAssignResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, bool imm, | |
| 80 | bool isDecl) const { | ||
| 81 | // Retrieve types | ||
| 82 | 413 | const QualType lhsType = lhs.type; | |
| 83 | 413 | const QualType rhsType = rhs.type; | |
| 84 |
2/4✓ Branch 2 → 3 taken 413 times.
✗ Branch 2 → 92 not taken.
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 413 times.
|
413 | assert(!lhsType.is(TY_DYN)); |
| 85 | |||
| 86 | // Check if we try to assign a constant value | ||
| 87 |
1/2✓ Branch 5 → 6 taken 413 times.
✗ Branch 5 → 92 not taken.
|
413 | ensureNoConstAssign(node, lhsType, isDecl); |
| 88 | |||
| 89 | // Allow pointers, arrays and structs of the same type straight away | ||
| 90 |
8/10✓ Branch 6 → 7 taken 413 times.
✗ Branch 6 → 85 not taken.
✓ Branch 7 → 8 taken 239 times.
✓ Branch 7 → 11 taken 174 times.
✓ Branch 8 → 9 taken 239 times.
✗ Branch 8 → 85 not taken.
✓ Branch 9 → 10 taken 237 times.
✓ Branch 9 → 11 taken 2 times.
✓ Branch 12 → 13 taken 237 times.
✓ Branch 12 → 29 taken 176 times.
|
413 | if (lhsType.isOneOf({TY_PTR, TY_ARRAY}) && lhsType == rhsType) { |
| 91 | // If we perform a heap x* = heap x* assignment, we need set the right hand side to MOVED | ||
| 92 |
8/22✓ Branch 13 → 14 taken 66 times.
✓ Branch 13 → 24 taken 171 times.
✓ Branch 14 → 15 taken 66 times.
✗ Branch 14 → 86 not taken.
✓ Branch 15 → 16 taken 64 times.
✓ Branch 15 → 24 taken 2 times.
✓ Branch 16 → 17 taken 64 times.
✗ Branch 16 → 86 not taken.
✗ Branch 17 → 18 not taken.
✓ Branch 17 → 24 taken 64 times.
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 86 not taken.
✗ Branch 19 → 20 not taken.
✗ Branch 19 → 86 not taken.
✗ Branch 20 → 21 not taken.
✗ Branch 20 → 24 not taken.
✗ Branch 21 → 22 not taken.
✗ Branch 21 → 86 not taken.
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 24 not taken.
✗ Branch 25 → 26 not taken.
✓ Branch 25 → 28 taken 237 times.
|
237 | if (rhs.entry && lhsType.isPtr() && lhsType.isHeap() && rhsType.removeReferenceWrapper().isPtr() && rhsType.isHeap()) |
| 93 | ✗ | rhs.entry->updateState(MOVED, node); | |
| 94 | 237 | return rhsType; | |
| 95 | } | ||
| 96 | // Allow struct of the same type straight away | ||
| 97 |
8/10✓ Branch 29 → 30 taken 176 times.
✗ Branch 29 → 92 not taken.
✓ Branch 30 → 31 taken 11 times.
✓ Branch 30 → 34 taken 165 times.
✓ Branch 31 → 32 taken 11 times.
✗ Branch 31 → 92 not taken.
✓ Branch 32 → 33 taken 9 times.
✓ Branch 32 → 34 taken 2 times.
✓ Branch 35 → 36 taken 9 times.
✓ Branch 35 → 40 taken 167 times.
|
176 | if (lhsType.is(TY_STRUCT) && lhsType.matches(rhsType, false, true, true)) { |
| 98 |
2/2✓ Branch 37 → 38 taken 5 times.
✓ Branch 37 → 39 taken 4 times.
|
9 | if (!rhs.isTemporary()) |
| 99 |
1/2✓ Branch 38 → 39 taken 5 times.
✗ Branch 38 → 92 not taken.
|
5 | typeChecker->implicitlyCallStructCopyCtor(rhs.entry, rhs.entry->declNode); |
| 100 | 9 | return rhsType; | |
| 101 | } | ||
| 102 | // Allow ref type to type of the same contained type straight away | ||
| 103 |
9/12✓ Branch 40 → 41 taken 167 times.
✗ Branch 40 → 88 not taken.
✓ Branch 41 → 42 taken 24 times.
✓ Branch 41 → 46 taken 143 times.
✓ Branch 42 → 43 taken 24 times.
✗ Branch 42 → 88 not taken.
✓ Branch 43 → 44 taken 24 times.
✗ Branch 43 → 88 not taken.
✓ Branch 44 → 45 taken 1 time.
✓ Branch 44 → 46 taken 23 times.
✓ Branch 47 → 48 taken 1 time.
✓ Branch 47 → 58 taken 166 times.
|
167 | if (rhsType.isRef() && lhsType.matches(rhsType.getContained(), false, false, true)) { |
| 104 | // In case of a return expression, we perform temp stealing | ||
| 105 |
4/10✓ Branch 48 → 49 taken 1 time.
✗ Branch 48 → 89 not taken.
✓ Branch 49 → 50 taken 1 time.
✗ Branch 49 → 89 not taken.
✗ Branch 50 → 51 not taken.
✓ Branch 50 → 54 taken 1 time.
✗ Branch 52 → 53 not taken.
✗ Branch 52 → 54 not taken.
✗ Branch 55 → 56 not taken.
✓ Branch 55 → 57 taken 1 time.
|
1 | if (rhsType.getContained().is(TY_STRUCT) && !rhs.isTemporary()) |
| 106 | ✗ | typeChecker->implicitlyCallStructCopyCtor(rhs.entry, rhs.entry->declNode); | |
| 107 | 1 | return lhsType; | |
| 108 | } | ||
| 109 | // Allow const ref type to type of the same contained type straight away | ||
| 110 |
9/14✓ Branch 58 → 59 taken 166 times.
✗ Branch 58 → 90 not taken.
✓ Branch 59 → 60 taken 23 times.
✓ Branch 59 → 65 taken 143 times.
✓ Branch 60 → 61 taken 23 times.
✗ Branch 60 → 90 not taken.
✓ Branch 61 → 62 taken 23 times.
✗ Branch 61 → 90 not taken.
✓ Branch 62 → 63 taken 23 times.
✗ Branch 62 → 90 not taken.
✓ Branch 63 → 64 taken 23 times.
✗ Branch 63 → 65 not taken.
✓ Branch 66 → 67 taken 23 times.
✓ Branch 66 → 68 taken 143 times.
|
166 | if (rhsType.isConstRef() && lhsType.matches(rhsType.getContained().toNonConst(), false, false, true)) |
| 111 | 23 | return lhsType; | |
| 112 | // Allow immediate value to const ref of the same contained type straight away | ||
| 113 |
6/8✓ Branch 68 → 69 taken 143 times.
✗ Branch 68 → 92 not taken.
✓ Branch 69 → 70 taken 1 time.
✓ Branch 69 → 72 taken 142 times.
✓ Branch 70 → 71 taken 1 time.
✗ Branch 70 → 72 not taken.
✓ Branch 73 → 74 taken 1 time.
✓ Branch 73 → 75 taken 142 times.
|
143 | if (lhsType.isConstRef() && imm) |
| 114 | 1 | return rhsType; | |
| 115 | |||
| 116 | // Check common type combinations | ||
| 117 |
1/2✓ Branch 75 → 76 taken 142 times.
✗ Branch 75 → 92 not taken.
|
142 | const QualType resultType = getAssignResultTypeCommon(node, lhs, rhs, isDecl, false); |
| 118 |
3/4✓ Branch 76 → 77 taken 142 times.
✗ Branch 76 → 92 not taken.
✓ Branch 77 → 78 taken 4 times.
✓ Branch 77 → 79 taken 138 times.
|
142 | if (!resultType.is(TY_INVALID)) |
| 119 | 4 | return resultType; | |
| 120 | |||
| 121 | // Check primitive type combinations | ||
| 122 |
2/2✓ Branch 81 → 82 taken 137 times.
✓ Branch 81 → 92 taken 1 time.
|
138 | return validateBinaryOperation(node, ASSIGN_OP_RULES, std::size(ASSIGN_OP_RULES), "=", lhsType, rhsType, true, |
| 123 | 137 | ERROR_FIELD_ASSIGN); | |
| 124 | } | ||
| 125 | |||
| 126 | 20500 | QualType OpRuleManager::getAssignResultTypeCommon(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, bool isDecl, | |
| 127 | bool isReturn) { | ||
| 128 | // Retrieve types | ||
| 129 | 20500 | const QualType lhsType = lhs.type; | |
| 130 | 20500 | const QualType rhsType = rhs.type; | |
| 131 | |||
| 132 | // Allow type to ref type of the same contained type straight away | ||
| 133 |
9/12✓ Branch 2 → 3 taken 20500 times.
✗ Branch 2 → 113 not taken.
✓ Branch 3 → 4 taken 425 times.
✓ Branch 3 → 8 taken 20075 times.
✓ Branch 4 → 5 taken 425 times.
✗ Branch 4 → 113 not taken.
✓ Branch 5 → 6 taken 425 times.
✗ Branch 5 → 113 not taken.
✓ Branch 6 → 7 taken 422 times.
✓ Branch 6 → 8 taken 3 times.
✓ Branch 9 → 10 taken 422 times.
✓ Branch 9 → 44 taken 20078 times.
|
20500 | if (lhsType.isRef() && lhsType.getContained().matches(rhsType, false, false, true)) { |
| 134 |
4/4✓ Branch 10 → 11 taken 359 times.
✓ Branch 10 → 12 taken 63 times.
✓ Branch 11 → 12 taken 297 times.
✓ Branch 11 → 13 taken 62 times.
|
422 | const bool isDeclOrReturn = isDecl || isReturn; |
| 135 |
7/8✓ Branch 14 → 15 taken 360 times.
✓ Branch 14 → 19 taken 62 times.
✓ Branch 16 → 17 taken 360 times.
✗ Branch 16 → 137 not taken.
✓ Branch 17 → 18 taken 1 time.
✓ Branch 17 → 19 taken 359 times.
✓ Branch 20 → 21 taken 1 time.
✓ Branch 20 → 29 taken 421 times.
|
422 | if (isDeclOrReturn && !lhsType.canBind(rhsType, rhs.isTemporary())) |
| 136 |
2/4✓ Branch 24 → 25 taken 1 time.
✗ Branch 24 → 117 not taken.
✓ Branch 25 → 26 taken 1 time.
✗ Branch 25 → 114 not taken.
|
3 | throw SemanticError(node, TEMP_TO_NON_CONST_REF, "Temporary values can only be bound to const reference variables/fields"); |
| 137 |
6/6✓ Branch 29 → 30 taken 297 times.
✓ Branch 29 → 33 taken 124 times.
✓ Branch 31 → 32 taken 1 time.
✓ Branch 31 → 33 taken 296 times.
✓ Branch 34 → 35 taken 1 time.
✓ Branch 34 → 43 taken 420 times.
|
421 | if (isReturn && rhs.isTemporary()) |
| 138 |
2/4✓ Branch 38 → 39 taken 1 time.
✗ Branch 38 → 126 not taken.
✓ Branch 39 → 40 taken 1 time.
✗ Branch 39 → 123 not taken.
|
3 | throw SemanticError(node, RETURN_OF_TEMPORARY_VALUE, "Cannot return reference to temporary value"); |
| 139 | 420 | return lhsType; | |
| 140 | } | ||
| 141 | // Allow char* = string | ||
| 142 |
9/14✓ Branch 44 → 45 taken 20078 times.
✗ Branch 44 → 137 not taken.
✓ Branch 45 → 46 taken 1 time.
✓ Branch 45 → 53 taken 20077 times.
✓ Branch 46 → 47 taken 1 time.
✗ Branch 46 → 137 not taken.
✓ Branch 47 → 48 taken 1 time.
✗ Branch 47 → 53 not taken.
✓ Branch 50 → 51 taken 1 time.
✗ Branch 50 → 137 not taken.
✓ Branch 51 → 52 taken 1 time.
✗ Branch 51 → 53 not taken.
✓ Branch 54 → 55 taken 1 time.
✓ Branch 54 → 56 taken 20077 times.
|
20078 | if (lhsType.isPtrTo(TY_CHAR) && rhsType.is(TY_STRING) && lhsType.getQualifiers() == rhsType.getQualifiers()) |
| 143 | 1 | return lhsType; | |
| 144 | // Allow array to pointer | ||
| 145 |
12/18✓ Branch 56 → 57 taken 20077 times.
✗ Branch 56 → 132 not taken.
✓ Branch 57 → 58 taken 163 times.
✓ Branch 57 → 65 taken 19914 times.
✓ Branch 58 → 59 taken 163 times.
✗ Branch 58 → 132 not taken.
✓ Branch 59 → 60 taken 6 times.
✓ Branch 59 → 65 taken 157 times.
✓ Branch 60 → 61 taken 6 times.
✗ Branch 60 → 132 not taken.
✓ Branch 61 → 62 taken 6 times.
✗ Branch 61 → 132 not taken.
✓ Branch 62 → 63 taken 6 times.
✗ Branch 62 → 132 not taken.
✓ Branch 63 → 64 taken 6 times.
✗ Branch 63 → 65 not taken.
✓ Branch 66 → 67 taken 6 times.
✓ Branch 66 → 68 taken 20071 times.
|
20077 | if (lhsType.isPtr() && rhsType.isArray() && lhsType.getContained().matches(rhsType.getContained(), false, false, true)) |
| 146 | 6 | return lhsType; | |
| 147 | // Allow interface* = struct* or interface& = struct that implements this interface | ||
| 148 |
1/2✓ Branch 70 → 71 taken 20071 times.
✗ Branch 70 → 137 not taken.
|
20071 | const bool sameChainDepth = Type::hasSameTypeChainDepth(lhsType.getType(), rhsType.getType()); |
| 149 |
10/14✓ Branch 71 → 72 taken 20071 times.
✗ Branch 71 → 137 not taken.
✓ Branch 72 → 73 taken 157 times.
✓ Branch 72 → 76 taken 19914 times.
✓ Branch 73 → 74 taken 157 times.
✗ Branch 73 → 137 not taken.
✓ Branch 74 → 75 taken 156 times.
✓ Branch 74 → 76 taken 1 time.
✗ Branch 75 → 76 not taken.
✓ Branch 75 → 78 taken 156 times.
✓ Branch 76 → 77 taken 19915 times.
✗ Branch 76 → 137 not taken.
✓ Branch 77 → 78 taken 3 times.
✓ Branch 77 → 79 taken 19912 times.
|
20071 | const bool typesCompatible = (lhsType.isPtr() && rhsType.isPtr() && sameChainDepth) || lhsType.isRef(); |
| 150 |
9/12✓ Branch 80 → 81 taken 159 times.
✓ Branch 80 → 86 taken 19912 times.
✓ Branch 81 → 82 taken 159 times.
✗ Branch 81 → 137 not taken.
✓ Branch 82 → 83 taken 5 times.
✓ Branch 82 → 86 taken 154 times.
✓ Branch 83 → 84 taken 5 times.
✗ Branch 83 → 137 not taken.
✓ Branch 84 → 85 taken 5 times.
✗ Branch 84 → 86 not taken.
✓ Branch 87 → 88 taken 5 times.
✓ Branch 87 → 93 taken 20066 times.
|
20071 | if (typesCompatible && lhsType.isBase(TY_INTERFACE) && rhsType.isBase(TY_STRUCT)) { |
| 151 | 5 | QualType lhsTypeCopy = lhsType; | |
| 152 | 5 | QualType rhsTypeCopy = rhsType; | |
| 153 |
1/2✓ Branch 88 → 89 taken 5 times.
✗ Branch 88 → 134 not taken.
|
5 | QualType::unwrapBothWithRefWrappers(lhsTypeCopy, rhsTypeCopy); |
| 154 |
2/4✓ Branch 89 → 90 taken 5 times.
✗ Branch 89 → 134 not taken.
✓ Branch 90 → 91 taken 5 times.
✗ Branch 90 → 92 not taken.
|
5 | if (lhsTypeCopy.matchesInterfaceImplementedByStruct(rhsTypeCopy)) |
| 155 | 5 | return lhsType; | |
| 156 | } | ||
| 157 | // Allow type* = heap type* straight away. This is used for initializing non-owning pointers to heap allocations | ||
| 158 |
10/14✓ Branch 93 → 94 taken 20066 times.
✗ Branch 93 → 137 not taken.
✓ Branch 94 → 95 taken 153 times.
✓ Branch 94 → 100 taken 19913 times.
✓ Branch 95 → 96 taken 153 times.
✗ Branch 95 → 137 not taken.
✓ Branch 96 → 97 taken 152 times.
✓ Branch 96 → 100 taken 1 time.
✓ Branch 97 → 98 taken 152 times.
✗ Branch 97 → 137 not taken.
✓ Branch 98 → 99 taken 152 times.
✗ Branch 98 → 100 not taken.
✓ Branch 101 → 102 taken 152 times.
✓ Branch 101 → 108 taken 19914 times.
|
20066 | if (lhsType.isPtr() && rhsType.isHeap() && lhsType.matches(rhsType, false, true, true)) { |
| 159 | 152 | TypeQualifiers rhsQualifiers = rhsType.getQualifiers(); | |
| 160 | 152 | rhsQualifiers.isHeap = false; | |
| 161 |
2/4✓ Branch 104 → 105 taken 152 times.
✗ Branch 104 → 135 not taken.
✓ Branch 105 → 106 taken 152 times.
✗ Branch 105 → 107 not taken.
|
152 | if (lhsType.getQualifiers() == rhsQualifiers) |
| 162 | 152 | return lhsType; | |
| 163 | } | ||
| 164 | |||
| 165 | // Nothing matched | ||
| 166 |
1/2✓ Branch 108 → 109 taken 19914 times.
✗ Branch 108 → 136 not taken.
|
19914 | return QualType(TY_INVALID); |
| 167 | } | ||
| 168 | |||
| 169 | 276 | ExprResult OpRuleManager::getPlusEqualResultType(ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, size_t opIdx) { | |
| 170 | // Check is there is an overloaded operator function available | ||
| 171 |
1/2✓ Branch 2 → 3 taken 276 times.
✗ Branch 2 → 24 not taken.
|
276 | const ExprResult resultType = isOperatorOverloadingFctAvailable<2>(node, OP_FCT_PLUS_EQUAL, {lhs, rhs}, opIdx); |
| 172 |
3/4✓ Branch 3 → 4 taken 276 times.
✗ Branch 3 → 26 not taken.
✓ Branch 4 → 5 taken 97 times.
✓ Branch 4 → 6 taken 179 times.
|
276 | if (!resultType.type.is(TY_INVALID)) |
| 173 | 97 | return resultType; | |
| 174 | |||
| 175 | // Check if we try to assign a constant value | ||
| 176 |
1/2✓ Branch 6 → 7 taken 179 times.
✗ Branch 6 → 26 not taken.
|
179 | ensureNoConstAssign(node, lhs.type); |
| 177 | |||
| 178 | // Remove reference wrappers | ||
| 179 |
1/2✓ Branch 7 → 8 taken 179 times.
✗ Branch 7 → 26 not taken.
|
179 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 180 |
1/2✓ Branch 8 → 9 taken 179 times.
✗ Branch 8 → 26 not taken.
|
179 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 181 | |||
| 182 | // Check if this is an unsafe operation | ||
| 183 |
7/10✓ Branch 9 → 10 taken 179 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 5 times.
✓ Branch 10 → 14 taken 174 times.
✓ Branch 11 → 12 taken 5 times.
✗ Branch 11 → 25 not taken.
✓ Branch 12 → 13 taken 5 times.
✗ Branch 12 → 14 not taken.
✓ Branch 15 → 16 taken 5 times.
✓ Branch 15 → 18 taken 174 times.
|
179 | if (lhsType.isPtr() && rhsType.isOneOf({TY_INT, TY_LONG, TY_SHORT})) { |
| 184 |
1/2✓ Branch 16 → 17 taken 5 times.
✗ Branch 16 → 26 not taken.
|
5 | ensureUnsafeAllowed(node, "+=", lhsType, rhsType); |
| 185 | 5 | return {lhs}; | |
| 186 | } | ||
| 187 | |||
| 188 |
1/2✓ Branch 20 → 21 taken 174 times.
✗ Branch 20 → 26 not taken.
|
174 | return {validateBinaryOperation(node, PLUS_EQUAL_OP_RULES, std::size(PLUS_EQUAL_OP_RULES), "+=", lhsType, rhsType)}; |
| 189 | } | ||
| 190 | |||
| 191 | 48 | ExprResult OpRuleManager::getMinusEqualResultType(ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, size_t opIdx) { | |
| 192 | // Check is there is an overloaded operator function available | ||
| 193 |
1/2✓ Branch 2 → 3 taken 48 times.
✗ Branch 2 → 24 not taken.
|
48 | const ExprResult resultType = isOperatorOverloadingFctAvailable<2>(node, OP_FCT_MINUS_EQUAL, {lhs, rhs}, opIdx); |
| 194 |
3/4✓ Branch 3 → 4 taken 48 times.
✗ Branch 3 → 26 not taken.
✓ Branch 4 → 5 taken 7 times.
✓ Branch 4 → 6 taken 41 times.
|
48 | if (!resultType.type.is(TY_INVALID)) |
| 195 | 7 | return resultType; | |
| 196 | |||
| 197 | // Check if we try to assign a constant value | ||
| 198 |
1/2✓ Branch 6 → 7 taken 41 times.
✗ Branch 6 → 26 not taken.
|
41 | ensureNoConstAssign(node, lhs.type); |
| 199 | |||
| 200 | // Remove reference wrappers | ||
| 201 |
1/2✓ Branch 7 → 8 taken 41 times.
✗ Branch 7 → 26 not taken.
|
41 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 202 |
1/2✓ Branch 8 → 9 taken 41 times.
✗ Branch 8 → 26 not taken.
|
41 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 203 | |||
| 204 | // Check if this is an unsafe operation | ||
| 205 |
7/10✓ Branch 9 → 10 taken 41 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 5 times.
✓ Branch 10 → 14 taken 36 times.
✓ Branch 11 → 12 taken 5 times.
✗ Branch 11 → 25 not taken.
✓ Branch 12 → 13 taken 5 times.
✗ Branch 12 → 14 not taken.
✓ Branch 15 → 16 taken 5 times.
✓ Branch 15 → 18 taken 36 times.
|
41 | if (lhsType.isPtr() && rhsType.isOneOf({TY_INT, TY_LONG, TY_SHORT})) { |
| 206 |
1/2✓ Branch 16 → 17 taken 5 times.
✗ Branch 16 → 26 not taken.
|
5 | ensureUnsafeAllowed(node, "-=", lhsType, rhsType); |
| 207 | 5 | return {lhs}; | |
| 208 | } | ||
| 209 | |||
| 210 |
1/2✓ Branch 20 → 21 taken 36 times.
✗ Branch 20 → 26 not taken.
|
36 | return {validateBinaryOperation(node, MINUS_EQUAL_OP_RULES, std::size(MINUS_EQUAL_OP_RULES), "-=", lhsType, rhsType)}; |
| 211 | } | ||
| 212 | |||
| 213 | 50 | ExprResult OpRuleManager::getMulEqualResultType(ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, size_t opIdx) { | |
| 214 | // Check is there is an overloaded operator function available | ||
| 215 |
1/2✓ Branch 2 → 3 taken 50 times.
✗ Branch 2 → 15 not taken.
|
50 | const ExprResult resultType = isOperatorOverloadingFctAvailable<2>(node, OP_FCT_MUL_EQUAL, {lhs, rhs}, opIdx); |
| 216 |
3/4✓ Branch 3 → 4 taken 50 times.
✗ Branch 3 → 16 not taken.
✓ Branch 4 → 5 taken 2 times.
✓ Branch 4 → 6 taken 48 times.
|
50 | if (!resultType.type.is(TY_INVALID)) |
| 217 | 2 | return resultType; | |
| 218 | |||
| 219 | // Check if we try to assign a constant value | ||
| 220 |
1/2✓ Branch 6 → 7 taken 48 times.
✗ Branch 6 → 16 not taken.
|
48 | ensureNoConstAssign(node, lhs.type); |
| 221 | |||
| 222 | // Remove reference wrappers | ||
| 223 |
1/2✓ Branch 7 → 8 taken 48 times.
✗ Branch 7 → 16 not taken.
|
48 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 224 |
1/2✓ Branch 8 → 9 taken 48 times.
✗ Branch 8 → 16 not taken.
|
48 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 225 | |||
| 226 |
1/2✓ Branch 11 → 12 taken 48 times.
✗ Branch 11 → 16 not taken.
|
48 | return {validateBinaryOperation(node, MUL_EQUAL_OP_RULES, std::size(MUL_EQUAL_OP_RULES), "*=", lhsType, rhsType)}; |
| 227 | } | ||
| 228 | |||
| 229 | 55 | ExprResult OpRuleManager::getDivEqualResultType(ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, size_t opIdx) { | |
| 230 | // Check is there is an overloaded operator function available | ||
| 231 |
1/2✓ Branch 2 → 3 taken 55 times.
✗ Branch 2 → 15 not taken.
|
55 | const ExprResult resultType = isOperatorOverloadingFctAvailable<2>(node, OP_FCT_DIV_EQUAL, {lhs, rhs}, opIdx); |
| 232 |
3/4✓ Branch 3 → 4 taken 55 times.
✗ Branch 3 → 16 not taken.
✓ Branch 4 → 5 taken 37 times.
✓ Branch 4 → 6 taken 18 times.
|
55 | if (!resultType.type.is(TY_INVALID)) |
| 233 | 37 | return resultType; | |
| 234 | |||
| 235 | // Check if we try to assign a constant value | ||
| 236 |
1/2✓ Branch 6 → 7 taken 18 times.
✗ Branch 6 → 16 not taken.
|
18 | ensureNoConstAssign(node, lhs.type); |
| 237 | |||
| 238 | // Remove reference wrappers | ||
| 239 |
1/2✓ Branch 7 → 8 taken 18 times.
✗ Branch 7 → 16 not taken.
|
18 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 240 |
1/2✓ Branch 8 → 9 taken 18 times.
✗ Branch 8 → 16 not taken.
|
18 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 241 | |||
| 242 |
1/2✓ Branch 11 → 12 taken 18 times.
✗ Branch 11 → 16 not taken.
|
18 | return {validateBinaryOperation(node, DIV_EQUAL_OP_RULES, std::size(DIV_EQUAL_OP_RULES), "/=", lhsType, rhsType)}; |
| 243 | } | ||
| 244 | |||
| 245 | 17 | QualType OpRuleManager::getRemEqualResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) const { | |
| 246 | // Check if we try to assign a constant value | ||
| 247 |
1/2✓ Branch 2 → 3 taken 17 times.
✗ Branch 2 → 11 not taken.
|
17 | ensureNoConstAssign(node, lhs.type); |
| 248 | |||
| 249 | // Remove reference wrappers | ||
| 250 |
1/2✓ Branch 3 → 4 taken 17 times.
✗ Branch 3 → 11 not taken.
|
17 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 251 |
1/2✓ Branch 4 → 5 taken 17 times.
✗ Branch 4 → 11 not taken.
|
17 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 252 | |||
| 253 |
1/2✓ Branch 7 → 8 taken 17 times.
✗ Branch 7 → 11 not taken.
|
34 | return validateBinaryOperation(node, REM_EQUAL_OP_RULES, std::size(REM_EQUAL_OP_RULES), "%=", lhsType, rhsType); |
| 254 | } | ||
| 255 | |||
| 256 | 12 | QualType OpRuleManager::getSHLEqualResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) const { | |
| 257 | // Check if we try to assign a constant value | ||
| 258 |
1/2✓ Branch 2 → 3 taken 12 times.
✗ Branch 2 → 11 not taken.
|
12 | ensureNoConstAssign(node, lhs.type); |
| 259 | |||
| 260 | // Remove reference wrappers | ||
| 261 |
1/2✓ Branch 3 → 4 taken 12 times.
✗ Branch 3 → 11 not taken.
|
12 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 262 |
1/2✓ Branch 4 → 5 taken 12 times.
✗ Branch 4 → 11 not taken.
|
12 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 263 | |||
| 264 |
1/2✓ Branch 7 → 8 taken 12 times.
✗ Branch 7 → 11 not taken.
|
24 | return validateBinaryOperation(node, SHL_EQUAL_OP_RULES, std::size(SHL_EQUAL_OP_RULES), "<<=", lhsType, rhsType); |
| 265 | } | ||
| 266 | |||
| 267 | 13 | QualType OpRuleManager::getSHREqualResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) const { | |
| 268 | // Check if we try to assign a constant value | ||
| 269 |
1/2✓ Branch 2 → 3 taken 13 times.
✗ Branch 2 → 11 not taken.
|
13 | ensureNoConstAssign(node, lhs.type); |
| 270 | |||
| 271 | // Remove reference wrappers | ||
| 272 |
1/2✓ Branch 3 → 4 taken 13 times.
✗ Branch 3 → 11 not taken.
|
13 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 273 |
1/2✓ Branch 4 → 5 taken 13 times.
✗ Branch 4 → 11 not taken.
|
13 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 274 | |||
| 275 |
1/2✓ Branch 7 → 8 taken 13 times.
✗ Branch 7 → 11 not taken.
|
26 | return validateBinaryOperation(node, SHR_EQUAL_OP_RULES, std::size(SHR_EQUAL_OP_RULES), ">>=", lhsType, rhsType); |
| 276 | } | ||
| 277 | |||
| 278 | 11 | QualType OpRuleManager::getAndEqualResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) const { | |
| 279 | // Check if we try to assign a constant value | ||
| 280 |
1/2✓ Branch 2 → 3 taken 11 times.
✗ Branch 2 → 11 not taken.
|
11 | ensureNoConstAssign(node, lhs.type); |
| 281 | |||
| 282 | // Remove reference wrappers | ||
| 283 |
1/2✓ Branch 3 → 4 taken 11 times.
✗ Branch 3 → 11 not taken.
|
11 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 284 |
1/2✓ Branch 4 → 5 taken 11 times.
✗ Branch 4 → 11 not taken.
|
11 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 285 | |||
| 286 |
1/2✓ Branch 7 → 8 taken 11 times.
✗ Branch 7 → 11 not taken.
|
22 | return validateBinaryOperation(node, AND_EQUAL_OP_RULES, std::size(AND_EQUAL_OP_RULES), "&=", lhsType, rhsType); |
| 287 | } | ||
| 288 | |||
| 289 | 11 | QualType OpRuleManager::getOrEqualResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) const { | |
| 290 | // Check if we try to assign a constant value | ||
| 291 |
1/2✓ Branch 2 → 3 taken 11 times.
✗ Branch 2 → 11 not taken.
|
11 | ensureNoConstAssign(node, lhs.type); |
| 292 | |||
| 293 | // Remove reference wrappers | ||
| 294 |
1/2✓ Branch 3 → 4 taken 11 times.
✗ Branch 3 → 11 not taken.
|
11 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 295 |
1/2✓ Branch 4 → 5 taken 11 times.
✗ Branch 4 → 11 not taken.
|
11 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 296 | |||
| 297 |
1/2✓ Branch 7 → 8 taken 11 times.
✗ Branch 7 → 11 not taken.
|
22 | return validateBinaryOperation(node, OR_EQUAL_OP_RULES, std::size(OR_EQUAL_OP_RULES), "|=", lhsType, rhsType); |
| 298 | } | ||
| 299 | |||
| 300 | 356 | QualType OpRuleManager::getXorEqualResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) const { | |
| 301 | // Check if we try to assign a constant value | ||
| 302 |
1/2✓ Branch 2 → 3 taken 356 times.
✗ Branch 2 → 11 not taken.
|
356 | ensureNoConstAssign(node, lhs.type); |
| 303 | |||
| 304 | // Remove reference wrappers | ||
| 305 |
1/2✓ Branch 3 → 4 taken 356 times.
✗ Branch 3 → 11 not taken.
|
356 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 306 |
1/2✓ Branch 4 → 5 taken 356 times.
✗ Branch 4 → 11 not taken.
|
356 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 307 | |||
| 308 |
1/2✓ Branch 7 → 8 taken 356 times.
✗ Branch 7 → 11 not taken.
|
712 | return validateBinaryOperation(node, XOR_EQUAL_OP_RULES, std::size(XOR_EQUAL_OP_RULES), "^=", lhsType, rhsType); |
| 309 | } | ||
| 310 | |||
| 311 | 1241 | QualType OpRuleManager::getLogicalOrResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) { | |
| 312 | // Remove reference wrappers | ||
| 313 |
1/2✓ Branch 2 → 3 taken 1241 times.
✗ Branch 2 → 10 not taken.
|
1241 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 314 |
1/2✓ Branch 3 → 4 taken 1241 times.
✗ Branch 3 → 10 not taken.
|
1241 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 315 | |||
| 316 |
2/2✓ Branch 6 → 7 taken 1240 times.
✓ Branch 6 → 10 taken 1 time.
|
2481 | return validateBinaryOperation(node, LOGICAL_OR_OP_RULES, std::size(LOGICAL_OR_OP_RULES), "||", lhsType, rhsType); |
| 317 | } | ||
| 318 | |||
| 319 | 221 | QualType OpRuleManager::getLogicalAndResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) { | |
| 320 | // Remove reference wrappers | ||
| 321 |
1/2✓ Branch 2 → 3 taken 221 times.
✗ Branch 2 → 10 not taken.
|
221 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 322 |
1/2✓ Branch 3 → 4 taken 221 times.
✗ Branch 3 → 10 not taken.
|
221 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 323 | |||
| 324 |
1/2✓ Branch 6 → 7 taken 221 times.
✗ Branch 6 → 10 not taken.
|
442 | return validateBinaryOperation(node, LOGICAL_AND_OP_RULES, std::size(LOGICAL_AND_OP_RULES), "&&", lhsType, rhsType); |
| 325 | } | ||
| 326 | |||
| 327 | 97 | QualType OpRuleManager::getBitwiseOrResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) { | |
| 328 | // Remove reference wrappers | ||
| 329 |
1/2✓ Branch 2 → 3 taken 97 times.
✗ Branch 2 → 10 not taken.
|
97 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 330 |
1/2✓ Branch 3 → 4 taken 97 times.
✗ Branch 3 → 10 not taken.
|
97 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 331 | |||
| 332 |
2/2✓ Branch 6 → 7 taken 96 times.
✓ Branch 6 → 10 taken 1 time.
|
193 | return validateBinaryOperation(node, BITWISE_OR_OP_RULES, std::size(BITWISE_OR_OP_RULES), "|", lhsType, rhsType); |
| 333 | } | ||
| 334 | |||
| 335 | 19 | QualType OpRuleManager::getBitwiseXorResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) { | |
| 336 | // Remove reference wrappers | ||
| 337 |
1/2✓ Branch 2 → 3 taken 19 times.
✗ Branch 2 → 10 not taken.
|
19 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 338 |
1/2✓ Branch 3 → 4 taken 19 times.
✗ Branch 3 → 10 not taken.
|
19 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 339 | |||
| 340 |
1/2✓ Branch 6 → 7 taken 19 times.
✗ Branch 6 → 10 not taken.
|
38 | return validateBinaryOperation(node, BITWISE_XOR_OP_RULES, std::size(BITWISE_XOR_OP_RULES), "^", lhsType, rhsType); |
| 341 | } | ||
| 342 | |||
| 343 | 51 | QualType OpRuleManager::getBitwiseAndResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) { | |
| 344 | // Remove reference wrappers | ||
| 345 |
1/2✓ Branch 2 → 3 taken 51 times.
✗ Branch 2 → 10 not taken.
|
51 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 346 |
1/2✓ Branch 3 → 4 taken 51 times.
✗ Branch 3 → 10 not taken.
|
51 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 347 | |||
| 348 |
1/2✓ Branch 6 → 7 taken 51 times.
✗ Branch 6 → 10 not taken.
|
102 | return validateBinaryOperation(node, BITWISE_AND_OP_RULES, std::size(BITWISE_AND_OP_RULES), "&", lhsType, rhsType); |
| 349 | } | ||
| 350 | |||
| 351 | 4358 | ExprResult OpRuleManager::getEqualResultType(ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, size_t opIdx) { | |
| 352 | // Check is there is an overloaded operator function available | ||
| 353 |
1/2✓ Branch 2 → 3 taken 4358 times.
✗ Branch 2 → 38 not taken.
|
4358 | const ExprResult resultType = isOperatorOverloadingFctAvailable<2>(node, OP_FCT_EQUAL, {lhs, rhs}, opIdx); |
| 354 |
3/4✓ Branch 3 → 4 taken 4358 times.
✗ Branch 3 → 39 not taken.
✓ Branch 4 → 5 taken 442 times.
✓ Branch 4 → 6 taken 3916 times.
|
4358 | if (!resultType.type.is(TY_INVALID)) |
| 355 | 442 | return resultType; | |
| 356 | |||
| 357 | // Remove reference wrappers | ||
| 358 |
1/2✓ Branch 6 → 7 taken 3916 times.
✗ Branch 6 → 39 not taken.
|
3916 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 359 |
1/2✓ Branch 7 → 8 taken 3916 times.
✗ Branch 7 → 39 not taken.
|
3916 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 360 | |||
| 361 | // Allow 'pointer == unsigned long' straight away | ||
| 362 |
10/14✓ Branch 8 → 9 taken 3916 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 983 times.
✓ Branch 9 → 15 taken 2933 times.
✓ Branch 10 → 11 taken 983 times.
✗ Branch 10 → 39 not taken.
✓ Branch 11 → 12 taken 1 time.
✓ Branch 11 → 15 taken 982 times.
✓ Branch 12 → 13 taken 1 time.
✗ Branch 12 → 39 not taken.
✓ Branch 13 → 14 taken 1 time.
✗ Branch 13 → 15 not taken.
✓ Branch 16 → 17 taken 1 time.
✓ Branch 16 → 19 taken 3915 times.
|
3916 | if (lhsType.isPtr() && rhsType.is(TY_LONG) && rhsType.isUnsigned()) |
| 363 |
1/2✓ Branch 17 → 18 taken 1 time.
✗ Branch 17 → 39 not taken.
|
1 | return ExprResult(QualType(TY_BOOL)); |
| 364 | |||
| 365 | // Allow 'string == char*' and vice versa straight away | ||
| 366 |
11/18✓ Branch 19 → 20 taken 3915 times.
✗ Branch 19 → 39 not taken.
✓ Branch 20 → 21 taken 155 times.
✓ Branch 20 → 23 taken 3760 times.
✓ Branch 21 → 22 taken 155 times.
✗ Branch 21 → 39 not taken.
✓ Branch 22 → 23 taken 155 times.
✗ Branch 22 → 27 not taken.
✓ Branch 23 → 24 taken 3915 times.
✗ Branch 23 → 39 not taken.
✓ Branch 24 → 25 taken 564 times.
✓ Branch 24 → 28 taken 3351 times.
✓ Branch 25 → 26 taken 564 times.
✗ Branch 25 → 39 not taken.
✗ Branch 26 → 27 not taken.
✓ Branch 26 → 28 taken 564 times.
✗ Branch 29 → 30 not taken.
✓ Branch 29 → 32 taken 3915 times.
|
3915 | if ((lhsType.is(TY_STRING) && rhsType.isPtrTo(TY_CHAR)) || (lhsType.isPtrTo(TY_CHAR) && rhsType.is(TY_STRING))) |
| 367 | ✗ | return ExprResult(QualType(TY_BOOL)); | |
| 368 | |||
| 369 | // Check primitive type combinations | ||
| 370 |
2/2✓ Branch 34 → 35 taken 3914 times.
✓ Branch 34 → 39 taken 1 time.
|
3915 | return ExprResult(validateBinaryOperation(node, EQUAL_OP_RULES, std::size(EQUAL_OP_RULES), "==", lhsType, rhsType)); |
| 371 | } | ||
| 372 | |||
| 373 | 1622 | ExprResult OpRuleManager::getNotEqualResultType(ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, size_t opIdx) { | |
| 374 | // Check is there is an overloaded operator function available | ||
| 375 |
1/2✓ Branch 2 → 3 taken 1622 times.
✗ Branch 2 → 38 not taken.
|
1622 | const ExprResult resultType = isOperatorOverloadingFctAvailable<2>(node, OP_FCT_NOT_EQUAL, {lhs, rhs}, opIdx); |
| 376 |
3/4✓ Branch 3 → 4 taken 1622 times.
✗ Branch 3 → 39 not taken.
✓ Branch 4 → 5 taken 11 times.
✓ Branch 4 → 6 taken 1611 times.
|
1622 | if (!resultType.type.is(TY_INVALID)) |
| 377 | 11 | return resultType; | |
| 378 | |||
| 379 | // Remove reference wrappers | ||
| 380 |
1/2✓ Branch 6 → 7 taken 1611 times.
✗ Branch 6 → 39 not taken.
|
1611 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 381 |
1/2✓ Branch 7 → 8 taken 1611 times.
✗ Branch 7 → 39 not taken.
|
1611 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 382 | |||
| 383 | // Allow 'pointer != unsigned long' straight away | ||
| 384 |
10/14✓ Branch 8 → 9 taken 1611 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 231 times.
✓ Branch 9 → 15 taken 1380 times.
✓ Branch 10 → 11 taken 231 times.
✗ Branch 10 → 39 not taken.
✓ Branch 11 → 12 taken 1 time.
✓ Branch 11 → 15 taken 230 times.
✓ Branch 12 → 13 taken 1 time.
✗ Branch 12 → 39 not taken.
✓ Branch 13 → 14 taken 1 time.
✗ Branch 13 → 15 not taken.
✓ Branch 16 → 17 taken 1 time.
✓ Branch 16 → 19 taken 1610 times.
|
1611 | if (lhsType.isPtr() && rhsType.is(TY_LONG) && rhsType.isUnsigned()) |
| 385 |
1/2✓ Branch 17 → 18 taken 1 time.
✗ Branch 17 → 39 not taken.
|
1 | return ExprResult(QualType(TY_BOOL)); |
| 386 | |||
| 387 | // Allow 'string != char*' and vice versa straight away | ||
| 388 |
12/18✓ Branch 19 → 20 taken 1610 times.
✗ Branch 19 → 39 not taken.
✓ Branch 20 → 21 taken 10 times.
✓ Branch 20 → 23 taken 1600 times.
✓ Branch 21 → 22 taken 10 times.
✗ Branch 21 → 39 not taken.
✓ Branch 22 → 23 taken 10 times.
✗ Branch 22 → 27 not taken.
✓ Branch 23 → 24 taken 1610 times.
✗ Branch 23 → 39 not taken.
✓ Branch 24 → 25 taken 7 times.
✓ Branch 24 → 28 taken 1603 times.
✓ Branch 25 → 26 taken 7 times.
✗ Branch 25 → 39 not taken.
✓ Branch 26 → 27 taken 7 times.
✗ Branch 26 → 28 not taken.
✓ Branch 29 → 30 taken 7 times.
✓ Branch 29 → 32 taken 1603 times.
|
1610 | if ((lhsType.is(TY_STRING) && rhsType.isPtrTo(TY_CHAR)) || (lhsType.isPtrTo(TY_CHAR) && rhsType.is(TY_STRING))) |
| 389 |
1/2✓ Branch 30 → 31 taken 7 times.
✗ Branch 30 → 39 not taken.
|
7 | return ExprResult(QualType(TY_BOOL)); |
| 390 | |||
| 391 | // Check primitive type combinations | ||
| 392 |
1/2✓ Branch 34 → 35 taken 1603 times.
✗ Branch 34 → 39 not taken.
|
1603 | return ExprResult(validateBinaryOperation(node, NOT_EQUAL_OP_RULES, std::size(NOT_EQUAL_OP_RULES), "!=", lhsType, rhsType)); |
| 393 | } | ||
| 394 | |||
| 395 | 1978 | QualType OpRuleManager::getLessResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) { | |
| 396 | // Remove reference wrappers | ||
| 397 |
1/2✓ Branch 2 → 3 taken 1978 times.
✗ Branch 2 → 10 not taken.
|
1978 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 398 |
1/2✓ Branch 3 → 4 taken 1978 times.
✗ Branch 3 → 10 not taken.
|
1978 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 399 | |||
| 400 |
1/2✓ Branch 6 → 7 taken 1978 times.
✗ Branch 6 → 10 not taken.
|
3956 | return validateBinaryOperation(node, LESS_OP_RULES, std::size(LESS_OP_RULES), "<", lhsType, rhsType); |
| 401 | } | ||
| 402 | |||
| 403 | 564 | QualType OpRuleManager::getGreaterResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) { | |
| 404 | // Remove reference wrappers | ||
| 405 |
1/2✓ Branch 2 → 3 taken 564 times.
✗ Branch 2 → 10 not taken.
|
564 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 406 |
1/2✓ Branch 3 → 4 taken 564 times.
✗ Branch 3 → 10 not taken.
|
564 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 407 | |||
| 408 |
2/2✓ Branch 6 → 7 taken 563 times.
✓ Branch 6 → 10 taken 1 time.
|
1127 | return validateBinaryOperation(node, GREATER_OP_RULES, std::size(GREATER_OP_RULES), ">", lhsType, rhsType); |
| 409 | } | ||
| 410 | |||
| 411 | 424 | QualType OpRuleManager::getLessEqualResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) { | |
| 412 | // Remove reference wrappers | ||
| 413 |
1/2✓ Branch 2 → 3 taken 424 times.
✗ Branch 2 → 10 not taken.
|
424 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 414 |
1/2✓ Branch 3 → 4 taken 424 times.
✗ Branch 3 → 10 not taken.
|
424 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 415 | |||
| 416 |
1/2✓ Branch 6 → 7 taken 424 times.
✗ Branch 6 → 10 not taken.
|
848 | return validateBinaryOperation(node, LESS_EQUAL_OP_RULES, std::size(LESS_EQUAL_OP_RULES), "<=", lhsType, rhsType); |
| 417 | } | ||
| 418 | |||
| 419 | 1056 | QualType OpRuleManager::getGreaterEqualResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) { | |
| 420 | // Remove reference wrappers | ||
| 421 |
1/2✓ Branch 2 → 3 taken 1056 times.
✗ Branch 2 → 21 not taken.
|
1056 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 422 |
1/2✓ Branch 3 → 4 taken 1056 times.
✗ Branch 3 → 21 not taken.
|
1056 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 423 | |||
| 424 | // Allow 'pointer == pointer' straight away | ||
| 425 |
7/10✓ Branch 4 → 5 taken 1056 times.
✗ Branch 4 → 21 not taken.
✓ Branch 5 → 6 taken 4 times.
✓ Branch 5 → 9 taken 1052 times.
✓ Branch 6 → 7 taken 4 times.
✗ Branch 6 → 21 not taken.
✓ Branch 7 → 8 taken 4 times.
✗ Branch 7 → 9 not taken.
✓ Branch 10 → 11 taken 4 times.
✓ Branch 10 → 14 taken 1052 times.
|
1056 | if (lhsType.isPtr() && rhsType.isPtr()) |
| 426 |
1/2✓ Branch 11 → 12 taken 4 times.
✗ Branch 11 → 20 not taken.
|
4 | return QualType(TY_BOOL); |
| 427 | |||
| 428 |
1/2✓ Branch 16 → 17 taken 1052 times.
✗ Branch 16 → 21 not taken.
|
1052 | return validateBinaryOperation(node, GREATER_EQUAL_OP_RULES, std::size(GREATER_EQUAL_OP_RULES), ">=", lhsType, rhsType); |
| 429 | } | ||
| 430 | |||
| 431 | 110 | ExprResult OpRuleManager::getShiftLeftResultType(ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, size_t opIdx) { | |
| 432 | // Check is there is an overloaded operator function available | ||
| 433 |
1/2✓ Branch 2 → 3 taken 110 times.
✗ Branch 2 → 14 not taken.
|
110 | const ExprResult resultType = isOperatorOverloadingFctAvailable<2>(node, OP_FCT_SHL, {lhs, rhs}, opIdx); |
| 434 |
3/4✓ Branch 3 → 4 taken 110 times.
✗ Branch 3 → 15 not taken.
✓ Branch 4 → 5 taken 85 times.
✓ Branch 4 → 6 taken 25 times.
|
110 | if (!resultType.type.is(TY_INVALID)) |
| 435 | 85 | return resultType; | |
| 436 | |||
| 437 | // Remove reference wrappers | ||
| 438 |
1/2✓ Branch 6 → 7 taken 25 times.
✗ Branch 6 → 15 not taken.
|
25 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 439 |
1/2✓ Branch 7 → 8 taken 25 times.
✗ Branch 7 → 15 not taken.
|
25 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 440 | |||
| 441 |
1/2✓ Branch 10 → 11 taken 25 times.
✗ Branch 10 → 15 not taken.
|
25 | return {validateBinaryOperation(node, SHIFT_LEFT_OP_RULES, std::size(SHIFT_LEFT_OP_RULES), "<<", lhsType, rhsType)}; |
| 442 | } | ||
| 443 | |||
| 444 | 69 | ExprResult OpRuleManager::getShiftRightResultType(ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, size_t opIdx) { | |
| 445 | // Check is there is an overloaded operator function available | ||
| 446 |
1/2✓ Branch 2 → 3 taken 69 times.
✗ Branch 2 → 14 not taken.
|
69 | const ExprResult resultType = isOperatorOverloadingFctAvailable<2>(node, OP_FCT_SHR, {lhs, rhs}, opIdx); |
| 447 |
3/4✓ Branch 3 → 4 taken 69 times.
✗ Branch 3 → 15 not taken.
✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 6 taken 68 times.
|
69 | if (!resultType.type.is(TY_INVALID)) |
| 448 | 1 | return resultType; | |
| 449 | |||
| 450 | // Remove reference wrappers | ||
| 451 |
1/2✓ Branch 6 → 7 taken 68 times.
✗ Branch 6 → 15 not taken.
|
68 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 452 |
1/2✓ Branch 7 → 8 taken 68 times.
✗ Branch 7 → 15 not taken.
|
68 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 453 | |||
| 454 |
1/2✓ Branch 10 → 11 taken 68 times.
✗ Branch 10 → 15 not taken.
|
68 | return {validateBinaryOperation(node, SHIFT_RIGHT_OP_RULES, std::size(SHIFT_RIGHT_OP_RULES), ">>", lhsType, rhsType)}; |
| 455 | } | ||
| 456 | |||
| 457 | 3102 | ExprResult OpRuleManager::getPlusResultType(ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, size_t opIdx) { | |
| 458 | // Check is there is an overloaded operator function available | ||
| 459 |
1/2✓ Branch 2 → 3 taken 3102 times.
✗ Branch 2 → 32 not taken.
|
3102 | const ExprResult result = isOperatorOverloadingFctAvailable<2>(node, OP_FCT_PLUS, {lhs, rhs}, opIdx); |
| 460 |
3/4✓ Branch 3 → 4 taken 3102 times.
✗ Branch 3 → 35 not taken.
✓ Branch 4 → 5 taken 70 times.
✓ Branch 4 → 6 taken 3032 times.
|
3102 | if (!result.type.is(TY_INVALID)) |
| 461 | 70 | return result; | |
| 462 | |||
| 463 | // Remove reference wrappers | ||
| 464 |
1/2✓ Branch 6 → 7 taken 3032 times.
✗ Branch 6 → 35 not taken.
|
3032 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 465 |
1/2✓ Branch 7 → 8 taken 3032 times.
✗ Branch 7 → 35 not taken.
|
3032 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 466 | |||
| 467 | // Allow any* + <int/long/short> | ||
| 468 |
7/10✓ Branch 8 → 9 taken 3032 times.
✗ Branch 8 → 33 not taken.
✓ Branch 9 → 10 taken 567 times.
✓ Branch 9 → 13 taken 2465 times.
✓ Branch 10 → 11 taken 567 times.
✗ Branch 10 → 33 not taken.
✓ Branch 11 → 12 taken 567 times.
✗ Branch 11 → 13 not taken.
✓ Branch 14 → 15 taken 567 times.
✓ Branch 14 → 17 taken 2465 times.
|
3032 | if (lhsType.isPtr() && rhsType.isOneOf({TY_INT, TY_LONG, TY_SHORT})) { |
| 469 |
1/2✓ Branch 15 → 16 taken 567 times.
✗ Branch 15 → 35 not taken.
|
567 | ensureUnsafeAllowed(node, "+", lhsType, rhsType); |
| 470 | 567 | return {lhsType}; | |
| 471 | } | ||
| 472 | // Allow <int/long/short> + any* | ||
| 473 |
6/10✓ Branch 17 → 18 taken 2465 times.
✗ Branch 17 → 34 not taken.
✓ Branch 18 → 19 taken 2353 times.
✓ Branch 18 → 22 taken 112 times.
✓ Branch 19 → 20 taken 2353 times.
✗ Branch 19 → 34 not taken.
✗ Branch 20 → 21 not taken.
✓ Branch 20 → 22 taken 2353 times.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 26 taken 2465 times.
|
2465 | if (lhsType.isOneOf({TY_INT, TY_LONG, TY_SHORT}) && rhsType.isPtr()) { |
| 474 | ✗ | ensureUnsafeAllowed(node, "+", lhsType, rhsType); | |
| 475 | ✗ | return {rhsType}; | |
| 476 | } | ||
| 477 | |||
| 478 |
2/2✓ Branch 28 → 29 taken 2464 times.
✓ Branch 28 → 35 taken 1 time.
|
2465 | return {validateBinaryOperation(node, PLUS_OP_RULES, std::size(PLUS_OP_RULES), "+", lhsType, rhsType)}; |
| 479 | } | ||
| 480 | |||
| 481 | 1976 | ExprResult OpRuleManager::getMinusResultType(ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, size_t opIdx) { | |
| 482 | // Check is there is an overloaded operator function available | ||
| 483 |
1/2✓ Branch 2 → 3 taken 1976 times.
✗ Branch 2 → 32 not taken.
|
1976 | const ExprResult resultType = isOperatorOverloadingFctAvailable<2>(node, OP_FCT_MINUS, {lhs, rhs}, opIdx); |
| 484 |
3/4✓ Branch 3 → 4 taken 1976 times.
✗ Branch 3 → 35 not taken.
✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 6 taken 1975 times.
|
1976 | if (!resultType.type.is(TY_INVALID)) |
| 485 | 1 | return resultType; | |
| 486 | |||
| 487 | // Remove reference wrappers | ||
| 488 |
1/2✓ Branch 6 → 7 taken 1975 times.
✗ Branch 6 → 35 not taken.
|
1975 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 489 |
1/2✓ Branch 7 → 8 taken 1975 times.
✗ Branch 7 → 35 not taken.
|
1975 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 490 | |||
| 491 | // Allow any* - <int/long/short> | ||
| 492 |
7/10✓ Branch 8 → 9 taken 1975 times.
✗ Branch 8 → 33 not taken.
✓ Branch 9 → 10 taken 3 times.
✓ Branch 9 → 13 taken 1972 times.
✓ Branch 10 → 11 taken 3 times.
✗ Branch 10 → 33 not taken.
✓ Branch 11 → 12 taken 3 times.
✗ Branch 11 → 13 not taken.
✓ Branch 14 → 15 taken 3 times.
✓ Branch 14 → 17 taken 1972 times.
|
1975 | if (lhsType.isPtr() && rhsType.isOneOf({TY_INT, TY_LONG, TY_SHORT})) { |
| 493 |
1/2✓ Branch 15 → 16 taken 3 times.
✗ Branch 15 → 35 not taken.
|
3 | ensureUnsafeAllowed(node, "-", lhsType, rhsType); |
| 494 | 3 | return {lhs}; | |
| 495 | } | ||
| 496 | // Allow <int/long/short> - any* | ||
| 497 |
6/10✓ Branch 17 → 18 taken 1972 times.
✗ Branch 17 → 34 not taken.
✓ Branch 18 → 19 taken 1959 times.
✓ Branch 18 → 22 taken 13 times.
✓ Branch 19 → 20 taken 1959 times.
✗ Branch 19 → 34 not taken.
✗ Branch 20 → 21 not taken.
✓ Branch 20 → 22 taken 1959 times.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 26 taken 1972 times.
|
1972 | if (lhsType.isOneOf({TY_INT, TY_LONG, TY_SHORT}) && rhsType.isPtr()) { |
| 498 | ✗ | ensureUnsafeAllowed(node, "-", lhsType, rhsType); | |
| 499 | ✗ | return {rhs}; | |
| 500 | } | ||
| 501 | |||
| 502 |
1/2✓ Branch 28 → 29 taken 1972 times.
✗ Branch 28 → 35 not taken.
|
1972 | return {validateBinaryOperation(node, MINUS_OP_RULES, std::size(MINUS_OP_RULES), "-", lhsType, rhsType)}; |
| 503 | } | ||
| 504 | |||
| 505 | 816 | ExprResult OpRuleManager::getMulResultType(ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, size_t opIdx) { | |
| 506 | // Check is there is an overloaded operator function available | ||
| 507 |
1/2✓ Branch 2 → 3 taken 816 times.
✗ Branch 2 → 14 not taken.
|
816 | const ExprResult resultType = isOperatorOverloadingFctAvailable<2>(node, OP_FCT_MUL, {lhs, rhs}, opIdx); |
| 508 |
3/4✓ Branch 3 → 4 taken 816 times.
✗ Branch 3 → 15 not taken.
✓ Branch 4 → 5 taken 9 times.
✓ Branch 4 → 6 taken 807 times.
|
816 | if (!resultType.type.is(TY_INVALID)) |
| 509 | 9 | return resultType; | |
| 510 | |||
| 511 | // Remove reference wrappers | ||
| 512 |
1/2✓ Branch 6 → 7 taken 807 times.
✗ Branch 6 → 15 not taken.
|
807 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 513 |
1/2✓ Branch 7 → 8 taken 807 times.
✗ Branch 7 → 15 not taken.
|
807 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 514 | |||
| 515 |
2/2✓ Branch 10 → 11 taken 806 times.
✓ Branch 10 → 15 taken 1 time.
|
807 | return {validateBinaryOperation(node, MUL_OP_RULES, std::size(MUL_OP_RULES), "*", lhsType, rhsType)}; |
| 516 | } | ||
| 517 | |||
| 518 | 162 | ExprResult OpRuleManager::getDivResultType(ASTNode *node, const ExprResult &lhs, const ExprResult &rhs, size_t opIdx) { | |
| 519 | // Check is there is an overloaded operator function available | ||
| 520 |
1/2✓ Branch 2 → 3 taken 162 times.
✗ Branch 2 → 14 not taken.
|
162 | const ExprResult resultType = isOperatorOverloadingFctAvailable<2>(node, OP_FCT_DIV, {lhs, rhs}, opIdx); |
| 521 |
3/4✓ Branch 3 → 4 taken 162 times.
✗ Branch 3 → 15 not taken.
✓ Branch 4 → 5 taken 3 times.
✓ Branch 4 → 6 taken 159 times.
|
162 | if (!resultType.type.is(TY_INVALID)) |
| 522 | 3 | return resultType; | |
| 523 | |||
| 524 | // Remove reference wrappers | ||
| 525 |
1/2✓ Branch 6 → 7 taken 159 times.
✗ Branch 6 → 15 not taken.
|
159 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 526 |
1/2✓ Branch 7 → 8 taken 159 times.
✗ Branch 7 → 15 not taken.
|
159 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 527 | |||
| 528 |
1/2✓ Branch 10 → 11 taken 159 times.
✗ Branch 10 → 15 not taken.
|
159 | return {validateBinaryOperation(node, DIV_OP_RULES, std::size(DIV_OP_RULES), "/", lhsType, rhsType)}; |
| 529 | } | ||
| 530 | |||
| 531 | 22 | ExprResult OpRuleManager::getRemResultType(const ASTNode *node, const ExprResult &lhs, const ExprResult &rhs) { | |
| 532 | // Remove reference wrappers | ||
| 533 |
1/2✓ Branch 2 → 3 taken 22 times.
✗ Branch 2 → 10 not taken.
|
22 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 534 |
1/2✓ Branch 3 → 4 taken 22 times.
✗ Branch 3 → 10 not taken.
|
22 | const QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 535 | |||
| 536 |
1/2✓ Branch 6 → 7 taken 22 times.
✗ Branch 6 → 10 not taken.
|
44 | return {validateBinaryOperation(node, REM_OP_RULES, std::size(REM_OP_RULES), "%", lhsType, rhsType)}; |
| 537 | } | ||
| 538 | |||
| 539 | 893 | QualType OpRuleManager::getPrefixMinusResultType(const ASTNode *node, const ExprResult &lhs) { | |
| 540 | // Remove reference wrappers | ||
| 541 |
1/2✓ Branch 2 → 3 taken 893 times.
✗ Branch 2 → 9 not taken.
|
893 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 542 | |||
| 543 |
1/2✓ Branch 5 → 6 taken 893 times.
✗ Branch 5 → 9 not taken.
|
1786 | return validateUnaryOperation(node, PREFIX_MINUS_OP_RULES, std::size(PREFIX_MINUS_OP_RULES), "-", lhsType); |
| 544 | } | ||
| 545 | |||
| 546 | 26 | QualType OpRuleManager::getPrefixPlusPlusResultType(const ASTNode *node, const ExprResult &lhs) const { | |
| 547 | // Check if we try to assign a constant value | ||
| 548 |
1/2✓ Branch 2 → 3 taken 26 times.
✗ Branch 2 → 14 not taken.
|
26 | ensureNoConstAssign(node, lhs.type); |
| 549 | |||
| 550 | // Remove reference wrappers | ||
| 551 |
1/2✓ Branch 3 → 4 taken 26 times.
✗ Branch 3 → 14 not taken.
|
26 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 552 | |||
| 553 | // Check if this is an unsafe operation | ||
| 554 |
2/4✓ Branch 4 → 5 taken 26 times.
✗ Branch 4 → 14 not taken.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 8 taken 26 times.
|
26 | if (lhsType.isPtr()) { |
| 555 | ✗ | ensureUnsafeAllowed(node, "++", lhsType); | |
| 556 | ✗ | return lhsType; | |
| 557 | } | ||
| 558 | |||
| 559 |
1/2✓ Branch 10 → 11 taken 26 times.
✗ Branch 10 → 14 not taken.
|
26 | return validateUnaryOperation(node, PREFIX_PLUS_PLUS_OP_RULES, std::size(PREFIX_PLUS_PLUS_OP_RULES), "++", lhsType); |
| 560 | } | ||
| 561 | |||
| 562 | 11 | QualType OpRuleManager::getPrefixMinusMinusResultType(const ASTNode *node, const ExprResult &lhs) const { | |
| 563 | // Check if we try to assign a constant value | ||
| 564 |
1/2✓ Branch 2 → 3 taken 11 times.
✗ Branch 2 → 14 not taken.
|
11 | ensureNoConstAssign(node, lhs.type); |
| 565 | |||
| 566 | // Remove reference wrappers | ||
| 567 |
1/2✓ Branch 3 → 4 taken 11 times.
✗ Branch 3 → 14 not taken.
|
11 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 568 | |||
| 569 | // Check if this is an unsafe operation | ||
| 570 |
2/4✓ Branch 4 → 5 taken 11 times.
✗ Branch 4 → 14 not taken.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 8 taken 11 times.
|
11 | if (lhsType.isPtr()) { |
| 571 | ✗ | ensureUnsafeAllowed(node, "--", lhsType); | |
| 572 | ✗ | return lhsType; | |
| 573 | } | ||
| 574 | |||
| 575 |
2/2✓ Branch 10 → 11 taken 10 times.
✓ Branch 10 → 14 taken 1 time.
|
11 | return validateUnaryOperation(node, PREFIX_MINUS_MINUS_OP_RULES, std::size(PREFIX_MINUS_MINUS_OP_RULES), "--", lhsType); |
| 576 | } | ||
| 577 | |||
| 578 | 777 | QualType OpRuleManager::getPrefixNotResultType(const ASTNode *node, const ExprResult &lhs) { | |
| 579 | // Remove reference wrappers | ||
| 580 |
1/2✓ Branch 2 → 3 taken 777 times.
✗ Branch 2 → 9 not taken.
|
777 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 581 | |||
| 582 |
1/2✓ Branch 5 → 6 taken 777 times.
✗ Branch 5 → 9 not taken.
|
1554 | return validateUnaryOperation(node, PREFIX_NOT_OP_RULES, std::size(PREFIX_NOT_OP_RULES), "!", lhsType); |
| 583 | } | ||
| 584 | |||
| 585 | 5 | QualType OpRuleManager::getPrefixBitwiseNotResultType(const ASTNode *node, const ExprResult &lhs) { | |
| 586 | // Remove reference wrappers | ||
| 587 |
1/2✓ Branch 2 → 3 taken 5 times.
✗ Branch 2 → 9 not taken.
|
5 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 588 | |||
| 589 |
1/2✓ Branch 5 → 6 taken 5 times.
✗ Branch 5 → 9 not taken.
|
10 | return validateUnaryOperation(node, PREFIX_BITWISE_NOT_OP_RULES, std::size(PREFIX_BITWISE_NOT_OP_RULES), "~", lhsType); |
| 590 | } | ||
| 591 | |||
| 592 | 234 | QualType OpRuleManager::getPrefixMulResultType(const ASTNode *node, const ExprResult &lhs) { | |
| 593 | // Remove reference wrappers | ||
| 594 |
1/2✓ Branch 2 → 3 taken 234 times.
✗ Branch 2 → 25 not taken.
|
234 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 595 | |||
| 596 |
3/4✓ Branch 3 → 4 taken 234 times.
✗ Branch 3 → 25 not taken.
✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 12 taken 233 times.
|
234 | if (!lhsType.isPtr()) |
| 597 |
3/6✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 21 not taken.
✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 19 not taken.
✓ Branch 8 → 9 taken 1 time.
✗ Branch 8 → 16 not taken.
|
1 | throw SemanticError(node, OPERATOR_WRONG_DATA_TYPE, "Cannot apply de-referencing operator on type " + lhsType.getName(true)); |
| 598 |
1/2✓ Branch 12 → 13 taken 233 times.
✗ Branch 12 → 25 not taken.
|
466 | return lhsType.getContained(); |
| 599 | } | ||
| 600 | |||
| 601 | 181 | QualType OpRuleManager::getPrefixBitwiseAndResultType(const ASTNode *node, const ExprResult &lhs) { | |
| 602 | // Remove reference wrappers | ||
| 603 |
1/2✓ Branch 2 → 3 taken 181 times.
✗ Branch 2 → 7 not taken.
|
181 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 604 | |||
| 605 |
1/2✓ Branch 3 → 4 taken 181 times.
✗ Branch 3 → 7 not taken.
|
362 | return lhsType.toPtr(node); |
| 606 | } | ||
| 607 | |||
| 608 | 1890 | ExprResult OpRuleManager::getPostfixPlusPlusResultType(ASTNode *node, const ExprResult &lhs, size_t opIdx) { | |
| 609 | // Check is there is an overloaded operator function available | ||
| 610 |
2/2✓ Branch 2 → 3 taken 1889 times.
✓ Branch 2 → 18 taken 1 time.
|
1890 | const ExprResult resultType = isOperatorOverloadingFctAvailable<1>(node, OP_FCT_POSTFIX_PLUS_PLUS, {lhs}, opIdx); |
| 611 |
3/4✓ Branch 3 → 4 taken 1889 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 9 times.
✓ Branch 4 → 6 taken 1880 times.
|
1889 | if (!resultType.type.is(TY_INVALID)) |
| 612 | 9 | return resultType; | |
| 613 | |||
| 614 | // Check if we try to assign a constant value | ||
| 615 |
1/2✓ Branch 6 → 7 taken 1880 times.
✗ Branch 6 → 19 not taken.
|
1880 | ensureNoConstAssign(node, lhs.type); |
| 616 | |||
| 617 | // Remove reference wrappers | ||
| 618 |
1/2✓ Branch 7 → 8 taken 1880 times.
✗ Branch 7 → 19 not taken.
|
1880 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 619 | |||
| 620 | // Check if this is an unsafe operation | ||
| 621 |
3/4✓ Branch 8 → 9 taken 1880 times.
✗ Branch 8 → 19 not taken.
✓ Branch 9 → 10 taken 9 times.
✓ Branch 9 → 12 taken 1871 times.
|
1880 | if (lhsType.isPtr()) { |
| 622 |
1/2✓ Branch 10 → 11 taken 9 times.
✗ Branch 10 → 19 not taken.
|
9 | ensureUnsafeAllowed(node, "++", lhsType); |
| 623 | 9 | return {lhs}; | |
| 624 | } | ||
| 625 | |||
| 626 |
2/2✓ Branch 14 → 15 taken 1870 times.
✓ Branch 14 → 19 taken 1 time.
|
1871 | return {validateUnaryOperation(node, POSTFIX_PLUS_PLUS_OP_RULES, std::size(POSTFIX_PLUS_PLUS_OP_RULES), "++", lhsType)}; |
| 627 | } | ||
| 628 | |||
| 629 | 435 | ExprResult OpRuleManager::getPostfixMinusMinusResultType(ASTNode *node, const ExprResult &lhs, size_t opIdx) { | |
| 630 | // Check is there is an overloaded operator function available | ||
| 631 |
1/2✓ Branch 2 → 3 taken 435 times.
✗ Branch 2 → 18 not taken.
|
435 | const ExprResult resultType = isOperatorOverloadingFctAvailable<1>(node, OP_FCT_POSTFIX_MINUS_MINUS, {lhs}, opIdx); |
| 632 |
3/4✓ Branch 3 → 4 taken 435 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 7 times.
✓ Branch 4 → 6 taken 428 times.
|
435 | if (!resultType.type.is(TY_INVALID)) |
| 633 | 7 | return resultType; | |
| 634 | |||
| 635 | // Check if we try to assign a constant value | ||
| 636 |
1/2✓ Branch 6 → 7 taken 428 times.
✗ Branch 6 → 19 not taken.
|
428 | ensureNoConstAssign(node, lhs.type); |
| 637 | |||
| 638 | // Remove reference wrappers | ||
| 639 |
1/2✓ Branch 7 → 8 taken 428 times.
✗ Branch 7 → 19 not taken.
|
428 | const QualType lhsType = lhs.type.removeReferenceWrapper(); |
| 640 | |||
| 641 | // Check if this is an unsafe operation | ||
| 642 |
3/4✓ Branch 8 → 9 taken 428 times.
✗ Branch 8 → 19 not taken.
✓ Branch 9 → 10 taken 2 times.
✓ Branch 9 → 12 taken 426 times.
|
428 | if (lhsType.isPtr()) { |
| 643 |
1/2✓ Branch 10 → 11 taken 2 times.
✗ Branch 10 → 19 not taken.
|
2 | ensureUnsafeAllowed(node, "--", lhsType); |
| 644 | 2 | return {lhs}; | |
| 645 | } | ||
| 646 | |||
| 647 |
1/2✓ Branch 14 → 15 taken 426 times.
✗ Branch 14 → 19 not taken.
|
426 | return {validateUnaryOperation(node, POSTFIX_MINUS_MINUS_OP_RULES, std::size(POSTFIX_MINUS_MINUS_OP_RULES), "--", lhsType)}; |
| 648 | } | ||
| 649 | |||
| 650 | 2701 | QualType OpRuleManager::getCastResultType(const ASTNode *node, QualType lhsType, const ExprResult &rhs) const { | |
| 651 | // Remove reference wrappers | ||
| 652 |
1/2✓ Branch 2 → 3 taken 2701 times.
✗ Branch 2 → 48 not taken.
|
2701 | lhsType = lhsType.removeReferenceWrapper(); |
| 653 |
1/2✓ Branch 3 → 4 taken 2701 times.
✗ Branch 3 → 55 not taken.
|
2701 | QualType rhsType = rhs.type.removeReferenceWrapper(); |
| 654 | |||
| 655 | // Only allow to cast the 'heap' qualifier away, if we are in unsafe mode | ||
| 656 |
2/2✓ Branch 6 → 7 taken 107 times.
✓ Branch 6 → 8 taken 2594 times.
|
2701 | if (lhsType.getQualifiers().isHeap != rhsType.getQualifiers().isHeap) |
| 657 |
1/2✓ Branch 7 → 8 taken 107 times.
✗ Branch 7 → 55 not taken.
|
107 | ensureUnsafeAllowed(node, "(cast)", lhsType, rhsType); |
| 658 | |||
| 659 | // Allow identity casts | ||
| 660 |
3/4✓ Branch 8 → 9 taken 2701 times.
✗ Branch 8 → 55 not taken.
✓ Branch 9 → 10 taken 271 times.
✓ Branch 9 → 11 taken 2430 times.
|
2701 | if (lhsType.matches(rhsType, false, true, true)) |
| 661 | 271 | return lhsType; | |
| 662 | // Allow casts string -> char* and string -> char[] | ||
| 663 |
12/16✓ Branch 11 → 12 taken 2430 times.
✗ Branch 11 → 49 not taken.
✓ Branch 12 → 13 taken 1188 times.
✓ Branch 12 → 19 taken 1242 times.
✓ Branch 13 → 14 taken 1188 times.
✗ Branch 13 → 49 not taken.
✓ Branch 14 → 15 taken 1188 times.
✗ Branch 14 → 49 not taken.
✓ Branch 15 → 16 taken 934 times.
✓ Branch 15 → 19 taken 254 times.
✓ Branch 16 → 17 taken 934 times.
✗ Branch 16 → 49 not taken.
✓ Branch 17 → 18 taken 930 times.
✓ Branch 17 → 19 taken 4 times.
✓ Branch 20 → 21 taken 930 times.
✓ Branch 20 → 22 taken 1500 times.
|
2430 | if (lhsType.isOneOf({TY_PTR, TY_ARRAY}) && lhsType.getContained().is(TY_CHAR) && rhsType.is(TY_STRING)) |
| 664 | 930 | return lhsType; | |
| 665 | // Allow casts char* -> string and char[] -> string | ||
| 666 |
10/16✓ Branch 22 → 23 taken 1500 times.
✗ Branch 22 → 51 not taken.
✓ Branch 23 → 24 taken 94 times.
✓ Branch 23 → 30 taken 1406 times.
✓ Branch 24 → 25 taken 94 times.
✗ Branch 24 → 51 not taken.
✓ Branch 25 → 26 taken 94 times.
✗ Branch 25 → 30 not taken.
✓ Branch 26 → 27 taken 94 times.
✗ Branch 26 → 51 not taken.
✓ Branch 27 → 28 taken 94 times.
✗ Branch 27 → 51 not taken.
✓ Branch 28 → 29 taken 94 times.
✗ Branch 28 → 30 not taken.
✓ Branch 31 → 32 taken 94 times.
✓ Branch 31 → 33 taken 1406 times.
|
1500 | if (lhsType.is(TY_STRING) && rhsType.isOneOf({TY_PTR, TY_ARRAY}) && rhsType.getContained().is(TY_CHAR)) |
| 667 | 94 | return lhsType; | |
| 668 | // Allow casts any* -> any* | ||
| 669 |
7/10✓ Branch 33 → 34 taken 1406 times.
✗ Branch 33 → 53 not taken.
✓ Branch 34 → 35 taken 258 times.
✓ Branch 34 → 38 taken 1148 times.
✓ Branch 35 → 36 taken 258 times.
✗ Branch 35 → 53 not taken.
✓ Branch 36 → 37 taken 258 times.
✗ Branch 36 → 38 not taken.
✓ Branch 39 → 40 taken 258 times.
✓ Branch 39 → 42 taken 1148 times.
|
1406 | if (lhsType.isOneOf({TY_PTR, TY_STRING}) && rhsType.isOneOf({TY_PTR, TY_STRING})) { |
| 670 |
1/2✓ Branch 40 → 41 taken 258 times.
✗ Branch 40 → 55 not taken.
|
258 | ensureUnsafeAllowed(node, "(cast)", lhsType, rhsType); |
| 671 | 258 | return lhsType; | |
| 672 | } | ||
| 673 | // Check primitive type combinations | ||
| 674 |
1/2✓ Branch 44 → 45 taken 1148 times.
✗ Branch 44 → 55 not taken.
|
1148 | return validateBinaryOperation(node, CAST_OP_RULES, std::size(CAST_OP_RULES), "(cast)", lhsType, rhsType, true); |
| 675 | } | ||
| 676 | |||
| 677 | template <size_t N> | ||
| 678 | 18505 | ExprResult OpRuleManager::isOperatorOverloadingFctAvailable(ASTNode *node, const char *const fctName, | |
| 679 | const std::array<ExprResult, N> &op, size_t opIdx) { | ||
| 680 | static_assert(N == 1 || N == 2, "Only unary and binary operators are overloadable"); | ||
| 681 | 18505 | Scope *calleeParentScope = nullptr; | |
| 682 | 18505 | const Function *callee = nullptr; | |
| 683 |
14/20spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✓ Branch 2 → 3 taken 2325 times.
✗ Branch 2 → 123 not taken.
✓ Branch 3 → 4 taken 2325 times.
✗ Branch 3 → 123 not taken.
✓ Branch 4 → 5 taken 2325 times.
✗ Branch 4 → 123 not taken.
✓ Branch 42 → 43 taken 2592 times.
✓ Branch 42 → 45 taken 17 times.
✓ Branch 48 → 6 taken 20209 times.
✓ Branch 48 → 49 taken 2308 times.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 2 → 3 taken 16180 times.
✗ Branch 2 → 132 not taken.
✓ Branch 3 → 4 taken 16180 times.
✗ Branch 3 → 132 not taken.
✓ Branch 4 → 5 taken 16180 times.
✗ Branch 4 → 132 not taken.
✓ Branch 49 → 50 taken 54193 times.
✓ Branch 49 → 52 taken 886 times.
✓ Branch 55 → 6 taken 133868 times.
✓ Branch 55 → 56 taken 15294 times.
|
229367 | for (const auto &sourceFile : typeChecker->resourceManager.sourceFiles | std::views::values) { |
| 684 | // Check if there is a registered operator function | ||
| 685 |
8/12spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✓ Branch 10 → 11 taken 20209 times.
✗ Branch 10 → 102 not taken.
✓ Branch 11 → 12 taken 20209 times.
✗ Branch 11 → 100 not taken.
✓ Branch 14 → 15 taken 17600 times.
✓ Branch 14 → 16 taken 2609 times.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 10 → 11 taken 133868 times.
✗ Branch 10 → 109 not taken.
✓ Branch 11 → 12 taken 133868 times.
✗ Branch 11 → 107 not taken.
✓ Branch 14 → 15 taken 78789 times.
✓ Branch 14 → 16 taken 55079 times.
|
462231 | if (!sourceFile->getNameRegistryEntry(fctName)) |
| 686 | 96389 | continue; | |
| 687 | |||
| 688 | // Match callees in the global scope of this source file | ||
| 689 | 57688 | calleeParentScope = sourceFile->globalScope.get(); | |
| 690 |
2/4spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✓ Branch 18 → 19 taken 2609 times.
✗ Branch 18 → 122 not taken.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 18 → 19 taken 55079 times.
✗ Branch 18 → 131 not taken.
|
57688 | const QualType thisType(TY_DYN); |
| 691 |
2/4spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✓ Branch 21 → 22 taken 2609 times.
✗ Branch 21 → 106 not taken.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 21 → 22 taken 55079 times.
✗ Branch 21 → 113 not taken.
|
57688 | ArgList args(N); |
| 692 |
2/4spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✓ Branch 24 → 25 taken 2609 times.
✗ Branch 24 → 109 not taken.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 24 → 25 taken 55079 times.
✗ Branch 24 → 116 not taken.
|
57688 | args[0] = {typeChecker->mapLocalTypeToImportedScopeType(calleeParentScope, op[0].type), op[0].isTemporary()}; |
| 693 | if constexpr (N == 2) | ||
| 694 |
1/2✓ Branch 31 → 32 taken 55079 times.
✗ Branch 31 → 118 not taken.
|
55079 | args[1] = {typeChecker->mapLocalTypeToImportedScopeType(calleeParentScope, op[1].type), op[1].isTemporary()}; |
| 695 |
4/8spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✓ Branch 33 → 34 taken 2609 times.
✗ Branch 33 → 113 not taken.
✓ Branch 34 → 35 taken 2609 times.
✗ Branch 34 → 111 not taken.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 40 → 41 taken 55079 times.
✗ Branch 40 → 122 not taken.
✓ Branch 41 → 42 taken 55079 times.
✗ Branch 41 → 120 not taken.
|
173064 | callee = FunctionManager::match(calleeParentScope, fctName, thisType, args, {}, false, node); |
| 696 |
4/4spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✓ Branch 38 → 39 taken 17 times.
✓ Branch 38 → 40 taken 2592 times.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 45 → 46 taken 886 times.
✓ Branch 45 → 47 taken 54193 times.
|
57688 | if (callee) |
| 697 | 903 | break; | |
| 698 | } | ||
| 699 | |||
| 700 | // Return invalid type if the callee was not found | ||
| 701 |
4/4spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✓ Branch 49 → 50 taken 2308 times.
✓ Branch 49 → 52 taken 17 times.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 56 → 57 taken 15294 times.
✓ Branch 56 → 59 taken 886 times.
|
18505 | if (!callee) |
| 702 | 17602 | return ExprResult(QualType(TY_INVALID)); | |
| 703 |
2/4spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✗ Branch 52 → 53 not taken.
✓ Branch 52 → 54 taken 17 times.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✗ Branch 59 → 60 not taken.
✓ Branch 59 → 61 taken 886 times.
|
903 | assert(calleeParentScope != nullptr); |
| 704 | |||
| 705 | // Save the pointer to the operator function in the AST node | ||
| 706 | 903 | std::vector<const Function *> &opFctPointers = typeChecker->getOpFctPointers(node); | |
| 707 |
3/4spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✗ Branch 56 → 57 not taken.
✓ Branch 56 → 59 taken 17 times.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 63 → 64 taken 74 times.
✓ Branch 63 → 66 taken 812 times.
|
903 | if (opFctPointers.size() <= opIdx) |
| 708 |
1/4spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✗ Branch 57 → 58 not taken.
✗ Branch 57 → 124 not taken.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 64 → 65 taken 74 times.
✗ Branch 64 → 133 not taken.
|
74 | opFctPointers.resize(opIdx + 1, nullptr); |
| 709 | 903 | opFctPointers.at(opIdx) = callee; | |
| 710 | |||
| 711 | // Check if we need to request a re-visit, because the function body was not type-checked yet | ||
| 712 | 903 | typeChecker->requestRevisitIfRequired(callee); | |
| 713 | |||
| 714 | // Check if the called function has sufficient visibility | ||
| 715 |
6/8spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✓ Branch 61 → 62 taken 17 times.
✗ Branch 61 → 65 not taken.
✓ Branch 63 → 64 taken 15 times.
✓ Branch 63 → 65 taken 2 times.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 68 → 69 taken 886 times.
✗ Branch 68 → 72 not taken.
✓ Branch 70 → 71 taken 394 times.
✓ Branch 70 → 72 taken 492 times.
|
903 | const bool isImported = calleeParentScope != nullptr && calleeParentScope->isImportedBy(typeChecker->rootScope); |
| 716 | 903 | const SymbolTableEntry *calleeEntry = callee->entry; | |
| 717 |
10/12spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✓ Branch 66 → 67 taken 15 times.
✓ Branch 66 → 71 taken 2 times.
✓ Branch 69 → 70 taken 1 time.
✓ Branch 69 → 71 taken 14 times.
✓ Branch 72 → 73 taken 1 time.
✓ Branch 72 → 82 taken 16 times.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 73 → 74 taken 394 times.
✓ Branch 73 → 78 taken 492 times.
✗ Branch 76 → 77 not taken.
✓ Branch 76 → 78 taken 394 times.
✗ Branch 79 → 80 not taken.
✓ Branch 79 → 89 taken 886 times.
|
903 | if (isImported && !calleeEntry->getQualType().isPublic()) |
| 718 |
1/4spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✓ Branch 77 → 78 taken 1 time.
✗ Branch 77 → 125 not taken.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✗ Branch 84 → 85 not taken.
✗ Branch 84 → 134 not taken.
|
2 | throw SemanticError(node, INSUFFICIENT_VISIBILITY, |
| 719 |
3/12spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✓ Branch 74 → 75 taken 1 time.
✗ Branch 74 → 132 not taken.
✓ Branch 75 → 76 taken 1 time.
✗ Branch 75 → 130 not taken.
✓ Branch 76 → 77 taken 1 time.
✗ Branch 76 → 128 not taken.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✗ Branch 81 → 82 not taken.
✗ Branch 81 → 141 not taken.
✗ Branch 82 → 83 not taken.
✗ Branch 82 → 139 not taken.
✗ Branch 83 → 84 not taken.
✗ Branch 83 → 137 not taken.
|
2 | "Overloaded operator '" + callee->getSignature() + "' has insufficient visibility"); |
| 720 | |||
| 721 | // Procedures always have the return type 'bool' | ||
| 722 |
4/4spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✓ Branch 85 → 86 taken 14 times.
✓ Branch 85 → 88 taken 2 times.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 92 → 93 taken 143 times.
✓ Branch 92 → 95 taken 743 times.
|
902 | if (callee->isProcedure()) |
| 723 | 157 | return ExprResult(QualType(TY_BOOL)); | |
| 724 | 745 | const QualType &returnType = callee->returnType; | |
| 725 | |||
| 726 | // Add anonymous symbol to keep track of dtor call, if non-trivially destructible | ||
| 727 | 745 | SymbolTableEntry *anonymousSymbol = nullptr; | |
| 728 |
8/12spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<1ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 1ul> const&, unsigned long):
✗ Branch 89 → 90 not taken.
✓ Branch 89 → 93 taken 2 times.
✗ Branch 91 → 92 not taken.
✗ Branch 91 → 93 not taken.
✗ Branch 94 → 95 not taken.
✓ Branch 94 → 97 taken 2 times.
spice::compiler::ExprResult spice::compiler::OpRuleManager::isOperatorOverloadingFctAvailable<2ul>(spice::compiler::ASTNode*, char const*, std::array<spice::compiler::ExprResult, 2ul> const&, unsigned long):
✓ Branch 96 → 97 taken 85 times.
✓ Branch 96 → 100 taken 658 times.
✓ Branch 98 → 99 taken 79 times.
✓ Branch 98 → 100 taken 6 times.
✓ Branch 101 → 102 taken 79 times.
✓ Branch 101 → 104 taken 664 times.
|
745 | if (returnType.is(TY_STRUCT) && !returnType.isTriviallyDestructible(node)) |
| 729 | 79 | anonymousSymbol = typeChecker->currentScope->symbolTable.insertAnonymous(returnType, node, opIdx); | |
| 730 | |||
| 731 | 745 | return {typeChecker->mapImportedScopeTypeToLocalType(calleeParentScope, returnType), anonymousSymbol}; | |
| 732 | } | ||
| 733 | |||
| 734 | 4009 | QualType OpRuleManager::validateUnaryOperation(const ASTNode *node, const UnaryOpRule opRules[], size_t opRulesSize, | |
| 735 | const char *name, const QualType &lhs) { | ||
| 736 |
2/2✓ Branch 11 → 3 taken 9782 times.
✓ Branch 11 → 12 taken 2 times.
|
9784 | for (size_t i = 0; i < opRulesSize; i++) { |
| 737 | 9782 | const UnaryOpRule &rule = opRules[i]; | |
| 738 |
2/2✓ Branch 5 → 6 taken 4007 times.
✓ Branch 5 → 10 taken 5775 times.
|
9782 | if (std::get<0>(rule) == lhs.getSuperType()) |
| 739 |
1/2✓ Branch 7 → 8 taken 4007 times.
✗ Branch 7 → 16 not taken.
|
4007 | return QualType(std::get<1>(rule)); |
| 740 | } | ||
| 741 |
1/2✓ Branch 13 → 14 taken 2 times.
✗ Branch 13 → 17 not taken.
|
2 | throw getExceptionUnary(node, name, lhs); |
| 742 | } | ||
| 743 | |||
| 744 | 38441 | QualType OpRuleManager::validateBinaryOperation(const ASTNode *node, const BinaryOpRule opRules[], size_t opRulesSize, | |
| 745 | const char *name, const QualType &lhs, const QualType &rhs, | ||
| 746 | bool preserveQualifiersFromLhs, const char *customMessagePrefix) { | ||
| 747 |
2/2✓ Branch 19 → 3 taken 381127 times.
✓ Branch 19 → 20 taken 19 times.
|
381146 | for (size_t i = 0; i < opRulesSize; i++) { |
| 748 | 381127 | const BinaryOpRule &rule = opRules[i]; | |
| 749 |
6/6✓ Branch 5 → 6 taken 74829 times.
✓ Branch 5 → 10 taken 306298 times.
✓ Branch 8 → 9 taken 38422 times.
✓ Branch 8 → 10 taken 36407 times.
✓ Branch 11 → 12 taken 38422 times.
✓ Branch 11 → 18 taken 342705 times.
|
381127 | if (std::get<0>(rule) == lhs.getSuperType() && std::get<1>(rule) == rhs.getSuperType()) { |
| 750 |
1/2✓ Branch 13 → 14 taken 38422 times.
✗ Branch 13 → 24 not taken.
|
38422 | QualType resultType((std::get<2>(rule))); |
| 751 |
2/2✓ Branch 14 → 15 taken 21049 times.
✓ Branch 14 → 17 taken 17373 times.
|
38422 | if (preserveQualifiersFromLhs) |
| 752 | 21049 | resultType.setQualifiers(lhs.getQualifiers()); | |
| 753 | 38422 | return resultType; | |
| 754 | } | ||
| 755 | } | ||
| 756 |
1/2✓ Branch 21 → 22 taken 19 times.
✗ Branch 21 → 25 not taken.
|
19 | throw getExceptionBinary(node, name, lhs, rhs, customMessagePrefix); |
| 757 | } | ||
| 758 | |||
| 759 | 2 | SemanticError OpRuleManager::getExceptionUnary(const ASTNode *node, const char *name, const QualType &lhs) { | |
| 760 |
6/12✓ Branch 2 → 3 taken 2 times.
✗ Branch 2 → 35 not taken.
✓ Branch 5 → 6 taken 2 times.
✗ Branch 5 → 27 not taken.
✓ Branch 6 → 7 taken 2 times.
✗ Branch 6 → 25 not taken.
✓ Branch 7 → 8 taken 2 times.
✗ Branch 7 → 23 not taken.
✓ Branch 8 → 9 taken 2 times.
✗ Branch 8 → 21 not taken.
✓ Branch 9 → 10 taken 2 times.
✗ Branch 9 → 19 not taken.
|
8 | return {node, OPERATOR_WRONG_DATA_TYPE, "Cannot apply '" + std::string(name) + "' operator on type " + lhs.getName(true)}; |
| 761 | } | ||
| 762 | |||
| 763 | 19 | SemanticError OpRuleManager::getExceptionBinary(const ASTNode *node, const char *name, const QualType &lhs, const QualType &rhs, | |
| 764 | const char *messagePrefix) { | ||
| 765 | // Build error message | ||
| 766 |
1/2✓ Branch 2 → 3 taken 19 times.
✗ Branch 2 → 50 not taken.
|
19 | std::stringstream errorMsg; |
| 767 |
2/2✓ Branch 3 → 4 taken 4 times.
✓ Branch 3 → 14 taken 15 times.
|
19 | if (strlen(messagePrefix) != 0) |
| 768 |
7/14✓ Branch 4 → 5 taken 4 times.
✗ Branch 4 → 48 not taken.
✓ Branch 5 → 6 taken 4 times.
✗ Branch 5 → 48 not taken.
✓ Branch 6 → 7 taken 4 times.
✗ Branch 6 → 37 not taken.
✓ Branch 7 → 8 taken 4 times.
✗ Branch 7 → 35 not taken.
✓ Branch 8 → 9 taken 4 times.
✗ Branch 8 → 35 not taken.
✓ Branch 9 → 10 taken 4 times.
✗ Branch 9 → 34 not taken.
✓ Branch 10 → 11 taken 4 times.
✗ Branch 10 → 32 not taken.
|
4 | errorMsg << messagePrefix << ". Expected " << lhs.getName(true) << " but got " << rhs.getName(true); |
| 769 | else | ||
| 770 |
8/16✓ Branch 14 → 15 taken 15 times.
✗ Branch 14 → 48 not taken.
✓ Branch 15 → 16 taken 15 times.
✗ Branch 15 → 48 not taken.
✓ Branch 16 → 17 taken 15 times.
✗ Branch 16 → 48 not taken.
✓ Branch 17 → 18 taken 15 times.
✗ Branch 17 → 43 not taken.
✓ Branch 18 → 19 taken 15 times.
✗ Branch 18 → 41 not taken.
✓ Branch 19 → 20 taken 15 times.
✗ Branch 19 → 41 not taken.
✓ Branch 20 → 21 taken 15 times.
✗ Branch 20 → 40 not taken.
✓ Branch 21 → 22 taken 15 times.
✗ Branch 21 → 38 not taken.
|
15 | errorMsg << "Cannot apply '" << name << "' operator on types " << lhs.getName(true) << " and " << rhs.getName(true); |
| 771 | |||
| 772 | // Return the exception | ||
| 773 |
2/4✓ Branch 25 → 26 taken 19 times.
✗ Branch 25 → 46 not taken.
✓ Branch 26 → 27 taken 19 times.
✗ Branch 26 → 44 not taken.
|
57 | return {node, OPERATOR_WRONG_DATA_TYPE, errorMsg.str()}; |
| 774 | 19 | } | |
| 775 | |||
| 776 | 11 | void OpRuleManager::ensureUnsafeAllowed(const ASTNode *node, const char *name, const QualType &lhs) const { | |
| 777 |
2/4✓ Branch 2 → 3 taken 11 times.
✗ Branch 2 → 43 not taken.
✓ Branch 3 → 4 taken 11 times.
✗ Branch 3 → 5 not taken.
|
11 | if (typeChecker->currentScope->doesAllowUnsafeOperations()) |
| 778 | 11 | return; | |
| 779 | // Print error message | ||
| 780 | ✗ | const std::string lhsName = lhs.getName(true); | |
| 781 | ✗ | const std::string errorMsg = "Cannot apply '" + std::string(name) + "' operator on type " + lhsName + | |
| 782 | ✗ | " as this is an unsafe operation. Please use unsafe blocks if you know what you are doing."; | |
| 783 | ✗ | SOFT_ERROR_VOID(node, UNSAFE_OPERATION_IN_SAFE_CONTEXT, errorMsg) | |
| 784 | ✗ | } | |
| 785 | |||
| 786 | 945 | void OpRuleManager::ensureUnsafeAllowed(const ASTNode *node, const char *name, const QualType &lhs, const QualType &rhs) const { | |
| 787 |
3/4✓ Branch 2 → 3 taken 945 times.
✗ Branch 2 → 57 not taken.
✓ Branch 3 → 4 taken 944 times.
✓ Branch 3 → 5 taken 1 time.
|
945 | if (typeChecker->currentScope->doesAllowUnsafeOperations()) |
| 788 | 944 | return; | |
| 789 | // Print error message | ||
| 790 |
1/2✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 57 not taken.
|
1 | const std::string lhsName = lhs.getName(true); |
| 791 |
1/2✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 55 not taken.
|
1 | const std::string rhsName = rhs.getName(true); |
| 792 |
6/12✓ Branch 9 → 10 taken 1 time.
✗ Branch 9 → 42 not taken.
✓ Branch 10 → 11 taken 1 time.
✗ Branch 10 → 40 not taken.
✓ Branch 11 → 12 taken 1 time.
✗ Branch 11 → 38 not taken.
✓ Branch 12 → 13 taken 1 time.
✗ Branch 12 → 36 not taken.
✓ Branch 13 → 14 taken 1 time.
✗ Branch 13 → 34 not taken.
✓ Branch 14 → 15 taken 1 time.
✗ Branch 14 → 32 not taken.
|
2 | const std::string errorMsg = "Cannot apply '" + std::string(name) + "' operator on types " + lhsName + " and " + rhsName + |
| 793 |
1/2✓ Branch 15 → 16 taken 1 time.
✗ Branch 15 → 30 not taken.
|
1 | " as this is an unsafe operation. Please use unsafe blocks if you know what you are doing."; |
| 794 |
1/2✓ Branch 23 → 24 taken 1 time.
✗ Branch 23 → 51 not taken.
|
1 | SOFT_ERROR_VOID(node, UNSAFE_OPERATION_IN_SAFE_CONTEXT, errorMsg) |
| 795 | 1 | } | |
| 796 | |||
| 797 | 29922 | void OpRuleManager::ensureNoConstAssign(const ASTNode *node, const QualType &lhs, bool isDecl, bool isReturn) const { | |
| 798 | // Check if we try to assign a constant value | ||
| 799 |
10/12✓ Branch 2 → 3 taken 29922 times.
✗ Branch 2 → 18 not taken.
✓ Branch 3 → 4 taken 29922 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 3378 times.
✓ Branch 4 → 8 taken 26544 times.
✓ Branch 5 → 6 taken 56 times.
✓ Branch 5 → 8 taken 3322 times.
✓ Branch 6 → 7 taken 14 times.
✓ Branch 6 → 8 taken 42 times.
✓ Branch 9 → 10 taken 14 times.
✓ Branch 9 → 17 taken 29908 times.
|
29922 | if (lhs.removeReferenceWrapper().isConst() && !isDecl && !isReturn) { |
| 800 |
2/4✓ Branch 10 → 11 taken 14 times.
✗ Branch 10 → 21 not taken.
✓ Branch 11 → 12 taken 14 times.
✗ Branch 11 → 19 not taken.
|
14 | const std::string errorMessage = "Trying to assign value to an immutable variable of type " + lhs.getName(true); |
| 801 |
1/2✓ Branch 13 → 14 taken 14 times.
✗ Branch 13 → 22 not taken.
|
14 | SOFT_ERROR_VOID(node, REASSIGN_CONST_VARIABLE, errorMessage); |
| 802 | 14 | } | |
| 803 | } | ||
| 804 | |||
| 805 | } // namespace spice::compiler | ||
| 806 |