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