accrue.analysis.interprocvarcontext

## Class AnalysisUtilVarContextDataFlow<A extends Ordered<A>,T extends AbstractValue<T>>

- java.lang.Object
- - accrue.analysis.interprocanalysis.AnalysisUtil<A>
  - - accrue.analysis.interprocvarcontext.AnalysisUtilVarContext<A,T>
    - - accrue.analysis.interprocvarcontext.AnalysisUtilVarContextDataFlow<A,T>

- Type Parameters:
    `A` - Type of analysis results
    `T` - Value type for analysis items in the context
  Direct Known Subclasses:
    AntiDepAnalysisUtil, DefUseAnalysisUtil, NotNullAnalysisUtil

      public abstract class AnalysisUtilVarContextDataFlow<A extends Ordered<A>,T extends AbstractValue<T>>
      extends AnalysisUtilVarContext<A,T>

  Abstract utility class for performing an interprocedural dataflow analysis.

- - ### Field Summary

    - ### Fields inherited from class accrue.analysis.interprocvarcontext.AnalysisUtilVarContext

      `trackErrors`

    - ### Fields inherited from class accrue.analysis.interprocanalysis.AnalysisUtil

      `extInfo, instanceInitializersChecked, workQueue`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AnalysisUtilVarContextDataFlow(WorkQueue<A> workQueue, AnalysisUnit currentAnalysisUnit, AccrueExtensionInfo extInfo)` Create a new utility class

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract FinalVarContext<T>` | `analyzeInitializersForDataFlow(VarContext<T> before)` Analyze the initializers for the current analysis unit given the current analysis results
    `FinalVarContext<T>` | `call(polyglot.types.ConstructorInstance ci, VarContext<T> input, T receiverAbsVal, polyglot.ast.New n, DataFlowNodeIdentifier callSiteNode)` Deprecated.
    `FinalVarContext<T>` | `call(polyglot.types.MethodInstance mi, VarContext<T> input, polyglot.ast.Call n, DataFlowNodeIdentifier callSiteNode)` Deprecated.
    `FinalVarContext<T>` | `call(polyglot.types.MethodInstance mi, VarContext<T> input, DataFlowNodeIdentifier callSite)` Process a call to `mi` with `VarContext` `input`.
    `FinalVarContext<T>` | `callFromNew(polyglot.types.ConstructorInstance ci, VarContext<T> input, T receiverAbsVal, DataFlowNodeIdentifier callSite)` Process a call to `ci` with `VarContext` `input`.
    `FinalVarContext<T>` | `callNonVirtual(polyglot.types.ProcedureInstance pi, AnalysisContext calleeContext, HContext receiver, T receiverAbsVal, VarContext<T> preCall, DataFlowNodeIdentifier callSite, boolean canTerminateNormally)` Process a call to a non-virtual call to `pi` with `VarContext` `input`.
    `FinalVarContext<T>` | `constructorCall(polyglot.types.ConstructorInstance ci, VarContext<T> input, polyglot.ast.ConstructorCall n, DataFlowNodeIdentifier callSiteNode)` Deprecated.
    `FinalVarContext<T>` | `constructorCallFromConstructor(polyglot.types.ConstructorInstance ci, VarContext<T> input, DataFlowNodeIdentifier callSite)` Process a call to `ci` with `VarContext` `input`.
    `protected FinalVarContext<T>` | `getAnalysisResultsFromWorkQueue(AnalysisUnit callee, VarContext<T> beforeCall)` Deprecated.
    `protected abstract FinalVarContext<T>` | `getAnalysisResultsFromWorkQueue(AnalysisUnit callee, VarContext<T> beforeCall, DataFlowNodeIdentifier callSite)` Get the analysis results for the given callee and variable context.
    `protected FinalVarContext<T>` | `guessAnalysisForMissingCode(polyglot.types.ProcedureInstance pi, AnalysisContext calleeContext, HContext receiver, VarContext<T> input, T receiverAbsVal, java.util.List<T> argAbsVals, java.util.Set<ExitMap.Key> computeExpectedExits, DataFlowNodeIdentifier callSite)` Get analysis results for procedures for which the source code is missing.
    `protected FinalVarContext<T>` | `makeFinalVarContext(java.util.Set<ExitMap.Key> expectedExits, VarContext<T> normal, VarContext<T> exceptional)` Make a final var context for the given normal and exceptional var contexts
    `protected FinalVarContext<T>` | `mergeCallResults(java.util.Map<HContext,FinalVarContext<T>> resMap, DataFlowNodeIdentifier callSite)` Merge the results of analyzing a virtual method call which may have multiple targets
    `protected VarContext<T>` | `prepareCalleeContext(AnalysisUnit callee, T receiverAbsVal, java.util.List<T> argAbsVals, VarContext<T> callerPreCall, DataFlowNodeIdentifier callSite)` Create a new context appropriate for analyzing the method instance

    - ### Methods inherited from class accrue.analysis.interprocvarcontext.AnalysisUtilVarContext

      `addLocations, analysisName, bottomAbstractValue, computeExpectedExits, createFinalVarContext, createInitContext, emptyFinalVarContext, getAnalysisForMissingReceiver, getLocationAbsVal, getSignatureForMissingCode, guessAnalysisForMissingCode, guessAnalysisForMissingReceiver, handleRecursiveCall, preCallNonVirtual, recordRead, recordReads, recordWrite, recordWrites, signatureAnalysisNames`

    - ### Methods inherited from class accrue.analysis.interprocanalysis.AnalysisUtil

      `abstractLocations, abstractLocations, abstractLocations, abstractLocations, abstractLocations, abstractLocations, abstractLocations, abstractLocations, abstractLocations, abstractLocationsForArray, abstractLocationsForArray, abstractLocationsForArray, abstractLocationsImplicitTarget, analyze, analyzeInitializers, analyzeStaticInitializers, createExitMap, currentAnalysisUnit, currentClass, currentContext, extensionInfo, instanceInitializers, leq, maybeRecursiveCall, pointsTo, pointsTo, pointsTo, pointsTo, pointsTo, pointsTo, pointsTo, pointsTo, pointsTo, pointsToGraph, pointsToThis, process, recordMissingCode, typeSystem, upperBound, workQueue`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AnalysisUtilVarContextDataFlow

          public AnalysisUtilVarContextDataFlow(WorkQueue<A> workQueue,
                                        AnalysisUnit currentAnalysisUnit,
                                        AccrueExtensionInfo extInfo)

      Create a new utility class
      Parameters:
        `workQueue` - Queue of analysis units
        `currentAnalysisUnit` - Current analysis unit from the queue
        `extInfo` - compiler analysis unit

  - ### Method Detail

    - #### callFromNew

          public FinalVarContext<T> callFromNew(polyglot.types.ConstructorInstance ci,
                                       VarContext<T> input,
                                       T receiverAbsVal,
                                       DataFlowNodeIdentifier callSite)
                                                                  throws polyglot.types.SemanticException

      Process a call to `ci` with `VarContext` `input`.
      Parameters:
        `ci` - constructor to analyze
        `input` - variable context before analyzing the method
        `receiverAbsVal` - The abstract value to use for the newly created object, i.e., the abstract value that "this" will map to in the invoked constructor.
        `callSite` - the site of the call to the constructor
      Returns:
        new map of variables to their values after the analysis
      Throws:
        `polyglot.types.SemanticException` - if analysis fails

    - #### call

          public FinalVarContext<T> call(polyglot.types.MethodInstance mi,
                                VarContext<T> input,
                                DataFlowNodeIdentifier callSite)
                                                           throws polyglot.types.SemanticException

      Process a call to `mi` with `VarContext` `input`.
      Parameters:
        `mi` - method to analyze
        `input` - variable context before analyzing the method
        `callSite` - the call site of the method call
      Returns:
        new map of variables to their values after the analysis
      Throws:
        `polyglot.types.SemanticException` - if analysis fails

    - #### mergeCallResults

          protected FinalVarContext<T> mergeCallResults(java.util.Map<HContext,FinalVarContext<T>> resMap,
                                            DataFlowNodeIdentifier callSite)

      Merge the results of analyzing a virtual method call which may have multiple targets
      Parameters:
        `resMap` - Map of heap contexts to analysis results
        `callSite` - DFI for the call site of the call
        `graph` - Control flow graph
      Returns:
        Context with the results for different targets merged

    - #### callNonVirtual

          public FinalVarContext<T> callNonVirtual(polyglot.types.ProcedureInstance pi,
                                          AnalysisContext calleeContext,
                                          HContext receiver,
                                          T receiverAbsVal,
                                          VarContext<T> preCall,
                                          DataFlowNodeIdentifier callSite,
                                          boolean canTerminateNormally)
                                                                     throws polyglot.types.SemanticException

      Process a call to a non-virtual call to `pi` with `VarContext` `input`.
      Parameters:
        `pi` - call to analyze
        `calleeContext` - procedure analysis context
        `receiver` - abstract heap object for the callee
        `preCall` - variable context before analyzing the method
        `callSite` - the call site for the procedure call
        `canTerminateNormally` - true if the called procedure can terminate normally
      Returns:
        new map of variables to their values after the analysis
      Throws:
        `polyglot.types.SemanticException` - if analysis fails

    - #### guessAnalysisForMissingCode

          protected FinalVarContext<T> guessAnalysisForMissingCode(polyglot.types.ProcedureInstance pi,
                                                       AnalysisContext calleeContext,
                                                       HContext receiver,
                                                       VarContext<T> input,
                                                       T receiverAbsVal,
                                                       java.util.List<T> argAbsVals,
                                                       java.util.Set<ExitMap.Key> computeExpectedExits,
                                                       DataFlowNodeIdentifier callSite)

      Get analysis results for procedures for which the source code is missing.
      Parameters:
        `pi` - procedure instance for which the code is missing
        `calleeContext` - context for the procedure missing source code
        `receiver` - Abstract heap object for the receiver of the missing procedure
        `input` - context before analyzing the missing procedure
        `receiverAbsVal` - abstract value for the receiver of the missing procedure
        `argAbsVals` - abstract values for the arguments to the missing procedure
        `computeExpectedExits` - expected exit keys for the missing procedure (for many analyses the `FinalVarContext` must have an entry for each exit key)
        `callSite` - AST node and analysis context for the call site
      Returns:
        `FinalVarContext` estimating the results of analyzing the missing code

    - #### prepareCalleeContext

          protected VarContext<T> prepareCalleeContext(AnalysisUnit callee,
                                           T receiverAbsVal,
                                           java.util.List<T> argAbsVals,
                                           VarContext<T> callerPreCall,
                                           DataFlowNodeIdentifier callSite)

      Create a new context appropriate for analyzing the method instance
      Parameters:
        `callee` - Analysis unit for the callee
        `receiverAbsVal` - value for the reciever
        `argAbsVals` - list of values for the procedure arguments
        `callerPreCall` - variable context before the procedure call
        `callSite` - procedure call site
      Returns:
        new variable context ready for the procedure analysis

    - #### constructorCallFromConstructor

          public FinalVarContext<T> constructorCallFromConstructor(polyglot.types.ConstructorInstance ci,
                                                          VarContext<T> input,
                                                          DataFlowNodeIdentifier callSite)
                                                                                     throws polyglot.types.SemanticException

      Process a call to `ci` with `VarContext` `input`. This is different from call(ConstructorInstance ci, VarContext input, T receiverAbsVal, DataFlowNodeIdentifier callSite), which is used when a "new C(...)" expression is encountered. By contrast, this is used when a "this(...)" or "super(...)" constructor call is encountered.
      Parameters:
        `ci` - constructor to analyze
        `input` - variable context before analyzing the method
        `callSite` - the site of the call to the constructor
      Returns:
        new map of variables to their values after the analysis
      Throws:
        `polyglot.types.SemanticException` - if analysis fails

    - #### call

          @Deprecated
          public final FinalVarContext<T> call(polyglot.types.ConstructorInstance ci,
                                           VarContext<T> input,
                                           T receiverAbsVal,
                                           polyglot.ast.New n,
                                           DataFlowNodeIdentifier callSiteNode)
                                                                 throws polyglot.types.SemanticException

      Deprecated.
      Use `#call(ConstructorInstance, VarContext, DataFlowNodeIdentifier)`
      Overrides:
        `call` in class `AnalysisUtilVarContext<A extends Ordered<A>,T extends AbstractValue<T>>`
      Parameters:
        `ci` - constructor to analyze
        `input` - variable context before analyzing the method
        `receiverAbsVal` - The abstract value to use for the newly created object, i.e., the abstract value that "this" will map to in the invoked constructor.
        `n` - the call to the constructor
      Returns:
        new map of variables to their values after the analysis
      Throws:
        `polyglot.types.SemanticException` - if analysis fails

    - #### call

          @Deprecated
          public final FinalVarContext<T> call(polyglot.types.MethodInstance mi,
                                           VarContext<T> input,
                                           polyglot.ast.Call n,
                                           DataFlowNodeIdentifier callSiteNode)
                                                                 throws polyglot.types.SemanticException

      Deprecated.
      Use `call(MethodInstance, VarContext, DataFlowNodeIdentifier)`
      Overrides:
        `call` in class `AnalysisUtilVarContext<A extends Ordered<A>,T extends AbstractValue<T>>`
      Parameters:
        `mi` - method to analyze
        `input` - variable context before analyzing the method
        `n` - the call to the method
      Returns:
        new map of variables to their values after the analysis
      Throws:
        `polyglot.types.SemanticException` - if analysis fails

    - #### constructorCall

          @Deprecated
          public final FinalVarContext<T> constructorCall(polyglot.types.ConstructorInstance ci,
                                                      VarContext<T> input,
                                                      polyglot.ast.ConstructorCall n,
                                                      DataFlowNodeIdentifier callSiteNode)
                                                                            throws polyglot.types.SemanticException

      Deprecated.
      Use `#constructorCall(ConstructorInstance, VarContext, DataFlowNodeIdentifier)`
      Overrides:
        `constructorCall` in class `AnalysisUtilVarContext<A extends Ordered<A>,T extends AbstractValue<T>>`
      Parameters:
        `ci` - constructor to analyze
        `input` - variable context before analyzing the method
        `n` - the call to the constructor
      Returns:
        new map of variables to their values after the analysis
      Throws:
        `polyglot.types.SemanticException` - if analysis fails

    - #### getAnalysisResultsFromWorkQueue

          @Deprecated
          protected final FinalVarContext<T> getAnalysisResultsFromWorkQueue(AnalysisUnit callee,
                                                                      VarContext<T> beforeCall)
                                                                                               throws polyglot.types.SemanticException

      Deprecated.
      Use `getAnalysisResultsFromWorkQueue(AnalysisUnit, VarContext, DataFlowNodeIdentifier)`
      Specified by:
        `getAnalysisResultsFromWorkQueue` in class `AnalysisUtilVarContext<A extends Ordered<A>,T extends AbstractValue<T>>`
      Parameters:
        `callee` - Code for a callee that is to be analyzed
        `beforeCall` - variable context before the call to the callee
      Returns:
        new variable context after performing the analysis
      Throws:
        `polyglot.types.SemanticException` - thrown for an analysis error

    - #### getAnalysisResultsFromWorkQueue

          protected abstract FinalVarContext<T> getAnalysisResultsFromWorkQueue(AnalysisUnit callee,
                                                           VarContext<T> beforeCall,
                                                           DataFlowNodeIdentifier callSite)
                                                                                                  throws polyglot.types.SemanticException

      Get the analysis results for the given callee and variable context.
      Parameters:
        `callee` - Code for a callee that is to be analyzed
        `beforeCall` - variable context before the call to the callee
      Returns:
        new variable context after performing the analysis
      Throws:
        `polyglot.types.SemanticException` - thrown for an analysis error

    - #### analyzeInitializersForDataFlow

          public abstract FinalVarContext<T> analyzeInitializersForDataFlow(VarContext<T> before)
                                                                                              throws polyglot.types.SemanticException

      Analyze the initializers for the current analysis unit given the current analysis results
      Parameters:
        `input` - current analysis results
      Returns:
        Map from exit condition to analysis result
      Throws:
        `polyglot.types.SemanticException` - thrown if the analysis fails

    - #### makeFinalVarContext

          protected FinalVarContext<T> makeFinalVarContext(java.util.Set<ExitMap.Key> expectedExits,
                                               VarContext<T> normal,
                                               VarContext<T> exceptional)

      Make a final var context for the given normal and exceptional var contexts
      Parameters:
        `expectedExits` - Exit keys
        `normal` - var context for normal termination
        `exceptional` - var context for an exception path
      Returns:
        final var context for the given normal and exceptional var contexts