LLVM
4.0.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
llvm.src
include
llvm
ADT
GraphTraits.h
Go to the documentation of this file.
1
//===-- llvm/ADT/GraphTraits.h - Graph traits template ----------*- C++ -*-===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file defines the little GraphTraits<X> template class that should be
11
// specialized by classes that want to be iteratable by generic graph iterators.
12
//
13
// This file also defines the marker class Inverse that is used to iterate over
14
// graphs in a graph defined, inverse ordering...
15
//
16
//===----------------------------------------------------------------------===//
17
18
#ifndef LLVM_ADT_GRAPHTRAITS_H
19
#define LLVM_ADT_GRAPHTRAITS_H
20
21
namespace
llvm {
22
23
// GraphTraits - This class should be specialized by different graph types...
24
// which is why the default version is empty.
25
//
26
template
<
class
GraphType>
27
struct
GraphTraits
{
28
// Elements to provide:
29
30
// typedef NodeRef - Type of Node token in the graph, which should
31
// be cheap to copy.
32
// typedef ChildIteratorType - Type used to iterate over children in graph,
33
// dereference to a NodeRef.
34
35
// static NodeRef getEntryNode(const GraphType &)
36
// Return the entry node of the graph
37
38
// static ChildIteratorType child_begin(NodeRef)
39
// static ChildIteratorType child_end (NodeRef)
40
// Return iterators that point to the beginning and ending of the child
41
// node list for the specified node.
42
//
43
44
// typedef ...iterator nodes_iterator; - dereference to a NodeRef
45
// static nodes_iterator nodes_begin(GraphType *G)
46
// static nodes_iterator nodes_end (GraphType *G)
47
// nodes_iterator/begin/end - Allow iteration over all nodes in the graph
48
49
// static unsigned size (GraphType *G)
50
// Return total number of nodes in the graph
51
//
52
53
54
// If anyone tries to use this class without having an appropriate
55
// specialization, make an error. If you get this error, it's because you
56
// need to include the appropriate specialization of GraphTraits<> for your
57
// graph, or you need to define it for a new graph type. Either that or
58
// your argument to XXX_begin(...) is unknown or needs to have the proper .h
59
// file #include'd.
60
//
61
typedef
typename
GraphType::UnknownGraphTypeError
NodeRef
;
62
};
63
64
65
// Inverse - This class is used as a little marker class to tell the graph
66
// iterator to iterate over the graph in a graph defined "Inverse" ordering.
67
// Not all graphs define an inverse ordering, and if they do, it depends on
68
// the graph exactly what that is. Here's an example of usage with the
69
// df_iterator:
70
//
71
// idf_iterator<Method*> I = idf_begin(M), E = idf_end(M);
72
// for (; I != E; ++I) { ... }
73
//
74
// Which is equivalent to:
75
// df_iterator<Inverse<Method*> > I = idf_begin(M), E = idf_end(M);
76
// for (; I != E; ++I) { ... }
77
//
78
template
<
class
GraphType>
79
struct
Inverse
{
80
const
GraphType &
Graph
;
81
82
inline
Inverse
(
const
GraphType &
G
) :
Graph
(G) {}
83
};
84
85
// Provide a partial specialization of GraphTraits so that the inverse of an
86
// inverse falls back to the original graph.
87
template
<
class
T>
struct
GraphTraits
<
Inverse
<
Inverse
<
T
>>> :
GraphTraits
<T> {};
88
89
}
// End llvm namespace
90
91
#endif
llvm::GraphTraits
Definition:
GraphTraits.h:27
llvm::Inverse
Definition:
GraphTraits.h:79
llvm::GraphTraits::NodeRef
GraphType::UnknownGraphTypeError NodeRef
Definition:
GraphTraits.h:61
T
llvm::Inverse::Graph
const GraphType & Graph
Definition:
GraphTraits.h:80
G
const DataFlowGraph & G
Definition:
RDFGraph.cpp:206
llvm::Inverse::Inverse
Inverse(const GraphType &G)
Definition:
GraphTraits.h:82
Generated on Wed Mar 8 2017 17:09:04 for LLVM by
1.8.6