Static Value-Flow Analysis
Loading...
Searching...
No Matches
ICFGBuilder.h
Go to the documentation of this file.
1//===- ICFGBuilder.h ----------------------------------------------------------------//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-> <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 Affero 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 Affero General Public License for more details.
17
18// You should have received a copy of the GNU Affero General Public License
19// along with this program. If not, see <http://www.gnu.org/licenses/>.
20//
21//===----------------------------------------------------------------------===//
22
23/*
24 * ICFGBuilder.h
25 *
26 * Created on:
27 * Author: yulei
28 */
29
30#ifndef INCLUDE_UTIL_ICFGBUILDER_H_
31#define INCLUDE_UTIL_ICFGBUILDER_H_
32
33#include "Graphs/ICFG.h"
34#include "Util/WorkList.h"
35#include "BasicTypes.h"
36#include "LLVMModule.h"
37
38namespace SVF
39{
40
42{
43
44public:
45
46 typedef std::vector<const Instruction*> InstVec;
53
54
55private:
57
58public:
60
61 ICFGBuilder() = default;
62
63 ICFG* build();
64
65private:
66
71
72private:
73
76 void processFunEntry(const Function* fun, WorkList& worklist);
77
78 void processUnreachableFromEntry(const Function* fun, WorkList& worklist);
79
80 void processFunBody(WorkList& worklist);
81
82 void processFunExit(const Function* fun);
84
85 void checkICFGNodesVisited(const Function* fun);
86
88
89
91 void addICFGInterEdges(const Instruction* cs, const Function* callee);
92
93 inline ICFGNode* getICFGNode(const Instruction* inst)
94 {
95 return llvmModuleSet()->getICFGNode(inst);
96 }
97
98 inline bool hasICFGNode(const Instruction* inst)
99 {
100 return llvmModuleSet()->hasICFGNode(inst);
101 }
102
105 {
106 return llvmModuleSet()->getCallICFGNode(cs);
107 }
110 {
111 return llvmModuleSet()->getRetICFGNode(cs);
112 }
115 {
116 return llvmModuleSet()->getIntraICFGNode(inst);
117 }
118
121 {
122 return llvmModuleSet()->getFunEntryICFGNode(fun);
123 }
126 {
127 return llvmModuleSet()->getFunExitICFGNode(fun);
128 }
129
131 {
132 return icfg->getGlobalICFGNode();
133 }
134
137
139 inline ICFGNode* addBlockICFGNode(const Instruction* inst);
140
143
145
147
153
154private:
156};
157
158} // End namespace SVF
159
160#endif /* INCLUDE_UTIL_ICFGBUILDER_H_ */
ICFGNode * getICFGNode(const Instruction *inst)
Definition ICFGBuilder.h:93
FunEntryICFGNode * addFunEntryBlock(const Function *fun)
Map< const Instruction *, CallICFGNode * > CSToCallNodeMapTy
Definition ICFGBuilder.h:48
void connectGlobalToProgEntry()
Map< const Instruction *, RetICFGNode * > CSToRetNodeMapTy
Definition ICFGBuilder.h:49
FunEntryICFGNode * getFunEntryICFGNode(const Function *fun)
get a function entry node
FIFOWorkList< const Instruction * > WorkList
Definition ICFGBuilder.h:59
FunExitICFGNode * getFunExitICFGNode(const Function *fun)
get a function exit node
IntraICFGNode * addIntraBlockICFGNode(const Instruction *inst)
Add and get IntraBlock ICFGNode.
Map< const Instruction *, IntraICFGNode * > InstToBlockNodeMapTy
Definition ICFGBuilder.h:50
CallICFGNode * getCallICFGNode(const Instruction *cs)
get a call node
std::vector< const Instruction * > InstVec
Definition ICFGBuilder.h:46
LLVMModuleSet * llvmModuleSet()
Definition ICFGBuilder.h:67
void addGlobalICFGNode()
Map< const Function *, FunEntryICFGNode * > FunToFunEntryNodeMapTy
Definition ICFGBuilder.h:51
void processUnreachableFromEntry(const Function *fun, WorkList &worklist)
Map< const Function *, FunExitICFGNode * > FunToFunExitNodeMapTy
Definition ICFGBuilder.h:52
InterICFGNode * addInterBlockICFGNode(const Instruction *inst)
Add/Get an inter block ICFGNode.
IntraICFGNode * getIntraICFGNode(const Instruction *inst)
get a intra node
bool hasICFGNode(const Instruction *inst)
Definition ICFGBuilder.h:98
void processFunBody(WorkList &worklist)
Set< const Instruction * > BBSet
Definition ICFGBuilder.h:47
GlobalICFGNode * getGlobalICFGNode() const
void checkICFGNodesVisited(const Function *fun)
void processFunEntry(const Function *fun, WorkList &worklist)
FunExitICFGNode * addFunExitBlock(const Function *fun)
ICFGNode * addBlockICFGNode(const Instruction *inst)
Add/Get a basic block ICFGNode.
RetICFGNode * getRetICFGNode(const Instruction *cs)
get a return node
ICFGBuilder()=default
void addICFGInterEdges(const Instruction *cs, const Function *callee)
Create edges between ICFG nodes across functions.
void processFunExit(const Function *fun)
virtual void addICFGNode(ICFGNode *node)
Add a ICFG node.
Definition ICFG.h:219
NodeID totalICFGNode
Definition ICFG.h:66
GlobalICFGNode * globalBlockNode
unique basic block for all globals
Definition ICFG.h:71
GlobalICFGNode * getGlobalICFGNode() const
Definition ICFG.h:236
static LLVMModuleSet * getLLVMModuleSet()
Definition LLVMModule.h:122
FunEntryICFGNode * getFunEntryICFGNode(const Function *fun)
Add a function entry node.
Definition LLVMModule.h:335
bool hasICFGNode(const Instruction *inst)
ICFGNode * getICFGNode(const Instruction *inst)
Get a basic block ICFGNode.
CallICFGNode * getCallICFGNode(const Instruction *cs)
get a call node
RetICFGNode * getRetICFGNode(const Instruction *cs)
get a return node
FunExitICFGNode * getFunExitICFGNode(const Function *fun)
Add a function exit node.
Definition LLVMModule.h:342
IntraICFGNode * getIntraICFGNode(const Instruction *inst)
get a intra node
for isBitcode
Definition BasicTypes.h:68
llvm::Function Function
Definition BasicTypes.h:85
llvm::Instruction Instruction
Definition BasicTypes.h:87
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74