Skip to content

Commit a206059

Browse files
committed
restored a fix that got lost during a PR merge
1 parent d82a025 commit a206059

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

soot-infoflow/src/soot/jimple/infoflow/Infoflow.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import soot.MethodOrMethodContext;
2929
import soot.PackManager;
3030
import soot.PatchingChain;
31+
import soot.PointsToAnalysis;
3132
import soot.Scene;
3233
import soot.SootMethod;
3334
import soot.Unit;
@@ -98,6 +99,7 @@
9899
import soot.jimple.infoflow.util.SootMethodRepresentationParser;
99100
import soot.jimple.infoflow.util.SystemClassHandler;
100101
import soot.jimple.toolkits.callgraph.ReachableMethods;
102+
import soot.jimple.toolkits.pointer.DumbPointerAnalysis;
101103
import soot.options.Options;
102104

103105
/**
@@ -1095,6 +1097,10 @@ protected void eliminateDeadCode(ISourceSinkManager sourcesSinks) {
10951097
icfgFactory.buildBiDirICFG(config.getCallgraphAlgorithm(), config.getEnableExceptionTracking()), null,
10961098
null, null, new AccessPathFactory(config), null);
10971099

1100+
// Dead code elimination may drop the points-to analysis. We need to restore it.
1101+
final Scene scene = Scene.v();
1102+
PointsToAnalysis pta = scene.getPointsToAnalysis();
1103+
10981104
// We need to exclude the dummy main method and all other artificial methods
10991105
// that the entry point creator may have generated as well
11001106
Set<SootMethod> excludedMethods = new HashSet<>();
@@ -1105,6 +1111,16 @@ protected void eliminateDeadCode(ISourceSinkManager sourcesSinks) {
11051111
ICodeOptimizer dce = new DeadCodeEliminator();
11061112
dce.initialize(config);
11071113
dce.run(dceManager, excludedMethods, sourcesSinks, taintWrapper);
1114+
1115+
// Restore the points-to analysis. This may restore a PAG that contains outdated
1116+
// methods, but it's still better than running the entire callgraph algorithm
1117+
// again. Continuing with the DumbPointerAnalysis is not a viable solution
1118+
// either, since it heavily over-approximates.
1119+
if (pta != null && !(pta instanceof DumbPointerAnalysis)) {
1120+
PointsToAnalysis newPta = scene.getPointsToAnalysis();
1121+
if (newPta == null || newPta instanceof DumbPointerAnalysis)
1122+
scene.setPointsToAnalysis(pta);
1123+
}
11081124
}
11091125

11101126
protected Collection<SootMethod> getMethodsForSeeds(IInfoflowCFG icfg) {

0 commit comments

Comments
 (0)