Static Value-Flow Analysis
Loading...
Searching...
No Matches
CFLGraphBuilder.h
Go to the documentation of this file.
1//===----- CFLGraphBuilder.h -- CFL Graph Builder --------------//
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 * CFLGraphBuilder.h
25 *
26 * Created on: May 22, 2022
27 * Author: Pei Xu
28 */
29
30#ifndef INCLUDE_CFL_CFLGRAPHBUILDER_H_
31#define INCLUDE_CFL_CFLGRAPHBUILDER_H_
32
33#include "CFL/CFGrammar.h"
34#include "Graphs/CFLGraph.h"
35#include "Graphs/SVFG.h"
36#include "Util/GeneralType.h"
37
38namespace SVF
39{
40
46
52{
53protected:
58
62
65
68
71
73 void buildlabelToKindMap(GrammarBase *grammar);
74
77
79 CFLGraph* buildFromText(std::string fileName, GrammarBase *grammar, BuildDirection direction = BuildDirection::plain);
80
82 CFLGraph *buildFromDot(std::string filename, GrammarBase *grammar, BuildDirection direction = BuildDirection::plain);
83
85 CFLGraph *buildFromJson(std::string filename, GrammarBase *grammar, BuildDirection direction = BuildDirection::plain);
86
87public:
90 template<class N, class E>
92
94 CFLGraph* build(std::string fileName, GrammarBase *grammar, BuildDirection direction = BuildDirection::plain);
95
98
101 {
102 return this->labelToKindMap;
103 }
104
107 {
108 return this->kindToLabelMap;
109 }
110
113 {
114 return this->kindToAttrsMap;
115 }
116
118};
119
122 public CFLGraphBuilder
123{
124public:
126 CFLGraph* buildBigraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar);
127
130 CFLGraph* buildBiPEGgraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar, SVFIR* pag);
131
132private:
135
138
141};
142
145 public CFLGraphBuilder
146{
147public:
149 CFLGraph* buildBigraph(SVFG *graph, Kind startKind, GrammarBase *grammar);
150
153 CFLGraph* buildBiPEGgraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar, SVFIR* pag);
154
155private:
158
161
164};
165
166
167}// SVF
168
169#endif /* INCLUDE_CFL_CFLGRAPHBUILDER_H_*/
AliasCFLGraphBuilder: a CFLGraphBuilder specialized for handling aliasing.
void addBiCFLEdge(CFLGraph *cflGraph, ConstraintNode *src, ConstraintNode *dst, CFGrammar::Kind label)
Handles edges, with the exception of the GEP.
void connectVGep(CFLGraph *cflGraph, ConstraintGraph *graph, ConstraintNode *src, ConstraintNode *dst, u32_t level, SVFIR *pag)
Connects VGep (Variable GEP).
void addBiGepCFLEdge(CFLGraph *cflGraph, ConstraintNode *src, ConstraintNode *dst, CFGrammar::Attribute attri)
Adds bidirectional GEP edges with attributes.
CFLGraph * buildBigraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar)
Builds a bidirectional CFL graph by copying nodes and edges from a const graph that inherits from Gen...
CFLGraph * buildBiPEGgraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar, SVFIR *pag)
void buildlabelToKindMap(GrammarBase *grammar)
build label and kind connect from the grammar
Map< CFGrammar::Kind, Set< CFGrammar::Attribute > > & getKindToAttrsMap()
Returns a reference to the map that associates Kinds with their corresponding attributes.
Map< std::string, Kind > & getLabelToKindMap()
Returns a reference to the map that associates string labels with their corresponding Kind.
CFLGraph * buildFromDot(std::string filename, GrammarBase *grammar, BuildDirection direction=BuildDirection::plain)
Method to build a CFL graph from a Dot file.
Map< std::string, Kind > labelToKindMap
Maps to maintain mapping between labels and kinds.
CFLGraph * build(GenericGraph< N, E > *graph, GrammarBase *grammar, BuildDirection direction=BuildDirection::plain)
CFGrammar::Symbol Symbol
CFGrammar::Kind Kind
Map< Kind, std::string > & getKindToLabelMap()
Returns a reference to the map that associates Kinds with their corresponding string labels.
Map< Kind, std::string > kindToLabelMap
CFLGraph * buildFromJson(std::string filename, GrammarBase *grammar, BuildDirection direction=BuildDirection::plain)
Method to build a CFL graph from a Json file.
CFLGraph * buildFromText(std::string fileName, GrammarBase *grammar, BuildDirection direction=BuildDirection::plain)
Method to build a CFL graph from a Text file.
CFLNode * addGNode(u32_t NodeID)
add src and dst node from file
void addAttribute(CFGrammar::Kind kind, CFGrammar::Attribute attribute)
Method to add an attribute to a specific kind.
Map< CFGrammar::Kind, Set< CFGrammar::Attribute > > kindToAttrsMap
Map to maintain attributes associated with each kind.
VFCFLGraphBuilder: a CFLGraphBuilder specialized for handling value-flow.
void connectVGep(CFLGraph *cflGraph, ConstraintGraph *graph, ConstraintNode *src, ConstraintNode *dst, u32_t level, SVFIR *pag)
Connects VGep (Variable GEP).
void addBiCFLEdge(CFLGraph *cflGraph, ConstraintNode *src, ConstraintNode *dst, CFGrammar::Kind label)
Handles edges, with the exception of the GEP.
void addBiGepCFLEdge(CFLGraph *cflGraph, ConstraintNode *src, ConstraintNode *dst, CFGrammar::Attribute attri)
Adds bidirectional GEP edges with attributes.
CFLGraph * buildBiPEGgraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar, SVFIR *pag)
CFLGraph * buildBigraph(SVFG *graph, Kind startKind, GrammarBase *grammar)
Builds a bidirectional CFL graph by copying nodes and edges from a const graph that inherits from SVF...
for isBitcode
Definition BasicTypes.h:70
u32_t NodeID
Definition GeneralType.h:76
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition GeneralType.h:56
unsigned u32_t
Definition GeneralType.h:67