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

daisytuner / sdfglib / 20792180504

07 Jan 2026 06:28PM UTC coverage: 62.339% (+0.2%) from 62.168%
20792180504

Pull #436

github

web-flow
Merge 6e411abb2 into acd6225ac
Pull Request #436: Add comprehensive tests and Doxygen documentation for SDFG transformations

14987 of 24041 relevant lines covered (62.34%)

88.99 hits per line

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

53.85
/src/analysis/scope_analysis.cpp
1
#include "sdfg/analysis/scope_analysis.h"
2
#include <vector>
3
#include "sdfg/structured_control_flow/control_flow_node.h"
4

5
namespace sdfg {
6
namespace analysis {
7

8
ScopeAnalysis::ScopeAnalysis(StructuredSDFG& sdfg) : Analysis(sdfg) {}
168✔
9

10
void ScopeAnalysis::
11
    run(structured_control_flow::ControlFlowNode* current, structured_control_flow::ControlFlowNode* parent_scope) {
554✔
12
    if (dynamic_cast<structured_control_flow::Block*>(current)) {
554✔
13
        this->scope_tree_[current] = parent_scope;
231✔
14
    } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(current)) {
323✔
15
        this->scope_tree_[current] = parent_scope;
249✔
16
        for (size_t i = 0; i < sequence_stmt->size(); i++) {
554✔
17
            this->run(&sequence_stmt->at(i).first, current);
305✔
18
        }
305✔
19
    } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(current)) {
249✔
20
        this->scope_tree_[current] = parent_scope;
7✔
21
        for (size_t i = 0; i < if_else_stmt->size(); i++) {
21✔
22
            this->run(&if_else_stmt->at(i).first, current);
14✔
23
        }
14✔
24
    } else if (auto while_stmt = dynamic_cast<structured_control_flow::While*>(current)) {
67✔
25
        this->scope_tree_[current] = parent_scope;
×
26
        this->run(&while_stmt->root(), current);
×
27
    } else if (auto for_stmt = dynamic_cast<structured_control_flow::StructuredLoop*>(current)) {
67✔
28
        this->scope_tree_[current] = parent_scope;
67✔
29
        this->run(&for_stmt->root(), current);
67✔
30
    } else if (dynamic_cast<structured_control_flow::Break*>(current)) {
67✔
31
        this->scope_tree_[current] = parent_scope;
×
32
    } else if (dynamic_cast<structured_control_flow::Continue*>(current)) {
×
33
        this->scope_tree_[current] = parent_scope;
×
34
    } else if (dynamic_cast<structured_control_flow::Return*>(current)) {
×
35
        this->scope_tree_[current] = parent_scope;
×
36
    } else {
×
37
        throw std::runtime_error("Unsupported control flow node type");
×
38
    }
×
39
}
554✔
40

41
void ScopeAnalysis::run(AnalysisManager& analysis_manager) {
168✔
42
    this->scope_tree_.clear();
168✔
43
    this->run(&this->sdfg_.root(), nullptr);
168✔
44
}
168✔
45

46
const std::unordered_map<const structured_control_flow::ControlFlowNode*, structured_control_flow::ControlFlowNode*>&
47
ScopeAnalysis::scope_tree() const {
×
48
    return this->scope_tree_;
×
49
}
×
50

51
structured_control_flow::ControlFlowNode* ScopeAnalysis::parent_scope(const structured_control_flow::ControlFlowNode*
52
                                                                          scope) const {
179✔
53
    if (this->scope_tree_.find(scope) == this->scope_tree_.end()) {
179✔
54
        return nullptr;
×
55
    }
×
56
    return this->scope_tree_.at(scope);
179✔
57
}
179✔
58

59
std::vector<structured_control_flow::ControlFlowNode*> ScopeAnalysis::
60
    ancestor_scopes(const structured_control_flow::ControlFlowNode* node) const {
×
61
    std::vector<structured_control_flow::ControlFlowNode*> result;
×
62
    auto parent = parent_scope(node);
×
63

64
    while (parent) {
×
65
        result.push_back(parent);
×
66
        parent = parent_scope(parent);
×
67
    }
×
68

69
    return result;
×
70
}
×
71

72
} // namespace analysis
73
} // 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