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

daisytuner / docc / 23207680822

17 Mar 2026 05:30PM UTC coverage: 63.838% (-0.1%) from 63.973%
23207680822

Pull #583

github

web-flow
Merge d81aa24e4 into 3868c059f
Pull Request #583: [MLIR] Setup a Model Zoo to test different End-to-End networks

12 of 96 new or added lines in 4 files covered. (12.5%)

161 existing lines in 2 files now uncovered.

26079 of 40852 relevant lines covered (63.84%)

401.75 hits per line

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

0.0
/sdfg/src/data_flow/library_nodes/stdlib/assert.cpp
1
#include "sdfg/data_flow/library_nodes/stdlib/assert.h"
2

3
#include <cassert>
4
#include <cstddef>
5
#include <cstdio>
6
#include <memory>
7
#include <nlohmann/json_fwd.hpp>
8
#include <string>
9

10
#include "sdfg/builder/structured_sdfg_builder.h"
11
#include "sdfg/codegen/code_snippet_factory.h"
12
#include "sdfg/codegen/dispatchers/block_dispatcher.h"
13
#include "sdfg/codegen/language_extension.h"
14
#include "sdfg/codegen/utils.h"
15
#include "sdfg/data_flow/data_flow_graph.h"
16
#include "sdfg/data_flow/data_flow_node.h"
17
#include "sdfg/data_flow/library_node.h"
18
#include "sdfg/element.h"
19
#include "sdfg/exceptions.h"
20
#include "sdfg/function.h"
21
#include "sdfg/graph/graph.h"
22
#include "sdfg/structured_control_flow/block.h"
23
#include "sdfg/symbolic/symbolic.h"
24

