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 <vector>
38
39#include "Graphs/ICFG.h"
40#include "Graphs/WTO.h"
41
42namespace SVF
43{
44
45class FunObjVar;
46
50
53class ICFGWTO : public WTO<ICFG>
54{
55public:
56 typedef WTO<ICFG> Base;
59
60 // 1st argument is the SCC's entry ICFGNode and 2nd argument is the function(s) in this SCC.
61 explicit ICFGWTO(const ICFGNode* node, Set<const FunObjVar*> funcScc = {}) :
62 Base(node), scc(funcScc)
63 {
64 if (scc.empty()) // if funcScc is empty, the scc is the function itself
65 scc.insert(node->getFun());
66 }
67
68 virtual ~ICFGWTO()
69 {
70 }
71
72 inline virtual std::vector<const ICFGNode*> getSuccessors(const ICFGNode* node) override
73 {
74 std::vector<const ICFGNode*> successors;
75
76 if (const auto* callNode = SVFUtil::dyn_cast<CallICFGNode>(node))
77 {
78
79 for (const auto &e : callNode->getOutEdges())
80 {
81 ICFGNode *calleeEntryICFGNode = e->getDstNode();
82 const ICFGNode *succ = nullptr;
83
84 if (scc.find(calleeEntryICFGNode->getFun()) != scc.end()) // caller & callee in the same SCC
86 else
87 succ = callNode->getRetICFGNode(); // caller & callee in different SCC
88
89 successors.push_back(succ);
90 }
91 }
92 else
93 {
94 for (const auto& e : node->getOutEdges())
95 {
96 ICFGNode *succ = e->getDstNode();
97 if (scc.find(succ->getFun()) == scc.end()) // if not in the same SCC, skip
98 continue;
99 successors.push_back(succ);
100 }
101 }
102
103 return successors;
104 }
105};
106
107} // namespace SVF
108
109#endif // SVF_ICFGWTO_H
const GEdgeSetTy & getOutEdges() const
virtual const FunObjVar * getFun() const
Return the function of this ICFGNode.
Definition ICFGNode.h:75
ICFGWTO(const ICFGNode *node, Set< const FunObjVar * > funcScc={})
Definition ICFGWTO.h:61
Set< const FunObjVar * > scc
Definition ICFGWTO.h:58
virtual ~ICFGWTO()
Definition ICFGWTO.h:68
virtual std::vector< const ICFGNode * > getSuccessors(const ICFGNode *node) override
Definition ICFGWTO.h:72
WTO< ICFG > Base
Definition ICFGWTO.h:56
WTOComponentVisitor< ICFG >::WTONodeT ICFGWTONode
Definition ICFGWTO.h:57
for isBitcode
Definition BasicTypes.h:70
WTOCycle< ICFG > ICFGCycleWTO
Definition ICFGWTO.h:49
WTONode< ICFG > ICFGSingletonWTO
Definition ICFGWTO.h:48
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76
WTOComponent< ICFG > ICFGWTOComp
Definition ICFGWTO.h:47