src/typechecker/TypeChecker.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/Attributes.h> | ||
| 7 | #include <global/GlobalResourceManager.h> | ||
| 8 | #include <symboltablebuilder/Scope.h> | ||
| 9 | #include <symboltablebuilder/SymbolTableBuilder.h> | ||
| 10 | #include <typechecker/FunctionManager.h> | ||
| 11 | |||
| 12 | namespace spice::compiler { | ||
| 13 | |||
| 14 | 23125 | TypeChecker::TypeChecker(GlobalResourceManager &resourceManager, SourceFile *sourceFile, TypeCheckerMode typeCheckerMode) | |
| 15 |
1/2✓ Branch 4 → 5 taken 23125 times.
✗ Branch 4 → 7 not taken.
|
23125 | : CompilerPass(resourceManager, sourceFile), typeCheckerMode(typeCheckerMode), warnings(sourceFile->compilerOutput.warnings) { |
| 16 | 23125 | } | |
| 17 | |||
| 18 | 16108 | std::any TypeChecker::visitEntry(EntryNode *node) { | |
| 19 | // Initialize | ||
| 20 | 16108 | currentScope = rootScope; | |
| 21 | |||
| 22 | // Initialize AST nodes with size of 1 | ||
| 23 | 16108 | const bool isPrepare = typeCheckerMode == TC_MODE_PRE; | |
| 24 |
2/2✓ Branch 2 → 3 taken 6067 times.
✓ Branch 2 → 4 taken 10041 times.
|
16108 | if (isPrepare) |
| 25 | 6067 | node->resizeToNumberOfManifestations(1); | |
| 26 | |||
| 27 | // Visit children | ||
| 28 |
2/2✓ Branch 4 → 5 taken 16008 times.
✓ Branch 4 → 29 taken 100 times.
|
16108 | visitChildren(node); |
| 29 | |||
| 30 | // Check which implicit structures we need for each struct, defined in this source file. Manifestations that are | ||
| 31 | // substantiated after this point are decided on directly at their creation (see createImplicitDefaultMembers). | ||
| 32 |
2/2✓ Branch 6 → 7 taken 6031 times.
✓ Branch 6 → 25 taken 9977 times.
|
16008 | if (isPrepare) |
| 33 |
3/4✓ Branch 7 → 8 taken 6031 times.
✗ Branch 7 → 32 not taken.
✓ Branch 22 → 10 taken 7487 times.
✓ Branch 22 → 23 taken 6031 times.
|
19549 | for (Struct *manifestation : rootScope->getAllStructManifestationsInDeclarationOrder()) |
| 34 |
1/2✓ Branch 12 → 13 taken 7487 times.
✗ Branch 12 → 30 not taken.
|
13518 | createImplicitDefaultMembers(*manifestation, node); |
| 35 | |||
| 36 |
1/2✓ Branch 25 → 26 taken 16008 times.
✗ Branch 25 → 33 not taken.
|
32016 | return nullptr; |
| 37 | } | ||
| 38 | |||
| 39 | /** | ||
| 40 | * Check if the capture rules for async lambdas are enforced if the async attribute is set | ||
| 41 | * | ||
| 42 | * Only one capture with pointer type, pass-by-val is allowed, since only then we can store it in the second field of the | ||
| 43 | * fat pointer and can ensure, that no stack variable is referenced inside the lambda. | ||
| 44 | * | ||
| 45 | * @param node Lambda base node | ||
| 46 | * @param attrs Lambda attributes | ||
| 47 | * @return False if the rules are violated, true otherwise | ||
| 48 | */ | ||
| 49 | 195 | bool TypeChecker::checkAsyncLambdaCaptureRules(const LambdaBaseNode *node, const LambdaAttrNode *attrs) const { | |
| 50 | // If the async attribute is not set, we can return early | ||
| 51 |
18/32✓ Branch 2 → 3 taken 16 times.
✓ Branch 2 → 13 taken 179 times.
✓ Branch 5 → 6 taken 16 times.
✗ Branch 5 → 53 not taken.
✓ Branch 6 → 7 taken 16 times.
✗ Branch 6 → 53 not taken.
✓ Branch 7 → 8 taken 16 times.
✗ Branch 7 → 13 not taken.
✓ Branch 10 → 11 taken 16 times.
✗ Branch 10 → 53 not taken.
✓ Branch 11 → 12 taken 16 times.
✗ Branch 11 → 53 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 16 times.
✓ Branch 15 → 16 taken 16 times.
✓ Branch 15 → 17 taken 179 times.
✓ Branch 17 → 18 taken 16 times.
✓ Branch 17 → 20 taken 179 times.
✓ Branch 20 → 21 taken 16 times.
✓ Branch 20 → 22 taken 179 times.
✓ Branch 22 → 23 taken 16 times.
✓ Branch 22 → 25 taken 179 times.
✓ Branch 25 → 26 taken 179 times.
✓ Branch 25 → 27 taken 16 times.
✗ Branch 53 → 54 not taken.
✗ Branch 53 → 55 not taken.
✗ Branch 57 → 58 not taken.
✗ Branch 57 → 60 not taken.
✗ Branch 62 → 63 not taken.
✗ Branch 62 → 64 not taken.
✗ Branch 66 → 67 not taken.
✗ Branch 66 → 69 not taken.
|
259 | if (!attrs || !attrs->attrLst->hasAttr(ATTR_ASYNC) || !attrs->attrLst->getAttrValueByName(ATTR_ASYNC)->boolValue) |
| 52 | 179 | return true; // Not violated | |
| 53 | |||
| 54 | // If we don't have any captures, we can return early | ||
| 55 | 16 | const CaptureMap &captures = node->bodyScope->symbolTable.captures; | |
| 56 |
1/2✗ Branch 28 → 29 not taken.
✓ Branch 28 → 30 taken 16 times.
|
16 | if (captures.empty()) |
| 57 | ✗ | return true; // Not violated | |
| 58 | |||
| 59 | // Check for the capture rules | ||
| 60 | 16 | if (const Capture &capture = captures.begin()->second; | |
| 61 |
8/8✓ Branch 33 → 34 taken 10 times.
✓ Branch 33 → 39 taken 6 times.
✓ Branch 36 → 37 taken 6 times.
✓ Branch 36 → 39 taken 4 times.
✓ Branch 38 → 39 taken 2 times.
✓ Branch 38 → 40 taken 4 times.
✓ Branch 41 → 42 taken 12 times.
✓ Branch 41 → 51 taken 4 times.
|
16 | captures.size() > 1 || !capture.capturedSymbol->getQualType().isPtr() || capture.getMode() != BY_VALUE) { |
| 62 | 12 | const auto warningMessage = | |
| 63 | "Async lambdas can only capture one pointer by value without storing captures in the caller stack frame, which can lead " | ||
| 64 | "to bugs due to references, outliving the validity scope of the referenced variable."; | ||
| 65 |
2/4✓ Branch 44 → 45 taken 12 times.
✗ Branch 44 → 73 not taken.
✓ Branch 45 → 46 taken 12 times.
✗ Branch 45 → 71 not taken.
|
24 | const CompilerWarning warning(node->codeLoc, ASYNC_LAMBDA_CAPTURE_RULE_VIOLATION, warningMessage); |
| 66 |
1/2✓ Branch 48 → 49 taken 12 times.
✗ Branch 48 → 77 not taken.
|
12 | currentScope->sourceFile->compilerOutput.warnings.push_back(warning); |
| 67 | 12 | } | |
| 68 | |||
| 69 | 16 | return false; // Violated | |
| 70 | } | ||
| 71 | |||
| 72 | 94 | Function *TypeChecker::matchCopyCtor(const QualType &thisType, const ASTNode *node) const { | |
| 73 |
1/2✓ Branch 2 → 3 taken 94 times.
✗ Branch 2 → 42 not taken.
|
94 | Scope *matchScope = thisType.getBodyScope(); |
| 74 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 94 times.
|
94 | assert(matchScope != nullptr); |
| 75 |
2/4✓ Branch 5 → 6 taken 94 times.
✗ Branch 5 → 28 not taken.
✓ Branch 9 → 10 taken 94 times.
✗ Branch 9 → 24 not taken.
|
188 | const ArgList args = {{thisType.toConstRef(node), false}}; |
| 76 | // The new instance being constructed is never const, regardless of whether the copy source (thisType) is const | ||
| 77 |
3/6✓ Branch 12 → 13 taken 94 times.
✗ Branch 12 → 36 not taken.
✓ Branch 15 → 16 taken 94 times.
✗ Branch 15 → 32 not taken.
✓ Branch 16 → 17 taken 94 times.
✗ Branch 16 → 30 not taken.
|
376 | return FunctionManager::match(matchScope, CTOR_FUNCTION_NAME, thisType.toNonConst(), args, {}, true, node); |
| 78 | 94 | } | |
| 79 | |||
| 80 | ✗ | Function *TypeChecker::matchMoveCtor(const QualType &thisType, const ASTNode *node) const { | |
| 81 | ✗ | Scope *matchScope = thisType.getBodyScope(); | |
| 82 | ✗ | assert(matchScope != nullptr); | |
| 83 | ✗ | const ArgList args = {{thisType.toNonConst().toRef(node), false}}; | |
| 84 | // The new instance being constructed is never const, regardless of whether the move source (thisType) is const | ||
| 85 | ✗ | return FunctionManager::match(matchScope, CTOR_FUNCTION_NAME, thisType.toNonConst(), args, {}, true, node); | |
| 86 | ✗ | } | |
| 87 | |||
| 88 | 2019767 | QualType TypeChecker::mapLocalTypeToImportedScopeType(const Scope *targetScope, const QualType &symbolType) const { | |
| 89 | // Skip all types, except structs | ||
| 90 |
3/4✓ Branch 2 → 3 taken 2019767 times.
✗ Branch 2 → 62 not taken.
✓ Branch 3 → 4 taken 1716417 times.
✓ Branch 3 → 5 taken 303350 times.
|
2019767 | if (!symbolType.isBase(TY_STRUCT)) |
| 91 | 1716417 | return symbolType; | |
| 92 | |||
| 93 | // If the target scope is in the current source file, we can return the symbol type as is | ||
| 94 | 303350 | SourceFile *targetSourceFile = targetScope->sourceFile; | |
| 95 |
2/2✓ Branch 5 → 6 taken 58114 times.
✓ Branch 5 → 7 taken 245236 times.
|
303350 | if (targetSourceFile == sourceFile) |
| 96 | 58114 | return symbolType; | |
| 97 | |||
| 98 | // Match the scope of the symbol type against all scopes in the name registry of the target file | ||
| 99 |
5/8✓ Branch 7 → 8 taken 245236 times.
✗ Branch 7 → 58 not taken.
✓ Branch 8 → 9 taken 245236 times.
✗ Branch 8 → 58 not taken.
✓ Branch 9 → 10 taken 245236 times.
✗ Branch 9 → 58 not taken.
✓ Branch 41 → 11 taken 32470870 times.
✓ Branch 41 → 42 taken 22485 times.
|
32493355 | for (const NameRegistryEntry &entry : targetSourceFile->exportedNameRegistry | std::views::values) |
| 100 |
7/10✓ Branch 12 → 13 taken 32470870 times.
✗ Branch 12 → 17 not taken.
✓ Branch 13 → 14 taken 32470870 times.
✗ Branch 13 → 58 not taken.
✓ Branch 14 → 15 taken 32470870 times.
✗ Branch 14 → 58 not taken.
✓ Branch 15 → 16 taken 4677609 times.
✓ Branch 15 → 17 taken 27793261 times.
✓ Branch 18 → 19 taken 4677609 times.
✓ Branch 18 → 39 taken 27793261 times.
|
32470870 | if (entry.targetEntry != nullptr && entry.targetEntry->getQualType().isBase(TY_STRUCT)) |
| 101 |
3/4✓ Branch 19 → 20 taken 4677609 times.
✗ Branch 19 → 57 not taken.
✓ Branch 37 → 22 taken 6512430 times.
✓ Branch 37 → 38 taken 4454858 times.
|
15644897 | for (const Struct *manifestation : *entry.targetEntry->declNode->getStructManifestations()) |
| 102 |
4/6✓ Branch 24 → 25 taken 6512430 times.
✗ Branch 24 → 56 not taken.
✓ Branch 25 → 26 taken 6512430 times.
✗ Branch 25 → 56 not taken.
✓ Branch 26 → 27 taken 222751 times.
✓ Branch 26 → 28 taken 6289679 times.
|
6512430 | if (manifestation->scope == symbolType.getBase().getBodyScope()) |
| 103 | 222751 | return symbolType; | |
| 104 | |||
| 105 | // The target file does not know about the struct at all | ||
| 106 | // -> show it how to find the struct | ||
| 107 |
3/6✓ Branch 42 → 43 taken 22485 times.
✗ Branch 42 → 59 not taken.
✓ Branch 43 → 44 taken 22485 times.
✗ Branch 43 → 59 not taken.
✓ Branch 44 → 45 taken 22485 times.
✗ Branch 44 → 59 not taken.
|
22485 | const std::string structName = symbolType.getBase().getSubType(); |
| 108 |
1/2✓ Branch 45 → 46 taken 22485 times.
✗ Branch 45 → 60 not taken.
|
22485 | const NameRegistryEntry *origRegistryEntry = sourceFile->getNameRegistryEntry(structName); |
| 109 | // If even this file does not know the struct by its unqualified name (deep transitive import), there is | ||
| 110 | // nothing to copy over. Skip teaching the target file; the type identity itself is unaffected, and member | ||
| 111 | // access falls back to the resolved body scope. | ||
| 112 |
2/2✓ Branch 46 → 47 taken 102 times.
✓ Branch 46 → 48 taken 22383 times.
|
22485 | if (origRegistryEntry == nullptr) |
| 113 | 102 | return symbolType; | |
| 114 | // Do not clobber an entry the target file already has under this name (e.g. its OWN same-named struct, like | ||
| 115 | // llvm's `Function` vs the model's `Function`). Teaching uses keepNewOnCollision=false, which would otherwise | ||
| 116 | // ERASE the target's existing entry and break resolution of its own type. The struct's QualType identity is | ||
| 117 | // carried by pointer regardless, so a name that is already taken does not need (re-)teaching here. | ||
| 118 |
3/4✓ Branch 48 → 49 taken 22383 times.
✗ Branch 48 → 60 not taken.
✓ Branch 49 → 50 taken 7510 times.
✓ Branch 49 → 51 taken 14873 times.
|
22383 | if (targetSourceFile->exportedNameRegistry.contains(structName)) |
| 119 | 7510 | return symbolType; | |
| 120 | 14873 | const uint64_t targetTypeId = origRegistryEntry->typeId; | |
| 121 | 14873 | SymbolTableEntry *targetEntry = origRegistryEntry->targetEntry; | |
| 122 |
1/2✓ Branch 51 → 52 taken 14873 times.
✗ Branch 51 → 60 not taken.
|
14873 | targetSourceFile->addNameRegistryEntry(structName, targetTypeId, targetEntry, origRegistryEntry->targetScope, false); |
| 123 | |||
| 124 | 14873 | return symbolType; | |
| 125 | 22485 | } | |
| 126 | |||
| 127 | 50420 | QualType TypeChecker::mapImportedScopeTypeToLocalType(const Scope *sourceScope, const QualType &symbolType) const { | |
| 128 | // Skip all types, except structs | ||
| 129 |
3/4✓ Branch 2 → 3 taken 50420 times.
✗ Branch 2 → 57 not taken.
✓ Branch 3 → 4 taken 4348 times.
✓ Branch 3 → 5 taken 46072 times.
|
50420 | if (!symbolType.isBase(TY_STRUCT)) |
| 130 | 4348 | return symbolType; | |
| 131 | |||
| 132 | // If the given source file is in the current one, we can return the symbol type as is | ||
| 133 | 46072 | const SourceFile *sourceSourceFile = sourceScope->sourceFile; | |
| 134 |
2/2✓ Branch 5 → 6 taken 9607 times.
✓ Branch 5 → 7 taken 36465 times.
|
46072 | if (sourceSourceFile == sourceFile) |
| 135 | 9607 | return symbolType; | |
| 136 | |||
| 137 | // Match the scope of the symbol type against all scopes in the name registry of this source file | ||
| 138 |
1/2✓ Branch 7 → 8 taken 36465 times.
✗ Branch 7 → 57 not taken.
|
36465 | const QualType baseType = symbolType.getBase(); |
| 139 |
5/8✓ Branch 8 → 9 taken 36465 times.
✗ Branch 8 → 56 not taken.
✓ Branch 9 → 10 taken 36465 times.
✗ Branch 9 → 56 not taken.
✓ Branch 10 → 11 taken 36465 times.
✗ Branch 10 → 56 not taken.
✓ Branch 41 → 12 taken 6264565 times.
✓ Branch 41 → 42 taken 436 times.
|
6265001 | for (const auto &entry : sourceFile->exportedNameRegistry | std::views::values) |
| 140 |
7/10✓ Branch 13 → 14 taken 6264565 times.
✗ Branch 13 → 18 not taken.
✓ Branch 14 → 15 taken 6264565 times.
✗ Branch 14 → 56 not taken.
✓ Branch 15 → 16 taken 6264565 times.
✗ Branch 15 → 56 not taken.
✓ Branch 16 → 17 taken 1086451 times.
✓ Branch 16 → 18 taken 5178114 times.
✓ Branch 19 → 20 taken 1086451 times.
✓ Branch 19 → 39 taken 5178114 times.
|
6264565 | if (entry.targetEntry != nullptr && entry.targetEntry->getQualType().isBase(TY_STRUCT)) |
| 141 |
3/4✓ Branch 20 → 21 taken 1086451 times.
✗ Branch 20 → 55 not taken.
✓ Branch 37 → 23 taken 1222502 times.
✓ Branch 37 → 38 taken 1050422 times.
|
3359375 | for (const Struct *manifestation : *entry.targetEntry->declNode->getStructManifestations()) |
| 142 |
3/4✓ Branch 25 → 26 taken 1222502 times.
✗ Branch 25 → 55 not taken.
✓ Branch 26 → 27 taken 36029 times.
✓ Branch 26 → 28 taken 1186473 times.
|
1222502 | if (manifestation->scope == baseType.getBodyScope()) |
| 143 | 36029 | return symbolType; | |
| 144 | |||
| 145 | // This source file does not know about the struct at all | ||
| 146 | // -> show it how to find the struct | ||
| 147 |
2/4✓ Branch 42 → 43 taken 436 times.
✗ Branch 42 → 57 not taken.
✓ Branch 43 → 44 taken 436 times.
✗ Branch 43 → 57 not taken.
|
436 | const NameRegistryEntry *origRegistryEntry = sourceSourceFile->getNameRegistryEntry(baseType.getSubType()); |
| 148 | // If even the source file does not know the struct by its unqualified name (deep transitive import), there is | ||
| 149 | // nothing to copy over. Skip teaching this file; the type identity itself is unaffected, and member access | ||
| 150 | // falls back to the resolved body scope. | ||
| 151 |
1/2✗ Branch 44 → 45 not taken.
✓ Branch 44 → 46 taken 436 times.
|
436 | if (origRegistryEntry == nullptr) |
| 152 | ✗ | return symbolType; | |
| 153 | // Do not clobber an entry this file already has under this name (see mapLocalTypeToImportedScopeType): teaching | ||
| 154 | // with keepNewOnCollision=false would ERASE this file's own same-named struct entry. The QualType identity is | ||
| 155 | // carried by pointer, so an already-taken name needs no (re-)teaching here. | ||
| 156 |
4/6✓ Branch 46 → 47 taken 436 times.
✗ Branch 46 → 57 not taken.
✓ Branch 47 → 48 taken 436 times.
✗ Branch 47 → 57 not taken.
✓ Branch 48 → 49 taken 32 times.
✓ Branch 48 → 50 taken 404 times.
|
436 | if (sourceFile->exportedNameRegistry.contains(baseType.getSubType())) |
| 157 | 32 | return symbolType; | |
| 158 | 404 | const uint64_t typeId = origRegistryEntry->typeId; | |
| 159 | 404 | SymbolTableEntry *targetEntry = origRegistryEntry->targetEntry; | |
| 160 |
2/4✓ Branch 50 → 51 taken 404 times.
✗ Branch 50 → 57 not taken.
✓ Branch 51 → 52 taken 404 times.
✗ Branch 51 → 57 not taken.
|
404 | sourceFile->addNameRegistryEntry(baseType.getSubType(), typeId, targetEntry, origRegistryEntry->targetScope, false); |
| 161 | |||
| 162 | 404 | return symbolType; | |
| 163 | } | ||
| 164 | |||
| 165 | /** | ||
| 166 | * Returns the operator function list for the current manifestation and the given node | ||
| 167 | * | ||
| 168 | * @param node Node to retrieve the op fct pointer list from | ||
| 169 | * @return Op fct pointer list | ||
| 170 | */ | ||
| 171 | 12674 | std::vector<const Function *> &TypeChecker::getOpFctPointers(ASTNode *node) const { | |
| 172 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 12674 times.
|
12674 | assert(node->getOpFctPointers()->size() > manIdx); |
| 173 | 12674 | return node->getOpFctPointers()->at(manIdx); | |
| 174 | } | ||
| 175 | |||
| 176 | /** | ||
| 177 | * Check if a function has been type-checked already. If not, request a revisit | ||
| 178 | * | ||
| 179 | * @param fct Function to check | ||
| 180 | */ | ||
| 181 | 224537 | void TypeChecker::requestRevisitIfRequired(const Function *fct) { | |
| 182 |
4/4✓ Branch 2 → 3 taken 222951 times.
✓ Branch 2 → 5 taken 1586 times.
✓ Branch 3 → 4 taken 145389 times.
✓ Branch 3 → 5 taken 77562 times.
|
224537 | if (fct && !fct->alreadyTypeChecked) |
| 183 | 145389 | fct->entry->scope->sourceFile->reVisitRequested = true; | |
| 184 | 224537 | } | |
| 185 | |||
| 186 | /** | ||
| 187 | * Check type name against well-known type names that require a runtime import. If found one, auto-import the runtime module. | ||
| 188 | * | ||
| 189 | * @param typeName Given type name | ||
| 190 | */ | ||
| 191 | 285530 | void TypeChecker::ensureLoadedRuntimeForTypeName(const std::string &typeName) const { | |
| 192 |
2/2✓ Branch 18 → 4 taken 838505 times.
✓ Branch 18 → 19 taken 260741 times.
|
1099246 | for (const auto &[wellKnownTypeName, runtimeModule] : TYPE_NAME_TO_RT_MODULE_MAPPING) { |
| 193 |
8/10✓ Branch 7 → 8 taken 838505 times.
✗ Branch 7 → 20 not taken.
✓ Branch 8 → 9 taken 44445 times.
✓ Branch 8 → 12 taken 794060 times.
✓ Branch 9 → 10 taken 44445 times.
✗ Branch 9 → 20 not taken.
✓ Branch 10 → 11 taken 24789 times.
✓ Branch 10 → 12 taken 19656 times.
✓ Branch 13 → 14 taken 24789 times.
✓ Branch 13 → 16 taken 813716 times.
|
838505 | if (typeName == wellKnownTypeName && !sourceFile->isRT(runtimeModule)) { |
| 194 |
1/2✓ Branch 14 → 15 taken 24789 times.
✗ Branch 14 → 20 not taken.
|
24789 | sourceFile->requestRuntimeModule(runtimeModule); |
| 195 | 24789 | break; | |
| 196 | } | ||
| 197 | } | ||
| 198 | 285530 | } | |
| 199 | |||
| 200 | /** | ||
| 201 | * Check type name against well-known function names that require a runtime import. If found one, auto-import the runtime module. | ||
| 202 | * | ||
| 203 | * @param functionName Given function name | ||
| 204 | */ | ||
| 205 | 69404 | void TypeChecker::ensureLoadedRuntimeForFunctionName(const std::string &functionName) const { | |
| 206 |
2/2✓ Branch 18 → 4 taken 1121134 times.
✓ Branch 18 → 19 taken 62364 times.
|
1183498 | for (const auto &[wellKnownFunctionName, runtimeModule] : FCT_NAME_TO_RT_MODULE_MAPPING) { |
| 207 |
8/10✓ Branch 7 → 8 taken 1121134 times.
✗ Branch 7 → 20 not taken.
✓ Branch 8 → 9 taken 7176 times.
✓ Branch 8 → 12 taken 1113958 times.
✓ Branch 9 → 10 taken 7176 times.
✗ Branch 9 → 20 not taken.
✓ Branch 10 → 11 taken 7040 times.
✓ Branch 10 → 12 taken 136 times.
✓ Branch 13 → 14 taken 7040 times.
✓ Branch 13 → 16 taken 1114094 times.
|
1121134 | if (functionName == wellKnownFunctionName && !sourceFile->isRT(runtimeModule)) { |
| 208 |
1/2✓ Branch 14 → 15 taken 7040 times.
✗ Branch 14 → 20 not taken.
|
7040 | sourceFile->requestRuntimeModule(runtimeModule); |
| 209 | 7040 | break; | |
| 210 | } | ||
| 211 | } | ||
| 212 | 69404 | } | |
| 213 | |||
| 214 | /** | ||
| 215 | * Add a soft error to the error list | ||
| 216 | */ | ||
| 217 | 56 | void TypeChecker::softError(const ASTNode *node, const SemanticErrorType errorType, const std::string &message) const { | |
| 218 | 56 | resourceManager.errorManager.addSoftError(node, errorType, message); | |
| 219 | 56 | } | |
| 220 | |||
| 221 | 70 | bool TypeChecker::isCopyCtorCall(const FctCallNode *node, const QualType &thisType) const { | |
| 222 |
1/2✓ Branch 2 → 3 taken 70 times.
✗ Branch 2 → 14 not taken.
|
70 | const FctCallNode::FctCallData &data = node->data.at(manIdx); |
| 223 |
2/2✓ Branch 4 → 5 taken 4 times.
✓ Branch 4 → 6 taken 66 times.
|
70 | if (data.args.size() != 2) |
| 224 | 4 | return false; | |
| 225 |
2/4✓ Branch 7 → 8 taken 66 times.
✗ Branch 7 → 13 not taken.
✓ Branch 8 → 9 taken 66 times.
✗ Branch 8 → 13 not taken.
|
66 | const QualType &secondArgType = data.args.back().first.removeReferenceWrapper().toNonConst(); |
| 226 |
1/2✓ Branch 9 → 10 taken 66 times.
✗ Branch 9 → 14 not taken.
|
66 | return thisType.matches(secondArgType, false, false, true); |
| 227 | } | ||
| 228 | |||
| 229 | } // namespace spice::compiler | ||
| 230 |