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,660 @@
|
|
|
1
|
+
//===- SVFUtil.h -- Analysis helper functions----------------------------//
|
|
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
|
+
* SVFUtil.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: Apr 11, 2013
|
|
27
|
+
* Author: Yulei Sui, dye
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifndef AnalysisUtil_H_
|
|
31
|
+
#define AnalysisUtil_H_
|
|
32
|
+
|
|
33
|
+
#include "FastCluster/fastcluster.h"
|
|
34
|
+
#include "SVFIR/SVFValue.h"
|
|
35
|
+
#include "SVFIR/SVFModule.h"
|
|
36
|
+
#include "Util/ExtAPI.h"
|
|
37
|
+
#include "MemoryModel/PointsTo.h"
|
|
38
|
+
#include <time.h>
|
|
39
|
+
|
|
40
|
+
namespace SVF
|
|
41
|
+
{
|
|
42
|
+
|
|
43
|
+
/*
|
|
44
|
+
* Util class to assist pointer analysis
|
|
45
|
+
*/
|
|
46
|
+
namespace SVFUtil
|
|
47
|
+
{
|
|
48
|
+
|
|
49
|
+
/// Overwrite llvm::outs()
|
|
50
|
+
inline std::ostream &outs()
|
|
51
|
+
{
|
|
52
|
+
return std::cout;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// Overwrite llvm::errs()
|
|
56
|
+
inline std::ostream &errs()
|
|
57
|
+
{
|
|
58
|
+
return std::cerr;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// Dump sparse bitvector set
|
|
62
|
+
void dumpSet(NodeBS To, OutStream & O = SVFUtil::outs());
|
|
63
|
+
void dumpSet(PointsTo To, OutStream & O = SVFUtil::outs());
|
|
64
|
+
|
|
65
|
+
/// Dump points-to set
|
|
66
|
+
void dumpPointsToSet(unsigned node, NodeBS To) ;
|
|
67
|
+
void dumpSparseSet(const NodeBS& To);
|
|
68
|
+
|
|
69
|
+
/// Dump alias set
|
|
70
|
+
void dumpAliasSet(unsigned node, NodeBS To) ;
|
|
71
|
+
|
|
72
|
+
/// Returns successful message by converting a string into green string output
|
|
73
|
+
std::string sucMsg(std::string msg);
|
|
74
|
+
|
|
75
|
+
/// Returns warning message by converting a string into yellow string output
|
|
76
|
+
std::string wrnMsg(std::string msg);
|
|
77
|
+
|
|
78
|
+
/// Writes a message run through wrnMsg.
|
|
79
|
+
void writeWrnMsg(std::string msg);
|
|
80
|
+
|
|
81
|
+
/// Print error message by converting a string into red string output
|
|
82
|
+
//@{
|
|
83
|
+
std::string errMsg(std::string msg);
|
|
84
|
+
std::string bugMsg1(std::string msg);
|
|
85
|
+
std::string bugMsg2(std::string msg);
|
|
86
|
+
std::string bugMsg3(std::string msg);
|
|
87
|
+
//@}
|
|
88
|
+
|
|
89
|
+
/// Print each pass/phase message by converting a string into blue string output
|
|
90
|
+
std::string pasMsg(std::string msg);
|
|
91
|
+
|
|
92
|
+
/// Print memory usage in KB.
|
|
93
|
+
void reportMemoryUsageKB(const std::string& infor, OutStream & O = SVFUtil::outs());
|
|
94
|
+
|
|
95
|
+
/// Get memory usage from system file. Return TRUE if succeed.
|
|
96
|
+
bool getMemoryUsageKB(u32_t* vmrss_kb, u32_t* vmsize_kb);
|
|
97
|
+
|
|
98
|
+
/// Increase the stack size limit
|
|
99
|
+
void increaseStackSize();
|
|
100
|
+
|
|
101
|
+
/*!
|
|
102
|
+
* Compare two PointsTo according to their size and points-to elements.
|
|
103
|
+
* 1. PointsTo with smaller size is smaller than the other;
|
|
104
|
+
* 2. If the sizes are equal, comparing the points-to targets.
|
|
105
|
+
*/
|
|
106
|
+
inline bool cmpPts (const PointsTo& lpts,const PointsTo& rpts)
|
|
107
|
+
{
|
|
108
|
+
if (lpts.count() != rpts.count())
|
|
109
|
+
return (lpts.count() < rpts.count());
|
|
110
|
+
else
|
|
111
|
+
{
|
|
112
|
+
PointsTo::iterator bit = lpts.begin(), eit = lpts.end();
|
|
113
|
+
PointsTo::iterator rbit = rpts.begin(), reit = rpts.end();
|
|
114
|
+
for (; bit != eit && rbit != reit; bit++, rbit++)
|
|
115
|
+
{
|
|
116
|
+
if (*bit != *rbit)
|
|
117
|
+
return (*bit < *rbit);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
inline bool cmpNodeBS(const NodeBS& lpts,const NodeBS& rpts)
|
|
125
|
+
{
|
|
126
|
+
if (lpts.count() != rpts.count())
|
|
127
|
+
return (lpts.count() < rpts.count());
|
|
128
|
+
else
|
|
129
|
+
{
|
|
130
|
+
NodeBS::iterator bit = lpts.begin(), eit = lpts.end();
|
|
131
|
+
NodeBS::iterator rbit = rpts.begin(), reit = rpts.end();
|
|
132
|
+
for (; bit != eit && rbit != reit; bit++, rbit++)
|
|
133
|
+
{
|
|
134
|
+
if (*bit != *rbit)
|
|
135
|
+
return (*bit < *rbit);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
typedef struct equalPointsTo
|
|
143
|
+
{
|
|
144
|
+
bool operator()(const PointsTo& lhs, const PointsTo& rhs) const
|
|
145
|
+
{
|
|
146
|
+
return SVFUtil::cmpPts(lhs, rhs);
|
|
147
|
+
}
|
|
148
|
+
} equalPointsTo;
|
|
149
|
+
|
|
150
|
+
typedef struct equalNodeBS
|
|
151
|
+
{
|
|
152
|
+
bool operator()(const NodeBS& lhs, const NodeBS& rhs) const
|
|
153
|
+
{
|
|
154
|
+
return SVFUtil::cmpNodeBS(lhs, rhs);
|
|
155
|
+
}
|
|
156
|
+
} equalNodeBS;
|
|
157
|
+
|
|
158
|
+
inline NodeBS ptsToNodeBS(const PointsTo &pts)
|
|
159
|
+
{
|
|
160
|
+
NodeBS nbs;
|
|
161
|
+
for (const NodeID o : pts) nbs.set(o);
|
|
162
|
+
return nbs;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
typedef OrderedSet<PointsTo, equalPointsTo> PointsToList;
|
|
166
|
+
void dumpPointsToList(const PointsToList& ptl);
|
|
167
|
+
|
|
168
|
+
/// Return true if it is an llvm intrinsic instruction
|
|
169
|
+
bool isIntrinsicInst(const SVFInstruction* inst);
|
|
170
|
+
//@}
|
|
171
|
+
|
|
172
|
+
/// Whether an instruction is a call or invoke instruction
|
|
173
|
+
inline bool isCallSite(const SVFInstruction* inst)
|
|
174
|
+
{
|
|
175
|
+
return SVFUtil::isa<SVFCallInst>(inst);
|
|
176
|
+
}
|
|
177
|
+
/// Whether an instruction is a call or invoke instruction
|
|
178
|
+
inline bool isCallSite(const SVFValue* val)
|
|
179
|
+
{
|
|
180
|
+
if(SVFUtil::isa<SVFCallInst>(val))
|
|
181
|
+
return true;
|
|
182
|
+
else
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/// Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls
|
|
187
|
+
inline bool isNonInstricCallSite(const SVFInstruction* inst)
|
|
188
|
+
{
|
|
189
|
+
if(isIntrinsicInst(inst))
|
|
190
|
+
return false;
|
|
191
|
+
return isCallSite(inst);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/// Return LLVM callsite given an instruction
|
|
195
|
+
inline CallSite getSVFCallSite(const SVFInstruction* inst)
|
|
196
|
+
{
|
|
197
|
+
assert(isCallSite(inst) && "not a callsite?");
|
|
198
|
+
CallSite cs(inst);
|
|
199
|
+
return cs;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/// Return LLVM callsite given a value
|
|
203
|
+
inline CallSite getSVFCallSite(const SVFValue* value)
|
|
204
|
+
{
|
|
205
|
+
assert(isCallSite(value) && "not a callsite?");
|
|
206
|
+
const SVFCallInst* svfInst = SVFUtil::cast<SVFCallInst>(value);
|
|
207
|
+
CallSite cs(svfInst);
|
|
208
|
+
return cs;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/// Split into two substrings around the first occurrence of a separator string.
|
|
212
|
+
inline std::vector<std::string> split(const std::string& s, char seperator)
|
|
213
|
+
{
|
|
214
|
+
std::vector<std::string> output;
|
|
215
|
+
std::string::size_type prev_pos = 0, pos = 0;
|
|
216
|
+
while((pos = s.find(seperator, pos)) != std::string::npos)
|
|
217
|
+
{
|
|
218
|
+
std::string substring( s.substr(prev_pos, pos-prev_pos) );
|
|
219
|
+
output.push_back(substring);
|
|
220
|
+
prev_pos = ++pos;
|
|
221
|
+
}
|
|
222
|
+
output.push_back(s.substr(prev_pos, pos-prev_pos));
|
|
223
|
+
return output;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/// Return callee of a callsite. Return null if this is an indirect call
|
|
227
|
+
//@{
|
|
228
|
+
inline const SVFFunction* getCallee(const CallSite cs)
|
|
229
|
+
{
|
|
230
|
+
return cs.getCalledFunction();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
inline const SVFFunction* getCallee(const SVFInstruction *inst)
|
|
234
|
+
{
|
|
235
|
+
if (!isCallSite(inst))
|
|
236
|
+
return nullptr;
|
|
237
|
+
CallSite cs(inst);
|
|
238
|
+
return getCallee(cs);
|
|
239
|
+
}
|
|
240
|
+
//@}
|
|
241
|
+
|
|
242
|
+
/// Given a map mapping points-to sets to a count, adds from into to.
|
|
243
|
+
template <typename Data>
|
|
244
|
+
void mergePtsOccMaps(Map<Data, unsigned> &to, const Map<Data, unsigned> from)
|
|
245
|
+
{
|
|
246
|
+
for (const typename Map<Data, unsigned>::value_type &ptocc : from)
|
|
247
|
+
{
|
|
248
|
+
to[ptocc.first] += ptocc.second;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/// Returns a string representation of a hclust method.
|
|
253
|
+
std::string hclustMethodToString(hclust_fast_methods method);
|
|
254
|
+
|
|
255
|
+
/// Inserts an element into a Set/CondSet (with ::insert).
|
|
256
|
+
template <typename Key, typename KeySet>
|
|
257
|
+
inline void insertKey(const Key &key, KeySet &keySet)
|
|
258
|
+
{
|
|
259
|
+
keySet.insert(key);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/// Inserts a NodeID into a NodeBS.
|
|
263
|
+
inline void insertKey(const NodeID &key, NodeBS &keySet)
|
|
264
|
+
{
|
|
265
|
+
keySet.set(key);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/// Removes an element from a Set/CondSet (or anything implementing ::erase).
|
|
269
|
+
template <typename Key, typename KeySet>
|
|
270
|
+
inline void removeKey(const Key &key, KeySet &keySet)
|
|
271
|
+
{
|
|
272
|
+
keySet.erase(key);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/// Removes a NodeID from a NodeBS.
|
|
276
|
+
inline void removeKey(const NodeID &key, NodeBS &keySet)
|
|
277
|
+
{
|
|
278
|
+
keySet.reset(key);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/// Function to call when alarm for time limit hits.
|
|
282
|
+
void timeLimitReached(int signum);
|
|
283
|
+
|
|
284
|
+
/// Starts an analysis timer. If timeLimit is 0, sets no timer.
|
|
285
|
+
/// If an alarm has already been set, does not set another.
|
|
286
|
+
/// Returns whether we set a timer or not.
|
|
287
|
+
bool startAnalysisLimitTimer(unsigned timeLimit);
|
|
288
|
+
|
|
289
|
+
/// Stops an analysis timer. limitTimerSet indicates whether the caller set the
|
|
290
|
+
/// timer or not (return value of startLimitTimer).
|
|
291
|
+
void stopAnalysisLimitTimer(bool limitTimerSet);
|
|
292
|
+
|
|
293
|
+
/// Return true if the call is an external call (external library in function summary table)
|
|
294
|
+
/// If the libary function is redefined in the application code (e.g., memcpy), it will return false and will not be treated as an external call.
|
|
295
|
+
//@{
|
|
296
|
+
inline bool isExtCall(const SVFFunction* fun)
|
|
297
|
+
{
|
|
298
|
+
return fun && ExtAPI::getExtAPI()->is_ext(fun);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/// Return true if the call is a heap allocator/reallocator
|
|
302
|
+
//@{
|
|
303
|
+
/// note that these two functions are not suppose to be used externally
|
|
304
|
+
inline bool isHeapAllocExtFunViaRet(const SVFFunction* fun)
|
|
305
|
+
{
|
|
306
|
+
return fun && (ExtAPI::getExtAPI()->is_alloc(fun)
|
|
307
|
+
|| ExtAPI::getExtAPI()->is_realloc(fun));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
inline bool isHeapAllocExtFunViaArg(const SVFFunction* fun)
|
|
311
|
+
{
|
|
312
|
+
return fun && ExtAPI::getExtAPI()->is_arg_alloc(fun);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/// Get the position of argument that holds an allocated heap object.
|
|
316
|
+
//@{
|
|
317
|
+
inline int getHeapAllocHoldingArgPosition(const SVFFunction* fun)
|
|
318
|
+
{
|
|
319
|
+
return ExtAPI::getExtAPI()->get_alloc_arg_pos(fun);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/// Return true if the call is a heap reallocator
|
|
323
|
+
//@{
|
|
324
|
+
/// note that this function is not suppose to be used externally
|
|
325
|
+
inline bool isReallocExtFun(const SVFFunction* fun)
|
|
326
|
+
{
|
|
327
|
+
return fun && (ExtAPI::getExtAPI()->is_realloc(fun));
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/// Return true if the call is a heap dealloc or not
|
|
331
|
+
//@{
|
|
332
|
+
/// note that this function is not suppose to be used externally
|
|
333
|
+
inline bool isDeallocExtFun(const SVFFunction* fun)
|
|
334
|
+
{
|
|
335
|
+
return fun && (ExtAPI::getExtAPI()->is_dealloc(fun));
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/// Return true if the call is a static global call
|
|
339
|
+
//@{
|
|
340
|
+
/// note that this function is not suppose to be used externally
|
|
341
|
+
inline bool isStaticExtFun(const SVFFunction* fun)
|
|
342
|
+
{
|
|
343
|
+
return fun && ExtAPI::getExtAPI()->has_static(fun);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/// Program entry function e.g. main
|
|
347
|
+
//@{
|
|
348
|
+
/// Return true if this is a program entry function (e.g. main)
|
|
349
|
+
inline bool isProgEntryFunction(const SVFFunction* fun)
|
|
350
|
+
{
|
|
351
|
+
return fun && fun->getName() == "main";
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/// Get program entry function from module.
|
|
355
|
+
inline const SVFFunction* getProgFunction(SVFModule* svfModule, const std::string& funName)
|
|
356
|
+
{
|
|
357
|
+
for (SVFModule::const_iterator it = svfModule->begin(), eit = svfModule->end(); it != eit; ++it)
|
|
358
|
+
{
|
|
359
|
+
const SVFFunction *fun = *it;
|
|
360
|
+
if (fun->getName()==funName)
|
|
361
|
+
return fun;
|
|
362
|
+
}
|
|
363
|
+
return nullptr;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/// Get program entry function from module.
|
|
367
|
+
inline const SVFFunction* getProgEntryFunction(SVFModule* svfModule)
|
|
368
|
+
{
|
|
369
|
+
for (SVFModule::const_iterator it = svfModule->begin(), eit = svfModule->end(); it != eit; ++it)
|
|
370
|
+
{
|
|
371
|
+
const SVFFunction *fun = *it;
|
|
372
|
+
if (isProgEntryFunction(fun))
|
|
373
|
+
return (fun);
|
|
374
|
+
}
|
|
375
|
+
return nullptr;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/// Return true if this is a program exit function call
|
|
379
|
+
//@{
|
|
380
|
+
inline bool isProgExitFunction (const SVFFunction * fun)
|
|
381
|
+
{
|
|
382
|
+
return fun && (fun->getName() == "exit" ||
|
|
383
|
+
fun->getName() == "__assert_rtn" ||
|
|
384
|
+
fun->getName() == "__assert_fail" );
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/// Return true if this argument belongs to an uncalled function
|
|
388
|
+
inline bool isArgOfUncalledFunction(const SVFValue* svfval)
|
|
389
|
+
{
|
|
390
|
+
if(const SVFArgument* arg = SVFUtil::dyn_cast<SVFArgument>(svfval))
|
|
391
|
+
return arg->isArgOfUncalledFunction();
|
|
392
|
+
else
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/// Return thread fork function
|
|
397
|
+
//@{
|
|
398
|
+
inline const SVFValue* getForkedFun(const CallSite cs)
|
|
399
|
+
{
|
|
400
|
+
return ThreadAPI::getThreadAPI()->getForkedFun(cs);
|
|
401
|
+
}
|
|
402
|
+
inline const SVFValue* getForkedFun(const SVFInstruction *inst)
|
|
403
|
+
{
|
|
404
|
+
return ThreadAPI::getThreadAPI()->getForkedFun(inst);
|
|
405
|
+
}
|
|
406
|
+
//@}
|
|
407
|
+
|
|
408
|
+
/// This function servers a allocation wrapper detector
|
|
409
|
+
inline bool isAnAllocationWraper(const SVFInstruction*)
|
|
410
|
+
{
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
inline bool isExtCall(const CallSite cs)
|
|
415
|
+
{
|
|
416
|
+
return isExtCall(getCallee(cs));
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
inline bool isExtCall(const SVFInstruction *inst)
|
|
420
|
+
{
|
|
421
|
+
return isExtCall(getCallee(inst));
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
inline bool isHeapAllocExtCallViaArg(const CallSite cs)
|
|
425
|
+
{
|
|
426
|
+
return isHeapAllocExtFunViaArg(getCallee(cs));
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
inline bool isHeapAllocExtCallViaArg(const SVFInstruction *inst)
|
|
430
|
+
{
|
|
431
|
+
return isHeapAllocExtFunViaArg(getCallee(inst));
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/// interfaces to be used externally
|
|
435
|
+
inline bool isHeapAllocExtCallViaRet(const CallSite cs)
|
|
436
|
+
{
|
|
437
|
+
bool isPtrTy = cs.getInstruction()->getType()->isPointerTy();
|
|
438
|
+
return isPtrTy && isHeapAllocExtFunViaRet(getCallee(cs));
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
inline bool isHeapAllocExtCallViaRet(const SVFInstruction *inst)
|
|
442
|
+
{
|
|
443
|
+
bool isPtrTy = inst->getType()->isPointerTy();
|
|
444
|
+
return isPtrTy && isHeapAllocExtFunViaRet(getCallee(inst));
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
inline bool isHeapAllocExtCall(const CallSite cs)
|
|
448
|
+
{
|
|
449
|
+
return isHeapAllocExtCallViaRet(cs) || isHeapAllocExtCallViaArg(cs);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
inline bool isHeapAllocExtCall(const SVFInstruction *inst)
|
|
453
|
+
{
|
|
454
|
+
return isHeapAllocExtCallViaRet(inst) || isHeapAllocExtCallViaArg(inst);
|
|
455
|
+
}
|
|
456
|
+
//@}
|
|
457
|
+
|
|
458
|
+
inline int getHeapAllocHoldingArgPosition(const CallSite cs)
|
|
459
|
+
{
|
|
460
|
+
return getHeapAllocHoldingArgPosition(getCallee(cs));
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
inline int getHeapAllocHoldingArgPosition(const SVFInstruction *inst)
|
|
464
|
+
{
|
|
465
|
+
return getHeapAllocHoldingArgPosition(getCallee(inst));
|
|
466
|
+
}
|
|
467
|
+
//@}
|
|
468
|
+
|
|
469
|
+
inline bool isReallocExtCall(const CallSite cs)
|
|
470
|
+
{
|
|
471
|
+
bool isPtrTy = cs.getInstruction()->getType()->isPointerTy();
|
|
472
|
+
return isPtrTy && isReallocExtFun(getCallee(cs));
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
inline bool isReallocExtCall(const SVFInstruction *inst)
|
|
476
|
+
{
|
|
477
|
+
bool isPtrTy = inst->getType()->isPointerTy();
|
|
478
|
+
return isPtrTy && isReallocExtFun(getCallee(inst));
|
|
479
|
+
}
|
|
480
|
+
//@}
|
|
481
|
+
|
|
482
|
+
inline bool isDeallocExtCall(const CallSite cs)
|
|
483
|
+
{
|
|
484
|
+
return isDeallocExtFun(getCallee(cs));
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
inline bool isDeallocExtCall(const SVFInstruction *inst)
|
|
488
|
+
{
|
|
489
|
+
return isDeallocExtFun(getCallee(inst));
|
|
490
|
+
}
|
|
491
|
+
//@}
|
|
492
|
+
|
|
493
|
+
inline bool isStaticExtCall(const CallSite cs)
|
|
494
|
+
{
|
|
495
|
+
bool isPtrTy = cs.getInstruction()->getType()->isPointerTy();
|
|
496
|
+
return isPtrTy && isStaticExtFun(getCallee(cs));
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
inline bool isStaticExtCall(const SVFInstruction *inst)
|
|
500
|
+
{
|
|
501
|
+
bool isPtrTy = inst->getType()->isPointerTy();
|
|
502
|
+
return isPtrTy && isStaticExtFun(getCallee(inst));
|
|
503
|
+
}
|
|
504
|
+
//@}
|
|
505
|
+
|
|
506
|
+
/// Return true if the call is a static global call
|
|
507
|
+
//@{
|
|
508
|
+
inline bool isHeapAllocOrStaticExtCall(const CallSite cs)
|
|
509
|
+
{
|
|
510
|
+
return isStaticExtCall(cs) || isHeapAllocExtCall(cs);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
inline bool isHeapAllocOrStaticExtCall(const SVFInstruction *inst)
|
|
514
|
+
{
|
|
515
|
+
return isStaticExtCall(inst) || isHeapAllocExtCall(inst);
|
|
516
|
+
}
|
|
517
|
+
//@}
|
|
518
|
+
|
|
519
|
+
/// Return true if this is a thread creation call
|
|
520
|
+
///@{
|
|
521
|
+
inline bool isThreadForkCall(const CallSite cs)
|
|
522
|
+
{
|
|
523
|
+
return ThreadAPI::getThreadAPI()->isTDFork(cs);
|
|
524
|
+
}
|
|
525
|
+
inline bool isThreadForkCall(const SVFInstruction *inst)
|
|
526
|
+
{
|
|
527
|
+
return ThreadAPI::getThreadAPI()->isTDFork(inst);
|
|
528
|
+
}
|
|
529
|
+
//@}
|
|
530
|
+
|
|
531
|
+
/// Return true if this is a hare_parallel_for call
|
|
532
|
+
///@{
|
|
533
|
+
inline bool isHareParForCall(const CallSite cs)
|
|
534
|
+
{
|
|
535
|
+
return ThreadAPI::getThreadAPI()->isHareParFor(cs);
|
|
536
|
+
}
|
|
537
|
+
inline bool isHareParForCall(const SVFInstruction *inst)
|
|
538
|
+
{
|
|
539
|
+
return ThreadAPI::getThreadAPI()->isHareParFor(inst);
|
|
540
|
+
}
|
|
541
|
+
//@}
|
|
542
|
+
|
|
543
|
+
/// Return true if this is a thread join call
|
|
544
|
+
///@{
|
|
545
|
+
inline bool isThreadJoinCall(const CallSite cs)
|
|
546
|
+
{
|
|
547
|
+
return ThreadAPI::getThreadAPI()->isTDJoin(cs);
|
|
548
|
+
}
|
|
549
|
+
inline bool isThreadJoinCall(const SVFInstruction *inst)
|
|
550
|
+
{
|
|
551
|
+
return ThreadAPI::getThreadAPI()->isTDJoin(inst);
|
|
552
|
+
}
|
|
553
|
+
//@}
|
|
554
|
+
|
|
555
|
+
/// Return true if this is a thread exit call
|
|
556
|
+
///@{
|
|
557
|
+
inline bool isThreadExitCall(const CallSite cs)
|
|
558
|
+
{
|
|
559
|
+
return ThreadAPI::getThreadAPI()->isTDExit(cs);
|
|
560
|
+
}
|
|
561
|
+
inline bool isThreadExitCall(const SVFInstruction *inst)
|
|
562
|
+
{
|
|
563
|
+
return ThreadAPI::getThreadAPI()->isTDExit(inst);
|
|
564
|
+
}
|
|
565
|
+
//@}
|
|
566
|
+
|
|
567
|
+
/// Return true if this is a lock acquire call
|
|
568
|
+
///@{
|
|
569
|
+
inline bool isLockAquireCall(const CallSite cs)
|
|
570
|
+
{
|
|
571
|
+
return ThreadAPI::getThreadAPI()->isTDAcquire(cs);
|
|
572
|
+
}
|
|
573
|
+
inline bool isLockAquireCall(const SVFInstruction *inst)
|
|
574
|
+
{
|
|
575
|
+
return ThreadAPI::getThreadAPI()->isTDAcquire(inst);
|
|
576
|
+
}
|
|
577
|
+
//@}
|
|
578
|
+
|
|
579
|
+
/// Return true if this is a lock acquire call
|
|
580
|
+
///@{
|
|
581
|
+
inline bool isLockReleaseCall(const CallSite cs)
|
|
582
|
+
{
|
|
583
|
+
return ThreadAPI::getThreadAPI()->isTDRelease(cs);
|
|
584
|
+
}
|
|
585
|
+
inline bool isLockReleaseCall(const SVFInstruction *inst)
|
|
586
|
+
{
|
|
587
|
+
return ThreadAPI::getThreadAPI()->isTDRelease(inst);
|
|
588
|
+
}
|
|
589
|
+
//@}
|
|
590
|
+
|
|
591
|
+
/// Return true if this is a barrier wait call
|
|
592
|
+
//@{
|
|
593
|
+
inline bool isBarrierWaitCall(const CallSite cs)
|
|
594
|
+
{
|
|
595
|
+
return ThreadAPI::getThreadAPI()->isTDBarWait(cs);
|
|
596
|
+
}
|
|
597
|
+
inline bool isBarrierWaitCall(const SVFInstruction *inst)
|
|
598
|
+
{
|
|
599
|
+
return ThreadAPI::getThreadAPI()->isTDBarWait(inst);
|
|
600
|
+
}
|
|
601
|
+
//@}
|
|
602
|
+
|
|
603
|
+
/// Return sole argument of the thread routine
|
|
604
|
+
//@{
|
|
605
|
+
inline const SVFValue* getActualParmAtForkSite(const CallSite cs)
|
|
606
|
+
{
|
|
607
|
+
return ThreadAPI::getThreadAPI()->getActualParmAtForkSite(cs);
|
|
608
|
+
}
|
|
609
|
+
inline const SVFValue* getActualParmAtForkSite(const SVFInstruction *inst)
|
|
610
|
+
{
|
|
611
|
+
return ThreadAPI::getThreadAPI()->getActualParmAtForkSite(inst);
|
|
612
|
+
}
|
|
613
|
+
//@}
|
|
614
|
+
|
|
615
|
+
/// Return the task function of the parallel_for routine
|
|
616
|
+
//@{
|
|
617
|
+
inline const SVFValue* getTaskFuncAtHareParForSite(const CallSite cs)
|
|
618
|
+
{
|
|
619
|
+
return ThreadAPI::getThreadAPI()->getTaskFuncAtHareParForSite(cs);
|
|
620
|
+
}
|
|
621
|
+
inline const SVFValue* getTaskFuncAtHareParForSite(const SVFInstruction *inst)
|
|
622
|
+
{
|
|
623
|
+
return ThreadAPI::getThreadAPI()->getTaskFuncAtHareParForSite(inst);
|
|
624
|
+
}
|
|
625
|
+
//@}
|
|
626
|
+
|
|
627
|
+
/// Return the task data argument of the parallel_for rountine
|
|
628
|
+
//@{
|
|
629
|
+
inline const SVFValue* getTaskDataAtHareParForSite(const CallSite cs)
|
|
630
|
+
{
|
|
631
|
+
return ThreadAPI::getThreadAPI()->getTaskDataAtHareParForSite(cs);
|
|
632
|
+
}
|
|
633
|
+
inline const SVFValue* getTaskDataAtHareParForSite(const SVFInstruction *inst)
|
|
634
|
+
{
|
|
635
|
+
return ThreadAPI::getThreadAPI()->getTaskDataAtHareParForSite(inst);
|
|
636
|
+
}
|
|
637
|
+
//@}
|
|
638
|
+
|
|
639
|
+
inline bool isProgExitCall(const CallSite cs)
|
|
640
|
+
{
|
|
641
|
+
return isProgExitFunction(getCallee(cs));
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
inline bool isProgExitCall(const SVFInstruction *inst)
|
|
645
|
+
{
|
|
646
|
+
return isProgExitFunction(getCallee(inst));
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
template<typename T>
|
|
650
|
+
constexpr typename std::remove_reference<T>::type &&
|
|
651
|
+
move(T &&t) noexcept
|
|
652
|
+
{
|
|
653
|
+
return std::move(t);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
} // End namespace SVFUtil
|
|
657
|
+
|
|
658
|
+
} // End namespace SVF
|
|
659
|
+
|
|
660
|
+
#endif /* AnalysisUtil_H_ */
|