private boolean visitedAllParents(ExplodedGraph.Edge edge) { return edge.parent.edges().stream().allMatch(visited::contains); }
private boolean visitedAllParents(ExplodedGraph.Edge edge) { return edge.parent.edges().stream().allMatch(visited::contains); }
private Set<Flow> run(final ExplodedGraph.Node node, PSet<Symbol> trackedSymbols) { Set<Flow> flows = new HashSet<>(); Deque<ExecutionPath> workList = new ArrayDeque<>(); SameConstraints sameConstraints = new SameConstraints(node, trackedSymbols, domains); node.edges().stream().flatMap(e -> startPath(e, trackedSymbols, sameConstraints)).forEach(workList::push); int flowSteps = 0; Set<ExecutionPath> visited = new HashSet<>(workList); while (!workList.isEmpty()) { ExecutionPath path = workList.pop(); if (path.finished) { flows.add(path.flow); } else { path.lastEdge.parent.edges().stream() .filter(path::notVisited) .flatMap(path::addEdge) .forEach(ep -> { if(visited.add(ep)) { workList.push(ep); } }); } flowSteps++; if(flowSteps == MAX_FLOW_STEPS) { LOG.debug("Flow was not able to complete"); break; } } return flows; }
private Set<Flow> run(final ExplodedGraph.Node node, PSet<Symbol> trackedSymbols) { Set<Flow> flows = new HashSet<>(); Deque<ExecutionPath> workList = new ArrayDeque<>(); SameConstraints sameConstraints = new SameConstraints(node, trackedSymbols, domains); node.edges().stream().flatMap(e -> startPath(e, trackedSymbols, sameConstraints)).forEach(workList::push); int flowSteps = 0; Set<ExecutionPath> visited = new HashSet<>(workList); while (!workList.isEmpty()) { ExecutionPath path = workList.pop(); if (path.finished) { flows.add(path.flow); } else { path.lastEdge.parent.edges().stream() .filter(path::notVisited) .flatMap(path::addEdge) .forEach(ep -> { if(visited.add(ep)) { workList.push(ep); } }); } flowSteps++; if(flowSteps == MAX_FLOW_STEPS) { LOG.debug("Flow was not able to complete"); break; } } return flows; }
private Flow flowForNullableMethodParameters(ExplodedGraph.Node node) { if (!node.edges().isEmpty() || !domains.contains(ObjectConstraint.class)) { return Flow.empty(); } Flow.Builder flowBuilder = Flow.builder(); trackedSymbols.forEach(symbol -> { SymbolicValue sv = node.programState.getValue(symbol); if (sv == null) { return; } ObjectConstraint startConstraint = node.programState.getConstraint(sv, ObjectConstraint.class); if (startConstraint != null && isMethodParameter(symbol)) { String msg = IMPLIES_CAN_BE_MSG; if (ObjectConstraint.NOT_NULL == startConstraint) { msg = "Implies '%s' can not be %s."; } flowBuilder.add(new JavaFileScannerContext.Location(String.format(msg, symbol.name(), "null"), ((VariableTree) symbol.declaration()).simpleName())); } }); return flowBuilder.build(); }
private Flow flowForNullableMethodParameters(ExplodedGraph.Node node) { if (!node.edges().isEmpty() || !domains.contains(ObjectConstraint.class)) { return Flow.empty(); } Flow.Builder flowBuilder = Flow.builder(); trackedSymbols.forEach(symbol -> { SymbolicValue sv = node.programState.getValue(symbol); if (sv == null) { return; } ObjectConstraint startConstraint = node.programState.getConstraint(sv, ObjectConstraint.class); if (startConstraint != null && isMethodParameter(symbol)) { String msg = IMPLIES_CAN_BE_MSG; if (ObjectConstraint.NOT_NULL == startConstraint) { msg = "Implies '%s' can not be %s."; } flowBuilder.add(new JavaFileScannerContext.Location(String.format(msg, symbol.name(), "null"), ((VariableTree) symbol.declaration()).simpleName())); } }); return flowBuilder.build(); }
private boolean assignedFromYieldWithUncertainResult(Constraint constraint, Node node) { return node.edges().stream().noneMatch(edge -> isConstraintOnlyPossibleResult(constraint, edge)); }
private boolean assignedFromYieldWithUncertainResult(Constraint constraint, Node node) { return node.edges().stream().noneMatch(edge -> isConstraintOnlyPossibleResult(constraint, edge)); }
void reportOnExceptionalYield(ExplodedGraph.Node node, SECheck check) { node.edges().stream().forEach(edge -> edge.yields().stream() .filter(yield -> yield.generatedByCheck(check)) .forEach(yield -> reportIssue(edge.parent(), (ExceptionalCheckBasedYield) yield, check)) ); }
void reportOnExceptionalYield(ExplodedGraph.Node node, SECheck check) { node.edges().stream().forEach(edge -> edge.yields().stream() .filter(yield -> yield.generatedByCheck(check)) .forEach(yield -> reportIssue(edge.parent(), (ExceptionalCheckBasedYield) yield, check)) ); }