/** * @throws NullPointerException if instances is null */ public static <T> Collection<T> toCollection(OrdinalSet<T> instances) { return Iterator2Collection.toSet(instances.iterator()); }
/** * @throws NullPointerException if instances is null */ public static <T> Collection<T> toCollection(OrdinalSet<T> instances) { return Iterator2Collection.toSet(instances.iterator()); }
/** * @throws NullPointerException if instances is null */ public static <T> Collection<T> toCollection(OrdinalSet<T> instances) { return Iterator2Collection.toSet(instances.iterator()); }
@Override public String toString() { return Iterator2Collection.toSet(iterator()).toString(); }
@Override public String toString() { return Iterator2Collection.toSet(iterator()).toString(); }
@Override public String toString() { return Iterator2Collection.toSet(iterator()).toString(); }
/** * get a points-to set that has already been computed via some previous call to {@link #compute()}; does _not_ do any fresh * demand-driven computation. */ public Collection<InstanceKeyAndState> getComputedP2Set(PointerKeyAndState queried) { return Iterator2Collection.toSet(makeOrdinalSet(find(pkToP2Set, queried)).iterator()); // return Iterator2Collection.toSet(new MapIterator<InstanceKeyAndState, InstanceKey>(makeOrdinalSet( // find(pkToP2Set, new PointerKeyAndState(lpk, stateMachine.getStartState()))).iterator(), // new Function<InstanceKeyAndState, InstanceKey>() { // // public InstanceKey apply(InstanceKeyAndState object) { // return object.getInstanceKey(); // } // // })); }
/** * get a points-to set that has already been computed via some previous call to {@link #compute()}; does _not_ do any fresh * demand-driven computation. */ public Collection<InstanceKeyAndState> getComputedP2Set(PointerKeyAndState queried) { return Iterator2Collection.toSet(makeOrdinalSet(find(pkToP2Set, queried)).iterator()); // return Iterator2Collection.toSet(new MapIterator<InstanceKeyAndState, InstanceKey>(makeOrdinalSet( // find(pkToP2Set, new PointerKeyAndState(lpk, stateMachine.getStartState()))).iterator(), // new Function<InstanceKeyAndState, InstanceKey>() { // // public InstanceKey apply(InstanceKeyAndState object) { // return object.getInstanceKey(); // } // // })); }
private static Set<Pair<CGNode, NewSiteReference>> getPropPrototypes(final PointerAnalysis<InstanceKey> fbPA, CallGraph CG, CGNode node, int vn) { return getPrototypeSites(fbPA, CG, o -> fbPA.getPointsToSet(new TransitivePrototypeKey(o)).iterator(), node, vn); }
private void handleUriParse(final NormalAllocationInNode ik, final PointerAnalysis<InstanceKey> pa, final OrdinalSetMapping<InstanceKey> mapping, final Map<InstanceKeySite, Set<InstanceKey>> unresolvedDependencies) { final CGNode allocNode = ik.getNode(); final Context context = allocNode.getContext(); final CGNode caller = (CGNode) context.get(ContextKey.CALLER); if (hasSignature(allocNode, "android.net.Uri.parse(Ljava/lang/String;)Landroid/net/Uri;")) { final CallSiteReference csr = (CallSiteReference) context.get(ContextKey.CALLSITE); final SSAInvokeInstruction invoke = (SSAInvokeInstruction) caller.getIR().getBasicBlocksForCall(csr)[0].getLastInstruction(); final OrdinalSet<InstanceKey> points = pa.getPointsToSet(new LocalPointerKey(caller, invoke.getUse(0))); if (!points.isEmpty()) { final InstanceKey stringKey = points.iterator().next(); final UriParseString node = new UriParseString( mapping.getMappedIndex(ik), mapping.getMappedIndex(stringKey)); addNode(node); nodeMap.put(ik, node); final Set<InstanceKey> iks = Collections.singleton(stringKey); unresolvedDependencies.put(node, iks); } } }
@Test public void testZeroLengthArray() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS); ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.ZERO_LENGTH_ARRAY_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); CallGraphBuilder<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis(); // System.err.println(pa); HeapModel heapModel = pa.getHeapModel(); CGNode mainNode = cg.getNode( cha.resolveMethod(MethodReference.findOrCreate( TypeReference.findOrCreate(ClassLoaderReference.Application, TestConstants.ZERO_LENGTH_ARRAY_MAIN), Selector.make("main([Ljava/lang/String;)V"))), Everywhere.EVERYWHERE); OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(heapModel.getPointerKeyForLocal(mainNode, 4)); Assert.assertEquals(1, pointsToSet.size()); InstanceKey arrayKey = pointsToSet.iterator().next(); OrdinalSet<InstanceKey> arrayContents = pa.getPointsToSet(heapModel.getPointerKeyForArrayContents(arrayKey)); System.err.println(arrayContents); Assert.assertEquals(0, arrayContents.size()); } }