Static Value-Flow Analysis
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 
37 namespace SVF
38 {
39 
40 enum class BuildDirection
41 {
42  plain,
44 };
45 
51 {
52 protected:
57 
61 
64 
67 
70 
72  void buildlabelToKindMap(GrammarBase *grammar);
73 
76 
79 
82 
85 
86 public:
89  template<class N, class E>
91 
94 
97 
100  {
101  return this->labelToKindMap;
102  }
103 
106  {
107  return this->kindToLabelMap;
108  }
109 
112  {
113  return this->kindToAttrsMap;
114  }
115 
117 };
118 
121 {
122 public:
124  CFLGraph* buildBigraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar);
125 
128  CFLGraph* buildBiPEGgraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar, SVFIR* pag);
129 
130 private:
133 
136 
139 };
140 
143 {
144 public:
146  CFLGraph* buildBigraph(SVFG *graph, Kind startKind, GrammarBase *grammar);
147 
150  CFLGraph* buildBiPEGgraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar, SVFIR* pag);
151 
152 private:
155 
158 
161 };
162 
163 
164 }// SVF
165 
166 #endif /* INCLUDE_CFL_CFLGRAPHBUILDER_H_*/
const char *const string
Definition: cJSON.h:172
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< Kind, std::string > & getKindToLabelMap()
Returns a reference to the map that associates Kinds with their corresponding string labels.
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< std::string, Kind > & getLabelToKindMap()
Returns a reference to the map that associates string labels with their corresponding Kind.
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.
Map< CFGrammar::Kind, Set< CFGrammar::Attribute > > & getKindToAttrsMap()
Returns a reference to the map that associates Kinds with their corresponding attributes.
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.
Definition: SVFG.h:66
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:68
BuildDirection
u32_t NodeID
Definition: GeneralType.h:55
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition: GeneralType.h:101
unsigned u32_t
Definition: GeneralType.h:46