Search in sources :

Example 26 with CFValue

use of org.checkerframework.framework.flow.CFValue in project checker-framework by typetools.

the class LowerBoundTransfer method visitNumericalSubtraction.

@Override
public TransferResult<CFValue, CFStore> visitNumericalSubtraction(NumericalSubtractionNode n, TransferInput<CFValue, CFStore> p) {
    TransferResult<CFValue, CFStore> result = super.visitNumericalSubtraction(n, p);
    AnnotationMirror newAnno = getAnnotationForMinus(n, p);
    return createNewResult(result, newAnno);
}
Also used : CFValue(org.checkerframework.framework.flow.CFValue) AnnotationMirror(javax.lang.model.element.AnnotationMirror) CFStore(org.checkerframework.framework.flow.CFStore)

Example 27 with CFValue

use of org.checkerframework.framework.flow.CFValue in project checker-framework by typetools.

the class LowerBoundTransfer method visitNumericalAddition.

@Override
public TransferResult<CFValue, CFStore> visitNumericalAddition(NumericalAdditionNode n, TransferInput<CFValue, CFStore> p) {
    TransferResult<CFValue, CFStore> result = super.visitNumericalAddition(n, p);
    AnnotationMirror newAnno = getAnnotationForPlus(n, p);
    return createNewResult(result, newAnno);
}
Also used : CFValue(org.checkerframework.framework.flow.CFValue) AnnotationMirror(javax.lang.model.element.AnnotationMirror) CFStore(org.checkerframework.framework.flow.CFStore)

Example 28 with CFValue

use of org.checkerframework.framework.flow.CFValue in project checker-framework by typetools.

the class LowerBoundTransfer method visitBitwiseAnd.

@Override
public TransferResult<CFValue, CFStore> visitBitwiseAnd(BitwiseAndNode n, TransferInput<CFValue, CFStore> p) {
    TransferResult<CFValue, CFStore> transferResult = super.visitBitwiseAnd(n, p);
    AnnotationMirror resultAnno = getAnnotationForAnd(n, p);
    return createNewResult(transferResult, resultAnno);
}
Also used : CFValue(org.checkerframework.framework.flow.CFValue) AnnotationMirror(javax.lang.model.element.AnnotationMirror) CFStore(org.checkerframework.framework.flow.CFStore)

Example 29 with CFValue

use of org.checkerframework.framework.flow.CFValue in project checker-framework by typetools.

the class UpperBoundAnnotatedTypeFactory method fromLessThanOrEqual.

private UBQualifier fromLessThanOrEqual(Tree tree, TreePath treePath, List<String> lessThanExpressions) {
    UBQualifier ubQualifier = null;
    for (String expression : lessThanExpressions) {
        FlowExpressions.Receiver receiver;
        try {
            receiver = getReceiverFromJavaExpressionString(expression, treePath);
        } catch (FlowExpressionParseException e) {
            receiver = null;
        }
        if (receiver == null || !CFAbstractStore.canInsertReceiver(receiver)) {
            continue;
        }
        CFStore store = getStoreBefore(tree);
        if (store != null) {
            CFValue value = store.getValue(receiver);
            if (value != null && value.getAnnotations().size() == 1) {
                UBQualifier newUBQ = UBQualifier.createUBQualifier(value.getAnnotations().iterator().next());
                if (ubQualifier == null) {
                    ubQualifier = newUBQ;
                } else {
                    ubQualifier = ubQualifier.glb(newUBQ);
                }
            }
        }
    }
    return ubQualifier;
}
Also used : CFValue(org.checkerframework.framework.flow.CFValue) CFStore(org.checkerframework.framework.flow.CFStore) FlowExpressions(org.checkerframework.dataflow.analysis.FlowExpressions) FlowExpressionParseException(org.checkerframework.framework.util.FlowExpressionParseUtil.FlowExpressionParseException)

Example 30 with CFValue

use of org.checkerframework.framework.flow.CFValue in project checker-framework by typetools.

the class UpperBoundTransfer method visitFieldAccess.

/**
 * If n is an array length field access, then the type of a.length is the glb
 * of @LTEqLengthOf("a") and the value of a.length in the store. This is case 19.
 */
@Override
public TransferResult<CFValue, CFStore> visitFieldAccess(FieldAccessNode n, TransferInput<CFValue, CFStore> in) {
    if (NodeUtils.isArrayLengthFieldAccess(n)) {
        FieldAccess arrayLength = FlowExpressions.internalReprOfFieldAccess(atypeFactory, n);
        Receiver arrayRec = arrayLength.getReceiver();
        Tree arrayTree = n.getReceiver().getTree();
        TransferResult<CFValue, CFStore> result = visitLengthAccess(n, in, arrayRec, arrayTree);
        if (result != null) {
            return result;
        }
    }
    return super.visitFieldAccess(n, in);
}
Also used : CFValue(org.checkerframework.framework.flow.CFValue) CFStore(org.checkerframework.framework.flow.CFStore) Receiver(org.checkerframework.dataflow.analysis.FlowExpressions.Receiver) Tree(com.sun.source.tree.Tree) FieldAccess(org.checkerframework.dataflow.analysis.FlowExpressions.FieldAccess)

Aggregations

CFValue (org.checkerframework.framework.flow.CFValue)54 CFStore (org.checkerframework.framework.flow.CFStore)41 AnnotationMirror (javax.lang.model.element.AnnotationMirror)39 Receiver (org.checkerframework.dataflow.analysis.FlowExpressions.Receiver)9 ArrayList (java.util.ArrayList)6 MethodInvocationNode (org.checkerframework.dataflow.cfg.node.MethodInvocationNode)6 Node (org.checkerframework.dataflow.cfg.node.Node)6 TypeMirror (javax.lang.model.type.TypeMirror)5 ConditionalTransferResult (org.checkerframework.dataflow.analysis.ConditionalTransferResult)5 RegularTransferResult (org.checkerframework.dataflow.analysis.RegularTransferResult)5 ArrayLenRange (org.checkerframework.common.value.qual.ArrayLenRange)4 Range (org.checkerframework.common.value.util.Range)4 FieldAccess (org.checkerframework.dataflow.analysis.FlowExpressions.FieldAccess)4 ExecutableElement (javax.lang.model.element.ExecutableElement)3 FlowExpressions (org.checkerframework.dataflow.analysis.FlowExpressions)3 ArrayCreationNode (org.checkerframework.dataflow.cfg.node.ArrayCreationNode)3 AssignmentNode (org.checkerframework.dataflow.cfg.node.AssignmentNode)3 ClassNameNode (org.checkerframework.dataflow.cfg.node.ClassNameNode)3 FieldAccessNode (org.checkerframework.dataflow.cfg.node.FieldAccessNode)3 GreaterThanNode (org.checkerframework.dataflow.cfg.node.GreaterThanNode)3