コード例 #1
0
  private OrdinalSet<InstanceKey> pointsToArrayField(final CGNode node, final int ssaVarBase) {
    final PointerAnalysis<InstanceKey> pts = sdg.getPointerAnalysis();

    final PointerKey pkBase = pts.getHeapModel().getPointerKeyForLocal(node, ssaVarBase);
    final OrdinalSet<InstanceKey> basePts = pts.getPointsToSet(pkBase);

    return basePts;

    // no field sensitivity atm

    //		OrdinalSet<InstanceKey> ptsSet = OrdinalSet.empty();
    //		for (final InstanceKey ik : basePts) {
    //			final PointerKey fieldPk = pts.getHeapModel().getPointerKeyForArrayContents(ik);
    //			final OrdinalSet<InstanceKey> ptsPart = pts.getPointsToSet(fieldPk);
    //			ptsSet = OrdinalSet.unify(ptsSet, ptsPart);
    //		}
    //
    //		return ptsSet;
  }
コード例 #2
0
ファイル: CallGraphTest.java プロジェクト: FirstGitHubID/WALA
 @Test
 public void testZeroOneContainerCopyOf()
     throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
   AnalysisScope scope =
       CallGraphTestUtil.makeJ2SEAnalysisScope(
           TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
   ClassHierarchy cha = ClassHierarchy.make(scope);
   Iterable<Entrypoint> entrypoints =
       Util.makeMainEntrypoints(scope, cha, "Ldemandpa/TestArraysCopyOf");
   AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
   AnalysisCache cache = new AnalysisCache();
   CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
   CallGraph cg = builder.makeCallGraph(options, null);
   PointerAnalysis pa = builder.getPointerAnalysis();
   CGNode mainMethod = AbstractPtrTest.findMainMethod(cg);
   PointerKey keyToQuery = AbstractPtrTest.getParam(mainMethod, "testThisVar", pa.getHeapModel());
   OrdinalSet<? extends InstanceKey> pointsToSet = pa.getPointsToSet(keyToQuery);
   Assert.assertEquals(1, pointsToSet.size());
 }
コード例 #3
0
ファイル: CISlicer.java プロジェクト: roostedglory/Object_SSA
 /**
  * Compute the set of PointerKeys each statement refs.Be careful to avoid eager PDG construction
  * here! That means .. don't iterate over SDG statements!
  */
 public static Map<Statement, Set<PointerKey>> scanForRef(
     SDG sdg, PointerAnalysis pa, ModRef modRef) {
   if (pa == null) {
     throw new IllegalArgumentException("null pa");
   }
   ExtendedHeapModel h = new DelegatingExtendedHeapModel(pa.getHeapModel());
   Map<Statement, Set<PointerKey>> result = HashMapFactory.make();
   for (CGNode n : sdg.getCallGraph()) {
     IR ir = n.getIR();
     if (ir != null) {
       for (int i = 0; i < ir.getInstructions().length; i++) {
         SSAInstruction st = ir.getInstructions()[i];
         if (st != null) {
           Set<PointerKey> mod = modRef.getRef(n, h, pa, st, null);
           if (!mod.isEmpty()) {
             NormalStatement normal = new NormalStatement(n, i);
             result.put(normal, mod);
           }
         }
       }
     }
   }
   return result;
 }
コード例 #4
0
  private OrdinalSet<InstanceKey> findReachableInstances(final CGNode node, final int ssaVar) {
    final PointerAnalysis<InstanceKey> pts = sdg.getPointerAnalysis();
    final PointerKey pkStart = pts.getHeapModel().getPointerKeyForLocal(node, ssaVar);

    return findReachableInstances(pts, pkStart);
  }