100template<
class N,
class E>
112 N* node = (*it).second;
113 for(
E*
edge : node->getOutEdges())
130 bool isDot = (fileName.rfind(
".dot") == fileName.length() - std::string(
".dot").length());
134 bool isJson = (fileName.rfind(
".json") == fileName.length() - std::string(
".json").length());
147 std::cout <<
"Building CFL Graph from text file: " << fileName <<
"..\n";
153 SVFUtil::errs() <<
"Error opening " << fileName << std::endl;
183 std::string
msg =
"In line " + std::to_string(
lineNum) +
184 " sym can not find in grammar, please correct the input dot or set --flexsymmap.";
202 std::cout <<
"Building CFL Graph from dot file: " << fileName <<
"..\n";
203 std::cout << std::boolalpha;
214 if (
srcStart == std::string::npos)
continue;
217 if (
srcEnd == std::string::npos)
continue;
220 if (
arrowPos == std::string::npos)
continue;
223 if (
dstStart == std::string::npos)
continue;
226 if (
dstEnd == std::string::npos)
continue;
229 if (
labelStart == std::string::npos)
continue;
233 if (
labelEnd == std::string::npos)
continue;
260 std::string
msg =
"In line " + std::to_string(
lineNum) +
261 " sym cannot be found in grammar. Please correct the input dot or set --flexsymmap.";
445 if (
level == 0)
return;
452 addBiGepCFLEdge(cflGraph, (*eit)->getDstNode(), dst,
maxField);
457 connectVGep(cflGraph, graph, (*eit)->getSrcNode(), dst,
level, pag);
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
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)
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.
virtual void addCFLNode(NodeID id, CFLNode *node)
virtual const CFLEdge * addCFLEdge(CFLNode *src, CFLNode *dst, CFLEdge::GEdgeFlag label)
const ConstraintEdge::ConstraintEdgeSetTy & getAddrInEdges() const
iterator begin()
Iterators.
bool hasGNode(NodeID id) const
Has a node.
NodeType * getGNode(NodeID id) const
Get a node.
const GEdgeSetTy & getOutEdges() const
const GEdgeSetTy & getInEdges() const
Kind strToKind(std::string str) const
Map< std::string, Kind > & getNonterminals()
Map< std::string, Kind > & getTerminals()
std::string kindToStr(Kind kind) const
static Kind getAttributedKind(Attribute attribute, Kind kind)
u32_t getNumOfElements() const
Get the number of elements of this object.
static bool classof(const NormalGepCGEdge *)
Methods for support type inquiry through isa, cast, and dyn_cast:
static const Option< bool > FlexSymMap
NodeID getId() const
Get ID.
bool isNullPtr(NodeID id) const
const MemObj * getBaseObj(NodeID id) const
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...
std::string errMsg(const std::string &msg)
Print error message by converting a string into red string output.
std::ostream & errs()
Overwrite llvm::errs()
std::vector< std::string > split(const std::string &s, char separator)
Split into two substrings around the first occurrence of a separator string.
llvm::IRBuilder IRBuilder