public PointerParamValueNumIterator(CGNode node) throws IllegalArgumentException { if (node == null) { throw new IllegalArgumentException("node == null"); } IR ir = node.getIR(); ti = TypeInference.make(ir, false); symbolTable = ir.getSymbolTable(); numParams = symbolTable.getNumberOfParameters(); paramInd = 0; setNextParameter(); }
public PointerParamValueNumIterator(CGNode node) throws IllegalArgumentException { if (node == null) { throw new IllegalArgumentException("node == null"); } IR ir = node.getIR(); ti = TypeInference.make(ir, false); symbolTable = ir.getSymbolTable(); numParams = symbolTable.getNumberOfParameters(); paramInd = 0; setNextParameter(); }
if (ir == null) return; TypeInference ti = TypeInference.make(ir, false); final IClass type = ti.getType(lpk.getValueNumber()).getType(); if (type == null)
if (ir == null) return; TypeInference ti = TypeInference.make(ir, false); final IClass type = ti.getType(lpk.getValueNumber()).getType(); if (type == null)
/** * add nodes for parameters and return values */ private void addNodesForParameters(CGNode node) { // TODO Auto-generated method stub IR ir = node.getIR(); TypeInference ti = TypeInference.make(ir, false); SymbolTable symbolTable = ir.getSymbolTable(); for (int i = 0; i < symbolTable.getNumberOfParameters(); i++) { int parameter = symbolTable.getParameter(i); TypeAbstraction t = ti.getType(parameter); if (t != null) { PointerKey paramPk = heapModel.getPointerKeyForLocal(node, parameter); addNode(paramPk); params.put(paramPk, node); } } addNode(heapModel.getPointerKeyForReturnValue(node)); addNode(heapModel.getPointerKeyForExceptionalReturnValue(node)); }
/** * add nodes for parameters and return values */ private void addNodesForParameters(CGNode node) { // TODO Auto-generated method stub IR ir = node.getIR(); TypeInference ti = TypeInference.make(ir, false); SymbolTable symbolTable = ir.getSymbolTable(); for (int i = 0; i < symbolTable.getNumberOfParameters(); i++) { int parameter = symbolTable.getParameter(i); TypeAbstraction t = ti.getType(parameter); if (t != null) { PointerKey paramPk = heapModel.getPointerKeyForLocal(node, parameter); addNode(paramPk); params.put(paramPk, node); } } addNode(heapModel.getPointerKeyForReturnValue(node)); addNode(heapModel.getPointerKeyForExceptionalReturnValue(node)); }
return Collections.emptyMap(); TypeInference ti = TypeInference.make(ir, false);
@Test public void test3() { MethodReference method = scope.findMethod(AnalysisScope.APPLICATION, "LtypeInference/TI", Atom.findOrCreateUnicodeAtom("inferInt"), new ImmutableByteArray(UTF8Convert.toUTF8("()V"))); Assert.assertNotNull("method not found", method); IMethod imethod = cha.resolveMethod(method); Assert.assertNotNull("imethod not found", imethod); IR ir = cache.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, options.getSSAOptions()); System.out.println(ir); TypeInference ti = TypeInference.make(ir, true); TypeAbstraction type = ti.getType(7); Assert.assertNotNull("null type abstraction", type); Assert.assertTrue("inferred wrong type", type.toString().equals("int")); }
return Collections.emptyMap(); TypeInference ti = TypeInference.make(ir, false);
@Test public void test4() { MethodReference method = scope.findMethod(AnalysisScope.APPLICATION, "LtypeInference/TI", Atom.findOrCreateUnicodeAtom("useCast"), new ImmutableByteArray(UTF8Convert.toUTF8("(Ljava/lang/Object;)V"))); Assert.assertNotNull("method not found", method); IMethod imethod = cha.resolveMethod(method); Assert.assertNotNull("imethod not found", imethod); IR ir = cache.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, options.getSSAOptions()); System.out.println(ir); TypeInference ti = TypeInference.make(ir, false); TypeAbstraction type = ti.getType(4); Assert.assertNotNull("null type abstraction", type); Assert.assertTrue("inferred wrong type " + type, type instanceof ConeType && ((ConeType)type).getTypeReference().getName().toString().equals("Ljava/lang/String")); }
@Test public void test1() { MethodReference method = scope.findMethod(AnalysisScope.APPLICATION, "LtypeInference/TI", Atom.findOrCreateUnicodeAtom("foo"), new ImmutableByteArray(UTF8Convert.toUTF8("()V"))); Assert.assertNotNull("method not found", method); IMethod imethod = cha.resolveMethod(method); Assert.assertNotNull("imethod not found", imethod); IR ir = cache.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, options.getSSAOptions()); System.out.println(ir); TypeInference ti = TypeInference.make(ir, false); for (int i = 1; i <= ir.getSymbolTable().getMaxValueNumber(); i++) { System.err.println(i + " " + ti.getType(i)); } }
@Test public void test2() { MethodReference method = scope.findMethod(AnalysisScope.APPLICATION, "LtypeInference/TI", Atom.findOrCreateUnicodeAtom("bar"), new ImmutableByteArray(UTF8Convert.toUTF8("(I)V"))); Assert.assertNotNull("method not found", method); IMethod imethod = cha.resolveMethod(method); Assert.assertNotNull("imethod not found", imethod); IR ir = cache.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, options.getSSAOptions()); System.out.println(ir); TypeInference ti = TypeInference.make(ir, true); Assert.assertNotNull("null type abstraction for parameter", ti.getType(2)); }
TypeInference ti = TypeInference.make(ir, false); for (int i = 1; i <= ir.getSymbolTable().getMaxValueNumber(); i++) { TypeAbstraction t = ti.getType(i);
/** * test that type inference works in the presence of a getfield where the * field's declared type cannot be loaded */ @Test public void testBug38540() throws ClassHierarchyException, IOException { AnalysisScope scope = null; scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); AnalysisOptions options = new AnalysisOptions(); ClassHierarchy cha = ClassHierarchyFactory.make(scope); TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "Main"); IClass klass = cha.lookupClass(t); Assert.assertTrue(klass != null); ShrikeCTMethod m = (ShrikeCTMethod) klass.getMethod(new Selector(Atom.findOrCreateAsciiAtom("foo"), Descriptor .findOrCreateUTF8("()Ljava/lang/Object;"))); Assert.assertTrue(m != null); IR ir = new AnalysisCacheImpl().getSSACache().findOrCreateIR(m, Everywhere.EVERYWHERE, options.getSSAOptions()); TypeInference.make(ir, false); }