Package edu.umd.cs.findbugs.ba

Examples of edu.umd.cs.findbugs.ba.Edge


        // of the basic block, and mark each exception edge
        // with the set of exceptions which can be propagated
        // along the edge.

        int exceptionEdgeCount = 0;
        Edge lastExceptionEdge = null;

        for (Iterator<Edge> i = cfg.outgoingEdgeIterator(basicBlock); i.hasNext();) {
            Edge e = i.next();
            if (e.isExceptionEdge()) {
                exceptionEdgeCount++;
                lastExceptionEdge = e;
            }
        }

        if (exceptionEdgeCount == 0) {
            // System.out.println("Shouldn't all blocks have an exception edge");
            return;
        }
        // Compute exceptions that can be thrown by the
        // basic block.
        cachedExceptionSet = computeBlockExceptionSet(basicBlock, result);

        if (exceptionEdgeCount == 1) {
            cachedExceptionSet.setEdgeExceptionSet(lastExceptionEdge, cachedExceptionSet.getExceptionSet());
            return;
        }

        // For each outgoing exception edge, compute exceptions
        // that can be thrown. This assumes that the exception
        // edges are enumerated in decreasing order of priority.
        // In the process, this will remove exceptions from
        // the thrown exception set.
        ExceptionSet thrownExceptionSet = cachedExceptionSet.getExceptionSet();
        if (!thrownExceptionSet.isEmpty()) {
            thrownExceptionSet = thrownExceptionSet.duplicate();
        }
        for (Iterator<Edge> i = cfg.outgoingEdgeIterator(basicBlock); i.hasNext();) {
            Edge edge = i.next();
            if (edge.isExceptionEdge()) {
                cachedExceptionSet.setEdgeExceptionSet(edge, computeEdgeExceptionSet(edge, thrownExceptionSet));
            }
        }
    }
