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 | 22252 | std::any TypeChecker::visitStmtLst(StmtLstNode *node) { | |
| 16 | // Visit nodes in this scope | ||
| 17 |
2/2✓ Branch 15 → 4 taken 43079 times.
✓ Branch 15 → 16 taken 22219 times.
|
65298 | for (StmtNode *stmt : node->statements) { |
| 18 |
1/2✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 43079 times.
|
43079 | if (!stmt) |
| 19 | ✗ | continue; | |
| 20 | // Print warning if statement is unreachable | ||
| 21 |
2/2✓ Branch 7 → 8 taken 3 times.
✓ Branch 7 → 10 taken 43076 times.
|
43079 | 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 43043 times.
✓ Branch 10 → 21 taken 33 times.
|
43076 | visit(stmt); |
| 27 | } | ||
| 28 | |||
| 29 | // Do cleanup of this scope, e.g. dtor calls for struct instances | ||
| 30 | 22219 | doScopeCleanup(node); | |
| 31 | |||
| 32 |
1/2✓ Branch 17 → 18 taken 22219 times.
✗ Branch 17 → 23 not taken.
|
22219 | return nullptr; |
| 33 | } | ||
| 34 | |||
| 35 | 39169 | std::any TypeChecker::visitDeclStmt(DeclStmtNode *node) { | |
| 36 | // Retrieve entry of the lhs variable | ||
| 37 |
1/2✓ Branch 2 → 3 taken 39169 times.
✗ Branch 2 → 165 not taken.
|
39169 | SymbolTableEntry *localVarEntry = currentScope->lookupStrict(node->varName); |
| 38 |
1/2✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 39169 times.
|
39169 | assert(localVarEntry != nullptr); |
| 39 | |||
| 40 | 39169 | QualType localVarType; | |
| 41 |
2/2✓ Branch 7 → 8 taken 10944 times.
✓ Branch 7 → 56 taken 28225 times.
|
39169 | if (node->hasAssignment) { |
| 42 | // Visit the right side | ||
| 43 |
3/4✓ Branch 8 → 9 taken 10939 times.
✓ Branch 8 → 115 taken 5 times.
✓ Branch 9 → 10 taken 10939 times.
✗ Branch 9 → 113 not taken.
|
10944 | auto rhs = std::any_cast<ExprResult>(visit(node->assignExpr)); |
| 44 | 10939 | auto [rhsTy, rhsEntry] = rhs; | |
| 45 | |||
| 46 | // Visit data type | ||
| 47 |
3/4✓ Branch 11 → 12 taken 10936 times.
✓ Branch 11 → 118 taken 3 times.
✓ Branch 12 → 13 taken 10936 times.
✗ Branch 12 → 116 not taken.
|
10939 | 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 10936 times.
✗ Branch 14 → 134 not taken.
✓ Branch 15 → 16 taken 10932 times.
✓ Branch 15 → 19 taken 4 times.
✓ Branch 16 → 17 taken 10932 times.
✗ Branch 16 → 134 not taken.
✓ Branch 17 → 18 taken 10911 times.
✓ Branch 17 → 19 taken 21 times.
✓ Branch 20 → 21 taken 10911 times.
✓ Branch 20 → 45 taken 25 times.
|
10936 | if (!localVarType.is(TY_UNRESOLVED) && !rhsTy.is(TY_UNRESOLVED)) { |
| 51 | 10911 | const ExprResult lhsResult = {localVarType, localVarEntry}; | |
| 52 |
2/2✓ Branch 21 → 22 taken 10901 times.
✓ Branch 21 → 132 taken 10 times.
|
10911 | const auto [type, copyCtor] = opRuleManager.getAssignResultType(node, lhsResult, rhs, true); |
| 53 | 10901 | localVarType = type; | |
| 54 | 10901 | 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 10901 times.
✗ Branch 24 → 120 not taken.
✓ Branch 25 → 26 taken 1314 times.
✓ Branch 25 → 31 taken 9587 times.
✓ Branch 26 → 27 taken 1314 times.
✗ Branch 26 → 120 not taken.
✓ Branch 27 → 28 taken 1314 times.
✗ Branch 27 → 120 not taken.
✓ Branch 28 → 29 taken 1314 times.
✗ Branch 28 → 120 not taken.
✗ Branch 29 → 30 not taken.
✓ Branch 29 → 31 taken 1314 times.
✗ Branch 32 → 33 not taken.
✓ Branch 32 → 44 taken 10901 times.
|
10901 | 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 10926 times.
✗ Branch 47 → 134 not taken.
✓ Branch 48 → 49 taken 10750 times.
✓ Branch 48 → 52 taken 176 times.
✓ Branch 49 → 50 taken 2049 times.
✓ Branch 49 → 52 taken 8701 times.
✓ Branch 50 → 51 taken 865 times.
✓ Branch 50 → 52 taken 1184 times.
✓ Branch 53 → 54 taken 865 times.
✓ Branch 53 → 55 taken 10061 times.
|
10926 | if (!localVarType.isRef() && rhsEntry != nullptr && rhsEntry->anonymous) |
| 68 |
1/2✓ Branch 54 → 55 taken 865 times.
✗ Branch 54 → 134 not taken.
|
865 | currentScope->symbolTable.deleteAnonymous(rhsEntry->name); |
| 69 | } else { | ||
| 70 | // Visit data type | ||
| 71 |
2/4✓ Branch 56 → 57 taken 28225 times.
✗ Branch 56 → 137 not taken.
✓ Branch 57 → 58 taken 28225 times.
✗ Branch 57 → 135 not taken.
|
28225 | localVarType = std::any_cast<QualType>(visit(node->dataType)); |
| 72 | |||
| 73 | // References with no initialization are illegal | ||
| 74 |
9/10✓ Branch 59 → 60 taken 28225 times.
✗ Branch 59 → 165 not taken.
✓ Branch 60 → 61 taken 7170 times.
✓ Branch 60 → 64 taken 21055 times.
✓ Branch 61 → 62 taken 83 times.
✓ Branch 61 → 64 taken 7087 times.
✓ Branch 62 → 63 taken 1 time.
✓ Branch 62 → 64 taken 82 times.
✓ Branch 65 → 66 taken 1 time.
✓ Branch 65 → 73 taken 28224 times.
|
28225 | 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 28225 times.
✗ Branch 73 → 165 not taken.
✓ Branch 74 → 75 taken 783 times.
✓ Branch 74 → 78 taken 27442 times.
✓ Branch 75 → 76 taken 201 times.
✓ Branch 75 → 78 taken 582 times.
✓ Branch 76 → 77 taken 191 times.
✓ Branch 76 → 78 taken 10 times.
✓ Branch 79 → 80 taken 191 times.
✓ Branch 79 → 106 taken 28034 times.
|
28225 | if (localVarType.is(TY_STRUCT) && !node->isFctParam && !node->isForEachItem) { |
| 79 |
1/2✓ Branch 80 → 81 taken 191 times.
✗ Branch 80 → 165 not taken.
|
191 | Scope *matchScope = localVarType.getBodyScope(); |
| 80 |
1/2✗ Branch 81 → 82 not taken.
✓ Branch 81 → 83 taken 191 times.
|
191 | assert(matchScope != nullptr); |
| 81 | // Check if we are required to call a ctor | ||
| 82 |
1/2✓ Branch 83 → 84 taken 191 times.
✗ Branch 83 → 165 not taken.
|
191 | node->isCtorCallRequired = !localVarType.isTriviallyConstructible(node); |
| 83 | // Check if we have a no-args ctor to call | ||
| 84 | 191 | const QualType &thisType = localVarType; | |
| 85 |
2/4✓ Branch 88 → 89 taken 191 times.
✗ Branch 88 → 147 not taken.
✓ Branch 89 → 90 taken 191 times.
✗ Branch 89 → 145 not taken.
|
573 | node->calledInitCtor = FunctionManager::match(matchScope, CTOR_FUNCTION_NAME, thisType, {}, {}, false, node); |
| 86 |
4/4✓ Branch 94 → 95 taken 17 times.
✓ Branch 94 → 106 taken 174 times.
✓ Branch 95 → 96 taken 5 times.
✓ Branch 95 → 106 taken 12 times.
|
191 | 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 39146 times.
✗ Branch 106 → 165 not taken.
|
39146 | localVarEntry->updateType(localVarType, true); |
| 96 |
1/2✓ Branch 107 → 108 taken 39146 times.
✗ Branch 107 → 165 not taken.
|
39146 | node->entries.at(manIdx) = localVarEntry; |
| 97 | |||
| 98 | // Update the state of the variable | ||
| 99 |
1/2✓ Branch 108 → 109 taken 39146 times.
✗ Branch 108 → 164 not taken.
|
39146 | localVarEntry->updateState(INITIALIZED, node); |
| 100 | |||
| 101 |
1/2✓ Branch 109 → 110 taken 39146 times.
✗ Branch 109 → 165 not taken.
|
39146 | return localVarType; |
| 102 | } | ||
| 103 | |||
| 104 | 10422 | std::any TypeChecker::visitReturnStmt(ReturnStmtNode *node) { | |
| 105 | // Retrieve return variable entry | ||
| 106 |
1/2✓ Branch 4 → 5 taken 10422 times.
✗ Branch 4 → 68 not taken.
|
31266 | SymbolTableEntry *returnVar = currentScope->lookup(RETURN_VARIABLE_NAME); |
| 107 | 10422 | const bool isFunction = returnVar != nullptr; | |
| 108 |
4/6✓ Branch 10 → 11 taken 10355 times.
✓ Branch 10 → 13 taken 67 times.
✓ Branch 11 → 12 taken 10355 times.
✗ Branch 11 → 91 not taken.
✓ Branch 13 → 14 taken 67 times.
✗ Branch 13 → 91 not taken.
|
10422 | const QualType returnType = isFunction ? returnVar->getQualType() : QualType(TY_DYN); |
| 109 | |||
| 110 | // Check if procedure with return value | ||
| 111 |
2/2✓ Branch 14 → 15 taken 67 times.
✓ Branch 14 → 28 taken 10355 times.
|
10422 | if (!isFunction) { |
| 112 |
2/2✓ Branch 15 → 16 taken 2 times.
✓ Branch 15 → 26 taken 65 times.
|
67 | 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 65 times.
✗ Branch 26 → 79 not taken.
|
65 | return nullptr; |
| 115 | } | ||
| 116 | |||
| 117 |
7/8✓ Branch 28 → 29 taken 6 times.
✓ Branch 28 → 33 taken 10349 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 10353 times.
|
10355 | 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 10349 times.
|
10353 | 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 10349 times.
✗ Branch 48 → 90 not taken.
✓ Branch 49 → 50 taken 10349 times.
✗ Branch 49 → 88 not taken.
|
10349 | const auto rhs = std::any_cast<ExprResult>(visit(node->assignExpr)); |
| 125 |
2/6✓ Branch 51 → 52 taken 10349 times.
✗ Branch 51 → 91 not taken.
✗ Branch 52 → 53 not taken.
✓ Branch 52 → 55 taken 10349 times.
✗ Branch 53 → 54 not taken.
✗ Branch 53 → 91 not taken.
|
10349 | HANDLE_UNRESOLVED_TYPE_QT(rhs.type) |
| 126 | |||
| 127 | // Check if types match | ||
| 128 | 10349 | const ExprResult returnResult = {returnType, returnVar}; | |
| 129 |
2/2✓ Branch 55 → 56 taken 10346 times.
✓ Branch 55 → 91 taken 3 times.
|
10349 | auto [_, copyCtor] = opRuleManager.getAssignResultType(node->assignExpr, returnResult, rhs, false, true, ERROR_MSG_RETURN); |
| 130 | 10346 | node->calledCopyCtor = copyCtor; | |
| 131 | |||
| 132 | // Check if the dtor call on the return value can be skipped | ||
| 133 |
2/2✓ Branch 58 → 59 taken 2510 times.
✓ Branch 58 → 62 taken 7836 times.
|
10346 | if (rhs.entry != nullptr) { |
| 134 |
2/2✓ Branch 59 → 60 taken 869 times.
✓ Branch 59 → 61 taken 1641 times.
|
2510 | 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 869 times.
✗ Branch 60 → 91 not taken.
|
869 | currentScope->symbolTable.deleteAnonymous(rhs.entry->name); |
| 137 | } else { | ||
| 138 | // Otherwise omit the destructor call, because the caller destructs the value | ||
| 139 | 1641 | rhs.entry->omitDtorCall = true; | |
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 |
1/2✓ Branch 62 → 63 taken 10346 times.
✗ Branch 62 → 91 not taken.
|
10346 | return node->returnType = returnType; |
| 144 | } | ||
| 145 | |||
| 146 | 134 | 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 133 times.
|
134 | 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 | 133 | const unsigned int maxBreaks = currentScope->getLoopNestingDepth(); | |
| 153 |
2/2✓ Branch 13 → 14 taken 1 time.
✓ Branch 13 → 25 taken 132 times.
|
133 | 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 132 times.
✗ Branch 25 → 45 not taken.
|
132 | return nullptr; |
| 157 | } | ||
| 158 | |||
| 159 | 419 | 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 418 times.
|
419 | 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 | 418 | const unsigned int maxContinues = currentScope->getLoopNestingDepth(); | |
| 167 |
2/2✓ Branch 13 → 14 taken 1 time.
✓ Branch 13 → 25 taken 417 times.
|
418 | 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 417 times.
✗ Branch 25 → 45 not taken.
|
417 | 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 | 1238 | std::any TypeChecker::visitAssertStmt(AssertStmtNode *node) { | |
| 182 | // Visit condition | ||
| 183 |
2/4✓ Branch 2 → 3 taken 1238 times.
✗ Branch 2 → 29 not taken.
✓ Branch 3 → 4 taken 1238 times.
✗ Branch 3 → 27 not taken.
|
1238 | const QualType conditionType = std::any_cast<ExprResult>(visit(node->assignExpr)).type; |
| 184 |
2/8✓ Branch 5 → 6 taken 1238 times.
✗ Branch 5 → 40 not taken.
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 11 taken 1238 times.
✗ Branch 7 → 8 not taken.
✗ Branch 7 → 31 not taken.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 31 not taken.
|
1238 | HANDLE_UNRESOLVED_TYPE_ER(conditionType) |
| 185 | |||
| 186 | // Check if condition evaluates to bool | ||
| 187 |
3/4✓ Branch 11 → 12 taken 1238 times.
✗ Branch 11 → 40 not taken.
✓ Branch 12 → 13 taken 1 time.
✓ Branch 12 → 23 taken 1237 times.
|
1238 | 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 1237 times.
✗ Branch 23 → 39 not taken.
|
1237 | return nullptr; |
| 191 | } | ||
| 192 | |||
| 193 | } // namespace spice::compiler | ||
| 194 |