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

daisytuner / docc / 26651271267

29 May 2026 05:11PM UTC coverage: 60.767% (-0.1%) from 60.869%
26651271267

push

github

web-flow
Merge pull request #726 from daisytuner/docc-llvm-fixes

Fixed LLVM frontend bugs

133 of 249 new or added lines in 5 files covered. (53.41%)

14 existing lines in 3 files now uncovered.

35323 of 58129 relevant lines covered (60.77%)

10997.13 hits per line

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

51.49
/sdfg/src/codegen/code_generators/c_style_base_code_generator.cpp
1

2
#include "sdfg/codegen/code_generators/c_style_base_code_generator.h"
3

4
#include "sdfg/helpers/helpers.h"
5

6
namespace sdfg::codegen {
7

8
CStyleBaseCodeGenerator::CStyleBaseCodeGenerator(
9
    StructuredSDFG& sdfg,
10
    analysis::AnalysisManager& analysis_manager,
11
    InstrumentationPlan& instrumentation_plan,
12
    ArgCapturePlan& arg_capture_plan,
13
    std::shared_ptr<CodeSnippetFactory> library_snippet_factory,
14
    const std::string& externals_prefix
15
)
16
    : CodeGenerator(
19✔
17
          sdfg,
19✔
18
          analysis_manager,
19✔
19
          instrumentation_plan,
19✔
20
          arg_capture_plan,
19✔
21
          std::move(library_snippet_factory),
19✔
22
          externals_prefix
19✔
23
      ) {
19✔
24
    if (sdfg.type() != FunctionType_CPU) {
19✔
25
        throw std::runtime_error("CStyleBaseCodeGenerator can only be used for CPU SDFGs");
×
26
    }
×
27
};
19✔
28

29
bool CStyleBaseCodeGenerator::generate() {
17✔
30
    this->dispatch_includes();
17✔
31
    this->dispatch_structures();
17✔
32
    this->dispatch_globals();
17✔
33
    this->dispatch_schedule();
17✔
34
    return true;
17✔
35
}
17✔
36

37
bool CStyleBaseCodeGenerator::emit_header(PrettyPrinter& out) {
×
38
    out << "#pragma once" << std::endl;
×
39

40
    dispatch_header(out);
×
41
    return true;
×
42
}
×
43

44
void CStyleBaseCodeGenerator::dispatch_header(PrettyPrinter& out) {
×
45
    dispatch_header_includes(out);
×
46
    dispatch_header_structures(out);
×
47
}
×
48

49
void CStyleBaseCodeGenerator::dispatch_includes() { dispatch_header_includes(this->includes_stream_); }
17✔
50

51
void CStyleBaseCodeGenerator::dispatch_structures() { dispatch_header_structures(this->classes_stream_); }
17✔
52

53
bool CStyleBaseCodeGenerator::emit_main_source(std::ostream& out, const std::filesystem::path& header_path) {
×
54
    out << "#include \"" << header_path.filename().string() << "\"" << std::endl;
×
55
    dispatch_globals();
×
56
    dispatch_schedule();
×
57

58
    for (auto& snippet : library_snippet_factory_->globals_snippets()) {
×
59
        out << snippet << std::endl;
×
60
    }
×
61
    std::vector<std::string> includes;
×
62
    for (auto* dep : library_snippet_factory_->get_used_lib_dependencies()) {
×
63
        dep->enumerate_includes(includes);
×
64
    }
×
65
    for (auto& include : includes) {
×
66
        out << "#include <" << include << ">" << std::endl;
×
67
    }
×
68

69
    out << this->globals_stream_.str() << std::endl;
×
70

71
    append_function_source(out);
×
72
    return true;
×
73
}
×
74

75
bool CStyleBaseCodeGenerator::as_source(const std::filesystem::path& header_path, const std::filesystem::path& source_path) {
1✔
76
    std::ofstream ofs_header(header_path, std::ofstream::out | std::ofstream::trunc);
1✔
77
    if (!ofs_header.is_open()) {
1✔
78
        return false;
×
79
    }
×
80

81
    std::ofstream ofs_source(source_path, std::ofstream::out | std::ofstream::trunc);
1✔
82
    if (!ofs_source.is_open()) {
1✔
83
        return false;
×
84
    }
×
85

86
    ofs_header << "#pragma once" << std::endl;
1✔
87
    ofs_header << this->includes_stream_.str() << std::endl;
1✔
88
    ofs_header << this->classes_stream_.str() << std::endl;
1✔
89
    ofs_header.close();
1✔
90

91
    ofs_source << "#include \"" << header_path.filename().string() << "\"" << std::endl;
1✔
92
    for (auto& snippet : library_snippet_factory_->globals_snippets()) {
1✔
93
        ofs_source << snippet << std::endl;
×
94
    }
×
95
    std::vector<std::string> includes;
1✔
96
    for (auto* dep : library_snippet_factory_->get_used_lib_dependencies()) {
1✔
NEW
97
        dep->enumerate_includes(includes);
×
NEW
98
    }
×
99
    for (auto& include : includes) {
1✔
NEW
100
        ofs_source << "#include <" << include << ">" << std::endl;
×
NEW
101
    }
×
102
    ofs_source << this->globals_stream_.str() << std::endl;
1✔
103

104
    append_function_source(ofs_source);
1✔
105

106
    ofs_source.close();
1✔
107

108
    return true;
1✔
109
}
1✔
110

111
void CStyleBaseCodeGenerator::append_function_source(std::ostream& ofs_source) {
1✔
112
    std::unique_ptr<std::vector<CaptureVarPlan>> capturePlan;
1✔
113
    if (!arg_capture_plan_.is_empty()) {
1✔
114
        this->emit_capture_context_init(ofs_source);
×
115
    }
×
116

117
    ofs_source << this->function_definition() << std::endl;
1✔
118
    ofs_source << "{" << std::endl;
1✔
119

120
    auto init_once = library_snippet_factory_->find(CODE_SNIPPET_INIT_ONCE);
1✔
121
    if (init_once != library_snippet_factory_->snippets().end()) {
1✔
122
        ofs_source << init_once->second.stream().str() << std::endl;
×
123
    }
×
124

125
    for (auto& snippet : library_snippet_factory_->setup_snippets()) {
1✔
126
        ofs_source << snippet << std::endl;
×
127
    }
×
128

129
    ofs_source << this->main_stream_.str() << std::endl;
1✔
130

131
    for (auto& snippet : library_snippet_factory_->teardown_snippets()) {
1✔
132
        ofs_source << snippet << std::endl;
×
133
    }
×
134

135
    auto deinit_once = library_snippet_factory_->find(CODE_SNIPPET_DEINIT_ONCE);
1✔
136
    if (deinit_once != library_snippet_factory_->snippets().end()) {
1✔
137
        ofs_source << deinit_once->second.stream().str() << std::endl;
×
138
    }
×
139

140
    ofs_source << "}" << std::endl;
1✔
141
}
1✔
142

143
} // namespace sdfg::codegen
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