GCC Code Coverage Report


Directory: ../
File: src/exception/ErrorManager.cpp
Date: 2025-02-05 01:09:36
Exec Total Coverage
Lines: 9 9 100.0%
Functions: 2 2 100.0%
Branches: 10 16 62.5%

Line Branch Exec Source
1 // Copyright (c) 2021-2025 ChilliBits. All rights reserved.
2
3 #include "ErrorManager.h"
4
5 #include <ast/ASTNodes.h>
6
7 namespace spice::compiler {
8
9 136 void ErrorManager::addSoftError(const ASTNode *astNode, SemanticErrorType errorType, const std::string &message) {
10 // Build error message
11
1/2
✓ Branch 0 (2→3) taken 136 times.
✗ Branch 1 (2→20) not taken.
136 const SemanticError semanticError(astNode, errorType, message);
12 // Add to soft errors list
13
2/4
✓ Branch 0 (6→7) taken 136 times.
✗ Branch 1 (6→14) not taken.
✓ Branch 2 (7→8) taken 136 times.
✗ Branch 3 (7→12) not taken.
136 addSoftError(astNode->codeLoc, semanticError.what());
14 136 }
15
16 136 void ErrorManager::addSoftError(const CodeLoc &codeLoc, const std::string &message) {
17 // Avoid duplicate errors
18
2/2
✓ Branch 0 (10→4) taken 99 times.
✓ Branch 1 (10→11) taken 126 times.
225 for (const auto &[errorLoc, message] : softErrors)
19
3/4
✓ Branch 0 (5→6) taken 99 times.
✗ Branch 1 (5→16) not taken.
✓ Branch 2 (6→7) taken 10 times.
✓ Branch 3 (6→8) taken 89 times.
99 if (errorLoc == codeLoc)
20 10 return;
21
2/4
✓ Branch 0 (11→12) taken 126 times.
✗ Branch 1 (11→19) not taken.
✓ Branch 2 (12→13) taken 126 times.
✗ Branch 3 (12→17) not taken.
126 softErrors.emplace_back(SoftError{codeLoc, message});
22 }
23
24 } // namespace spice::compiler
25