private void initialize(CFG.Block block, Map<Tree, CFGLoop> container) { Block loopFirstBlock = block.trueBlock(); if (loopFirstBlock == null) { // Special case where no condition is given in FOR loop: only one successor specified loopFirstBlock = block.successors().iterator().next(); } collectBlocks(loopFirstBlock, container); successors.addAll(block.successors()); successors.remove(block.falseBlock()); collectWaysOut(container); }
private void initialize(CFG.Block block, Map<Tree, CFGLoop> container) { Block loopFirstBlock = block.trueBlock(); if (loopFirstBlock == null) { // Special case where no condition is given in FOR loop: only one successor specified loopFirstBlock = block.successors().iterator().next(); } collectBlocks(loopFirstBlock, container); successors.addAll(block.successors()); successors.remove(block.falseBlock()); collectWaysOut(container); }
@CheckForNull private static Set<Block> localSuccessors(CFG.Block block, Map<Tree, CFGLoop> container) { if (isStarting(block)) { CFGLoop loop = container.get(block.terminator()); if (loop == null) { loop = create(block, container); } Set<Block> loopSuccessors = new HashSet<>(loop.successors); if (block.trueBlock() == null) { // Special case where no condition is given in FOR loop: only one successor specified return null; } else { loopSuccessors.add(block.falseBlock()); } return loopSuccessors; } return block.successors(); }
private void handleBranch(CFG.Block programPosition, Tree condition, boolean checkPath) { Pair<List<ProgramState>, List<ProgramState>> pair = constraintManager.assumeDual(programState); ProgramPoint falseBlockProgramPoint = new ProgramPoint(programPosition.falseBlock()); for (ProgramState state : pair.a) { ProgramState ps = state;
private void handleBranch(CFG.Block programPosition, Tree condition, boolean checkPath) { Pair<List<ProgramState>, List<ProgramState>> pair = constraintManager.assumeDual(programState); ProgramPoint falseBlockProgramPoint = new ProgramPoint(programPosition.falseBlock()); for (ProgramState state : pair.a) { ProgramState ps = state;
public void enqueue(ProgramPoint newProgramPoint, ProgramState programState, boolean exitPath, @Nullable MethodYield methodYield) { ProgramPoint programPoint = newProgramPoint; int nbOfExecution = programState.numberOfTimeVisited(programPoint); if (nbOfExecution > MAX_EXEC_PROGRAM_POINT) { if (isRestartingForEachLoop(programPoint)) { // reached the max number of visit by program point, so take the false branch with current program state programPoint = new ProgramPoint(((CFG.Block) programPoint.block).falseBlock()); } else { debugPrint(programPoint); return; } } checkExplodedGraphTooBig(programState); ProgramState ps = programState.visitedPoint(programPoint, nbOfExecution + 1); ExplodedGraph.Node cachedNode = explodedGraph.node(programPoint, ps); if (!cachedNode.isNew() && exitPath == cachedNode.exitPath) { // has been enqueued earlier cachedNode.addParent(node, methodYield); return; } cachedNode.exitPath = exitPath; cachedNode.addParent(node, methodYield); workList.addFirst(cachedNode); }
public void enqueue(ProgramPoint newProgramPoint, ProgramState programState, boolean exitPath, @Nullable MethodYield methodYield) { ProgramPoint programPoint = newProgramPoint; int nbOfExecution = programState.numberOfTimeVisited(programPoint); if (nbOfExecution > MAX_EXEC_PROGRAM_POINT) { if (isRestartingForEachLoop(programPoint)) { // reached the max number of visit by program point, so take the false branch with current program state programPoint = new ProgramPoint(((CFG.Block) programPoint.block).falseBlock()); } else { debugPrint(programPoint); return; } } checkExplodedGraphTooBig(programState); ProgramState ps = programState.visitedPoint(programPoint, nbOfExecution + 1); ExplodedGraph.Node cachedNode = explodedGraph.node(programPoint, ps); if (!cachedNode.isNew() && exitPath == cachedNode.exitPath) { // has been enqueued earlier cachedNode.addParent(node, methodYield); return; } cachedNode.exitPath = exitPath; cachedNode.addParent(node, methodYield); workList.addFirst(cachedNode); }
private void handleBranch(CFG.Block programPosition, Tree condition, boolean checkPath) { Pair<List<ProgramState>, List<ProgramState>> pair = constraintManager.assumeDual(programState); ExplodedGraph.ProgramPoint falseBlockProgramPoint = new ExplodedGraph.ProgramPoint(programPosition.falseBlock(), 0); for (ProgramState state : pair.a) { // enqueue false-branch, if feasible ProgramState ps = state.stackValue(SymbolicValue.FALSE_LITERAL); enqueue(falseBlockProgramPoint, ps, node.exitPath); if (checkPath) { alwaysTrueOrFalseChecker.evaluatedToFalse(condition); } } ExplodedGraph.ProgramPoint trueBlockProgramPoint = new ExplodedGraph.ProgramPoint(programPosition.trueBlock(), 0); for (ProgramState state : pair.b) { ProgramState ps = state.stackValue(SymbolicValue.TRUE_LITERAL); // enqueue true-branch, if feasible enqueue(trueBlockProgramPoint, ps, node.exitPath); if (checkPath) { alwaysTrueOrFalseChecker.evaluatedToTrue(condition); } } }
@CheckForNull private static Set<Block> localSuccessors(CFG.Block block, Map<Tree, CFGLoop> container) { if (isStarting(block)) { CFGLoop loop = container.get(block.terminator()); if (loop == null) { loop = create(block, container); } Set<Block> loopSuccessors = new HashSet<>(loop.successors); if (block.trueBlock() == null) { // Special case where no condition is given in FOR loop: only one successor specified return null; } else { loopSuccessors.add(block.falseBlock()); } return loopSuccessors; } return block.successors(); }