Static Value-Flow Analysis
Public Member Functions | Private Attributes | List of all members
SVF::CFLVF Class Reference

#include <CFLVF.h>

Inheritance diagram for SVF::CFLVF:
SVF::CFLBase SVF::BVDataPTAImpl SVF::PointerAnalysis

Public Member Functions

 CFLVF (SVFIR *ir)
 
virtual void checkParameter ()
 Parameter Checking. More...
 
virtual void initialize ()
 Initialize the grammar, graph, solver. More...
 
virtual void finalize ()
 Print grammar and graph. More...
 
void buildCFLGraph ()
 Build CFLGraph via VFG. More...
 
- Public Member Functions inherited from SVF::CFLBase
 CFLBase (SVFIR *ir, PointerAnalysis::PTATY pty)
 
virtual ~CFLBase ()
 Destructor. More...
 
virtual void buildCFLGrammar ()
 Build Grammar from text file. More...
 
virtual void normalizeCFLGrammar ()
 Normalize grammar. More...
 
CFLGraphgetCFLGraph ()
 Get CFL graph. More...
 
virtual void countSumEdges ()
 Count the num of Nonterminal Edges. More...
 
virtual void solve ()
 Solving CFL Reachability. More...
 
virtual void analyze ()
 Perform analyze (main part of CFLR Analysis) More...
 
- Public Member Functions inherited from SVF::BVDataPTAImpl
 BVDataPTAImpl (SVFIR *pag, PointerAnalysis::PTATY type, bool alias_check=true)
 Constructor. More...
 
 ~BVDataPTAImpl () override=default
 Destructor. More...
 
PersistentPointsToCache< PointsTo > & getPtCache ()
 
const PointsTogetPts (NodeID id) override
 
const NodeSetgetRevPts (NodeID nodeId) override
 
virtual void clearPts (NodeID id, NodeID element)
 Remove element from the points-to set of id. More...
 
virtual void clearFullPts (NodeID id)
 Clear points-to set of id. More...
 
virtual bool unionPts (NodeID id, const PointsTo &target)
 
virtual bool unionPts (NodeID id, NodeID ptd)
 
virtual bool addPts (NodeID id, NodeID ptd)
 
virtual void clearAllPts ()
 Clear all data. More...
 
virtual void expandFIObjs (const PointsTo &pts, PointsTo &expandedPts)
 Expand FI objects. More...
 
virtual void expandFIObjs (const NodeBS &pts, NodeBS &expandedPts)
 TODO: remove repetition. More...
 
void remapPointsToSets (void)
 Remap all points-to sets to use the current mapping. More...
 
virtual void writeToFile (const std::string &filename)
 Interface for analysis result storage on filesystem. More...
 
virtual void writeObjVarToFile (const std::string &filename)
 
virtual void writePtsResultToFile (std::fstream &f)
 
virtual void writeGepObjVarMapToFile (std::fstream &f)
 
virtual bool readFromFile (const std::string &filename)
 
virtual void readPtsResultFromFile (std::ifstream &f)
 
virtual void readGepObjVarMapFromFile (std::ifstream &f)
 
virtual void readAndSetObjFieldSensitivity (std::ifstream &f, const std::string &delimiterStr)
 
AliasResult alias (const SVFValue *V1, const SVFValue *V2) override
 Interface expose to users of our pointer analysis, given Value infos. More...
 
AliasResult alias (NodeID node1, NodeID node2) override
 Interface expose to users of our pointer analysis, given PAGNodeID. More...
 
virtual AliasResult alias (const PointsTo &pts1, const PointsTo &pts2)
 Interface expose to users of our pointer analysis, given two pts. More...
 
void dumpCPts () override
 dump and debug, print out conditional pts More...
 
void dumpTopLevelPtsTo () override
 
void dumpAllPts () override
 
- Public Member Functions inherited from SVF::PointerAnalysis
ICFGgetICFG () const
 Get ICFG. More...
 
u32_t getNumOfResolvedIndCallEdge () const
 Return number of resolved indirect call edges. More...
 
PTACallGraphgetCallGraph () const
 Return call graph. More...
 
CallGraphSCCgetCallGraphSCC () const
 Return call graph SCC. More...
 
 PointerAnalysis (SVFIR *pag, PTATY ty=Default_PTA, bool alias_check=true)
 Constructor. More...
 
