Package edu.umd.cs.findbugs.ba.vna

Examples of edu.umd.cs.findbugs.ba.vna.ValueNumber


                Location loc = i.next();
                InstructionHandle handle = loc.getHandle();
                Instruction ins = handle.getInstruction();
                if (ins instanceof ReturnInstruction && !(ins instanceof RETURN)) {
                    ValueNumberFrame vnaFrame = vnaDataflow.getFactAtLocation(loc);
                    ValueNumber topVN = vnaFrame.getTopValue();

                    TypeQualifierValueSet flowSet = dataflow.getFactAtLocation(loc);
                    FlowValue topFlowValue = flowSet.getValue(topVN);

                    if (topFlowValue != null) {
View Full Code Here


        if (when == When.UNKNOWN && !typeQualifierValue.isStrictQualifier()) {
            return;
        }
        ValueNumberFrame vnaFrameAfterInstruction = vnaDataflow.getFactAfterLocation(location);
        if (vnaFrameAfterInstruction.isValid()) {
            ValueNumber tosValue = vnaFrameAfterInstruction.getTopValue();
            SourceSinkInfo sourceSinkInfo = new SourceSinkInfo(sourceSinkType, location, tosValue, when);
            sourceSinkInfo.setInterproc(interproc);
            sourceSinkInfo.setConstantValue(constantValue);
            registerSourceSink(sourceSinkInfo);
        }
View Full Code Here

            // Get the TypeQualifierAnnotation for this parameter
            SourceSinkInfo info;
            TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(xmethod, param,
                    typeQualifierValue);
            When when = (tqa != null) ? tqa.when : When.UNKNOWN;
            ValueNumber vn = vnaFrameAtEntry.getValue(slotOffset + firstParamSlot);
            info = new SourceSinkInfo(SourceSinkType.PARAMETER, cfg.getLocationAtEntry(), vn, when);
            info.setParameterAndLocal(param, slotOffset + firstParamSlot);
            registerSourceSink(info);

            param++;
View Full Code Here

    public void reportBugs(Map<ValueNumber, NullValueUnconditionalDeref> nullValueGuaranteedDerefMap,
            HashSet<ValueNumber> npeIfStatementCovered, Map<ValueNumber, SortedSet<Location>> bugLocationMap,
            Map<ValueNumber, Set<Location>> nullValueAssignmentMap) throws CFGBuilderException, DataflowAnalysisException {
        // Report
        for (Map.Entry<ValueNumber, NullValueUnconditionalDeref> e : nullValueGuaranteedDerefMap.entrySet()) {
            ValueNumber valueNumber = e.getKey();
            Set<Location> derefLocationSet = e.getValue().getDerefLocationSet();
            Set<Location> assignedNullLocationSet = nullValueAssignmentMap.get(valueNumber);
            if (assignedNullLocationSet == null) {
                if (DEBUG_DEREFS) {
                    String where = classContext.getJavaClass().getClassName() + "." + method.getName() + ":"
View Full Code Here

        }

        // See if there are any definitely-null values in the frame
        for (int j = 0; j < slots; j++) {
            IsNullValue isNullValue = invFrame.getValue(j);
            ValueNumber valueNumber = vnaFrame.getValue(j);
            if ((isNullValue.isDefinitelyNull() || isNullValue.isNullOnSomePath() && isNullValue.isReturnValue())
                    && (derefSet.isUnconditionallyDereferenced(valueNumber))) {
                if (MY_DEBUG) {
                    System.out.println("Found NP bug");
                    System.out.println("Location: " + thisLocation);
                    System.out.println("Value number frame: " + vnaFrame);
                    System.out.println("Value number: " + valueNumber);
                    System.out.println("IsNullValue frame: " + invFrame);
                    System.out.println("IsNullValue value: " + isNullValue);
                    System.out.println("Unconditional dere framef: " + derefSet);
                    System.out.println("Unconditionally dereferenced: " + derefSet.isUnconditionallyDereferenced(valueNumber));

                }
                Location where = thisLocation;
                if (!isEdge && isNullValue.isNullOnSomePath() && isNullValue.isReturnValue()) {
                    try {
                        where = classContext.getCFG(method).getPreviousLocation(where);
                    } catch (CFGBuilderException e) {
                        AnalysisContext.logError(
                                "Error looking for previous instruction to " + where + " in "
                                        + classContext.getFullyQualifiedMethodName(method), e);
                    }
                }
                noteUnconditionallyDereferencedNullValue(where, knownNullAndDoomedAt, nullValueGuaranteedDerefMap, derefSet,
                        isNullValue, valueNumber);
            }
        }

        // See if there are any known-null values in the heap that
        // will be dereferenced in the future.
        for (Map.Entry<ValueNumber, IsNullValue> entry : invFrame.getKnownValueMapEntrySet()) {
            ValueNumber valueNumber = entry.getKey();
            IsNullValue isNullValue = entry.getValue();
            if ((isNullValue.isDefinitelyNull() || isNullValue.isNullOnSomePath()
                    && (isNullValue.isReturnValue() || isNullValue.isFieldValue()))
                    && derefSet.isUnconditionallyDereferenced(valueNumber)) {
View Full Code Here

        // Get the value number
        ValueNumberFrame vnaFrame = classContext.getValueNumberDataflow(method).getStartFact(basicBlock);
        if (!vnaFrame.isValid()) {
            return;
        }
        ValueNumber valueNumber = vnaFrame.getInstance(exceptionThrower, classContext.getConstantPoolGen());
        Location location = new Location(exceptionThrowerHandle, basicBlock);
        if (DEBUG) {
            System.out.println("Warning: VN " + valueNumber + " invf: " + frame + " @ " + location);
        }
View Full Code Here

        FieldInstruction fieldIns;

        // The instruction must be GETFIELD or GETSTATIC
        if (ins instanceof GETFIELD) {
            fieldIns = (GETFIELD) ins;
            ValueNumber ref = before.getTopValue();
            field = new FieldVariable(ref, fieldIns.getClassName(cpg), fieldIns.getFieldName(cpg), fieldIns.getSignature(cpg));
        } else if (ins instanceof GETSTATIC) {
            fieldIns = (GETSTATIC) ins;
            field = new FieldVariable(fieldIns.getClassName(cpg), fieldIns.getFieldName(cpg), fieldIns.getSignature(cpg));
        } else {
View Full Code Here

                // this parameter already has an explicit annotation
                continue;
            }

            // Get the value number for this parameter
            ValueNumber paramVN = vnaDataflow.getAnalysis().getEntryValueForParameter(i);

            FlowValue paramFlowValue = entryFact.getValue(paramVN);
            if (paramFlowValue == FlowValue.ALWAYS || paramFlowValue == FlowValue.NEVER) {
                TypeQualifierDatabase tqdb = Global.getAnalysisCache().getDatabase(TypeQualifierDatabase.class);
                TypeQualifierAnnotation tqa = TypeQualifierAnnotation.getValue(tqv,
View Full Code Here

        isStrict = typeQualifierValue.isStrictQualifier();
    }

    public void modelSourceSink(SourceSinkInfo sourceSinkInfo) {
        assert sourceSinkInfo != null;
        ValueNumber vn = sourceSinkInfo.getValueNumber();
        FlowValue flowValue = FlowValue.flowValueFromWhen(sourceSinkInfo.getWhen());

        setValue(vn, flowValue);
        if (true) {
            switch (flowValue) {
View Full Code Here

                    continue;
                }
                if (frame.getStackDepth() - numConsumed < 0) {
                    throw new DataflowAnalysisException("Stack underflow", methodGen, handle);
                }
                ValueNumber ref = frame.getValue(frame.getNumSlots() - numConsumed);
                LockSet lockSet = dataflow.getFactAtLocation(location);
                int lockCount = lockSet.getLockCount(ref.getNumber());

                if (lockCount == 0) {
                    Collection<ValueNumber> lockedValueNumbers = lockSet.getLockedValueNumbers(frame);
                    boolean foundMatch = false;
                    for (ValueNumber v : lockedValueNumbers) {
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.ba.vna.ValueNumber

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.