Package edu.umd.cs.findbugs.ba

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


     * @return a Location corresponding to the PC value, or null if no such
     *         Location can be found
     * @throws CFGBuilderException
     */
    private static Location pcToLocation(ClassContext classContext, Method method, int pc) throws CFGBuilderException {
        CFG cfg = classContext.getCFG(method);
        for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
            Location location = i.next();
            if (location.getHandle().getPosition() == pc) {
                return location;
            }
        }
View Full Code Here


     * @param node
     *            the CallGraphNode for the method to be scanned
     */
    private void scan(CallGraphNode node) throws CFGBuilderException {
        Method method = node.getMethod();
        CFG cfg = classContext.getCFG(method);

        if (method.isSynchronized()) {
            hasSynchronization = true;
        }

        Iterator<BasicBlock> i = cfg.blockIterator();
        while (i.hasNext()) {
            BasicBlock block = i.next();
            Iterator<InstructionHandle> j = block.instructionIterator();
            while (j.hasNext()) {
                InstructionHandle handle = j.next();
View Full Code Here

    private ResourceCollection<Resource> buildResourceCollection(ClassContext classContext, Method method,
            ResourceTrackerType resourceTracker) throws CFGBuilderException, DataflowAnalysisException {

        ResourceCollection<Resource> resourceCollection = new ResourceCollection<Resource>();

        CFG cfg = classContext.getCFG(method);
        ConstantPoolGen cpg = classContext.getConstantPoolGen();

        for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
            Location location = i.next();
            Resource resource = resourceTracker.isResourceCreation(location.getBasicBlock(), location.getHandle(), cpg);
            if (resource != null) {
                resourceCollection.addCreatedResource(location, resource);
            }
View Full Code Here

    }

    private boolean mightCloseResource(ClassContext classContext, Method method, ResourceTrackerType resourceTracker)
            throws CFGBuilderException, DataflowAnalysisException {

        CFG cfg = classContext.getCFG(method);
        ConstantPoolGen cpg = classContext.getConstantPoolGen();

        for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
            Location location = i.next();
            if (resourceTracker.mightCloseResource(location.getBasicBlock(), location.getHandle(), cpg)) {
                return true;
            }
View Full Code Here

        MethodGen methodGen = classContext.getMethodGen(method);
        if (methodGen == null) {
            return;
        }
        try {
            CFG cfg = classContext.getCFG(method);
            DepthFirstSearch dfs = classContext.getDepthFirstSearch(method);

            if (DEBUG) {
                System.out.println(SignatureConverter.convertMethodSignature(methodGen));
            }
View Full Code Here

    private void analyzeMethod(ClassContext classContext, Method method) {
        JavaClass jclass = classContext.getJavaClass();
        XMethod xmethod = XFactory.createXMethod(jclass, method);
        try {
            CFG cfg = classContext.getCFG(method);

            ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method);
            UnconditionalValueDerefDataflow dataflow = classContext.getUnconditionalValueDerefDataflow(method);

            SignatureParser parser = new SignatureParser(method.getSignature());
            int paramLocalOffset = method.isStatic() ? 0 : 1;

            // Build BitSet of params that are unconditionally dereferenced
            BitSet unconditionalDerefSet = new BitSet();
            UnconditionalValueDerefSet entryFact = dataflow.getResultFact(cfg.getEntry());
            Iterator<String> paramIterator = parser.parameterSignatureIterator();
            int i = 0;
            while (paramIterator.hasNext()) {
                String paramSig = paramIterator.next();
View Full Code Here

    protected int returnsNonNull;

    private void analyzeMethod(ClassContext classContext, Method method) {
        returnsReference++;
        try {
            CFG cfg = classContext.getCFG(method);

            IsNullValueDataflow inv = classContext.getIsNullValueDataflow(method);
            boolean guaranteedNonNull = true;
            for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
                Location location = i.next();
                InstructionHandle handle = location.getHandle();
                Instruction ins = handle.getInstruction();

                if (!(ins instanceof ARETURN)) {
View Full Code Here

        LinkedList<WarningWithProperties> refComparisonList = new LinkedList<WarningWithProperties>();
        LinkedList<WarningWithProperties> stringComparisonList = new LinkedList<WarningWithProperties>();


        comparedForEqualityInThisMethod = new HashMap<String,Integer>();
        CFG cfg = classContext.getCFG(method);
        DepthFirstSearch dfs = classContext.getDepthFirstSearch(method);
        ExceptionSetFactory exceptionSetFactory = classContext.getExceptionSetFactory(method);

        // Perform type analysis using our special type merger
        // (which handles String types specially, keeping track of
        // which ones appear to be dynamically created)
        RefComparisonTypeMerger typeMerger = new RefComparisonTypeMerger(bugReporter, exceptionSetFactory);
        RefComparisonTypeFrameModelingVisitor visitor = new RefComparisonTypeFrameModelingVisitor(methodGen.getConstantPool(),
                typeMerger, bugReporter);
        TypeAnalysis typeAnalysis = new SpecialTypeAnalysis(method, methodGen, cfg, dfs, typeMerger, visitor, bugReporter,
                exceptionSetFactory);
        TypeDataflow typeDataflow = new TypeDataflow(cfg, typeAnalysis);
        Profiler profiler = Global.getAnalysisCache().getProfiler();
        profiler.start(SpecialTypeAnalysis.class);
        try {
            typeDataflow.execute();
        } finally {
            profiler.end(SpecialTypeAnalysis.class);
        }

        // Inspect Locations in the method for suspicious ref comparisons and
        // calls to equals()
        for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
            Location location = i.next();

            inspectLocation(jclass, cpg, method, methodGen, refComparisonList, stringComparisonList, visitor, typeDataflow,
                    location);
        }
View Full Code Here

TOP

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

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.