Skip to content

Commit

Permalink
fixup! Add class to compute control flow graphs for blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Mar 20, 2024
1 parent 0b69953 commit 6beb60c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 1 addition & 3 deletions hilti/toolchain/include/compiler/detail/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ struct Flow : MetaNode {
class CFG {
public:
using N = Node*;
using Node = CXXGraph::Node<N>;
using Edge = CXXGraph::DirectedEdge<N>;
using NodeP = std::shared_ptr<const Node>;
using NodeP = std::shared_ptr<const CXXGraph::Node<N>>;

CFG(const N& root);

Expand Down
7 changes: 4 additions & 3 deletions hilti/toolchain/src/compiler/cfg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ CFG::NodeP CFG::add_return(const NodeP& parent, const N& expression) {
return parent;
}

std::shared_ptr<const CFG::Node> CFG::get_or_add_node(const N& n) {
std::shared_ptr<const CXXGraph::Node<CFG::N>> CFG::get_or_add_node(const N& n) {
const auto& id = node_id(n);
if ( auto x = g.getNode(id) )
return *x;

auto y = std::make_shared<Node>(id, n);
auto y = std::make_shared<CXXGraph::Node<N>>(id, n);
g.addNode(y);
return y;
}
Expand All @@ -171,7 +171,8 @@ void CFG::add_edge(NodeP from, NodeP to) {
xs.end() != std::find_if(xs.begin(), xs.end(), [&](const auto& e) { return e->getNodePair().second == to; }) )
return;
else {
auto e = std::make_shared<Edge>(g.getEdgeSet().size(), std::move(from), std::move(to));
auto e =
std::make_shared<CXXGraph::DirectedEdge<CFG::N>>(g.getEdgeSet().size(), std::move(from), std::move(to));
g.addEdge(std::move(e));
return;
}
Expand Down

0 comments on commit 6beb60c

Please sign in to comment.