Static Value-Flow Analysis
Loading...
Searching...
No Matches
CFLAlias.h
Go to the documentation of this file.
1//===----- CFLAlias.h -- CFL Alias Analysis Client--------------//
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 * CFLAlias.h
25 *
26 * Created on: March 5, 2022
27 * Author: Yulei Sui
28 */
29
30#ifndef INCLUDE_CFL_CFLALIAS_H_
31#define INCLUDE_CFL_CFLALIAS_H_
32
33#include "CFL/CFLBase.h"
34#include "CFL/CFLStat.h"
35
36namespace SVF
37{
38
39class CFLStat;
40
41class CFLAlias : public CFLBase
42{
43
44public:
46
50
52 virtual void initialize();
53
55 virtual void initializeSolver();
56
57
59 virtual void finalize();
60
62 virtual void solve();
63
72
74 virtual const PointsTo& getCFLPts(NodeID ptr)
75 {
78 for(auto outedge = funNode->getOutEdges().begin(); outedge!=funNode->getOutEdges().end(); outedge++)
79 {
80 if((*outedge)->getEdgeKind() == graph->getStartKind())
81 {
82 // Need to Find dst addr src
83 SVFVar *vNode = svfir->getGNode((*outedge)->getDstID());
85 // Remove svfir->getBaseValVar, SVF IR api change
86 if (vNode->hasIncomingEdges(SVFStmt::Gep))
87 {
89 SVFVar::iterator it = geps.begin();
90 basevNodeID = (*it)->getSrcID();
91 }
92 else
93 basevNodeID = vNode->getId();
95 for(auto inEdge = vNode->getInEdges().begin(); inEdge!=vNode->getInEdges().end(); inEdge++)
96 {
97 if((*inEdge)->getEdgeKind() == 0)
98 {
99 addPts(ptr, (*inEdge)->getSrcID());
100 }
101 }
102 }
103 }
104 return getPts(ptr);
105 }
106
108
110 virtual inline bool addCopyEdge(NodeID src, NodeID dst)
111 {
112 const CFLEdge *edge = graph->hasEdge(graph->getGNode(src),graph->getGNode(dst), 1);
113 if (edge != nullptr )
114 {
115 return false;
116 }
117 CFGrammar::Kind copyKind = grammar->strToKind("copy");
121 return true;
122 }
123
126 {
128 abort(); // to be implemented
129 }
130
132 virtual bool updateCallGraph(const CallSiteToFunPtrMap& callsites);
133
136
138 void connectCaller2CalleeParams(const CallICFGNode* cs, const FunObjVar* F);
139
141
142private:
144};
145
146class POCRAlias : public CFLAlias
147{
148public:
150 {
151 }
153 virtual void initializeSolver();
154};
155
156class POCRHybrid : public CFLAlias
157{
158public:
160 {
161 }
162
164 virtual void initializeSolver();
165};
166} // End namespace SVF
167
168#endif /* INCLUDE_CFL_CFLALIAS_H_*/
const PointsTo & getPts(NodeID id) override
virtual bool addPts(NodeID id, NodeID ptd)
virtual const NodeSet & getRevPts(NodeID nodeId)
Given an object, get all the nodes having whose pointsto contains the object.
Definition CFLAlias.h:125
void connectCaller2CalleeParams(const CallICFGNode *cs, const FunObjVar *F)
Connect formal and actual parameters for indirect callsites.
Definition CFLAlias.cpp:62
virtual void finalize()
Print grammar and graph.
Definition CFLAlias.cpp:213
virtual bool addCopyEdge(NodeID src, NodeID dst)
Need Original one for virtual table.
Definition CFLAlias.h:110
virtual void onTheFlyCallGraphSolve(const CallSiteToFunPtrMap &callsites, CallEdgeMap &newEdges)
On the fly call graph construction.
Definition CFLAlias.cpp:39
virtual void initializeSolver()
Initialize Solver.
Definition CFLAlias.cpp:208
OrderedMap< const CallICFGNode *, NodeID > CallSite2DummyValPN
Definition CFLAlias.h:45
void heapAllocatorViaIndCall(const CallICFGNode *cs)
Definition CFLAlias.cpp:145
virtual void solve()
Solving CFL Reachability.
Definition CFLAlias.cpp:228
virtual const PointsTo & getCFLPts(NodeID ptr)
Get points-to targets of a pointer. V In this context.
Definition CFLAlias.h:74
virtual bool updateCallGraph(const CallSiteToFunPtrMap &callsites)
Update call graph for the input indirect callsites.
Definition CFLAlias.cpp:173
CFLAlias(SVFIR *ir)
Definition CFLAlias.h:47
CallSite2DummyValPN callsite2DummyValPN
Map an instruction to a dummy obj which created at an indirect callsite, which invokes a heap allocat...
Definition CFLAlias.h:143
virtual void initialize()
Initialize the grammar, graph, solver.
Definition CFLAlias.cpp:188
virtual AliasResult alias(NodeID node1, NodeID node2)
Interface exposed to users of our Alias analysis, given PAGNodeID.
Definition CFLAlias.h:65
CFL Client Base Class.
Definition CFLBase.h:50
CFLSolver * solver
Definition CFLBase.h:113
CFLGraph * graph
Definition CFLBase.h:110
CFGrammar * grammar
Definition CFLBase.h:112
SVFIR * svfir
Definition CFLBase.h:109
Kind getStartKind() const
Definition CFLGraph.cpp:37
virtual const CFLEdge * addCFLEdge(CFLNode *src, CFLNode *dst, CFLEdge::GEdgeFlag label)
Definition CFLGraph.cpp:47
virtual const CFLEdge * hasEdge(CFLNode *src, CFLNode *dst, CFLEdge::GEdgeFlag label)
Definition CFLGraph.cpp:63
virtual bool pushIntoWorklist(const CFLEdge *item)
Definition CFLSolver.h:84
NodeType * getGNode(NodeID id) const
Get a node.
GEdgeSetTy::iterator iterator
Kind strToKind(std::string str) const
Definition CFGrammar.cpp:55
POCRAlias(SVFIR *ir)
Definition CFLAlias.h:149
virtual void initializeSolver()
Initialize POCR Solver.
Definition CFLAlias.cpp:247
virtual void initializeSolver()
Initialize POCRHybrid Solver.
Definition CFLAlias.cpp:252
POCRHybrid(SVFIR *ir)
Definition CFLAlias.h:159
@ CFLFICI_WPA
Flow-, context-, insensitive CFL-reachability-based analysis.
OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap
SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
SVFStmt::SVFStmtSetTy & getIncomingEdges(SVFStmt::PEDGEK kind)
Edge accessors and checkers.
for isBitcode
Definition BasicTypes.h:68
Set< NodeID > NodeSet
u32_t NodeID
Definition GeneralType.h:56
AliasResult
Definition SVFType.h:541
@ MayAlias
Definition SVFType.h:543
@ NoAlias
Definition SVFType.h:542
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74