Package it.unive.lisa.interprocedural
Interface InterproceduralAnalysis<A extends AbstractState<A>>
-
- Type Parameters:
A
- the type ofAbstractState
contained into the analysis state
public interface InterproceduralAnalysis<A extends AbstractState<A>>
The definition of interprocedural analyses.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
fixpoint(AnalysisState<A> entryState, java.lang.Class<? extends WorkingSet<Statement>> fixpointWorkingSet, FixpointConfiguration conf)
Computes a fixpoint over the whole control flow graph, producing aAnalyzedCFG
for eachCFG
contained in this analysis.AnalysisState<A>
getAbstractResultOf(CFGCall call, AnalysisState<A> entryState, ExpressionSet[] parameters, StatementStore<A> expressions)
Computes an analysis state that abstracts the execution of the possible targets considering that they were givenparameters
as actual parameters, and the state when the call is executed isentryState
.
Note that the interprocedural analysis is also responsible for registering the call to theCallGraph
, if needed.AnalysisState<A>
getAbstractResultOf(OpenCall call, AnalysisState<A> entryState, ExpressionSet[] parameters, StatementStore<A> expressions)
Computes an analysis state that abstracts the execution of an unknown target considering that they were givenparameters
as actual parameters, and the state when the call is executed isentryState
.java.util.Collection<AnalyzedCFG<A>>
getAnalysisResultsOf(CFG cfg)
Yields the results of the given analysis, identified by its class, on the givenCFG
.FixpointResults<A>
getFixpointResults()
Yields the results of the fixpoint computation over the whole application.void
init(Application app, CallGraph callgraph, OpenCallPolicy policy)
Initializes the interprocedural analysis of the given program.boolean
needsCallGraph()
Yieldstrue
if this analysis needs aCallGraph
instance to function.Call
resolve(UnresolvedCall call, java.util.Set<Type>[] types, SymbolAliasing aliasing)
Yields aCall
implementation that corresponds to the resolution of the givenUnresolvedCall
.default boolean
returnsVoid(Call call, AnalysisState<A> returned)
Yields whether or if this call returned no value or its return type isVoidType
.default org.apache.commons.lang3.tuple.Pair<AnalysisState<A>,ExpressionSet[]>
scope(AnalysisState<A> state, ScopeToken scope, ExpressionSet[] actuals)
Converts the pre-state ofcall
to a valid entry state for one of its targets.default AnalysisState<A>
unscope(CFGCall call, ScopeToken scope, AnalysisState<A> state)
Converts the exit state of a cfg that was invoked bycall
to a valid post-state ofcall
.
-
-
-
Method Detail
-
needsCallGraph
boolean needsCallGraph()
Yieldstrue
if this analysis needs aCallGraph
instance to function. If this method returnfalse
and aCallGraph
is passed to LiSA in its configuration, the latter will be ignored and won't be initialized nor constructed.- Returns:
- whether or not this analysis needs a call graph
-
init
void init(Application app, CallGraph callgraph, OpenCallPolicy policy) throws InterproceduralAnalysisException
Initializes the interprocedural analysis of the given program. A call to this method should effectively re-initialize the interprocedural analysis as if it is yet to be used. This is useful when the same instance is used in multiple analyses.- Parameters:
callgraph
- the callgraph used to resolve method callsapp
- the application to analyzepolicy
- theOpenCallPolicy
to be used for computing the result ofOpenCall
s- Throws:
InterproceduralAnalysisException
- if an exception happens while performing the interprocedural analysis
-
fixpoint
void fixpoint(AnalysisState<A> entryState, java.lang.Class<? extends WorkingSet<Statement>> fixpointWorkingSet, FixpointConfiguration conf) throws FixpointException
Computes a fixpoint over the whole control flow graph, producing aAnalyzedCFG
for eachCFG
contained in this analysis. Each result is computed withCFG.fixpoint(AnalysisState, InterproceduralAnalysis, WorkingSet, FixpointConfiguration, ScopeId)
or one of its overloads. Results of individual cfgs are then available throughgetAnalysisResultsOf(CFG)
.- Parameters:
entryState
- the entry state for theCFG
s that are the entrypoints of the computationfixpointWorkingSet
- the concrete class ofWorkingSet
to be used in fixpoints.conf
- theFixpointConfiguration
containing the parameters tuning fixpoint behavior- Throws:
FixpointException
- if something goes wrong while evaluating the fixpoint
-
getAnalysisResultsOf
java.util.Collection<AnalyzedCFG<A>> getAnalysisResultsOf(CFG cfg)
Yields the results of the given analysis, identified by its class, on the givenCFG
. Results are provided asAnalyzedCFG
.- Parameters:
cfg
- the cfg whose fixpoint results needs to be retrieved- Returns:
- the result of the fixpoint computation of
valueDomain
overcfg
-
getAbstractResultOf
AnalysisState<A> getAbstractResultOf(CFGCall call, AnalysisState<A> entryState, ExpressionSet[] parameters, StatementStore<A> expressions) throws SemanticException
Computes an analysis state that abstracts the execution of the possible targets considering that they were givenparameters
as actual parameters, and the state when the call is executed isentryState
.
Note that the interprocedural analysis is also responsible for registering the call to theCallGraph
, if needed.- Parameters:
call
- the call to evaluateentryState
- the abstract analysis state when the call is reachedparameters
- the expressions representing the actual parameters of the callexpressions
- the cache where analysis states of intermediate expressions must be stored- Returns:
- an abstract analysis state representing the abstract result of
the cfg call. The
AnalysisState.getComputedExpressions()
will contain anIdentifier
pointing to the meta variable containing the abstraction of the returned value, if any - Throws:
SemanticException
- if something goes wrong during the computation
-
getAbstractResultOf
AnalysisState<A> getAbstractResultOf(OpenCall call, AnalysisState<A> entryState, ExpressionSet[] parameters, StatementStore<A> expressions) throws SemanticException
Computes an analysis state that abstracts the execution of an unknown target considering that they were givenparameters
as actual parameters, and the state when the call is executed isentryState
.- Parameters:
call
- the call to evaluateentryState
- the abstract analysis state when the call is reachedparameters
- the expressions representing the actual parameters of the callexpressions
- the cache where analysis states of intermediate expressions must be stored- Returns:
- an abstract analysis state representing the abstract result of
the open call. The
AnalysisState.getComputedExpressions()
will contain anIdentifier
pointing to the meta variable containing the abstraction of the returned value, if any - Throws:
SemanticException
- if something goes wrong during the computation
-
resolve
Call resolve(UnresolvedCall call, java.util.Set<Type>[] types, SymbolAliasing aliasing) throws CallResolutionException
Yields aCall
implementation that corresponds to the resolution of the givenUnresolvedCall
. This method will forward the call toCallGraph.resolve(UnresolvedCall, Set[], SymbolAliasing)
if needed.- Parameters:
call
- the call to resolvetypes
- the runtime types of the parameters of the callaliasing
- the symbol aliasing information- Returns:
- a collection of all the possible runtime targets
- Throws:
CallResolutionException
- if this analysis is unable to resolve the given call
-
getFixpointResults
FixpointResults<A> getFixpointResults()
Yields the results of the fixpoint computation over the whole application.- Returns:
- the results of the fixpoint
-
scope
default org.apache.commons.lang3.tuple.Pair<AnalysisState<A>,ExpressionSet[]> scope(AnalysisState<A> state, ScopeToken scope, ExpressionSet[] actuals) throws SemanticException
Converts the pre-state ofcall
to a valid entry state for one of its targets. Specifically, the state returned by this method corresponds to the given one modified by (i) pushing the scope that is introduced when the call happens (and that can be popped withunscope(CFGCall, ScopeToken, AnalysisState)
), and (ii) generating the expressions for the formal parameters by pushing the same scope to the ones of the actual parameters.- Parameters:
scope
- the scope corresponding to the callstate
- the exit state of the call's targetactuals
- the expressions representing the actual parameters at the program point of the call- Returns:
- a pair containing the computed call state and the expressions corresponding to the formal parameters
- Throws:
SemanticException
- if something goes wrong during the computation
-
unscope
default AnalysisState<A> unscope(CFGCall call, ScopeToken scope, AnalysisState<A> state) throws SemanticException
Converts the exit state of a cfg that was invoked bycall
to a valid post-state ofcall
. Specifically, the state returned by this method corresponds to the given one modified by (i) popping the scope introduced before the call happened (seescope(AnalysisState, ScopeToken, ExpressionSet[])
), and (ii) storing the returned value on the meta-variable left on the stack, if any.- Parameters:
call
- the call that caused the computation of the given state through a fixpoint computationscope
- the scope corresponding to the callstate
- the exit state of the call's target- Returns:
- the state that can be returned by the call
- Throws:
SemanticException
- if something goes wrong during the computation
-
returnsVoid
default boolean returnsVoid(Call call, AnalysisState<A> returned)
Yields whether or if this call returned no value or its return type isVoidType
. If this method returnstrue
, then no value should be assigned to the call's meta variable.- Parameters:
call
- the callreturned
- the post-state of the call- Returns:
true
if that condition holds
-
-