25
namespace sdfg {
26
namespace stdlib {
27

28
AssertNode::AssertNode(
29
    size_t element_id,
30
    const DebugInfo& debug_info,
31
    const graph::Vertex vertex,
32
    data_flow::DataFlowGraph& parent,
33
    std::string message
34
)
35
    : data_flow::LibraryNode(
×
36
          element_id,
×
37
          debug_info,
×
38
          vertex,
×
39
          parent,
×
40
          LibraryNodeType_Assert,
×
41
          {},
×
42
          {"_arg"},
×
NEW
43
          true,
×
44
          data_flow::ImplementationType_NONE
×
45
      ),
×
46
      message_(message) {}
×
47

48
std::string& AssertNode::message() { return this->message_; }
×
49

50
const std::string& AssertNode::message() const { return this->message_; }
×
51

52
std::string AssertNode::toStr() const {
×
53
    if (this->message_.empty()) {
×
54
        return "assert(_arg)";
×
55
    } else {
×
56
        return "assert(_arg && " + this->message_ + ")";
×
57
    }
×
58
}
×
59

60
symbolic::SymbolSet AssertNode::symbols() const { return {}; }
×
61

62
symbolic::Expression AssertNode::flop() const { return symbolic::zero(); }
×
63

64
std::unique_ptr<data_flow::DataFlowNode> AssertNode::
65
    clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const {
×
66
    return std::make_unique<AssertNode>(element_id, this->debug_info(), vertex, parent, this->message());
×
67
}
×
68

69
void AssertNode::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {}
×
70

71
nlohmann::json AssertNodeSerializer::serialize(const data_flow::LibraryNode& library_node) {
×
72
    const auto& assert_node = static_cast<const AssertNode&>(library_node);
×
73

74
    nlohmann::json j;
×
75
    j["code"] = assert_node.code().value();
×
76

77
    j["message"] = assert_node.message();
×
78

79
    return j;
×
80
}
×
81

82
data_flow::LibraryNode& AssertNodeSerializer::deserialize(
83
    const nlohmann::json& j, builder::StructuredSDFGBuilder& builder, structured_control_flow::Block& parent
84
) {
×
85
    assert(j.contains("code"));
×
86
    assert(j.contains("debug_info"));
×
87
    assert(j.contains("message"));
×
88

89
    auto code = j["code"].get<std::string>();
×
90
    if (code != LibraryNodeType_Assert.value()) {
×
91
        throw InvalidSDFGException("Invalid library node code");
×
92
    }
×
93

94
    sdfg::serializer::JSONSerializer serializer;
×
95
    DebugInfo debug_info = serializer.json_to_debug_info(j["debug_info"]);
×
96

97
    auto message = j["message"].get<std::string>();
×
98

99
    return builder.add_library_node<AssertNode>(parent, debug_info, message);
×
100
}
×
101

102
void AssertNodeDispatcher::escape_message(codegen::PrettyPrinter& stream, const std::string& message) {
×
103
    stream << "\"";
×
104
    for (unsigned char c : message) {
×
105
        switch (c) {
×
106
            case '\\':
×
107
                stream << "\\\\";
×
108
                break;
×
109
            case '\"':
×
110
                stream << "\\\"";
×
111
                break;
×
112
            case '\n':
×
113
                stream << "\\n";
×
114
                break;
×
115
            case '\r':
×
116
                stream << "\\r";
×
117
                break;
×
118
            case '\t':
×
119
                stream << "\\t";
×
120
                break;
×
121
            case '\v':
×
122
                stream << "\\v";
×
123
                break;
×
124
            case '\f':
×
125
                stream << "\\f";
×
126
                break;
×
127
            case '\b':
×
128
                stream << "\\b";
×
129
                break;
×
130
            case '\a':
×
131
                stream << "\\a";
×
132
                break;
×
133
            default:
×
134
                if (c < 0x20 || c == 0x7F) {
×
135
                    char buf[5];
×
136
                    std::snprintf(buf, sizeof(buf), "\\x%02X", (unsigned) c);
×
137
                    stream << buf;
×
138
                } else {
×
139
                    stream << static_cast<char>(c);
×
140
                }
×
141
        }
×
142
    }
×
143
    stream << "\"";
×
144
}
×
145

146
AssertNodeDispatcher::AssertNodeDispatcher(
147
    codegen::LanguageExtension& language_extension,
148
    const Function& function,
149
    const data_flow::DataFlowGraph& data_flow_graph,
150
    const data_flow::LibraryNode& node
151
)
152
    : codegen::LibraryNodeDispatcher(language_extension, function, data_flow_graph, node) {}
×
153

154
void AssertNodeDispatcher::dispatch_code(
155
    codegen::PrettyPrinter& stream,
156
    codegen::PrettyPrinter& globals_stream,
157
    codegen::CodeSnippetFactory& library_snippet_factory
158
) {
×
159
    auto& node = static_cast<const AssertNode&>(this->node_);
×
160

161
#ifndef __APPLE__
×
162
    std::string bool_cast = "";
×
163
#endif
×
164
    // Should be in include stream. Change when include handling is reworked!
165
    if (this->language_extension_.language() == "C") {
×
166
        globals_stream << "#include <assert.h>" << std::endl;
×
167
    } else {
×
168
        globals_stream << "#include <cassert>" << std::endl;
×
169
#ifndef __APPLE__
×
170
        bool_cast = "static_cast<bool>";
×
171
#endif
×
172
    }
×
173

174
#ifdef __APPLE__
175
    stream << "(__builtin_expect(!bool(" << node.input(0) << "), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, \""
176
           << node.input(0) << "\"";
177
#else
178
    stream << "(" << bool_cast << "(" << node.input(0) << ") ? void (0) : __assert_fail(\"" << node.input(0) << "\"";
×
179
#endif
×
180
    if (!node.message().empty()) {
×
181
        stream << " \" && \" ";
×
182
        this->escape_message(stream, node.message());
×
183
    }
×
184
#ifdef __APPLE__
185
    stream << ") : (void) 0);" << std::endl;
186
#else
187
    stream << ", __FILE__, __LINE__, __extension__ __PRETTY_FUNCTION__));" << std::endl;
×
188
#endif
×
189
}
×
190

191
} // namespace stdlib
192
} // 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