svf-lib 1.0.1375 → 1.0.1376
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SVF-osx/Release-build/svf-llvm/libSvfLLVM.a +0 -0
- package/SVF-osx/svf/include/include/AbstractExecution/AbstractValue.h +79 -0
- package/SVF-osx/svf/include/include/AbstractExecution/AddressValue.h +210 -0
- package/SVF-osx/svf/include/include/AbstractExecution/ExeState.h +223 -0
- package/SVF-osx/svf/include/include/AbstractExecution/IntervalExeState.h +425 -0
- package/SVF-osx/svf/include/include/AbstractExecution/IntervalValue.h +868 -0
- package/SVF-osx/svf/include/include/AbstractExecution/NumericLiteral.h +406 -0
- package/SVF-osx/svf/include/include/AbstractExecution/RelExeState.h +225 -0
- package/SVF-osx/svf/include/include/AbstractExecution/RelationSolver.h +68 -0
- package/SVF-osx/svf/include/include/AbstractExecution/SVFIR2ItvExeState.h +186 -0
- package/SVF-osx/svf/include/include/AbstractExecution/WTO.h +845 -0
- package/SVF-osx/svf/include/include/CFL/CFGNormalizer.h +84 -0
- package/SVF-osx/svf/include/include/CFL/CFLAlias.h +176 -0
- package/SVF-osx/svf/include/include/CFL/CFLBase.h +115 -0
- package/SVF-osx/svf/include/include/CFL/CFLData.h +316 -0
- package/SVF-osx/svf/include/include/CFL/CFLDataBuilder.h +91 -0
- package/SVF-osx/svf/include/include/CFL/CFLGramGraphChecker.h +74 -0
- package/SVF-osx/svf/include/include/CFL/CFLGrammar.h +468 -0
- package/SVF-osx/svf/include/include/CFL/CFLGrammar.txt +15 -0
- package/SVF-osx/svf/include/include/CFL/CFLGraphBuilder.h +193 -0
- package/SVF-osx/svf/include/include/CFL/CFLSolver.h +136 -0
- package/SVF-osx/svf/include/include/CFL/CFLStat.h +67 -0
- package/SVF-osx/svf/include/include/CFL/CFLVF.h +65 -0
- package/SVF-osx/svf/include/include/CFL/GrammarBuilder.h +100 -0
- package/SVF-osx/svf/include/include/CFL/PEGGrammar.txt +11 -0
- package/SVF-osx/svf/include/include/CFL/VFG.txt +7 -0
- package/SVF-osx/svf/include/include/DDA/ContextDDA.h +230 -0
- package/SVF-osx/svf/include/include/DDA/DDAClient.h +168 -0
- package/SVF-osx/svf/include/include/DDA/DDAPass.h +99 -0
- package/SVF-osx/svf/include/include/DDA/DDAStat.h +138 -0
- package/SVF-osx/svf/include/include/DDA/DDAVFSolver.h +789 -0
- package/SVF-osx/svf/include/include/DDA/FlowDDA.h +178 -0
- package/SVF-osx/svf/include/include/FastCluster/LICENSE.TXT +13 -0
- package/SVF-osx/svf/include/include/FastCluster/fastcluster.h +80 -0
- package/SVF-osx/svf/include/include/Graphs/CFLGraph.h +215 -0
- package/SVF-osx/svf/include/include/Graphs/CHG.h +351 -0
- package/SVF-osx/svf/include/include/Graphs/ConsG.h +408 -0
- package/SVF-osx/svf/include/include/Graphs/ConsGEdge.h +353 -0
- package/SVF-osx/svf/include/include/Graphs/ConsGNode.h +391 -0
- package/SVF-osx/svf/include/include/Graphs/DOTGraphTraits.h +188 -0
- package/SVF-osx/svf/include/include/Graphs/GenericGraph.h +620 -0
- package/SVF-osx/svf/include/include/Graphs/GraphPrinter.h +111 -0
- package/SVF-osx/svf/include/include/Graphs/GraphTraits.h +150 -0
- package/SVF-osx/svf/include/include/Graphs/GraphWriter.h +380 -0
- package/SVF-osx/svf/include/include/Graphs/ICFG.h +331 -0
- package/SVF-osx/svf/include/include/Graphs/ICFGEdge.h +264 -0
- package/SVF-osx/svf/include/include/Graphs/ICFGNode.h +523 -0
- package/SVF-osx/svf/include/include/Graphs/ICFGStat.h +164 -0
- package/SVF-osx/svf/include/include/Graphs/IRGraph.h +243 -0
- package/SVF-osx/svf/include/include/Graphs/PTACallGraph.h +471 -0
- package/SVF-osx/svf/include/include/Graphs/SVFG.h +490 -0
- package/SVF-osx/svf/include/include/Graphs/SVFGEdge.h +237 -0
- package/SVF-osx/svf/include/include/Graphs/SVFGNode.h +513 -0
- package/SVF-osx/svf/include/include/Graphs/SVFGOPT.h +362 -0
- package/SVF-osx/svf/include/include/Graphs/SVFGStat.h +273 -0
- package/SVF-osx/svf/include/include/Graphs/ThreadCallGraph.h +422 -0
- package/SVF-osx/svf/include/include/Graphs/VFG.h +664 -0
- package/SVF-osx/svf/include/include/Graphs/VFGEdge.h +295 -0
- package/SVF-osx/svf/include/include/Graphs/VFGNode.h +1197 -0
- package/SVF-osx/svf/include/include/MSSA/MSSAMuChi.h +722 -0
- package/SVF-osx/svf/include/include/MSSA/MemPartition.h +169 -0
- package/SVF-osx/svf/include/include/MSSA/MemRegion.h +491 -0
- package/SVF-osx/svf/include/include/MSSA/MemSSA.h +452 -0
- package/SVF-osx/svf/include/include/MSSA/SVFGBuilder.h +98 -0
- package/SVF-osx/svf/include/include/MTA/FSMPTA.h +270 -0
- package/SVF-osx/svf/include/include/MTA/LockAnalysis.h +517 -0
- package/SVF-osx/svf/include/include/MTA/MHP.h +565 -0
- package/SVF-osx/svf/include/include/MTA/MTA.h +101 -0
- package/SVF-osx/svf/include/include/MTA/MTAResultValidator.h +448 -0
- package/SVF-osx/svf/include/include/MTA/MTAStat.h +74 -0
- package/SVF-osx/svf/include/include/MTA/PCG.h +229 -0
- package/SVF-osx/svf/include/include/MTA/TCT.h +599 -0
- package/SVF-osx/svf/include/include/MemoryModel/AbstractPointsToDS.h +316 -0
- package/SVF-osx/svf/include/include/MemoryModel/ConditionalPT.h +878 -0
- package/SVF-osx/svf/include/include/MemoryModel/LocationSet.h +148 -0
- package/SVF-osx/svf/include/include/MemoryModel/MutablePointsToDS.h +1025 -0
- package/SVF-osx/svf/include/include/MemoryModel/PersistentPointsToCache.h +463 -0
- package/SVF-osx/svf/include/include/MemoryModel/PersistentPointsToDS.h +955 -0
- package/SVF-osx/svf/include/include/MemoryModel/PointerAnalysis.h +452 -0
- package/SVF-osx/svf/include/include/MemoryModel/PointerAnalysisImpl.h +590 -0
- package/SVF-osx/svf/include/include/MemoryModel/PointsTo.h +255 -0
- package/SVF-osx/svf/include/include/MemoryModel/SVFLoop.h +164 -0
- package/SVF-osx/svf/include/include/SABER/DoubleFreeChecker.h +76 -0
- package/SVF-osx/svf/include/include/SABER/FileChecker.h +82 -0
- package/SVF-osx/svf/include/include/SABER/LeakChecker.h +124 -0
- package/SVF-osx/svf/include/include/SABER/ProgSlice.h +313 -0
- package/SVF-osx/svf/include/include/SABER/SaberCheckerAPI.h +166 -0
- package/SVF-osx/svf/include/include/SABER/SaberCondAllocator.h +310 -0
- package/SVF-osx/svf/include/include/SABER/SaberSVFGBuilder.h +104 -0
- package/SVF-osx/svf/include/include/SABER/SrcSnkDDA.h +321 -0
- package/SVF-osx/svf/include/include/SABER/SrcSnkSolver.h +186 -0
- package/SVF-osx/svf/include/include/SVFIR/PAGBuilderFromFile.h +80 -0
- package/SVF-osx/svf/include/include/SVFIR/SVFIR.h +659 -0
- package/SVF-osx/svf/include/include/SVFIR/SVFModule.h +233 -0
- package/SVF-osx/svf/include/include/SVFIR/SVFStatements.h +1136 -0
- package/SVF-osx/svf/include/include/SVFIR/SVFType.h +527 -0
- package/SVF-osx/svf/include/include/SVFIR/SVFValue.h +1120 -0
- package/SVF-osx/svf/include/include/SVFIR/SVFVariables.h +721 -0
- package/SVF-osx/svf/include/include/SVFIR/SymbolTableInfo.h +597 -0
- package/SVF-osx/svf/include/include/Util/Annotator.h +180 -0
- package/SVF-osx/svf/include/include/Util/BitVector.h +55 -0
- package/SVF-osx/svf/include/include/Util/CallGraphBuilder.h +74 -0
- package/SVF-osx/svf/include/include/Util/Casting.h +426 -0
- package/SVF-osx/svf/include/include/Util/CommandLine.h +530 -0
- package/SVF-osx/svf/include/include/Util/CoreBitVector.h +214 -0
- package/SVF-osx/svf/include/include/Util/CppUtil.h +81 -0
- package/SVF-osx/svf/include/include/Util/CxtStmt.h +501 -0
- package/SVF-osx/svf/include/include/Util/DPItem.h +618 -0
- package/SVF-osx/svf/include/include/Util/ExtAPI.h +339 -0
- package/SVF-osx/svf/include/include/Util/ExtAPI.json +5707 -0
- package/SVF-osx/svf/include/include/Util/GraphReachSolver.h +186 -0
- package/SVF-osx/svf/include/include/Util/NodeIDAllocator.h +194 -0
- package/SVF-osx/svf/include/include/Util/Options.h +266 -0
- package/SVF-osx/svf/include/include/Util/PTAStat.h +65 -0
- package/SVF-osx/svf/include/include/Util/SCC.h +354 -0
- package/SVF-osx/svf/include/include/Util/SVFStat.h +100 -0
- package/SVF-osx/svf/include/include/Util/SVFUtil.h +660 -0
- package/SVF-osx/svf/include/include/Util/SparseBitVector.h +1202 -0
- package/SVF-osx/svf/include/include/Util/ThreadAPI.h +330 -0
- package/SVF-osx/svf/include/include/Util/WorkList.h +317 -0
- package/SVF-osx/svf/include/include/Util/Z3Expr.h +318 -0
- package/SVF-osx/svf/include/include/Util/cJSON.h +300 -0
- package/SVF-osx/svf/include/include/Util/iterator.h +407 -0
- package/SVF-osx/svf/include/include/Util/iterator_range.h +76 -0
- package/SVF-osx/svf/include/include/WPA/Andersen.h +416 -0
- package/SVF-osx/svf/include/include/WPA/AndersenPWC.h +160 -0
- package/SVF-osx/svf/include/include/WPA/CSC.h +95 -0
- package/SVF-osx/svf/include/include/WPA/FlowSensitive.h +317 -0
- package/SVF-osx/svf/include/include/WPA/Steensgaard.h +126 -0
- package/SVF-osx/svf/include/include/WPA/TypeAnalysis.h +83 -0
- package/SVF-osx/svf/include/include/WPA/VersionedFlowSensitive.h +287 -0
- package/SVF-osx/svf/include/include/WPA/WPAFSSolver.h +254 -0
- package/SVF-osx/svf/include/include/WPA/WPAPass.h +119 -0
- package/SVF-osx/svf/include/include/WPA/WPASolver.h +205 -0
- package/SVF-osx/svf/include/include/WPA/WPAStat.h +222 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/BasicTypes.h +250 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/BreakConstantExpr.h +94 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/CHGBuilder.h +73 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/DCHG.h +484 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/GEPTypeBridgeIterator.h +183 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/ICFGBuilder.h +106 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMLoopAnalysis.h +61 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMModule.h +360 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMUtil.h +466 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/SVFIRBuilder.h +417 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/SymbolTableBuilder.h +110 -0
- package/package.json +1 -1
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
//===- SVFIR.h -- SVF IR Graph or PAG (Program Assignment Graph)--------------------------------------//
|
|
2
|
+
//
|
|
3
|
+
// SVF: Static Value-Flow Analysis
|
|
4
|
+
//
|
|
5
|
+
// Copyright (C) <2013-2017> <Yulei Sui>
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// This program is free software: you can redistribute it and/or modify
|
|
9
|
+
// it under the terms of the GNU General Public License as published by
|
|
10
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
// (at your option) any later version.
|
|
12
|
+
|
|
13
|
+
// This program is distributed in the hope that it will be useful,
|
|
14
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
// GNU General Public License for more details.
|
|
17
|
+
|
|
18
|
+
// You should have received a copy of the GNU General Public License
|
|
19
|
+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
//
|
|
21
|
+
//===----------------------------------------------------------------------===//
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* IRGraph.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: Nov 1, 2013
|
|
27
|
+
* Author: Yulei Sui
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
#ifndef IRGRAPH_H_
|
|
32
|
+
#define IRGRAPH_H_
|
|
33
|
+
|
|
34
|
+
#include "SVFIR/SVFStatements.h"
|
|
35
|
+
#include "SVFIR/SVFVariables.h"
|
|
36
|
+
#include "Util/NodeIDAllocator.h"
|
|
37
|
+
#include "Util/SVFUtil.h"
|
|
38
|
+
#include "Graphs/ICFG.h"
|
|
39
|
+
|
|
40
|
+
namespace SVF
|
|
41
|
+
{
|
|
42
|
+
typedef SVFVar PAGNode;
|
|
43
|
+
typedef SVFStmt PAGEdge;
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
* Graph representation of SVF IR. It can be seen as a program assignment graph (PAG)
|
|
47
|
+
*/
|
|
48
|
+
class IRGraph : public GenericGraph<SVFVar,SVFStmt>
|
|
49
|
+
{
|
|
50
|
+
public:
|
|
51
|
+
typedef Set<const SVFStmt*> SVFStmtSet;
|
|
52
|
+
typedef Map<const SVFValue*,SVFStmtSet> ValueToEdgeMap;
|
|
53
|
+
|
|
54
|
+
protected:
|
|
55
|
+
SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap; // < SVFIR edge map containing all PAGEdges
|
|
56
|
+
SVFStmt::KindToSVFStmtMapTy KindToPTASVFStmtSetMap; // < SVFIR edge map containing only pointer-related edges, i.e, both LHS and RHS are of pointer type
|
|
57
|
+
bool fromFile; ///< Whether the SVFIR is built according to user specified data from a txt file
|
|
58
|
+
NodeID nodeNumAfterPAGBuild; // initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes
|
|
59
|
+
u32_t totalPTAPAGEdge;
|
|
60
|
+
ValueToEdgeMap valueToEdgeMap; ///< Map llvm::Values to all corresponding PAGEdges
|
|
61
|
+
SymbolTableInfo* symInfo;
|
|
62
|
+
|
|
63
|
+
/// Add a node into the graph
|
|
64
|
+
inline NodeID addNode(SVFVar* node, NodeID i)
|
|
65
|
+
{
|
|
66
|
+
addGNode(i,node);
|
|
67
|
+
return i;
|
|
68
|
+
}
|
|
69
|
+
/// Add an edge into the graph
|
|
70
|
+
bool addEdge(SVFVar* src, SVFVar* dst, SVFStmt* edge);
|
|
71
|
+
|
|
72
|
+
//// Return true if this edge exits
|
|
73
|
+
SVFStmt* hasNonlabeledEdge(SVFVar* src, SVFVar* dst, SVFStmt::PEDGEK kind);
|
|
74
|
+
/// Return true if this labeled edge exits, including store, call and load
|
|
75
|
+
/// two store edge can have same dst and src but located in different basic blocks, thus flags are needed to distinguish them
|
|
76
|
+
SVFStmt* hasLabeledEdge(SVFVar* src, SVFVar* dst, SVFStmt::PEDGEK kind, const ICFGNode* cs);
|
|
77
|
+
/// Return MultiOpndStmt since it has more than one operands (we use operand 2 here to make the flag)
|
|
78
|
+
SVFStmt* hasLabeledEdge(SVFVar* src, SVFVar* op1, SVFStmt::PEDGEK kind, const SVFVar* op2);
|
|
79
|
+
|
|
80
|
+
/// Map a value to a set of edges
|
|
81
|
+
inline void mapValueToEdge(const SVFValue* V, SVFStmt *edge)
|
|
82
|
+
{
|
|
83
|
+
auto inserted = valueToEdgeMap.emplace(V, SVFStmtSet{edge});
|
|
84
|
+
if (!inserted.second)
|
|
85
|
+
{
|
|
86
|
+
inserted.first->second.emplace(edge);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/// get MemObj according to LLVM value
|
|
90
|
+
inline const MemObj* getMemObj(const SVFValue* val) const
|
|
91
|
+
{
|
|
92
|
+
return symInfo->getObj(symInfo->getObjSym(val));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public:
|
|
96
|
+
IRGraph(bool buildFromFile): fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0)
|
|
97
|
+
{
|
|
98
|
+
symInfo = SymbolTableInfo::SymbolInfo();
|
|
99
|
+
// insert dummy value if a correct value cannot be found
|
|
100
|
+
valueToEdgeMap[nullptr] = SVFStmtSet();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
virtual ~IRGraph();
|
|
104
|
+
|
|
105
|
+
inline SymbolTableInfo* getSymbolInfo() const
|
|
106
|
+
{
|
|
107
|
+
return symInfo;
|
|
108
|
+
}
|
|
109
|
+
/// Whether this SVFIR built from a txt file
|
|
110
|
+
inline bool isBuiltFromFile()
|
|
111
|
+
{
|
|
112
|
+
return fromFile;
|
|
113
|
+
}
|
|
114
|
+
/// Get all SVFIR Edges that corresponds to an LLVM value
|
|
115
|
+
inline const SVFStmtSet& getValueEdges(const SVFValue* V)
|
|
116
|
+
{
|
|
117
|
+
auto it = valueToEdgeMap.find(V);
|
|
118
|
+
if (it == valueToEdgeMap.end())
|
|
119
|
+
{
|
|
120
|
+
//special empty set
|
|
121
|
+
return valueToEdgeMap.at(nullptr);
|
|
122
|
+
}
|
|
123
|
+
return it->second;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/// Get SVFIR Node according to LLVM value
|
|
127
|
+
///getNode - Return the node corresponding to the specified pointer.
|
|
128
|
+
inline NodeID getValueNode(const SVFValue* V)
|
|
129
|
+
{
|
|
130
|
+
return symInfo->getValSym(V);
|
|
131
|
+
}
|
|
132
|
+
inline bool hasValueNode(const SVFValue* V)
|
|
133
|
+
{
|
|
134
|
+
return symInfo->hasValSym(V);
|
|
135
|
+
}
|
|
136
|
+
/// getObject - Return the obj node id refer to the memory object for the
|
|
137
|
+
/// specified global, heap or alloca instruction according to llvm value.
|
|
138
|
+
inline NodeID getObjectNode(const SVFValue* V)
|
|
139
|
+
{
|
|
140
|
+
return symInfo->getObjSym(V);
|
|
141
|
+
}
|
|
142
|
+
/// GetReturnNode - Return the unique node representing the return value of a function
|
|
143
|
+
inline NodeID getReturnNode(const SVFFunction* func) const
|
|
144
|
+
{
|
|
145
|
+
return symInfo->getRetSym(func);
|
|
146
|
+
}
|
|
147
|
+
/// getVarargNode - Return the unique node representing the variadic argument of a variadic function.
|
|
148
|
+
inline NodeID getVarargNode(const SVFFunction* func) const
|
|
149
|
+
{
|
|
150
|
+
return symInfo->getVarargSym(func);
|
|
151
|
+
}
|
|
152
|
+
inline NodeID getBlackHoleNode() const
|
|
153
|
+
{
|
|
154
|
+
return symInfo->blackholeSymID();
|
|
155
|
+
}
|
|
156
|
+
inline NodeID getConstantNode() const
|
|
157
|
+
{
|
|
158
|
+
return symInfo->constantSymID();
|
|
159
|
+
}
|
|
160
|
+
inline NodeID getBlkPtr() const
|
|
161
|
+
{
|
|
162
|
+
return symInfo->blkPtrSymID();
|
|
163
|
+
}
|
|
164
|
+
inline NodeID getNullPtr() const
|
|
165
|
+
{
|
|
166
|
+
return symInfo->nullPtrSymID();
|
|
167
|
+
}
|
|
168
|
+
inline const MemObj* getBlackHoleObj() const
|
|
169
|
+
{
|
|
170
|
+
return symInfo->getBlkObj();
|
|
171
|
+
}
|
|
172
|
+
inline const MemObj* getConstantObj() const
|
|
173
|
+
{
|
|
174
|
+
return symInfo->getConstantObj();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
inline u32_t getValueNodeNum() const
|
|
178
|
+
{
|
|
179
|
+
return symInfo->valSyms().size();
|
|
180
|
+
}
|
|
181
|
+
inline u32_t getObjectNodeNum() const
|
|
182
|
+
{
|
|
183
|
+
return symInfo->idToObjMap().size();
|
|
184
|
+
}
|
|
185
|
+
inline u32_t getNodeNumAfterPAGBuild() const
|
|
186
|
+
{
|
|
187
|
+
return nodeNumAfterPAGBuild;
|
|
188
|
+
}
|
|
189
|
+
inline void setNodeNumAfterPAGBuild(u32_t num)
|
|
190
|
+
{
|
|
191
|
+
nodeNumAfterPAGBuild = num;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
inline u32_t getPAGNodeNum() const
|
|
195
|
+
{
|
|
196
|
+
return nodeNum;
|
|
197
|
+
}
|
|
198
|
+
inline u32_t getPAGEdgeNum() const
|
|
199
|
+
{
|
|
200
|
+
return edgeNum;
|
|
201
|
+
}
|
|
202
|
+
inline u32_t getPTAPAGEdgeNum() const
|
|
203
|
+
{
|
|
204
|
+
return totalPTAPAGEdge;
|
|
205
|
+
}
|
|
206
|
+
/// Return graph name
|
|
207
|
+
inline std::string getGraphName() const
|
|
208
|
+
{
|
|
209
|
+
return "SVFIR";
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/// Dump SVFIR
|
|
213
|
+
void dump(std::string name);
|
|
214
|
+
|
|
215
|
+
/// View graph from the debugger
|
|
216
|
+
void view();
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
namespace SVF
|
|
222
|
+
{
|
|
223
|
+
|
|
224
|
+
/* !
|
|
225
|
+
* GenericGraphTraits specializations of SVFIR to be used for the generic graph algorithms.
|
|
226
|
+
* Provide graph traits for tranversing from a SVFIR node using standard graph traversals.
|
|
227
|
+
*/
|
|
228
|
+
template<> struct GenericGraphTraits<SVF::SVFVar*> : public GenericGraphTraits<SVF::GenericNode<SVF::SVFVar,SVF::SVFStmt>* >
|
|
229
|
+
{
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
/// Inverse GenericGraphTraits specializations for SVFIR node, it is used for inverse traversal.
|
|
233
|
+
template<> struct GenericGraphTraits<Inverse<SVF::SVFVar *> > : public GenericGraphTraits<Inverse<SVF::GenericNode<SVF::SVFVar,SVF::SVFStmt>* > >
|
|
234
|
+
{
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
template<> struct GenericGraphTraits<SVF::IRGraph*> : public GenericGraphTraits<SVF::GenericGraph<SVF::SVFVar,SVF::SVFStmt>* >
|
|
238
|
+
{
|
|
239
|
+
typedef SVF::SVFVar *NodeRef;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
} // End namespace llvm
|
|
243
|
+
#endif /* IRGRAPH_H_ */
|
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
//===- PTACallGraph.h -- Call graph representation----------------------------//
|
|
2
|
+
//
|
|
3
|
+
// SVF: Static Value-Flow Analysis
|
|
4
|
+
//
|
|
5
|
+
// Copyright (C) <2013-2017> <Yulei Sui>
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// This program is free software: you can redistribute it and/or modify
|
|
9
|
+
// it under the terms of the GNU General Public License as published by
|
|
10
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
// (at your option) any later version.
|
|
12
|
+
|
|
13
|
+
// This program is distributed in the hope that it will be useful,
|
|
14
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
// GNU General Public License for more details.
|
|
17
|
+
|
|
18
|
+
// You should have received a copy of the GNU General Public License
|
|
19
|
+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
//
|
|
21
|
+
//===----------------------------------------------------------------------===//
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* PTACallGraph.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: Nov 7, 2013
|
|
27
|
+
* Author: Yulei Sui
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifndef PTACALLGRAPH_H_
|
|
31
|
+
#define PTACALLGRAPH_H_
|
|
32
|
+
|
|
33
|
+
#include "Graphs/GenericGraph.h"
|
|
34
|
+
#include "SVFIR/SVFValue.h"
|
|
35
|
+
#include "Graphs/ICFG.h"
|
|
36
|
+
#include <set>
|
|
37
|
+
|
|
38
|
+
namespace SVF
|
|
39
|
+
{
|
|
40
|
+
|
|
41
|
+
class PTACallGraphNode;
|
|
42
|
+
class SVFModule;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
* Call Graph edge representing a calling relation between two functions
|
|
47
|
+
* Multiple calls from function A to B are merged into one call edge
|
|
48
|
+
* Each call edge has a set of direct callsites and a set of indirect callsites
|
|
49
|
+
*/
|
|
50
|
+
typedef GenericEdge<PTACallGraphNode> GenericCallGraphEdgeTy;
|
|
51
|
+
class PTACallGraphEdge : public GenericCallGraphEdgeTy
|
|
52
|
+
{
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
typedef Set<const CallICFGNode*> CallInstSet;
|
|
56
|
+
enum CEDGEK
|
|
57
|
+
{
|
|
58
|
+
CallRetEdge,TDForkEdge,TDJoinEdge,HareParForEdge
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
private:
|
|
63
|
+
CallInstSet directCalls;
|
|
64
|
+
CallInstSet indirectCalls;
|
|
65
|
+
CallSiteID csId;
|
|
66
|
+
public:
|
|
67
|
+
/// Constructor
|
|
68
|
+
PTACallGraphEdge(PTACallGraphNode* s, PTACallGraphNode* d, CEDGEK kind, CallSiteID cs) :
|
|
69
|
+
GenericCallGraphEdgeTy(s, d, makeEdgeFlagWithInvokeID(kind, cs)), csId(cs)
|
|
70
|
+
{
|
|
71
|
+
}
|
|
72
|
+
/// Destructor
|
|
73
|
+
virtual ~PTACallGraphEdge()
|
|
74
|
+
{
|
|
75
|
+
}
|
|
76
|
+
/// Compute the unique edgeFlag value from edge kind and CallSiteID.
|
|
77
|
+
static inline GEdgeFlag makeEdgeFlagWithInvokeID(GEdgeKind k, CallSiteID cs)
|
|
78
|
+
{
|
|
79
|
+
return (cs << EdgeKindMaskBits) | k;
|
|
80
|
+
}
|
|
81
|
+
/// Get direct and indirect calls
|
|
82
|
+
//@{
|
|
83
|
+
inline CallSiteID getCallSiteID() const
|
|
84
|
+
{
|
|
85
|
+
return csId;
|
|
86
|
+
}
|
|
87
|
+
inline bool isDirectCallEdge() const
|
|
88
|
+
{
|
|
89
|
+
return !directCalls.empty() && indirectCalls.empty();
|
|
90
|
+
}
|
|
91
|
+
inline bool isIndirectCallEdge() const
|
|
92
|
+
{
|
|
93
|
+
return directCalls.empty() && !indirectCalls.empty();
|
|
94
|
+
}
|
|
95
|
+
inline CallInstSet& getDirectCalls()
|
|
96
|
+
{
|
|
97
|
+
return directCalls;
|
|
98
|
+
}
|
|
99
|
+
inline CallInstSet& getIndirectCalls()
|
|
100
|
+
{
|
|
101
|
+
return indirectCalls;
|
|
102
|
+
}
|
|
103
|
+
inline const CallInstSet& getDirectCalls() const
|
|
104
|
+
{
|
|
105
|
+
return directCalls;
|
|
106
|
+
}
|
|
107
|
+
inline const CallInstSet& getIndirectCalls() const
|
|
108
|
+
{
|
|
109
|
+
return indirectCalls;
|
|
110
|
+
}
|
|
111
|
+
//@}
|
|
112
|
+
|
|
113
|
+
/// Add direct and indirect callsite
|
|
114
|
+
//@{
|
|
115
|
+
void addDirectCallSite(const CallICFGNode* call);
|
|
116
|
+
|
|
117
|
+
void addInDirectCallSite(const CallICFGNode* call);
|
|
118
|
+
//@}
|
|
119
|
+
|
|
120
|
+
/// Iterators for direct and indirect callsites
|
|
121
|
+
//@{
|
|
122
|
+
inline CallInstSet::const_iterator directCallsBegin() const
|
|
123
|
+
{
|
|
124
|
+
return directCalls.begin();
|
|
125
|
+
}
|
|
126
|
+
inline CallInstSet::const_iterator directCallsEnd() const
|
|
127
|
+
{
|
|
128
|
+
return directCalls.end();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
inline CallInstSet::const_iterator indirectCallsBegin() const
|
|
132
|
+
{
|
|
133
|
+
return indirectCalls.begin();
|
|
134
|
+
}
|
|
135
|
+
inline CallInstSet::const_iterator indirectCallsEnd() const
|
|
136
|
+
{
|
|
137
|
+
return indirectCalls.end();
|
|
138
|
+
}
|
|
139
|
+
//@}
|
|
140
|
+
|
|
141
|
+
/// ClassOf
|
|
142
|
+
//@{
|
|
143
|
+
static inline bool classof(const PTACallGraphEdge*)
|
|
144
|
+
{
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
static inline bool classof(const GenericCallGraphEdgeTy *edge)
|
|
148
|
+
{
|
|
149
|
+
return edge->getEdgeKind() == PTACallGraphEdge::CallRetEdge ||
|
|
150
|
+
edge->getEdgeKind() == PTACallGraphEdge::TDForkEdge ||
|
|
151
|
+
edge->getEdgeKind() == PTACallGraphEdge::TDJoinEdge;
|
|
152
|
+
}
|
|
153
|
+
//@}
|
|
154
|
+
|
|
155
|
+
/// Overloading operator << for dumping ICFG node ID
|
|
156
|
+
//@{
|
|
157
|
+
friend OutStream& operator<< (OutStream &o, const PTACallGraphEdge &edge)
|
|
158
|
+
{
|
|
159
|
+
o << edge.toString();
|
|
160
|
+
return o;
|
|
161
|
+
}
|
|
162
|
+
//@}
|
|
163
|
+
|
|
164
|
+
virtual const std::string toString() const;
|
|
165
|
+
|
|
166
|
+
typedef GenericNode<PTACallGraphNode,PTACallGraphEdge>::GEdgeSetTy CallGraphEdgeSet;
|
|
167
|
+
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/*
|
|
171
|
+
* Call Graph node representing a function
|
|
172
|
+
*/
|
|
173
|
+
typedef GenericNode<PTACallGraphNode,PTACallGraphEdge> GenericCallGraphNodeTy;
|
|
174
|
+
class PTACallGraphNode : public GenericCallGraphNodeTy
|
|
175
|
+
{
|
|
176
|
+
|
|
177
|
+
public:
|
|
178
|
+
typedef PTACallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet;
|
|
179
|
+
typedef PTACallGraphEdge::CallGraphEdgeSet::iterator iterator;
|
|
180
|
+
typedef PTACallGraphEdge::CallGraphEdgeSet::const_iterator const_iterator;
|
|
181
|
+
|
|
182
|
+
private:
|
|
183
|
+
const SVFFunction* fun;
|
|
184
|
+
|
|
185
|
+
public:
|
|
186
|
+
/// Constructor
|
|
187
|
+
PTACallGraphNode(NodeID i, const SVFFunction* f) : GenericCallGraphNodeTy(i,0), fun(f)
|
|
188
|
+
{
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/// Get function of this call node
|
|
193
|
+
inline const SVFFunction* getFunction() const
|
|
194
|
+
{
|
|
195
|
+
return fun;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/// Return TRUE if this function can be reached from main.
|
|
199
|
+
bool isReachableFromProgEntry() const;
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
/// Overloading operator << for dumping ICFG node ID
|
|
203
|
+
//@{
|
|
204
|
+
friend OutStream& operator<< (OutStream &o, const PTACallGraphNode &node)
|
|
205
|
+
{
|
|
206
|
+
o << node.toString();
|
|
207
|
+
return o;
|
|
208
|
+
}
|
|
209
|
+
//@}
|
|
210
|
+
|
|
211
|
+
virtual const std::string toString() const;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/*!
|
|
215
|
+
* Pointer Analysis Call Graph used internally for various pointer analysis
|
|
216
|
+
*/
|
|
217
|
+
typedef GenericGraph<PTACallGraphNode,PTACallGraphEdge> GenericCallGraphTy;
|
|
218
|
+
class PTACallGraph : public GenericCallGraphTy
|
|
219
|
+
{
|
|
220
|
+
|
|
221
|
+
public:
|
|
222
|
+
typedef PTACallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet;
|
|
223
|
+
typedef Map<const SVFFunction*, PTACallGraphNode *> FunToCallGraphNodeMap;
|
|
224
|
+
typedef Map<const CallICFGNode*, CallGraphEdgeSet> CallInstToCallGraphEdgesMap;
|
|
225
|
+
typedef std::pair<const CallICFGNode*, const SVFFunction*> CallSitePair;
|
|
226
|
+
typedef Map<CallSitePair, CallSiteID> CallSiteToIdMap;
|
|
227
|
+
typedef Map<CallSiteID, CallSitePair> IdToCallSiteMap;
|
|
228
|
+
typedef Set<const SVFFunction*> FunctionSet;
|
|
229
|
+
typedef OrderedMap<const CallICFGNode*, FunctionSet> CallEdgeMap;
|
|
230
|
+
typedef CallGraphEdgeSet::iterator CallGraphEdgeIter;
|
|
231
|
+
typedef CallGraphEdgeSet::const_iterator CallGraphEdgeConstIter;
|
|
232
|
+
|
|
233
|
+
enum CGEK
|
|
234
|
+
{
|
|
235
|
+
NormCallGraph, ThdCallGraph
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
private:
|
|
239
|
+
CGEK kind;
|
|
240
|
+
|
|
241
|
+
/// Indirect call map
|
|
242
|
+
CallEdgeMap indirectCallMap;
|
|
243
|
+
|
|
244
|
+
/// Call site information
|
|
245
|
+
static CallSiteToIdMap csToIdMap; ///< Map a pair of call instruction and callee to a callsite ID
|
|
246
|
+
static IdToCallSiteMap idToCSMap; ///< Map a callsite ID to a pair of call instruction and callee
|
|
247
|
+
static CallSiteID totalCallSiteNum; ///< CallSiteIDs, start from 1;
|
|
248
|
+
|
|
249
|
+
protected:
|
|
250
|
+
FunToCallGraphNodeMap funToCallGraphNodeMap; ///< Call Graph node map
|
|
251
|
+
CallInstToCallGraphEdgesMap callinstToCallGraphEdgesMap; ///< Map a call instruction to its corresponding call edges
|
|
252
|
+
|
|
253
|
+
NodeID callGraphNodeNum;
|
|
254
|
+
u32_t numOfResolvedIndCallEdge;
|
|
255
|
+
|
|
256
|
+
/// Clean up memory
|
|
257
|
+
void destroy();
|
|
258
|
+
|
|
259
|
+
public:
|
|
260
|
+
/// Constructor
|
|
261
|
+
PTACallGraph(CGEK k = NormCallGraph);
|
|
262
|
+
|
|
263
|
+
/// Add callgraph Node
|
|
264
|
+
void addCallGraphNode(const SVFFunction* fun);
|
|
265
|
+
|
|
266
|
+
/// Destructor
|
|
267
|
+
virtual ~PTACallGraph()
|
|
268
|
+
{
|
|
269
|
+
destroy();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/// Return type of this callgraph
|
|
273
|
+
inline CGEK getKind() const
|
|
274
|
+
{
|
|
275
|
+
return kind;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/// Get callees from an indirect callsite
|
|
279
|
+
//@{
|
|
280
|
+
inline CallEdgeMap& getIndCallMap()
|
|
281
|
+
{
|
|
282
|
+
return indirectCallMap;
|
|
283
|
+
}
|
|
284
|
+
inline bool hasIndCSCallees(const CallICFGNode* cs) const
|
|
285
|
+
{
|
|
286
|
+
return (indirectCallMap.find(cs) != indirectCallMap.end());
|
|
287
|
+
}
|
|
288
|
+
inline const FunctionSet& getIndCSCallees(const CallICFGNode* cs) const
|
|
289
|
+
{
|
|
290
|
+
CallEdgeMap::const_iterator it = indirectCallMap.find(cs);
|
|
291
|
+
assert(it!=indirectCallMap.end() && "not an indirect callsite!");
|
|
292
|
+
return it->second;
|
|
293
|
+
}
|
|
294
|
+
//@}
|
|
295
|
+
inline u32_t getTotalCallSiteNumber() const
|
|
296
|
+
{
|
|
297
|
+
return totalCallSiteNum;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
inline u32_t getNumOfResolvedIndCallEdge() const
|
|
301
|
+
{
|
|
302
|
+
return numOfResolvedIndCallEdge;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
inline const CallInstToCallGraphEdgesMap& getCallInstToCallGraphEdgesMap() const
|
|
306
|
+
{
|
|
307
|
+
return callinstToCallGraphEdgesMap;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/// Issue a warning if the function which has indirect call sites can not be reached from program entry.
|
|
311
|
+
void verifyCallGraph();
|
|
312
|
+
|
|
313
|
+
/// Get call graph node
|
|
314
|
+
//@{
|
|
315
|
+
inline PTACallGraphNode* getCallGraphNode(NodeID id) const
|
|
316
|
+
{
|
|
317
|
+
return getGNode(id);
|
|
318
|
+
}
|
|
319
|
+
inline PTACallGraphNode* getCallGraphNode(const SVFFunction* fun) const
|
|
320
|
+
{
|
|
321
|
+
FunToCallGraphNodeMap::const_iterator it = funToCallGraphNodeMap.find(fun);
|
|
322
|
+
assert(it!=funToCallGraphNodeMap.end() && "call graph node not found!!");
|
|
323
|
+
return it->second;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
//@}
|
|
327
|
+
|
|
328
|
+
/// Add/Get CallSiteID
|
|
329
|
+
//@{
|
|
330
|
+
inline CallSiteID addCallSite(const CallICFGNode* cs, const SVFFunction* callee)
|
|
331
|
+
{
|
|
332
|
+
std::pair<const CallICFGNode*, const SVFFunction*> newCS(std::make_pair(cs, callee));
|
|
333
|
+
CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
|
|
334
|
+
//assert(it == csToIdMap.end() && "cannot add a callsite twice");
|
|
335
|
+
if(it == csToIdMap.end())
|
|
336
|
+
{
|
|
337
|
+
CallSiteID id = totalCallSiteNum++;
|
|
338
|
+
csToIdMap.insert(std::make_pair(newCS, id));
|
|
339
|
+
idToCSMap.insert(std::make_pair(id, newCS));
|
|
340
|
+
return id;
|
|
341
|
+
}
|
|
342
|
+
return it->second;
|
|
343
|
+
}
|
|
344
|
+
inline CallSiteID getCallSiteID(const CallICFGNode* cs, const SVFFunction* callee) const
|
|
345
|
+
{
|
|
346
|
+
CallSitePair newCS(std::make_pair(cs, callee));
|
|
347
|
+
CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
|
|
348
|
+
assert(it != csToIdMap.end() && "callsite id not found! This maybe a partially resolved callgraph, please check the indCallEdge limit");
|
|
349
|
+
return it->second;
|
|
350
|
+
}
|
|
351
|
+
inline bool hasCallSiteID(const CallICFGNode* cs, const SVFFunction* callee) const
|
|
352
|
+
{
|
|
353
|
+
CallSitePair newCS(std::make_pair(cs, callee));
|
|
354
|
+
CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
|
|
355
|
+
return it != csToIdMap.end();
|
|
356
|
+
}
|
|
357
|
+
inline const CallSitePair& getCallSitePair(CallSiteID id) const
|
|
358
|
+
{
|
|
359
|
+
IdToCallSiteMap::const_iterator it = idToCSMap.find(id);
|
|
360
|
+
assert(it != idToCSMap.end() && "cannot find call site for this CallSiteID");
|
|
361
|
+
return (it->second);
|
|
362
|
+
}
|
|
363
|
+
inline const CallICFGNode* getCallSite(CallSiteID id) const
|
|
364
|
+
{
|
|
365
|
+
return getCallSitePair(id).first;
|
|
366
|
+
}
|
|
367
|
+
inline const SVFFunction* getCallerOfCallSite(CallSiteID id) const
|
|
368
|
+
{
|
|
369
|
+
return getCallSite(id)->getCaller();
|
|
370
|
+
}
|
|
371
|
+
inline const SVFFunction* getCalleeOfCallSite(CallSiteID id) const
|
|
372
|
+
{
|
|
373
|
+
return getCallSitePair(id).second;
|
|
374
|
+
}
|
|
375
|
+
//@}
|
|
376
|
+
/// Whether we have aleady created this call graph edge
|
|
377
|
+
PTACallGraphEdge* hasGraphEdge(PTACallGraphNode* src, PTACallGraphNode* dst,PTACallGraphEdge::CEDGEK kind, CallSiteID csId) const;
|
|
378
|
+
/// Get call graph edge via nodes
|
|
379
|
+
PTACallGraphEdge* getGraphEdge(PTACallGraphNode* src, PTACallGraphNode* dst,PTACallGraphEdge::CEDGEK kind, CallSiteID csId);
|
|
380
|
+
|
|
381
|
+
/// Get all callees for a callsite
|
|
382
|
+
inline void getCallees(const CallICFGNode* cs, FunctionSet& callees)
|
|
383
|
+
{
|
|
384
|
+
if(hasCallGraphEdge(cs))
|
|
385
|
+
{
|
|
386
|
+
for (CallGraphEdgeSet::const_iterator it = getCallEdgeBegin(cs), eit =
|
|
387
|
+
getCallEdgeEnd(cs); it != eit; ++it)
|
|
388
|
+
{
|
|
389
|
+
callees.insert((*it)->getDstNode()->getFunction());
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/// Get call graph edge via call instruction
|
|
395
|
+
//@{
|
|
396
|
+
/// whether this call instruction has a valid call graph edge
|
|
397
|
+
inline bool hasCallGraphEdge(const CallICFGNode* inst) const
|
|
398
|
+
{
|
|
399
|
+
return callinstToCallGraphEdgesMap.find(inst)!=callinstToCallGraphEdgesMap.end();
|
|
400
|
+
}
|
|
401
|
+
inline CallGraphEdgeSet::const_iterator getCallEdgeBegin(const CallICFGNode* inst) const
|
|
402
|
+
{
|
|
403
|
+
CallInstToCallGraphEdgesMap::const_iterator it = callinstToCallGraphEdgesMap.find(inst);
|
|
404
|
+
assert(it!=callinstToCallGraphEdgesMap.end()
|
|
405
|
+
&& "call instruction does not have a valid callee");
|
|
406
|
+
return it->second.begin();
|
|
407
|
+
}
|
|
408
|
+
inline CallGraphEdgeSet::const_iterator getCallEdgeEnd(const CallICFGNode* inst) const
|
|
409
|
+
{
|
|
410
|
+
CallInstToCallGraphEdgesMap::const_iterator it = callinstToCallGraphEdgesMap.find(inst);
|
|
411
|
+
assert(it!=callinstToCallGraphEdgesMap.end()
|
|
412
|
+
&& "call instruction does not have a valid callee");
|
|
413
|
+
return it->second.end();
|
|
414
|
+
}
|
|
415
|
+
//@}
|
|
416
|
+
/// Add call graph edge
|
|
417
|
+
inline void addEdge(PTACallGraphEdge* edge)
|
|
418
|
+
{
|
|
419
|
+
edge->getDstNode()->addIncomingEdge(edge);
|
|
420
|
+
edge->getSrcNode()->addOutgoingEdge(edge);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/// Add direct/indirect call edges
|
|
424
|
+
//@{
|
|
425
|
+
void addDirectCallGraphEdge(const CallICFGNode* call, const SVFFunction* callerFun, const SVFFunction* calleeFun);
|
|
426
|
+
void addIndirectCallGraphEdge(const CallICFGNode* cs,const SVFFunction* callerFun, const SVFFunction* calleeFun);
|
|
427
|
+
//@}
|
|
428
|
+
|
|
429
|
+
/// Get callsites invoking the callee
|
|
430
|
+
//@{
|
|
431
|
+
void getAllCallSitesInvokingCallee(const SVFFunction* callee, PTACallGraphEdge::CallInstSet& csSet);
|
|
432
|
+
void getDirCallSitesInvokingCallee(const SVFFunction* callee, PTACallGraphEdge::CallInstSet& csSet);
|
|
433
|
+
void getIndCallSitesInvokingCallee(const SVFFunction* callee, PTACallGraphEdge::CallInstSet& csSet);
|
|
434
|
+
//@}
|
|
435
|
+
|
|
436
|
+
/// Whether its reachable between two functions
|
|
437
|
+
bool isReachableBetweenFunctions(const SVFFunction* srcFn, const SVFFunction* dstFn) const;
|
|
438
|
+
|
|
439
|
+
/// Dump the graph
|
|
440
|
+
void dump(const std::string& filename);
|
|
441
|
+
|
|
442
|
+
/// View the graph from the debugger
|
|
443
|
+
void view();
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
} // End namespace SVF
|
|
447
|
+
|
|
448
|
+
namespace SVF
|
|
449
|
+
{
|
|
450
|
+
/* !
|
|
451
|
+
* GenericGraphTraits specializations for generic graph algorithms.
|
|
452
|
+
* Provide graph traits for traversing from a constraint node using standard graph traversals.
|
|
453
|
+
*/
|
|
454
|
+
template<> struct GenericGraphTraits<SVF::PTACallGraphNode*> : public GenericGraphTraits<SVF::GenericNode<SVF::PTACallGraphNode,SVF::PTACallGraphEdge>* >
|
|
455
|
+
{
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
/// Inverse GenericGraphTraits specializations for call graph node, it is used for inverse traversal.
|
|
459
|
+
template<>
|
|
460
|
+
struct GenericGraphTraits<Inverse<SVF::PTACallGraphNode *> > : public GenericGraphTraits<Inverse<SVF::GenericNode<SVF::PTACallGraphNode,SVF::PTACallGraphEdge>* > >
|
|
461
|
+
{
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
template<> struct GenericGraphTraits<SVF::PTACallGraph*> : public GenericGraphTraits<SVF::GenericGraph<SVF::PTACallGraphNode,SVF::PTACallGraphEdge>* >
|
|
465
|
+
{
|
|
466
|
+
typedef SVF::PTACallGraphNode *NodeRef;
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
} // End namespace llvm
|
|
470
|
+
|
|
471
|
+
#endif /* PTACALLGRAPH_H_ */
|