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

daisytuner / sdfglib / 18952417028

30 Oct 2025 07:15PM UTC coverage: 62.285% (+0.002%) from 62.283%
18952417028

push

github

web-flow
Merge pull request #317 from daisytuner/recursive-ext

fixes code generated for recursive calls

5 of 6 new or added lines in 4 files covered. (83.33%)

1 existing line in 1 file now uncovered.

10122 of 16251 relevant lines covered (62.29%)

102.89 hits per line

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

72.73
/src/structured_control_flow/sequence.cpp
1
#include "sdfg/structured_control_flow/sequence.h"
2

3
#include "sdfg/function.h"
4

5
namespace sdfg {
6
namespace structured_control_flow {
7

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

11
      };
×
12

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

18
      };
853✔
19

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

27
    for (auto& entry : this->assignments_) {
966✔
28
        auto& lhs = entry.first;
196✔
29
        auto& type = function.type(lhs->get_name());
196✔
30
        if (type.type_id() != types::TypeID::Scalar) {
196✔
31
            throw InvalidSDFGException("Assignment - LHS: must be integer type");
×
32
        }
33
        if (!types::is_integer(type.primitive_type())) {
196✔
34
            throw InvalidSDFGException("Assignment - LHS: must be integer type");
×
35
        }
36

37
        auto& rhs = entry.second;
196✔
38
        bool is_relational = SymEngine::is_a_Relational(*rhs);
196✔
39
        for (auto& atom : symbolic::atoms(rhs)) {
270✔
40
            if (symbolic::is_nullptr(atom)) {
74✔
41
                if (!is_relational) {
1✔
42
                    throw InvalidSDFGException("Assignment - RHS: nullptr can only be used in comparisons");
×
43
                }
44
                continue;
1✔
45
            }
46
            auto& atom_type = function.type(atom->get_name());
73✔
47

48
            // Scalar integers
49
            if (atom_type.type_id() == types::TypeID::Scalar) {
73✔
50
                if (!types::is_integer(atom_type.primitive_type())) {
69✔
51
                    throw InvalidSDFGException("Assignment - RHS: must evaluate to integer type");
×
52
                }
53
                continue;
69✔
54
            }
55

56
            // Pointer types (only in comparisons)
57
            if (atom_type.type_id() == types::TypeID::Pointer) {
4✔
58
                if (!is_relational) {
1✔
59
                    throw InvalidSDFGException("Assignment - RHS: pointer types can only be used in comparisons");
×
60
                }
61
                continue;
1✔
62
            }
63
        }
64
    }
65
};
770✔
66

67
const control_flow::Assignments& Transition::assignments() const { return this->assignments_; };
49✔
68

69
control_flow::Assignments& Transition::assignments() { return this->assignments_; };
1,641✔
70

71
Sequence& Transition::parent() { return *this->parent_; };
×
72

73
const Sequence& Transition::parent() const { return *this->parent_; };
×
74

75
bool Transition::empty() const { return this->assignments_.empty(); };
17✔
76

77
size_t Transition::size() const { return this->assignments_.size(); };
50✔
78

79
void Transition::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
2✔
80
    if (SymEngine::is_a<SymEngine::Symbol>(*old_expression) && SymEngine::is_a<SymEngine::Symbol>(*new_expression)) {
2✔
81
        auto old_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(old_expression);
2✔
82
        auto new_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(new_expression);
2✔
83

84
        if (this->assignments().find(old_symbol) != this->assignments().end()) {
2✔
85
            this->assignments()[new_symbol] = this->assignments()[old_symbol];
×
86
            this->assignments().erase(old_symbol);
×
87
        }
×
88
    }
2✔
89

90
    for (auto& entry : this->assignments()) {
2✔
UNCOV
91
        entry.second = symbolic::subs(entry.second, old_expression, new_expression);
×
92
    }
93
};
2✔
94

95
Sequence::Sequence(size_t element_id, const DebugInfo& debug_info)
1,610✔
96
    : ControlFlowNode(element_id, debug_info) {
805✔
97

98
      };
805✔
99

100
void Sequence::validate(const Function& function) const {
643✔
101
    // children and transition have same length
102
    if (this->children_.size() != this->transitions_.size()) {
643✔
103
        throw InvalidSDFGException("Sequence must have the same number of children and transitions");
×
104
    }
105

106
    for (auto& child : this->children_) {
1,413✔
107
        child->validate(function);
770✔
108
    }
109
    for (auto& trans : this->transitions_) {
1,413✔
110
        trans->validate(function);
770✔
111
    }
112
};
643✔
113

114
size_t Sequence::size() const { return this->children_.size(); };
3,811✔
115

116
std::pair<const ControlFlowNode&, const Transition&> Sequence::at(size_t i) const {
156✔
117
    return {*this->children_.at(i), *this->transitions_.at(i)};
156✔
118
};
119

120
std::pair<ControlFlowNode&, Transition&> Sequence::at(size_t i) {
2,274✔
121
    return {*this->children_.at(i), *this->transitions_.at(i)};
2,274✔
122
};
123

124
int Sequence::index(const ControlFlowNode& child) const {
75✔
125
    for (size_t i = 0; i < this->children_.size(); i++) {
81✔
126
        if (this->children_.at(i).get() == &child) {
81✔
127
            return static_cast<int>(i);
75✔
128
        }
129
    }
6✔
130

131
    return -1;
×
132
};
75✔
133

134
int Sequence::index(const Transition& transition) const {
×
135
    for (size_t i = 0; i < this->transitions_.size(); i++) {
×
136
        if (this->transitions_.at(i).get() == &transition) {
×
137
            return static_cast<int>(i);
×
138
        }
139
    }
×
140

141
    return -1;
×
142
};
×
143

144
void Sequence::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
2✔
145
    for (auto& child : this->children_) {
4✔
146
        child->replace(old_expression, new_expression);
2✔
147
    }
148

149
    for (auto& trans : this->transitions_) {
4✔
150
        trans->replace(old_expression, new_expression);
2✔
151
    }
152
};
2✔
153

154
} // namespace structured_control_flow
155
} // 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