@Override public boolean understands(CGNode node) { if(node.getMethod() instanceof DexIMethod) return true; return false; }
private RTAContextInterpreter getNodeInterpreter(CGNode node) { if (node.getMethod() instanceof FakeRootMethod) { FakeRootMethod f = (FakeRootMethod) node.getMethod(); return f.getInterpreter(); } else { if (DEBUG) { System.err.println(("providing context insensitive interpreter for node " + node)); } return defaultInterpreter; } }
private Position getInstructionPosition(SSAInstruction instruction) { IMethod method = node.getMethod(); if (method instanceof AstMethod) { return ((AstMethod) method).getSourcePosition(instruction.iindex); } return null; }
@Override public Iterator<NewSiteReference> iterateNewSites(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } try { return CodeScanner.getNewSites(node.getMethod()).iterator(); } catch (InvalidClassFileException e) { throw new RuntimeException(e); } }
@Override public boolean understands(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } if (!(node.getContext().isA(JavaTypeContext.class))) { return false; } return node.getMethod().getReference().equals(GetClassContextSelector.GET_CLASS); }
@Override protected boolean sameMethod(CGNode opNode, String definingMethod) { return definingMethod.equals(opNode.getMethod().getReference().getDeclaringClass().getName().toString()); } }
@Override public boolean understands(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } if (!(node.getContext().isA(JavaTypeContext.class))) { return false; } return ClassFactoryContextSelector.isClassFactory(node.getMethod().getReference()); }
public static boolean hasExposedUses(CGNode caller, CallSiteReference site) { int uses[] = ((AstMethod) caller.getMethod()).lexicalInfo().getExposedUses(site.getProgramCounter()); if (uses != null && uses.length > 0) { for (int use : uses) { if (use > 0) { return true; } } } return false; } }
protected CallString getCallString(CGNode caller, CallSiteReference site, IMethod target) { int length = getLength(caller, site, target); if (length > 0) { if (caller.getContext().get(CALL_STRING) != null) { return new CallString(site, caller.getMethod(), length, (CallString) caller.getContext().get(CALL_STRING)); } else { return new CallString(site, caller.getMethod()); } } else { return null; } }
@Override public PointerKey getPointerKeyForLocal(CGNode node, int valueNumber) { if (!node.getMethod().isStatic() && valueNumber == 1) { return delegate.getFilteredPointerKeyForLocal(node, valueNumber, getFilter(node)); } else { return delegate.getPointerKeyForLocal(node, valueNumber); } }
public static boolean fromLoader(CGNode node, ClassLoaderReference clr) { IClass declClass = node.getMethod().getDeclaringClass(); ClassLoaderReference nodeClRef = declClass.getClassLoader().getReference(); return nodeClRef.equals(clr); }
@Override public boolean hasNoInterestingUses(CGNode node, int vn, DefUse du) { if (node.getMethod() instanceof AstMethod) { // uses in nested functions are interesting IntSet uses = ((AstIRFactory.AstIR) node.getIR()).lexicalInfo().getAllExposedUses(); if (uses.contains(vn)) { return false; } } return super.hasNoInterestingUses(node, vn, du); }
private final static CGNode findNode(CallGraph cg, String methodName) { for (CGNode n : cg) { if (n.getMethod().getName().toString().equals(methodName)) { return n; } } Assertions.UNREACHABLE("Unexpected: failed to find " + methodName + " node"); return null; }
private final static CGNode findDoNothingNode(CallGraph cg) { for (CGNode n : cg) { if (n.getMethod().getName().toString().equals("doNothing")) { return n; } } Assertions.UNREACHABLE("Unexpected: failed to find doNothing node"); return null; } }
public static CGNode findStaticMethod(CallGraph cg, Atom name, Descriptor args) { for (CGNode n : cg) { // System.err.println(n.getMethod().getName() + " " + // n.getMethod().getDescriptor()); if (n.getMethod().getName().equals(name) && n.getMethod().getDescriptor().equals(args)) { return n; } } Assertions.UNREACHABLE("failed to find method"); return null; }
public static CGNode findMethod(CallGraph cg, String name) { Atom a = Atom.findOrCreateUnicodeAtom(name); for (CGNode n : cg) { if (n.getMethod().getName().equals(a)) { return n; } } System.err.println("call graph " + cg); Assertions.UNREACHABLE("failed to find method " + name); return null; }
@Override protected void customInit() { super.customInit(); FakeRootMethod m = (FakeRootMethod) getCallGraph().getFakeRootNode().getMethod(); for (TypeReference element : PRE_ALLOC) { SSANewInstruction n = m.addAllocation(element); // visit now to ensure java.lang.Object is visited first visitNew(getCallGraph().getFakeRootNode(), n.getNewSite()); } }
@Test public void testIntra() { for (CGNode node : cg) { IntraproceduralExceptionAnalysis analysis = new IntraproceduralExceptionAnalysis(node, filter.getFilter(node), cha, pointerAnalysis); if (node.getMethod().getDeclaringClass().getName().getClassName().toString().equals("TestPruning")) { checkThrownExceptions(node, analysis); checkCaughtExceptions(node, analysis); } } }
@Override public void check(CallGraph cg) { MethodReference mref = descriptorToMethodRef(method, cg.getClassHierarchy()); for (CGNode cgNode : cg.getNodes(mref)) { Assert.assertTrue("failed for " + this.variableName + " in " + cgNode + "\n" + cgNode.getIR(), this.check(cgNode.getMethod(), cgNode.getIR())); } }