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

daisytuner / sdfglib / 17651658650

11 Sep 2025 04:58PM UTC coverage: 61.012% (+1.3%) from 59.755%
17651658650

Pull #219

github

web-flow
Merge 742a12367 into f744ac9f5
Pull Request #219: stdlib Library Nodes and ConstantNodes

499 of 1681 new or added lines in 81 files covered. (29.68%)

95 existing lines in 36 files now uncovered.

9718 of 15928 relevant lines covered (61.01%)

108.0 hits per line

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

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

3
#include "sdfg/element.h"
4

5
namespace sdfg {
6

7
SDFG::SDFG(const std::string& name, FunctionType type, const types::IType& return_type)
50✔
8
    : Function(name, type, return_type), start_state_(nullptr) {};
50✔
9

10
SDFG::SDFG(const std::string& name, FunctionType type) : SDFG(name, type, types::Scalar(types::PrimitiveType::Void)) {};
50✔
11

12
void SDFG::validate() const {
13✔
13
    // Call parent validate
14
    Function::validate();
13✔
15

16
    // Validate states and edges
17
    for (auto& state : this->states()) {
30✔
18
        state.validate(*this);
17✔
19
    }
20
    for (auto& edge : this->edges()) {
29✔
21
        edge.validate(*this);
16✔
22
    }
23

24
    for (auto& term : this->terminal_states()) {
17✔
25
        if (!dynamic_cast<const control_flow::ReturnState*>(&term)) {
4✔
NEW
26
            throw InvalidSDFGException("Terminal state is not a valid State");
×
27
        }
28
    }
29
};
13✔
30

NEW
31
size_t SDFG::num_terminal_states() const {
×
NEW
32
    return std::distance(this->terminal_states().begin(), this->terminal_states().end());
×
33
};
34

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

39
size_t SDFG::out_degree(const control_flow::State& state) const {
53✔
40
    return boost::out_degree(state.vertex(), this->graph_);
53✔
41
};
42

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

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

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

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

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

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

78
std::unordered_map<const control_flow::State*, const control_flow::State*> SDFG::post_dominator_tree() {
5✔
79
    auto pdom_tree_ = graph::post_dominator_tree(this->graph_);
5✔
80

81
    std::unordered_map<const control_flow::State*, const control_flow::State*> pdom_tree;
5✔
82
    for (auto& entry : pdom_tree_) {
27✔
83
        if (this->states_.find(entry.first) == this->states_.end()) {
22✔
84
            // This is the synthetic super-terminal, skip it
NEW
85
            continue;
×
86
        }
87

88
        control_flow::State* first = this->states_.at(entry.first).get();
22✔
89
        control_flow::State* second = nullptr;
22✔
90
        if (entry.second != boost::graph_traits<graph::Graph>::null_vertex() &&
39✔
91
            this->states_.find(entry.second) != this->states_.end()) {
17✔
92
            second = this->states_.at(entry.second).get();
17✔
93
        }
17✔
94
        pdom_tree.insert({first, second});
22✔
95
    }
96

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

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

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

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

113
    std::list<std::list<graph::Edge>> all_paths_raw = 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
} // 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