GTIRB  v2.1.0
GrammaTech Intermediate Representation for Binaries: C++ API
Namespaces | Typedefs | Enumerations | Functions
CFG.hpp File Reference

Types and operations for interprocedural control flow graphs (CFGs). More...

#include <gtirb/Casting.hpp>
#include <gtirb/Export.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/iterator/filter_iterator.hpp>
#include <boost/iterator/indirect_iterator.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/range/iterator_range.hpp>
#include <variant>
Include dependency graph for CFG.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 gtirb
 Main namespace for the GTIRB API.
 

Typedefs

using gtirb::block_iterator = cfg_node_cast_iter< CodeBlock >
 Iterator over blocks (Block). More...
 
using gtirb::CFG = CfgBuilder< boost::listS, boost::listS, boost::bidirectionalS >::type
 Interprocedural control flow graph, with vertices of type Block. More...
 
using gtirb::cfg_iterator = boost::indirect_iterator< cfg_node_iter_base >
 Iterator over CfgNodes (CfgNode). More...
 
using gtirb::cfg_predecessors_range = boost::iterator_range< boost::transform_iterator< EdgeDescrToNodeLabel< CfgPredecessorTraits, CfgNode * >, CfgPredecessorTraits::edge_iterator > >
 iterator_range over a CfgNode's predecessors, non-const version More...
 
using gtirb::cfg_successors_range = boost::iterator_range< boost::transform_iterator< EdgeDescrToNodeLabel< CfgSuccessorTraits, CfgNode * >, CfgSuccessorTraits::edge_iterator > >
 iterator_range over a CfgNode's successors, non-const version More...
 
using gtirb::const_block_iterator = cfg_node_cast_iter< const CodeBlock >
 Constant iterator over blocks (Block). More...
 
using gtirb::const_cfg_iterator = boost::indirect_iterator< cfg_node_iter_base, const CfgNode >
 Const iterator over CfgNodes (CfgNode). More...
 
using gtirb::const_cfg_predecessors_range = boost::iterator_range< boost::transform_iterator< EdgeDescrToNodeLabel< CfgPredecessorTraits, const CfgNode * >, CfgPredecessorTraits::edge_iterator > >
 iterator_range over a CfgNode's predecessors, const version More...
 
using gtirb::const_cfg_successors_range = boost::iterator_range< boost::transform_iterator< EdgeDescrToNodeLabel< CfgSuccessorTraits, const CfgNode * >, CfgSuccessorTraits::edge_iterator > >
 iterator_range over a CfgNode's successors, const version More...
 
using gtirb::EdgeLabel = std::optional< std::tuple< ConditionalEdge, DirectEdge, EdgeType > >
 A label on a CFG edge. More...
 

Enumerations

enum  gtirb::ConditionalEdge : bool { gtirb::ConditionalEdge::OnFalse, gtirb::ConditionalEdge::OnTrue }
 Indicates whether an edge is conditional on true. More...
 
enum  gtirb::DirectEdge : bool { gtirb::DirectEdge::IsIndirect, gtirb::DirectEdge::IsDirect }
 Indicates whether an edge represents indirect control flow. More...
 
enum  gtirb::EdgeType {
  gtirb::EdgeType::Branch, gtirb::EdgeType::Call, gtirb::EdgeType::Fallthrough, gtirb::EdgeType::Return,
  gtirb::EdgeType::Syscall, gtirb::EdgeType::Sysret
}
 Indicates the type of control flow transfer indicated by this edge. More...
 

Functions

GTIRB_EXPORT_API std::optional< CFG::edge_descriptor > gtirb::addEdge (const CfgNode *From, const CfgNode *To, CFG &Cfg)
 Create a new edge between two CFG nodes if they exist in the graph. More...
 
GTIRB_EXPORT_API std::pair< CFG::vertex_descriptor, bool > gtirb::addVertex (CfgNode *B, CFG &Cfg)
 Add a node to the CFG. More...
 
GTIRB_EXPORT_API boost::iterator_range< block_iterator > gtirb::blocks (CFG &Cfg)
 Get a range of just the Block elements in the specified graph. More...
 
GTIRB_EXPORT_API boost::iterator_range< const_block_iterator > gtirb::blocks (const CFG &Cfg)
 Get a constant range of just the Block elements in the specified graph. More...
 
cfg_predecessors_range gtirb::cfgPredecessors (CFG &G, const CfgNode *N)
 Returns an iterator_range to iterate the predecessors of a CfgNode. More...
 
const_cfg_predecessors_range gtirb::cfgPredecessors (const CFG &G, const CfgNode *N)
 
cfg_successors_range gtirb::cfgSuccessors (CFG &G, const CfgNode *N)
 Returns an iterator_range to iterate the successors of a CfgNode. More...
 
const_cfg_successors_range gtirb::cfgSuccessors (const CFG &G, const CfgNode *N)
 
GTIRB_EXPORT_API std::optional< CFG::vertex_descriptor > gtirb::getVertex (const CfgNode *N, const CFG &Cfg)
 Get the boost::graph vertex descriptor for a CfgNode if it is in the graph. More...
 
GTIRB_EXPORT_API boost::iterator_range< cfg_iterator > gtirb::nodes (CFG &Cfg)
 Get a range of the CfgNode elements in the specified graph. More...
 
GTIRB_EXPORT_API boost::iterator_range< const_cfg_iterator > gtirb::nodes (const CFG &Cfg)
 Get a constant range of the CfgNode elements in the specified graph. More...
 
GTIRB_EXPORT_API std::ostream & gtirb::operator<< (std::ostream &OS, const ConditionalEdge &CE)
 
GTIRB_EXPORT_API std::ostream & gtirb::operator<< (std::ostream &OS, const DirectEdge &DE)
 
GTIRB_EXPORT_API std::ostream & gtirb::operator<< (std::ostream &OS, const EdgeLabel &Label)
 
GTIRB_EXPORT_API std::ostream & gtirb::operator<< (std::ostream &OS, const EdgeType &ET)
 
GTIRB_EXPORT_API bool gtirb::removeEdge (const CfgNode *From, const CfgNode *To, CFG &Cfg)
 Remove all edges between the source and target nodes from the CFG. More...
 
GTIRB_EXPORT_API bool gtirb::removeEdge (const CfgNode *From, const CfgNode *To, EdgeLabel Label, CFG &Cfg)
 Remove all edges with given label between the source and target nodes from the CFG. More...
 
GTIRB_EXPORT_API bool gtirb::removeVertex (CfgNode *N, CFG &Cfg)
 Remove a node from the CFG. More...
 

Detailed Description

Types and operations for interprocedural control flow graphs (CFGs).

See also
Control Flow Graphs (CFGs)