diff --git a/src/main/java/pascal/taie/analysis/graph/callgraph/CHABuilder.java b/src/main/java/pascal/taie/analysis/graph/callgraph/CHABuilder.java index cfcbca77a..6c021b644 100644 --- a/src/main/java/pascal/taie/analysis/graph/callgraph/CHABuilder.java +++ b/src/main/java/pascal/taie/analysis/graph/callgraph/CHABuilder.java @@ -70,17 +70,18 @@ private CallGraph buildCallGraph(JMethod entry) { workList.add(entry); while (!workList.isEmpty()) { JMethod method = workList.poll(); - callGraph.addReachableMethod(method); - callGraph.callSitesIn(method).forEach(invoke -> { - Set callees = resolveCalleesOf(invoke); - callees.forEach(callee -> { - if (!callGraph.contains(callee)) { - workList.add(callee); - } - callGraph.addEdge(new Edge<>( - CallGraphs.getCallKind(invoke), invoke, callee)); + if (callGraph.addReachableMethod(method)) { + callGraph.callSitesIn(method).forEach(invoke -> { + Set callees = resolveCalleesOf(invoke); + callees.forEach(callee -> { + if (!callGraph.contains(callee)) { + workList.add(callee); + } + callGraph.addEdge(new Edge<>( + CallGraphs.getCallKind(invoke), invoke, callee)); + }); }); - }); + } } return callGraph; }