Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2015 The Pennsylvania State University and the University of Wisconsin
   * Systems and Internet Infrastructure Security Laboratory
   *
   * Author: Damien Octeau
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package edu.psu.cse.siis.coal;
 
 
 
 
 import soot.Local;
 import soot.Unit;
 import soot.Value;
A factory for call-to-return edge functions. Call-to-return edge functions indicate how values are propagated in parallel to a call statement.
 
   private final Logger logger = LoggerFactory.getLogger(getClass());

  
Returns a call-to-return edge function.

Parameters:
callSite A statement that is the source of a call edge. Most of the time, this should be a call statement, but sometimes it can be a field access that is connected to a class initializer.
callNode The symbol (variable) before the call.
returnSite The statement to which the call returns.
returnSideNode The symbol after the call.
pointsToAnalysis The pointer analysis.
Returns:
A call-to-return edge function.
 
       Value callNodeUnit returnSiteValue returnSideNodePointsToAnalysis pointsToAnalysis) {
     Stmt callStmt = (StmtcallSite;
     InvokeExpr invokeExpr = callStmt.containsInvokeExpr() ? callStmt.getInvokeExpr() : null;
 
     if (invokeExpr != null) {
       // The statement contains a method invocation.
       Argument[] arguments = Model.v().getArgumentsForMethod(invokeExpr);
 
       if (arguments != null) {
         // The call statement is a modifier.
         if (invokeExpr instanceof InstanceInvokeExpr) {
           InstanceInvokeExpr instanceInvokeExpr = (InstanceInvokeExprinvokeExpr;
           Value base = instanceInvokeExpr.getBase();
           PointsToSet basePointsToSet = pointsToAnalysis.reachingObjects((Localbase);
           PointsToSet callNodePointsToSet = FunctionFactoryUtils.getPointsToSetForValue(callNode);
 
           if (basePointsToSet.hasNonEmptyIntersection(callNodePointsToSet)) {
             if (.isDebugEnabled()) {
               .debug("Call node " + callNode);
               .debug("Stmt " + callSite);
               .debug("Returning "
                   + PropagationTransformerFactory.makeTransformer(callSitearguments,
                       !callNode.equals(base)));
             }
 
             return PropagationTransformerFactory.makeTransformer(callSitearguments,
                 !callNode.equals(base));
           }
         }
       } else {
         arguments = Model.v().getArgumentsForGenMethod(invokeExpr);
 
         if (arguments != null) {
           if (callStmt instanceof DefinitionStmt) {
             DefinitionStmt definitionStmt = (DefinitionStmtcallStmt;
             Value leftValue = definitionStmt.getLeftOp();
 
             if (leftValue.equals(returnSideNode)) {
              return PropagationTransformerFactory.makeTransformer(callSiteargumentsfalse);
            }
          }
        } else if (callSite instanceof DefinitionStmt) {
          DefinitionStmt definitionStmt = (DefinitionStmtcallSite;
          arguments =
              Model.v().getArgumentsForCopyConstructor(invokeExpr.getMethodRef().getSignature());
          if (arguments != null) {
            if (callNode.equals(invokeExpr.getArg(arguments[0].getArgnum()[0]))
                && returnSideNode.equals(definitionStmt.getLeftOp())) {
              Argument[] extraArguments = Arrays.copyOfRange(arguments, 1, arguments.length);
              return PropagationTransformerFactory.makeTransformer(callSiteextraArgumentsfalse);
            }
          }
        }
      }
    }
    return EdgeIdentity.v();
  }
New to GrepCode? Check out our FAQ X