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

Method shiftCG

src/main/java/pascal/taie/config/AnalysisPlanner.java:172–205  ·  view source on GitHub ↗

Shifts call graph builder (cg) in given sequence to ensure that it will run before all the analyses that it does not require.

(List<AnalysisConfig> analyses)

Source from the content-addressed store, hash-verified

170 * it will run before all the analyses that it does not require.
171 */
172 private List<AnalysisConfig> shiftCG(List<AnalysisConfig> analyses) {
173 AnalysisConfig cg = CollectionUtils.findFirst(analyses,
174 AnalysisPlanner::isCG);
175 Set<AnalysisConfig> required = manager.getAllRequiredConfigs(cg);
176 List<AnalysisConfig> notRequired = new ArrayList<>();
177 // obtain the analyses that run before cg but not required by cg
178 for (AnalysisConfig c : analyses) {
179 if (c.equals(cg)) {
180 break;
181 }
182 if (!required.contains(c)) {
183 notRequired.add(c);
184 }
185 }
186 List<AnalysisConfig> result = new ArrayList<>(analyses.size());
187 // add analyses that are required by cg
188 for (AnalysisConfig c : analyses) {
189 if (required.contains(c)) {
190 result.add(c);
191 }
192 if (c.equals(cg)) { // found cg, break
193 break;
194 }
195 }
196 result.add(cg); // add cg
197 // add analyses that are not required by cg but placed before cg
198 // in the original sequence
199 result.addAll(notRequired);
200 // add remaining analyses
201 for (int i = analyses.indexOf(cg) + 1; i < analyses.size(); ++i) {
202 result.add(analyses.get(i));
203 }
204 return result;
205 }
206
207 /**
208 * Builds a dependence graph for AnalysisConfigs.

Callers 1

expandPlanMethod · 0.95

Calls 8

findFirstMethod · 0.95
getAllRequiredConfigsMethod · 0.80
containsMethod · 0.65
addMethod · 0.65
sizeMethod · 0.65
addAllMethod · 0.65
getMethod · 0.65
equalsMethod · 0.45

Tested by

no test coverage detected