Package edu.umd.cs.findbugs.ba

Examples of edu.umd.cs.findbugs.ba.BasicBlock$InstructionIterator


    private void examineBasicBlocks() throws DataflowAnalysisException, CFGBuilderException {
        // Look for null check blocks where the reference being checked
        // is definitely null, or null on some path
        Iterator<BasicBlock> bbIter = invDataflow.getCFG().blockIterator();
        while (bbIter.hasNext()) {
            BasicBlock basicBlock = bbIter.next();

            if (basicBlock.isNullCheck()) {
                analyzeNullCheck(invDataflow, basicBlock);
            } else if (!basicBlock.isEmpty()) {
                // Look for all reference comparisons where
                // - both values compared are definitely null, or
                // - one value is definitely null and one is definitely not null
                // These cases are not null dereferences,
                // but they are quite likely to indicate an error, so while
                // we've got
                // information about null values, we may as well report them.
                InstructionHandle lastHandle = basicBlock.getLastInstruction();
                Instruction last = lastHandle.getInstruction();
                switch (last.getOpcode()) {
                case Constants.IF_ACMPEQ:
                case Constants.IF_ACMPNE:
                    analyzeRefComparisonBranch(basicBlock, lastHandle);
View Full Code Here


            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 {
                location = Location.getLastLocation(source);
View Full Code Here

        Iterator<BasicBlock> bbIter = invDataflow.getCFG().blockIterator();
        LineNumberTable table = method.getLineNumberTable();
        int position = exceptionThrowerHandle.getPosition();
        int line = table == null ? 0 : table.getSourceLine(position);
        while (bbIter.hasNext()) {
            BasicBlock bb = bbIter.next();

            if (!bb.isNullCheck()) {
                continue;
            }

            InstructionHandle eth = bb.getExceptionThrower();
            if (eth == exceptionThrowerHandle) {
                continue;
            }
            if (eth.getInstruction().getOpcode() != exceptionThrower.getOpcode()) {
                continue;
View Full Code Here

        // annotations on the method parameters.
        if (xmethod.isIdentity()) {
            return;
        }

        BasicBlock entry = dataflow.getCFG().getEntry();
        TypeQualifierValueSet entryFact = dataflow.getAnalysis().getResultFact(entry);

        for (int i = 0; i < xmethod.getNumParams(); i++) {
            if (TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(xmethod, i, tqv) != null) {
                // this parameter already has an explicit annotation
View Full Code Here

     */
    private BitSet findPreviouslyDeadBlocks() throws DataflowAnalysisException, CFGBuilderException {
        BitSet deadBlocks = new BitSet();
        ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method);
        for (Iterator<BasicBlock> i = vnaDataflow.getCFG().blockIterator(); i.hasNext();) {
            BasicBlock block = i.next();
            ValueNumberFrame vnaFrame = vnaDataflow.getStartFact(block);
            if (vnaFrame.isTop()) {
                deadBlocks.set(block.getLabel());
            }
        }

        return deadBlocks;
    }
View Full Code Here

        Location loc = startLocation;
        InstructionHandle prev = getPreviousInstruction(loc.getHandle(), skipNops);
        if (prev != null) {
            return new Location(prev, loc.getBasicBlock());
        }
        BasicBlock block = loc.getBasicBlock();
        while (true) {
            block = cfg.getPredecessorWithEdgeType(block, EdgeTypes.FALL_THROUGH_EDGE);
            if (block == null) {
                return null;
            }
            InstructionHandle lastInstruction = block.getLastInstruction();
            if (lastInstruction != null) {
                return new Location(lastInstruction, block);
            }
        }
    }
View Full Code Here

        ConstantPoolGen cpg = classContext.getConstantPoolGen();
        TypeDataflow typeDataflow = classContext.getTypeDataflow(method);

        for (Iterator<BasicBlock> i = cfg.blockIterator(); i.hasNext();) {
            BasicBlock basicBlock = i.next();

            // Check if it's a method invocation.
            if (!basicBlock.isExceptionThrower()) {
                continue;
            }
            InstructionHandle thrower = basicBlock.getExceptionThrower();
            Instruction ins = thrower.getInstruction();
            if (!(ins instanceof InvokeInstruction)) {
                continue;
            }
View Full Code Here

        }

    }

    private Location getEdgeTargetLocation(CFG cfg, Edge edge) {
        BasicBlock targetBlock = edge.getTarget();

        // Target block is nonempty?
        if (targetBlock.getFirstInstruction() != null) {
            return new Location(targetBlock.getFirstInstruction(), targetBlock);
        }

        // Target block is an ETB?
        if (targetBlock.isExceptionThrower()) {
            BasicBlock fallThroughSuccessor = cfg.getSuccessorWithEdgeType(targetBlock, EdgeTypes.FALL_THROUGH_EDGE);
            if (fallThroughSuccessor == null) {
                // Fall through edge might have been pruned
                for (Iterator<Edge> i = cfg.removedEdgeIterator(); i.hasNext();) {
                    Edge removedEdge = i.next();
                    if (removedEdge.getSource() == targetBlock && removedEdge.getType() == EdgeTypes.FALL_THROUGH_EDGE) {
                        fallThroughSuccessor = removedEdge.getTarget();
                        break;
                    }
                }
            }

            if (fallThroughSuccessor != null && fallThroughSuccessor.getFirstInstruction() != null) {
                return new Location(fallThroughSuccessor.getFirstInstruction(), fallThroughSuccessor);
            }
        }

        return null;
    }
View Full Code Here

        return null;
    }

    private Location getEdgeSourceLocation(CFG cfg, Edge edge) {
        BasicBlock sourceBlock = edge.getSource();
        return (sourceBlock.getLastInstruction() != null) ? new Location(sourceBlock.getLastInstruction(), sourceBlock) : null;
    }
View Full Code Here

    public void execute(InstructionScannerGenerator generator) {
        // Pump the instructions in the path through the generator and all
        // generated scanners
        while (edgeIter.hasNext()) {
            Edge edge = edgeIter.next();
            BasicBlock source = edge.getSource();
            if (DEBUG) {
                System.out.println("ISD: scanning instructions in block " + source.getLabel());
            }

            // Traverse all instructions in the source block
            Iterator<InstructionHandle> i = source.instructionIterator();
            int count = 0;
            while (i.hasNext()) {
                InstructionHandle handle = i.next();

                // Check if the generator wants to create a new scanner
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.ba.BasicBlock$InstructionIterator

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.