src/typechecker/TypeCheckerStatements.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright (c) 2021-2026 ChilliBits. All rights reserved. | ||
| 2 | |||
| 3 | #include "TypeChecker.h" | ||
| 4 | |||
| 5 | #include <SourceFile.h> | ||
| 6 | #include <ast/ASTNodes.h> | ||
| 7 | #include <global/GlobalResourceManager.h> | ||
| 8 | #include <symboltablebuilder/Scope.h> | ||
| 9 | #include <symboltablebuilder/SymbolTableBuilder.h> | ||
| 10 | #include <typechecker/FunctionManager.h> | ||
| 11 | #include <typechecker/MacroDefs.h> | ||
| 12 | |||
| 13 | namespace spice::compiler { | ||
| 14 | |||
| 15 | 21780 | std::any TypeChecker::visitStmtLst(StmtLstNode *node) { | |
| 16 | // Visit nodes in this scope | ||
| 17 |
2/2✓ Branch 15 → 4 taken 42234 times.
✓ Branch 15 → 16 taken 21747 times.
|
63981 | for (StmtNode *stmt : node->statements) { |
| 18 |
1/2✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 42234 times.
|
42234 | if (!stmt) |
| 19 | ✗ | continue; | |
| 20 | // Print warning if statement is unreachable | ||
| 21 |
2/2✓ Branch 7 → 8 taken 3 times.
✓ Branch 7 → 10 taken 42231 times.
|
42234 | if (stmt->unreachable) { |
| 22 |
1/2✓ Branch 8 → 9 taken 3 times.
✗ Branch 8 → 20 not taken.
|
3 | warnings.emplace_back(stmt->codeLoc, UNREACHABLE_CODE, "This statement is unreachable"); |
| 23 | 3 | continue; | |
| 24 | } | ||
| 25 | // Visit the statement | ||
| 26 |
2/2✓ Branch 10 → 11 taken 42198 times.
✓ Branch 10 → 21 taken 33 times.
|
42231 | visit(stmt); |
| 27 | } | ||
| 28 | |||
| 29 | // Do cleanup of this scope, e.g. dtor calls for struct instances | ||
| 30 | 21747 | doScopeCleanup(node); | |
| 31 | |||
| 32 |
1/2✓ Branch 17 → 18 taken 21747 times.
✗ Branch 17 → 23 not taken.
|
21747 | return nullptr; |
| 33 | } | ||
| 34 | |||
| 35 | 38302 | std::any TypeChecker::visitDeclStmt(DeclStmtNode *node) { | |
| 36 | // Retrieve entry of the lhs variable | ||
| 37 |
1/2✓ Branch 2 → 3 taken 38302 times.
✗ Branch 2 → 165 not taken.
|
38302 | SymbolTableEntry *localVarEntry = currentScope->lookupStrict(node->varName); |
| 38 |
1/2✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 38302 times.
|
38302 | assert(localVarEntry != nullptr); |
| 39 | |||
| 40 | 38302 | QualType localVarType; | |
| 41 |
2/2✓ Branch 7 → 8 taken 10701 times.
✓ Branch 7 → 56 taken 27601 times.
|
38302 | if (node->hasAssignment) { |
| 42 | // Visit the right side | ||
| 43 |
3/4✓ Branch 8 → 9 taken 10696 times.
✓ Branch 8 → 115 taken 5 times.
✓ Branch 9 → 10 taken 10696 times.
✗ Branch 9 → 113 not taken.
|
10701 | auto rhs = std::any_cast<ExprResult>(visit(node->assignExpr)); |
| 44 | 10696 | auto [rhsTy, rhsEntry] = rhs; | |
| 45 | |||
| 46 | // Visit data type | ||
| 47 |
3/4✓ Branch 11 → 12 taken 10693 times.
✓ Branch 11 → 118 taken 3 times.
✓ Branch 12 → 13 taken 10693 times.
✗ Branch 12 → 116 not taken.
|
10696 | localVarType = std::any_cast<QualType>(visit(node->dataType)); |
| 48 | |||
| 49 | // Check if type has to be inferred or both types are fixed | ||
| 50 |
8/10✓ Branch 14 → 15 taken 10693 times.
✗ Branch 14 → 134 not taken.
✓ Branch 15 → 16 taken 10689 times.
✓ Branch 15 → 19 taken 4 times.
✓ Branch 16 → 17 taken 10689 times.
✗ Branch 16 → 134 not taken.
✓ Branch 17 → 18 taken 10668 times.
✓ Branch 17 → 19 taken 21 times.
✓ Branch 20 → 21 taken 10668 times.
✓ Branch 20 → 45 taken 25 times.
|
10693 | if (!localVarType.is(TY_UNRESOLVED) && !rhsTy.is(TY_UNRESOLVED)) { |
| 51 | 10668 | const ExprResult lhsResult = {localVarType, localVarEntry}; | |
| 52 |
2/2✓ Branch 21 → 22 taken 10658 times.
✓ Branch 21 → 132 taken 10 times.
|
10668 | const auto [type, copyCtor] = opRuleManager.getAssignResultType(node, lhsResult, rhs, true); |
| 53 | 10658 | localVarType = type; | |
| 54 | 10658 | node->calledCopyCtor = copyCtor; | |
| 55 | |||
| 56 | // If this is a struct type, check if the type is known. If not, error out | ||
| 57 |
8/14✓ Branch 24 → 25 taken 10658 times.
✗ Branch 24 → 120 not taken.
✓ Branch 25 → 26 taken 1273 times.
✓ Branch 25 → 31 taken 9385 times.
✓ Branch 26 → 27 taken 1273 times.
✗ Branch 26 → 120 not taken.
✓ Branch 27 → 28 taken 1273 times.
✗ Branch 27 → 120 not taken.
✓ Branch 28 → 29 taken 1273 times.
✗ Branch 28 → 120 not taken.
✗ Branch 29 → 30 not taken.
✓ Branch 29 → 31 taken 1273 times.
✗ Branch 32 → 33 not taken.
✓ Branch 32 → 44 taken 10658 times.
|
10658 | if (localVarType.isBase(TY_STRUCT) && !sourceFile->getNameRegistryEntry(localVarType.getBase().getSubType())) { |
| 58 | ✗ | const std::string structName = localVarType.getBase().getSubType(); | |
| 59 | ✗ | softError(node->dataType, UNKNOWN_DATATYPE, "Unknown struct type '" + structName + "'. Forgot to import?"); | |
| 60 | ✗ | localVarType = QualType(TY_UNRESOLVED); | |
| 61 | ✗ | } | |
| 62 | } else { | ||
| 63 |
1/2✓ Branch 45 → 46 taken 25 times.
✗ Branch 45 → 133 not taken.
|
25 | localVarType = QualType(TY_UNRESOLVED); |
| 64 | } | ||
| 65 | |||
| 66 | // If there is an anonymous entry attached (e.g. for struct instantiation) and we take over ownership, delete it | ||
| 67 |
9/10✓ Branch 47 → 48 taken 10683 times.
✗ Branch 47 → 134 not taken.
✓ Branch 48 → 49 taken 10506 times.
✓ Branch 48 → 52 taken 177 times.
✓ Branch 49 → 50 taken 2007 times.
✓ Branch 49 → 52 taken 8499 times.
✓ Branch 50 → 51 taken 852 times.
✓ Branch 50 → 52 taken 1155 times.
✓ Branch 53 → 54 taken 852 times.
✓ Branch 53 → 55 taken 9831 times.
|
10683 | if (!localVarType.isRef() && rhsEntry != nullptr && rhsEntry->anonymous) |
| 68 |
1/2✓ Branch 54 → 55 taken 852 times.
✗ Branch 54 → 134 not taken.
|
852 | currentScope->symbolTable.deleteAnonymous(rhsEntry->name); |
| 69 | } else { | ||
| 70 | // Visit data type | ||
| 71 |
2/4✓ Branch 56 → 57 taken 27601 times.
✗ Branch 56 → 137 not taken.
✓ Branch 57 → 58 taken 27601 times.
✗ Branch 57 → 135 not taken.
|
27601 | localVarType = std::any_cast<QualType>(visit(node->dataType)); |
| 72 | |||
| 73 | // References with no initialization are illegal | ||
| 74 |
9/10✓ Branch 59 → 60 taken 27601 times.
✗ Branch 59 → 165 not taken.
✓ Branch 60 → 61 taken 7098 times.
✓ Branch 60 → 64 taken 20503 times.
✓ Branch 61 → 62 taken 84 times.
✓ Branch 61 → 64 taken 7014 times.
✓ Branch 62 → 63 taken 1 time.
✓ Branch 62 → 64 taken 83 times.
✓ Branch 65 → 66 taken 1 time.
✓ Branch 65 → 73 taken 27600 times.
|
27601 | if (localVarType.isRef() && !node->isFctParam && !node->isForEachItem) |
| 75 |
2/4✓ Branch 68 → 69 taken 1 time.
✗ Branch 68 → 141 not taken.
✓ Branch 69 → 70 taken 1 time.
✗ Branch 69 → 139 not taken.
|
2 | softError(node, REFERENCE_WITHOUT_INITIALIZER, "References must always be initialized directly"); |
| 76 | |||
| 77 | // If this is a struct, check for the default ctor | ||
| 78 |
9/10✓ Branch 73 → 74 taken 27601 times.
✗ Branch 73 → 165 not taken.
✓ Branch 74 → 75 taken 732 times.
✓ Branch 74 → 78 taken 26869 times.
✓ Branch 75 → 76 taken 195 times.
✓ Branch 75 → 78 taken 537 times.
✓ Branch 76 → 77 taken 185 times.
✓ Branch 76 → 78 taken 10 times.
✓ Branch 79 → 80 taken 185 times.
✓ Branch 79 → 106 taken 27416 times.
|
27601 | if (localVarType.is(TY_STRUCT) && !node->isFctParam && !node->isForEachItem) { |
| 79 |
1/2✓ Branch 80 → 81 taken 185 times.
✗ Branch 80 → 165 not taken.
|
185 | Scope *matchScope = localVarType.getBodyScope(); |
| 80 |
1/2✗ Branch 81 → 82 not taken.
✓ Branch 81 → 83 taken 185 times.
|
185 | assert(matchScope != nullptr); |
| 81 | // Check if we are required to call a ctor | ||
| 82 |
1/2✓ Branch 83 → 84 taken 185 times.
✗ Branch 83 → 165 not taken.
|
185 | node->isCtorCallRequired = !localVarType.isTriviallyConstructible(node); |
| 83 | // Check if we have a no-args ctor to call | ||
| 84 | 185 | const QualType &thisType = localVarType; | |
| 85 |
2/4✓ Branch 88 → 89 taken 185 times.
✗ Branch 88 → 147 not taken.
✓ Branch 89 → 90 taken 185 times.
✗ Branch 89 → 145 not taken.
|
555 | node->calledInitCtor = FunctionManager::match(matchScope, CTOR_FUNCTION_NAME, thisType, {}, {}, false, node); |
| 86 |
4/4✓ Branch 94 → 95 taken 17 times.
✓ Branch 94 → 106 taken 168 times.
✓ Branch 95 → 96 taken 5 times.
✓ Branch 95 → 106 taken 12 times.
|
185 | if (node->calledInitCtor == nullptr && node->isCtorCallRequired) { |
| 87 |
1/2✓ Branch 96 → 97 taken 5 times.
✗ Branch 96 → 163 not taken.
|
5 | const std::string &structName = localVarType.getSubType(); |
| 88 |
2/4✓ Branch 97 → 98 taken 5 times.
✗ Branch 97 → 159 not taken.
✓ Branch 98 → 99 taken 5 times.
✗ Branch 98 → 157 not taken.
|
5 | const auto msg = "Struct '" + structName + "' is not trivially constructible and has no no-args constructor."; |
| 89 |
3/6✓ Branch 100 → 101 taken 5 times.
✗ Branch 100 → 161 not taken.
✓ Branch 101 → 102 taken 5 times.
✗ Branch 101 → 160 not taken.
✓ Branch 102 → 103 taken 5 times.
✗ Branch 102 → 160 not taken.
|
5 | SOFT_ERROR_QT(node, NO_MATCHING_CTOR_FOUND, msg); |
| 90 | 5 | } | |
| 91 | } | ||
| 92 | } | ||
| 93 | |||
| 94 | // Update the type of the variable | ||
| 95 |
1/2✓ Branch 106 → 107 taken 38279 times.
✗ Branch 106 → 165 not taken.
|
38279 | localVarEntry->updateType(localVarType, true); |
| 96 |
1/2✓ Branch 107 → 108 taken 38279 times.
✗ Branch 107 → 165 not taken.
|
38279 | node->entries.at(manIdx) = localVarEntry; |
| 97 | |||
| 98 | // Update the state of the variable | ||
| 99 |
1/2✓ Branch 108 → 109 taken 38279 times.
✗ Branch 108 → 164 not taken.
|
38279 | localVarEntry->updateState(INITIALIZED, node); |
| 100 | |||
| 101 |
1/2✓ Branch 109 → 110 taken 38279 times.
✗ Branch 109 → 165 not taken.
|
38279 | return localVarType; |
| 102 | } | ||
| 103 | |||
| 104 | 10158 | std::any TypeChecker::visitReturnStmt(ReturnStmtNode *node) { | |
| 105 | // Retrieve return variable entry | ||
| 106 |
1/2✓ Branch 4 → 5 taken 10158 times.
✗ Branch 4 → 68 not taken.
|
30474 | SymbolTableEntry *returnVar = currentScope->lookup(RETURN_VARIABLE_NAME); |
| 107 | 10158 | const bool isFunction = returnVar != nullptr; | |
| 108 |
4/6✓ Branch 10 → 11 taken 10090 times.
✓ Branch 10 → 13 taken 68 times.
✓ Branch 11 → 12 taken 10090 times.
✗ Branch 11 → 91 not taken.
✓ Branch 13 → 14 taken 68 times.
✗ Branch 13 → 91 not taken.
|
10158 | const QualType returnType = isFunction ? returnVar->getQualType() : QualType(TY_DYN); |
| 109 | |||
| 110 | // Check if procedure with return value | ||
| 111 |
2/2✓ Branch 14 → 15 taken 68 times.
✓ Branch 14 → 28 taken 10090 times.
|
10158 | if (!isFunction) { |
| 112 |
2/2✓ Branch 15 → 16 taken 2 times.
✓ Branch 15 → 26 taken 66 times.
|
68 | if (node->hasReturnValue) |
| 113 |
4/8✓ Branch 18 → 19 taken 2 times.
✗ Branch 18 → 74 not taken.
✓ Branch 19 → 20 taken 2 times.
✗ Branch 19 → 72 not taken.
✓ Branch 22 → 23 taken 2 times.
✗ Branch 22 → 78 not taken.
✓ Branch 23 → 24 taken 2 times.
✗ Branch 23 → 78 not taken.
|
6 | SOFT_ERROR_ER(node->assignExpr, RETURN_WITH_VALUE_IN_PROCEDURE, "Return with value in procedure is not allowed") |
| 114 |
1/2✓ Branch 26 → 27 taken 66 times.
✗ Branch 26 → 79 not taken.
|
66 | return nullptr; |
| 115 | } | ||
| 116 | |||
| 117 |
7/8✓ Branch 28 → 29 taken 6 times.
✓ Branch 28 → 33 taken 10084 times.
✓ Branch 30 → 31 taken 6 times.
✗ Branch 30 → 91 not taken.
✓ Branch 31 → 32 taken 2 times.
✓ Branch 31 → 33 taken 4 times.
✓ Branch 34 → 35 taken 2 times.
✓ Branch 34 → 45 taken 10088 times.
|
10090 | if (!node->hasReturnValue && !returnVar->getLifecycle().isInitialized()) |
| 118 |
4/8✓ Branch 37 → 38 taken 2 times.
✗ Branch 37 → 82 not taken.
✓ Branch 38 → 39 taken 2 times.
✗ Branch 38 → 80 not taken.
✓ Branch 41 → 42 taken 2 times.
✗ Branch 41 → 86 not taken.
✓ Branch 42 → 43 taken 2 times.
✗ Branch 42 → 86 not taken.
|
6 | SOFT_ERROR_QT(node, RETURN_WITHOUT_VALUE_RESULT, "Return without value, but result variable is not initialized yet") |
| 119 | |||
| 120 |
2/2✓ Branch 45 → 46 taken 4 times.
✓ Branch 45 → 48 taken 10084 times.
|
10088 | if (!node->hasReturnValue) |
| 121 |
1/2✓ Branch 46 → 47 taken 4 times.
✗ Branch 46 → 87 not taken.
|
4 | return nullptr; |
| 122 | |||
| 123 | // Visit right side | ||
| 124 |
2/4✓ Branch 48 → 49 taken 10084 times.
✗ Branch 48 → 90 not taken.
✓ Branch 49 → 50 taken 10084 times.
✗ Branch 49 → 88 not taken.
|
10084 | const auto rhs = std::any_cast<ExprResult>(visit(node->assignExpr)); |
| 125 |
2/6✓ Branch 51 → 52 taken 10084 times.
✗ Branch 51 → 91 not taken.
✗ Branch 52 → 53 not taken.
✓ Branch 52 → 55 taken 10084 times.
✗ Branch 53 → 54 not taken.
✗ Branch 53 → 91 not taken.
|
10084 | HANDLE_UNRESOLVED_TYPE_QT(rhs.type) |
| 126 | |||
| 127 | // Check if types match | ||
| 128 | 10084 | const ExprResult returnResult = {returnType, returnVar}; | |
| 129 |
2/2✓ Branch 55 → 56 taken 10081 times.
✓ Branch 55 → 91 taken 3 times.
|
10084 | auto [_, copyCtor] = opRuleManager.getAssignResultType(node->assignExpr, returnResult, rhs, false, true, ERROR_MSG_RETURN); |
| 130 | 10081 | node->calledCopyCtor = copyCtor; | |
| 131 | |||
| 132 | // Check if the dtor call on the return value can be skipped | ||
| 133 |
2/2✓ Branch 58 → 59 taken 2474 times.
✓ Branch 58 → 62 taken 7607 times.
|
10081 | if (rhs.entry != nullptr) { |
| 134 |
2/2✓ Branch 59 → 60 taken 866 times.
✓ Branch 59 → 61 taken 1608 times.
|
2474 | if (rhs.entry->anonymous) { |
| 135 | // If there is an anonymous entry attached (e.g. for struct instantiation), delete it | ||
| 136 |
1/2✓ Branch 60 → 62 taken 866 times.
✗ Branch 60 → 91 not taken.
|
866 | currentScope->symbolTable.deleteAnonymous(rhs.entry->name); |
| 137 | } else { | ||
| 138 | // Otherwise omit the destructor call, because the caller destructs the value | ||
| 139 | 1608 | rhs.entry->omitDtorCall = true; | |
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 |
1/2✓ Branch 62 → 63 taken 10081 times.
✗ Branch 62 → 91 not taken.
|
10081 | return node->returnType = returnType; |
| 144 | } | ||
| 145 | |||
| 146 | 132 | std::any TypeChecker::visitBreakStmt(BreakStmtNode *node) { | |
| 147 | // Check if the stated number is valid | ||
| 148 |
2/2✓ Branch 2 → 3 taken 1 time.
✓ Branch 2 → 12 taken 131 times.
|
132 | if (node->breakTimes < 1) |
| 149 |
4/8✓ Branch 4 → 5 taken 1 time.
✗ Branch 4 → 30 not taken.
✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 28 not taken.
✓ Branch 8 → 9 taken 1 time.
✗ Branch 8 → 34 not taken.
✓ Branch 9 → 10 taken 1 time.
✗ Branch 9 → 34 not taken.
|
1 | SOFT_ERROR_ER(node, INVALID_BREAK_NUMBER, "Break count must be >= 1, you provided " + std::to_string(node->breakTimes)) |
| 150 | |||
| 151 | // Check if we can break this often | ||
| 152 | 131 | const unsigned int maxBreaks = currentScope->getLoopNestingDepth(); | |
| 153 |
2/2✓ Branch 13 → 14 taken 1 time.
✓ Branch 13 → 25 taken 130 times.
|
131 | if (static_cast<unsigned int>(node->breakTimes) > maxBreaks) |
| 154 |
5/10✓ Branch 15 → 16 taken 1 time.
✗ Branch 15 → 39 not taken.
✓ Branch 16 → 17 taken 1 time.
✗ Branch 16 → 37 not taken.
✓ Branch 17 → 18 taken 1 time.
✗ Branch 17 → 35 not taken.
✓ Branch 21 → 22 taken 1 time.
✗ Branch 21 → 44 not taken.
✓ Branch 22 → 23 taken 1 time.
✗ Branch 22 → 44 not taken.
|
1 | SOFT_ERROR_ER(node, INVALID_BREAK_NUMBER, "We can only break " + std::to_string(maxBreaks) + " time(s) here") |
| 155 | |||
| 156 |
1/2✓ Branch 25 → 26 taken 130 times.
✗ Branch 25 → 45 not taken.
|
130 | return nullptr; |
| 157 | } | ||
| 158 | |||
| 159 | 411 | std::any TypeChecker::visitContinueStmt(ContinueStmtNode *node) { | |
| 160 | // Check if the stated number is valid | ||
| 161 |
2/2✓ Branch 2 → 3 taken 1 time.
✓ Branch 2 → 12 taken 410 times.
|
411 | if (node->continueTimes < 1) |
| 162 |
4/8✓ Branch 4 → 5 taken 1 time.
✗ Branch 4 → 30 not taken.
✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 28 not taken.
✓ Branch 8 → 9 taken 1 time.
✗ Branch 8 → 34 not taken.
✓ Branch 9 → 10 taken 1 time.
✗ Branch 9 → 34 not taken.
|
1 | SOFT_ERROR_ER(node, INVALID_CONTINUE_NUMBER, |
| 163 | "Continue count must be >= 1, you provided " + std::to_string(node->continueTimes)) | ||
| 164 | |||
| 165 | // Check if we can continue this often | ||
| 166 | 410 | const unsigned int maxContinues = currentScope->getLoopNestingDepth(); | |
| 167 |
2/2✓ Branch 13 → 14 taken 1 time.
✓ Branch 13 → 25 taken 409 times.
|
410 | if (static_cast<unsigned int>(node->continueTimes) > maxContinues) |
| 168 |
5/10✓ Branch 15 → 16 taken 1 time.
✗ Branch 15 → 39 not taken.
✓ Branch 16 → 17 taken 1 time.
✗ Branch 16 → 37 not taken.
✓ Branch 17 → 18 taken 1 time.
✗ Branch 17 → 35 not taken.
✓ Branch 21 → 22 taken 1 time.
✗ Branch 21 → 44 not taken.
✓ Branch 22 → 23 taken 1 time.
✗ Branch 22 → 44 not taken.
|
1 | SOFT_ERROR_ER(node, INVALID_CONTINUE_NUMBER, "We can only continue " + std::to_string(maxContinues) + " time(s) here") |
| 169 | |||
| 170 |
1/2✓ Branch 25 → 26 taken 409 times.
✗ Branch 25 → 45 not taken.
|
409 | return nullptr; |
| 171 | } | ||
| 172 | |||
| 173 | 6 | std::any TypeChecker::visitFallthroughStmt(FallthroughStmtNode *node) { | |
| 174 | // Check if we can do a fallthrough here | ||
| 175 |
2/2✓ Branch 3 → 4 taken 2 times.
✓ Branch 3 → 14 taken 4 times.
|
6 | if (!currentScope->isInCaseBranch()) |
| 176 |
4/8✓ Branch 6 → 7 taken 2 times.
✗ Branch 6 → 19 not taken.
✓ Branch 7 → 8 taken 2 times.
✗ Branch 7 → 17 not taken.
✓ Branch 10 → 11 taken 2 times.
✗ Branch 10 → 23 not taken.
✓ Branch 11 → 12 taken 2 times.
✗ Branch 11 → 23 not taken.
|
6 | SOFT_ERROR_ER(node, FALLTHROUGH_NOT_ALLOWED, "Fallthrough is only allowed in case branches") |
| 177 | |||
| 178 |
1/2✓ Branch 14 → 15 taken 4 times.
✗ Branch 14 → 24 not taken.
|
4 | return nullptr; |
| 179 | } | ||
| 180 | |||
| 181 | 1226 | std::any TypeChecker::visitAssertStmt(AssertStmtNode *node) { | |
| 182 | // Visit condition | ||
| 183 |
2/4✓ Branch 2 → 3 taken 1226 times.
✗ Branch 2 → 29 not taken.
✓ Branch 3 → 4 taken 1226 times.
✗ Branch 3 → 27 not taken.
|
1226 | const QualType conditionType = std::any_cast<ExprResult>(visit(node->assignExpr)).type; |
| 184 |
2/8✓ Branch 5 → 6 taken 1226 times.
✗ Branch 5 → 40 not taken.
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 11 taken 1226 times.
✗ Branch 7 → 8 not taken.
✗ Branch 7 → 31 not taken.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 31 not taken.
|
1226 | HANDLE_UNRESOLVED_TYPE_ER(conditionType) |
| 185 | |||
| 186 | // Check if condition evaluates to bool | ||
| 187 |
3/4✓ Branch 11 → 12 taken 1226 times.
✗ Branch 11 → 40 not taken.
✓ Branch 12 → 13 taken 1 time.
✓ Branch 12 → 23 taken 1225 times.
|
1226 | if (!conditionType.is(TY_BOOL)) |
| 188 |
4/8✓ Branch 15 → 16 taken 1 time.
✗ Branch 15 → 34 not taken.
✓ Branch 16 → 17 taken 1 time.
✗ Branch 16 → 32 not taken.
✓ Branch 19 → 20 taken 1 time.
✗ Branch 19 → 38 not taken.
✓ Branch 20 → 21 taken 1 time.
✗ Branch 20 → 38 not taken.
|
3 | SOFT_ERROR_ER(node->assignExpr, ASSERTION_CONDITION_BOOL, "The asserted condition must be of type bool") |
| 189 | |||
| 190 |
1/2✓ Branch 23 → 24 taken 1225 times.
✗ Branch 23 → 39 not taken.
|
1225 | return nullptr; |
| 191 | } | ||
| 192 | |||
| 193 | } // namespace spice::compiler | ||
| 194 |