Skip to content

Commit

Permalink
Merge pull request #837 from soot-oss/allow-other-views-in-analysis
Browse files Browse the repository at this point in the history
open up parameter type
  • Loading branch information
kadirayk authored Feb 2, 2024
2 parents a64e314 + cea54ea commit 0e7e27d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
public class ICFGDotExporter {

public static String buildICFGGraph(
Map<MethodSignature, StmtGraph> signatureToStmtGraph, View view, CallGraph callGraph) {
Map<MethodSignature, StmtGraph<?>> signatureToStmtGraph, View view, CallGraph callGraph) {
final StringBuilder sb = new StringBuilder();
DotExporter.buildDiGraphObject(sb);
Map<Integer, MethodSignature> calls;
calls = computeCalls(signatureToStmtGraph, view, callGraph);
for (Map.Entry<MethodSignature, StmtGraph> entry : signatureToStmtGraph.entrySet()) {
for (Map.Entry<MethodSignature, StmtGraph<?>> entry : signatureToStmtGraph.entrySet()) {
String graph = DotExporter.buildGraph(entry.getValue(), true, calls, entry.getKey());
sb.append(graph + "\n");
sb.append(graph).append("\n");
}
sb.append("}");
return sb.toString();
Expand All @@ -58,10 +58,10 @@ public static String buildICFGGraph(
* methods.
*/
public static Map<Integer, MethodSignature> computeCalls(
Map<MethodSignature, StmtGraph> stmtGraphSet, View view, CallGraph callgraph) {
Map<MethodSignature, StmtGraph<?>> stmtGraphSet, View view, CallGraph callgraph) {
Map<Integer, MethodSignature> calls = new HashMap<>();
for (Map.Entry<MethodSignature, StmtGraph> entry : stmtGraphSet.entrySet()) {
StmtGraph stmtGraph = entry.getValue();
for (Map.Entry<MethodSignature, StmtGraph<?>> entry : stmtGraphSet.entrySet()) {
StmtGraph<?> stmtGraph = entry.getValue();
MethodSignature source = entry.getKey();
Collection<? extends BasicBlock<?>> blocks;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import sootup.core.model.SootMethod;
import sootup.core.signatures.MethodSignature;
import sootup.core.views.View;
import sootup.java.core.views.JavaView;

/**
* Default implementation for the {@link InterproceduralCFG} interface. Includes all statements
Expand Down Expand Up @@ -136,7 +135,7 @@ private Stmt filterEdgeAndGetCallerStmt(@Nonnull MethodSignature methodSignature
IDESolver.DEFAULT_CACHE_BUILDER.build(loaderMethodToCallers);

public JimpleBasedInterproceduralCFG(
JavaView view,
View view,
MethodSignature mainMethodSignature,
boolean enableExceptions,
boolean includeReflectiveCalls) {
Expand All @@ -149,22 +148,22 @@ public JimpleBasedInterproceduralCFG(
}

public String buildICFGGraph(CallGraph callGraph) {
Map<MethodSignature, StmtGraph> signatureToStmtGraph = new LinkedHashMap<>();
Map<MethodSignature, StmtGraph<?>> signatureToStmtGraph = new LinkedHashMap<>();
computeAllCalls(mainMethodSignature, signatureToStmtGraph, callGraph);
return ICFGDotExporter.buildICFGGraph(signatureToStmtGraph, view, callGraph);
}

public void computeAllCalls(
MethodSignature methodSignature,
Map<MethodSignature, StmtGraph> signatureToStmtGraph,
Map<MethodSignature, StmtGraph<?>> signatureToStmtGraph,
CallGraph callGraph) {
ArrayList<MethodSignature> visitedMethods = new ArrayList<>();
computeAllCalls(methodSignature, signatureToStmtGraph, callGraph, visitedMethods);
}

private void computeAllCalls(
MethodSignature methodSignature,
Map<MethodSignature, StmtGraph> signatureToStmtGraph,
Map<MethodSignature, StmtGraph<?>> signatureToStmtGraph,
CallGraph callGraph,
List<MethodSignature> visitedMethods) {
visitedMethods.add(methodSignature);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void ICFGInterfaceDotExport() {
/** Compute the Edges of the given methodSignature from the provided callGraph */
public String edgesFromCallGraph(
MethodSignature methodSignature, JimpleBasedInterproceduralCFG icfg, CallGraph callGraph) {
Map<MethodSignature, StmtGraph> signatureToStmtGraph = new LinkedHashMap<>();
Map<MethodSignature, StmtGraph<?>> signatureToStmtGraph = new LinkedHashMap<>();
icfg.computeAllCalls(methodSignature, signatureToStmtGraph, callGraph);
Map<Integer, MethodSignature> calls;
calls = ICFGDotExporter.computeCalls(signatureToStmtGraph, view, callGraph);
Expand Down

0 comments on commit 0e7e27d

Please sign in to comment.