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

daisytuner / sdfglib / 17907460602

22 Sep 2025 07:08AM UTC coverage: 60.192% (-0.5%) from 60.653%
17907460602

Pull #233

github

web-flow
Merge 07c7b1d2f into c3f4f7063
Pull Request #233: adds constant returns with type and extends API

60 of 184 new or added lines in 10 files covered. (32.61%)

19 existing lines in 5 files now uncovered.

9514 of 15806 relevant lines covered (60.19%)

105.75 hits per line

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

46.67
/src/deepcopy/structured_sdfg_deep_copy.cpp
1
#include "sdfg/deepcopy/structured_sdfg_deep_copy.h"
2

3
#include "sdfg/element.h"
4

5
namespace sdfg {
6
namespace deepcopy {
7

8
void StructuredSDFGDeepCopy::append(structured_control_flow::Sequence& root, structured_control_flow::Sequence& source) {
18✔
9
    for (size_t i = 0; i < source.size(); i++) {
31✔
10
        auto child = source.at(i);
13✔
11
        auto& node = child.first;
13✔
12
        auto& trans = child.second;
13✔
13

14
        if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&node)) {
13✔
15
            auto& block =
3✔
16
                this->builder_.add_block(root, block_stmt->dataflow(), trans.assignments(), block_stmt->debug_info());
3✔
17
            this->node_mapping[block_stmt] = &block;
3✔
18
        } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&node)) {
13✔
19
            auto& new_seq = this->builder_.add_sequence(root, trans.assignments(), sequence_stmt->debug_info());
2✔
20
            this->node_mapping[sequence_stmt] = &new_seq;
2✔
21
            this->append(new_seq, *sequence_stmt);
2✔
22
        } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&node)) {
10✔
23
            auto& new_scope = this->builder_.add_if_else(root, trans.assignments(), if_else_stmt->debug_info());
×
24
            this->node_mapping[if_else_stmt] = &new_scope;
×
25
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
26
                auto branch = if_else_stmt->at(i);
×
27
                auto& new_branch = this->builder_.add_case(new_scope, branch.second, branch.first.debug_info());
×
28
                this->node_mapping[&branch.first] = &new_branch;
×
29
                this->append(new_branch, branch.first);
×
30
            }
×
31
        } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&node)) {
8✔
32
            auto& new_scope = this->builder_.add_while(root, trans.assignments(), loop_stmt->debug_info());
3✔
33
            this->node_mapping[loop_stmt] = &new_scope;
3✔
34
            this->append(new_scope.root(), loop_stmt->root());
3✔
35
        } else if (auto cont_stmt = dynamic_cast<structured_control_flow::Continue*>(&node)) {
8✔
36
            auto& new_cont = this->builder_.add_continue(root, trans.assignments(), cont_stmt->debug_info());
1✔
37
            this->node_mapping[cont_stmt] = &new_cont;
1✔
38
        } else if (auto br_stmt = dynamic_cast<structured_control_flow::Break*>(&node)) {
5✔
39
            auto& new_br = this->builder_.add_break(root, trans.assignments(), br_stmt->debug_info());
1✔
40
            this->node_mapping[br_stmt] = &new_br;
1✔
41
        } else if (auto ret_stmt = dynamic_cast<structured_control_flow::Return*>(&node)) {
4✔
42
            if (ret_stmt->is_data()) {
1✔
43
                auto& new_ret =
1✔
44
                    this->builder_.add_return(root, ret_stmt->data(), trans.assignments(), ret_stmt->debug_info());
1✔
45
                this->node_mapping[ret_stmt] = &new_ret;
1✔
46
            } else if (ret_stmt->is_unreachable()) {
1✔
NEW
47
                auto& new_ret = this->builder_.add_unreachable(root, trans.assignments(), ret_stmt->debug_info());
×
NEW
48
                this->node_mapping[ret_stmt] = &new_ret;
×
NEW
49
            } else if (ret_stmt->is_constant()) {
×
NEW
50
                auto& new_ret = this->builder_.add_constant_return(
×
NEW
51
                    root, ret_stmt->data(), ret_stmt->type(), trans.assignments(), ret_stmt->debug_info()
×
52
                );
NEW
53
                this->node_mapping[ret_stmt] = &new_ret;
×
NEW
54
            }
×
55
        } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&node)) {
3✔
56
            auto& new_scope = this->builder_.add_for(
2✔
57
                root,
1✔
58
                for_stmt->indvar(),
1✔
59
                for_stmt->condition(),
1✔
60
                for_stmt->init(),
1✔
61
                for_stmt->update(),
1✔
62
                trans.assignments(),
1✔
63
                for_stmt->debug_info()
1✔
64
            );
65
            this->node_mapping[for_stmt] = &new_scope;
1✔
66
            this->append(new_scope.root(), for_stmt->root());
1✔
67
        } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&node)) {
2✔
68
            auto& new_scope = this->builder_.add_map(
2✔
69
                root,
1✔
70
                map_stmt->indvar(),
1✔
71
                map_stmt->condition(),
1✔
72
                map_stmt->init(),
1✔
73
                map_stmt->update(),
1✔
74
                map_stmt->schedule_type(),
1✔
75
                trans.assignments(),
1✔
76
                map_stmt->debug_info()
1✔
77
            );
78
            this->node_mapping[map_stmt] = &new_scope;
1✔
79
            this->append(new_scope.root(), map_stmt->root());
1✔
80
        } else {
1✔
81
            throw std::runtime_error("Deep copy not implemented");
×
82
        }
