MCPcopy Create free account
hub / github.com/LFYSec/MScan / ResultProcessor

Class ResultProcessor

src/main/java/pascal/taie/analysis/misc/ResultProcessor.java:60–345  ·  view source on GitHub ↗

Special class for process the results of other analyses after they finish. This class is designed mainly for testing purpose. Currently, it supports input/output analysis results from/to file, and compare analysis results with input results. This analysis should be specified as the last analysis.

Source from the content-addressed store, hash-verified

58 * with input results. This analysis should be specified as the last analysis.
59 */
60public class ResultProcessor extends ProgramAnalysis<Set<String>> {
61
62 public static final String ID = "process-result";
63
64 private static final Logger logger = LogManager.getLogger(ResultProcessor.class);
65
66 private final boolean onlyApp;
67
68 private final String action;
69
70 private PrintStream out;
71
72 private Map<Pair<String, String>, List<String>> inputs;
73
74 private Set<String> mismatches;
75
76 public ResultProcessor(AnalysisConfig config) {
77 super(config);
78 onlyApp = getOptions().getBoolean("only-app");
79 action = getOptions().getString("action");
80 }
81
82 @Override
83 public Set<String> analyze() {
84 // initialization
85 switch (action) {
86 case "dump" -> setOutput();
87 case "compare" -> readInputs();
88 }
89 mismatches = Sets.newLinkedSet();
90 // Classify given analysis IDs into two groups,
91 // one for ProgramAnalysis if present in the World,
92 // and another for Class/MethodAnalysis otherwise.
93 @SuppressWarnings("unchecked")
94 List<String> analyses = (List<String>) getOptions().get("analyses");
95 Map<Boolean, List<String>> groups = analyses.stream()
96 .collect(Collectors.groupingBy(World.get()::hasResult));
97 List<String> programAnalyses = groups.get(true);
98 if (programAnalyses != null) {
99 processProgramAnalysisResult(programAnalyses);
100 }
101 List<String> classMethodAnalyses = groups.get(false);
102 if (classMethodAnalyses != null) {
103 processClassMethodAnalysisResult(classMethodAnalyses);
104 }
105 if (getOptions().getBoolean("log-mismatches")) {
106 mismatches.forEach(logger::info);
107 }
108 // close out stream
109 if (action.equals("dump") && out != System.out) {
110 out.close();
111 }
112 return mismatches;
113 }
114
115 private void setOutput() {
116 String output = getOptions().getString("action-file");
117 if (output != null) {

Callers

nothing calls this directly

Calls 7

getLineNumberMethod · 0.65
getStmtMethod · 0.65
getIRMethod · 0.65
toStringMethod · 0.65
equalsMethod · 0.45
getDeclaringClassMethod · 0.45
compareToMethod · 0.45

Tested by

no test coverage detected