• 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

40.0
/src/control_flow/state.cpp
1
#include "sdfg/control_flow/state.h"
2

3
#include "sdfg/sdfg.h"
4

5
namespace sdfg {
6
namespace control_flow {
7

8
State::State(size_t element_id, const DebugInfo& debug_info, const graph::Vertex vertex)
128✔
9
    : Element(element_id, debug_info), vertex_(vertex) {
64✔
10
    this->dataflow_ = std::make_unique<data_flow::DataFlowGraph>();
64✔
11
};
64✔
12

13
void State::validate(const Function& function) const { this->dataflow_->validate(function); };
17✔
14

15
graph::Vertex State::vertex() const { return this->vertex_; };
148✔
16

17
const data_flow::DataFlowGraph& State::dataflow() const { return *this->dataflow_; };
17✔
18

19
data_flow::DataFlowGraph& State::dataflow() { return *this->dataflow_; };
24✔
20

21
void State::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
×
22
    this->dataflow_->replace(old_expression, new_expression);
×
23
};
×
24

25
ReturnState::ReturnState(size_t element_id, const DebugInfo& debug_info, const graph::Vertex vertex, const std::string& data)
4✔
26
    : State(element_id, debug_info, vertex), data_(data), unreachable_(false), type_(nullptr) {};
4✔
27

NEW
28
ReturnState::ReturnState(size_t element_id, const DebugInfo& debug_info, const graph::Vertex vertex)
×
NEW
29
    : State(element_id, debug_info, vertex), data_(""), unreachable_(true), type_(nullptr) {};
×
30

UNCOV
31
ReturnState::ReturnState(
×
32
    size_t element_id,
33
    const DebugInfo& debug_info,
34
    const graph::Vertex vertex,
35
    const std::string& data,
36
    const types::IType& type
37
)
NEW
38
    : State(element_id, debug_info, vertex), data_(data), unreachable_(false), type_(type.clone()) {};
×
39

40
const std::string& ReturnState::data() const { return this->data_; };
4✔
41

NEW
42
const types::IType& ReturnState::type() const { return *(this->type_); };
×
43

UNCOV
44
bool ReturnState::unreachable() const { return this->unreachable_; };
×
45

46
bool ReturnState::is_data() const { return !this->unreachable_ && type_ == nullptr; };
8✔
47

NEW
48
bool ReturnState::is_unreachable() const { return this->unreachable_; };
×
49

NEW
50
bool ReturnState::is_constant() const { return !this->unreachable_ && type_ != nullptr; };
×
51

52
void ReturnState::validate(const Function& function) const {
4✔
53
    State::validate(function);
4✔
54

55
    auto& sdfg = static_cast<const SDFG&>(function);
4✔
56
    if (sdfg.out_degree(*this) > 0) {
4✔
57
        throw InvalidSDFGException("ReturnState must not have outgoing transitions");
×
58
    }
59

60
    if (is_data()) {
4✔
61
        if (data_ != "" && !function.exists(data_)) {
4✔
NEW
62
            throw InvalidSDFGException("Return node with data '" + data_ + "' does not correspond to any container");
×
63
        }
64
        if (unreachable_) {
4✔
NEW
65
            throw InvalidSDFGException("Return node cannot be both data and unreachable");
×
66
        }
67
        if (type_ != nullptr) {
4✔
NEW
68
            throw InvalidSDFGException("Return node with data cannot have a type");
×
69
        }
70
    } else if (is_constant()) {
4✔
NEW
71
        if (function.exists(data_)) {
×
NEW
72
            throw InvalidSDFGException(
×
NEW
73
                "Return node with constant data '" + data_ + "' cannot correspond to any container"
×
74
            );
75
        }
NEW
76
        if (type_ == nullptr) {
×
NEW
77
            throw InvalidSDFGException("Return node with constant data must have a type");
×
78
        }
NEW
79
    } else if (is_unreachable()) {
×
NEW
80
        if (!data_.empty()) {
×
NEW
81
            throw InvalidSDFGException("Unreachable return node cannot have data");
×
82
        }
NEW
83
        if (type_ != nullptr) {
×
NEW
84
            throw InvalidSDFGException("Unreachable return node cannot have a type");
×
85
        }
NEW
86
    } else {
×
NEW
87
        throw InvalidSDFGException("Return node must be either data, constant, or unreachable");
×
88
    }
89
}
4✔
90

91
void ReturnState::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
×
92
    State::replace(old_expression, new_expression);
×
93

94
    if (this->data_ == old_expression->__str__()) {
×
95
        this->data_ = new_expression->__str__();
×
96
    }
×
97
};
×
98

99
} // namespace control_flow
100
} // 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