Static Value-Flow Analysis
Loading...
Searching...
No Matches
ICFGWTO.h
Go to the documentation of this file.
1//===--------------- ICFGWTO.h -- WTO for ICFG----------------------//
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 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 * ICFGWTO.h
25 *
26 * The implementation is based on F. Bourdoncle's paper:
27 * "Efficient chaotic iteration strategies with widenings", Formal
28 * Methods in Programming and Their Applications, 1993, pages 128-141.
29 *
30 * Created on: Jan 22, 2024
31 * Author: Xiao Cheng
32 *
33 */
34#ifndef SVF_ICFGWTO_H
35#define SVF_ICFGWTO_H
36
37#include "Graphs/ICFG.h"
38#include "Graphs/WTO.h"
39#include "Graphs/CallGraph.h"
40
41namespace SVF
42{
43
47
48class ICFGWTO : public WTO<ICFG>
49{
50public:
51 typedef WTO<ICFG> Base;
53
54 explicit ICFGWTO(ICFG* graph, const ICFGNode* node) : Base(graph, node) {}
55
56 virtual ~ICFGWTO()
57 {
58 }
59
60 inline void forEachSuccessor(
61 const ICFGNode* node,
62 std::function<void(const ICFGNode*)> func) const override
63 {
64 if (const auto* callNode = SVFUtil::dyn_cast<CallICFGNode>(node))
65 {
66 const ICFGNode* succ = callNode->getRetICFGNode();
67 func(succ);
68 }
69 else
70 {
71 for (const auto& e : node->getOutEdges())
72 {
73 if (!e->isIntraCFGEdge() ||
74 node->getFun() != e->getDstNode()->getFun())
75 continue;
76 func(e->getDstNode());
77 }
78 }
79 }
80};
81
82// Added for IWTO
83class ICFGIWTO : public ICFGWTO
84{
85public:
86 typedef ICFGWTO Base;
90
91 explicit ICFGIWTO(ICFG* graph, const ICFGNode* node, NodeBS & funcPar, CallGraph* cg) :
92 Base(graph, node), funcPar(funcPar), cg(cg) {}
93
94 virtual ~ICFGIWTO()
95 {
96 }
97
98 inline void forEachSuccessor(
99 const ICFGNode* node,
100 std::function<void(const ICFGNode*)> func) const override
101 {
102 if (const auto* callNode = SVFUtil::dyn_cast<CallICFGNode>(node))
103 {
104
105 for (const auto &e : callNode->getOutEdges())
106 {
107 ICFGNode *calleeEntryICFGNode = e->getDstNode();
109
110 const ICFGNode* succ = nullptr;
111 if (funcPar.test(calleeCGNode->getId()))
113 else
114 succ = callNode->getRetICFGNode();
115
116 func(succ);
117 }
118 }
119 else
120 {
121 for (const auto& e : node->getOutEdges())
122 {
123 ICFGNode *succ = e->getDstNode();
125 if (!funcPar.test(succCGNode->getId()))
126 continue;
127 func(succ);
128 }
129 }
130 }
131};
132
133} // namespace SVF
134
135#endif // SVF_ICFGWTO_H
const CallGraphNode * getCallGraphNode(const std::string &name)
Get call graph node.
const GEdgeSetTy & getOutEdges() const
virtual ~ICFGIWTO()
Definition ICFGWTO.h:94
ICFGWTO Base
Definition ICFGWTO.h:86
WTOComponentVisitor< ICFG >::WTONodeT ICFGWTONode
Definition ICFGWTO.h:87
void forEachSuccessor(const ICFGNode *node, std::function< void(const ICFGNode *)> func) const override
Definition ICFGWTO.h:98
CallGraph * cg
Definition ICFGWTO.h:89
NodeBS & funcPar
Definition ICFGWTO.h:88
ICFGIWTO(ICFG *graph, const ICFGNode *node, NodeBS &funcPar, CallGraph *cg)
Definition ICFGWTO.h:91
virtual const FunObjVar * getFun() const
Return the function of this ICFGNode.
Definition ICFGNode.h:76
void forEachSuccessor(const ICFGNode *node, std::function< void(const ICFGNode *)> func) const override
Definition ICFGWTO.h:60
virtual ~ICFGWTO()
Definition ICFGWTO.h:56
ICFGWTO(ICFG *graph, const ICFGNode *node)
Definition ICFGWTO.h:54
WTO< ICFG > Base
Definition ICFGWTO.h:51
WTOComponentVisitor< ICFG >::WTONodeT ICFGWTONode
Definition ICFGWTO.h:52
bool test(unsigned Idx) const
for isBitcode
Definition BasicTypes.h:68
WTOCycle< ICFG > ICFGCycleWTO
Definition ICFGWTO.h:46
WTONode< ICFG > ICFGSingletonWTO
Definition ICFGWTO.h:45
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
WTOComponent< ICFG > ICFGWTOComp
Definition ICFGWTO.h:44