Static Value-Flow Analysis
Loading...
Searching...
No Matches
CDG.cpp
Go to the documentation of this file.
1//===- CDG.cpp -- Control Dependence Graph -------------------------//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-2017> <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 * CDG.cpp
25 *
26 * Created on: Sep 27, 2023
27 * Author: Xiao Cheng
28 */
29#include "Graphs/CDG.h"
30
31using namespace SVF;
32
33CDG *CDG::controlDg = nullptr;
34
36{
37 if (!hasCDGNode(src->getId()))
38 {
39 addGNode(src->getId(), new CDGNode(src));
40 }
41 if (!hasCDGNode(dst->getId()))
42 {
43 addGNode(dst->getId(), new CDGNode(dst));
44 }
45 if (!hasCDGEdge(getCDGNode(src->getId()), getCDGNode(dst->getId())))
46 {
47 CDGEdge *pEdge = new CDGEdge(getCDGNode(src->getId()),
48 getCDGNode(dst->getId()));
49 pEdge->insertBranchCondition(pNode, branchID);
51 incEdgeNum();
52 }
53 else
54 {
56 getCDGNode(dst->getId()));
57 pEdge->insertBranchCondition(pNode, branchID);
58 }
59}
bool hasCDGEdge(CDGNode *src, CDGNode *dst)
Whether we has a CDG edge.
Definition CDG.h:201
CDGEdge * getCDGEdge(const CDGNode *src, const CDGNode *dst)
Get a control dependence edge according to src and dst.
Definition CDG.h:216
static CDG * controlDg
Definition CDG.h:155
void addCDGEdgeFromSrcDst(const ICFGNode *src, const ICFGNode *dst, const SVFVar *pNode, s32_t branchID)
Add CDG edges from nodeid pair.
Definition CDG.cpp:35
bool hasCDGNode(NodeID id) const
Whether has the CDGNode.
Definition CDG.h:195
bool addCDGEdge(CDGEdge *edge)
Add CDG edge.
Definition CDG.h:281
CDGNode * getCDGNode(NodeID id) const
Get a CDG node.
Definition CDG.h:187
void addGNode(NodeID id, NodeType *node)
Add a Node.
NodeID getId() const
Get ID.
for isBitcode
Definition BasicTypes.h:68
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
signed s32_t
Definition GeneralType.h:47