use of org.checkerframework.framework.flow.CFStore 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);
}
use of org.checkerframework.framework.flow.CFStore 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);
}
use of org.checkerframework.framework.flow.CFStore 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;
}
use of org.checkerframework.framework.flow.CFStore 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);
}
use of org.checkerframework.framework.flow.CFStore in project checker-framework by typetools.
the class RegexTransfer method handleMatcherGroupCount.
/**
* See whether possibleMatcher is a call of groupCount on a Matcher and possibleConstant is a
* constant. If so, annotate the matcher as constant + 1 if !isAlsoEqual constant if isAlsoEqual
*
* @param possibleMatcher the Node that might be a call of Matcher.groupCount()
* @param possibleConstant the Node that might be a constant
* @param isAlsoEqual whether the comparison operation is strict or reflexive
* @param in the TransferInput
* @param resultIn TransferResult
* @return the possibly refined output TransferResult
*/
private TransferResult<CFValue, CFStore> handleMatcherGroupCount(Node possibleMatcher, Node possibleConstant, boolean isAlsoEqual, TransferInput<CFValue, CFStore> in, TransferResult<CFValue, CFStore> resultIn) {
if (!(possibleMatcher instanceof MethodInvocationNode)) {
return resultIn;
}
if (!(possibleConstant instanceof IntegerLiteralNode)) {
return resultIn;
}
MethodAccessNode methodAccessNode = ((MethodInvocationNode) possibleMatcher).getTarget();
ExecutableElement method = methodAccessNode.getMethod();
Node receiver = methodAccessNode.getReceiver();
if (!isMatcherGroupCountMethod(method, receiver)) {
return resultIn;
}
Receiver matcherReceiver = FlowExpressions.internalReprOf(analysis.getTypeFactory(), receiver);
IntegerLiteralNode iln = (IntegerLiteralNode) possibleConstant;
int groupCount;
if (isAlsoEqual) {
groupCount = iln.getValue();
} else {
groupCount = iln.getValue() + 1;
}
CFStore thenStore = resultIn.getRegularStore();
CFStore elseStore = thenStore.copy();
ConditionalTransferResult<CFValue, CFStore> newResult = new ConditionalTransferResult<>(resultIn.getResultValue(), thenStore, elseStore);
RegexAnnotatedTypeFactory factory = (RegexAnnotatedTypeFactory) analysis.getTypeFactory();
AnnotationMirror regexAnnotation = factory.createRegexAnnotation(groupCount);
thenStore.insertValue(matcherReceiver, regexAnnotation);
return newResult;
}
Aggregations