@Override public IClassHierarchy getClassHierarchy() { return cg.getClassHierarchy(); }
@Override public IClassHierarchy getClassHierarchy() { return cg.getClassHierarchy(); }
@Override public IClassHierarchy getClassHierarchy() { return cg.getClassHierarchy(); }
public SimpleMemoryAccessMap(CallGraph cg, HeapModel heapModel, boolean includePrimOps) { if (cg == null) { throw new IllegalArgumentException("null cg"); } this.cha = cg.getClassHierarchy(); this.heapModel = heapModel; this.includePrimOps = includePrimOps; populate(cg); }
@Override public IClassHierarchy getClassHierarchy() { return getCallGraph().getClassHierarchy(); } }
/** * @param klasses Collection<IClass> * @throws IllegalArgumentException if cg is null */ public TypeBasedHeapModel(AnalysisOptions options, Collection<IClass> klasses, CallGraph cg) { if (cg == null) { throw new IllegalArgumentException("cg is null"); } iKeyFactory = new ClassBasedInstanceKeys(options, cg.getClassHierarchy()); this.klasses = klasses; this.cg = cg; }
public SimpleMemoryAccessMap(CallGraph cg, HeapModel heapModel, boolean includePrimOps) { if (cg == null) { throw new IllegalArgumentException("null cg"); } this.cha = cg.getClassHierarchy(); this.heapModel = heapModel; this.includePrimOps = includePrimOps; populate(cg); }
@Override public IClassHierarchy getClassHierarchy() { return getCallGraph().getClassHierarchy(); } }
/** * @param klasses Collection<IClass> * @throws IllegalArgumentException if cg is null */ public TypeBasedHeapModel(AnalysisOptions options, Collection<IClass> klasses, CallGraph cg) { if (cg == null) { throw new IllegalArgumentException("cg is null"); } iKeyFactory = new ClassBasedInstanceKeys(options, cg.getClassHierarchy()); this.klasses = klasses; this.cg = cg; }
public static CGNode getCGNode(String methodSignature, CallGraph cg) { logger.debug("Retrieve CGNode for " + methodSignature); IMethod refMethod = getIMethod(cg.getClassHierarchy(), methodSignature); if (refMethod == null) return null; return getCGNode(refMethod, cg); }
public ContextSensitiveReachingDefs(CallGraph cg) { this.cha = cg.getClassHierarchy(); // we use an ICFGSupergraph, which basically adapts ExplodedInterproceduralCFG to the ISupergraph interface this.supergraph = ICFGSupergraph.make(cg); }
public StaticInitializer(CallGraph cg) { cha = cg.getClassHierarchy(); supergraph = ICFGSupergraph.make(cg); }
@Test public void testInnerClass() throws IllegalArgumentException, CancelException, IOException { runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), Collections.singletonList( cg -> { final String typeStr = singleInputForTest(); final TypeReference type = findOrCreateTypeReference("Source", typeStr + "$WhatsIt", cg.getClassHierarchy()); final IClass iClass = cg.getClassHierarchy().lookupClass(type); Assert.assertNotNull("Could not find class " + typeStr, iClass); Assert.assertEquals("Expected to be enclosed in 'InnerClass'.", ((JavaSourceLoaderImpl.JavaClass) iClass) .getEnclosingClass(), // todo is there another way? cg.getClassHierarchy().lookupClass(findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy()))); }), true, null); }
private static IR getIR(CallGraph cg, String fullyQualifiedTypeName, String methodName, String methodParameter, String methodReturnType) { IClassHierarchy classHierarchy = cg.getClassHierarchy(); MethodReference methodRef = IRTests .descriptorToMethodRef( String.format("Source#%s#%s#(%s)%s", fullyQualifiedTypeName, methodName, methodParameter, methodReturnType), classHierarchy); IMethod method = classHierarchy.resolveMethod(methodRef); CGNode node = cg.getNode(method, Everywhere.EVERYWHERE); return node.getIR(); }
@Test public void testAnonymousClass() throws IllegalArgumentException, CancelException, IOException { runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), Collections.singletonList( cg -> { final String typeStr = singleInputForTest(); final TypeReference type = findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy()); final IClass iClass = cg.getClassHierarchy().lookupClass(type); Assert.assertNotNull("Could not find class " + typeStr, iClass); // todo what to check?? could not find anything in the APIs for // anonymous }), true, null); }
@Override public void check(CallGraph cg) { MethodReference mref = descriptorToMethodRef("Source#Array1#foo#()V", cg.getClassHierarchy()); int count = 0; CGNode node = cg.getNodes(mref).iterator().next(); for (SSAInstruction s : node.getIR().getInstructions()) { if (isArrayInstruction(s)) { count++; } } Assert.assertEquals("Unexpected number of array instructions in 'foo'.", count, 4); }
@Test public void testArrayLiteral1() throws IllegalArgumentException, CancelException, IOException { runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), Collections.singletonList( cg -> { MethodReference mref = descriptorToMethodRef("Source#ArrayLiteral1#main#([Ljava/lang/String;)V", cg.getClassHierarchy()); CGNode node = cg.getNodes(mref).iterator().next(); SSAInstruction s = node.getIR().getInstructions()[2]; Assert.assertTrue("Did not find new array instruction.", s instanceof SSANewInstruction); Assert.assertTrue("", ((SSANewInstruction) s).getNewSite().getDeclaredType().isArrayType()); }), true, null); }
@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())); } }
@Test public void testExclusions() throws IllegalArgumentException, CancelException, IOException { File exclusions = TemporaryFile.stringToFile(File.createTempFile("exl", "txt"), "Exclusions.Excluded\n"); Pair<CallGraph, PointerAnalysis<? extends InstanceKey>> x = runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, exclusions.getAbsolutePath()); IClassHierarchy cha = x.fst.getClassHierarchy(); TypeReference topType = TypeReference.findOrCreate(JavaSourceAnalysisScope.SOURCE, TypeName.findOrCreate("LExclusions")); assert cha.lookupClass(topType) != null; TypeReference inclType = TypeReference.findOrCreate(JavaSourceAnalysisScope.SOURCE, TypeName.findOrCreate("LExclusions$Included")); assert cha.lookupClass(inclType) != null; TypeReference exclType = TypeReference.findOrCreate(JavaSourceAnalysisScope.SOURCE, TypeName.findOrCreate("LExclusions$Excluded")); assert cha.lookupClass(exclType) == null; } }
@Test public void testQualifiedStatic() throws IllegalArgumentException, CancelException, IOException { runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), Collections.singletonList( cg -> { MethodReference mref = descriptorToMethodRef("Source#QualifiedStatic#main#([Ljava/lang/String;)V", cg.getClassHierarchy()); CGNode node = cg.getNodes(mref).iterator().next(); SSAInstruction s = node.getIR().getInstructions()[4]; Assert.assertTrue("Did not find a getstatic instruction.", s instanceof SSAGetInstruction && ((SSAGetInstruction) s).isStatic()); final FieldReference field = ((SSAGetInstruction) s).getDeclaredField(); Assert.assertEquals("Expected a getstatic for 'value'.", field.getName().toString(), "value"); Assert.assertEquals("Expected a getstatic for 'value'.", field.getDeclaringClass().getName().toString(), "LFooQ"); }), true, null); }