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

daisytuner / sdfglib / 21491323166

29 Jan 2026 07:10PM UTC coverage: 66.308% (+0.5%) from 65.778%
21491323166

push

github

web-flow
Merge pull request #481 from daisytuner/refactor-cutout

Refactor cutout

96 of 160 new or added lines in 7 files covered. (60.0%)

4 existing lines in 3 files now uncovered.

22723 of 34269 relevant lines covered (66.31%)

382.43 hits per line

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

59.35
/sdfg/src/structured_control_flow/sequence.cpp
1
#include "sdfg/structured_control_flow/sequence.h"
2
#include "sdfg/codegen/utils.h"
3

4
#include "sdfg/function.h"
5

6
namespace sdfg {
7
namespace structured_control_flow {
8

9
Transition::Transition(size_t element_id, const DebugInfo& debug_info, Sequence& parent)
10
    : Element(element_id, debug_info), parent_(&parent) {
×
11

12
      };
×
13

14
Transition::Transition(
15
    size_t element_id, const DebugInfo& debug_info, Sequence& parent, const control_flow::Assignments& assignments
16
)
17
    : Element(element_id, debug_info), parent_(&parent), assignments_(assignments) {
2,824✔
18

19
      };
2,824✔
20

21
void Transition::validate(const Function& function) const {
4,136✔
22
    for (const auto& entry : this->assignments_) {
4,136✔
23
        if (entry.first.is_null() || entry.second.is_null()) {
346✔
24
            throw InvalidSDFGException("Transition: Assignments cannot have null expressions");
×
25
        }
×
26
    }
346✔
27

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

49
        auto& rhs = entry.second;
346✔
50
        for (auto& atom : symbolic::atoms(rhs)) {
346✔
51
            if (symbolic::is_nullptr(atom)) {
174✔
52
                continue;
×
53
            }
×
54
            auto& atom_type = function.type(atom->get_name());
174✔
55

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

82
const control_flow::Assignments& Transition::assignments() const { return this->assignments_; };
74✔
83

84
control_flow::Assignments& Transition::assignments() { return this->assignments_; };
7,515✔
85

86
Sequence& Transition::parent() { return *this->parent_; };
8✔
87

88
const Sequence& Transition::parent() const { return *this->parent_; };
1✔
89

90
bool Transition::empty() const { return this->assignments_.empty(); };
140✔
91

92
size_t Transition::size() const { return this->assignments_.size(); };
43✔
93

94
void Transition::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
83✔
95
    if (SymEngine::is_a<SymEngine::Symbol>(*old_expression) && SymEngine::is_a<SymEngine::Symbol>(*new_expression)) {
83✔
96
        auto old_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(old_expression);
78✔
97
        auto new_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(new_expression);
78✔
98

99
        if (this->assignments().find(old_symbol) != this->assignments().end()) {
78✔
100
            this->assignments()[new_symbol] = this->assignments()[old_symbol];
×
101
            this->assignments().erase(old_symbol);
×
102
        }
×
103
    }
78✔
104

105
    for (auto& entry : this->assignments()) {
83✔
106
        entry.second = symbolic::subs(entry.second, old_expression, new_expression);
×
107
    }
×
108
};
83✔
109

110
Sequence::Sequence(size_t element_id, const DebugInfo& debug_info)
111
    : ControlFlowNode(element_id, debug_info) {
2,411✔
112

113
      };
2,411✔
114

115
void Sequence::validate(const Function& function) const {
2,813✔
116
    // children and transition have same length
117
    if (this->children_.size() != this->transitions_.size()) {
2,813✔
118
        throw InvalidSDFGException("Sequence must have the same number of children and transitions");
×
119
    }
×
120

121
    for (auto& child : this->children_) {
4,138✔
122
        child->validate(function);
4,138✔
123
    }
4,138✔
124
    for (auto& trans : this->transitions_) {
4,136✔
125
        trans->validate(function);
4,136✔
126
    }
4,136✔
127
};
2,813✔
128

129
size_t Sequence::size() const { return this->children_.size(); };
17,294✔
130

131
std::pair<const ControlFlowNode&, const Transition&> Sequence::at(size_t i) const {
1,263✔
132
    return {*this->children_.at(i), *this->transitions_.at(i)};
1,263✔
133
};
1,263✔
134

135
std::pair<ControlFlowNode&, Transition&> Sequence::at(size_t i) {
10,245✔
136
    return {*this->children_.at(i), *this->transitions_.at(i)};
10,245✔
137
};
10,245✔
138

139
int Sequence::index(const ControlFlowNode& child) const {
567✔
140
    for (size_t i = 0; i < this->children_.size(); i++) {
771✔
141
        if (this->children_.at(i).get() == &child) {
771✔
142
            return static_cast<int>(i);
567✔
143
        }
567✔
144
    }
771✔
145

146
    return -1;
×
147
};
567✔
148

149
int Sequence::index(const Transition& transition) const {
×
150
    for (size_t i = 0; i < this->transitions_.size(); i++) {
×
151
        if (this->transitions_.at(i).get() == &transition) {
×
152
            return static_cast<int>(i);
×
153
        }
×
154
    }
×
155

156
    return -1;
×
157
};
×
158

159
void Sequence::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
68✔
160
    for (auto& child : this->children_) {
83✔
161
        child->replace(old_expression, new_expression);
83✔
162
    }
83✔
163

164
    for (auto& trans : this->transitions_) {
83✔
165
        trans->replace(old_expression, new_expression);
83✔
166
    }
83✔
167
};
68✔
168

169
} // namespace structured_control_flow
170
} // 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