Package it.unive.lisa.analysis
Class CFGWithAnalysisResults<A extends AbstractState<A,H,V>,H extends HeapDomain<H>,V extends ValueDomain<V>>
- java.lang.Object
-
- it.unive.lisa.util.datastructures.graph.Graph<CFG,Statement,Edge>
-
- it.unive.lisa.program.cfg.CFG
-
- it.unive.lisa.analysis.CFGWithAnalysisResults<A,H,V>
-
- Type Parameters:
A- the type ofAbstractStatecontained into the analysis stateH- the type ofHeapDomaincontained into the computed abstract stateV- the type ofValueDomaincontained into the computed abstract state
- All Implemented Interfaces:
Lattice<CFGWithAnalysisResults<A,H,V>>,CodeMember
public class CFGWithAnalysisResults<A extends AbstractState<A,H,V>,H extends HeapDomain<H>,V extends ValueDomain<V>> extends CFG implements Lattice<CFGWithAnalysisResults<A,H,V>>
A control flow graph, that hasStatements as nodes andEdges as edges. It also maps each statement (and its inner expressions) to the result of a fixpoint computation, in the form of anAnalysisStateinstance.
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.util.datastructures.graph.Graph
adjacencyMatrix, entrypoints
-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_REPR, BOTTOM_STRING, TOP_REPR, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description CFGWithAnalysisResults(CFG cfg, AnalysisState<A,H,V> singleton)Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.CFGWithAnalysisResults(CFG cfg, AnalysisState<A,H,V> singleton, java.util.Map<Statement,AnalysisState<A,H,V>> entryStates, java.util.Map<Statement,AnalysisState<A,H,V>> results)Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CFGWithAnalysisResults<A,H,V>bottom()Yields the bottom element of this lattice.booleanequals(java.lang.Object obj)AnalysisState<A,H,V>getAnalysisStateAfter(Statement st)Yields the computed result at a given statement (exit state).AnalysisState<A,H,V>getAnalysisStateBefore(Statement st)Yields the computed result before a given statement (entry state).AnalysisState<A,H,V>getEntryState()Yields the entry state.AnalysisState<A,H,V>getExitState()Yields the exit state.java.lang.StringgetId()Yields a string meant to identify this specific result, based on how it has been produced.inthashCode()booleanisBottom()Yieldstrueif and only if this object represents the bottom of the lattice.booleanisTop()Yieldstrueif and only if this object represents the top of the lattice.CFGWithAnalysisResults<A,H,V>join(CFGWithAnalysisResults<A,H,V> other)Joins twoCFGWithAnalysisResultstogether.booleanlessOrEqual(CFGWithAnalysisResults<A,H,V> other)Yieldstrueif and only if this lattice element is in relation with (usually represented through ≤) the given one.CFGWithAnalysisResults<A,H,V>lub(CFGWithAnalysisResults<A,H,V> other)Performs the least upper bound operation between this lattice element and the given one.voidsetId(java.lang.String id)Sets the string meant to identify this specific result, based on how it has been produced.protected DotCFGtoDot(java.util.function.Function<Statement,java.lang.String> labelGenerator)Converts this graph to aDotGraphinstance.CFGWithAnalysisResults<A,H,V>top()Yields the top element of this lattice.CFGWithAnalysisResults<A,H,V>widening(CFGWithAnalysisResults<A,H,V> other)Performs the widening operation between this lattice element and the given one.-
Methods inherited from class it.unive.lisa.program.cfg.CFG
addControlFlowStructure, fixpoint, fixpoint, fixpoint, getAllExitpoints, getControlFlowStructures, getDescriptor, getGenericProgramPoint, getGuards, getIfThenElseGuards, getLoopGuards, getMostRecentGuard, getMostRecentIfThenElseGuard, getMostRecentLoopGuard, getNormalExitpoints, isGuarded, isInsideIfThenElse, isInsideLoop, preSimplify, simplify, toString, validate
-
Methods inherited from class it.unive.lisa.util.datastructures.graph.Graph
accept, addEdge, addNode, addNode, dump, dump, followersOf, getAdjacencyMatrix, getEdgeConnecting, getEdges, getEdgesCount, getEntrypoints, getIngoingEdges, getNodes, getNodesCount, getOutgoingEdges, isEqualTo, predecessorsOf, simplify
-
-
-
-
Constructor Detail
-
CFGWithAnalysisResults
public CFGWithAnalysisResults(CFG cfg, AnalysisState<A,H,V> singleton)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.- Parameters:
cfg- the original control flow graphsingleton- an instance of theAnalysisStatecontaining the abstract state of the analysis that was executed, used to retrieve top and bottom values
-
CFGWithAnalysisResults
public CFGWithAnalysisResults(CFG cfg, AnalysisState<A,H,V> singleton, java.util.Map<Statement,AnalysisState<A,H,V>> entryStates, java.util.Map<Statement,AnalysisState<A,H,V>> results)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.- Parameters:
cfg- the original control flow graphsingleton- an instance of theAnalysisStatecontaining the abstract state of the analysis that was executed, used to retrieve top and bottom valuesentryStates- the entry state for each entry point of the cfgresults- the results of the fixpoint computation
-
-
Method Detail
-
getId
public java.lang.String getId()
Yields a string meant to identify this specific result, based on how it has been produced. This method might returnnull.- Returns:
- the identifier of this result
-
setId
public void setId(java.lang.String id)
Sets the string meant to identify this specific result, based on how it has been produced.- Parameters:
id- the identifier of this result (might benull)
-
getAnalysisStateBefore
public final AnalysisState<A,H,V> getAnalysisStateBefore(Statement st) throws SemanticException
Yields the computed result before a given statement (entry state).- Parameters:
st- the statement- Returns:
- the result computed before the given statement
- Throws:
SemanticException- if the lub operator fails
-
getAnalysisStateAfter
public final AnalysisState<A,H,V> getAnalysisStateAfter(Statement st)
Yields the computed result at a given statement (exit state).- Parameters:
st- the statement- Returns:
- the result computed at the given statement
-
getEntryState
public final AnalysisState<A,H,V> getEntryState() throws SemanticException
Yields the entry state.- Returns:
- the entry state of the CFG
- Throws:
SemanticException- if the lub operator fails
-
getExitState
public final AnalysisState<A,H,V> getExitState() throws SemanticException
Yields the exit state.- Returns:
- the entry state of the CFG
- Throws:
SemanticException- if the lub operator fails
-
join
public CFGWithAnalysisResults<A,H,V> join(CFGWithAnalysisResults<A,H,V> other) throws SemanticException
Joins twoCFGWithAnalysisResultstogether. The difference between this method andlub(CFGWithAnalysisResults)is that this method does not set the ID of the resulting cfg.- Parameters:
other- the other cfg- Returns:
- the least upper bound of the two cfgs without its id set
- Throws:
SemanticException- if something goes wrong during the join
-
lub
public CFGWithAnalysisResults<A,H,V> lub(CFGWithAnalysisResults<A,H,V> other) throws SemanticException
Description copied from interface:LatticePerforms the least upper bound operation between this lattice element and the given one. This operation is commutative.- Specified by:
lubin interfaceLattice<A extends AbstractState<A,H,V>>- Parameters:
other- the other lattice element- Returns:
- the least upper bound
- Throws:
SemanticException- if an error occurs during the computation
-
widening
public CFGWithAnalysisResults<A,H,V> widening(CFGWithAnalysisResults<A,H,V> other) throws SemanticException
Description copied from interface:LatticePerforms the widening operation between this lattice element and the given one. This operation is not commutative.- Specified by:
wideningin interfaceLattice<A extends AbstractState<A,H,V>>- Parameters:
other- the other lattice element- Returns:
- the widening between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
lessOrEqual
public boolean lessOrEqual(CFGWithAnalysisResults<A,H,V> other) throws SemanticException
Description copied from interface:LatticeYieldstrueif and only if this lattice element is in relation with (usually represented through ≤) the given one. This operation is not commutative.- Specified by:
lessOrEqualin interfaceLattice<A extends AbstractState<A,H,V>>- Parameters:
other- the other lattice element- Returns:
trueif and only if that condition holds- Throws:
SemanticException- if an error occurs during the computation
-
top
public CFGWithAnalysisResults<A,H,V> top()
Description copied from interface:LatticeYields the top element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isTop()uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isTop()accordingly to provide a coherent test.
-
isTop
public boolean isTop()
Description copied from interface:LatticeYieldstrueif and only if this object represents the top of the lattice. The default implementation of this method uses reference equality betweenthisand the value returned byLattice.top(), thus assuming that the top element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.
-
bottom
public CFGWithAnalysisResults<A,H,V> bottom()
Description copied from interface:LatticeYields the bottom element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isBottom()uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isBottom()accordingly to provide a coherent test.
-
isBottom
public boolean isBottom()
Description copied from interface:LatticeYieldstrueif and only if this object represents the bottom of the lattice. The default implementation of this method uses reference equality betweenthisand the value returned byLattice.bottom(), thus assuming that the bottom element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.
-
toDot
protected DotCFG toDot(java.util.function.Function<Statement,java.lang.String> labelGenerator)
Description copied from class:GraphConverts this graph to aDotGraphinstance.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-