PTATY getAnalysisTy () const
 Type of pointer analysis. More...
 
PTAImplTy getImplTy () const
 Return implementation type of the pointer analysis. More...
 
bool printStat ()
 Whether print statistics. More...
 
void disablePrintStat ()
 Whether print statistics. More...
 
CallEdgeMapgetIndCallMap ()
 Get callees from an indirect callsite. More...
 
bool hasIndCSCallees (const CallICFGNode *cs) const
 
const FunctionSetgetIndCSCallees (const CallICFGNode *cs) const
 
virtual void resolveIndCalls (const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
 Resolve indirect call edges. More...
 
void callGraphSCCDetection ()
 PTACallGraph SCC related methods. More...
 
NodeID getCallGraphSCCRepNode (NodeID id) const
 Get SCC rep node of a SVFG node. More...
 
bool inSameCallGraphSCC (const SVFFunction *fun1, const SVFFunction *fun2)
 Return TRUE if this edge is inside a PTACallGraph SCC, i.e., src node and dst node are in the same SCC on the SVFG. More...
 
bool isInRecursion (const SVFFunction *fun) const
 
bool isLocalVarInRecursiveFun (NodeID id) const
 Whether a local variable is in function recursions. More...
 
virtual const std::string PTAName () const
 Return PTA name. More...
 
CommonCHGraphgetCHGraph () const
 get CHGraph More...
 
void getVFnsFromCHA (const CallICFGNode *cs, VFunSet &vfns)
 
void getVFnsFromPts (const CallICFGNode *cs, const PointsTo &target, VFunSet &vfns)
 
void connectVCallToVFns (const CallICFGNode *cs, const VFunSet &vfns, CallEdgeMap &newEdges)
 
virtual void resolveCPPIndCalls (const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
 Resolve cpp indirect call edges. More...
 
SVFIRgetPAG () const
 
PTAStatgetStat () const
 Get PTA stat. More...
 
SVFModulegetModule () const
 Module. More...
 
OrderedNodeSetgetAllValidPtrs ()
 Get all Valid Pointers for resolution. More...
 
virtual ~PointerAnalysis ()
 Destructor. More...
 
virtual void computeDDAPts (NodeID)
 Compute points-to results on-demand, overridden by derived classes. More...
 
void printIndCSTargets (const CallICFGNode *cs, const FunctionSet &targets)
 Print targets of a function pointer. More...
 
virtual void dumpPts (NodeID ptr, const PointsTo &pts)
 
void printIndCSTargets ()
 
void dumpAllTypes ()
 
void dumpStat ()
 Dump the statistics. More...
 
bool containBlackHoleNode (const PointsTo &pts)
 Determine whether a points-to contains a black hole or constant node. More...
 
bool containConstantNode (const PointsTo &pts)
 
virtual bool isBlkObjOrConstantObj (NodeID ptd) const
 
bool isHeapMemObj (NodeID id) const
 Whether this object is heap or array. More...
 
bool isArrayMemObj (NodeID id) const
 
bool isFIObjNode (NodeID id) const
 
NodeID getBaseObjVar (NodeID id)
 
NodeID getFIObjVar (NodeID id)
 
NodeID getGepObjVar (NodeID id, const APOffset &ap)
 
virtual const NodeBSgetAllFieldsObjVars (NodeID id)
 
void setObjFieldInsensitive (NodeID id)
 
bool isFieldInsensitive (NodeID id) const
 

Private Attributes

CFLSVFGBuilder memSSA
 
SVFGsvfg
 

Additional Inherited Members

- Public Types inherited from SVF::BVDataPTAImpl
enum  PTBackingType { Mutable , Persistent }
 How the PTData used is implemented. More...
 
typedef PTData< NodeID, NodeSet, NodeID, PointsToPTDataTy
 
typedef DiffPTData< NodeID, NodeSet, NodeID, PointsToDiffPTDataTy
 
typedef DFPTData< NodeID, NodeSet, NodeID, PointsToDFPTDataTy
 
typedef VersionedPTData< NodeID, NodeSet, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > VersionedPTDataTy
 
typedef MutablePTData< NodeID, NodeSet, NodeID, PointsToMutPTDataTy
 
typedef MutableDiffPTData< NodeID, NodeSet, NodeID, PointsToMutDiffPTDataTy
 
typedef MutableDFPTData< NodeID, NodeSet, NodeID, PointsToMutDFPTDataTy
 
typedef MutableIncDFPTData< NodeID, NodeSet, NodeID, PointsToMutIncDFPTDataTy
 
typedef MutableVersionedPTData< NodeID, NodeSet, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > MutVersionedPTDataTy
 
typedef PersistentPTData< NodeID, NodeSet, NodeID, PointsToPersPTDataTy
 
typedef PersistentDiffPTData< NodeID, NodeSet, NodeID, PointsToPersDiffPTDataTy
 
typedef PersistentDFPTData< NodeID, NodeSet, NodeID, PointsToPersDFPTDataTy
 
typedef PersistentIncDFPTData< NodeID, NodeSet, NodeID, PointsToPersIncDFPTDataTy
 
typedef PersistentVersionedPTData< NodeID, NodeSet, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > PersVersionedPTDataTy
 
- Public Types inherited from SVF::PointerAnalysis
enum  PTATY {
  Andersen_BASE , Andersen_WPA , AndersenSCD_WPA , AndersenSFR_WPA ,
  AndersenWaveDiff_WPA , Steensgaard_WPA , CSCallString_WPA , CSSummary_WPA ,
  FSDATAFLOW_WPA , FSSPARSE_WPA , VFS_WPA , FSCS_WPA ,
  CFLFICI_WPA , CFLFSCI_WPA , CFLFSCS_WPA , TypeCPP_WPA ,
  FieldS_DDA , FlowS_DDA , PathS_DDA , Cxt_DDA ,
  Default_PTA
}
 Pointer analysis type list. More...
 
enum  PTAImplTy { BaseImpl , BVDataImpl , CondImpl }
 Implementation type: BVDataPTAImpl or CondPTAImpl. More...
 
typedef Set< const CallICFGNode * > CallSiteSet
 Indirect call edges type, map a callsite to a set of callees. More...
 
typedef SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
 
typedef Set< const SVFFunction * > FunctionSet
 
typedef OrderedMap< const CallICFGNode *, FunctionSetCallEdgeMap
 
typedef SCCDetection< PTACallGraph * > CallGraphSCC
 
typedef Set< const SVFGlobalValue * > VTableSet
 
typedef Set< const SVFFunction * > VFunSet
 
- Static Public Member Functions inherited from SVF::BVDataPTAImpl
static bool classof (const PointerAnalysis *pta)
 
- Static Public Attributes inherited from SVF::CFLBase
static double timeOfBuildCFLGrammar = 0
 Statistics. More...
 
static double timeOfNormalizeGrammar = 0
 
static double timeOfBuildCFLGraph = 0
 
static double numOfTerminalEdges = 0
 
static double numOfTemporaryNonterminalEdges = 0
 
static double numOfNonterminalEdges = 0
 
static double numOfStartEdges = 0
 
static double numOfIteration = 1
 
static double numOfChecks = 1
 
static double timeOfSolving = 0
 
- Static Public Attributes inherited from SVF::PointerAnalysis
static const std::string aliasTestMayAlias = "MAYALIAS"
 
static const std::string aliasTestMayAliasMangled = "_Z8MAYALIASPvS_"
 
static const std::string aliasTestNoAlias = "NOALIAS"
 
static const std::string aliasTestNoAliasMangled = "_Z7NOALIASPvS_"
 
static const std::string aliasTestPartialAlias = "PARTIALALIAS"
 
static const std::string aliasTestPartialAliasMangled = "_Z12PARTIALALIASPvS_"
 
static const std::string aliasTestMustAlias = "MUSTALIAS"
 
static const std::string aliasTestMustAliasMangled = "_Z9MUSTALIASPvS_"
 
static const std::string aliasTestFailMayAlias = "EXPECTEDFAIL_MAYALIAS"
 
static const std::string aliasTestFailMayAliasMangled = "_Z21EXPECTEDFAIL_MAYALIASPvS_"
 
static const std::string aliasTestFailNoAlias = "EXPECTEDFAIL_NOALIAS"
 
static const std::string aliasTestFailNoAliasMangled = "_Z20EXPECTEDFAIL_NOALIASPvS_"
 
- Protected Member Functions inherited from SVF::BVDataPTAImpl
PTDataTygetPTDataTy () const
 Get points-to data structure. More...
 
void finalize () override
 Finalization of pointer analysis, and normalize points-to information to Bit Vector representation. More...
 
virtual bool updateCallGraph (const CallSiteToFunPtrMap &)
 Update callgraph. This should be implemented by its subclass. More...
 
DiffPTDataTygetDiffPTDataTy () const
 
DFPTDataTygetDFPTDataTy () const
 
MutDFPTDataTygetMutDFPTDataTy () const
 
VersionedPTDataTygetVersionedPTDataTy () const
 
virtual void onTheFlyCallGraphSolve (const CallSiteToFunPtrMap &callsites, CallEdgeMap &newEdges)
 On the fly call graph construction. More...
 
virtual void onTheFlyThreadCallGraphSolve (const CallSiteToFunPtrMap &callsites, CallEdgeMap &newForkEdges)
 On the fly thread call graph construction respecting forksite. More...
 
virtual void normalizePointsTo ()
 
- Protected Member Functions inherited from SVF::PointerAnalysis
const CallSiteToFunPtrMapgetIndirectCallsites () const
 Return all indirect callsites. More...
 
NodeID getFunPtr (const CallICFGNode *cs) const
 Return function pointer PAGNode at a callsite cs. More...
 
virtual void validateTests ()
 Alias check functions to verify correctness of pointer analysis. More...
 
virtual void validateSuccessTests (std::string fun)
 
virtual void validateExpectedFailureTests (std::string fun)
 
void resetObjFieldSensitive ()
 Reset all object node as field-sensitive. More...
 
- Protected Attributes inherited from SVF::CFLBase
SVFIRsvfir
 
CFLGraphgraph
 
GrammarBasegrammarBase
 
CFGrammargrammar
 
CFLSolversolver
 
- Protected Attributes inherited from SVF::PointerAnalysis
bool print_stat
 User input flags. More...
 
bool alias_validation
 Flag for validating points-to/alias results. More...
 
u32_t OnTheFlyIterBudgetForStat
 Flag for iteration budget for on-the-fly statistics. More...
 
SVFModulesvfMod
 Module. More...
 
PTATY ptaTy
 Pointer analysis Type. More...
 
PTAImplTy ptaImplTy
 PTA implementation type. More...
 
PTAStatstat
 Statistics. More...
 
PTACallGraphcallgraph
 Call graph used for pointer analysis. More...
 
CallGraphSCCcallGraphSCC
 SCC for PTACallGraph. More...
 
ICFGicfg
 Interprocedural control-flow graph. More...
 
CommonCHGraphchgraph
 CHGraph. More...
 
- Static Protected Attributes inherited from SVF::PointerAnalysis
static SVFIRpag = nullptr
 SVFIR. More...
 

Detailed Description

Definition at line 41 of file CFLVF.h.

Constructor & Destructor Documentation

◆ CFLVF()

SVF::CFLVF::CFLVF ( SVFIR ir)
inline

Definition at line 45 of file CFLVF.h.

46  {
47  }
CFLBase(SVFIR *ir, PointerAnalysis::PTATY pty)
Definition: CFLBase.h:53
@ CFLFSCS_WPA
Flow-, context-, CFL-reachability-based analysis.

Member Function Documentation

◆ buildCFLGraph()

void CFLVF::buildCFLGraph ( )
virtual

Build CFLGraph via VFG.

Reimplemented from SVF::CFLBase.

Definition at line 35 of file CFLVF.cpp.

36 {
37  // Build CFL Graph
38  VFCFLGraphBuilder cflGraphBuilder = VFCFLGraphBuilder();
39  if (Options::CFLGraph().empty()) // built from svfir
40  {
43  svfg = memSSA.buildFullSVFG(ander);
45  }
46  else
47  graph = cflGraphBuilder.build(Options::CFLGraph(), grammarBase);
48 
49  // Check CFL Graph and Grammar are accordance with grammar
51  cflChecker.check(grammarBase, &cflGraphBuilder, graph);
52 }
static AndersenWaveDiff * createAndersenWaveDiff(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
Definition: Andersen.h:408
CFLGraph * graph
Definition: CFLBase.h:110
GrammarBase * grammarBase
Definition: CFLBase.h:111
void check(GrammarBase *grammar, CFLGraphBuilder *graphBuilder, CFLGraph *graph)
CFLGraph * build(GenericGraph< N, E > *graph, GrammarBase *grammar, BuildDirection direction=BuildDirection::plain)
CFLSVFGBuilder memSSA
Definition: CFLVF.h:62
SVFG * svfg
Definition: CFLVF.h:63
Kind getStartKind()
Definition: CFGrammar.h:205
static const Option< std::string > CFLGraph
Definition: Options.h:232
virtual void initialize()
Initialization of a pointer analysis, including building symbol table and SVFIR etc.
static SVFIR * pag
SVFIR.
SVFG * buildFullSVFG(BVDataPTAImpl *pta)
Definition: SVFGBuilder.cpp:49
VFCFLGraphBuilder: a CFLGraphBuilder specialized for handling value-flow.
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...

◆ checkParameter()

void CFLVF::checkParameter ( )
virtual

Parameter Checking.

Reimplemented from SVF::CFLBase.

Definition at line 72 of file CFLVF.cpp.

73 {
74  // Check for valid grammar file before parsing other options
76  bool vfgfile = (filename.rfind("VFGGrammar.txt") == filename.length() - std::string("VFGGrammar.txt").length());
77  if (!Options::Customized() && !vfgfile)
78  {
79  SVFUtil::errs() << "Invalid VFG grammar file: " << Options::GrammarFilename() << "\n"
80  << "Please use a file that ends with 'VFG.txt', "
81  << "or use the -customized flag to allow custom grammar files.\n";
82  assert(false && "grammar loading failed!"); // exit with error
83  }
84 }
const char *const string
Definition: cJSON.h:172
static const Option< bool > Customized
Definition: Options.h:239
static const Option< std::string > GrammarFilename
Definition: Options.h:231
std::ostream & errs()
Overwrite llvm::errs()
Definition: SVFUtil.h:56

◆ finalize()

void CFLVF::finalize ( )
virtual

Print grammar and graph.

Reimplemented from SVF::CFLBase.

Definition at line 87 of file CFLVF.cpp.

88 {
89  if(Options::PrintCFL())
90  {
91  if (Options::CFLGraph().empty())
92  svfir->dump("IR");
93  grammar->dump("Grammar");
94  graph->dump("CFLGraph");
95  }
96 }
void dump() const
Definition: CFGrammar.cpp:346
CFGrammar * grammar
Definition: CFLBase.h:112
SVFIR * svfir
Definition: CFLBase.h:109
void dump(const std::string &filename)
Definition: CFLGraph.cpp:73
void dump(std::string name)
Dump SVFIR.
Definition: IRGraph.cpp:102
static const Option< bool > PrintCFL
Definition: Options.h:233

◆ initialize()

void CFLVF::initialize ( )
virtual

Initialize the grammar, graph, solver.

Reimplemented from SVF::PointerAnalysis.

Definition at line 54 of file CFLVF.cpp.

55 {
56  // Parameter Checking
58 
59  // Build CFL Grammar
61 
62  // Build CFL Graph
63  buildCFLGraph();
64 
65  // Normalize grammar
67 
68  // Initialize solver
69  solver = new CFLSolver(graph, grammar);
70 }
CFLSolver * solver
Definition: CFLBase.h:113
virtual void normalizeCFLGrammar()
Normalize grammar.
Definition: CFLBase.cpp:105
virtual void buildCFLGrammar()
Build Grammar from text file.
Definition: CFLBase.cpp:65
virtual void checkParameter()
Parameter Checking.
Definition: CFLVF.cpp:72
void buildCFLGraph()
Build CFLGraph via VFG.
Definition: CFLVF.cpp:35

Member Data Documentation

◆ memSSA

CFLSVFGBuilder SVF::CFLVF::memSSA
private

Definition at line 62 of file CFLVF.h.

◆ svfg

SVFG* SVF::CFLVF::svfg
private

Definition at line 63 of file CFLVF.h.


The documentation for this class was generated from the following files: