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

daisytuner / sdfglib / 20555406222

28 Dec 2025 02:53PM UTC coverage: 38.976% (-0.1%) from 39.111%
20555406222

Pull #408

github

web-flow
Merge 089cdb50d into 4e1d3209f
Pull Request #408: Several fixes for library nodes

13539 of 45102 branches covered (30.02%)

Branch coverage included in aggregate %.

1 of 99 new or added lines in 11 files covered. (1.01%)

14 existing lines in 7 files now uncovered.

11671 of 19578 relevant lines covered (59.61%)

83.78 hits per line

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

11.89
/src/data_flow/library_nodes/stdlib/malloc.cpp
1
#include "sdfg/data_flow/library_nodes/stdlib/malloc.h"
2

3
namespace sdfg {
4
namespace stdlib {
5

6
MallocNode::MallocNode(
5✔
7
    size_t element_id,
8
    const DebugInfo& debug_info,
9
    const graph::Vertex vertex,
10
    data_flow::DataFlowGraph& parent,
11
    const symbolic::Expression size
12
)
13
    : LibraryNode(
5!
14
          element_id,
5✔
15
          debug_info,
5✔
16
          vertex,
5✔
17
          parent,
5✔
18
          LibraryNodeType_Malloc,
19
          {"_ret"},
5!
20
          {},
5✔
21
          true,
22
          data_flow::ImplementationType_NONE
23
      ),
24
      size_(size) {}
5!
25

26
const symbolic::Expression MallocNode::size() const { return size_; }
4✔
27

28
void MallocNode::validate(const Function& function) const {}
3✔
29

30
symbolic::SymbolSet MallocNode::symbols() const { return symbolic::atoms(this->size_); }
5!
31

32
std::unique_ptr<data_flow::DataFlowNode> MallocNode::
33
    clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const {
×
34
    return std::make_unique<MallocNode>(element_id, debug_info_, vertex, parent, size_);
×
35
}
36

37
void MallocNode::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
×
38
    this->size_ = symbolic::subs(this->size_, old_expression, new_expression);
×
39
}
×
40

41
nlohmann::json MallocNodeSerializer::serialize(const data_flow::LibraryNode& library_node) {
×
42
    const MallocNode& node = static_cast<const MallocNode&>(library_node);
×
43

44
    nlohmann::json j;
×
45
    j["code"] = node.code().value();
×
46

47
    sdfg::serializer::JSONSerializer serializer;
×
48
    j["size"] = serializer.expression(node.size());
×
49

50
    return j;
×
51
}
×
52

53
data_flow::LibraryNode& MallocNodeSerializer::deserialize(
×
54
    const nlohmann::json& j, builder::StructuredSDFGBuilder& builder, structured_control_flow::Block& parent
55
) {
56
    assert(j.contains("code"));
×
57
    assert(j.contains("debug_info"));
×
58
    assert(j.contains("size"));
×
59

60
    auto code = j["code"].get<std::string>();
×
61
    if (code != LibraryNodeType_Malloc.value()) {
×
62
        throw InvalidSDFGException("Invalid library node code");
×
63
    }
64

65
    sdfg::serializer::JSONSerializer serializer;
×
66
    DebugInfo debug_info = serializer.json_to_debug_info(j["debug_info"]);
×
67

68
    auto size = symbolic::parse(j.at("size"));
×
69

70
    return builder.add_library_node<MallocNode>(parent, debug_info, size);
×
71
}
×
72

73
MallocNodeDispatcher::MallocNodeDispatcher(
×
74
    codegen::LanguageExtension& language_extension,
75
    const Function& function,
76
    const data_flow::DataFlowGraph& data_flow_graph,
77
    const MallocNode& node
78
)
79
    : codegen::LibraryNodeDispatcher(language_extension, function, data_flow_graph, node) {}
×
80

81
void MallocNodeDispatcher::dispatch_code(
×
82
    codegen::PrettyPrinter& stream,
83
    codegen::PrettyPrinter& globals_stream,
84
    codegen::CodeSnippetFactory& library_snippet_factory
85
) {
86
    auto& malloc_node = static_cast<const MallocNode&>(node_);
×
87

NEW
88
    auto& graph = malloc_node.get_parent();
×
NEW
89
    auto& oedge = *graph.out_edges(malloc_node).begin();
×
90

91
    stream << malloc_node.outputs().at(0);
×
92
    stream << " = ";
×
NEW
93
    stream << "("
×
NEW
94
           << language_extension_.type_cast(
×
NEW
95
                  language_extension_.external_prefix() + "malloc(" +
×
NEW
96
                      language_extension_.expression(malloc_node.size()) + ")",
×
NEW
97
                  oedge.base_type()
×
98
              )
NEW
99
           << ");";
×
100
    stream << std::endl;
×
101
}
×
102

103
} // namespace stdlib
104
} // 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