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

daisytuner / sdfglib / 15656007340

14 Jun 2025 08:51PM UTC coverage: 13.234% (-49.9%) from 63.144%
15656007340

Pull #76

github

web-flow
Merge 9586c8161 into 413c53212
Pull Request #76: New Loop Dependency Analysis

361 of 465 new or added lines in 7 files covered. (77.63%)

6215 existing lines in 110 files now uncovered.

1612 of 12181 relevant lines covered (13.23%)

13.64 hits per line

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

32.43
/src/builder/function_builder.cpp
1
#include "sdfg/builder/function_builder.h"
2

3
namespace sdfg {
4
namespace builder {
5

6
const types::IType& FunctionBuilder::add_container(const std::string& name,
72✔
7
                                                   const types::IType& type, bool is_argument,
8
                                                   bool is_external) const {
9
    if (is_argument && is_external) {
72✔
10
        throw InvalidSDFGException("Container " + name +
×
11
                                   " cannot be both an argument and an external");
12
    }
13
    // Legal name
14
    if (name.find(".") != std::string::npos) {
72✔
15
        throw InvalidSDFGException("Container name " + name + " contains a dot");
×
16
    } else if (name.find(" ") != std::string::npos) {
72✔
17
        throw InvalidSDFGException("Container name " + name + " contains a space");
×
18
    } else if (name.find("(") != std::string::npos) {
72✔
19
        throw InvalidSDFGException("Container name " + name + " contains a parenthesis");
×
20
    } else if (name.find(")") != std::string::npos) {
72✔
21
        throw InvalidSDFGException("Container name " + name + " contains a parenthesis");
×
22
    } else if (name.find("[") != std::string::npos) {
72✔
23
        throw InvalidSDFGException("Container name " + name + " contains a bracket");
×
24
    } else if (name.find("]") != std::string::npos) {
72✔
25
        throw InvalidSDFGException("Container name " + name + " contains a bracket");
×
26
    } else if (name.find("*") != std::string::npos) {
72✔
27
        throw InvalidSDFGException("Container name " + name + " contains a star");
×
28
    } else if (name.find("&") != std::string::npos) {
72✔
29
        throw InvalidSDFGException("Container name " + name + " contains a ampersand");
×
30
    } else if (name.find("!") != std::string::npos) {
72✔
31
        throw InvalidSDFGException("Container name " + name + " contains a bang");
×
32
    } else if (name.find("~") != std::string::npos) {
72✔
33
        throw InvalidSDFGException("Container name " + name + " contains a tilde");
×
34
    } else if (name.find("`") != std::string::npos) {
72✔
35
        throw InvalidSDFGException("Container name " + name + " contains a backtick");
×
36
    } else if (name.find("\"") != std::string::npos) {
72✔
37
        throw InvalidSDFGException("Container name " + name + " contains a quote");
×
38
    } else if (name.find("'") != std::string::npos) {
72✔
39
        throw InvalidSDFGException("Container name " + name + " contains a single quote");
×
40
    } else if (name.find(";") != std::string::npos) {
72✔
41
        throw InvalidSDFGException("Container name " + name + " contains a semicolon");
×
42
    } else if (name.find(":") != std::string::npos) {
72✔
43
        throw InvalidSDFGException("Container name " + name + " contains a colon");
×
44
    } else if (name.find(",") != std::string::npos) {
72✔
45
        throw InvalidSDFGException("Container name " + name + " contains a comma");
×
46
    } else if (name.find("=") != std::string::npos) {
72✔
47
        throw InvalidSDFGException("Container name " + name + " contains a equal sign");
×
48
    } else if (name.find("+") != std::string::npos) {
72✔
49
        throw InvalidSDFGException("Container name " + name + " contains a plus sign");
×
50
    } else if (name.find("-") != std::string::npos) {
72✔
51
        throw InvalidSDFGException("Container name " + name + " contains a minus sign");
×
52
    } else if (name.find("/") != std::string::npos) {
72✔
53
        throw InvalidSDFGException("Container name " + name + " contains a slash");
×
54
    } else if (name.find("%") != std::string::npos) {
72✔
55
        throw InvalidSDFGException("Container name " + name + " contains a percent sign");
×
56
    } else if (name.find("^") != std::string::npos) {
72✔
57
        throw InvalidSDFGException("Container name " + name + " contains a caret");
×
58
    } else if (name.find("|") != std::string::npos) {
72✔
59
        throw InvalidSDFGException("Container name " + name + " contains a pipe");
×
60
    }
61

62
    auto res = this->function().containers_.insert({name, type.clone()});
72✔
63
    assert(res.second);
72✔
64

65
    if (is_argument) {
72✔
66
        this->function().arguments_.push_back(name);
47✔
67
    }
47✔
68
    if (is_external) {
72✔
UNCOV
69
        this->function().externals_.push_back(name);
×
UNCOV
70
    }
×
71
    if (type.is_symbol() && dynamic_cast<const types::Scalar*>(&type)) {
72✔
72
        auto sym = symbolic::symbol(name);
46✔
73
        this->function().assumptions_.insert({sym, symbolic::Assumption::create(sym, type)});
46✔
74
    }
46✔
75

76
    return *(*res.first).second;
72✔
77
};
×
78

UNCOV
79
void FunctionBuilder::remove_container(const std::string& name) const {
×
UNCOV
80
    auto& function = this->function();
×
UNCOV
81
    if (!function.is_transient(name)) {
×
UNCOV
82
        throw InvalidSDFGException("Container " + name + " is not transient");
×
83
    }
UNCOV
84
    if (this->function().containers_.find(name) == this->function().containers_.end()) {
×
85
        throw InvalidSDFGException("Container " + name + " does not exist");
×
86
    }
87

UNCOV
88
    auto& type = function.containers_[name];
×
UNCOV
89
    if (type->is_symbol() && dynamic_cast<const types::Scalar*>(type.get())) {
×
UNCOV
90
        function.assumptions_.erase(symbolic::symbol(name));
×
UNCOV
91
    }
×
92

UNCOV
93
    function.containers_.erase(name);
×
UNCOV
94
};
×
95

UNCOV
96
void FunctionBuilder::change_type(const std::string& name, const types::IType& type) const {
×
UNCOV
97
    auto& function = this->function();
×
UNCOV
98
    if (!function.is_transient(name)) {
×
99
        throw InvalidSDFGException("Container " + name + " is not transient");
×
100
    }
UNCOV
101
    if (function.containers_.find(name) == function.containers_.end()) {
×
102
        throw InvalidSDFGException("Container " + name + " does not exist");
×
103
    }
104

UNCOV
105
    function.containers_[name] = type.clone();
×
UNCOV
106
};
×
107

UNCOV
108
types::StructureDefinition& FunctionBuilder::add_structure(const std::string& name,
×
109
                                                           bool is_packed) const {
UNCOV
110
    if (this->function().structures_.find(name) != this->function().structures_.end()) {
×
111
        throw InvalidSDFGException("Structure " + name + " already exists");
×
112
    }
113

UNCOV
114
    auto res = this->function().structures_.insert(
×
UNCOV
115
        {name, std::make_unique<types::StructureDefinition>(name, is_packed)});
×
UNCOV
116
    assert(res.second);
×
117

UNCOV
118
    return *(*res.first).second;
×
119
};
×
120

UNCOV
121
void FunctionBuilder::make_array(const std::string& name, const symbolic::Expression& size) const {
×
UNCOV
122
    auto& function = this->function();
×
UNCOV
123
    if (!function.is_transient(name)) {
×
UNCOV
124
        throw InvalidSDFGException("Container " + name + " is not transient");
×
125
    }
UNCOV
126
    if (function.containers_.find(name) == function.containers_.end()) {
×
127
        throw InvalidSDFGException("Container " + name + " does not exist");
×
128
    }
129

UNCOV
130
    auto& old_type = function.containers_[name];
×
UNCOV
131
    if (old_type->is_symbol() && dynamic_cast<const types::Scalar*>(old_type.get())) {
×
UNCOV
132
        function.assumptions_.erase(symbolic::symbol(name));
×
UNCOV
133
    }
×
134

UNCOV
135
    function.containers_[name] = std::make_unique<types::Array>(*old_type, size);
×
UNCOV
136
};
×
137

UNCOV
138
std::string FunctionBuilder::find_new_name(std::string prefix) const {
×
UNCOV
139
    size_t i = 0;
×
UNCOV
140
    std::string new_name = prefix + std::to_string(i);
×
UNCOV
141
    while (this->function().exists(new_name)) {
×
142
        i++;
×
143
        new_name = prefix + std::to_string(i);
×
144
    }
UNCOV
145
    return new_name;
×
UNCOV
146
};
×
147

148
}  // namespace builder
149
}  // 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