• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daisytuner / sdfglib / 21475859063

29 Jan 2026 11:10AM UTC coverage: 66.34% (+0.5%) from 65.843%
21475859063

Pull #481

github

web-flow
Merge f2b89efe1 into a924afda9
Pull Request #481: Refactor cutout

100 of 187 new or added lines in 8 files covered. (53.48%)

3 existing lines in 3 files now uncovered.

22687 of 34198 relevant lines covered (66.34%)

383.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.18
/sdfg/src/control_flow/interstate_edge.cpp
1
#include "sdfg/control_flow/interstate_edge.h"
2

3
#include "sdfg/codegen/utils.h"
4
#include "sdfg/function.h"
5

6
namespace sdfg {
7
namespace control_flow {
8

9
InterstateEdge::InterstateEdge(
10
    size_t element_id,
11
    const DebugInfo& debug_info,
12
    const graph::Edge& edge,
13
    const control_flow::State& src,
14
    const control_flow::State& dst,
15
    const symbolic::Condition condition,
16
    const sdfg::control_flow::Assignments& assignments
17
)
18
    : Element(element_id, debug_info), edge_(edge), src_(src), dst_(dst), condition_(condition),
166✔
19
      assignments_(assignments) {
166✔
20

21
      };
166✔
22

23
void InterstateEdge::validate(const Function& function) const {
9✔
24
    for (auto& entry : this->assignments_) {
9✔
25
        auto& lhs = entry.first;
6✔
26
        auto& type = function.type(lhs->get_name());
6✔
27
        if (type.type_id() == types::TypeID::Scalar) {
6✔
28
            if (!types::is_integer(type.primitive_type())) {
6✔
NEW
29
                throw InvalidSDFGException("Assignment - LHS: must be integer type");
×
NEW
30
            }
×
31
        } else if (type.type_id() == types::TypeID::Reference) {
6✔
NEW
32
            auto* reference = dynamic_cast<const sdfg::codegen::Reference*>(&type);
×
NEW
33
            assert(reference != nullptr);
×
NEW
34
            auto& referenced_type = reference->reference_type();
×
NEW
35
            if (referenced_type.type_id() != types::TypeID::Scalar) {
×
NEW
36
                throw InvalidSDFGException("Assignment - LHS: must be a reference to a scalar type");
×
NEW
37
            }
×
NEW
38
            if (!types::is_integer(referenced_type.primitive_type())) {
×
NEW
39
                throw InvalidSDFGException("Assignment - LHS: must be integer type");
×
NEW
40
            }
×
NEW
41
        } else {
×
NEW
42
            throw InvalidSDFGException("Assignment - LHS: must be scalar type or a reference thereof");
×
UNCOV
43
        }
×
44

45
        auto& rhs = entry.second;
6✔
46
        for (auto& atom : symbolic::atoms(rhs)) {
6✔
47
            if (symbolic::is_nullptr(atom)) {
4✔
48
                continue;
×
49
            }
×
50
            auto& atom_type = function.type(atom->get_name());
4✔
51

52
            // Scalar integers
53
            if (atom_type.type_id() == types::TypeID::Scalar) {
4✔
54
                if (!types::is_integer(atom_type.primitive_type())) {
4✔
55
                    throw InvalidSDFGException("Assignment - RHS: must evaluate to integer type");
×
56
                }
×
57
                continue;
4✔
58
            } else if (atom_type.type_id() == types::TypeID::Reference) {
4✔
NEW
59
                auto* reference = dynamic_cast<const sdfg::codegen::Reference*>(&atom_type);
×
NEW
60
                assert(reference != nullptr);
×
NEW
61
                auto& referenced_type = reference->reference_type();
×
NEW
62
                if (referenced_type.type_id() != types::TypeID::Scalar) {
×
NEW
63
                    throw InvalidSDFGException("Assignment - RHS: must be a reference to a scalar type");
×
NEW
64
                }
×
NEW
65
                if (!types::is_integer(referenced_type.primitive_type())) {
×
NEW
66
                    throw InvalidSDFGException("Assignment - RHS: must evaluate to integer type");
×
NEW
67
                }
×
NEW
68
                continue;
×
69
            } else if (atom_type.type_id() == types::TypeID::Pointer) {
×
70
                continue;
×
71
            } else {
×
72
                throw InvalidSDFGException("Assignment - RHS: must evaluate to integer or pointer type");
×
73
            }
×
74
        }
4✔
75
    }
6✔
76

77
    if (this->condition_.is_null()) {
9✔
78
        throw InvalidSDFGException("InterstateEdge: Condition cannot be null");
×
79
    }
×
80
    if (!SymEngine::is_a_Boolean(*this->condition_)) {
9✔
81
        throw InvalidSDFGException("InterstateEdge: Condition must be a boolean expression");
×
82
    }
×
83
    for (auto& atom : symbolic::atoms(this->condition_)) {
9✔
84
        if (symbolic::is_nullptr(atom)) {
7✔
85
            continue;
1✔
86
        }
1✔
87
        auto& atom_type = function.type(atom->get_name());
6✔
88
        if (atom_type.type_id() != types::TypeID::Scalar && atom_type.type_id() != types::TypeID::Pointer) {
6✔
89
            throw InvalidSDFGException("Condition: must be integer type or pointer type");
×
90
        }
×
91
    }
6✔
92
};
9✔
93

94
const graph::Edge InterstateEdge::edge() const { return this->edge_; };
2✔
95

96
const control_flow::State& InterstateEdge::src() const { return this->src_; };
53✔
97

98
const control_flow::State& InterstateEdge::dst() const { return this->dst_; };
383✔
99

100
const symbolic::Condition InterstateEdge::condition() const { return this->condition_; };
68✔
101

102
bool InterstateEdge::is_unconditional() const { return symbolic::is_true(this->condition_); };
54✔
103

104
const sdfg::control_flow::Assignments& InterstateEdge::assignments() const { return this->assignments_; };
133✔
105

106
void InterstateEdge::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
1✔
107
    symbolic::subs(this->condition_, old_expression, new_expression);
1✔
108

109
    if (SymEngine::is_a<SymEngine::Symbol>(*old_expression) && SymEngine::is_a<SymEngine::Symbol>(*new_expression)) {
1✔
110
        auto old_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(old_expression);
1✔
111
        if (this->assignments_.find(old_symbol) != this->assignments_.end()) {
1✔
112
            auto new_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(new_expression);
1✔
113
            this->assignments_[new_symbol] = this->assignments_[old_symbol];
1✔
114
            this->assignments_.erase(old_symbol);
1✔
115
        }
1✔
116
    }
1✔
117

118
    for (auto& entry : this->assignments_) {
1✔
119
        entry.second = symbolic::subs(entry.second, old_expression, new_expression);
1✔
120
    }
1✔
121
};
1✔
122

123
} // namespace control_flow
124
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc