GCC Code Coverage Report


Directory: src/
File: src/analysis/analysis-type-resolution.cpp
Date: 2025-10-15 09:43:47
Exec Total Coverage
Lines: 14 22 63.6%
Functions: 3 4 75.0%
Branches: 7 8 87.5%

Line Branch Exec Source
1 #include <gyoji-analysis.hpp>
2 #include <stdio.h>
3
4 using namespace Gyoji::mir;
5 using namespace Gyoji::context;
6 using namespace Gyoji::analysis;
7
8 30 AnalysisPassTypeResolution::AnalysisPassTypeResolution(CompilerContext & _compiler_context)
9 60 : AnalysisPass(_compiler_context, "type resolution")
10 30 {}
11 AnalysisPassTypeResolution::~AnalysisPassTypeResolution()
12 {}
13
14 void
15 30 AnalysisPassTypeResolution::check(const MIR & mir) const
16 {
17 // TODO: Go back through all of the types and make sure that every type
18 // that is used in a structure 'inline' is actually complete.
19 // If not, produce a compile error to that effect.
20 // This needs to be recursive!
21
2/2
✓ Branch 7 taken 548 times.
✓ Branch 8 taken 30 times.
578 for (const auto & type_it : mir.get_types().get_types()) {
22 548 const Type & type = *type_it.second;
23 548 check_type(type);
24 }
25 30 }
26
27 void
28 558 AnalysisPassTypeResolution::check_type(const Type & type) const
29 {
30
2/2
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 554 times.
558 if (type.get_type() == Type::TYPE_COMPOSITE) {
31
2/2
✓ Branch 6 taken 10 times.
✓ Branch 7 taken 4 times.
14 for (const auto & member : type.get_members()) {
32
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if (!member.get_type()->is_complete()) {
33 std::unique_ptr<Gyoji::context::Error> error = std::make_unique<Gyoji::context::Error>("Class contains incomplete type");
34 error->add_message(member.get_source_ref(),
35 std::string("Incomplete type in member ") + member.get_name() + std::string(" of type ") + type.get_name());
36 error->add_message(member.get_type()->get_declared_source_ref(),
37 "Forward declaration is here.");
38 get_compiler_context().get_errors().add_error(std::move(error));
39 }
40 10 check_type(*member.get_type());
41 }
42 }
43 558 }
44
45
46