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

daisytuner / sdfglib / 19233097446

10 Nov 2025 01:22PM UTC coverage: 61.551% (+0.02%) from 61.533%
19233097446

Pull #331

github

web-flow
Merge bee958fc7 into 6b22fe1a8
Pull Request #331: allow interpretation of pointers as ints in symbolic expressions

54 of 95 new or added lines in 19 files covered. (56.84%)

3 existing lines in 3 files now uncovered.

10391 of 16882 relevant lines covered (61.55%)

107.15 hits per line

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

18.52
/src/control_flow/interstate_edge.cpp
1
#include "sdfg/control_flow/interstate_edge.h"
2

3
#include "sdfg/function.h"
4

5
namespace sdfg {
6
namespace control_flow {
7

8
InterstateEdge::InterstateEdge(
53✔
9
    size_t element_id,
10
    const DebugInfo& debug_info,
11
    const graph::Edge& edge,
12
    const control_flow::State& src,
13
    const control_flow::State& dst,
14
    const symbolic::Condition condition,
15
    const sdfg::control_flow::Assignments& assignments
16
)
17
    : Element(element_id, debug_info), edge_(edge), src_(src), dst_(dst), condition_(condition),
106✔
18
      assignments_(assignments) {
53✔
19

20
      };
53✔
21

22
void InterstateEdge::validate(const Function& function) const {
×
23
    for (auto& entry : this->assignments_) {
×
24
        auto& lhs = entry.first;
×
25
        auto& type = function.type(lhs->get_name());
×
26
        if (type.type_id() != types::TypeID::Scalar) {
×
NEW
27
            throw InvalidSDFGException("Assignment - LHS: must be scalar type");
×
28
        }
29
        if (!types::is_integer(type.primitive_type())) {
×
30
            throw InvalidSDFGException("Assignment - LHS: must be integer type");
×
31
        }
32

33
        auto& rhs = entry.second;
×
34
        for (auto& atom : symbolic::atoms(rhs)) {
×
35
            if (symbolic::is_nullptr(atom)) {
×
36
                continue;
×
37
            }
38
            auto& atom_type = function.type(atom->get_name());
×
39

40
            // Scalar integers
41
            if (atom_type.type_id() == types::TypeID::Scalar) {
×
42
                if (!types::is_integer(atom_type.primitive_type())) {
×
43
                    throw InvalidSDFGException("Assignment - RHS: must evaluate to integer type");
×
44
                }
45
                continue;
×
NEW
46
            } else if (atom_type.type_id() == types::TypeID::Pointer) {
×
UNCOV
47
                continue;
×
48
            } else {
NEW
49
                throw InvalidSDFGException("Assignment - RHS: must evaluate to integer or pointer type");
×
50
            }
51
        }
52
    }
53

54
    if (this->condition_.is_null()) {
×
55
        throw InvalidSDFGException("InterstateEdge: Condition cannot be null");
×
56
    }
57
    if (!SymEngine::is_a_Boolean(*this->condition_)) {
×
58
        throw InvalidSDFGException("InterstateEdge: Condition must be a boolean expression");
×
59
    }
60
    for (auto& atom : symbolic::atoms(this->condition_)) {
×
61
        if (symbolic::is_nullptr(atom)) {
×
62
            continue;
×
63
        }
64
        auto& atom_type = function.type(atom->get_name());
×
65
        if (atom_type.type_id() != types::TypeID::Scalar && atom_type.type_id() != types::TypeID::Pointer) {
×
66
            throw InvalidSDFGException("Condition: must be integer type or pointer type");
×
67
        }
68
    }
69
};
×
70

71
const graph::Edge InterstateEdge::edge() const { return this->edge_; };
2✔
72

73
const control_flow::State& InterstateEdge::src() const { return this->src_; };
8✔
74

75
const control_flow::State& InterstateEdge::dst() const { return this->dst_; };
41✔
76

77
const symbolic::Condition InterstateEdge::condition() const { return this->condition_; };
11✔
78

79
bool InterstateEdge::is_unconditional() const { return symbolic::is_true(this->condition_); };
11✔
80

81
const sdfg::control_flow::Assignments& InterstateEdge::assignments() const { return this->assignments_; };
20✔
82

83
void InterstateEdge::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
×
84
    symbolic::subs(this->condition_, old_expression, new_expression);
×
85

86
    if (SymEngine::is_a<SymEngine::Symbol>(*old_expression) && SymEngine::is_a<SymEngine::Symbol>(*new_expression)) {
×
87
        auto old_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(old_expression);
×
88
        if (this->assignments_.find(old_symbol) != this->assignments_.end()) {
×
89
            auto new_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(new_expression);
×
90
            this->assignments_[new_symbol] = this->assignments_[old_symbol];
×
91
            this->assignments_.erase(old_symbol);
×
92
        }
×
93
    }
×
94

95
    for (auto& entry : this->assignments_) {
×
96
        entry.second = symbolic::subs(entry.second, old_expression, new_expression);
×
97
    }
98
};
×
99

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