GCC Code Coverage Report


Directory: ../
File: src/exception/ErrorManager.cpp
Date: 2024-11-22 23:10:59
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-2024 ChilliBits. All rights reserved.
2
3 #include "ErrorManager.h"
4
5 #include <ast/ASTNodes.h>
6
7 namespace spice::compiler {
8
9 121 void ErrorManager::addSoftError(const ASTNode *astNode, SemanticErrorType errorType, const std::string &message) {
10 // Build error message
11
1/2
✓ Branch 1 taken 121 times.
✗ Branch 2 not taken.
121 const SemanticError semanticError(astNode, errorType, message);
12 // Add to soft errors list
13
2/4
✓ Branch 2 taken 121 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 121 times.
✗ Branch 6 not taken.
121 addSoftError(astNode->codeLoc, semanticError.what());
14 121 }
15
16 121 void ErrorManager::addSoftError(const CodeLoc &codeLoc, const std::string &message) {
17 // Avoid duplicate errors
18
2/2
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 111 times.
132 for (const auto &[errorLoc, message] : softErrors)
19
3/4
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 11 times.
21 if (errorLoc == codeLoc)
20 10 return;
21
2/4
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 softErrors.emplace_back(SoftError{codeLoc, message});
22 }
23
24 } // namespace spice::compiler
25