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;
}
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);
}
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);
}
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);
}
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;
}
Aggregations