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

daisytuner / sdfglib / 16069945621

04 Jul 2025 08:56AM UTC coverage: 64.375% (-0.2%) from 64.606%
16069945621

push

github

web-flow
Merge pull request #137 from daisytuner/clang-format

runs clang-format on codebase

609 of 827 new or added lines in 63 files covered. (73.64%)

46 existing lines in 30 files now uncovered.

8578 of 13325 relevant lines covered (64.38%)

177.24 hits per line

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

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

3
namespace sdfg {
4
namespace builder {
5

6
size_t FunctionBuilder::new_element_id() const { return ++this->function().element_counter_; };
3,830✔
7

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

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

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

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

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

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

93
    function.containers_.erase(name);
4✔
94
};
6✔
95

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

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

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

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

117
    return *(*res.first).second;
17✔
118
};
×
119

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

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

134
    function.containers_[name] = std::make_unique<types::Array>(*old_type, size);
1✔
135
};
2✔
136

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

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