Skip to content

Commit

Permalink
not throwing an error if not necessary when nothing was added to the …
Browse files Browse the repository at this point in the history
…CallGraph
  • Loading branch information
swissiety committed Dec 21, 2023
1 parent 011a239 commit 54191f1
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,17 +313,21 @@ protected abstract void postProcessingMethod(
@Nonnull
@Override
public CallGraph addClass(@Nonnull CallGraph oldCallGraph, @Nonnull JavaClassType classType) {
MutableCallGraph updated = oldCallGraph.copy();

SootClass<?> clazz = view.getClassOrThrow(classType);
Set<MethodSignature> newMethodSignatures =
clazz.getMethods().stream().map(Method::getSignature).collect(Collectors.toSet());
clazz.getMethods().stream()
.map(Method::getSignature)
.filter(methodSig -> !oldCallGraph.containsMethod(methodSig))
.collect(Collectors.toSet());

if (newMethodSignatures.stream().anyMatch(oldCallGraph::containsMethod)) {
// FIXME: [ms] handle better - remove from entry point signatures in this case
throw new IllegalArgumentException("CallGraph already contains methods from " + classType);
// were all the added method signatures already visited in the CallGraph? i.e. is there
// something to add?
if (newMethodSignatures.isEmpty()) {
return oldCallGraph;

Check warning on line 326 in sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java

View check run for this annotation

Codecov / codecov/patch

sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java#L326

Added line #L326 was not covered by tests
}

MutableCallGraph updated = oldCallGraph.copy();

// Step 1: Add edges from the new methods to other methods
Deque<MethodSignature> workList = new ArrayDeque<>(newMethodSignatures);
Set<MethodSignature> processed = new HashSet<>(oldCallGraph.getMethodSignatures());
Expand Down

0 comments on commit 54191f1

Please sign in to comment.