src/importcollector/ImportCollector.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright (c) 2021-2026 ChilliBits. All rights reserved. | ||
| 2 | |||
| 3 | #include "ImportCollector.h" | ||
| 4 | |||
| 5 | #include <algorithm> | ||
| 6 | |||
| 7 | #include <SourceFile.h> | ||
| 8 | #include <ast/ASTNodes.h> | ||
| 9 | #include <ast/Attributes.h> | ||
| 10 | #include <driver/Driver.h> | ||
| 11 | #include <exception/SemanticError.h> | ||
| 12 | #include <global/GlobalResourceManager.h> | ||
| 13 | #include <symboltablebuilder/Scope.h> | ||
| 14 | #include <util/SystemUtil.h> | ||
| 15 | |||
| 16 | namespace spice::compiler { | ||
| 17 | |||
| 18 | 6091 | std::any ImportCollector::visitEntry(EntryNode *node) { | |
| 19 | // Visit all module attributes | ||
| 20 |
2/2✓ Branch 17 → 4 taken 2152 times.
✓ Branch 17 → 18 taken 6091 times.
|
14334 | for (ModAttrNode *attr : node->modAttrs) |
| 21 |
1/2✓ Branch 6 → 7 taken 2152 times.
✗ Branch 6 → 38 not taken.
|
2152 | visit(attr); |
| 22 | |||
| 23 | // Visit all import defs | ||
| 24 |
2/2✓ Branch 33 → 20 taken 5912 times.
✓ Branch 33 → 34 taken 6079 times.
|
18082 | for (ImportDefNode *importDef : node->importDefs) |
| 25 |
2/2✓ Branch 22 → 23 taken 5900 times.
✓ Branch 22 → 40 taken 12 times.
|
5912 | visit(importDef); |
| 26 | |||
| 27 |
1/2✓ Branch 34 → 35 taken 6079 times.
✗ Branch 34 → 42 not taken.
|
12158 | return nullptr; |
| 28 | } | ||
| 29 | |||
| 30 | 5912 | std::any ImportCollector::visitImportDef(ImportDefNode *node) { | |
| 31 | // Validate the import path before resolving it against any base directory. Import paths must be relative and must | ||
| 32 | // not contain parent-directory ('..') components. Otherwise a malicious source file could escape the std/bootstrap/ | ||
| 33 | // project roots (e.g. 'import "../../../etc/x"' or 'import "std/../../../etc/x"') and read arbitrary files, or worse, | ||
| 34 | // smuggle shell metacharacters into a filename that later ends up in a linker invocation. | ||
| 35 |
1/2✓ Branch 2 → 3 taken 5912 times.
✗ Branch 2 → 439 not taken.
|
5912 | const std::filesystem::path importPathRelative(node->importPath); |
| 36 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 12 taken 5912 times.
|
5912 | if (importPathRelative.has_root_path()) |
| 37 | ✗ | throw SemanticError(node, INVALID_IMPORT_PATH, "Import paths must be relative, but '" + node->importPath + "' is not"); | |
| 38 |
2/2✓ Branch 28 → 14 taken 17574 times.
✓ Branch 28 → 29 taken 5910 times.
|
23484 | for (const std::filesystem::path &part : importPathRelative) |
| 39 |
3/4✓ Branch 15 → 16 taken 17574 times.
✗ Branch 15 → 255 not taken.
✓ Branch 18 → 19 taken 2 times.
✓ Branch 18 → 26 taken 17572 times.
|
17574 | if (part == "..") |
| 40 | ✗ | throw SemanticError(node, INVALID_IMPORT_PATH, | |
| 41 |
3/6✓ Branch 20 → 21 taken 2 times.
✗ Branch 20 → 261 not taken.
✓ Branch 21 → 22 taken 2 times.
✗ Branch 21 → 259 not taken.
✓ Branch 22 → 23 taken 2 times.
✗ Branch 22 → 256 not taken.
|
2 | "Import paths must not contain parent-directory ('..') components: '" + node->importPath + "'"); |
| 42 | |||
| 43 | 5910 | const bool isStd = node->importPath.starts_with("std/"); | |
| 44 | 5910 | const bool isBootstrap = node->importPath.starts_with("bootstrap/"); | |
| 45 | |||
| 46 | 5910 | std::filesystem::path basePath; | |
| 47 |
2/2✓ Branch 32 → 33 taken 4169 times.
✓ Branch 32 → 44 taken 1741 times.
|
5910 | if (isStd) { // Include source file from standard library |
| 48 | // Find std library | ||
| 49 |
1/2✓ Branch 33 → 34 taken 4169 times.
✗ Branch 33 → 275 not taken.
|
4169 | const std::filesystem::path stdPath = SystemUtil::getStdDir(); |
| 50 | // Format: /dir/to/path/file | ||
| 51 |
3/6✓ Branch 35 → 36 taken 4169 times.
✗ Branch 35 → 270 not taken.
✓ Branch 36 → 37 taken 4169 times.
✗ Branch 36 → 268 not taken.
✓ Branch 37 → 38 taken 4169 times.
✗ Branch 37 → 266 not taken.
|
4169 | basePath = stdPath / node->importPath.substr(node->importPath.find("std/") + 4); |
| 52 |
2/2✓ Branch 44 → 45 taken 1594 times.
✓ Branch 44 → 56 taken 147 times.
|
5910 | } else if (isBootstrap) { // Include source file from bootstrap library |
| 53 | // Find bootstrap library | ||
| 54 |
1/2✓ Branch 45 → 46 taken 1594 times.
✗ Branch 45 → 285 not taken.
|
1594 | const std::filesystem::path bootstrapPath = SystemUtil::getBootstrapDir(); |
| 55 | // Format: /dir/to/path/file | ||
| 56 |
3/6✓ Branch 47 → 48 taken 1594 times.
✗ Branch 47 → 280 not taken.
✓ Branch 48 → 49 taken 1594 times.
✗ Branch 48 → 278 not taken.
✓ Branch 49 → 50 taken 1594 times.
✗ Branch 49 → 276 not taken.
|
1594 | basePath = bootstrapPath / node->importPath.substr(node->importPath.find("bootstrap/") + 10); |
| 57 | 1594 | } else { // Include own source file | |
| 58 | // Format: /dir/to/path/file | ||
| 59 |
3/6✓ Branch 56 → 57 taken 147 times.
✗ Branch 56 → 291 not taken.
✓ Branch 57 → 58 taken 147 times.
✗ Branch 57 → 288 not taken.
✓ Branch 58 → 59 taken 147 times.
✗ Branch 58 → 286 not taken.
|
147 | basePath = sourceFile->filePath.parent_path() / node->importPath; |
| 60 | } | ||
| 61 | 5910 | basePath.make_preferred(); | |
| 62 | |||
| 63 |
2/4✓ Branch 66 → 67 taken 5910 times.
✗ Branch 66 → 293 not taken.
✓ Branch 67 → 68 taken 5910 times.
✗ Branch 67 → 293 not taken.
|
5910 | const std::string osName = cliOptions.targetTriple.getOSTypeName(cliOptions.targetTriple.getOS()).str(); |
| 64 |
2/4✓ Branch 69 → 70 taken 5910 times.
✗ Branch 69 → 294 not taken.
✓ Branch 70 → 71 taken 5910 times.
✗ Branch 70 → 294 not taken.
|
5910 | const std::string archName = cliOptions.targetTriple.getArchTypeName(cliOptions.targetTriple.getArch()).str(); |
| 65 | |||
| 66 | // Format: /dir/to/path/file.spice | ||
| 67 |
1/2✓ Branch 71 → 72 taken 5910 times.
✗ Branch 71 → 431 not taken.
|
5910 | std::filesystem::path defaultPath = basePath; |
| 68 |
5/10✓ Branch 72 → 73 taken 5910 times.
✗ Branch 72 → 303 not taken.
✓ Branch 73 → 74 taken 5910 times.
✗ Branch 73 → 301 not taken.
✓ Branch 74 → 75 taken 5910 times.
✗ Branch 74 → 299 not taken.
✓ Branch 75 → 76 taken 5910 times.
✗ Branch 75 → 297 not taken.
✓ Branch 76 → 77 taken 5910 times.
✗ Branch 76 → 295 not taken.
|
5910 | defaultPath.replace_filename(basePath.stem().string() + ".spice"); |
| 69 | // Format: /dir/to/path/file_linux.spice | ||
| 70 |
1/2✓ Branch 81 → 82 taken 5910 times.
✗ Branch 81 → 429 not taken.
|
5910 | std::filesystem::path osPath = basePath; |
| 71 |
7/14✓ Branch 82 → 83 taken 5910 times.
✗ Branch 82 → 319 not taken.
✓ Branch 83 → 84 taken 5910 times.
✗ Branch 83 → 317 not taken.
✓ Branch 84 → 85 taken 5910 times.
✗ Branch 84 → 315 not taken.
✓ Branch 85 → 86 taken 5910 times.
✗ Branch 85 → 313 not taken.
✓ Branch 86 → 87 taken 5910 times.
✗ Branch 86 → 311 not taken.
✓ Branch 87 → 88 taken 5910 times.
✗ Branch 87 → 309 not taken.
✓ Branch 88 → 89 taken 5910 times.
✗ Branch 88 → 307 not taken.
|
5910 | osPath.replace_filename(basePath.stem().string() + "_" + osName + ".spice"); |
| 72 | // Format: /dir/to/path/file_linux_x86_64.spice | ||
| 73 |
1/2✓ Branch 95 → 96 taken 5910 times.
✗ Branch 95 → 427 not taken.
|
5910 | std::filesystem::path osArchPath = basePath; |
| 74 |
9/18✓ Branch 96 → 97 taken 5910 times.
✗ Branch 96 → 341 not taken.
✓ Branch 97 → 98 taken 5910 times.
✗ Branch 97 → 339 not taken.
✓ Branch 98 → 99 taken 5910 times.
✗ Branch 98 → 337 not taken.
✓ Branch 99 → 100 taken 5910 times.
✗ Branch 99 → 335 not taken.
✓ Branch 100 → 101 taken 5910 times.
✗ Branch 100 → 333 not taken.
✓ Branch 101 → 102 taken 5910 times.
✗ Branch 101 → 331 not taken.
✓ Branch 102 → 103 taken 5910 times.
✗ Branch 102 → 329 not taken.
✓ Branch 103 → 104 taken 5910 times.
✗ Branch 103 → 327 not taken.
✓ Branch 104 → 105 taken 5910 times.
✗ Branch 104 → 325 not taken.
|
5910 | osArchPath.replace_filename(basePath.stem().string() + "_" + osName + "_" + archName + ".spice"); |
| 75 | |||
| 76 | // Check which source file to import | ||
| 77 | 5910 | std::filesystem::path importPath; | |
| 78 |
7/10✓ Branch 114 → 115 taken 5910 times.
✗ Branch 114 → 423 not taken.
✓ Branch 115 → 116 taken 2 times.
✓ Branch 115 → 119 taken 5908 times.
✓ Branch 116 → 117 taken 2 times.
✗ Branch 116 → 423 not taken.
✓ Branch 117 → 118 taken 2 times.
✗ Branch 117 → 119 not taken.
✓ Branch 120 → 121 taken 2 times.
✓ Branch 120 → 122 taken 5908 times.
|
5910 | if (exists(osArchPath) && !equivalent(sourceFile->filePath, osArchPath)) { |
| 79 | // file_os_arch.spice is first choice | ||
| 80 |
1/2✓ Branch 121 → 185 taken 2 times.
✗ Branch 121 → 423 not taken.
|
2 | importPath = osArchPath; |
| 81 |
8/10✓ Branch 122 → 123 taken 5908 times.
✗ Branch 122 → 423 not taken.
✓ Branch 123 → 124 taken 78 times.
✓ Branch 123 → 127 taken 5830 times.
✓ Branch 124 → 125 taken 78 times.
✗ Branch 124 → 423 not taken.
✓ Branch 125 → 126 taken 76 times.
✓ Branch 125 → 127 taken 2 times.
✓ Branch 128 → 129 taken 76 times.
✓ Branch 128 → 130 taken 5832 times.
|
5908 | } else if (exists(osPath) && !equivalent(sourceFile->filePath, osPath)) { |
| 82 | // file_os.spice is second choice | ||
| 83 |
1/2✓ Branch 129 → 185 taken 76 times.
✗ Branch 129 → 423 not taken.
|
76 | importPath = osPath; |
| 84 |
3/4✓ Branch 130 → 131 taken 5832 times.
✗ Branch 130 → 423 not taken.
✓ Branch 131 → 132 taken 5828 times.
✓ Branch 131 → 133 taken 4 times.
|
5832 | } else if (exists(defaultPath)) { |
| 85 | // file.spice is third choice | ||
| 86 |
1/2✓ Branch 132 → 185 taken 5828 times.
✗ Branch 132 → 423 not taken.
|
5828 | importPath = defaultPath; |
| 87 | } else { | ||
| 88 | 4 | const bool obfuscate = cliOptions.comparableOutput; | |
| 89 |
6/18✓ Branch 133 → 134 taken 4 times.
✗ Branch 133 → 137 not taken.
✓ Branch 134 → 135 taken 4 times.
✗ Branch 134 → 349 not taken.
✓ Branch 135 → 136 taken 4 times.
✗ Branch 135 → 349 not taken.
✓ Branch 136 → 138 taken 4 times.
✗ Branch 136 → 349 not taken.
✗ Branch 137 → 138 not taken.
✗ Branch 137 → 349 not taken.
✓ Branch 138 → 139 taken 4 times.
✗ Branch 138 → 140 not taken.
✓ Branch 140 → 141 taken 4 times.
✗ Branch 140 → 142 not taken.
✗ Branch 349 → 350 not taken.
✗ Branch 349 → 351 not taken.
✗ Branch 353 → 354 not taken.
✗ Branch 353 → 355 not taken.
|
4 | const std::string osArchPathObfuscated = obfuscate ? osArchPath.stem().string() + ".spice" : osArchPath.generic_string(); |
| 90 |
6/18✓ Branch 142 → 143 taken 4 times.
✗ Branch 142 → 146 not taken.
✓ Branch 143 → 144 taken 4 times.
✗ Branch 143 → 357 not taken.
✓ Branch 144 → 145 taken 4 times.
✗ Branch 144 → 357 not taken.
✓ Branch 145 → 147 taken 4 times.
✗ Branch 145 → 357 not taken.
✗ Branch 146 → 147 not taken.
✗ Branch 146 → 357 not taken.
✓ Branch 147 → 148 taken 4 times.
✗ Branch 147 → 149 not taken.
✓ Branch 149 → 150 taken 4 times.
✗ Branch 149 → 151 not taken.
✗ Branch 357 → 358 not taken.
✗ Branch 357 → 359 not taken.
✗ Branch 361 → 362 not taken.
✗ Branch 361 → 363 not taken.
|
4 | const std::string osPathObfuscated = obfuscate ? osPath.stem().string() + ".spice" : osPath.generic_string(); |
| 91 |
6/18✓ Branch 151 → 152 taken 4 times.
✗ Branch 151 → 155 not taken.
✓ Branch 152 → 153 taken 4 times.
✗ Branch 152 → 365 not taken.
✓ Branch 153 → 154 taken 4 times.
✗ Branch 153 → 365 not taken.
✓ Branch 154 → 156 taken 4 times.
✗ Branch 154 → 365 not taken.
✗ Branch 155 → 156 not taken.
✗ Branch 155 → 365 not taken.
✓ Branch 156 → 157 taken 4 times.
✗ Branch 156 → 158 not taken.
✓ Branch 158 → 159 taken 4 times.
✗ Branch 158 → 160 not taken.
✗ Branch 365 → 366 not taken.
✗ Branch 365 → 367 not taken.
✗ Branch 369 → 370 not taken.
✗ Branch 369 → 371 not taken.
|
4 | const std::string defaultPathObfuscated = obfuscate ? defaultPath.stem().string() + ".spice" : defaultPath.generic_string(); |
| 92 | |||
| 93 |
1/2✓ Branch 160 → 161 taken 4 times.
✗ Branch 160 → 387 not taken.
|
4 | std::stringstream errorMessage; |
| 94 |
7/14✓ Branch 161 → 162 taken 4 times.
✗ Branch 161 → 385 not taken.
✓ Branch 162 → 163 taken 4 times.
✗ Branch 162 → 377 not taken.
✓ Branch 163 → 164 taken 4 times.
✗ Branch 163 → 375 not taken.
✓ Branch 164 → 165 taken 4 times.
✗ Branch 164 → 373 not taken.
✓ Branch 165 → 166 taken 4 times.
✗ Branch 165 → 373 not taken.
✓ Branch 166 → 167 taken 4 times.
✗ Branch 166 → 373 not taken.
✓ Branch 167 → 168 taken 4 times.
✗ Branch 167 → 373 not taken.
|
4 | errorMessage << "The source file '" << basePath.stem().string() << ".spice' was not found" << std::endl << std::endl; |
| 95 |
2/4✓ Branch 170 → 171 taken 4 times.
✗ Branch 170 → 385 not taken.
✓ Branch 171 → 172 taken 4 times.
✗ Branch 171 → 385 not taken.
|
4 | errorMessage << "The following paths were checked with descending priority:" << std::endl; |
| 96 |
3/6✓ Branch 172 → 173 taken 4 times.
✗ Branch 172 → 385 not taken.
✓ Branch 173 → 174 taken 4 times.
✗ Branch 173 → 385 not taken.
✓ Branch 174 → 175 taken 4 times.
✗ Branch 174 → 385 not taken.
|
4 | errorMessage << "- " << osArchPathObfuscated << std::endl; |
| 97 |
3/6✓ Branch 175 → 176 taken 4 times.
✗ Branch 175 → 385 not taken.
✓ Branch 176 → 177 taken 4 times.
✗ Branch 176 → 385 not taken.
✓ Branch 177 → 178 taken 4 times.
✗ Branch 177 → 385 not taken.
|
4 | errorMessage << "- " << osPathObfuscated << std::endl; |
| 98 |
2/4✓ Branch 178 → 179 taken 4 times.
✗ Branch 178 → 385 not taken.
✓ Branch 179 → 180 taken 4 times.
✗ Branch 179 → 385 not taken.
|
4 | errorMessage << "- " << defaultPathObfuscated; |
| 99 |
2/4✓ Branch 181 → 182 taken 4 times.
✗ Branch 181 → 382 not taken.
✓ Branch 182 → 183 taken 4 times.
✗ Branch 182 → 379 not taken.
|
4 | throw SemanticError(node, IMPORTED_FILE_NOT_EXISTING, errorMessage.str()); |
| 100 | 16 | } | |
| 101 | |||
| 102 | // The lexical '..'-component check above only rejects traversal spelled out in the import path itself. A | ||
| 103 | // same-looking relative import can still resolve outside the intended std/bootstrap/project root if a directory | ||
| 104 | // along the way is a symlink. Canonicalize the resolved file and its intended base directory (this also resolves | ||
| 105 | // symlinks) and reject the import unless the former stays contained in the latter. | ||
| 106 | // A main source file given as a bare filename (e.g. 'spice build main.spice') has an empty parent_path(); treat | ||
| 107 | // that as the current directory, since that is what the empty path already means to every other join above. | ||
| 108 |
1/2✓ Branch 185 → 186 taken 5906 times.
✗ Branch 185 → 423 not taken.
|
5906 | std::filesystem::path ownFileDir = sourceFile->filePath.parent_path(); |
| 109 |
1/2✗ Branch 187 → 188 not taken.
✓ Branch 187 → 189 taken 5906 times.
|
5906 | if (ownFileDir.empty()) |
| 110 | ✗ | ownFileDir = "."; | |
| 111 | 5906 | std::filesystem::path intendedRoot; | |
| 112 |
2/2✓ Branch 190 → 191 taken 4167 times.
✓ Branch 190 → 195 taken 1739 times.
|
5906 | if (isStd) |
| 113 |
1/2✓ Branch 191 → 192 taken 4167 times.
✗ Branch 191 → 394 not taken.
|
4167 | intendedRoot = SystemUtil::getStdDir(); |
| 114 |
2/2✓ Branch 195 → 196 taken 1594 times.
✓ Branch 195 → 200 taken 145 times.
|
1739 | else if (isBootstrap) |
| 115 |
1/2✓ Branch 196 → 197 taken 1594 times.
✗ Branch 196 → 395 not taken.
|
1594 | intendedRoot = SystemUtil::getBootstrapDir(); |
| 116 | else | ||
| 117 |
1/2✓ Branch 200 → 201 taken 145 times.
✗ Branch 200 → 419 not taken.
|
145 | intendedRoot = ownFileDir; |
| 118 |
1/2✓ Branch 201 → 202 taken 5906 times.
✗ Branch 201 → 419 not taken.
|
5906 | const std::filesystem::path allowedRoot = canonical(intendedRoot); |
| 119 |
1/2✓ Branch 202 → 203 taken 5906 times.
✗ Branch 202 → 417 not taken.
|
5906 | const std::filesystem::path canonicalImportPath = canonical(importPath); |
| 120 |
1/2✓ Branch 203 → 204 taken 5906 times.
✗ Branch 203 → 415 not taken.
|
5906 | const auto [in1, in2] = std::ranges::mismatch(allowedRoot, canonicalImportPath); |
| 121 |
2/2✓ Branch 206 → 207 taken 2 times.
✓ Branch 206 → 214 taken 5904 times.
|
5906 | if (in1 != allowedRoot.end()) |
| 122 |
3/6✓ Branch 208 → 209 taken 2 times.
✗ Branch 208 → 401 not taken.
✓ Branch 209 → 210 taken 2 times.
✗ Branch 209 → 399 not taken.
✓ Branch 210 → 211 taken 2 times.
✗ Branch 210 → 396 not taken.
|
2 | throw SemanticError(node, INVALID_IMPORT_PATH, "Import path '" + node->importPath + "' escapes the permitted directory tree"); |
| 123 | |||
| 124 | // Check if the import already exists | ||
| 125 |
3/4✓ Branch 214 → 215 taken 5904 times.
✗ Branch 214 → 415 not taken.
✓ Branch 217 → 218 taken 4 times.
✓ Branch 217 → 225 taken 5900 times.
|
11808 | if (rootScope->lookupStrict(node->importName) != nullptr) |
| 126 |
3/6✓ Branch 219 → 220 taken 4 times.
✗ Branch 219 → 410 not taken.
✓ Branch 220 → 221 taken 4 times.
✗ Branch 220 → 408 not taken.
✓ Branch 221 → 222 taken 4 times.
✗ Branch 221 → 405 not taken.
|
4 | throw SemanticError(node, DUPLICATE_IMPORT_NAME, "Duplicate import '" + node->importName + "'"); |
| 127 | |||
| 128 | // Create symbol for import | ||
| 129 |
1/2✓ Branch 225 → 226 taken 5900 times.
✗ Branch 225 → 415 not taken.
|
5900 | node->entry = rootScope->insert(node->importName, node); |
| 130 | |||
| 131 | // Create the imported source file | ||
| 132 |
1/2✓ Branch 228 → 229 taken 5900 times.
✗ Branch 228 → 415 not taken.
|
5900 | const auto importedSourceFile = resourceManager.createSourceFile(sourceFile, node->importName, importPath, isStd); |
| 133 | // Register it as a dependency to the current source file | ||
| 134 |
1/2✓ Branch 229 → 230 taken 5900 times.
✗ Branch 229 → 415 not taken.
|
5900 | sourceFile->addDependency(importedSourceFile, node->importName); |
| 135 | |||
| 136 |
1/2✓ Branch 230 → 231 taken 5900 times.
✗ Branch 230 → 414 not taken.
|
11800 | return nullptr; |
| 137 | 6006 | } | |
| 138 | |||
| 139 | 2152 | std::any ImportCollector::visitModAttr(ModAttrNode *node) { | |
| 140 | // !!! Only bool attributes allowed here, due to missing attribute value checks being executed in a later stage !!! | ||
| 141 | |||
| 142 | // core.compiler.keep-on-name-collision | ||
| 143 |
4/6✓ Branch 4 → 5 taken 2152 times.
✗ Branch 4 → 64 not taken.
✓ Branch 5 → 6 taken 2152 times.
✗ Branch 5 → 62 not taken.
✓ Branch 8 → 9 taken 2056 times.
✓ Branch 8 → 16 taken 96 times.
|
6456 | if (node->attrLst->hasAttr(ATTR_CORE_COMPILER_KEEP_ON_NAME_COLLISION)) { |
| 144 |
2/4✓ Branch 11 → 12 taken 2056 times.
✗ Branch 11 → 70 not taken.
✓ Branch 12 → 13 taken 2056 times.
✗ Branch 12 → 68 not taken.
|
4112 | const bool keepOnCollision = node->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_KEEP_ON_NAME_COLLISION)->boolValue; |
| 145 | 2056 | sourceFile->alwaysKeepSymbolsOnNameCollision = keepOnCollision; | |
| 146 | } | ||
| 147 | |||
| 148 | // core.compiler.warnings.ignore | ||
| 149 |
4/6✓ Branch 18 → 19 taken 2152 times.
✗ Branch 18 → 76 not taken.
✓ Branch 19 → 20 taken 2152 times.
✗ Branch 19 → 74 not taken.
✓ Branch 22 → 23 taken 30 times.
✓ Branch 22 → 30 taken 2122 times.
|
6456 | if (node->attrLst->hasAttr(ATTR_CORE_COMPILER_WARNINGS_IGNORE)) { |
| 150 |
2/4✓ Branch 25 → 26 taken 30 times.
✗ Branch 25 → 82 not taken.
✓ Branch 26 → 27 taken 30 times.
✗ Branch 26 → 80 not taken.
|
60 | const bool ignoreWarnings = node->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_WARNINGS_IGNORE)->boolValue; |
| 151 | 30 | sourceFile->ignoreWarnings = ignoreWarnings; | |
| 152 | } | ||
| 153 | |||
| 154 | // core.compiler.explicitErrorHandling | ||
| 155 |
4/6✓ Branch 32 → 33 taken 2152 times.
✗ Branch 32 → 88 not taken.
✓ Branch 33 → 34 taken 2152 times.
✗ Branch 33 → 86 not taken.
✓ Branch 36 → 37 taken 8 times.
✓ Branch 36 → 44 taken 2144 times.
|
6456 | if (node->attrLst->hasAttr(ATTR_CORE_COMPILER_EXPLICIT_ERROR_HANDLING)) { |
| 156 |
2/4✓ Branch 39 → 40 taken 8 times.
✗ Branch 39 → 94 not taken.
✓ Branch 40 → 41 taken 8 times.
✗ Branch 40 → 92 not taken.
|
16 | const bool explicitErrorHandling = node->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_EXPLICIT_ERROR_HANDLING)->boolValue; |
| 157 | 8 | sourceFile->explicitErrorHandling = explicitErrorHandling; | |
| 158 | } | ||
| 159 | |||
| 160 | // core.compiler.errorReturnTracing | ||
| 161 |
4/6✓ Branch 46 → 47 taken 2152 times.
✗ Branch 46 → 100 not taken.
✓ Branch 47 → 48 taken 2152 times.
✗ Branch 47 → 98 not taken.
✓ Branch 50 → 51 taken 10 times.
✓ Branch 50 → 58 taken 2142 times.
|
6456 | if (node->attrLst->hasAttr(ATTR_CORE_COMPILER_ERROR_RETURN_TRACING)) { |
| 162 |
2/4✓ Branch 53 → 54 taken 10 times.
✗ Branch 53 → 106 not taken.
✓ Branch 54 → 55 taken 10 times.
✗ Branch 54 → 104 not taken.
|
20 | const bool errorReturnTracing = node->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_ERROR_RETURN_TRACING)->boolValue; |
| 163 | 10 | sourceFile->errorReturnTracing = errorReturnTracing; | |
| 164 | } | ||
| 165 | |||
| 166 |
1/2✓ Branch 58 → 59 taken 2152 times.
✗ Branch 58 → 110 not taken.
|
4304 | return nullptr; |
| 167 | } | ||
| 168 | |||
| 169 | } // namespace spice::compiler | ||
| 170 |