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

daisytuner / sdfglib / 15238257521

25 May 2025 01:14PM UTC coverage: 60.342% (-0.1%) from 60.473%
15238257521

push

github

web-flow
Merge pull request #31 from daisytuner/exception-handling

Exception handling

18 of 60 new or added lines in 17 files covered. (30.0%)

1 existing line in 1 file now uncovered.

8052 of 13344 relevant lines covered (60.34%)

102.27 hits per line

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

87.63
/src/sdfg.cpp
1
#include "sdfg/sdfg.h"
2

3
#include "sdfg/codegen/language_extensions/c_language_extension.h"
4
#include "sdfg/element.h"
5
#include "sdfg/symbolic/symbolic.h"
6

7
namespace sdfg {
8

9
SDFG::SDFG(const std::string& name)
102✔
10
    : Function(name),
51✔
11
      start_state_(nullptr){
51✔
12

13
      };
51✔
14

15
const DebugInfo SDFG::debug_info() const {
1✔
16
    DebugInfo info;
1✔
17
    for (auto& state : this->states()) {
1✔
18
        info = DebugInfo::merge(info, state.debug_info());
×
19
        for (auto& data_flow_node : state.dataflow().nodes()) {
×
20
            info = DebugInfo::merge(info, data_flow_node.debug_info());
×
21
        }
22
        for (auto& edge : state.dataflow().edges()) {
×
23
            info = DebugInfo::merge(info, edge.debug_info());
×
24
        }
25
    }
26
    for (auto& edges : this->edges()) {
1✔
27
        info = DebugInfo::merge(info, edges.debug_info());
×
28
    }
29
    return info;
1✔
30
};
1✔
31

32
size_t SDFG::in_degree(const control_flow::State& state) const {
15✔
33
    return boost::in_degree(state.vertex(), this->graph_);
15✔
34
};
35

36
size_t SDFG::out_degree(const control_flow::State& state) const {
50✔
37
    return boost::out_degree(state.vertex(), this->graph_);
50✔
38
};
39

40
bool SDFG::is_adjacent(const control_flow::State& src, const control_flow::State& dst) const {
6✔
41
    return boost::edge(src.vertex(), dst.vertex(), this->graph_).second;
6✔
42
};
43

44
const control_flow::InterstateEdge& SDFG::edge(const control_flow::State& src,
4✔
45
                                               const control_flow::State& dst) const {
46
    auto e = boost::edge(src.vertex(), dst.vertex(), this->graph_);
4✔
47
    if (!e.second) {
4✔
48
        throw InvalidSDFGException("Edge does not exist");
×
49
    }
50
    return *this->edges_.at(e.first);
4✔
51
};
×
52

53
const control_flow::State& SDFG::start_state() const {
6✔
54
    if (this->start_state_ == nullptr) {
6✔
55
        throw InvalidSDFGException("Start state not set");
×
56
    }
57
    return *this->start_state_;
6✔
58
};
×
59

60
std::unordered_map<const control_flow::State*, const control_flow::State*> SDFG::dominator_tree()
1✔
61
    const {
62
    auto dom_tree_ = graph::dominator_tree(this->graph_, this->start_state_->vertex());
1✔
63

64
    std::unordered_map<const control_flow::State*, const control_flow::State*> dom_tree;
1✔
65
    for (auto& entry : dom_tree_) {
6✔
66
        control_flow::State* first = this->states_.at(entry.first).get();
5✔
67
        control_flow::State* second = nullptr;
5✔
68
        if (entry.second != boost::graph_traits<graph::Graph>::null_vertex()) {
5✔
69
            second = this->states_.at(entry.second).get();
4✔
70
        }
4✔
71
        dom_tree.insert({first, second});
5✔
72
    }
73

74
    return dom_tree;
1✔
75
};
1✔
76

77
std::unordered_map<const control_flow::State*, const control_flow::State*>
78
SDFG::post_dominator_tree() const {
5✔
79
    auto terminal_state = this->terminal_states();
5✔
80
    if (std::distance(terminal_state.begin(), terminal_state.end()) != 1) {
5✔
NEW
81
        throw InvalidSDFGException("SDFG: Multiple terminal states");
×
82
    }
83

84
    auto pdom_tree_ = graph::post_dominator_tree(this->graph_, (*terminal_state.begin()).vertex());
5✔
85

86
    std::unordered_map<const control_flow::State*, const control_flow::State*> pdom_tree;
5✔
87
    for (auto& entry : pdom_tree_) {
25✔
88
        control_flow::State* first = this->states_.at(entry.first).get();
20✔
89
        control_flow::State* second = nullptr;
20✔
90
        if (entry.second != boost::graph_traits<graph::Graph>::null_vertex()) {
20✔
91
            second = this->states_.at(entry.second).get();
15✔
92
        }
15✔
93
        pdom_tree.insert({first, second});
20✔
94
    }
95

96
    return pdom_tree;
5✔
97
};
5✔
98

99
std::list<const control_flow::InterstateEdge*> SDFG::back_edges() const {
4✔
100
    std::list<const control_flow::InterstateEdge*> bedges;
4✔
101
    for (const auto& edge : graph::back_edges(this->graph_, this->start_state_->vertex())) {
5✔
102
        bedges.push_back(this->edges_.find(edge)->second.get());
1✔
103
    }
104

105
    return bedges;
4✔
106
};
4✔
107

108
std::list<std::list<const control_flow::InterstateEdge*>> SDFG::all_simple_paths(
1✔
109
    const control_flow::State& src, const control_flow::State& dst) const {
110
    std::list<std::list<const control_flow::InterstateEdge*>> all_paths;
1✔
111

112
    std::list<std::list<graph::Edge>> all_paths_raw =
113
        graph::all_simple_paths(this->graph_, src.vertex(), dst.vertex());
1✔
114
    for (auto& path_raw : all_paths_raw) {
3✔
115
        std::list<const control_flow::InterstateEdge*> path;
2✔
116
        for (auto& edge : path_raw) {
8✔
117
            path.push_back(this->edges_.find(edge)->second.get());
6✔
118
        }
119
        all_paths.push_back(path);
2✔
120
    }
2✔
121

122
    return all_paths;
1✔
123
};
1✔
124

125
void SDFG::as_dot(std::ostream& f) const {
1✔
126
    std::map<graph::Graph::vertex_descriptor, size_t> node_ids;
1✔
127
    std::map<graph::Graph::vertex_descriptor, std::string> node_names;
1✔
128
    for (auto u : boost::make_iterator_range(boost::vertices(this->graph_))) {
6✔
129
        node_ids[u] = node_ids.size();
5✔
130
        node_names[u] = this->states_.at(u)->name();
5✔
131
    }
132

133
    codegen::CLanguageExtension lang_ext;
1✔
134
    std::map<graph::Graph::edge_descriptor, std::string> edge_names;
1✔
135
    for (auto u : boost::make_iterator_range(boost::edges(this->graph_))) {
6✔
136
        std::string desc = lang_ext.expression(this->edges_.at(u)->condition());
5✔
137
        desc += " ; ";
5✔
138
        for (auto& ass : this->edges_.at(u)->assignments()) {
5✔
139
            desc += lang_ext.expression(ass.first) + " = " + lang_ext.expression(ass.second) + ",";
×
140
        }
141
        edge_names[u] = desc;
5✔
142
    }
5✔
143

144
    boost::default_writer w;
145
    boost::write_graphviz(f, this->graph_,
2✔
146
                          boost::make_label_writer(boost::make_assoc_property_map(node_names)),
1✔
147
                          boost::make_label_writer(boost::make_assoc_property_map(edge_names)), w,
1✔
148
                          boost::make_assoc_property_map(node_ids));
1✔
149
};
1✔
150

151
}  // 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