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

daisytuner / sdfglib / 16069945621

04 Jul 2025 08:56AM UTC coverage: 64.375% (-0.2%) from 64.606%
16069945621

push

github

web-flow
Merge pull request #137 from daisytuner/clang-format

runs clang-format on codebase

609 of 827 new or added lines in 63 files covered. (73.64%)

46 existing lines in 30 files now uncovered.

8578 of 13325 relevant lines covered (64.38%)

177.24 hits per line

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

61.07
/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) {
39✔
9
    for (size_t i = 0; i < source.size(); i++) {
57✔
10
        auto child = source.at(i);
18✔
11
        auto& node = child.first;
18✔
12
        auto& trans = child.second;
18✔
13

14
        if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&node)) {
18✔
15
            auto& block =
4✔
16
                this->builder_.add_block(root, block_stmt->dataflow(), trans.assignments(), block_stmt->debug_info());
4✔
17
            this->node_mapping[block_stmt] = &block;
4✔
18
        } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&node)) {
18✔
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)) {
14✔
23
            auto& new_scope = this->builder_.add_if_else(root, trans.assignments(), if_else_stmt->debug_info());
4✔
24
            this->node_mapping[if_else_stmt] = &new_scope;
4✔
25
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
12✔
26
                auto branch = if_else_stmt->at(i);
8✔
27
                auto& new_branch = this->builder_.add_case(new_scope, branch.second, branch.first.debug_info());
8✔
28
                this->node_mapping[&branch.first] = &new_branch;
8✔
29
                this->append(new_branch, branch.first);
8✔
30
            }
8✔
31
        } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&node)) {
12✔
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
    }
18✔
73
};
39✔
74

75
void StructuredSDFGDeepCopy::
76
    insert(structured_control_flow::Sequence& root, structured_control_flow::ControlFlowNode& source) {
23✔
77
    if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&source)) {
23✔
NEW
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)) {
23✔
81
        auto& new_seq = this->builder_.add_sequence(root, {}, sequence_stmt->debug_info());
23✔
82
        this->node_mapping[sequence_stmt] = &new_seq;
23✔
83
        this->append(new_seq, *sequence_stmt);
23✔
84
    } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&source)) {
23✔
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);
×
NEW
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)) {
×
NEW
98
        auto& new_scope = this->builder_.add_for(
×
NEW
99
            root,
×
NEW
100
            for_stmt->indvar(),
×
NEW
101
            for_stmt->condition(),
×
NEW
102
            for_stmt->init(),
×
NEW
103
            for_stmt->update(),
×
NEW
104
            {},
×
NEW
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)) {
×
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)) {
×
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(
×
NEW
120
            root,
×
NEW
121
            map_stmt->indvar(),
×
NEW
122
            map_stmt->condition(),
×
NEW
123
            map_stmt->init(),
×
NEW
124
            map_stmt->update(),
×
NEW
125
            map_stmt->schedule_type(),
×
NEW
126
            {},
×
NEW
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
};
23✔
135

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

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

150
std::unordered_map<const structured_control_flow::ControlFlowNode*, const structured_control_flow::ControlFlowNode*>
151
StructuredSDFGDeepCopy::insert() {
1✔
152
    if (auto seq_source = dynamic_cast<structured_control_flow::Sequence*>(&this->source_)) {
1✔
153
        this->node_mapping.clear();
1✔
154
        this->append(this->root_, *seq_source);
1✔
155
        return this->node_mapping;
1✔
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

© 2025 Coveralls, Inc