Static Value-Flow Analysis
Loading...
Searching...
No Matches
CFLSVFGBuilder.cpp
Go to the documentation of this file.
1//===- CFLSVFGBuilder.cpp -- Building SVFG for CFL--------------------------//
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// Created by Xiao on 30/12/23.
25//
27#include "Graphs/SVFG.h"
28#include "Util/Options.h"
29#include "CFL/CFLSVFGBuilder.h"
30
31
32using namespace SVF;
33using namespace SVFUtil;
34
36{
37
38 MemSSA* mssa = svfg->getMSSA();
39 svfg->buildSVFG();
40 BVDataPTAImpl* pta = mssa->getPTA();
41 DBOUT(DGENERAL, outs() << pasMsg("\tCollect Global Variables\n"));
42
43 collectGlobals(pta);
44
45 DBOUT(DGENERAL, outs() << pasMsg("\tRemove Dereference Direct SVFG Edge\n"));
46
48
50
51 DBOUT(DGENERAL, outs() << pasMsg("\tAdd Sink SVFG Nodes\n"));
52
54
55 if(pta->printStat())
56 svfg->performStat();
57}
58
59
71{
72
73 for(SVFG::iterator it = svfg->begin(), eit = svfg->end(); it!=eit; ++it)
74 {
75 const SVFGNode* node = it->second;
76
77 if(const StoreSVFGNode* stmtNode = SVFUtil::dyn_cast<StoreSVFGNode>(node))
78 {
79 if(SVFUtil::isa<StoreStmt>(stmtNode->getPAGEdge()))
80 {
82 if(isStrongUpdate(node, singleton, pta))
83 {
85 for (SVFGNode::const_iterator it2 = node->InEdgeBegin(), eit2 = node->InEdgeEnd(); it2 != eit2; ++it2)
86 {
87 if ((*it2)->isIndirectVFGEdge())
88 {
89 toRemove.insert(*it2);
90 }
91 }
92 for (SVFGEdge* edge: toRemove)
93 {
94 svfg->removeSVFGEdge(edge);
95 }
96 }
97 }
98 }
99 }
100}
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition SVFType.h:484
#define DGENERAL
Definition SVFType.h:490
virtual void rmIncomingEdgeForSUStore(BVDataPTAImpl *pta)
virtual void buildSVFG()
Re-write create SVFG method.
IDToNodeMapTy::iterator iterator
Node Iterators.
iterator InEdgeBegin()
iterator InEdgeEnd()
BVDataPTAImpl * getPTA() const
Return PTA.
Definition MemSSA.h:308
bool printStat()
Whether print statistics.
PTACallGraph * getCallGraph() const
Return call graph.
std::unique_ptr< SVFG > svfg
Definition SVFGBuilder.h:91
bool isStrongUpdate(const SVFGNode *node, NodeID &singleton, BVDataPTAImpl *pta)
Return TRUE if this is a strong update STORE statement.
void collectGlobals(BVDataPTAImpl *pta)
virtual void AddExtActualParmSVFGNodes(PTACallGraph *callgraph)
Add actual parameter SVFGNode for 1st argument of a deallocation like external function.
void rmDerefDirSVFGEdges(BVDataPTAImpl *pta)
VFGEdge::VFGEdgeSetTy::const_iterator const_iterator
Definition VFGNode.h:55
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
Definition SVFUtil.cpp:100
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:50
for isBitcode
Definition BasicTypes.h:68
u32_t NodeID
Definition GeneralType.h:55
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74