Search in sources :

Example 26 with CFStore

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

the class FormatterTransfer method visitMethodInvocation.

/**
 * Makes it so that the {@link FormatUtil#asFormat} method returns a correctly annotated String.
 */
@Override
public TransferResult<CFValue, CFStore> visitMethodInvocation(MethodInvocationNode node, TransferInput<CFValue, CFStore> in) {
    FormatterAnnotatedTypeFactory atypeFactory = (FormatterAnnotatedTypeFactory) analysis.getTypeFactory();
    TransferResult<CFValue, CFStore> result = super.visitMethodInvocation(node, in);
    FormatterTreeUtil tu = atypeFactory.treeUtil;
    if (tu.isAsFormatCall(node, atypeFactory)) {
        Result<ConversionCategory[]> cats = tu.asFormatCallCategories(node);
        if (cats.value() == null) {
            tu.failure(cats, "format.asformat.indirect.arguments");
        } else {
            AnnotationMirror anno = atypeFactory.treeUtil.categoriesToFormatAnnotation(cats.value());
            CFValue newResultValue = analysis.createSingleAnnotationValue(anno, result.getResultValue().getUnderlyingType());
            return new RegularTransferResult<>(newResultValue, result.getRegularStore());
        }
    }
    return result;
}
Also used : CFValue(org.checkerframework.framework.flow.CFValue) AnnotationMirror(javax.lang.model.element.AnnotationMirror) CFStore(org.checkerframework.framework.flow.CFStore) RegularTransferResult(org.checkerframework.dataflow.analysis.RegularTransferResult)

Example 27 with CFStore

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

the class LowerBoundTransfer method visitIntegerDivision.

@Override
public TransferResult<CFValue, CFStore> visitIntegerDivision(IntegerDivisionNode n, TransferInput<CFValue, CFStore> p) {
    TransferResult<CFValue, CFStore> result = super.visitIntegerDivision(n, p);
    AnnotationMirror newAnno = getAnnotationForDivide(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 CFStore

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

the class LowerBoundTransfer method visitSignedRightShift.

@Override
public TransferResult<CFValue, CFStore> visitSignedRightShift(SignedRightShiftNode n, TransferInput<CFValue, CFStore> p) {
    TransferResult<CFValue, CFStore> transferResult = super.visitSignedRightShift(n, p);
    AnnotationMirror resultAnno = getAnnotationForRightShift(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 CFStore

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

the class LowerBoundTransfer method visitIntegerRemainder.

@Override
public TransferResult<CFValue, CFStore> visitIntegerRemainder(IntegerRemainderNode n, TransferInput<CFValue, CFStore> p) {
    TransferResult<CFValue, CFStore> transferResult = super.visitIntegerRemainder(n, p);
    AnnotationMirror resultAnno = getAnnotationForRemainder(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 30 with CFStore

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

the class LowerBoundTransfer method strengthenAnnotationOfEqualTo.

/**
 * Implements the transfer rules for both equal nodes and not-equals nodes (i.e. cases 5 and 6).
 */
@Override
protected TransferResult<CFValue, CFStore> strengthenAnnotationOfEqualTo(TransferResult<CFValue, CFStore> result, Node firstNode, Node secondNode, CFValue firstValue, CFValue secondValue, boolean notEqualTo) {
    result = super.strengthenAnnotationOfEqualTo(result, firstNode, secondNode, firstValue, secondValue, notEqualTo);
    IndexRefinementInfo rfi = new IndexRefinementInfo(result, analysis, secondNode, firstNode);
    if (rfi.leftAnno == null || rfi.rightAnno == null) {
        return result;
    }
    // There is also special processing to look
    // for literals on one side of the equals and a GTEN1 or NN on the other, so that
    // those types can be promoted in the branch where their values are not equal to certain
    // literals.
    CFStore notEqualsStore = notEqualTo ? rfi.thenStore : rfi.elseStore;
    notEqualToValue(rfi.left, rfi.right, rfi.rightAnno, notEqualsStore);
    notEqualToValue(rfi.right, rfi.left, rfi.leftAnno, notEqualsStore);
    return rfi.newResult;
}
Also used : CFStore(org.checkerframework.framework.flow.CFStore) IndexRefinementInfo(org.checkerframework.checker.index.IndexRefinementInfo)

Aggregations

CFStore (org.checkerframework.framework.flow.CFStore)45 CFValue (org.checkerframework.framework.flow.CFValue)41 AnnotationMirror (javax.lang.model.element.AnnotationMirror)31 MethodInvocationNode (org.checkerframework.dataflow.cfg.node.MethodInvocationNode)8 Node (org.checkerframework.dataflow.cfg.node.Node)8 Receiver (org.checkerframework.dataflow.analysis.FlowExpressions.Receiver)7 TypeMirror (javax.lang.model.type.TypeMirror)5 ConditionalTransferResult (org.checkerframework.dataflow.analysis.ConditionalTransferResult)5 AssignmentNode (org.checkerframework.dataflow.cfg.node.AssignmentNode)5 ArrayCreationNode (org.checkerframework.dataflow.cfg.node.ArrayCreationNode)4 FieldAccessNode (org.checkerframework.dataflow.cfg.node.FieldAccessNode)4 Tree (com.sun.source.tree.Tree)3 ExecutableElement (javax.lang.model.element.ExecutableElement)3 RegularTransferResult (org.checkerframework.dataflow.analysis.RegularTransferResult)3 ClassNameNode (org.checkerframework.dataflow.cfg.node.ClassNameNode)3 GreaterThanNode (org.checkerframework.dataflow.cfg.node.GreaterThanNode)3 GreaterThanOrEqualNode (org.checkerframework.dataflow.cfg.node.GreaterThanOrEqualNode)3 IntegerLiteralNode (org.checkerframework.dataflow.cfg.node.IntegerLiteralNode)3 LessThanNode (org.checkerframework.dataflow.cfg.node.LessThanNode)3 LessThanOrEqualNode (org.checkerframework.dataflow.cfg.node.LessThanOrEqualNode)3