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

daisytuner / sdfglib / 17368505925

01 Sep 2025 05:29AM UTC coverage: 58.982% (-0.8%) from 59.781%
17368505925

push

github

web-flow
Merge pull request #216 from daisytuner/transitions-bug

Updates API for Sequence transitions to prevent leakage of assignments

239 of 547 new or added lines in 25 files covered. (43.69%)

75 existing lines in 12 files now uncovered.

9190 of 15581 relevant lines covered (58.98%)

115.89 hits per line

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

51.15
/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✔
UNCOV
23
            auto& new_scope = this->builder_.add_if_else(root, trans.assignments(), if_else_stmt->debug_info());
×
UNCOV
24
            this->node_mapping[if_else_stmt] = &new_scope;
×
UNCOV
25
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
UNCOV
26
                auto branch = if_else_stmt->at(i);
×
UNCOV
27
                auto& new_branch = this->builder_.add_case(new_scope, branch.second, branch.first.debug_info());
×
UNCOV
28
                this->node_mapping[&branch.first] = &new_branch;
×
UNCOV
29
                this->append(new_branch, branch.first);
×
UNCOV
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
            auto& new_ret = this->builder_.add_return(root, trans.assignments(), ret_stmt->debug_info());
1✔
43
            this->node_mapping[ret_stmt] = &new_ret;
1✔
44
        } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&node)) {
3✔
45
            auto& new_scope = this->builder_.add_for(
2✔
46
                root,
1✔
47
                for_stmt->indvar(),
1✔
48
                for_stmt->condition(),
1✔
49
                for_stmt->init(),
1✔
50
                for_stmt->update(),
1✔
51
                trans.assignments(),
1✔
52
                for_stmt->debug_info()
1✔
53
            );
54
            this->node_mapping[for_stmt] = &new_scope;
1✔
55
            this->append(new_scope.root(), for_stmt->root());
1✔
56
        } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&node)) {
2✔
57
            auto& new_scope = this->builder_.add_map(
2✔
58
                root,
1✔
59
                map_stmt->indvar(),
1✔
60
                map_stmt->condition(),
1✔
61
                map_stmt->init(),
1✔
62
                map_stmt->update(),
1✔
63
                map_stmt->schedule_type(),
1✔
64
                trans.assignments(),
1✔
65
                map_stmt->debug_info()
1✔
66
            );
67
            this->node_mapping[map_stmt] = &new_scope;
1✔
68
            this->append(new_scope.root(), map_stmt->root());
1✔
69
        } else {
1✔
70
            throw std::runtime_error("Deep copy not implemented");
×
71
        }
72
    }
13✔
73
};
18✔
74

75
void StructuredSDFGDeepCopy::
76
    insert(structured_control_flow::Sequence& root, structured_control_flow::ControlFlowNode& source) {
11✔
77
    if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&source)) {
11✔
78
        auto& block = this->builder_.add_block(root, block_stmt->dataflow(), {}, block_stmt->debug_info());
×
79
        this->node_mapping[block_stmt] = &block;
×
80
    } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&source)) {
11✔
81
        auto& new_seq = this->builder_.add_sequence(root, {}, sequence_stmt->debug_info());
11✔
82
        this->node_mapping[sequence_stmt] = &new_seq;
11✔
83
        this->append(new_seq, *sequence_stmt);
11✔
84
    } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&source)) {
11✔
85
        auto& new_scope = this->builder_.add_if_else(root);
×
86
        this->node_mapping[if_else_stmt] = &new_scope;
×
87
        for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
88
            auto branch = if_else_stmt->at(i);
×
89
            auto& new_branch = this->builder_.add_case(new_scope, branch.second, branch.first.debug_info());
×
90
            this->node_mapping[&branch.first] = &new_branch;
×
91
            this->append(new_branch, branch.first);
×
92
        }
×
93
    } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&source)) {
×
94
        auto& new_scope = this->builder_.add_while(root, {}, loop_stmt->debug_info());
×
95
        this->node_mapping[loop_stmt] = &new_scope;
×
96
        this->append(new_scope.root(), loop_stmt->root());
×
97
    } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&source)) {
×
98
        auto& new_scope = this->builder_.add_for(
×
99
            root,
×
100
            for_stmt->indvar(),
×
101
            for_stmt->condition(),
×
102
            for_stmt->init(),
×
103
            for_stmt->update(),
×
104
            {},
×
105
            for_stmt->debug_info()
×
106
        );
107
        this->node_mapping[for_stmt] = &new_scope;
×
108
        this->append(new_scope.root(), for_stmt->root());
×
109
    } else if (auto cont_stmt = dynamic_cast<structured_control_flow::Continue*>(&source)) {
×
NEW
110
        auto& new_cont = this->builder_.add_continue(root, {}, cont_stmt->debug_info());
×
111
        this->node_mapping[cont_stmt] = &new_cont;
×
112
    } else if (auto br_stmt = dynamic_cast<structured_control_flow::Break*>(&source)) {
×
NEW
113
        auto& new_br = this->builder_.add_break(root, {}, br_stmt->debug_info());
×
114
        this->node_mapping[br_stmt] = &new_br;
×
115
    } else if (auto ret_stmt = dynamic_cast<structured_control_flow::Return*>(&source)) {
×
116
        auto& new_ret = this->builder_.add_return(root, {}, ret_stmt->debug_info());
×
117
        this->node_mapping[ret_stmt] = &new_ret;
×
118
    } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&source)) {
×
119
        auto& new_scope = this->builder_.add_map(
×
120
            root,
×
121
            map_stmt->indvar(),
×
122
            map_stmt->condition(),
×
123
            map_stmt->init(),
×
124
            map_stmt->update(),
×
125
            map_stmt->schedule_type(),
×
126
            {},
×
127
            map_stmt->debug_info()
×
128
        );
129
        this->node_mapping[map_stmt] = &new_scope;
×
130
        this->append(new_scope.root(), map_stmt->root());
×
131
    } else {
×
132
        throw std::runtime_error("Deep copy not implemented");
×
133
    }
134
};
11✔
135

136
StructuredSDFGDeepCopy::StructuredSDFGDeepCopy(
22✔
137
    builder::StructuredSDFGBuilder& builder,
138
    structured_control_flow::Sequence& root,
139
    structured_control_flow::ControlFlowNode& source
140
)
141
    : builder_(builder), root_(root), source_(source) {};
22✔
142

143
std::unordered_map<const structured_control_flow::ControlFlowNode*, const structured_control_flow::ControlFlowNode*>
144
StructuredSDFGDeepCopy::copy() {
11✔
145
    this->node_mapping.clear();
11✔
146
    this->insert(this->root_, this->source_);
11✔
147
    return this->node_mapping;
11✔
148
};
149

150
std::unordered_map<const structured_control_flow::ControlFlowNode*, const structured_control_flow::ControlFlowNode*>
151
StructuredSDFGDeepCopy::insert() {
×
152
    if (auto seq_source = dynamic_cast<structured_control_flow::Sequence*>(&this->source_)) {
×
153
        this->node_mapping.clear();
×
154
        this->append(this->root_, *seq_source);
×
155
        return this->node_mapping;
×
156
    } else {
157
        throw std::runtime_error("Source node must be a sequence");
×
158
    }
159
};
×
160

161
} // namespace deepcopy
162
} // 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