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

daisytuner / sdfglib / 20764569418

06 Jan 2026 10:50PM UTC coverage: 62.168% (+21.4%) from 40.764%
20764569418

push

github

web-flow
Merge pull request #433 from daisytuner/clang-coverage

updates clang coverage flags

14988 of 24109 relevant lines covered (62.17%)

88.57 hits per line

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

63.64
/include/sdfg/codegen/code_generator.h
1
#pragma once
2

3
#include <filesystem>
4
#include <string>
5
#include <utility>
6

7
#include "code_snippet_factory.h"
8
#include "sdfg/analysis/mem_access_range_analysis.h"
9
#include "sdfg/codegen/instrumentation/arg_capture_plan.h"
10
#include "sdfg/codegen/instrumentation/instrumentation_plan.h"
11
#include "sdfg/codegen/utils.h"
12
#include "sdfg/structured_sdfg.h"
13
#include "sdfg/types/type.h"
14

15
namespace sdfg {
16
namespace codegen {
17

18
/**
19
 * @brief Base class for code generators
20
 *
21
 * This class provides the basic structure for code generators.
22
 * It contains the streams for the includes, classes, globals, library functions and main code.
23
 */
24
class CodeGenerator {
25
protected:
26
    /// @brief Reference to the schedule
27
    StructuredSDFG& sdfg_;
28

29
    /// @brief Analysis manager for the SDFG
30
    analysis::AnalysisManager& analysis_manager_;
31

32
    /// @brief Instrumentation strategy
33
    InstrumentationPlan& instrumentation_plan_;
34
    ArgCapturePlan& arg_capture_plan_;
35

36
    /// @brief Stream for includes
37
    PrettyPrinter includes_stream_;
38

39
    /// @brief Stream for classes
40
    PrettyPrinter classes_stream_;
41

42
    /// @brief Stream for global variables and functions
43
    PrettyPrinter globals_stream_;
44

45
    /// @brief Stream for library functions
46
    std::shared_ptr<CodeSnippetFactory> library_snippet_factory_;
47

48
    /// @brief Main stream
49
    PrettyPrinter main_stream_;
50

51
    /// @brief Prefix to use for external functions
52
    std::string externals_prefix_;
53

54
public:
55
    CodeGenerator(
56
        StructuredSDFG& sdfg,
57
        analysis::AnalysisManager& analysis_manager,
58
        InstrumentationPlan& instrumentation_plan,
59
        ArgCapturePlan& arg_capture_plan,
60
        std::shared_ptr<CodeSnippetFactory> library_snippet_factory = std::make_shared<CodeSnippetFactory>(),
61
        const std::string& externals_prefix = ""
62
    )
63
        : sdfg_(sdfg), analysis_manager_(analysis_manager), instrumentation_plan_(instrumentation_plan),
20✔
64
          arg_capture_plan_(arg_capture_plan), library_snippet_factory_(std::move(library_snippet_factory)),
20✔
65
          externals_prefix_(externals_prefix) {};
20✔
66

67

68
    virtual ~CodeGenerator() = default;
20✔
69

70
    /**
71
     * @brief Generate the code
72
     *
73
     * @return true if the code was generated successfully
74
     */
75
    virtual bool generate() = 0;
76

77
    /// @brief Generate a function definition for the SDFG
78
    virtual std::string function_definition() = 0;
79

80
    /// @brief Generate the SDFG's code into source files
81
    virtual bool as_source(const std::filesystem::path& header_path, const std::filesystem::path& source_path) = 0;
82

83
    /// @brief Generate only the function source code and append it to the source file. @ref as_source generates this
84
    /// into `source_path` after includes, globals and structs
85
    virtual void append_function_source(std::ofstream& ofs_source) = 0;
86

87
    /// @brief Get the includes
88
    const PrettyPrinter& includes() const { return this->includes_stream_; };
×
89

90
    /// @brief Get the classes
91
    const PrettyPrinter& classes() const { return this->classes_stream_; };
7✔
92

93
    /// @brief Get the globals
94
    const PrettyPrinter& globals() const { return this->globals_stream_; };
3✔
95

96
    /// @brief all created library snippets
97
    const std::unordered_map<std::string, CodeSnippet>& library_snippets() const {
×
98
        return this->library_snippet_factory_->snippets();
×
99
    };
×
100

101
    /// @brief Get the main stream
102
    const PrettyPrinter& main() const { return this->main_stream_; };
7✔
103
};
104

105
} // namespace codegen
106
} // 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