Static Value-Flow Analysis
Loading...
Searching...
No Matches
SparseObjGraph.h
Go to the documentation of this file.
1//===- SparseObjGraph.h - Static packed Obj value-flow routes -------------===//
2
3#ifndef INCLUDE_GRAPHS_SPARSEOBJGRAPH_H_
4#define INCLUDE_GRAPHS_SPARSEOBJGRAPH_H_
5
6#include "Graphs/ICFG.h"
7
8#include <deque>
9#include <map>
10#include <memory>
11
12namespace SVF
13{
14
15class PointerAnalysis;
16class PAG;
17class SVFG;
18class SparseObjNode;
19
21
26{
27public:
29 const NodeBS* bases)
30 : GenericSparseObjEdgeTy(source, target, 0), bases(bases) {}
31
33 const NodeBS& getBases() const
34 {
35 return *bases;
36 }
37 std::string toString() const;
38
39private:
40 friend class SparseObjGraph;
41 const NodeBS* bases;
42};
43
45
51{
52public:
57
60
61 const ICFGNode* getICFGNode() const
62 {
63 return location;
64 }
65 std::string toString() const;
66};
67
69
80{
81public:
84
86 SparseObjGraph(const SVFG& svfg, ICFG& icfg,
87 PointerAnalysis& pta, const PAG& pag);
88 ~SparseObjGraph() override;
91
93 const std::vector<const Edge*>& getInputs(const ICFGNode* node) const;
95 std::string toString() const;
97 void dump(const std::string& file);
98
99 const PAG& getPAG() const
100 {
101 return pag;
102 }
103
104private:
105 typedef std::pair<const ICFGNode*, const IntraCFGEdge*> NodeKey;
106 typedef std::pair<NodeKey, NodeKey> EdgeKey;
107
108 bool isBranch(const ICFGNode* node) const;
109 bool isControlBoundary(const ICFGNode* node) const;
112 void addRoute(const NodeBS& bases, const ICFGNode* source,
113 const ICFGNode* target, const IntraCFGEdge* branch);
114 void addRoute(NodeID base, const ICFGNode* source,
115 const ICFGNode* target, const IntraCFGEdge* branch);
117 void connectFunction(const FunObjVar* fun, const NodeBS& funBases,
118 const Map<const ICFGNode*, NodeBS>& eventsAt);
121 void addSource(const ICFGNode* node, const NodeBS& bases);
123 void connectCallBypass(const CallICFGNode* call, const NodeBS& bases);
126 void connectSegment(const FunObjVar* fun, const ICFGNode* source,
127 const ICFGNode* start, const IntraCFGEdge* branch,
128 const NodeBS& bases,
129 const Map<const ICFGNode*, NodeBS>& eventsAt);
130 static const NodeBS& getEvents(const Map<const ICFGNode*, NodeBS>& eventsAt,
131 const ICFGNode* node);
132 Node* getOrCreateNode(const ICFGNode* location, const IntraCFGEdge* branch);
133 const NodeBS* intern(const NodeBS& bases);
134 void finalize();
135
137 const PAG& pag;
139 std::map<EdgeKey, NodeBS> routeLabels;
147
151 std::deque<const ICFGNode*> sourceWorklist;
152};
153
154} // namespace SVF
155
156namespace SVF
157{
158
159template<>
164
165template<>
170
171template<>
177
178} // namespace SVF
179
180#endif
Definition PAG.h:46
NodeID id
Node ID.
Definition SVFValue.h:204
const NodeBS & getBases() const
Base Obj IDs routed over this edge; each base carries all its fields.
friend class SparseObjGraph
SparseObjEdge(SparseObjNode *source, SparseObjNode *target, const NodeBS *bases)
std::string toString() const
const NodeBS * bases
const std::vector< const Edge * > & getInputs(const ICFGNode *node) const
Return incoming edges at this ICFG location for client-side value flow.
void addSource(const ICFGNode *node, const NodeBS &bases)
bool isBranch(const ICFGNode *node) const
SparseObjGraph & operator=(const SparseObjGraph &)=delete
Map< const ICFGNode *, std::vector< const Edge * > > inputs
static const NodeBS & getEvents(const Map< const ICFGNode *, NodeBS > &eventsAt, const ICFGNode *node)
const PAG & getPAG() const
Map< NodeKey, Node * > nodes
std::pair< const ICFGNode *, const IntraCFGEdge * > NodeKey
Map< u64_t, std::vector< std::unique_ptr< NodeBS > > > labels
Interned labels, bucketed by hash.
SparseObjGraph(const SVFG &svfg, ICFG &icfg, PointerAnalysis &pta, const PAG &pag)
Construction uses static graphs and points-to results, not AE state.
void connectCallBypass(const CallICFGNode *call, const NodeBS &bases)
Route the bases that no callee returns from the call to its return site.
Map< const ICFGNode *, NodeBS > returnedGroups
Map< const ICFGNode *, Map< const FunObjVar *, NodeBS > > returnedGroupsByCallee
bool isControlBoundary(const ICFGNode *node) const
std::map< EdgeKey, NodeBS > routeLabels
Map< const ICFGNode *, NodeBS > doneSources
Worklist of connectFunction for the function being connected.
Node * getOrCreateNode(const ICFGNode *location, const IntraCFGEdge *branch)
void connectFunction(const FunObjVar *fun, const NodeBS &funBases, const Map< const ICFGNode *, NodeBS > &eventsAt)
Walk one function once, carrying base sets instead of one base.
void connectSegment(const FunObjVar *fun, const ICFGNode *source, const ICFGNode *start, const IntraCFGEdge *branch, const NodeBS &bases, const Map< const ICFGNode *, NodeBS > &eventsAt)
~SparseObjGraph() override
std::deque< const ICFGNode * > sourceWorklist
std::string toString() const
Describe the static nodes and edges as text, without AE values.
SparseObjGraph(const SparseObjGraph &)=delete
const NodeBS * intern(const NodeBS &bases)
Map< const ICFGNode *, NodeBS > pendingSources
void dump(const std::string &file)
Write a DOT graph to <file>.dot through GraphPrinter.
void addRoute(const NodeBS &bases, const ICFGNode *source, const ICFGNode *target, const IntraCFGEdge *branch)
std::pair< NodeKey, NodeKey > EdgeKey
const IntraCFGEdge * branch
const ICFGNode * location
std::string toString() const
SparseObjNode(NodeID id, const ICFGNode *location, const IntraCFGEdge *branch)
const ICFGNode * getICFGNode() const
for isBitcode
Definition BasicTypes.h:70
u32_t NodeID
Definition GeneralType.h:76
GenericGraph< SparseObjNode, SparseObjEdge > GenericSparseObjGraphTy
GenericNode< SparseObjNode, SparseObjEdge > GenericSparseObjNodeTy
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition GeneralType.h:56
SparseBitVector NodeBS
Definition GeneralType.h:82
GenericEdge< SparseObjNode > GenericSparseObjEdgeTy