View Full Code Here


        if (isParameter && !wouldHaveBeenAKaboom) {
            return;
        }
        boolean createdDeadCode = false;
        boolean infeasibleEdgeSimplyThrowsException = false;
        Edge infeasibleEdge = redundantBranch.infeasibleEdge;
        if (infeasibleEdge != null) {
            if (DEBUG) {
                System.out.println("Check if " + redundantBranch + " creates dead code");
            }
            BasicBlock target = infeasibleEdge.getTarget();

            if (DEBUG) {
                System.out.println("Target block is  "
                        + (target.isExceptionThrower() ? " exception thrower" : " not exception thrower"));
            }
View Full Code Here

                // Try to advance to the successors of this basic block,
                // ignoring loop backedges.
                Iterator<Edge> i = cfg.outgoingEdgeIterator(state.getBasicBlock());
                BitSet visitedSuccessorSet = new BitSet();
                while (i.hasNext()) {
                    Edge edge = i.next();
                    if (dfs.getDFSEdgeType(edge) == BACK_EDGE) {
                        continue;
                    }

                    BasicBlock destBlock = edge.getTarget();
                    int destId = destBlock.getLabel();

                    // CFGs can have duplicate edges
                    if (visitedSuccessorSet.get(destId)) {
                        continue;
View Full Code Here

        boolean changed = false;
        boolean ASSUME_ASSERTIONS_ENABLED = true;
        if (ASSUME_ASSERTIONS_ENABLED) {
            LinkedList<Edge> edgesToRemove = new LinkedList<Edge>();
            for (Iterator<Edge> i = cfg.edgeIterator(); i.hasNext();) {
                Edge e = i.next();
                if (e.getType() == EdgeTypes.IFCMP_EDGE) {
                    try {
                        BasicBlock source = e.getSource();
                        InstructionHandle last = source.getLastInstruction();
                        Instruction lastInstruction = last.getInstruction();
                        InstructionHandle prev = last.getPrev();
                        Instruction prevInstruction = prev.getInstruction();
                        if (prevInstruction instanceof GETSTATIC && lastInstruction instanceof IFNE) {
                            GETSTATIC getStatic = (GETSTATIC) prevInstruction;

                            if (getStatic.getFieldName(methodGen.getConstantPool()).equals("$assertionsDisabled")
                                    && getStatic.getSignature(methodGen.getConstantPool()).equals("Z")) {
                                edgesToRemove.add(e);
                            }
                        }
                    } catch (RuntimeException exception) {
                        assert true; // ignore it
                    }
                }
            }
            if (edgesToRemove.size() > 0) {
                changed = true;
                for (Edge e : edgesToRemove) {
                    cfg.removeEdge(e);
                }
            }
        }
        cfg.setFlag(CFG.PRUNED_FAILED_ASSERTION_EDGES);

        final boolean PRUNE_INFEASIBLE_EXCEPTION_EDGES = AnalysisContext.currentAnalysisContext().getBoolProperty(
                AnalysisFeatures.ACCURATE_EXCEPTIONS);

        if (PRUNE_INFEASIBLE_EXCEPTION_EDGES && !cfg.isFlagSet(CFG.PRUNED_INFEASIBLE_EXCEPTIONS)) {
            try {
                TypeDataflow typeDataflow = analysisCache.getMethodAnalysis(TypeDataflow.class, descriptor);
                // Exception edge pruning based on ExceptionSets.
                // Note: this is quite slow.
                PruneInfeasibleExceptionEdges pruner = new PruneInfeasibleExceptionEdges(cfg, methodGen, typeDataflow);
                pruner.execute();
                changed = changed || pruner.wasCFGModified();
            } catch (MissingClassException e) {
                AnalysisContext.currentAnalysisContext().getLookupFailureCallback()
                .reportMissingClass(e.getClassNotFoundException());
            } catch (DataflowAnalysisException e) {
                AnalysisContext.currentAnalysisContext().getLookupFailureCallback()
                .logError("unable to extract type analysis", e);
            } catch (ClassNotFoundException e) {
                AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e);
View Full Code Here

    private void findIfElseDuplicates(CFG cfg, Method method, BasicBlock bb) {
        BasicBlock thenBB = null, elseBB = null;

        Iterator<Edge> iei = cfg.outgoingEdgeIterator(bb);
        while (iei.hasNext()) {
            Edge e = iei.next();
            if (e.getType() == EdgeTypes.IFCMP_EDGE) {
                elseBB = e.getTarget();
            } else if (e.getType() == EdgeTypes.FALL_THROUGH_EDGE) {
                thenBB = e.getTarget();
            }
        }

        if ((thenBB == null) || (elseBB == null)) {
            return;
View Full Code Here

        if (ih != null) {
            return ih;
        }
        Iterator<Edge> iei = cfg.outgoingEdgeIterator(bb);
        while (iei.hasNext()) {
            Edge e = iei.next();
            String edgeString = e.toString();
            if (EdgeTypes.FALL_THROUGH_EDGE == e.getType()) {
                return getDeepFirstInstruction(cfg, e.getTarget());
            }
        }
        return null;
    }
View Full Code Here

        Iterator<Edge> iei = cfg.outgoingEdgeIterator(bb);
        int idx = 0;

        while (iei.hasNext()) {
            Edge e = iei.next();
            int eType = e.getType();
            if (eType == EdgeTypes.SWITCH_EDGE || eType == EdgeTypes.SWITCH_DEFAULT_EDGE) {
                BasicBlock target = e.getTarget();
                InstructionHandle firstIns = getDeepFirstInstruction(cfg, target);
                if (firstIns == null)
                {
                    continue; // give up on this edge
                }
View Full Code Here

            BasicBlock bb = bbi.next();
            InstructionHandle last = bb.getLastInstruction(); // may be null
            if (prevs.contains(last)) { // danger will robinson
                Iterator<Edge> iei = cfg.outgoingEdgeIterator(bb);
                while (iei.hasNext()) {
                    Edge e = iei.next();
                    int eType = e.getType();
                    String aab = e.toString();
                    if (eType == EdgeTypes.GOTO_EDGE) {
                        BasicBlock target = e.getTarget();
                        InstructionHandle targetFirst = getDeepFirstInstruction(cfg, target);
                        if (targetFirst != null) {
                            int targetPos = targetFirst.getPosition();
                            if (targetPos > maxGoto) {
                                maxGoto = targetPos;
View Full Code Here

    private InstructionHandle findThenFinish(CFG cfg, BasicBlock thenBB, int elsePos) {
        InstructionHandle inst = thenBB.getFirstInstruction();
        while (inst == null) {
            Iterator<Edge> ie = cfg.outgoingEdgeIterator(thenBB);
            while (ie.hasNext()) {
                Edge e = ie.next();
                if (e.getType() == EdgeTypes.FALL_THROUGH_EDGE) {
                    thenBB = e.getTarget();
                    break;
                }
            }
            inst = thenBB.getFirstInstruction();
        }
View Full Code Here

    public void checkEdges(CFG cfg, Map<ValueNumber, NullValueUnconditionalDeref> nullValueGuaranteedDerefMap,
            Map<ValueNumber, SortedSet<Location>> bugEdgeLocationMap) throws DataflowAnalysisException {
        // Check every non-exception control edge
        for (Iterator<Edge> i = cfg.edgeIterator(); i.hasNext();) {
            Edge edge = i.next();

            UnconditionalValueDerefSet uvdFact = uvdDataflow.getFactOnEdge(edge);

            if (uvdFact.isEmpty()) {
                continue;
            }

            if (edge.isExceptionEdge()) {
                if (DEBUG_DEREFS) {
                    System.out.println("On exception edge " + edge.formatAsString(false));
                }

                // continue;
            }

            if (DEBUG_DEREFS) {
                System.out.println("On edge " + edge.formatAsString(false));
            }

            BasicBlock source = edge.getSource();
            ValueNumberFrame vnaFact = vnaDataflow.getResultFact(source);
            IsNullValueFrame invFact = invDataflow.getFactAtMidEdge(edge);

            Location location = null;
            if (edge.isExceptionEdge()) {
                BasicBlock b = cfg.getSuccessorWithEdgeType(source, EdgeTypes.FALL_THROUGH_EDGE);
                if (b != null) {
                    location = new Location(source.getExceptionThrower(), b);
                }
            } else {
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.ba.Edge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.