Interface InterproceduralAnalysis<A extends AbstractState<A>>

  • Type Parameters:
    A - the type of AbstractState contained into the analysis state

    public interface InterproceduralAnalysis<A extends AbstractState<A>>
    The definition of interprocedural analyses.
    • Method Detail

      • needsCallGraph

        boolean needsCallGraph()
        Yields true if this analysis needs a CallGraph instance to function. If this method return false and a CallGraph 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 calls
        app - the application to analyze
        policy - the OpenCallPolicy to be used for computing the result of OpenCalls
        Throws:
        InterproceduralAnalysisException - if an exception happens while performing the interprocedural analysis
      • getAnalysisResultsOf

        java.util.Collection<AnalyzedCFG<A>> getAnalysisResultsOf​(CFG cfg)
        Yields the results of the given analysis, identified by its class, on the given CFG. Results are provided as AnalyzedCFG.
        Parameters:
        cfg - the cfg whose fixpoint results needs to be retrieved
        Returns:
        the result of the fixpoint computation of valueDomain over cfg
      • 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 given parameters as actual parameters, and the state when the call is executed is entryState.

        Note that the interprocedural analysis is also responsible for registering the call to the CallGraph, if needed.
        Parameters:
        call - the call to evaluate
        entryState - the abstract analysis state when the call is reached
        parameters - the expressions representing the actual parameters of the call
        expressions - 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 an Identifier 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 given parameters as actual parameters, and the state when the call is executed is entryState.
        Parameters:
        call - the call to evaluate
        entryState - the abstract analysis state when the call is reached
        parameters - the expressions representing the actual parameters of the call
        expressions - 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 an Identifier pointing to the meta variable containing the abstraction of the returned value, if any
        Throws:
        SemanticException - if something goes wrong during the computation
      • 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 of call 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 with unscope(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 call
        state - the exit state of the call's target
        actuals - 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 by call to a valid post-state of call. Specifically, the state returned by this method corresponds to the given one modified by (i) popping the scope introduced before the call happened (see scope(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 computation
        scope - the scope corresponding to the call
        state - 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 is VoidType. If this method returns true, then no value should be assigned to the call's meta variable.
        Parameters:
        call - the call
        returned - the post-state of the call
        Returns:
        true if that condition holds