@Override public IClass getConcreteType() { return node.getClassHierarchy().lookupClass(createdType); }
@Override public IClass getConcreteType() { return node.getClassHierarchy().lookupClass(createdType); }
public ExplicitCallGraph(IMethod fakeRootMethod, AnalysisOptions options, IAnalysisCacheView cache) { super(); if (options == null) { throw new IllegalArgumentException("null options"); } if (cache == null) { throw new IllegalArgumentException("null cache"); } this.cha = fakeRootMethod.getClassHierarchy(); this.options = options; this.cache = cache; this.maxNumberOfNodes = options.getMaxNumberOfNodes(); this.fakeRootMethod = fakeRootMethod; }
public ExplicitCallGraph(IMethod fakeRootMethod, AnalysisOptions options, IAnalysisCacheView cache) { super(); if (options == null) { throw new IllegalArgumentException("null options"); } if (cache == null) { throw new IllegalArgumentException("null cache"); } this.cha = fakeRootMethod.getClassHierarchy(); this.options = options; this.cache = cache; this.maxNumberOfNodes = options.getMaxNumberOfNodes(); this.fakeRootMethod = fakeRootMethod; }
@Override public boolean recordFactoryType(CGNode node, IClass klass) { if (klass == null) { throw new IllegalArgumentException("klass is null"); } if (node == null) { throw new IllegalArgumentException("node is null"); } return recordType(node.getMethod().getClassHierarchy(), node.getContext(), klass.getReference()); }
@Override public boolean recordFactoryType(CGNode node, IClass klass) { if (klass == null) { throw new IllegalArgumentException("klass is null"); } if (node == null) { throw new IllegalArgumentException("node is null"); } return recordType(node.getMethod().getClassHierarchy(), node.getContext(), klass.getReference()); }
/** * @param options governing call graph construction options * @param pointerKeyFactory factory which embodies pointer abstraction policy */ protected PropagationCallGraphBuilder(IMethod abstractRootMethod, AnalysisOptions options, IAnalysisCacheView cache, PointerKeyFactory pointerKeyFactory) { if (abstractRootMethod == null) { throw new IllegalArgumentException("cha is null"); } if (options == null) { throw new IllegalArgumentException("options is null"); } assert cache != null; this.cha = abstractRootMethod.getClassHierarchy(); this.options = options; this.analysisCache = cache; // we need pointer keys to handle reflection assert pointerKeyFactory != null; this.pointerKeyFactory = pointerKeyFactory; callGraph = createEmptyCallGraph(abstractRootMethod, options); try { callGraph.init(); } catch (CancelException e) { if (DEBUG_GENERAL) { System.err.println("Could not initialize the call graph due to node number constraints: " + e.getMessage()); } } callGraph.setInterpreter(contextInterpreter); JAVA_LANG_OBJECT = cha.lookupClass(TypeReference.JavaLangObject); }
/** * @param options governing call graph construction options * @param pointerKeyFactory factory which embodies pointer abstraction policy */ protected PropagationCallGraphBuilder(IMethod abstractRootMethod, AnalysisOptions options, IAnalysisCacheView cache, PointerKeyFactory pointerKeyFactory) { if (abstractRootMethod == null) { throw new IllegalArgumentException("cha is null"); } if (options == null) { throw new IllegalArgumentException("options is null"); } assert cache != null; this.cha = abstractRootMethod.getClassHierarchy(); this.options = options; this.analysisCache = cache; // we need pointer keys to handle reflection assert pointerKeyFactory != null; this.pointerKeyFactory = pointerKeyFactory; callGraph = createEmptyCallGraph(abstractRootMethod, options); try { callGraph.init(); } catch (CancelException e) { if (DEBUG_GENERAL) { System.err.println("Could not initialize the call graph due to node number constraints: " + e.getMessage()); } } callGraph.setInterpreter(contextInterpreter); JAVA_LANG_OBJECT = cha.lookupClass(TypeReference.JavaLangObject); }
public static Set<IClass> getCaughtExceptionTypes(SSAGetCaughtExceptionInstruction instruction, IRView ir) { if (ir == null) { throw new IllegalArgumentException("ir is null"); } if (instruction == null) { throw new IllegalArgumentException("instruction is null"); } Iterator<TypeReference> exceptionTypes = ((ExceptionHandlerBasicBlock) ir.getControlFlowGraph().getNode( instruction.getBasicBlockNumber())).getCaughtExceptionTypes(); HashSet<IClass> types = HashSetFactory.make(10); for (TypeReference tr : Iterator2Iterable.make(exceptionTypes)) { IClass c = ir.getMethod().getClassHierarchy().lookupClass(tr); if (c != null) { types.add(c); } } return types; }
public static Set<IClass> getCaughtExceptionTypes(SSAGetCaughtExceptionInstruction instruction, IRView ir) { if (ir == null) { throw new IllegalArgumentException("ir is null"); } if (instruction == null) { throw new IllegalArgumentException("instruction is null"); } Iterator<TypeReference> exceptionTypes = ((ExceptionHandlerBasicBlock) ir.getControlFlowGraph().getNode( instruction.getBasicBlockNumber())).getCaughtExceptionTypes(); HashSet<IClass> types = HashSetFactory.make(10); for (TypeReference tr : Iterator2Iterable.make(exceptionTypes)) { IClass c = ir.getMethod().getClassHierarchy().lookupClass(tr); if (c != null) { types.add(c); } } return types; }
/** * Return the method that m overrides, or null if none */ public static IMethod getOverriden(IMethod m) { IClass c = m.getDeclaringClass(); IClass parent = c.getSuperclass(); if (parent == null) { return null; } else { MethodReference ref = MethodReference.findOrCreate(parent.getReference(), m.getSelector()); IMethod m2 = m.getClassHierarchy().resolveMethod(ref); if (m2 != null && !m2.equals(m)) { return m2; } return null; } }
/** * Return the method that m overrides, or null if none */ public static IMethod getOverriden(IMethod m) { IClass c = m.getDeclaringClass(); IClass parent = c.getSuperclass(); if (parent == null) { return null; } else { MethodReference ref = MethodReference.findOrCreate(parent.getReference(), m.getSelector()); IMethod m2 = m.getClassHierarchy().resolveMethod(ref); if (m2 != null && !m2.equals(m)) { return m2; } return null; } }
/** * find the root of the inheritance tree for method m. */ public static IMethod getRootOfInheritanceTree(IMethod m) { IClass c = m.getDeclaringClass(); IClass parent = c.getSuperclass(); if (parent == null) { return m; } else { MethodReference ref = MethodReference.findOrCreate(parent.getReference(), m.getSelector()); IMethod m2 = m.getClassHierarchy().resolveMethod(ref); if (m2 != null && !m2.equals(m)) { return getRootOfInheritanceTree(m2); } return m; } }
/** * find the root of the inheritance tree for method m. */ public static IMethod getRootOfInheritanceTree(IMethod m) { IClass c = m.getDeclaringClass(); IClass parent = c.getSuperclass(); if (parent == null) { return m; } else { MethodReference ref = MethodReference.findOrCreate(parent.getReference(), m.getSelector()); IMethod m2 = m.getClassHierarchy().resolveMethod(ref); if (m2 != null && !m2.equals(m)) { return getRootOfInheritanceTree(m2); } return m; } }
/** * Return the implicit this-pointer as a supertype. * * @param asType A type of a super-class of this */ public Parameter getThisAs(final TypeReference asType) { final int self = getThisNo(); switch (this.base) { case IMETHOD: final IClassHierarchy cha = this.method.getClassHierarchy(); try { if (! isSubclassOf(this.method.getParameterType(self), asType, cha) ) { throw new IllegalArgumentException("Class " + asType + " is not a super-class of " + this.method.getParameterType(self)); } } catch (ClassLookupException e) { // Cant't test assume all fitts } return new Parameter(self, "self", asType, ParamerterDisposition.THIS, this.base, this.method.getReference(), this.descriptorOffset); case METHOD_REFERENCE: // TODO assert asType is a subtype of self.type - we need cha to do that :( return new Parameter(self, "self", asType, ParamerterDisposition.THIS, this.base, this.mRef, this.descriptorOffset); default: throw new UnsupportedOperationException("No implementation of getThis() for base " + this.base); } }
/** * Return the implicit this-pointer as a supertype. * * @param asType A type of a super-class of this */ public Parameter getThisAs(final TypeReference asType) { final int self = getThisNo(); switch (this.base) { case IMETHOD: final IClassHierarchy cha = this.method.getClassHierarchy(); try { if (! isSubclassOf(this.method.getParameterType(self), asType, cha) ) { throw new IllegalArgumentException("Class " + asType + " is not a super-class of " + this.method.getParameterType(self)); } } catch (ClassLookupException e) { // Cant't test assume all fitts } return new Parameter(self, "self", asType, ParamerterDisposition.THIS, this.base, this.method.getReference(), this.descriptorOffset); case METHOD_REFERENCE: // TODO assert asType is a subtype of self.type - we need cha to do that :( return new Parameter(self, "self", asType, ParamerterDisposition.THIS, this.base, this.mRef, this.descriptorOffset); default: throw new UnsupportedOperationException("No implementation of getThis() for base " + this.base); } }
IClass ct = m.getClassHierarchy().lookupClass(m.getParameterType(i)); isAppClazz = ct == null || WalaUtils.isAppClass(ct); sb.append(isAppClazz? customTypeReplacement : m.getParameterType(i).getName().toString()); IClass ct = m.getClassHierarchy().lookupClass(m.getReturnType()); sb.append(ct == null || WalaUtils.isAppClass(ct)? customTypeReplacement : m.getReturnType().getName().toString()); } else
@Override public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) { IMethod resolved = caller.getMethod().getClassHierarchy().resolveMethod(site.getDeclaredTarget()); if (isClassFactory(resolved != null? resolved.getReference(): site.getDeclaredTarget())) { SSAAbstractInvokeInstruction[] invokeInstructions = caller.getIR().getCalls(site); if (invokeInstructions.length >= 1) { if (invokeInstructions[0].isStatic()) { return thisParameter; } else { return firstParameter; } } else { return EmptyIntSet.instance; } } else { return EmptyIntSet.instance; } } }
@Override public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) { IMethod resolved = caller.getMethod().getClassHierarchy().resolveMethod(site.getDeclaredTarget()); if (isClassFactory(resolved != null? resolved.getReference(): site.getDeclaredTarget())) { SSAAbstractInvokeInstruction[] invokeInstructions = caller.getIR().getCalls(site); if (invokeInstructions.length >= 1) { if (invokeInstructions[0].isStatic()) { return thisParameter; } else { return firstParameter; } } else { return EmptyIntSet.instance; } } else { return EmptyIntSet.instance; } } }
IClass clazz = node.getMethod().getClassHierarchy().lookupClass(typeRef); if (null == clazz) {