83
    }
13✔
84
};
18✔
85

86
void StructuredSDFGDeepCopy::
87
    insert(structured_control_flow::Sequence& root, structured_control_flow::ControlFlowNode& source) {
11✔
88
    if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&source)) {
11✔
89
        auto& block = this->builder_.add_block(root, block_stmt->dataflow(), {}, block_stmt->debug_info());
×
90
        this->node_mapping[block_stmt] = &block;
×
91
    } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&source)) {
11✔
92
        auto& new_seq = this->builder_.add_sequence(root, {}, sequence_stmt->debug_info());
11✔
93
        this->node_mapping[sequence_stmt] = &new_seq;
11✔
94
        this->append(new_seq, *sequence_stmt);
11✔
95
    } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&source)) {
11✔
96
        auto& new_scope = this->builder_.add_if_else(root);
×
97
        this->node_mapping[if_else_stmt] = &new_scope;
×
98
        for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
99
            auto branch = if_else_stmt->at(i);
×
100
            auto& new_branch = this->builder_.add_case(new_scope, branch.second, branch.first.debug_info());
×
101
            this->node_mapping[&branch.first] = &new_branch;
×
102
            this->append(new_branch, branch.first);
×
103
        }
×
104
    } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&source)) {
×
105
        auto& new_scope = this->builder_.add_while(root, {}, loop_stmt->debug_info());
×
106
        this->node_mapping[loop_stmt] = &new_scope;
×
107
        this->append(new_scope.root(), loop_stmt->root());
×
108
    } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&source)) {
×
109
        auto& new_scope = this->builder_.add_for(
×
110
            root,
×
111
            for_stmt->indvar(),
×
112
            for_stmt->condition(),
×
113
            for_stmt->init(),
×
114
            for_stmt->update(),
×
115
            {},
×
116
            for_stmt->debug_info()
×
117
        );
118
        this->node_mapping[for_stmt] = &new_scope;
×
119
        this->append(new_scope.root(), for_stmt->root());
×
120
    } else if (auto cont_stmt = dynamic_cast<structured_control_flow::Continue*>(&source)) {
×
121
        auto& new_cont = this->builder_.add_continue(root, {}, cont_stmt->debug_info());
×
122
        this->node_mapping[cont_stmt] = &new_cont;
×
123
    } else if (auto br_stmt = dynamic_cast<structured_control_flow::Break*>(&source)) {
×
124
        auto& new_br = this->builder_.add_break(root, {}, br_stmt->debug_info());
×
125
        this->node_mapping[br_stmt] = &new_br;
×
126
    } else if (auto ret_stmt = dynamic_cast<structured_control_flow::Return*>(&source)) {
×
NEW
127
        if (ret_stmt->is_data()) {
×
NEW
128
            auto& new_ret = this->builder_.add_return(root, ret_stmt->data(), {}, ret_stmt->debug_info());
×
NEW
129
            this->node_mapping[ret_stmt] = &new_ret;
×
NEW
130
        } else if (ret_stmt->is_unreachable()) {
×
NEW
131
            auto& new_ret = this->builder_.add_unreachable(root, {}, ret_stmt->debug_info());
×
NEW
132
            this->node_mapping[ret_stmt] = &new_ret;
×
NEW
133
        } else if (ret_stmt->is_constant()) {
×
NEW
134
            auto& new_ret =
×
NEW
135
                this->builder_.add_constant_return(root, ret_stmt->data(), ret_stmt->type(), {}, ret_stmt->debug_info());
×
NEW
136
            this->node_mapping[ret_stmt] = &new_ret;
×
NEW
137
        }
×
138
    } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&source)) {
×
139
        auto& new_scope = this->builder_.add_map(
×
140
            root,
×
141
            map_stmt->indvar(),
×
142
            map_stmt->condition(),
×
143
            map_stmt->init(),
×
144
            map_stmt->update(),
×
145
            map_stmt->schedule_type(),
×
146
            {},
×
147
            map_stmt->debug_info()
×
148
        );
149
        this->node_mapping[map_stmt] = &new_scope;
×
150
        this->append(new_scope.root(), map_stmt->root());
×
151
    } else {
×
152
        throw std::runtime_error("Deep copy not implemented");
×
153
    }
154
};
11✔
155

156
StructuredSDFGDeepCopy::StructuredSDFGDeepCopy(
22✔
157
    builder::StructuredSDFGBuilder& builder,
158
    structured_control_flow::Sequence& root,
159
    structured_control_flow::ControlFlowNode& source
160
)
161
    : builder_(builder), root_(root), source_(source) {};
22✔
162

163
std::unordered_map<const structured_control_flow::ControlFlowNode*, const structured_control_flow::ControlFlowNode*>
164
StructuredSDFGDeepCopy::copy() {
11✔
165
    this->node_mapping.clear();
11✔
166
    this->insert(this->root_, this->source_);
11✔
167
    return this->node_mapping;
11✔
168
};
169

170
std::unordered_map<const structured_control_flow::ControlFlowNode*, const structured_control_flow::ControlFlowNode*>
171
StructuredSDFGDeepCopy::insert() {
×
172
    if (auto seq_source = dynamic_cast<structured_control_flow::Sequence*>(&this->source_)) {
×
173
        this->node_mapping.clear();
×
174
        this->append(this->root_, *seq_source);
×
175
        return this->node_mapping;
×
176
    } else {
177
        throw std::runtime_error("Source node must be a sequence");
×
178
    }
179
};
×
180

181
} // namespace deepcopy
182
} // 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