Class BaseCasesFinder<A extends it.unive.lisa.analysis.AbstractState<A>>
- java.lang.Object
-
- it.unive.lisa.interprocedural.CallGraphBasedAnalysis<A>
-
- it.unive.lisa.interprocedural.context.ContextBasedAnalysis<A>
-
- it.unive.lisa.interprocedural.context.recursion.BaseCasesFinder<A>
-
- Type Parameters:
A
- the type ofAbstractState
contained into the analysis state
- All Implemented Interfaces:
it.unive.lisa.interprocedural.InterproceduralAnalysis<A>
public class BaseCasesFinder<A extends it.unive.lisa.analysis.AbstractState<A>> extends ContextBasedAnalysis<A>
A recursion solver that applies a single iteration of the recursion starting from bottom and using top as entry state for the recursion. This is useful for understanding what is the return value in the base cases of the recursion: as the call that closes the recursion loop returns bottom, only the returns from the base cases will affect the result.
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.interprocedural.context.ContextBasedAnalysis
conf, results, token
-
Fields inherited from class it.unive.lisa.interprocedural.CallGraphBasedAnalysis
app, callgraph, policy
-
-
Constructor Summary
Constructors Constructor Description BaseCasesFinder(ContextBasedAnalysis<A> backing, Recursion<A> recursion, boolean returnsVoid)
Builds the solver.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canShortcut(it.unive.lisa.program.cfg.CFG cfg)
Whether or not this analysis can avoid computing a fixpoint for the given cfg when it is invoked by a call, and shortcut to the result for the same token if it exists and if it was produced with a greater entry state.it.unive.lisa.analysis.AnalysisState<A>
find()
Solves the recursion by iterating once starting from bottom.void
fixpoint(it.unive.lisa.analysis.AnalysisState<A> entryState, java.lang.Class<? extends it.unive.lisa.util.collections.workset.WorkingSet<it.unive.lisa.program.cfg.statement.Statement>> fixpointWorkingSet, it.unive.lisa.conf.FixpointConfiguration conf)
it.unive.lisa.analysis.AnalysisState<A>
getAbstractResultOf(it.unive.lisa.program.cfg.statement.call.CFGCall call, it.unive.lisa.analysis.AnalysisState<A> entryState, it.unive.lisa.analysis.lattices.ExpressionSet[] parameters, it.unive.lisa.analysis.StatementStore<A> expressions)
void
init(it.unive.lisa.program.Application app, it.unive.lisa.interprocedural.callgraph.CallGraph callgraph, it.unive.lisa.interprocedural.OpenCallPolicy policy)
protected boolean
shouldCheckForRecursions()
Whether or not this analysis should look for recursions when evaluating calls, immediately returning bottom when one is found.protected boolean
shouldStoreFixpointResults()
Whether or not this analysis should store the results of fixpoint executions for them to be returned as part ofContextBasedAnalysis.getFixpointResults()
.-
Methods inherited from class it.unive.lisa.interprocedural.context.ContextBasedAnalysis
getAnalysisResultsOf, getFixpointResults
-
Methods inherited from class it.unive.lisa.interprocedural.CallGraphBasedAnalysis
getAbstractResultOf, needsCallGraph, prepareEntryStateOfEntryPoint, resolve
-
-
-
-
Constructor Detail
-
BaseCasesFinder
public BaseCasesFinder(ContextBasedAnalysis<A> backing, Recursion<A> recursion, boolean returnsVoid)
Builds the solver.- Parameters:
backing
- the analysis that backs this solver, and that can be used to query call resultsrecursion
- the recursion to solvereturnsVoid
- whether or not the recursion returns void
-
-
Method Detail
-
init
public void init(it.unive.lisa.program.Application app, it.unive.lisa.interprocedural.callgraph.CallGraph callgraph, it.unive.lisa.interprocedural.OpenCallPolicy policy) throws it.unive.lisa.interprocedural.InterproceduralAnalysisException
- Specified by:
init
in interfaceit.unive.lisa.interprocedural.InterproceduralAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Overrides:
init
in classContextBasedAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Throws:
it.unive.lisa.interprocedural.InterproceduralAnalysisException
-
fixpoint
public void fixpoint(it.unive.lisa.analysis.AnalysisState<A> entryState, java.lang.Class<? extends it.unive.lisa.util.collections.workset.WorkingSet<it.unive.lisa.program.cfg.statement.Statement>> fixpointWorkingSet, it.unive.lisa.conf.FixpointConfiguration conf) throws it.unive.lisa.util.datastructures.graph.algorithms.FixpointException
- Specified by:
fixpoint
in interfaceit.unive.lisa.interprocedural.InterproceduralAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Overrides:
fixpoint
in classContextBasedAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Throws:
it.unive.lisa.util.datastructures.graph.algorithms.FixpointException
-
getAbstractResultOf
public it.unive.lisa.analysis.AnalysisState<A> getAbstractResultOf(it.unive.lisa.program.cfg.statement.call.CFGCall call, it.unive.lisa.analysis.AnalysisState<A> entryState, it.unive.lisa.analysis.lattices.ExpressionSet[] parameters, it.unive.lisa.analysis.StatementStore<A> expressions) throws it.unive.lisa.analysis.SemanticException
- Specified by:
getAbstractResultOf
in interfaceit.unive.lisa.interprocedural.InterproceduralAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Overrides:
getAbstractResultOf
in classContextBasedAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Throws:
it.unive.lisa.analysis.SemanticException
-
canShortcut
protected boolean canShortcut(it.unive.lisa.program.cfg.CFG cfg)
Description copied from class:ContextBasedAnalysis
Whether or not this analysis can avoid computing a fixpoint for the given cfg when it is invoked by a call, and shortcut to the result for the same token if it exists and if it was produced with a greater entry state.- Overrides:
canShortcut
in classContextBasedAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Parameters:
cfg
- the cfg under evaluation- Returns:
true
if that condition holds (defaults totrue
)
-
shouldCheckForRecursions
protected boolean shouldCheckForRecursions()
Description copied from class:ContextBasedAnalysis
Whether or not this analysis should look for recursions when evaluating calls, immediately returning bottom when one is found.- Overrides:
shouldCheckForRecursions
in classContextBasedAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Returns:
true
if that condition holds (defaults totrue
)
-
shouldStoreFixpointResults
protected boolean shouldStoreFixpointResults()
Description copied from class:ContextBasedAnalysis
Whether or not this analysis should store the results of fixpoint executions for them to be returned as part ofContextBasedAnalysis.getFixpointResults()
.- Overrides:
shouldStoreFixpointResults
in classContextBasedAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Returns:
true
if that condition holds (defaults totrue
)
-
find
public it.unive.lisa.analysis.AnalysisState<A> find() throws it.unive.lisa.analysis.SemanticException
Solves the recursion by iterating once starting from bottom.- Returns:
- the poststate for the call that starts the recursion
- Throws:
it.unive.lisa.analysis.SemanticException
- if an exception happens during the computation
-
-